Рефакторинг в Intellisense (#3328)
* Migrate from HashTable to Dictionary<string, string> (StandartDirectories variable) * Add check to register files for parsing only if they have supported extension * Delete legacy code in CodeCompletion.cs * Delete unnecessary fields in CodeCompletionController * Refactor compiling dependencies code in DomSyntaxTreeVisitor * Fix AddStandardNetNamespacesToUserScope check * Comment out uses *some type* support in Intellisense * Delete unused SemanticOptions in DomSyntaxTreeVisitor * Comment out unused NamespaceTypeScope
This commit is contained in:
parent
5996f4bbc2
commit
0626885b5f
|
|
@ -9,15 +9,13 @@ using PascalABCCompiler.Parsers;
|
|||
using PascalABCCompiler.Errors;
|
||||
using System.IO;
|
||||
using Languages.Facade;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
|
||||
namespace CodeCompletion
|
||||
{
|
||||
public class CodeCompletionController
|
||||
{
|
||||
public static LanguageProvider LanguageProvider = LanguageProvider.Instance;
|
||||
private string FileName;
|
||||
string Text;
|
||||
private static readonly LanguageProvider LanguageProvider = LanguageProvider.Instance;
|
||||
|
||||
public Dictionary<syntax_tree_node, string> docs = new Dictionary<syntax_tree_node, string>();
|
||||
// static bool parsers_loaded=false;
|
||||
public IParser Parser;
|
||||
|
|
@ -39,7 +37,7 @@ namespace CodeCompletion
|
|||
}
|
||||
|
||||
public static PascalABCCompiler.Compiler comp;// = new PascalABCCompiler.Compiler();
|
||||
public static Hashtable StandartDirectories = new Hashtable();
|
||||
public static Dictionary<string, string> StandartDirectories = new Dictionary<string, string>();
|
||||
public static Hashtable comp_modules = new Hashtable(StringComparer.OrdinalIgnoreCase);
|
||||
// public static Hashtable parsers = new Hashtable(StringComparer.OrdinalIgnoreCase);
|
||||
public static Dictionary<string, InterfaceUnitScope> pabcNamespaces = new Dictionary<string, InterfaceUnitScope>();
|
||||
|
|
@ -67,50 +65,26 @@ namespace CodeCompletion
|
|||
return currentLanguage?.Parser;
|
||||
}
|
||||
}
|
||||
|
||||
internal compilation_unit ParsersControllerGetCompilationUnit(string FileName, string Text, List<Error> ErrorsList, List<CompilerWarning> Warnings, bool compilingNotMainProgram)
|
||||
{
|
||||
ILanguage language = LanguageProvider.SelectLanguageByExtensionSafe(FileName);
|
||||
if (language == null)
|
||||
return null;
|
||||
Parser = language.Parser;
|
||||
|
||||
return Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal, compilingNotMainProgram);
|
||||
}
|
||||
|
||||
internal compilation_unit ParsersControllerGetCompilationUnitSpecial(string FileName, string Text, List<Error> ErrorsList, List<CompilerWarning> Warnings, bool compilingNotMainProgram)
|
||||
{
|
||||
ILanguage language = LanguageProvider.SelectLanguageByExtensionSafe(FileName);
|
||||
if (language == null)
|
||||
return null;
|
||||
|
||||
return Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Special, compilingNotMainProgram);
|
||||
}
|
||||
|
||||
public DomConverter Compile(string FileName, string Text)
|
||||
{
|
||||
this.Text = Text;
|
||||
this.FileName = FileName;
|
||||
List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
|
||||
List<Error> ErrorsList = new List<Error>();
|
||||
List<CompilerWarning> Warnings = new List<CompilerWarning>();
|
||||
PascalABCCompiler.SyntaxTree.compilation_unit cu = null;
|
||||
IDocParser docParser = null;
|
||||
string ext = Path.GetExtension(FileName);
|
||||
compilation_unit cu = null;
|
||||
|
||||
ILanguage currentLanguage = LanguageProvider.SelectLanguageByExtension(FileName);
|
||||
|
||||
Parser = currentLanguage.Parser;
|
||||
|
||||
try
|
||||
{
|
||||
cu = ParsersControllerGetCompilationUnit(FileName, Text, ErrorsList, Warnings, false);
|
||||
cu = Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal, false);
|
||||
|
||||
ErrorsList.Clear();
|
||||
|
||||
docParser = LanguageProvider.SelectLanguageByExtension(FileName).DocParser;
|
||||
if (currentLanguage.DocParser != null)
|
||||
BuildDocs(Text, cu, currentLanguage.DocParser);
|
||||
|
||||
if (docParser != null)
|
||||
{
|
||||
documentation_comment_list dt = docParser.BuildTree(Text);
|
||||
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
||||
if (cu != null)
|
||||
docs = docconst.Construct(cu, dt);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -131,32 +105,26 @@ namespace CodeCompletion
|
|||
|
||||
dconv.ConvertToDom(cu);
|
||||
}
|
||||
else
|
||||
// Попытка поменять текст программы ниже сработает только для PascalABC.NET
|
||||
else if (currentLanguage == LanguageProvider.MainLanguage)
|
||||
{
|
||||
|
||||
ErrorsList.Clear();
|
||||
Warnings.Clear();
|
||||
try
|
||||
{
|
||||
//cu = ParsersController.GetComilationUnit(file_name, Text+")))));end.",comp.CompilerOptions.ParserSearchPatchs,ErrorsList);
|
||||
//cu = ParsersControllerGetComilationUnit(file_name, get_temp_text(Text), ErrorsList, true);
|
||||
string tmp = ParsersHelper.GetModifiedProgramm(Text);
|
||||
if (tmp != null)
|
||||
{
|
||||
cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings, false);
|
||||
}
|
||||
if (comp_modules[FileName] == null)
|
||||
{
|
||||
if (cu == null)
|
||||
cu = get_fictive_unit(Text, FileName);
|
||||
cu = Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Special, false);
|
||||
}
|
||||
|
||||
ErrorsList.Clear();
|
||||
if (docParser != null)
|
||||
{
|
||||
documentation_comment_list dt = docParser.BuildTree(Text);
|
||||
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
||||
if (cu != null)
|
||||
docs = docconst.Construct(cu, dt);
|
||||
}
|
||||
Warnings.Clear();
|
||||
|
||||
if (currentLanguage.DocParser != null)
|
||||
BuildDocs(Text, cu, currentLanguage.DocParser);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -176,177 +144,88 @@ namespace CodeCompletion
|
|||
//ConvertToDom(cu);
|
||||
}
|
||||
|
||||
//vremenno, potom ubrat
|
||||
private compilation_unit get_fictive_unit(string s, string FileName)
|
||||
private void BuildDocs(string Text, compilation_unit cu, IDocParser docParser)
|
||||
{
|
||||
program_module prog = new program_module();
|
||||
int line = 1;
|
||||
int col = 1;
|
||||
for (int i = 0; i < s.Length; i++)
|
||||
if (s[i] == '\n')
|
||||
{
|
||||
line++;
|
||||
col = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
col++;
|
||||
}
|
||||
prog.source_context = new SourceContext(1, 1, line + 3, 3);
|
||||
prog.program_block = new block();
|
||||
prog.file_name = FileName;
|
||||
statement_list sl = new statement_list();
|
||||
prog.program_block.program_code = sl;
|
||||
prog.program_block.program_code.left_logical_bracket = new token_info("begin");
|
||||
prog.program_block.program_code.left_logical_bracket.source_context = new SourceContext(1, 1, 1, 5);
|
||||
prog.program_block.program_code.right_logical_bracket = new token_info("end");
|
||||
prog.program_block.program_code.right_logical_bracket.source_context = new SourceContext(line + 3, 1, line + 3, 3);
|
||||
sl.subnodes.Add(new empty_statement());
|
||||
return prog;
|
||||
}
|
||||
|
||||
public PascalABCCompiler.SyntaxTree.compilation_unit ParseOnlySyntaxTree(string FileName, string Text)
|
||||
{
|
||||
List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
|
||||
List<CompilerWarning> Warnings = new List<CompilerWarning>();
|
||||
PascalABCCompiler.SyntaxTree.compilation_unit cu = ParsersControllerGetCompilationUnit(FileName, Text, ErrorsList, Warnings, false);
|
||||
return cu;
|
||||
}
|
||||
|
||||
/*public DomConverter CompileAllIfNeed(string FileName, string Text)
|
||||
{
|
||||
DomConverter dconv = (DomConverter)comp_modules[FileName];
|
||||
if (dconv != null) return dconv;
|
||||
this.Text = Text;
|
||||
this.FileName = FileName;
|
||||
string ext = Path.GetExtension(FileName);
|
||||
List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
|
||||
List<CompilerWarning> Warnings = new List<CompilerWarning>();
|
||||
ILanguage language = LanguageProvider.SelectLanguageByExtensionSafe(FileName);
|
||||
if (language == null)
|
||||
return dconv;
|
||||
Parser = language.Parser;
|
||||
compilation_unit cu = language.Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal);
|
||||
ErrorsList.Clear();
|
||||
documentation_comment_list dt = language.DocParser.BuildTree(Text);
|
||||
documentation_comment_list dt = docParser.BuildTree(Text);
|
||||
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
||||
if (cu != null)
|
||||
docs = docconst.Construct(cu, dt);
|
||||
dconv = new DomConverter(this);
|
||||
if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
|
||||
{
|
||||
dconv.visitor.add_doc_from_text = false;
|
||||
}
|
||||
if (cu != null)
|
||||
dconv.ConvertToDom(cu);
|
||||
else
|
||||
{
|
||||
ErrorsList.Clear();
|
||||
Warnings.Clear();
|
||||
//cu = ParsersControllerGetComilationUnit(file_name, Text, ErrorsList, true);
|
||||
if (comp_modules[FileName] == null)
|
||||
{
|
||||
string tmp = ParsersHelper.GetModifiedProgramm(Text);
|
||||
if (tmp != null)
|
||||
{
|
||||
cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings);
|
||||
ErrorsList.Clear();
|
||||
}
|
||||
if (cu == null)
|
||||
cu = get_fictive_unit(Text, FileName);
|
||||
}
|
||||
ErrorsList.Clear();
|
||||
Warnings.Clear();
|
||||
dt = language.DocParser.BuildTree(Text);
|
||||
//PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
||||
if (cu != null)
|
||||
docs = docconst.Construct(cu, dt);
|
||||
if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
|
||||
{
|
||||
dconv.visitor.add_doc_from_text = false;
|
||||
}
|
||||
if (cu != null)
|
||||
{
|
||||
dconv.ConvertToDom(cu);
|
||||
}
|
||||
}
|
||||
//comp_modules[file_name] = dconv;
|
||||
if (dconv.is_compiled) comp_modules[FileName] = dconv;
|
||||
|
||||
if (docs != null) docs.Clear();
|
||||
//GC.Collect();
|
||||
return dconv;
|
||||
}*/
|
||||
}
|
||||
|
||||
public compilation_unit ParseOnlySyntaxTree(string FileName, string Text)
|
||||
{
|
||||
var currentLanguage = LanguageProvider.SelectLanguageByExtensionSafe(FileName);
|
||||
|
||||
if (currentLanguage == null)
|
||||
return null;
|
||||
|
||||
var cu = currentLanguage.Parser.GetCompilationUnit(FileName, Text, new List<Error>(), new List<CompilerWarning>(), ParseMode.Normal, false);
|
||||
|
||||
return cu;
|
||||
}
|
||||
|
||||
public DomConverter CompileAllIfNeed(string FileName, bool parse_only_interface=false)
|
||||
{
|
||||
this.FileName = FileName;
|
||||
this.Text = comp.GetSourceFileText(FileName);
|
||||
string ext = Path.GetExtension(FileName);
|
||||
List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
|
||||
string Text = comp.GetSourceFileText(FileName);
|
||||
List<Error> ErrorsList = new List<Error>();
|
||||
List<CompilerWarning> Warnings = new List<CompilerWarning>();
|
||||
PascalABCCompiler.SyntaxTree.compilation_unit cu = null;
|
||||
compilation_unit cu = null;
|
||||
|
||||
DomConverter dconv = new DomConverter(this);
|
||||
|
||||
ILanguage language = LanguageProvider.SelectLanguageByExtensionSafe(FileName);
|
||||
if (language == null)
|
||||
ILanguage currentLanguage = LanguageProvider.SelectLanguageByExtensionSafe(FileName);
|
||||
|
||||
if (currentLanguage == null)
|
||||
return dconv;
|
||||
Parser = language.Parser;
|
||||
|
||||
Parser = currentLanguage.Parser;
|
||||
|
||||
if (Text != null)
|
||||
{
|
||||
cu = language.Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal, true);
|
||||
cu = Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal, true);
|
||||
}
|
||||
ErrorsList.Clear();
|
||||
Warnings.Clear();
|
||||
|
||||
var docParser = language.DocParser;
|
||||
|
||||
if (docParser != null)
|
||||
{
|
||||
documentation_comment_list dt = docParser.BuildTree(Text);
|
||||
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
||||
if (cu != null)
|
||||
docs = docconst.Construct(cu, dt);
|
||||
}
|
||||
if (currentLanguage.DocParser != null)
|
||||
BuildDocs(Text, cu, currentLanguage.DocParser);
|
||||
|
||||
dconv.visitor.parse_only_interface = parse_only_interface;
|
||||
if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
|
||||
{
|
||||
dconv.visitor.add_doc_from_text = false;
|
||||
}
|
||||
|
||||
if (cu != null)
|
||||
{
|
||||
dconv.ConvertToDom(cu);
|
||||
else
|
||||
}
|
||||
// Попытка поменять текст программы ниже сработает только для PascalABC.NET
|
||||
else if (currentLanguage == LanguageProvider.MainLanguage)
|
||||
{
|
||||
ErrorsList.Clear();
|
||||
Warnings.Clear();
|
||||
//cu = ParsersControllerGetComilationUnit(file_name, Text, ErrorsList, true);
|
||||
|
||||
if (comp_modules[FileName] == null)
|
||||
{
|
||||
string tmp = ParsersHelper.GetModifiedProgramm(Text);
|
||||
if (tmp != null)
|
||||
{
|
||||
cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings, true);
|
||||
ErrorsList.Clear();
|
||||
cu = Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Special, true);
|
||||
}
|
||||
if (cu == null)
|
||||
cu = get_fictive_unit(Text, FileName);
|
||||
}
|
||||
ErrorsList.Clear();
|
||||
Warnings.Clear();
|
||||
|
||||
if (docParser != null)
|
||||
{
|
||||
documentation_comment_list dt = docParser.BuildTree(Text);
|
||||
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
||||
if (cu != null)
|
||||
docs = docconst.Construct(cu, dt);
|
||||
ErrorsList.Clear();
|
||||
Warnings.Clear();
|
||||
}
|
||||
|
||||
if (currentLanguage.DocParser != null)
|
||||
BuildDocs(Text, cu, currentLanguage.DocParser);
|
||||
|
||||
if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
|
||||
{
|
||||
dconv.visitor.add_doc_from_text = false;
|
||||
dconv.visitor.add_doc_from_text = false;
|
||||
}
|
||||
|
||||
if (cu != null)
|
||||
{
|
||||
dconv.ConvertToDom(cu);
|
||||
|
|
@ -409,8 +288,8 @@ namespace CodeCompletion
|
|||
if (CodeCompletionController.comp != null)
|
||||
Dirs.AddRange(CodeCompletionController.comp.CompilerOptions.SearchDirectories);
|
||||
// Надо как-то проверять, что мы не в инсталированной версии EVA
|
||||
if (CodeCompletionController.StandartDirectories.ContainsKey(LibSourceDirectoryIdent) && Directory.Exists((string)CodeCompletionController.StandartDirectories[LibSourceDirectoryIdent]))
|
||||
Dirs.Add((string)CodeCompletionController.StandartDirectories[LibSourceDirectoryIdent]);
|
||||
if (CodeCompletionController.StandartDirectories.ContainsKey(LibSourceDirectoryIdent) && Directory.Exists(CodeCompletionController.StandartDirectories[LibSourceDirectoryIdent]))
|
||||
Dirs.Add(CodeCompletionController.StandartDirectories[LibSourceDirectoryIdent]);
|
||||
return CodeCompletionController.comp.FindSourceFileNameInDirs(unit_name, out found_dir_ind, caseSensitiveSearch, Dirs.ToArray());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ using System.Text;
|
|||
|
||||
namespace CodeCompletion
|
||||
{
|
||||
public class SemanticOptions
|
||||
{
|
||||
public bool allow_import_types=true;
|
||||
}
|
||||
|
||||
public class DomSyntaxTreeVisitor : AbstractVisitor
|
||||
{
|
||||
|
|
@ -44,7 +40,6 @@ namespace CodeCompletion
|
|||
private static Compiler compiler;
|
||||
public static bool use_semantic_for_intellisense;
|
||||
private Dictionary<method_call, SymScope> method_call_cache = new Dictionary<method_call, SymScope>();
|
||||
public SemanticOptions semantic_options = new SemanticOptions();
|
||||
public Hashtable cur_used_assemblies;
|
||||
|
||||
public DomSyntaxTreeVisitor(DomConverter converter)
|
||||
|
|
@ -2514,7 +2509,17 @@ namespace CodeCompletion
|
|||
AssemblyDocCache.Load(_as, path);
|
||||
PascalABCCompiler.NetHelper.NetHelper.init_namespaces(_as);
|
||||
List<string> namespaces = new List<string>();
|
||||
namespaces.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetNamespaces(_as));
|
||||
|
||||
currentUnitLanguage = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtension(_unit_module.file_name);
|
||||
|
||||
string unitName = _unit_module.unit_name.idunit_name.name;
|
||||
|
||||
var languageUsingStandardUnit = Languages.Facade.LanguageProvider.Instance.Languages.Find(lang => lang.SystemUnitNames.Contains(unitName));
|
||||
|
||||
// Пока что добавили возможость грубо отключить добавление NET пространств имен по умолчанию здесь (второе условие нужно, чтобы в стандартные модули языка они тоже не добавлялись) EVA
|
||||
if (currentUnitLanguage.LanguageInformation.AddStandardNetNamespacesToUserScope && (languageUsingStandardUnit?.LanguageInformation.AddStandardNetNamespacesToUserScope ?? true))
|
||||
namespaces.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetNamespaces(_as));
|
||||
|
||||
InterfaceUnitScope unit_scope = null;
|
||||
bool existed_ns = false;
|
||||
is_namespace = _unit_module.unit_name.HeaderKeyword == UnitHeaderKeyword.Namespace;
|
||||
|
|
@ -2638,8 +2643,6 @@ namespace CodeCompletion
|
|||
}
|
||||
}
|
||||
|
||||
string unitName = _unit_module.unit_name.idunit_name.name;
|
||||
|
||||
// считаем основной модуль идущим первым в списке EVA
|
||||
var language = Languages.Facade.LanguageProvider.Instance.Languages.Find(lang => lang.SystemUnitNames.First() == unitName);
|
||||
|
||||
|
|
@ -2657,23 +2660,15 @@ namespace CodeCompletion
|
|||
|
||||
CodeCompletionController.comp_modules[_unit_module.file_name] = this.converter;
|
||||
|
||||
currentUnitLanguage = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtension(_unit_module.file_name);
|
||||
|
||||
var languageUsingStandardUnit = Languages.Facade.LanguageProvider.Instance.Languages.Find(lang => lang.SystemUnitNames.Contains(unitName));
|
||||
|
||||
if (!existed_ns)
|
||||
{
|
||||
// Пока что добавили возможость грубо отключить добавление NET пространств имен по умолчанию здесь (второе условие нужно, чтобы в стандартные модули языка они тоже не добавлялись) EVA
|
||||
if (currentUnitLanguage.LanguageInformation.AddStandardNetNamespacesToUserScope && (languageUsingStandardUnit?.LanguageInformation.AddStandardNetNamespacesToUserScope ?? true))
|
||||
foreach (string s in namespaces)
|
||||
{
|
||||
foreach (string s in namespaces)
|
||||
if (!ns_cache.ContainsKey(s))
|
||||
{
|
||||
if (!ns_cache.ContainsKey(s))
|
||||
{
|
||||
NamespaceScope ns_scope = new NamespaceScope(s);
|
||||
entry_scope.AddName(s, ns_scope);
|
||||
ns_cache[s] = s;
|
||||
}
|
||||
NamespaceScope ns_scope = new NamespaceScope(s);
|
||||
entry_scope.AddName(s, ns_scope);
|
||||
ns_cache[s] = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2692,17 +2687,16 @@ namespace CodeCompletion
|
|||
|
||||
if (_interface_node.uses_modules != null)
|
||||
{
|
||||
(cur_scope as InterfaceUnitScope).uses_source_range = get_location(_interface_node.uses_modules);
|
||||
|
||||
usedUnitsNames = _interface_node.uses_modules.units.Select(unit => unit.name.idents[0].name).ToList();
|
||||
|
||||
//foreach (unit_or_namespace s in _interface_node.uses_modules.units)
|
||||
(cur_scope as InterfaceUnitScope).uses_source_range = get_location(_interface_node.uses_modules);
|
||||
|
||||
// компиляция зависимостей из секции uses
|
||||
for (int j = _interface_node.uses_modules.units.Count - 1; j >= 0; j--)
|
||||
{
|
||||
unit_or_namespace s = _interface_node.uses_modules.units[j];
|
||||
add_unit_ref(s, Path.GetDirectoryName(_unit_module.file_name),
|
||||
cur_scope, ns_cache, semantic_options.allow_import_types,
|
||||
unl, currentUnitLanguage.CaseSensitive);
|
||||
CompileUsedUnitOrNamespace(s, Path.GetDirectoryName(_unit_module.file_name),
|
||||
cur_scope, ns_cache, unl, currentUnitLanguage.CaseSensitive);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2897,22 +2891,9 @@ namespace CodeCompletion
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private void add_system_unit()
|
||||
{
|
||||
AddUnit(this.converter.controller.Parser?.LanguageInformation.SystemUnitName);
|
||||
}
|
||||
|
||||
private void add_extensions_unit()
|
||||
{
|
||||
AddUnit(StringConstants.pascalExtensionsUnitName);
|
||||
}
|
||||
*/
|
||||
|
||||
private void add_unit_ref(unit_or_namespace s, string curr_path,
|
||||
SymScope cur_scope, Hashtable ns_cache, bool allow_import_types,
|
||||
using_namespace_list unl, bool caseSensitiveSearch)
|
||||
private void CompileUsedUnitOrNamespace(unit_or_namespace s, string curr_path,
|
||||
SymScope cur_scope, Hashtable ns_cache, using_namespace_list unl, bool caseSensitiveSearch)
|
||||
{
|
||||
|
||||
try
|
||||
|
|
@ -2920,105 +2901,76 @@ namespace CodeCompletion
|
|||
if (s is uses_unit_in uui)
|
||||
{
|
||||
string unit_name = CodeCompletionNameHelper.FindSourceFileName(uui.in_file.Value, out _, caseSensitiveSearch, curr_path);
|
||||
if (unit_name==null) throw new InvalidOperationException($"uses '{uui.in_file.Value}';");
|
||||
|
||||
DomConverter dc = CodeCompletionController.comp_modules[unit_name] as DomConverter;
|
||||
if (dc == null /*|| CodeCompletionController.recomp_files[unit_name] != null*/)
|
||||
{
|
||||
dc = new CodeCompletionController().CompileAllIfNeed(unit_name, true);
|
||||
}
|
||||
if (dc.visitor != null)
|
||||
{
|
||||
dc.visitor.entry_scope.InitAssemblies();
|
||||
cur_scope.AddUsedUnit(dc.visitor.entry_scope);
|
||||
cur_scope.AddName(Path.GetFileNameWithoutExtension(unit_name), dc.visitor.entry_scope);
|
||||
}
|
||||
|
||||
if (unit_name == null) throw new InvalidOperationException($"uses '{uui.in_file.Value}';");
|
||||
|
||||
CompileUnit(unit_name, cur_scope);
|
||||
}
|
||||
else
|
||||
{
|
||||
string str = "";
|
||||
for (int i = 0; i < s.name.idents.Count; i++)
|
||||
string usedName = "";
|
||||
|
||||
if (s.name.idents.Count == 1)
|
||||
{
|
||||
str += s.name.idents[i].name;
|
||||
usedName = s.name.idents[0].name;
|
||||
|
||||
string realName = str;
|
||||
// на случай имен модулей, отличающихся от имен файла EVA
|
||||
string realName = GetRealNameForModule(usedName);
|
||||
|
||||
if (s.name.idents.Count == 1)
|
||||
string pcu_unit_name = FindPCUFileName(realName, curr_path, caseSensitiveSearch);
|
||||
string unit_name = CodeCompletionNameHelper.FindSourceFileName(realName, out _, caseSensitiveSearch, curr_path);
|
||||
|
||||
/*if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(_program_module.file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0
|
||||
&& string.Compare(System.IO.Path.GetDirectoryName(_program_module.file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0)
|
||||
unit_name = null;*/
|
||||
if (unit_name != null)
|
||||
{
|
||||
// на случай имен модулей, отличающихся от имен файла EVA
|
||||
realName = GetRealNameForModule(str);
|
||||
CompileUnit(unit_name, cur_scope);
|
||||
}
|
||||
|
||||
NamespaceScope ns_scope = null;
|
||||
if (i == 0)
|
||||
else
|
||||
{
|
||||
string pcu_unit_name = FindPCUFileName(realName, curr_path, caseSensitiveSearch);
|
||||
string unit_name = CodeCompletionNameHelper.FindSourceFileName(realName, out _, caseSensitiveSearch, curr_path);
|
||||
|
||||
/*if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(_program_module.file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0
|
||||
&& string.Compare(System.IO.Path.GetDirectoryName(_program_module.file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0)
|
||||
unit_name = null;*/
|
||||
unit_name = pcu_unit_name;
|
||||
|
||||
if (unit_name != null)
|
||||
{
|
||||
DomConverter dc = CodeCompletionController.comp_modules[unit_name] as DomConverter;
|
||||
if (dc == null /*|| CodeCompletionController.recomp_files[unit_name] != null*/)
|
||||
{
|
||||
dc = new CodeCompletionController().CompileAllIfNeed(unit_name, true);
|
||||
}
|
||||
if (dc.visitor != null)
|
||||
{
|
||||
dc.visitor.entry_scope.InitAssemblies();
|
||||
cur_scope.AddUsedUnit(dc.visitor.entry_scope);
|
||||
cur_scope.AddName(str, dc.visitor.entry_scope);
|
||||
}
|
||||
IntellisensePCUReader pcu_rdr = new IntellisensePCUReader();
|
||||
SymScope ss = pcu_rdr.GetUnit(unit_name);
|
||||
UnitDocCache.Load(ss, unit_name);
|
||||
cur_scope.AddUsedUnit(ss);
|
||||
cur_scope.AddName(usedName, ss);
|
||||
}
|
||||
else
|
||||
{
|
||||
//unit_name = FindPCUFileName(str);
|
||||
unit_name = pcu_unit_name;
|
||||
if (unit_name != null)
|
||||
// У пространств имен Паскаля может быть разделение по точке, но этот случай не учитывается в ветке else EVA
|
||||
if (CodeCompletionController.pabcNamespaces.ContainsKey(usedName.ToLower()))
|
||||
{
|
||||
IntellisensePCUReader pcu_rdr = new IntellisensePCUReader();
|
||||
SymScope ss = pcu_rdr.GetUnit(unit_name);
|
||||
UnitDocCache.Load(ss, unit_name);
|
||||
cur_scope.AddUsedUnit(ss);
|
||||
cur_scope.AddName(str, ss);
|
||||
InterfaceUnitScope un_scope = CodeCompletionController.pabcNamespaces[usedName.ToLower()];
|
||||
cur_scope.AddUsedUnit(un_scope);
|
||||
cur_scope.AddName(usedName, un_scope);
|
||||
}
|
||||
else
|
||||
else if (PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(usedName))
|
||||
{
|
||||
if (CodeCompletion.CodeCompletionController.pabcNamespaces.ContainsKey(str.ToLower()))
|
||||
{
|
||||
InterfaceUnitScope un_scope = CodeCompletion.CodeCompletionController.pabcNamespaces[str.ToLower()];
|
||||
cur_scope.AddUsedUnit(un_scope);
|
||||
cur_scope.AddName(str, un_scope);
|
||||
}
|
||||
else if (PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str))
|
||||
{
|
||||
ns_scope = new NamespaceScope(str);
|
||||
ns_cache[str] = str;
|
||||
cur_scope.AddName(str, ns_scope);
|
||||
if (s.name.idents.Count == 1)
|
||||
cur_scope.AddUsedUnit(ns_scope);
|
||||
}
|
||||
else if (PascalABCCompiler.NetHelper.NetHelper.IsType(str) && allow_import_types)
|
||||
{
|
||||
Type t = PascalABCCompiler.NetHelper.NetHelper.FindType(str);
|
||||
cur_scope.AddUsedUnit(new NamespaceTypeScope(TypeTable.get_compiled_type(new SymInfo(t.Name, SymbolKind.Class, t.FullName), t)));
|
||||
}
|
||||
|
||||
var ns_scope = new NamespaceScope(usedName);
|
||||
ns_cache[usedName] = usedName;
|
||||
cur_scope.AddName(usedName, ns_scope);
|
||||
cur_scope.AddUsedUnit(ns_scope);
|
||||
}
|
||||
//unit_name = System.IO.Path.GetDirectoryName(_program_module.file_name)+"\\"+str+System.IO.Path.GetExtension(_program_module.file_name);
|
||||
// Не поддерживается в основном компиляторе EVA
|
||||
/*else if (PascalABCCompiler.NetHelper.NetHelper.IsType(usedName) && allow_import_types)
|
||||
{
|
||||
Type t = PascalABCCompiler.NetHelper.NetHelper.FindType(usedName);
|
||||
cur_scope.AddUsedUnit(new NamespaceTypeScope(TypeTable.get_compiled_type(new SymInfo(t.Name, SymbolKind.Class, t.FullName), t)));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
if (i == s.name.idents.Count - 1 && i > 0 /*&& PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str)*/)
|
||||
//possible_namespaces.Add(str);
|
||||
cur_scope.AddUsedUnit(new NamespaceScope(str));
|
||||
if (i < s.name.idents.Count - 1)
|
||||
str += ".";
|
||||
|
||||
}
|
||||
unl.AddElement(new PascalABCCompiler.TreeRealization.using_namespace(str));
|
||||
else
|
||||
{
|
||||
usedName = string.Join(".", s.name.idents.Select(id => id.name));
|
||||
|
||||
cur_scope.AddUsedUnit(new NamespaceScope(usedName));
|
||||
}
|
||||
|
||||
unl.AddElement(new using_namespace(usedName));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -3029,9 +2981,22 @@ namespace CodeCompletion
|
|||
}
|
||||
}
|
||||
|
||||
private void CompileUnit(string unit_name, SymScope cur_scope)
|
||||
{
|
||||
var dc = (DomConverter)CodeCompletionController.comp_modules[unit_name]
|
||||
?? new CodeCompletionController().CompileAllIfNeed(unit_name, true);
|
||||
|
||||
if (dc.visitor != null)
|
||||
{
|
||||
dc.visitor.entry_scope.InitAssemblies();
|
||||
cur_scope.AddUsedUnit(dc.visitor.entry_scope);
|
||||
cur_scope.AddName(Path.GetFileNameWithoutExtension(unit_name), dc.visitor.entry_scope);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetRealNameForModule(string nameInUses)
|
||||
{
|
||||
// для такого пока не реализована поддержка EVA
|
||||
// для такого пока не реализована поддержка в конверторах синтаксического дерева EVA
|
||||
/*var specialModulesAliases = Languages.Facade.LanguageProvider.Instance.Languages.SelectMany(l =>
|
||||
l.LanguageInformation.SpecialModulesAliases != null ? l.LanguageInformation.SpecialModulesAliases : new Dictionary<string, string>());
|
||||
|
||||
|
|
@ -3052,77 +3017,42 @@ namespace CodeCompletion
|
|||
return nameInUses;
|
||||
}
|
||||
|
||||
private void add_unit_ref_for_import(ident_list importedModuleName, statement importStatement, as_statement_list asStatementsList, string curr_path,
|
||||
SymScope cur_scope, Hashtable ns_cache, bool allow_import_types,
|
||||
using_namespace_list unl, bool caseSensitiveSearch)
|
||||
private void CompileImportedUnit(string importedName, statement importStatement, as_statement_list asStatementsList, string curr_path,
|
||||
SymScope cur_scope, using_namespace_list unl, bool caseSensitiveSearch)
|
||||
{
|
||||
try
|
||||
{
|
||||
string str = "";
|
||||
for (int i = 0; i < importedModuleName.idents.Count; i++)
|
||||
// на случай имен модулей, отличающихся от имен файла EVA
|
||||
string realName = GetRealNameForModule(importedName);
|
||||
|
||||
string pcu_unit_name = FindPCUFileName(realName, curr_path, caseSensitiveSearch);
|
||||
string unit_name = CodeCompletionNameHelper.FindSourceFileName(realName, out _, caseSensitiveSearch, curr_path);
|
||||
|
||||
if (unit_name != null)
|
||||
{
|
||||
str += importedModuleName.idents[i].name;
|
||||
|
||||
string realName = str;
|
||||
|
||||
if (importedModuleName.idents.Count == 1)
|
||||
DomConverter dc = (DomConverter)CodeCompletionController.comp_modules[unit_name]
|
||||
?? new CodeCompletionController().CompileAllIfNeed(unit_name, true);
|
||||
|
||||
if (dc.visitor != null)
|
||||
{
|
||||
// на случай имен модулей, отличающихся от имен файла EVA
|
||||
realName = GetRealNameForModule(str);
|
||||
dc.visitor.entry_scope.InitAssemblies();
|
||||
AddImportedNamesToCurScope(importStatement, asStatementsList, cur_scope, importedName, dc.visitor.entry_scope);
|
||||
}
|
||||
|
||||
NamespaceScope ns_scope = null;
|
||||
if (i == 0)
|
||||
{
|
||||
string pcu_unit_name = FindPCUFileName(realName, curr_path, caseSensitiveSearch);
|
||||
string unit_name = CodeCompletionNameHelper.FindSourceFileName(realName, out _, caseSensitiveSearch, curr_path);
|
||||
|
||||
if (unit_name != null)
|
||||
{
|
||||
DomConverter dc = CodeCompletionController.comp_modules[unit_name] as DomConverter;
|
||||
if (dc == null)
|
||||
{
|
||||
dc = new CodeCompletionController().CompileAllIfNeed(unit_name, true);
|
||||
}
|
||||
if (dc.visitor != null)
|
||||
{
|
||||
dc.visitor.entry_scope.InitAssemblies();
|
||||
AddImportedNamesToCurScope(importStatement, asStatementsList, cur_scope, str, dc.visitor.entry_scope);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unit_name = pcu_unit_name;
|
||||
if (unit_name != null)
|
||||
{
|
||||
IntellisensePCUReader pcu_rdr = new IntellisensePCUReader();
|
||||
SymScope ss = pcu_rdr.GetUnit(unit_name);
|
||||
UnitDocCache.Load(ss, unit_name);
|
||||
AddImportedNamesToCurScope(importStatement, asStatementsList, cur_scope, str, ss);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CodeCompletion.CodeCompletionController.pabcNamespaces.ContainsKey(str.ToLower()))
|
||||
{
|
||||
InterfaceUnitScope un_scope = CodeCompletion.CodeCompletionController.pabcNamespaces[str.ToLower()];
|
||||
AddImportedNamesToCurScope(importStatement, asStatementsList, cur_scope, str, un_scope);
|
||||
}
|
||||
else if (PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str))
|
||||
{
|
||||
ns_scope = new NamespaceScope(str);
|
||||
ns_cache[str] = str;
|
||||
AddImportedNamesToCurScope(importStatement, asStatementsList, cur_scope, str, ns_scope, importedModuleName.idents.Count > 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i == importedModuleName.idents.Count - 1 && i > 0)
|
||||
AddImportedNamesToCurScope(importStatement, asStatementsList, cur_scope, str, ns_scope, false);
|
||||
|
||||
if (i < importedModuleName.idents.Count - 1)
|
||||
str += ".";
|
||||
}
|
||||
unl.AddElement(new using_namespace(str));
|
||||
else
|
||||
{
|
||||
unit_name = pcu_unit_name;
|
||||
|
||||
if (unit_name != null)
|
||||
{
|
||||
IntellisensePCUReader pcu_rdr = new IntellisensePCUReader();
|
||||
SymScope ss = pcu_rdr.GetUnit(unit_name);
|
||||
UnitDocCache.Load(ss, unit_name);
|
||||
AddImportedNamesToCurScope(importStatement, asStatementsList, cur_scope, importedName, ss);
|
||||
}
|
||||
}
|
||||
|
||||
unl.AddElement(new using_namespace(importedName));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -3132,7 +3062,7 @@ namespace CodeCompletion
|
|||
}
|
||||
}
|
||||
|
||||
private static void AddImportedNamesToCurScope(statement importStatement, as_statement_list asStatementsList, SymScope currentScope, string importedModuleName, SymScope importedModuleScope, bool notFinalNamespaceName = false)
|
||||
private static void AddImportedNamesToCurScope(statement importStatement, as_statement_list asStatementsList, SymScope currentScope, string importedModuleName, SymScope importedModuleScope)
|
||||
{
|
||||
int fictiveUnitIndex = currentScope.used_units.FindIndex(unit => unit.Name == importedModuleName);
|
||||
|
||||
|
|
@ -3153,7 +3083,7 @@ namespace CodeCompletion
|
|||
importedModuleScope.si.name = importedModuleName;
|
||||
importedModuleScope.si.addit_name = aliasName;
|
||||
}
|
||||
else if (importStatement is from_import_statement fromImport && !notFinalNamespaceName)
|
||||
else if (importStatement is from_import_statement fromImport)
|
||||
{
|
||||
if (fromImport.is_star)
|
||||
{
|
||||
|
|
@ -3193,7 +3123,13 @@ namespace CodeCompletion
|
|||
List<string> namespaces = new List<string>();
|
||||
PascalABCCompiler.NetHelper.NetHelper.init_namespaces(_as);
|
||||
AssemblyDocCache.Load(_as, path);
|
||||
namespaces.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetNamespaces(_as));
|
||||
|
||||
currentUnitLanguage = Languages.Facade.LanguageProvider.Instance.SelectLanguageByName(_program_module.Language);
|
||||
|
||||
// Пока что добавили возможость грубо отключить добавление NET пространств имен по умолчанию здесь EVA
|
||||
if (currentUnitLanguage.LanguageInformation.AddStandardNetNamespacesToUserScope)
|
||||
namespaces.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetNamespaces(_as));
|
||||
|
||||
//List<Scope> netScopes = new List<Scope>();
|
||||
//PascalABCCompiler.NetHelper.NetScope ns=new PascalABCCompiler.NetHelper.NetScope(unl,_as,tcst);
|
||||
InterfaceUnitScope unit_scope = null;
|
||||
|
|
@ -3299,8 +3235,6 @@ namespace CodeCompletion
|
|||
}
|
||||
}
|
||||
|
||||
currentUnitLanguage = Languages.Facade.LanguageProvider.Instance.SelectLanguageByName(_program_module.Language);
|
||||
|
||||
if (currentUnitLanguage.ApplySyntaxTreeConvertersForIntellisense)
|
||||
{
|
||||
foreach (ISyntaxTreeConverter converter in currentUnitLanguage.SyntaxTreeConverters)
|
||||
|
|
@ -3317,13 +3251,12 @@ namespace CodeCompletion
|
|||
|
||||
unit_scope.uses_source_range = get_location(_program_module.used_units);
|
||||
|
||||
//foreach (unit_or_namespace s in _program_module.used_units.units)
|
||||
// компиляция зависимостей из секции uses
|
||||
for (int j = _program_module.used_units.units.Count - 1; j >= 0; j--)
|
||||
{
|
||||
unit_or_namespace s = _program_module.used_units.units[j];
|
||||
add_unit_ref(s, Path.GetDirectoryName(_program_module.file_name),
|
||||
cur_scope, ns_cache, semantic_options.allow_import_types,
|
||||
unl, currentUnitLanguage.CaseSensitive);
|
||||
CompileUsedUnitOrNamespace(s, Path.GetDirectoryName(_program_module.file_name),
|
||||
cur_scope, ns_cache, unl, currentUnitLanguage.CaseSensitive);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3341,17 +3274,13 @@ namespace CodeCompletion
|
|||
AddStandardUnit(unitName, currentUnitLanguage.CaseSensitive, currentUnitLanguage.LanguageInformation.AddStandardUnitNamesToUserScope);
|
||||
}
|
||||
|
||||
// Пока что добавили возможость грубо отключить добавление NET пространств имен по умолчанию здесь EVA
|
||||
if (currentUnitLanguage.LanguageInformation.AddStandardNetNamespacesToUserScope)
|
||||
foreach (string s in namespaces)
|
||||
{
|
||||
foreach (string s in namespaces)
|
||||
if (!ns_cache.ContainsKey(s))
|
||||
{
|
||||
if (!ns_cache.ContainsKey(s))
|
||||
{
|
||||
NamespaceScope ns_scope = new NamespaceScope(s);
|
||||
cur_scope.AddName(s, ns_scope);
|
||||
ns_cache[s] = s;
|
||||
}
|
||||
NamespaceScope ns_scope = new NamespaceScope(s);
|
||||
cur_scope.AddName(s, ns_scope);
|
||||
ns_cache[s] = s;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3414,20 +3343,18 @@ namespace CodeCompletion
|
|||
{
|
||||
foreach (var unitNode in import.modules_names.as_statements.Select(st => st.real_name).Reverse())
|
||||
{
|
||||
add_unit_ref_for_import(new ident_list(unitNode), import, import.modules_names,
|
||||
CompileImportedUnit(unitNode.name, import, import.modules_names,
|
||||
Path.GetDirectoryName(fileName),
|
||||
cur_scope, ns_cache, semantic_options.allow_import_types,
|
||||
unl, caseSensitiveSearch);
|
||||
cur_scope, unl, caseSensitiveSearch);
|
||||
|
||||
usedUnitNames.Add(unitNode.name);
|
||||
}
|
||||
}
|
||||
else if (importStatement is from_import_statement fromImport)
|
||||
{
|
||||
add_unit_ref_for_import(new ident_list(fromImport.module_name), fromImport, fromImport.imported_names,
|
||||
CompileImportedUnit(fromImport.module_name.name, fromImport, fromImport.imported_names,
|
||||
Path.GetDirectoryName(fileName),
|
||||
cur_scope, ns_cache, semantic_options.allow_import_types,
|
||||
unl, caseSensitiveSearch);
|
||||
cur_scope, unl, caseSensitiveSearch);
|
||||
|
||||
usedUnitNames.Add(fromImport.module_name.name);
|
||||
}
|
||||
|
|
@ -5118,9 +5045,8 @@ namespace CodeCompletion
|
|||
for (int j = _implementation_node.uses_modules.units.Count - 1; j >= 0; j--)
|
||||
{
|
||||
unit_or_namespace s = _implementation_node.uses_modules.units[j];
|
||||
add_unit_ref(s, Path.GetDirectoryName(this.cur_unit_file_name),
|
||||
cur_scope, ns_cache, semantic_options.allow_import_types,
|
||||
unl, currentLanguage.CaseSensitive);
|
||||
CompileUsedUnitOrNamespace(s, Path.GetDirectoryName(this.cur_unit_file_name),
|
||||
cur_scope, ns_cache, unl, currentLanguage.CaseSensitive);
|
||||
}
|
||||
}
|
||||
impl_scope = cur_scope;
|
||||
|
|
|
|||
|
|
@ -5387,7 +5387,7 @@ namespace CodeCompletion
|
|||
//
|
||||
// }
|
||||
|
||||
public class NamespaceTypeScope : SymScope, INamespaceTypeScope
|
||||
/*public class NamespaceTypeScope : SymScope, INamespaceTypeScope
|
||||
{
|
||||
private CompiledScope entry_type;
|
||||
|
||||
|
|
@ -5433,7 +5433,7 @@ namespace CodeCompletion
|
|||
{
|
||||
return entry_type.GetStaticNames();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public class NamespaceScope : SymScope, INamespaceScope
|
||||
{
|
||||
|
|
|
|||
|
|
@ -448,13 +448,13 @@ namespace PascalABCCompiler
|
|||
}
|
||||
//для поиска pcu в третью очередь исп. путь к pas файлу
|
||||
|
||||
public Hashtable StandardDirectories;
|
||||
public Dictionary<string, string> StandardDirectories;
|
||||
|
||||
private void SetDirectories()
|
||||
{
|
||||
SystemDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName);
|
||||
|
||||
StandardDirectories = new Hashtable(StringComparer.InvariantCultureIgnoreCase)
|
||||
StandardDirectories = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase)
|
||||
{
|
||||
{ "%PABCSYSTEM%", SystemDirectory }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ namespace PascalABCCompiler
|
|||
sc.begin_position.line_num, sc.begin_position.column_num,
|
||||
sc.end_position.line_num, sc.end_position.column_num);
|
||||
}
|
||||
public static string ReplaceAllKeys(string str, Hashtable hashtable)
|
||||
public static string ReplaceAllKeys(string str, Dictionary<string, string> hashtable)
|
||||
{
|
||||
foreach (string key in hashtable.Keys)
|
||||
if (hashtable[key] != null)
|
||||
str = str.Replace(key, hashtable[key].ToString());
|
||||
str = str.Replace(key, hashtable[key]);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using PascalABCCompiler.NetHelper;
|
||||
|
||||
namespace PascalABCCompiler.CodeGenerators
|
||||
|
|
@ -23,7 +22,7 @@ namespace PascalABCCompiler.CodeGenerators
|
|||
private NETGenerator.ILConverter il_converter;//=new NETGenerator.ILConverter();
|
||||
|
||||
public void GenerateILCodeAndSaveAssembly(SemanticTree.IProgramNode ProgramTree,string TargetFileName,string SourceFileName ,
|
||||
NETGenerator.CompilerOptions options, Hashtable StandartDirectories, string[] ResourceFiles)
|
||||
NETGenerator.CompilerOptions options, Dictionary<string, string> StandartDirectories, string[] ResourceFiles)
|
||||
{
|
||||
il_converter = new NETGenerator.ILConverter(StandartDirectories);
|
||||
il_converter.ConvertFromTree(ProgramTree, TargetFileName, SourceFileName, options, ResourceFiles);
|
||||
|
|
|
|||
|
|
@ -271,9 +271,9 @@ namespace PascalABCCompiler.NETGenerator
|
|||
make_next_spoint = true;
|
||||
}
|
||||
|
||||
private Hashtable StandartDirectories;
|
||||
private Dictionary<string, string> StandartDirectories;
|
||||
|
||||
public ILConverter(Hashtable StandartDirectories)
|
||||
public ILConverter(Dictionary<string, string> StandartDirectories)
|
||||
{
|
||||
this.StandartDirectories = StandartDirectories;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace VisualPascalABC
|
|||
private DebugHelper DebugHelper;
|
||||
private CodeCompletionParserController CodeCompletionParserController;
|
||||
public UserOptions UserOptions;
|
||||
private System.Collections.Hashtable StandartDirectories;
|
||||
private Dictionary<string, string> StandartDirectories;
|
||||
Dictionary<string, CodeFileDocumentControl> OpenDocuments;
|
||||
|
||||
public VisualEnvironmentCompiler(InvokeDegegate beginInvoke,
|
||||
|
|
@ -70,7 +70,7 @@ namespace VisualPascalABC
|
|||
SetTextDelegate addTextToCompilerMessages, ToolStripMenuItem pluginsMenuItem,
|
||||
ToolStrip pluginsToolStrip, ExecuteSourceLocationActionDelegate ExecuteSLAction,
|
||||
ExecuteVisualEnvironmentCompilerActionDelegate ExecuteVECAction,
|
||||
PascalABCCompiler.Errors.ErrorsStrategyManager ErrorsManager, RunManager RunnerManager, DebugHelper DebugHelper,UserOptions UserOptions,System.Collections.Hashtable StandartDirectories,
|
||||
PascalABCCompiler.Errors.ErrorsStrategyManager ErrorsManager, RunManager RunnerManager, DebugHelper DebugHelper,UserOptions UserOptions, Dictionary<string, string> StandartDirectories,
|
||||
Dictionary<string, CodeFileDocumentControl> OpenDocuments, IWorkbench workbench)
|
||||
{
|
||||
this.StandartDirectories = StandartDirectories;
|
||||
|
|
|
|||
|
|
@ -117,7 +117,8 @@ namespace VisualPascalABC
|
|||
|
||||
public void UpdateFolding()
|
||||
{
|
||||
CodeCompletionParserController.open_files[this.FileName] = true;
|
||||
if (Languages.Facade.LanguageProvider.Instance.HasLanguageForExtension(FileName))
|
||||
CodeCompletionParserController.filesToParse[FileName] = true;
|
||||
}
|
||||
|
||||
public void CollapseRegions()
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ namespace VisualPascalABC
|
|||
|
||||
PlayPauseButtonsVisibleInPanel = false;
|
||||
|
||||
WorkbenchStorage.StandartDirectories = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
|
||||
WorkbenchStorage.StandartDirectories = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
WorkbenchStorage.StandartDirectories.Add(Constants.SystemDirectoryIdent, System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName));
|
||||
|
||||
RestoreDesktop();
|
||||
|
|
@ -614,10 +614,11 @@ namespace VisualPascalABC
|
|||
case VisualEnvironmentCompilerAction.OpenFile:
|
||||
return WorkbenchServiceFactory.FileService.OpenFile((string)obj, null);
|
||||
case VisualEnvironmentCompilerAction.GetDirectory:
|
||||
string s=VisualEnvironmentCompiler.Compiler.CompilerOptions.StandardDirectories[(string)obj] as string;
|
||||
if (s != null)
|
||||
VisualEnvironmentCompiler.Compiler.CompilerOptions.StandardDirectories.TryGetValue((string)obj, out var s);
|
||||
if (s != null)
|
||||
return s;
|
||||
return WorkbenchStorage.StandartDirectories[(string)obj] as string;
|
||||
WorkbenchStorage.StandartDirectories.TryGetValue((string)obj, out s);
|
||||
return s;
|
||||
case VisualEnvironmentCompilerAction.PT4PositionCursorAfterTask: // SSM 09.11.19
|
||||
{
|
||||
var ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace VisualPascalABC
|
|||
|
||||
public class CodeCompletionParserController : VisualPascalABCPlugins.ICodeCompletionService
|
||||
{
|
||||
public static Dictionary<string, bool> open_files = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
|
||||
public static Dictionary<string, bool> filesToParse = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
|
||||
public VisualEnvironmentCompiler visualEnvironmentCompiler;
|
||||
private System.Threading.Thread th = null;
|
||||
private CodeCompletionProvider ccp;
|
||||
|
|
@ -67,40 +67,42 @@ namespace VisualPascalABC
|
|||
CodeCompletion.CodeCompletionController.comp_modules[NewFileName] = CodeCompletion.CodeCompletionController.comp_modules[OldFileName];
|
||||
if (CodeCompletion.CodeCompletionController.comp_modules.ContainsKey(OldFileName))
|
||||
CodeCompletion.CodeCompletionController.comp_modules.Remove(OldFileName);
|
||||
open_files[NewFileName] = open_files[OldFileName];
|
||||
if (open_files.ContainsKey(OldFileName))
|
||||
open_files.Remove(OldFileName);
|
||||
filesToParse[NewFileName] = filesToParse[OldFileName];
|
||||
if (filesToParse.ContainsKey(OldFileName))
|
||||
filesToParse.Remove(OldFileName);
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterFileForParsing(string FileName)
|
||||
{
|
||||
open_files[FileName] = true;
|
||||
CodeCompletion.CodeCompletionController.SetLanguage(FileName);
|
||||
//ParseAllFiles();
|
||||
if (Languages.Facade.LanguageProvider.Instance.HasLanguageForExtension(FileName))
|
||||
{
|
||||
filesToParse[FileName] = true;
|
||||
CodeCompletion.CodeCompletionController.SetLanguage(FileName);
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseFile(string FileName)
|
||||
{
|
||||
if (CodeCompletion.CodeCompletionController.comp_modules[FileName] != null)
|
||||
CodeCompletion.CodeCompletionController.comp_modules.Remove(FileName);
|
||||
open_files.Remove(FileName);
|
||||
filesToParse.Remove(FileName);
|
||||
}
|
||||
|
||||
public void SetAsChanged(string FileName)
|
||||
{
|
||||
if (FileName != null)
|
||||
open_files[FileName] = true;
|
||||
if (FileName != null && filesToParse.ContainsKey(FileName))
|
||||
filesToParse[FileName] = true;
|
||||
}
|
||||
|
||||
public void SetAllInProjectChanged()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (string s in open_files.Keys.ToArray())
|
||||
foreach (string s in filesToParse.Keys.ToArray())
|
||||
{
|
||||
if (ProjectFactory.Instance.CurrentProject.ContainsSourceFile(s))
|
||||
open_files[s] = true;
|
||||
filesToParse[s] = true;
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
|
@ -146,10 +148,10 @@ namespace VisualPascalABC
|
|||
{
|
||||
Dictionary<string, string> recomp_files = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
bool is_comp = false;
|
||||
foreach (string FileName in open_files.Keys.ToArray()) // копирование ключей обязательно, иначе будет InvalidOperationException EVA
|
||||
foreach (string FileName in filesToParse.Keys.ToArray()) // копирование ключей обязательно, иначе будет InvalidOperationException EVA
|
||||
{
|
||||
|
||||
if (open_files[FileName])
|
||||
if (filesToParse[FileName])
|
||||
{
|
||||
is_comp = true;
|
||||
CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController();
|
||||
|
|
@ -160,7 +162,7 @@ namespace VisualPascalABC
|
|||
long cur_mem = Environment.WorkingSet;
|
||||
CodeCompletion.DomConverter dc = controller.Compile(FileName, text);
|
||||
mem_delta += Environment.WorkingSet - cur_mem;
|
||||
open_files[FileName] = false;
|
||||
filesToParse[FileName] = false;
|
||||
if (dc.is_compiled)
|
||||
{
|
||||
//CodeCompletion.CodeCompletionController.comp_modules.Remove(file_name);
|
||||
|
|
@ -172,7 +174,7 @@ namespace VisualPascalABC
|
|||
}
|
||||
CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc;
|
||||
recomp_files[FileName] = FileName;
|
||||
open_files[FileName] = false;
|
||||
filesToParse[FileName] = false;
|
||||
if (ParseInformationUpdated != null)
|
||||
ParseInformationUpdated(dc.visitor.entry_scope, FileName);
|
||||
}
|
||||
|
|
@ -180,7 +182,7 @@ namespace VisualPascalABC
|
|||
CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc;
|
||||
}
|
||||
}
|
||||
foreach (string FileName in open_files.Keys.ToArray()) // копирование ключей обязательно, иначе будет InvalidOperationException EVA
|
||||
foreach (string FileName in filesToParse.Keys.ToArray()) // копирование ключей обязательно, иначе будет InvalidOperationException EVA
|
||||
{
|
||||
CodeCompletion.DomConverter dc = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter;
|
||||
CodeCompletion.SymScope ss = null;
|
||||
|
|
@ -206,7 +208,7 @@ namespace VisualPascalABC
|
|||
for (int i = 0; i < ss.used_units.Count; i++)
|
||||
{
|
||||
string s = ss.used_units[i].file_name;
|
||||
if (s != null && open_files.ContainsKey(s) && recomp_files.ContainsKey(s))
|
||||
if (s != null && filesToParse.ContainsKey(s) && recomp_files.ContainsKey(s))
|
||||
{
|
||||
is_comp = true;
|
||||
CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController();
|
||||
|
|
@ -215,7 +217,7 @@ namespace VisualPascalABC
|
|||
long cur_mem = Environment.WorkingSet;
|
||||
dc = controller.Compile(FileName, text);
|
||||
mem_delta += Environment.WorkingSet - cur_mem;
|
||||
open_files[FileName] = false;
|
||||
filesToParse[FileName] = false;
|
||||
CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc;
|
||||
if (dc.is_compiled)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ namespace VisualPascalABC
|
|||
}
|
||||
if (fnd_scope != null)
|
||||
{
|
||||
foreach (string FileName in CodeCompletionParserController.open_files.Keys)
|
||||
foreach (string FileName in CodeCompletionParserController.filesToParse.Keys)
|
||||
{
|
||||
CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController();
|
||||
string text = VisualPABCSingleton.MainForm.VisualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace VisualPascalABC
|
|||
CompilerOptions1.UseDllForSystemUnits = false;
|
||||
CompilerOptions1.RunWithEnvironment = RunWithEnvironment;
|
||||
bool savePCU = Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate;
|
||||
if (Path.GetDirectoryName(CompilerOptions1.SourceFileName).ToLower() == ((string)WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent]).ToLower())
|
||||
if (Path.GetDirectoryName(CompilerOptions1.SourceFileName).ToLower() == WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent].ToLower())
|
||||
Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = false;
|
||||
|
||||
if (RuntimeServicesModule != null)
|
||||
|
|
@ -128,7 +128,7 @@ namespace VisualPascalABC
|
|||
|
||||
//CompilerOptions1.SavePCUInThreadPull = true;
|
||||
bool savePCU = Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate;
|
||||
if (Path.GetDirectoryName(FileName).ToLower() == ((string)WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent]).ToLower())
|
||||
if (Path.GetDirectoryName(FileName).ToLower() == WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent].ToLower())
|
||||
Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = false;
|
||||
|
||||
string ofn = Workbench.VisualEnvironmentCompiler.Compile(CompilerOptions1);
|
||||
|
|
@ -220,7 +220,7 @@ namespace VisualPascalABC
|
|||
|
||||
//CompilerOptions1.SavePCUInThreadPull = true;
|
||||
__savePCU = Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate;
|
||||
if (Path.GetDirectoryName(FileName).ToLower() == ((string)WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent]).ToLower())
|
||||
if (Path.GetDirectoryName(FileName).ToLower() == WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent].ToLower())
|
||||
Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = false;
|
||||
|
||||
Workbench.VisualEnvironmentCompiler.Compiler.OnChangeCompilerState += CompilationOnChangeCompilerState;
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ namespace VisualPascalABC
|
|||
internal static string WorkingDirectory = null;
|
||||
internal static string WorkingDirectoryInOptionsFile = null;
|
||||
internal static string LibSourceDirectory = null;
|
||||
internal static Hashtable StandartDirectories;
|
||||
internal static Dictionary<string, string> StandartDirectories;
|
||||
internal static System.Threading.Thread MainProgramThread;
|
||||
internal static bool SetCurrentTabPageIfWriteToOutputWindow = false;
|
||||
internal static bool WorkingDirectoryExsist
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace VisualPascalABC
|
|||
private DebugHelper DebugHelper;
|
||||
private CodeCompletionParserController CodeCompletionParserController;
|
||||
public UserOptions UserOptions;
|
||||
private System.Collections.Hashtable StandartDirectories;
|
||||
private Dictionary<string, string> StandartDirectories;
|
||||
Dictionary<string, CodeFileDocumentControl> OpenDocuments;
|
||||
|
||||
public VisualEnvironmentCompiler(InvokeDegegate beginInvoke,
|
||||
|
|
@ -68,7 +68,7 @@ namespace VisualPascalABC
|
|||
SetTextDelegate addTextToCompilerMessages, ToolStripMenuItem pluginsMenuItem,
|
||||
ToolStrip pluginsToolStrip, ExecuteSourceLocationActionDelegate ExecuteSLAction,
|
||||
ExecuteVisualEnvironmentCompilerActionDelegate ExecuteVECAction,
|
||||
PascalABCCompiler.Errors.ErrorsStrategyManager ErrorsManager, RunManager RunnerManager, DebugHelper DebugHelper,UserOptions UserOptions,System.Collections.Hashtable StandartDirectories,
|
||||
PascalABCCompiler.Errors.ErrorsStrategyManager ErrorsManager, RunManager RunnerManager, DebugHelper DebugHelper,UserOptions UserOptions, Dictionary<string, string> StandartDirectories,
|
||||
Dictionary<string, CodeFileDocumentControl> OpenDocuments, IWorkbench workbench)
|
||||
{
|
||||
this.StandartDirectories = StandartDirectories;
|
||||
|
|
|
|||
|
|
@ -114,12 +114,13 @@ namespace VisualPascalABC
|
|||
{
|
||||
ActiveTextAreaControl.TextArea.Refresh(ActiveTextAreaControl.TextArea.FoldMargin);
|
||||
}
|
||||
|
||||
public void UpdateFolding()
|
||||
{
|
||||
CodeCompletionParserController.open_files[this.FileName] = true;
|
||||
}
|
||||
|
||||
|
||||
public void UpdateFolding()
|
||||
{
|
||||
if (Languages.Facade.LanguageProvider.Instance.HasLanguageForExtension(FileName))
|
||||
CodeCompletionParserController.filesToParse[FileName] = true;
|
||||
}
|
||||
|
||||
public void CollapseRegions()
|
||||
{
|
||||
foreach (FoldMarker marker in Document.FoldingManager.FoldMarker)
|
||||
|
|
|
|||
|
|
@ -357,7 +357,7 @@ namespace VisualPascalABC
|
|||
|
||||
PlayPauseButtonsVisibleInPanel = false;
|
||||
|
||||
WorkbenchStorage.StandartDirectories = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
|
||||
WorkbenchStorage.StandartDirectories = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
WorkbenchStorage.StandartDirectories.Add(Constants.SystemDirectoryIdent, System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName));
|
||||
|
||||
//---------------------------------------------
|
||||
|
|
@ -707,10 +707,11 @@ namespace VisualPascalABC
|
|||
case VisualEnvironmentCompilerAction.OpenFile:
|
||||
return WorkbenchServiceFactory.FileService.OpenFile((string)obj, null);
|
||||
case VisualEnvironmentCompilerAction.GetDirectory:
|
||||
string s=VisualEnvironmentCompiler.Compiler.CompilerOptions.StandardDirectories[(string)obj] as string;
|
||||
if (s != null)
|
||||
VisualEnvironmentCompiler.Compiler.CompilerOptions.StandardDirectories.TryGetValue((string)obj, out var s);
|
||||
if (s != null)
|
||||
return s;
|
||||
return WorkbenchStorage.StandartDirectories[(string)obj] as string;
|
||||
WorkbenchStorage.StandartDirectories.TryGetValue((string)obj, out s);
|
||||
return s;
|
||||
case VisualEnvironmentCompilerAction.PT4PositionCursorAfterTask: // SSM 09.11.19
|
||||
{
|
||||
var ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace VisualPascalABC
|
|||
|
||||
public class CodeCompletionParserController : VisualPascalABCPlugins.ICodeCompletionService
|
||||
{
|
||||
public static Dictionary<string, bool> open_files = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
|
||||
public static Dictionary<string, bool> filesToParse = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
|
||||
public VisualEnvironmentCompiler visualEnvironmentCompiler;
|
||||
private System.Threading.Thread th = null;
|
||||
private CodeCompletionProvider ccp;
|
||||
|
|
@ -68,40 +68,42 @@ namespace VisualPascalABC
|
|||
CodeCompletion.CodeCompletionController.comp_modules[NewFileName] = CodeCompletion.CodeCompletionController.comp_modules[OldFileName];
|
||||
if (CodeCompletion.CodeCompletionController.comp_modules.ContainsKey(OldFileName))
|
||||
CodeCompletion.CodeCompletionController.comp_modules.Remove(OldFileName);
|
||||
open_files[NewFileName] = open_files[OldFileName];
|
||||
if (open_files.ContainsKey(OldFileName))
|
||||
open_files.Remove(OldFileName);
|
||||
filesToParse[NewFileName] = filesToParse[OldFileName];
|
||||
if (filesToParse.ContainsKey(OldFileName))
|
||||
filesToParse.Remove(OldFileName);
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterFileForParsing(string FileName)
|
||||
{
|
||||
open_files[FileName] = true;
|
||||
CodeCompletion.CodeCompletionController.SetLanguage(FileName);
|
||||
//ParseAllFiles();
|
||||
if (Languages.Facade.LanguageProvider.Instance.HasLanguageForExtension(FileName))
|
||||
{
|
||||
filesToParse[FileName] = true;
|
||||
CodeCompletion.CodeCompletionController.SetLanguage(FileName);
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseFile(string FileName)
|
||||
{
|
||||
if (CodeCompletion.CodeCompletionController.comp_modules[FileName] != null)
|
||||
CodeCompletion.CodeCompletionController.comp_modules.Remove(FileName);
|
||||
open_files.Remove(FileName);
|
||||
filesToParse.Remove(FileName);
|
||||
}
|
||||
|
||||
public void SetAsChanged(string FileName)
|
||||
{
|
||||
if (FileName != null)
|
||||
open_files[FileName] = true;
|
||||
if (FileName != null && filesToParse.ContainsKey(FileName))
|
||||
filesToParse[FileName] = true;
|
||||
}
|
||||
|
||||
public void SetAllInProjectChanged()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (string s in open_files.Keys.ToArray())
|
||||
foreach (string s in filesToParse.Keys.ToArray())
|
||||
{
|
||||
if (ProjectFactory.Instance.CurrentProject.ContainsSourceFile(s))
|
||||
open_files[s] = true;
|
||||
filesToParse[s] = true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -151,10 +153,10 @@ namespace VisualPascalABC
|
|||
{
|
||||
Dictionary<string, string> recomp_files = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
bool is_comp = false;
|
||||
foreach (string FileName in open_files.Keys.ToArray()) // копирование ключей обязательно, иначе будет InvalidOperationException EVA
|
||||
foreach (string FileName in filesToParse.Keys.ToArray()) // копирование ключей обязательно, иначе будет InvalidOperationException EVA
|
||||
{
|
||||
|
||||
if (open_files[FileName])
|
||||
if (filesToParse[FileName])
|
||||
{
|
||||
is_comp = true;
|
||||
CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController();
|
||||
|
|
@ -165,7 +167,7 @@ namespace VisualPascalABC
|
|||
long cur_mem = Environment.WorkingSet;
|
||||
CodeCompletion.DomConverter dc = controller.Compile(FileName, text);
|
||||
mem_delta += Environment.WorkingSet - cur_mem;
|
||||
open_files[FileName] = false;
|
||||
filesToParse[FileName] = false;
|
||||
if (dc.is_compiled)
|
||||
{
|
||||
//CodeCompletion.CodeCompletionController.comp_modules.Remove(file_name);
|
||||
|
|
@ -177,7 +179,7 @@ namespace VisualPascalABC
|
|||
}
|
||||
CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc;
|
||||
recomp_files[FileName] = FileName;
|
||||
open_files[FileName] = false;
|
||||
filesToParse[FileName] = false;
|
||||
if (ParseInformationUpdated != null)
|
||||
ParseInformationUpdated(dc.visitor.entry_scope, FileName);
|
||||
}
|
||||
|
|
@ -185,7 +187,7 @@ namespace VisualPascalABC
|
|||
CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc;
|
||||
}
|
||||
}
|
||||
foreach (string FileName in open_files.Keys.ToArray()) // копирование ключей обязательно, иначе будет InvalidOperationException EVA
|
||||
foreach (string FileName in filesToParse.Keys.ToArray()) // копирование ключей обязательно, иначе будет InvalidOperationException EVA
|
||||
{
|
||||
CodeCompletion.DomConverter dc = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter;
|
||||
CodeCompletion.SymScope ss = null;
|
||||
|
|
@ -211,7 +213,7 @@ namespace VisualPascalABC
|
|||
for (int i = 0; i < ss.used_units.Count; i++)
|
||||
{
|
||||
string s = ss.used_units[i].file_name;
|
||||
if (s != null && open_files.ContainsKey(s) && recomp_files.ContainsKey(s))
|
||||
if (s != null && filesToParse.ContainsKey(s) && recomp_files.ContainsKey(s))
|
||||
{
|
||||
is_comp = true;
|
||||
CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController();
|
||||
|
|
@ -220,7 +222,7 @@ namespace VisualPascalABC
|
|||
long cur_mem = Environment.WorkingSet;
|
||||
dc = controller.Compile(FileName, text);
|
||||
mem_delta += Environment.WorkingSet - cur_mem;
|
||||
open_files[FileName] = false;
|
||||
filesToParse[FileName] = false;
|
||||
CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc;
|
||||
if (dc.is_compiled)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ namespace VisualPascalABC
|
|||
}
|
||||
if (fnd_scope != null)
|
||||
{
|
||||
foreach (string FileName in CodeCompletionParserController.open_files.Keys)
|
||||
foreach (string FileName in CodeCompletionParserController.filesToParse.Keys)
|
||||
{
|
||||
CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController();
|
||||
string text = VisualPABCSingleton.MainForm.VisualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace VisualPascalABC
|
|||
CompilerOptions1.UseDllForSystemUnits = false;
|
||||
CompilerOptions1.RunWithEnvironment = RunWithEnvironment;
|
||||
bool savePCU = Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate;
|
||||
if (Path.GetDirectoryName(CompilerOptions1.SourceFileName).ToLower() == ((string)WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent]).ToLower())
|
||||
if (Path.GetDirectoryName(CompilerOptions1.SourceFileName).ToLower() == WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent].ToLower())
|
||||
Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = false;
|
||||
|
||||
if (RuntimeServicesModule != null)
|
||||
|
|
@ -127,7 +127,7 @@ namespace VisualPascalABC
|
|||
|
||||
//CompilerOptions1.SavePCUInThreadPull = true;
|
||||
bool savePCU = Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate;
|
||||
if (Path.GetDirectoryName(FileName).ToLower() == ((string)WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent]).ToLower())
|
||||
if (Path.GetDirectoryName(FileName).ToLower() == WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent].ToLower())
|
||||
Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = false;
|
||||
|
||||
//MessageBox.Show("111");
|
||||
|
|
@ -223,7 +223,7 @@ namespace VisualPascalABC
|
|||
|
||||
//CompilerOptions1.SavePCUInThreadPull = true;
|
||||
__savePCU = Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate;
|
||||
if (Path.GetDirectoryName(FileName).ToLower() == ((string)WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent]).ToLower())
|
||||
if (Path.GetDirectoryName(FileName).ToLower() == WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent].ToLower())
|
||||
Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = false;
|
||||
|
||||
Workbench.VisualEnvironmentCompiler.Compiler.OnChangeCompilerState += CompilationOnChangeCompilerState;
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ namespace VisualPascalABC
|
|||
internal static string WorkingDirectory = null;
|
||||
internal static string WorkingDirectoryInOptionsFile = null;
|
||||
internal static string LibSourceDirectory = null;
|
||||
internal static Hashtable StandartDirectories;
|
||||
internal static Dictionary<string, string> StandartDirectories;
|
||||
internal static System.Threading.Thread MainProgramThread;
|
||||
internal static bool SetCurrentTabPageIfWriteToOutputWindow = false;
|
||||
internal static bool WorkingDirectoryExsist
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
{$HiddenIdents}
|
||||
unit SPythonSystem;
|
||||
|
||||
{$reference '%GAC%\System.dll'}
|
||||
{$reference '%GAC%\mscorlib.dll'}
|
||||
{$reference '%GAC%\System.Core.dll'}
|
||||
{$reference '%GAC%\System.Numerics.dll'}
|
||||
// В SPython данной версии нет возможности использовать пространства имен
|
||||
// {$reference '%GAC%\System.dll'}
|
||||
// {$reference '%GAC%\mscorlib.dll'}
|
||||
// {$reference '%GAC%\System.Core.dll'}
|
||||
// {$reference '%GAC%\System.Numerics.dll'}
|
||||
|
||||
interface
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue