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