Деактивация кнопок, связанных с Intellisense, для языков без Intellisense + разделение ILanguageInformation на два интерфейса (#3378)

* Refactor language information classes

* Implement SimpleLanguageInformation abstract class

* Move some properties to SimpleLanguageInformation

* Implement format and debug buttons disabling if Intellisense is not supported for current language

* Add Intellisense available check in FormsExtensions to deactivate menu items if needed

* Change function interfaces in VisibilityService

* Replace CodeCompletionController.CurrentParser null checks with IntellisenseAvailable method call

* Refactor IParser and BaseParser to deduplicate code

* Fix BuildTreeInSpecialMode in SPythonParser

* Add SimpleParser class for new languages without Intellisense

* Delete duplicate SetDebugButtonsEnabled function

* Add Intellisense available check in RunService when attaching debugger

* Delete inner check in SetDebugButtonsEnabled to improve architecture

* Change CurrentParser property in CodeCompletion to be CurrentLanguage

* Divide ILanguageInformation into two interfaces (creating new ILanguageIntellisenseSupport)

* Fix LanguageIntellisenseSupport initialization in BaseLanguage

* Fix RunService fictive_attach logic

* Disable Intellisense parsing for languages without Intellisense support

* Add DefaultLanguageInformation abstract class

* Add default implementation for SetSemanticConstants in BaseLanguage

* Simplify IParser interface

* Update developer guide documentation
This commit is contained in:
Александр Земляк 2026-01-27 22:25:28 +03:00 committed by GitHub
parent 333201895f
commit b23f9c96d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
69 changed files with 4244 additions and 4249 deletions

File diff suppressed because it is too large Load diff

View file

@ -11,6 +11,7 @@ namespace Languages.SPython
public SPythonLanguage() : base( public SPythonLanguage() : base(
languageInformation: new Frontend.Data.SPythonLanguageInformation(), languageInformation: new Frontend.Data.SPythonLanguageInformation(),
languageIntellisenseSupport: new Frontend.Data.SPythonIntellisenseSupport(),
parser: new SPythonParser.SPythonLanguageParser(), parser: new SPythonParser.SPythonLanguageParser(),
docParser: null, docParser: null,

View file

@ -14,32 +14,13 @@ namespace SPythonParser
{ {
public List<ISyntaxTreeConverter> SyntaxTreeConvertersForIntellisense { get; set; } public List<ISyntaxTreeConverter> SyntaxTreeConvertersForIntellisense { get; set; }
public override void Reset()
{
CompilerDirectives = new List<compiler_directive>();
Errors.Clear();
}
protected override void PreBuildTree(string FileName)
{
CompilerDirectives = new List<compiler_directive>();
}
protected override syntax_tree_node BuildTreeInNormalMode(string FileName, string Text, bool compilingNotMainProgram, List<string> DefinesList = null) protected override syntax_tree_node BuildTreeInNormalMode(string FileName, string Text, bool compilingNotMainProgram, List<string> DefinesList = null)
{ {
Errors.Clear();
Warnings.Clear();
syntax_tree_node root = Parse(Text, FileName, false, compilingNotMainProgram, DefinesList); syntax_tree_node root = Parse(Text, FileName, false, compilingNotMainProgram, DefinesList);
if (Errors.Count > 0) if (Errors.Count > 0)
return null; return null;
if (root != null && root is compilation_unit)
(root as compilation_unit).file_name = FileName;
return root; return root;
} }
@ -114,15 +95,11 @@ namespace SPythonParser
protected override syntax_tree_node BuildTreeInSpecialMode(string FileName, string Text, bool compilingNotMainProgram) protected override syntax_tree_node BuildTreeInSpecialMode(string FileName, string Text, bool compilingNotMainProgram)
{ {
Errors.Clear(); return Parse(Text, FileName, compilingNotMainProgram: compilingNotMainProgram);
return Parse(Text, FileName, compilingNotMainProgram);
} }
protected override syntax_tree_node BuildTreeInFormatterMode(string FileName, string Text) protected override syntax_tree_node BuildTreeInFormatterMode(string FileName, string Text)
{ {
Errors.Clear();
return Parse(Text, FileName, true); return Parse(Text, FileName, true);
} }

View file

@ -19,7 +19,6 @@ namespace CodeCompletion
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;
static CodeCompletionController() static CodeCompletionController()
{ {
@ -48,6 +47,11 @@ namespace CodeCompletion
// static string cur_ext = ".pas"; // static string cur_ext = ".pas";
private static ILanguage currentLanguage; private static ILanguage currentLanguage;
/// <summary>
/// Запоминает язык текущего открытого файла.
/// Если язык файла не поддерживается в системе, то ошибка не выбрасывается,
/// текущему языку присваивается null.
/// </summary>
public static void SetLanguage(string fileName) public static void SetLanguage(string fileName)
{ {
currentLanguage = LanguageProvider.SelectLanguageByExtensionSafe(fileName); currentLanguage = LanguageProvider.SelectLanguageByExtensionSafe(fileName);
@ -58,14 +62,21 @@ namespace CodeCompletion
pabcNamespaces.Clear(); pabcNamespaces.Clear();
} }
// нужно переделать на использование ILanguage EVA public static ILanguage CurrentLanguage
public static IParser CurrentParser
{ {
get get
{ {
return currentLanguage?.Parser; return currentLanguage;
} }
} }
/// <summary>
/// Поддерживается ли Intellisense для текущего языка
/// </summary>
public static bool IntellisenseAvailable()
{
return CurrentLanguage != null && CurrentLanguage.LanguageIntellisenseSupport != null;
}
public DomConverter Compile(string FileName, string Text) public DomConverter Compile(string FileName, string Text)
{ {
@ -75,11 +86,9 @@ namespace CodeCompletion
ILanguage currentLanguage = LanguageProvider.SelectLanguageByExtension(FileName); ILanguage currentLanguage = LanguageProvider.SelectLanguageByExtension(FileName);
Parser = currentLanguage.Parser;
try try
{ {
cu = Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal, false); cu = currentLanguage.Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal, false);
ErrorsList.Clear(); ErrorsList.Clear();
@ -117,7 +126,7 @@ namespace CodeCompletion
string tmp = ParsersHelper.GetModifiedProgramm(Text); string tmp = ParsersHelper.GetModifiedProgramm(Text);
if (tmp != null) if (tmp != null)
{ {
cu = Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Special, false); cu = currentLanguage.Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Special, false);
} }
ErrorsList.Clear(); ErrorsList.Clear();
@ -179,11 +188,9 @@ namespace CodeCompletion
if (currentLanguage == null) if (currentLanguage == null)
return dconv; return dconv;
Parser = currentLanguage.Parser;
if (Text != null) if (Text != null)
{ {
cu = Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal, true); cu = currentLanguage.Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal, true);
} }
ErrorsList.Clear(); ErrorsList.Clear();
Warnings.Clear(); Warnings.Clear();
@ -212,7 +219,7 @@ namespace CodeCompletion
string tmp = ParsersHelper.GetModifiedProgramm(Text); string tmp = ParsersHelper.GetModifiedProgramm(Text);
if (tmp != null) if (tmp != null)
{ {
cu = Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Special, true); cu = currentLanguage.Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Special, true);
} }
ErrorsList.Clear(); ErrorsList.Clear();
@ -252,31 +259,31 @@ namespace CodeCompletion
public PascalABCCompiler.Parsers.KeywordKind GetKeywordKind(string name) public PascalABCCompiler.Parsers.KeywordKind GetKeywordKind(string name)
{ {
if (CodeCompletionController.CurrentParser != null) if (CodeCompletionController.IntellisenseAvailable())
return CodeCompletionController.CurrentParser.LanguageInformation.GetKeywordKind(name); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetKeywordKind(name);
return PascalABCCompiler.Parsers.KeywordKind.None; return PascalABCCompiler.Parsers.KeywordKind.None;
} }
public bool IsKeyword(string name) public bool IsKeyword(string name)
{ {
if (CodeCompletionController.CurrentParser != null) if (CodeCompletionController.IntellisenseAvailable())
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.IsKeyword(name); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsKeyword(name);
} }
return false; return false;
} }
public List<string> GetKeywords() public List<string> GetKeywords()
{ {
if (CodeCompletionController.CurrentParser != null) if (CodeCompletionController.IntellisenseAvailable())
return CodeCompletionController.CurrentParser.LanguageInformation.KeywordsStorage.KeywordsForIntellisenseList; return CodeCompletionController.CurrentLanguage.LanguageInformation.KeywordsStorage.KeywordsForIntellisenseList;
return new List<string>(); return new List<string>();
} }
public List<string> GetTypeKeywords() public List<string> GetTypeKeywords()
{ {
if (CodeCompletionController.CurrentParser != null) if (CodeCompletionController.IntellisenseAvailable())
return CodeCompletionController.CurrentParser.LanguageInformation.KeywordsStorage.TypeKeywords; return CodeCompletionController.CurrentLanguage.LanguageInformation.KeywordsStorage.TypeKeywords;
return new List<string>(); return new List<string>();
} }

View file

@ -224,7 +224,7 @@ namespace CodeCompletion
if (elem == null || !(elem is ProcScope)) if (elem == null || !(elem is ProcScope))
{ {
int pos = 0; int pos = 0;
string full_name = CodeCompletionController.CurrentParser.LanguageInformation.ConstructOverridedMethodHeader(procs[i], out pos); string full_name = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.ConstructOverridedMethodHeader(procs[i], out pos);
SymInfo si = new SymInfo(full_name.Substring(pos), procs[i].si.kind, full_name); SymInfo si = new SymInfo(full_name.Substring(pos), procs[i].si.kind, full_name);
si.acc_mod = procs[i].si.acc_mod; si.acc_mod = procs[i].si.acc_mod;
meths.Add(si); meths.Add(si);
@ -605,7 +605,7 @@ namespace CodeCompletion
} }
} }
string s = CodeCompletionController.CurrentParser.LanguageInformation.GetSimpleDescriptionWithoutNamespace((si as ElementScope).sc as PascalABCCompiler.Parsers.ITypeScope); string s = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetSimpleDescriptionWithoutNamespace((si as ElementScope).sc as PascalABCCompiler.Parsers.ITypeScope);
if (s != out_si.name) if (s != out_si.name)
out_si.addit_name = s; out_si.addit_name = s;
} }
@ -765,7 +765,7 @@ namespace CodeCompletion
pos.metadata_type = MetadataType.Class; pos.metadata_type = MetadataType.Class;
if (!only_check) if (!only_check)
{ {
pos.metadata = CodeCompletionController.CurrentParser.LanguageInformation.GetCompiledTypeRepresentation(cs.CompiledType, cs.CompiledType, ref pos.line, ref pos.column); pos.metadata = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetCompiledTypeRepresentation(cs.CompiledType, cs.CompiledType, ref pos.line, ref pos.column);
Type t = cs.CompiledType; Type t = cs.CompiledType;
int lines = 0; int lines = 0;
int ind = pos.metadata.IndexOf('\n'); int ind = pos.metadata.IndexOf('\n');
@ -787,7 +787,7 @@ namespace CodeCompletion
pos.metadata_title = prepare_file_name(cfs.CompiledField.DeclaringType.Name); pos.metadata_title = prepare_file_name(cfs.CompiledField.DeclaringType.Name);
if (!only_check) if (!only_check)
{ {
pos.metadata = CodeCompletionController.CurrentParser.LanguageInformation.GetCompiledTypeRepresentation(cfs.CompiledField.DeclaringType, cfs.CompiledField, ref pos.line, ref pos.column); pos.metadata = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetCompiledTypeRepresentation(cfs.CompiledField.DeclaringType, cfs.CompiledField, ref pos.line, ref pos.column);
Type t = cfs.CompiledField.DeclaringType; Type t = cfs.CompiledField.DeclaringType;
int lines = 0; int lines = 0;
int ind = pos.metadata.IndexOf('\n'); int ind = pos.metadata.IndexOf('\n');
@ -809,7 +809,7 @@ namespace CodeCompletion
pos.metadata_type = MetadataType.Method; pos.metadata_type = MetadataType.Method;
if (!only_check) if (!only_check)
{ {
pos.metadata = CodeCompletionController.CurrentParser.LanguageInformation.GetCompiledTypeRepresentation(cms.CompiledMethod.DeclaringType, cms.CompiledMethod, ref pos.line, ref pos.column); pos.metadata = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetCompiledTypeRepresentation(cms.CompiledMethod.DeclaringType, cms.CompiledMethod, ref pos.line, ref pos.column);
Type t = cms.CompiledMethod.DeclaringType; Type t = cms.CompiledMethod.DeclaringType;
int lines = 0; int lines = 0;
int ind = pos.metadata.IndexOf('\n'); int ind = pos.metadata.IndexOf('\n');
@ -829,7 +829,7 @@ namespace CodeCompletion
pos.metadata_type = MetadataType.Property; pos.metadata_type = MetadataType.Property;
if (!only_check) if (!only_check)
{ {
pos.metadata = CodeCompletionController.CurrentParser.LanguageInformation.GetCompiledTypeRepresentation((ss as CompiledPropertyScope).CompiledProperty.DeclaringType, (ss as CompiledPropertyScope).CompiledProperty, ref pos.line, ref pos.column); pos.metadata = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetCompiledTypeRepresentation((ss as CompiledPropertyScope).CompiledProperty.DeclaringType, (ss as CompiledPropertyScope).CompiledProperty, ref pos.line, ref pos.column);
Type t = cps.CompiledProperty.DeclaringType; Type t = cps.CompiledProperty.DeclaringType;
int lines = 0; int lines = 0;
int ind = pos.metadata.IndexOf('\n'); int ind = pos.metadata.IndexOf('\n');
@ -849,7 +849,7 @@ namespace CodeCompletion
pos.metadata_type = MetadataType.Constructor; pos.metadata_type = MetadataType.Constructor;
if (!only_check) if (!only_check)
{ {
pos.metadata = CodeCompletionController.CurrentParser.LanguageInformation.GetCompiledTypeRepresentation(ccs.CompiledConstructor.DeclaringType, ccs.CompiledConstructor, ref pos.line, ref pos.column); pos.metadata = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetCompiledTypeRepresentation(ccs.CompiledConstructor.DeclaringType, ccs.CompiledConstructor, ref pos.line, ref pos.column);
Type t = ccs.CompiledConstructor.DeclaringType; Type t = ccs.CompiledConstructor.DeclaringType;
int lines = 0; int lines = 0;
int ind = pos.metadata.IndexOf('\n'); int ind = pos.metadata.IndexOf('\n');
@ -869,7 +869,7 @@ namespace CodeCompletion
pos.metadata_type = MetadataType.Event; pos.metadata_type = MetadataType.Event;
if (!only_check) if (!only_check)
{ {
pos.metadata = CodeCompletionController.CurrentParser.LanguageInformation.GetCompiledTypeRepresentation(ces.CompiledEvent.DeclaringType, ces.CompiledEvent, ref pos.line, ref pos.column); pos.metadata = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetCompiledTypeRepresentation(ces.CompiledEvent.DeclaringType, ces.CompiledEvent, ref pos.line, ref pos.column);
Type t = ces.CompiledEvent.DeclaringType; Type t = ces.CompiledEvent.DeclaringType;
int lines = 0; int lines = 0;
int ind = pos.metadata.IndexOf('\n'); int ind = pos.metadata.IndexOf('\n');
@ -1113,7 +1113,7 @@ namespace CodeCompletion
if (ps.is_constructor) if (ps.is_constructor)
si = new ElementScope(ps.declaringType); si = new ElementScope(ps.declaringType);
} }
string[] description = CodeCompletionController.CurrentParser.LanguageInformation.GetIndexerString(si); string[] description = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetIndexerString(si);
if (description != null) if (description != null)
for (int i = 0; i < description.Length; i++) for (int i = 0; i < description.Length; i++)
{ {

View file

@ -308,7 +308,7 @@ namespace CodeCompletion
var co = new CompilerOptions(); var co = new CompilerOptions();
co.SavePCU = false; co.SavePCU = false;
co.GenerateCode = false; co.GenerateCode = false;
if (!currentUnitLanguage.ApplySyntaxTreeConvertersForIntellisense) if (!currentUnitLanguage.LanguageIntellisenseSupport.ApplySyntaxTreeConvertersForIntellisense)
co.UnitSyntaxTree = cu; co.UnitSyntaxTree = cu;
co.SourceFileName = cu.source_context.FileName; co.SourceFileName = cu.source_context.FileName;
co.ForIntellisense = true; co.ForIntellisense = true;
@ -474,9 +474,9 @@ namespace CodeCompletion
else if (has_lambdas(_assign.from)) else if (has_lambdas(_assign.from))
_assign.from.visit(this); _assign.from.visit(this);
else if (_assign.to is ident && cur_scope != null && cur_scope.Name.StartsWith("<>lambda") else if (_assign.to is ident && cur_scope != null && cur_scope.Name.StartsWith("<>lambda")
&& (_assign.to as ident).name.Equals(currentUnitLanguage.LanguageInformation.ResultVariableName, currentUnitLanguage.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase)) && (_assign.to as ident).name.Equals(currentUnitLanguage.LanguageIntellisenseSupport.ResultVariableName, currentUnitLanguage.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase))
{ {
var sc = cur_scope.FindNameOnlyInThisType(currentUnitLanguage.LanguageInformation.ResultVariableName); var sc = cur_scope.FindNameOnlyInThisType(currentUnitLanguage.LanguageIntellisenseSupport.ResultVariableName);
if (sc is ElementScope) if (sc is ElementScope)
{ {
ElementScope es = sc as ElementScope; ElementScope es = sc as ElementScope;
@ -935,7 +935,7 @@ namespace CodeCompletion
{ {
returned_scope = TypeTable.string_type;//entry_scope.FindName(StringConstants.string_type_name); returned_scope = TypeTable.string_type;//entry_scope.FindName(StringConstants.string_type_name);
//cnst_val.prim_val = "'"+_string_const.Value+"'"; //cnst_val.prim_val = "'"+_string_const.Value+"'";
cnst_val.prim_val = this.converter.controller.Parser.LanguageInformation.GetStringForString(_string_const.Value); cnst_val.prim_val = currentUnitLanguage.LanguageIntellisenseSupport.GetStringForString(_string_const.Value);
} }
public override void visit(expression_list _expression_list) public override void visit(expression_list _expression_list)
@ -2094,7 +2094,7 @@ namespace CodeCompletion
returned_scope = ps; returned_scope = ps;
var resultName = currentUnitLanguage.LanguageInformation.ResultVariableName; var resultName = currentUnitLanguage.LanguageIntellisenseSupport.ResultVariableName;
if (resultName != null) if (resultName != null)
{ {
ps.AddName(resultName, new ElementScope(new SymInfo(resultName, SymbolKind.Variable, resultName), ps.return_type, ps)); ps.AddName(resultName, new ElementScope(new SymInfo(resultName, SymbolKind.Variable, resultName), ps.return_type, ps));
@ -2170,7 +2170,7 @@ namespace CodeCompletion
if (bl.program_code.subnodes.Count == 1) if (bl.program_code.subnodes.Count == 1)
{ {
var ass = bl.program_code.subnodes[0] as assign; var ass = bl.program_code.subnodes[0] as assign;
if (ass != null && ass.to is ident && (ass.to as ident).name.Equals(currentUnitLanguage.LanguageInformation.ResultVariableName, currentUnitLanguage.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase)) if (ass != null && ass.to is ident && (ass.to as ident).name.Equals(currentUnitLanguage.LanguageIntellisenseSupport.ResultVariableName, currentUnitLanguage.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase))
{ {
if (!(ass.from is nil_const)) if (!(ass.from is nil_const))
{ {
@ -2262,7 +2262,7 @@ namespace CodeCompletion
if (_type_declaration.type_def is class_definition) if (_type_declaration.type_def is class_definition)
{ {
class_definition cl_def = _type_declaration.type_def as class_definition; class_definition cl_def = _type_declaration.type_def as class_definition;
string key = this.converter.controller.Parser.LanguageInformation.GetClassKeyword(cl_def.keyword); string key = currentUnitLanguage.LanguageIntellisenseSupport.GetClassKeyword(cl_def.keyword);
if (cl_def.attribute == class_attribute.Auto) if (cl_def.attribute == class_attribute.Auto)
key = "auto " + key; key = "auto " + key;
else if ((cl_def.attribute & class_attribute.Abstract) == class_attribute.Abstract) else if ((cl_def.attribute & class_attribute.Abstract) == class_attribute.Abstract)
@ -2528,7 +2528,7 @@ namespace CodeCompletion
var languageUsingStandardUnit = Languages.Facade.LanguageProvider.Instance.Languages.Find(lang => lang.SystemUnitNames.Contains(unitName)); var languageUsingStandardUnit = Languages.Facade.LanguageProvider.Instance.Languages.Find(lang => lang.SystemUnitNames.Contains(unitName));
// Пока что добавили возможость грубо отключить добавление NET пространств имен по умолчанию здесь (второе условие нужно, чтобы в стандартные модули языка они тоже не добавлялись) EVA // Пока что добавили возможость грубо отключить добавление NET пространств имен по умолчанию здесь (второе условие нужно, чтобы в стандартные модули языка они тоже не добавлялись) EVA
if (currentUnitLanguage.LanguageInformation.AddStandardNetNamespacesToUserScope && (languageUsingStandardUnit?.LanguageInformation.AddStandardNetNamespacesToUserScope ?? true)) if (currentUnitLanguage.LanguageIntellisenseSupport.AddStandardNetNamespacesToUserScope && (languageUsingStandardUnit?.LanguageIntellisenseSupport.AddStandardNetNamespacesToUserScope ?? true))
namespaces.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetNamespaces(_as)); namespaces.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetNamespaces(_as));
InterfaceUnitScope unit_scope = null; InterfaceUnitScope unit_scope = null;
@ -2661,7 +2661,7 @@ namespace CodeCompletion
{ {
// добавление стандартных типов можно делать в отдельный фиктивный модуль, как в основном компиляторе // добавление стандартных типов можно делать в отдельный фиктивный модуль, как в основном компиляторе
// это позволит работать директиве DisableStandardUnits, а также не будет засорять сам стандартный модуль типами EVA // это позволит работать директиве DisableStandardUnits, а также не будет засорять сам стандартный модуль типами EVA
add_standart_types(entry_scope, language.LanguageInformation); add_standart_types(entry_scope, language.LanguageIntellisenseSupport);
if (language == Languages.Facade.LanguageProvider.Instance.MainLanguage) if (language == Languages.Facade.LanguageProvider.Instance.MainLanguage)
{ {
@ -2684,7 +2684,7 @@ namespace CodeCompletion
} }
} }
if (currentUnitLanguage.ApplySyntaxTreeConvertersForIntellisense) if (currentUnitLanguage.LanguageIntellisenseSupport.ApplySyntaxTreeConvertersForIntellisense)
{ {
foreach (ISyntaxTreeConverter converter in currentUnitLanguage.SyntaxTreeConverters) foreach (ISyntaxTreeConverter converter in currentUnitLanguage.SyntaxTreeConverters)
{ {
@ -2729,7 +2729,8 @@ namespace CodeCompletion
} }
} }
if (currentUnitLanguage.ApplySyntaxTreeConvertersForIntellisense && currentUnitLanguage.LanguageInformation.SyntaxTreeIsConvertedAfterUsedModulesCompilation) if (currentUnitLanguage.LanguageIntellisenseSupport.ApplySyntaxTreeConvertersForIntellisense
&& currentUnitLanguage.LanguageInformation.SyntaxTreeIsConvertedAfterUsedModulesCompilation)
{ {
var namesFromUsedUnits = CollectNamesFromUsedUnits(cur_scope); var namesFromUsedUnits = CollectNamesFromUsedUnits(cur_scope);
@ -2889,7 +2890,7 @@ namespace CodeCompletion
//get_standart_types(dc.stv); //get_standart_types(dc.stv);
// для SPython, например, не нужно подсказывать стандартные модули в программе, это условие для этого EVA // для SPython, например, не нужно подсказывать стандартные модули в программе, это условие для этого EVA
if (currentUnitLanguage.LanguageInformation.AddStandardUnitNamesToUserScope) if (currentUnitLanguage.LanguageIntellisenseSupport.AddStandardUnitNamesToUserScope)
{ {
entry_scope.AddName(unitName, dc.visitor.entry_scope); entry_scope.AddName(unitName, dc.visitor.entry_scope);
} }
@ -2907,7 +2908,7 @@ namespace CodeCompletion
dc.visitor.entry_scope.InitAssemblies(); dc.visitor.entry_scope.InitAssemblies();
entry_scope.AddUsedUnit(dc.visitor.entry_scope); entry_scope.AddUsedUnit(dc.visitor.entry_scope);
//get_standart_types(dc.stv); //get_standart_types(dc.stv);
if (currentUnitLanguage.LanguageInformation.AddStandardUnitNamesToUserScope) if (currentUnitLanguage.LanguageIntellisenseSupport.AddStandardUnitNamesToUserScope)
{ {
entry_scope.AddName(unitName, dc.visitor.entry_scope); entry_scope.AddName(unitName, dc.visitor.entry_scope);
} }
@ -3153,7 +3154,7 @@ namespace CodeCompletion
currentUnitLanguage = Languages.Facade.LanguageProvider.Instance.SelectLanguageByName(_program_module.Language); currentUnitLanguage = Languages.Facade.LanguageProvider.Instance.SelectLanguageByName(_program_module.Language);
// Пока что добавили возможость грубо отключить добавление NET пространств имен по умолчанию здесь EVA // Пока что добавили возможость грубо отключить добавление NET пространств имен по умолчанию здесь EVA
if (currentUnitLanguage.LanguageInformation.AddStandardNetNamespacesToUserScope) if (currentUnitLanguage.LanguageIntellisenseSupport.AddStandardNetNamespacesToUserScope)
namespaces.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetNamespaces(_as)); namespaces.AddRange(PascalABCCompiler.NetHelper.NetHelper.GetNamespaces(_as));
//List<Scope> netScopes = new List<Scope>(); //List<Scope> netScopes = new List<Scope>();
@ -3261,7 +3262,7 @@ namespace CodeCompletion
} }
} }
if (currentUnitLanguage.ApplySyntaxTreeConvertersForIntellisense) if (currentUnitLanguage.LanguageIntellisenseSupport.ApplySyntaxTreeConvertersForIntellisense)
{ {
foreach (ISyntaxTreeConverter converter in currentUnitLanguage.SyntaxTreeConverters) foreach (ISyntaxTreeConverter converter in currentUnitLanguage.SyntaxTreeConverters)
{ {
@ -3310,7 +3311,8 @@ namespace CodeCompletion
} }
} }
if (currentUnitLanguage.ApplySyntaxTreeConvertersForIntellisense && currentUnitLanguage.LanguageInformation.SyntaxTreeIsConvertedAfterUsedModulesCompilation) if (currentUnitLanguage.LanguageIntellisenseSupport.ApplySyntaxTreeConvertersForIntellisense
&& currentUnitLanguage.LanguageInformation.SyntaxTreeIsConvertedAfterUsedModulesCompilation)
{ {
var namesFromUsedUnits = CollectNamesFromUsedUnits(cur_scope); var namesFromUsedUnits = CollectNamesFromUsedUnits(cur_scope);
@ -3387,7 +3389,7 @@ namespace CodeCompletion
} }
} }
private void add_standart_types(SymScope cur_scope, ILanguageInformation languageInfo) private void add_standart_types(SymScope cur_scope, ILanguageIntellisenseSupport languageIntellisenseSupport)
{ {
var standardTypesData = new List<Tuple<PascalABCCompiler.Parsers.KeywordKind, CompiledScope>>() var standardTypesData = new List<Tuple<PascalABCCompiler.Parsers.KeywordKind, CompiledScope>>()
@ -3415,7 +3417,7 @@ namespace CodeCompletion
var keywordKind = data.Item1; var keywordKind = data.Item1;
var type = data.Item2; var type = data.Item2;
var type_name = languageInfo.GetStandardTypeByKeyword(keywordKind); var type_name = languageIntellisenseSupport.GetStandardTypeByKeyword(keywordKind);
if (type_name != null) if (type_name != null)
{ {
@ -4647,7 +4649,7 @@ namespace CodeCompletion
{ {
returned_scope = TypeTable.char_type;//entry_scope.FindName(StringConstants.char_type_name); returned_scope = TypeTable.char_type;//entry_scope.FindName(StringConstants.char_type_name);
if (in_kav) if (in_kav)
cnst_val.prim_val = this.converter.controller.Parser.LanguageInformation.GetStringForChar(_char_const.cconst); cnst_val.prim_val = currentUnitLanguage.LanguageIntellisenseSupport.GetStringForChar(_char_const.cconst);
//cnst_val.prim_val = "'"+_char_const.cconst.ToString()+"'"; //cnst_val.prim_val = "'"+_char_const.cconst.ToString()+"'";
else cnst_val.prim_val = _char_const.cconst; else cnst_val.prim_val = _char_const.cconst;
} }
@ -4660,7 +4662,7 @@ namespace CodeCompletion
public override void visit(sharp_char_const _sharp_char_const) public override void visit(sharp_char_const _sharp_char_const)
{ {
returned_scope = TypeTable.char_type;//entry_scope.FindName(StringConstants.char_type_name); returned_scope = TypeTable.char_type;//entry_scope.FindName(StringConstants.char_type_name);
cnst_val.prim_val = this.converter.controller.Parser.LanguageInformation.GetStringForSharpChar(_sharp_char_const.char_num); cnst_val.prim_val = currentUnitLanguage.LanguageIntellisenseSupport.GetStringForSharpChar(_sharp_char_const.char_num);
} }
private bool in_kav=true; private bool in_kav=true;
@ -5788,7 +5790,7 @@ namespace CodeCompletion
TypeScope saved_return_type = ps.return_type; TypeScope saved_return_type = ps.return_type;
if (!disable_lambda_compilation) if (!disable_lambda_compilation)
{ {
string resultName = currentUnitLanguage.LanguageInformation.ResultVariableName; string resultName = currentUnitLanguage.LanguageIntellisenseSupport.ResultVariableName;
if (awaitedProcType != null) if (awaitedProcType != null)
{ {
var invokeMeth = awaitedProcType.FindNameOnlyInType("Invoke") as ProcScope; var invokeMeth = awaitedProcType.FindNameOnlyInType("Invoke") as ProcScope;

View file

@ -388,7 +388,7 @@ namespace CodeCompletion
public List<ProcScope> GetExtensionMethods(TypeScope ts, string name=null) public List<ProcScope> GetExtensionMethods(TypeScope ts, string name=null)
{ {
StringComparison comparison = CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; StringComparison comparison = CodeCompletionController.CurrentLanguage.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
if (ts is TypeSynonim) if (ts is TypeSynonim)
return GetExtensionMethods((ts as TypeSynonim).actType, name); return GetExtensionMethods((ts as TypeSynonim).actType, name);
@ -757,7 +757,7 @@ namespace CodeCompletion
SymScope minScope = null; SymScope minScope = null;
// задает нужна ли модификация алгоритма с обходом всех кандидатов EVA // задает нужна ли модификация алгоритма с обходом всех кандидатов EVA
bool findMinScope = CodeCompletionController.CurrentParser.LanguageInformation.UsesFunctionsOverlappingSourceContext; bool findMinScope = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.UsesFunctionsOverlappingSourceContext;
SymScope foundScope = FindScopeByLocation(line, column, ref minScope, findMinScope); SymScope foundScope = FindScopeByLocation(line, column, ref minScope, findMinScope);
@ -974,7 +974,7 @@ namespace CodeCompletion
if (o is SymScope) if (o is SymScope)
ss = o as SymScope; ss = o as SymScope;
else else
if (!CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) if (!CodeCompletionController.CurrentLanguage.CaseSensitive)
ss = (o as List<SymScope>)[0]; ss = (o as List<SymScope>)[0];
else else
{ {
@ -996,7 +996,7 @@ namespace CodeCompletion
} }
if (ss == null) return null; if (ss == null) return null;
TypeScope ts = ss as TypeScope; TypeScope ts = ss as TypeScope;
if (CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) if (CodeCompletionController.CurrentLanguage.CaseSensitive)
{ {
string shortName = System.Text.RegularExpressions.Regex.Replace(name, @"`\d+$", ""); string shortName = System.Text.RegularExpressions.Regex.Replace(name, @"`\d+$", "");
@ -1021,10 +1021,10 @@ namespace CodeCompletion
else else
if (members != null) if (members != null)
foreach (SymScope ss in members) foreach (SymScope ss in members)
if (string.Compare(ss.si.name, name, !CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) == 0) if (string.Compare(ss.si.name, name, !CodeCompletionController.CurrentLanguage.CaseSensitive) == 0)
if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1) if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1)
{ {
if (string.Compare(ss.loc.file_name, loc.file_name, !CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) == 0 && this != ss) if (string.Compare(ss.loc.file_name, loc.file_name, !CodeCompletionController.CurrentLanguage.CaseSensitive) == 0 && this != ss)
{ {
if (IsClassMember(ss) || IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num)) if (IsClassMember(ss) || IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num))
{ {
@ -1068,7 +1068,7 @@ namespace CodeCompletion
} }
else if (members != null) else if (members != null)
foreach (SymScope ss in members) foreach (SymScope ss in members)
if (string.Compare(ss.si.name, name, !CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) == 0) if (string.Compare(ss.si.name, name, !CodeCompletionController.CurrentLanguage.CaseSensitive) == 0)
if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1) if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1)
{ {
if (string.Compare(ss.loc.file_name, loc.file_name, true) == 0 && this != ss && ss.topScope != this) if (string.Compare(ss.loc.file_name, loc.file_name, true) == 0 && this != ss && ss.topScope != this)
@ -1405,7 +1405,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser?.LanguageInformation.GetSimpleDescription(this); return CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetSimpleDescription(this);
} }
} }
@ -1688,12 +1688,12 @@ namespace CodeCompletion
public override void BuildDescription() public override void BuildDescription()
{ {
si.description = CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); si.description = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
public void MakeDescription() public void MakeDescription()
{ {
si.description = CodeCompletionController.CurrentParser?.LanguageInformation.GetDescription(this); si.description = CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetDescription(this);
if (!string.IsNullOrEmpty(documentation)) if (!string.IsNullOrEmpty(documentation))
si.description += Environment.NewLine + documentation; si.description += Environment.NewLine + documentation;
} }
@ -1799,7 +1799,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser?.LanguageInformation.GetSimpleDescription(this); return CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetSimpleDescription(this);
} }
} }
@ -2271,7 +2271,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser?.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -2608,7 +2608,7 @@ namespace CodeCompletion
{ {
if (documentation != null && documentation.Length > 0 && documentation[0] == '-') return; if (documentation != null && documentation.Length > 0 && documentation[0] == '-') return;
this.si.description = this.ToString(); this.si.description = this.ToString();
this.si.addit_name = CodeCompletionController.CurrentParser?.LanguageInformation.GetShortName(this); this.si.addit_name = CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetShortName(this);
if (documentation != null) this.si.description += "\n" + this.documentation; if (documentation != null) this.si.description += "\n" + this.documentation;
} }
@ -2616,7 +2616,7 @@ namespace CodeCompletion
{ {
if (documentation != null && documentation.Length > 0 && documentation[0] == '-') return; if (documentation != null && documentation.Length > 0 && documentation[0] == '-') return;
si.description = ToString(); si.description = ToString();
si.addit_name = CodeCompletionController.CurrentParser.LanguageInformation.GetShortName(this); si.addit_name = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetShortName(this);
} }
public void AddTemplateParameter(string name) public void AddTemplateParameter(string name)
@ -2841,8 +2841,8 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
simp_descr = CodeCompletionController.CurrentParser?.LanguageInformation.GetSimpleDescription(this); simp_descr = CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetSimpleDescription(this);
return CodeCompletionController.CurrentParser?.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -2934,7 +2934,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -3055,7 +3055,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -3213,7 +3213,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -3915,7 +3915,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser?.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -4036,7 +4036,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
//return left.ToString() + ".." + right.ToString(); //return left.ToString() + ".." + right.ToString();
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -4236,7 +4236,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -4314,7 +4314,7 @@ namespace CodeCompletion
this.topScope = topScope; this.topScope = topScope;
if (baseScope == null) if (baseScope == null)
{ {
if (CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities) if (CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IncludeDotNetEntities)
switch (kind) switch (kind)
{ {
case SymbolKind.Struct: this.baseScope = TypeTable.get_compiled_type(new SymInfo(typeof(ValueType).Name, SymbolKind.Struct, typeof(ValueType).FullName), typeof(ValueType)); break; case SymbolKind.Struct: this.baseScope = TypeTable.get_compiled_type(new SymInfo(typeof(ValueType).Name, SymbolKind.Struct, typeof(ValueType).FullName), typeof(ValueType)); break;
@ -4330,10 +4330,10 @@ namespace CodeCompletion
si = new SymInfo("type", kind, "type"); si = new SymInfo("type", kind, "type");
switch (kind) switch (kind)
{ {
case SymbolKind.Struct: si.description = CodeCompletionController.CurrentParser.LanguageInformation.GetKeyword(PascalABCCompiler.Parsers.SymbolKind.Struct); break; case SymbolKind.Struct: si.description = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetKeyword(PascalABCCompiler.Parsers.SymbolKind.Struct); break;
case SymbolKind.Class: si.description = CodeCompletionController.CurrentParser.LanguageInformation.GetKeyword(PascalABCCompiler.Parsers.SymbolKind.Class); break; case SymbolKind.Class: si.description = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetKeyword(PascalABCCompiler.Parsers.SymbolKind.Class); break;
case SymbolKind.Interface: si.description = CodeCompletionController.CurrentParser.LanguageInformation.GetKeyword(PascalABCCompiler.Parsers.SymbolKind.Interface); break; case SymbolKind.Interface: si.description = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetKeyword(PascalABCCompiler.Parsers.SymbolKind.Interface); break;
case SymbolKind.Enum: si.description = CodeCompletionController.CurrentParser.LanguageInformation.GetKeyword(PascalABCCompiler.Parsers.SymbolKind.Enum); break; case SymbolKind.Enum: si.description = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetKeyword(PascalABCCompiler.Parsers.SymbolKind.Enum); break;
} }
} }
@ -4928,17 +4928,17 @@ namespace CodeCompletion
public override void BuildDescription() public override void BuildDescription()
{ {
si.description = CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); si.description = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
// Случай делегата // Случай делегата
if (aliased && this is ProcType) if (aliased && this is ProcType)
si.description = CodeCompletionController.CurrentParser.LanguageInformation.GetSynonimDescription(this); si.description = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetSynonimDescription(this);
} }
//opisanie, vysvechivaetsja v zheltkom okoshke //opisanie, vysvechivaetsja v zheltkom okoshke
public override string GetDescription() public override string GetDescription()
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
//dubl????? //dubl?????
@ -5471,7 +5471,7 @@ namespace CodeCompletion
public override void BuildDescription() public override void BuildDescription()
{ {
si.description = CodeCompletionController.CurrentParser?.LanguageInformation.GetDescription(this); si.description = CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetDescription(this);
} }
private SymInfo convertToDefaultNETNames(Type t, SymInfo si) private SymInfo convertToDefaultNETNames(Type t, SymInfo si)
@ -5772,7 +5772,7 @@ namespace CodeCompletion
} }
if (si.name == null) if (si.name == null)
AssemblyDocCache.AddDescribeToComplete(this.si, ctn); AssemblyDocCache.AddDescribeToComplete(this.si, ctn);
this.si.name = CodeCompletionController.CurrentParser?.LanguageInformation.GetShortName(this); this.si.name = CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetShortName(this);
this.si.kind = get_kind(); this.si.kind = get_kind();
this.si.description = GetDescription(); this.si.description = GetDescription();
@ -6131,7 +6131,7 @@ namespace CodeCompletion
public override string GetFullName() public override string GetFullName()
{ {
//return ctn.FullName; //return ctn.FullName;
return CodeCompletionController.CurrentParser.LanguageInformation.GetSimpleDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetSimpleDescription(this);
} }
public override List<ProcScope> GetOverridableMethods() public override List<ProcScope> GetOverridableMethods()
@ -6420,13 +6420,13 @@ namespace CodeCompletion
public override string GetDescription() public override string GetDescription()
{ {
return CodeCompletionController.CurrentParser?.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage?.LanguageIntellisenseSupport.GetDescription(this);
} }
public override SymInfo[] GetNames(ExpressionVisitor ev, PascalABCCompiler.Parsers.KeywordKind keyword, bool called_in_base) public override SymInfo[] GetNames(ExpressionVisitor ev, PascalABCCompiler.Parsers.KeywordKind keyword, bool called_in_base)
{ {
List<SymInfo> syms = new List<SymInfo>(); List<SymInfo> syms = new List<SymInfo>();
if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities) if (!CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IncludeDotNetEntities)
return syms.ToArray(); return syms.ToArray();
MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic |/*BindingFlags.Instance|*/BindingFlags.Static | BindingFlags.FlattenHierarchy); MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic |/*BindingFlags.Instance|*/BindingFlags.Static | BindingFlags.FlattenHierarchy);
List<MemberInfo> constrs = new List<MemberInfo>(); List<MemberInfo> constrs = new List<MemberInfo>();
@ -6552,7 +6552,7 @@ namespace CodeCompletion
public SymInfo[] GetStaticNames() public SymInfo[] GetStaticNames()
{ {
List<SymInfo> syms = new List<SymInfo>(); List<SymInfo> syms = new List<SymInfo>();
if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities) if (!CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IncludeDotNetEntities)
return syms.ToArray(); return syms.ToArray();
MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic |/*BindingFlags.Instance|*/BindingFlags.Static | BindingFlags.FlattenHierarchy); MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic |/*BindingFlags.Instance|*/BindingFlags.Static | BindingFlags.FlattenHierarchy);
@ -6637,7 +6637,7 @@ namespace CodeCompletion
public override SymInfo[] GetNamesAsInObject(ExpressionVisitor ev) public override SymInfo[] GetNamesAsInObject(ExpressionVisitor ev)
{ {
List<SymInfo> syms = new List<SymInfo>(); List<SymInfo> syms = new List<SymInfo>();
if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities) if (!CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IncludeDotNetEntities)
return syms.ToArray(); return syms.ToArray();
MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy); MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
List<MemberInfo> members = new List<MemberInfo>(); List<MemberInfo> members = new List<MemberInfo>();
@ -6719,7 +6719,7 @@ namespace CodeCompletion
public override SymInfo[] GetNamesAsInBaseClass(ExpressionVisitor ev, bool is_static) public override SymInfo[] GetNamesAsInBaseClass(ExpressionVisitor ev, bool is_static)
{ {
List<SymInfo> syms = new List<SymInfo>(); List<SymInfo> syms = new List<SymInfo>();
if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities) if (!CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IncludeDotNetEntities)
return syms.ToArray(); return syms.ToArray();
MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy); MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy);
if (ctn.IsInterface) if (ctn.IsInterface)
@ -6841,7 +6841,7 @@ namespace CodeCompletion
public override SymInfo[] GetNames() public override SymInfo[] GetNames()
{ {
List<SymInfo> syms = new List<SymInfo>(); List<SymInfo> syms = new List<SymInfo>();
if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities) if (!CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IncludeDotNetEntities)
return syms.ToArray(); return syms.ToArray();
MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy); MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy);
if (ctn.IsInterface) if (ctn.IsInterface)
@ -6960,7 +6960,7 @@ namespace CodeCompletion
public override SymInfo[] GetNamesAsInObject() public override SymInfo[] GetNamesAsInObject()
{ {
List<SymInfo> syms = new List<SymInfo>(); List<SymInfo> syms = new List<SymInfo>();
if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities) if (!CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IncludeDotNetEntities)
return syms.ToArray(); return syms.ToArray();
MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.Instance); MemberInfo[] mis = ctn.GetMembers(BindingFlags.Public | BindingFlags.Instance);
foreach (MemberInfo mi in mis) foreach (MemberInfo mi in mis)
@ -7052,10 +7052,10 @@ namespace CodeCompletion
public override List<SymScope> FindOverloadNames(string name) public override List<SymScope> FindOverloadNames(string name)
{ {
StringComparison comparison = CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; StringComparison comparison = CodeCompletionController.CurrentLanguage.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
List<SymScope> names = new List<SymScope>(); List<SymScope> names = new List<SymScope>();
List<PascalABCCompiler.TreeConverter.SymbolInfo> sil = PascalABCCompiler.NetHelper.NetHelper.FindNameIncludeProtected(ctn, name, CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive); List<PascalABCCompiler.TreeConverter.SymbolInfo> sil = PascalABCCompiler.NetHelper.NetHelper.FindNameIncludeProtected(ctn, name, CodeCompletionController.CurrentLanguage.CaseSensitive);
//IEnumerable<MemberInfo> ext_meths = PascalABCCompiler.NetHelper.NetHelper.GetExtensionMethods(ctn); //IEnumerable<MemberInfo> ext_meths = PascalABCCompiler.NetHelper.NetHelper.GetExtensionMethods(ctn);
List<ProcScope> pascal_ext_meths = this.GetExtensionMethods(name, this); List<ProcScope> pascal_ext_meths = this.GetExtensionMethods(name, this);
if (sil != null && sil.Count > 1 && sil.FirstOrDefault().sym_info.semantic_node_type == semantic_node_type.basic_property_node) if (sil != null && sil.Count > 1 && sil.FirstOrDefault().sym_info.semantic_node_type == semantic_node_type.basic_property_node)
@ -7221,10 +7221,10 @@ namespace CodeCompletion
public override SymScope FindName(string name) public override SymScope FindName(string name)
{ {
StringComparison comparison = CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; StringComparison comparison = CodeCompletionController.CurrentLanguage.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
List<PascalABCCompiler.TreeConverter.SymbolInfo> sil = PascalABCCompiler.NetHelper.NetHelper.FindNameIncludeProtected(ctn, name, CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive); List<PascalABCCompiler.TreeConverter.SymbolInfo> sil = PascalABCCompiler.NetHelper.NetHelper.FindNameIncludeProtected(ctn, name, CodeCompletionController.CurrentLanguage.CaseSensitive);
if (!CodeCompletionController.CurrentParser.LanguageInformation.IncludeDotNetEntities) if (!CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IncludeDotNetEntities)
return null; return null;
if (sil == null) if (sil == null)
{ {
@ -7371,7 +7371,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.GetFullTypeName(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetFullTypeName(this);
} }
} }
@ -7511,7 +7511,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -7603,7 +7603,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
//return "event "+ TypeUtility.GetShortTypeName(ei.DeclaringType) +"."+ ei.Name + ": "+sc.ToString(); //return "event "+ TypeUtility.GetShortTypeName(ei.DeclaringType) +"."+ ei.Name + ": "+sc.ToString();
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -7705,7 +7705,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -7786,7 +7786,7 @@ namespace CodeCompletion
} }
if (si.name == null) if (si.name == null)
AssemblyDocCache.AddDescribeToComplete(this.si, mi); AssemblyDocCache.AddDescribeToComplete(this.si, mi);
this.si.name = CodeCompletionController.CurrentParser.LanguageInformation.GetShortName(this); this.si.name = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetShortName(this);
this.si.description = this.ToString(); this.si.description = this.ToString();
//this.si.describe += "\n"+AssemblyDocCache.GetDocumentation(mi.DeclaringType.Assembly,"M:"+mi.DeclaringType.FullName+"."+mi.Name+GetParamNames()); //this.si.describe += "\n"+AssemblyDocCache.GetDocumentation(mi.DeclaringType.Assembly,"M:"+mi.DeclaringType.FullName+"."+mi.Name+GetParamNames());
this.topScope = declaringType; this.topScope = declaringType;
@ -7831,7 +7831,7 @@ namespace CodeCompletion
this.is_global = is_global; this.is_global = is_global;
if (si.name == null) if (si.name == null)
AssemblyDocCache.AddDescribeToComplete(this.si, mi); AssemblyDocCache.AddDescribeToComplete(this.si, mi);
this.si.name = CodeCompletionController.CurrentParser.LanguageInformation.GetShortName(this); this.si.name = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetShortName(this);
this.si.description = this.ToString(); this.si.description = this.ToString();
//this.si.describe += "\n"+AssemblyDocCache.GetDocumentation(mi.DeclaringType.Assembly,"M:"+mi.DeclaringType.FullName+"."+mi.Name+GetParamNames()); //this.si.describe += "\n"+AssemblyDocCache.GetDocumentation(mi.DeclaringType.Assembly,"M:"+mi.DeclaringType.FullName+"."+mi.Name+GetParamNames());
this.topScope = declaringType; this.topScope = declaringType;
@ -7997,7 +7997,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
} }
@ -8024,7 +8024,7 @@ namespace CodeCompletion
foreach (ParameterInfo pi in mi.GetParameters()) foreach (ParameterInfo pi in mi.GetParameters())
parameters.Add(new CompiledParameterScope(new SymInfo(pi.Name, SymbolKind.Parameter, pi.Name), pi)); parameters.Add(new CompiledParameterScope(new SymInfo(pi.Name, SymbolKind.Parameter, pi.Name), pi));
this.si.name = CodeCompletionController.CurrentParser.LanguageInformation.GetShortName(this); this.si.name = CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetShortName(this);
this.si.description = this.ToString();//+"\n"+AssemblyDocCache.GetDocumentation(mi.DeclaringType.Assembly,"M:"+mi.DeclaringType.FullName+".#ctor"+GetParamNames()); this.si.description = this.ToString();//+"\n"+AssemblyDocCache.GetDocumentation(mi.DeclaringType.Assembly,"M:"+mi.DeclaringType.FullName+".#ctor"+GetParamNames());
this.topScope = declaringType; this.topScope = declaringType;
if (mi.IsPrivate) if (mi.IsPrivate)
@ -8113,7 +8113,7 @@ namespace CodeCompletion
public override string ToString() public override string ToString()
{ {
return CodeCompletionController.CurrentParser.LanguageInformation.GetDescription(this); return CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDescription(this);
} }
} }

View file

@ -140,7 +140,7 @@ namespace CodeCompletion
shouldPositions.Add(new Position(line + 1, col + 1, 0, 0, null)); shouldPositions.Add(new Position(line + 1, col + 1, 0, 0, null));
string expr_without_brackets = null; string expr_without_brackets = null;
PascalABCCompiler.Parsers.KeywordKind keyw = PascalABCCompiler.Parsers.KeywordKind.None; PascalABCCompiler.Parsers.KeywordKind keyw = PascalABCCompiler.Parsers.KeywordKind.None;
string full_expr = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets); string full_expr = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets);
List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>(); List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>();
var errors = new List<PascalABCCompiler.Errors.Error>(); var errors = new List<PascalABCCompiler.Errors.Error>();
expression expr = parser.GetExpression("test" + System.IO.Path.GetExtension(FileName), full_expr, errors, new List<PascalABCCompiler.Errors.CompilerWarning>()); expression expr = parser.GetExpression("test" + System.IO.Path.GetExtension(FileName), full_expr, errors, new List<PascalABCCompiler.Errors.CompilerWarning>());
@ -160,7 +160,7 @@ namespace CodeCompletion
shouldPositions.Add(new Position(line + 1, col, 0, 0, null)); shouldPositions.Add(new Position(line + 1, col, 0, 0, null));
string expr_without_brackets = null; string expr_without_brackets = null;
PascalABCCompiler.Parsers.KeywordKind keyw = PascalABCCompiler.Parsers.KeywordKind.None; PascalABCCompiler.Parsers.KeywordKind keyw = PascalABCCompiler.Parsers.KeywordKind.None;
string full_expr = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets); string full_expr = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets);
List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>(); List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>();
var errors = new List<PascalABCCompiler.Errors.Error>(); var errors = new List<PascalABCCompiler.Errors.Error>();
expression expr = parser.GetExpression("test" + System.IO.Path.GetExtension(FileName), full_expr, errors, new List<PascalABCCompiler.Errors.CompilerWarning>()); expression expr = parser.GetExpression("test" + System.IO.Path.GetExtension(FileName), full_expr, errors, new List<PascalABCCompiler.Errors.CompilerWarning>());
@ -239,7 +239,7 @@ namespace CodeCompletion
{ {
string expr_without_brackets = null; string expr_without_brackets = null;
PascalABCCompiler.Parsers.KeywordKind keyw; PascalABCCompiler.Parsers.KeywordKind keyw;
var expr = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets); var expr = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets);
if (expr == null) if (expr == null)
expr = expr_without_brackets; expr = expr_without_brackets;
var errors = new List<PascalABCCompiler.Errors.Error>(); var errors = new List<PascalABCCompiler.Errors.Error>();
@ -253,7 +253,7 @@ namespace CodeCompletion
{ {
string expr_without_brackets = null; string expr_without_brackets = null;
PascalABCCompiler.Parsers.KeywordKind keyw; PascalABCCompiler.Parsers.KeywordKind keyw;
var expr = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets); var expr = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets);
if (expr == null) if (expr == null)
expr = expr_without_brackets; expr = expr_without_brackets;
var errors = new List<PascalABCCompiler.Errors.Error>(); var errors = new List<PascalABCCompiler.Errors.Error>();
@ -270,7 +270,7 @@ namespace CodeCompletion
{ {
string expr_without_brackets = null; string expr_without_brackets = null;
PascalABCCompiler.Parsers.KeywordKind keyw; PascalABCCompiler.Parsers.KeywordKind keyw;
var expr = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets); var expr = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets);
if (expr == null) if (expr == null)
expr = expr_without_brackets; expr = expr_without_brackets;
var errors = new List<PascalABCCompiler.Errors.Error>(); var errors = new List<PascalABCCompiler.Errors.Error>();
@ -345,266 +345,266 @@ namespace CodeCompletion
int col=0; int col=0;
PascalABCCompiler.Parsers.KeywordKind keyw; PascalABCCompiler.Parsers.KeywordKind keyw;
//LanguageIntegration.LanguageIntegrator.ReloadAllParsers(); //LanguageIntegration.LanguageIntegrator.ReloadAllParsers();
IParser parser = LanguageProvider.Instance.MainLanguage.Parser; var languageIntellisenseSupport = LanguageProvider.Instance.MainLanguage.LanguageIntellisenseSupport;
string test_str = "System.Console"; string test_str = "System.Console";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "System(2+3,-Test34).Console"; test_str = "System(2+3,-Test34).Console";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "(a+b*c-e)"; test_str = "(a+b*c-e)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "a[2,3+b[2-3*b(2*Test-&var,nil)]][56,89,(44)]"; test_str = "a[2,3+b[2-3*b(2*Test-&var,nil)]][56,89,(44)]";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "begin test"; test_str = "begin test";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim(' ','\n','\t')=="test"); assert(s.Trim(' ','\n','\t')=="test");
test_str = "begin test[4]"; test_str = "begin test[4]";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim(' ','\n','\t')=="test[4]"); assert(s.Trim(' ','\n','\t')=="test[4]");
test_str = "begin sin(2)"; test_str = "begin sin(2)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim(' ','\n','\t')=="sin(2)"); assert(s.Trim(' ','\n','\t')=="sin(2)");
test_str = "repeat test"; test_str = "repeat test";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim(' ','\n','\t')=="test"); assert(s.Trim(' ','\n','\t')=="test");
test_str = "while test"; test_str = "while test";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim(' ','\n','\t')=="test"); assert(s.Trim(' ','\n','\t')=="test");
test_str = "Test(new Text2, new Text3(2,3),inherited Create).a[new Text3]"; test_str = "Test(new Text2, new Text3(2,3),inherited Create).a[new Text3]";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "Test[new Text2, new Text3(2,3),inherited Create].a[new Text3]"; test_str = "Test[new Text2, new Text3(2,3),inherited Create].a[new Text3]";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "Str(a:2)"; test_str = "Str(a:2)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "Str(a:2:5)"; test_str = "Str(a:2:5)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "&Begin.&Var.&else.&for"; test_str = "&Begin.&Var.&else.&for";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "a[s<5]"; test_str = "a[s<5]";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "a[s>5]"; test_str = "a[s>5]";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "a(s<5)"; test_str = "a(s<5)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "a(s>5)"; test_str = "a(s>5)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "ab{2 hsdjsdh 'ddd'}"; test_str = "ab{2 hsdjsdh 'ddd'}";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "TClass&<integer>.abc"; test_str = "TClass&<integer>.abc";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "TClass&<integer>"; test_str = "TClass&<integer>";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "Test[new {dsdsdsd} Text2, new Text3{sdsd}(2,{''''''} 3),inherited {zez snj }Create]{...}.a{^^}[new Text3]"; test_str = "Test[new {dsdsdsd} Text2, new Text3{sdsd}(2,{''''''} 3),inherited {zez snj }Create]{...}.a{^^}[new Text3]";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "begin \n \t\t \n bb \t"; test_str = "begin \n \t\t \n bb \t";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="bb"); assert(s.Trim('\n',' ','\t')=="bb");
test_str = "Test\n[new {dsdsdsd\n} Text2, new \t Text3(2,{''''''} 3),inherited {zez snj }Create]{...}.a{^^}[new Text3]"; test_str = "Test\n[new {dsdsdsd\n} Text2, new \t Text3(2,{''''''} 3),inherited {zez snj }Create]{...}.a{^^}[new Text3]";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "test//abcd\ntest.abcd"; test_str = "test//abcd\ntest.abcd";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="test.abcd"); assert(s.Trim('\n',' ','\t')=="test.abcd");
test_str = "test(2,3) < ppp"; test_str = "test(2,3) < ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "test(2,3) + ppp"; test_str = "test(2,3) + ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "test(2,3) * ppp"; test_str = "test(2,3) * ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "test(2,3) div ppp"; test_str = "test(2,3) div ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "test(2,3) - ppp"; test_str = "test(2,3) - ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "test(2,3) shl ppp"; test_str = "test(2,3) shl ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "(s as string)"; test_str = "(s as string)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s==test_str); assert(s==test_str);
test_str = "begin (s as string)"; test_str = "begin (s as string)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="(s as string)"); assert(s.Trim('\n',' ','\t')=="(s as string)");
test_str = "test(2,3) shr ppp"; test_str = "test(2,3) shr ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "test(2,3) > ppp"; test_str = "test(2,3) > ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "test(2,3) or ppp"; test_str = "test(2,3) or ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "test(2,3) and ppp"; test_str = "test(2,3) and ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "test(2,3) xor ppp"; test_str = "test(2,3) xor ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "test(2,3) mod ppp"; test_str = "test(2,3) mod ppp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')=="ppp"); assert(s.Trim('\n',' ','\t')=="ppp");
test_str = "typeof(char)"; test_str = "typeof(char)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')==test_str); assert(s.Trim('\n',' ','\t')==test_str);
test_str = "sizeof(char)"; test_str = "sizeof(char)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off,test_str,line,col,out keyw); s = languageIntellisenseSupport.FindExpression(off,test_str,line,col,out keyw);
assert(s.Trim('\n',' ','\t')==test_str); assert(s.Trim('\n',' ','\t')==test_str);
test_str = "()->(obj as string).Trim"; test_str = "()->(obj as string).Trim";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == "(obj as string).Trim"); assert(s.Trim('\n', ' ', '\t') == "(obj as string).Trim");
test_str = "Seq(0)\n.f1//комментарий\n.Print"; test_str = "Seq(0)\n.f1//комментарий\n.Print";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == "Seq(0)\n.f1\n.Print"); assert(s.Trim('\n', ' ', '\t') == "Seq(0)\n.f1\n.Print");
test_str = "$'is {a}'"; test_str = "$'is {a}'";
off = test_str.Length-2; off = test_str.Length-2;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == "a"); assert(s.Trim('\n', ' ', '\t') == "a");
test_str = "seq1.Where(i ->(i = 1) or (i = 2)).JoinIntoString"; test_str = "seq1.Where(i ->(i = 1) or (i = 2)).JoinIntoString";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == "seq1.Where(i ->(i = 1) or (i = 2)).JoinIntoString"); assert(s.Trim('\n', ' ', '\t') == "seq1.Where(i ->(i = 1) or (i = 2)).JoinIntoString");
test_str = "$'{f1(s0)}'"; test_str = "$'{f1(s0)}'";
off = test_str.Length - 3; off = test_str.Length - 3;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == "s0"); assert(s.Trim('\n', ' ', '\t') == "s0");
test_str = "f1&<byte>\n.ToString"; test_str = "f1&<byte>\n.ToString";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == test_str); assert(s.Trim('\n', ' ', '\t') == test_str);
test_str = "a[2:]"; test_str = "a[2:]";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == test_str); assert(s.Trim('\n', ' ', '\t') == test_str);
test_str = "' '' '"; test_str = "' '' '";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == test_str); assert(s.Trim('\n', ' ', '\t') == test_str);
test_str = "' '' '' '"; test_str = "' '' '' '";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == test_str); assert(s.Trim('\n', ' ', '\t') == test_str);
test_str = "' ' '"; test_str = "' ' '";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == ""); assert(s.Trim('\n', ' ', '\t') == "");
test_str = "(2..4)"; test_str = "(2..4)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpression(off, test_str, line, col, out keyw); s = languageIntellisenseSupport.FindExpression(off, test_str, line, col, out keyw);
assert(s.Trim('\n', ' ', '\t') == test_str); assert(s.Trim('\n', ' ', '\t') == test_str);
@ -613,228 +613,228 @@ namespace CodeCompletion
//testirovanie nazhatija skobki //testirovanie nazhatija skobki
test_str = "writeln"; test_str = "writeln";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "Console.WriteLine"; test_str = "Console.WriteLine";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "begin writeln"; test_str = "begin writeln";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s.Trim('\n',' ','\t') == "writeln"); assert(s.Trim('\n',' ','\t') == "writeln");
assert(num_param==0); assert(num_param==0);
test_str = "Console{dsdsdsd}.WriteLine{''''''sds}"; test_str = "Console{dsdsdsd}.WriteLine{''''''sds}";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "test(2,3).mmm"; test_str = "test(2,3).mmm";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "test[2<3].a"; test_str = "test[2<3].a";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "test[2>3].a"; test_str = "test[2>3].a";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "test[2>3] .a"; test_str = "test[2>3] .a";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "23 < test"; test_str = "23 < test";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s.Trim('\n',' ','\t') == "test"); assert(s.Trim('\n',' ','\t') == "test");
assert(num_param==0); assert(num_param==0);
test_str = "23 > test"; test_str = "23 > test";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s.Trim('\n',' ','\t') == "test"); assert(s.Trim('\n',' ','\t') == "test");
assert(num_param==0); assert(num_param==0);
test_str = "(a<b) + test"; test_str = "(a<b) + test";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s.Trim('\n',' ','\t') == "test"); assert(s.Trim('\n',' ','\t') == "test");
assert(num_param==0); assert(num_param==0);
test_str = "test2[sin(2,3),cos(2)]"; test_str = "test2[sin(2,3),cos(2)]";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
test_str = "sin{sdsd}(2,3).ttt"; test_str = "sin{sdsd}(2,3).ttt";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "new System.Collections.Generic.List<integer>"; test_str = "new System.Collections.Generic.List<integer>";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "TClass&<T>.bbb"; test_str = "TClass&<T>.bbb";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "()->(obj as string).Trim"; test_str = "()->(obj as string).Trim";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s == "(obj as string).Trim"); assert(s == "(obj as string).Trim");
assert(num_param == 0); assert(num_param == 0);
test_str = "test; \n sin"; test_str = "test; \n sin";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s.Trim(' ','\n','\t') == "sin"); assert(s.Trim(' ','\n','\t') == "sin");
assert(num_param==0); assert(num_param==0);
test_str = "new TClass"; test_str = "new TClass";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "Proc1({}2+3,'aasd',Proc2(a[34,{}2],new TClass(f('ssd')))).zzz"; test_str = "Proc1({}2+3,'aasd',Proc2(a[34,{}2],new TClass(f('ssd')))).zzz";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "'abc'.tostring('aa','bb{()').ggg"; test_str = "'abc'.tostring('aa','bb{()').ggg";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "Test([],[1,2,3],{cdsds} \tsin"; test_str = "Test([],[1,2,3],{cdsds} \tsin";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s.Trim(' ','\n','\t') == "{cdsds} \tsin"); assert(s.Trim(' ','\n','\t') == "{cdsds} \tsin");
assert(num_param==0); assert(num_param==0);
test_str = "test(2+3,aa.bb"; test_str = "test(2+3,aa.bb";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == "aa.bb"); assert(s == "aa.bb");
test_str = "test(2<3).bb"; test_str = "test(2<3).bb";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "sin(new TClass<integer>,TClass&<real>).pp"; test_str = "sin(new TClass<integer>,TClass&<real>).pp";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
assert(num_param==0); assert(num_param==0);
test_str = "raise new TClass"; test_str = "raise new TClass";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s.Trim(' ','\n','\t') == "new TClass"); assert(s.Trim(' ','\n','\t') == "new TClass");
assert(num_param==0); assert(num_param==0);
test_str = "begin test(2)"; test_str = "begin test(2)";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s.Trim(' ','\n','\t') == "test(2)"); assert(s.Trim(' ','\n','\t') == "test(2)");
assert(num_param==0); assert(num_param==0);
test_str = "//aaaa\nConsole.WriteLine"; test_str = "//aaaa\nConsole.WriteLine";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s.Trim(' ','\n','\t') == "Console.WriteLine"); assert(s.Trim(' ','\n','\t') == "Console.WriteLine");
assert(num_param==0); assert(num_param==0);
test_str = "System.Math.DivRem"; test_str = "System.Math.DivRem";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim(' ', '\n', '\t') == "System.Math.DivRem"); assert(s.Trim(' ', '\n', '\t') == "System.Math.DivRem");
assert(num_param == 0); assert(num_param == 0);
test_str = "seq1.Where(i ->(i = 1) or (i = 2)).JoinIntoString"; test_str = "seq1.Where(i ->(i = 1) or (i = 2)).JoinIntoString";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim('\n', ' ', '\t') == "seq1.Where(i ->(i = 1) or (i = 2)).JoinIntoString"); assert(s.Trim('\n', ' ', '\t') == "seq1.Where(i ->(i = 1) or (i = 2)).JoinIntoString");
test_str = "seq1.Where(i ->(i = '1') or (i = '2')).JoinIntoString"; test_str = "seq1.Where(i ->(i = '1') or (i = '2')).JoinIntoString";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim('\n', ' ', '\t') == "seq1.Where(i ->(i = '1') or (i = '2')).JoinIntoString"); assert(s.Trim('\n', ' ', '\t') == "seq1.Where(i ->(i = '1') or (i = '2')).JoinIntoString");
test_str = "f1&<array of byte>"; test_str = "f1&<array of byte>";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim('\n', ' ', '\t') == "f1&<array of byte>"); assert(s.Trim('\n', ' ', '\t') == "f1&<array of byte>");
test_str = "f1&<sequence of byte>"; test_str = "f1&<sequence of byte>";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim('\n', ' ', '\t') == "f1&<sequence of byte>"); assert(s.Trim('\n', ' ', '\t') == "f1&<sequence of byte>");
test_str = "&var.&uses.&procedure"; test_str = "&var.&uses.&procedure";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,'(',ref num_param);
assert(s == test_str); assert(s == test_str);
test_str = "s.OrderBy"; test_str = "s.OrderBy";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s == test_str); assert(s == test_str);
test_str = "f1&<byte>\n.ToString"; test_str = "f1&<byte>\n.ToString";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim('\n', ' ', '\t') == "f1&<byte>\n.ToString"); assert(s.Trim('\n', ' ', '\t') == "f1&<byte>\n.ToString");
test_str = "begin ''.PadLeft"; test_str = "begin ''.PadLeft";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim('\n', ' ', '\t') == "''.PadLeft"); assert(s.Trim('\n', ' ', '\t') == "''.PadLeft");
test_str = "begin var s := ''.PadLeft"; test_str = "begin var s := ''.PadLeft";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim('\n', ' ', '\t') == "''.PadLeft"); assert(s.Trim('\n', ' ', '\t') == "''.PadLeft");
test_str = "begin \n var s := ''.PadLeft"; test_str = "begin \n var s := ''.PadLeft";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim('\n', ' ', '\t') == "''.PadLeft"); assert(s.Trim('\n', ' ', '\t') == "''.PadLeft");
test_str = "writeln(23);\n ''.PadLeft"; test_str = "writeln(23);\n ''.PadLeft";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim('\n', ' ', '\t') == "''.PadLeft"); assert(s.Trim('\n', ' ', '\t') == "''.PadLeft");
test_str = "writeln(23);\n ''.PadLeft(2).ToString"; test_str = "writeln(23);\n ''.PadLeft(2).ToString";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, '(', ref num_param);
assert(s.Trim('\n', ' ', '\t') == "''.PadLeft(2).ToString"); assert(s.Trim('\n', ' ', '\t') == "''.PadLeft(2).ToString");
@ -843,129 +843,129 @@ namespace CodeCompletion
test_str = ";test(3,aa.bb"; test_str = ";test(3,aa.bb";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s == "test"); assert(s == "test");
assert(num_param == 3); assert(num_param == 3);
test_str = ";test(a[2,3,4],sin(2+3),aa.bb"; test_str = ";test(a[2,3,4],sin(2+3),aa.bb";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s == "test"); assert(s == "test");
assert(num_param == 4); assert(num_param == 4);
test_str = "Console.WriteLine(a[2,3,4]{ds},[1,2+3,5,'aa)'],sin(2+3,4+f(3)),aa.bb,(23)"; test_str = "Console.WriteLine(a[2,3,4]{ds},[1,2+3,5,'aa)'],sin(2+3,4+f(3)),aa.bb,(23)";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s == "Console.WriteLine"); assert(s == "Console.WriteLine");
assert(num_param == 6); assert(num_param == 6);
test_str = "Console.WriteLine(new TClass(2,3"; test_str = "Console.WriteLine(new TClass(2,3";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s == "new TClass"); assert(s == "new TClass");
assert(num_param == 3); assert(num_param == 3);
test_str = "Console.WriteLine(new{} TClass(2+f(2,[]),3"; test_str = "Console.WriteLine(new{} TClass(2+f(2,[]),3";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s == "new{} TClass"); assert(s == "new{} TClass");
assert(num_param == 3); assert(num_param == 3);
test_str = "begin \n\t sin("; test_str = "begin \n\t sin(";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == "sin"); assert(s.Trim(' ','\n','\t') == "sin");
assert(num_param == 2); assert(num_param == 2);
test_str = "sin(2)"; test_str = "sin(2)";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == ""); assert(s.Trim(' ','\n','\t') == "");
test_str = "begin f(2)+sin(2,3,4)"; test_str = "begin f(2)+sin(2,3,4)";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == ""); assert(s.Trim(' ','\n','\t') == "");
test_str = ";\n [sin(f(3)),a[3]"; test_str = ";\n [sin(f(3)),a[3]";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == ""); assert(s.Trim(' ','\n','\t') == "");
test_str = ";\n (sin)"; test_str = ";\n (sin)";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == ""); assert(s.Trim(' ','\n','\t') == "");
test_str = "max(2<3"; test_str = "max(2<3";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == "max"); assert(s.Trim(' ','\n','\t') == "max");
assert(num_param == 2); assert(num_param == 2);
test_str = "max(2>3"; test_str = "max(2>3";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == "max"); assert(s.Trim(' ','\n','\t') == "max");
assert(num_param == 2); assert(num_param == 2);
test_str = "max(Test&<integer>(2,3)"; test_str = "max(Test&<integer>(2,3)";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == "max"); assert(s.Trim(' ','\n','\t') == "max");
assert(num_param == 2); assert(num_param == 2);
test_str = "new TextABC(60,110,110,'Hello!',RGB(x"; test_str = "new TextABC(60,110,110,'Hello!',RGB(x";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == "RGB"); assert(s.Trim(' ','\n','\t') == "RGB");
assert(num_param == 2); assert(num_param == 2);
test_str = "new TextABC(60,110,110,'Hello!',new RGB(x"; test_str = "new TextABC(60,110,110,'Hello!',new RGB(x";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == "new RGB"); assert(s.Trim(' ','\n','\t') == "new RGB");
assert(num_param == 2); assert(num_param == 2);
test_str = "new TextABC(new RGB(x"; test_str = "new TextABC(new RGB(x";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == "new RGB"); assert(s.Trim(' ','\n','\t') == "new RGB");
assert(num_param == 2); assert(num_param == 2);
test_str = "new TextABC(new RGB(x,(2)"; test_str = "new TextABC(new RGB(x,(2)";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == "new RGB"); assert(s.Trim(' ','\n','\t') == "new RGB");
assert(num_param == 3); assert(num_param == 3);
test_str = "new TextABC(new RGB(x(2)"; test_str = "new TextABC(new RGB(x(2)";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off,test_str,line,col,',',ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off,test_str,line,col,',',ref num_param);
assert(s.Trim(' ','\n','\t') == "new RGB"); assert(s.Trim(' ','\n','\t') == "new RGB");
assert(num_param == 2); assert(num_param == 2);
test_str = "Power(10 div 2"; test_str = "Power(10 div 2";
off = test_str.Length; off = test_str.Length;
num_param = 1; num_param = 1;
s = parser.LanguageInformation.FindExpressionForMethod(off, test_str, line, col, ',', ref num_param); s = languageIntellisenseSupport.FindExpressionForMethod(off, test_str, line, col, ',', ref num_param);
assert(s.Trim(' ', '\n', '\t') == "Power"); assert(s.Trim(' ', '\n', '\t') == "Power");
assert(num_param == 2); assert(num_param == 2);
@ -975,77 +975,77 @@ namespace CodeCompletion
//mouse hover //mouse hover
test_str = "sin(2)"; test_str = "sin(2)";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')=="sin(2)"); assert(s.Trim('\n',' ','\t')=="sin(2)");
test_str = "sin(2,3,4)"; test_str = "sin(2,3,4)";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')=="sin(2,3,4)"); assert(s.Trim('\n',' ','\t')=="sin(2,3,4)");
test_str = "sin {sdsd'} (2,3,4)"; test_str = "sin {sdsd'} (2,3,4)";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')==test_str); assert(s.Trim('\n',' ','\t')==test_str);
test_str = "sin (df,'3)+2','{')"; test_str = "sin (df,'3)+2','{')";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')==test_str); assert(s.Trim('\n',' ','\t')==test_str);
test_str = "cos()"; test_str = "cos()";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')==test_str); assert(s.Trim('\n',' ','\t')==test_str);
test_str = "cos{()}"; test_str = "cos{()}";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')=="cos"); assert(s.Trim('\n',' ','\t')=="cos");
test_str = "cos//()"; test_str = "cos//()";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')=="cos"); assert(s.Trim('\n',' ','\t')=="cos");
test_str = "cos(//)"; test_str = "cos(//)";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')=="cos"); assert(s.Trim('\n',' ','\t')=="cos");
test_str = "cos('//')"; test_str = "cos('//')";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')==test_str); assert(s.Trim('\n',' ','\t')==test_str);
test_str = "cos({//})"; test_str = "cos({//})";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')==test_str); assert(s.Trim('\n',' ','\t')==test_str);
test_str = "cos(Math.Cos(x)+1)"; test_str = "cos(Math.Cos(x)+1)";
off = 1; off = 1;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off,test_str,line,col,out keyw,out str);
assert(s.Trim('\n',' ','\t')==test_str); assert(s.Trim('\n',' ','\t')==test_str);
test_str = "new t1<byte>(2)"; test_str = "new t1<byte>(2)";
off = 5; off = 5;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off, test_str, line, col, out keyw, out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off, test_str, line, col, out keyw, out str);
assert(s.Trim('\n', ' ', '\t') == "new t1<byte>(2)"); assert(s.Trim('\n', ' ', '\t') == "new t1<byte>(2)");
test_str = "new t1<List<byte>>(2)"; test_str = "new t1<List<byte>>(2)";
off = 5; off = 5;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off, test_str, line, col, out keyw, out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off, test_str, line, col, out keyw, out str);
assert(s.Trim('\n', ' ', '\t') == "new t1<List<byte>>(2)"); assert(s.Trim('\n', ' ', '\t') == "new t1<List<byte>>(2)");
test_str = "t1&<byte>.x"; test_str = "t1&<byte>.x";
off = test_str.Length; off = test_str.Length;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off, test_str, line, col, out keyw, out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off, test_str, line, col, out keyw, out str);
assert(s.Trim('\n', ' ', '\t') == "t1&<byte>.x"); assert(s.Trim('\n', ' ', '\t') == "t1&<byte>.x");
test_str = "Arr(0).Select&<integer,ft>"; test_str = "Arr(0).Select&<integer,ft>";
off = 8; off = 8;
s = parser.LanguageInformation.FindExpressionFromAnyPosition(off, test_str, line, col, out keyw, out str); s = languageIntellisenseSupport.FindExpressionFromAnyPosition(off, test_str, line, col, out keyw, out str);
assert(s.Trim('\n', ' ', '\t') == "Arr(0).Select&<integer,ft>"); assert(s.Trim('\n', ' ', '\t') == "Arr(0).Select&<integer,ft>");
//---- //----
@ -1055,7 +1055,7 @@ namespace CodeCompletion
StreamWriter sw = new StreamWriter("mscorlib.txt"); StreamWriter sw = new StreamWriter("mscorlib.txt");
foreach (Type t in types) foreach (Type t in types)
{ {
sw.WriteLine(parser.LanguageInformation.GetCompiledTypeRepresentation(t, t, ref i, ref j)); sw.WriteLine(languageIntellisenseSupport.GetCompiledTypeRepresentation(t, t, ref i, ref j));
} }
sw.Close(); sw.Close();
@ -1063,7 +1063,7 @@ namespace CodeCompletion
sw = new StreamWriter(typeof(System.Diagnostics.Process).Assembly.ManifestModule.ScopeName+".txt"); sw = new StreamWriter(typeof(System.Diagnostics.Process).Assembly.ManifestModule.ScopeName+".txt");
foreach (Type t in types) foreach (Type t in types)
{ {
sw.WriteLine(parser.LanguageInformation.GetCompiledTypeRepresentation(t, t, ref i, ref j)); sw.WriteLine(languageIntellisenseSupport.GetCompiledTypeRepresentation(t, t, ref i, ref j));
} }
sw.Close(); sw.Close();
@ -1072,7 +1072,7 @@ namespace CodeCompletion
sw = new StreamWriter(typeof(System.Data.Constraint).Assembly.ManifestModule.ScopeName + ".txt"); sw = new StreamWriter(typeof(System.Data.Constraint).Assembly.ManifestModule.ScopeName + ".txt");
foreach (Type t in types) foreach (Type t in types)
{ {
sw.WriteLine(parser.LanguageInformation.GetCompiledTypeRepresentation(t, t, ref i, ref j)); sw.WriteLine(languageIntellisenseSupport.GetCompiledTypeRepresentation(t, t, ref i, ref j));
} }
sw.Close(); sw.Close();
@ -1081,7 +1081,7 @@ namespace CodeCompletion
sw = new StreamWriter(typeof(System.Xml.XmlDocument).Assembly.ManifestModule.ScopeName + ".txt"); sw = new StreamWriter(typeof(System.Xml.XmlDocument).Assembly.ManifestModule.ScopeName + ".txt");
foreach (Type t in types) foreach (Type t in types)
{ {
sw.WriteLine(parser.LanguageInformation.GetCompiledTypeRepresentation(t, t, ref i, ref j)); sw.WriteLine(languageIntellisenseSupport.GetCompiledTypeRepresentation(t, t, ref i, ref j));
} }
sw.Close(); sw.Close();
} }

View file

@ -2,9 +2,10 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using PascalABCCompiler.Parsers; using PascalABCCompiler.Parsers;
using System.Collections.Generic;
using PascalABCCompiler.SyntaxTreeConverters; using PascalABCCompiler.SyntaxTreeConverters;
using PascalABCCompiler.SystemLibrary;
using PascalABCCompiler.TreeConverter; using PascalABCCompiler.TreeConverter;
using System.Collections.Generic;
namespace Languages.Facade namespace Languages.Facade
{ {
@ -13,14 +14,17 @@ namespace Languages.Facade
/// </summary> /// </summary>
public abstract class BaseLanguage : ILanguage public abstract class BaseLanguage : ILanguage
{ {
/// <summary> /// <summary>
/// Все параметры должны быть не null (и не пустым массивом), кроме IDocParser в случае, если он не требуется /// Все параметры должны быть не null (и не пустым массивом),
/// кроме IDocParser и ILanguageIntellisenseSupport в случае, если они не требуются
/// </summary> /// </summary>
public BaseLanguage(ILanguageInformation languageInformation, public BaseLanguage(ILanguageInformation languageInformation, ILanguageIntellisenseSupport languageIntellisenseSupport,
IParser parser, IDocParser docParser, List<ISyntaxTreeConverter> syntaxTreeConverters) IParser parser, IDocParser docParser, List<ISyntaxTreeConverter> syntaxTreeConverters)
{ {
this.LanguageInformation = languageInformation; this.LanguageInformation = languageInformation;
this.LanguageIntellisenseSupport = languageIntellisenseSupport;
if (this.LanguageIntellisenseSupport != null)
this.LanguageIntellisenseSupport.LanguageInformation = languageInformation;
this.Parser = parser; this.Parser = parser;
this.Parser.LanguageInformation = languageInformation; this.Parser.LanguageInformation = languageInformation;
this.DocParser = docParser; this.DocParser = docParser;
@ -39,19 +43,37 @@ namespace Languages.Facade
public string[] SystemUnitNames => LanguageInformation.SystemUnitNames; public string[] SystemUnitNames => LanguageInformation.SystemUnitNames;
public virtual ILanguageInformation LanguageInformation { get; } public ILanguageInformation LanguageInformation { get; }
public virtual IParser Parser { get; protected set; } public ILanguageIntellisenseSupport LanguageIntellisenseSupport { get; }
public virtual IDocParser DocParser { get; protected set; } public IParser Parser { get; protected set; }
public virtual List<ISyntaxTreeConverter> SyntaxTreeConverters { get; protected set; } public IDocParser DocParser { get; protected set; }
public bool ApplySyntaxTreeConvertersForIntellisense => LanguageInformation.ApplySyntaxTreeConvertersForIntellisense; public List<ISyntaxTreeConverter> SyntaxTreeConverters { get; protected set; }
public virtual syntax_tree_visitor SyntaxTreeToSemanticTreeConverter { get; protected set; } public syntax_tree_visitor SyntaxTreeToSemanticTreeConverter { get; protected set; }
public abstract void SetSemanticConstants(); public virtual void SetSemanticConstants()
{
SemanticRulesConstants.ClassBaseType = SystemLibrary.object_type;
SemanticRulesConstants.StructBaseType = SystemLibrary.value_type;
SemanticRulesConstants.AddResultVariable = true;
SemanticRulesConstants.ZeroBasedStrings = true;
SemanticRulesConstants.FastStrings = false;
SemanticRulesConstants.InitStringAsEmptyString = true;
SemanticRulesConstants.UseDivisionAssignmentOperatorsForIntegerTypes = false;
SemanticRulesConstants.ManyVariablesOneInitializator = false;
SemanticRulesConstants.OrderIndependedMethodNames = true;
SemanticRulesConstants.OrderIndependedFunctionNames = false;
SemanticRulesConstants.OrderIndependedTypeNames = false;
SemanticRulesConstants.EnableExitProcedure = true;
SemanticRulesConstants.StrongPointersTypeCheckForDotNet = true;
SemanticRulesConstants.AllowChangeLoopVariable = false;
SemanticRulesConstants.AllowGlobalVisibilityForPABCDll = true;
SemanticRulesConstants.AllowMethodCallsWithoutParentheses = false;
}
public abstract void SetSyntaxTreeToSemanticTreeConverter(); public abstract void SetSyntaxTreeToSemanticTreeConverter();
} }

View file

@ -30,6 +30,8 @@ namespace Languages.Facade
ILanguageInformation LanguageInformation { get; } ILanguageInformation LanguageInformation { get; }
ILanguageIntellisenseSupport LanguageIntellisenseSupport { get; }
/// <summary> /// <summary>
/// Основной парсер языка /// Основной парсер языка
/// </summary> /// </summary>
@ -45,11 +47,6 @@ namespace Languages.Facade
/// </summary> /// </summary>
List<ISyntaxTreeConverter> SyntaxTreeConverters { get; } List<ISyntaxTreeConverter> SyntaxTreeConverters { get; }
/// <summary>
/// Вызывать ли преобразователей синтаксического дерева в работе Intellisense
/// </summary>
bool ApplySyntaxTreeConvertersForIntellisense { get; }
/// <summary> /// <summary>
/// Преобразователь из синтаксического дерева в семантическое /// Преобразователь из синтаксического дерева в семантическое
/// </summary> /// </summary>

View file

@ -1,4 +1,5 @@
using PascalABCCompiler.ParserTools.Directives; // Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using PascalABCCompiler.SyntaxTree; using PascalABCCompiler.SyntaxTree;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -8,25 +9,9 @@ using System.Text;
namespace PascalABCCompiler.Parsers namespace PascalABCCompiler.Parsers
{ {
public abstract class BaseLanguageInformation : ILanguageInformation public abstract class BaseLanguageIntellisenseSupport : ILanguageIntellisenseSupport
{ {
public abstract string Name { get; } public ILanguageInformation LanguageInformation { get; set; }
public abstract string Version { get; }
public abstract string Copyright { get; }
public abstract bool CaseSensitive { get; }
public abstract string[] FilesExtensions { get; }
public abstract string[] SystemUnitNames { get; }
public abstract BaseKeywords KeywordsStorage { get; }
public abstract Dictionary<string, DirectiveInfo> ValidDirectives { get; protected set; }
public abstract string CommentSymbol { get; }
public abstract string BodyStartBracket { get; } public abstract string BodyStartBracket { get; }
@ -46,8 +31,6 @@ namespace PascalABCCompiler.Parsers
public abstract string ProcedureName { get; } public abstract string ProcedureName { get; }
public abstract string FunctionName { get; } public abstract string FunctionName { get; }
public abstract bool SyntaxTreeIsConvertedAfterUsedModulesCompilation { get; }
public abstract bool ApplySyntaxTreeConvertersForIntellisense { get; } public abstract bool ApplySyntaxTreeConvertersForIntellisense { get; }
public abstract bool IncludeDotNetEntities { get; } public abstract bool IncludeDotNetEntities { get; }
@ -58,11 +41,12 @@ namespace PascalABCCompiler.Parsers
public abstract bool UsesFunctionsOverlappingSourceContext { get; } public abstract bool UsesFunctionsOverlappingSourceContext { get; }
public virtual Dictionary<string, string> SpecialModulesAliases => null;
protected abstract string IntTypeName { get; } protected abstract string IntTypeName { get; }
public abstract bool IsParams(string paramDescription); public virtual bool IsParams(string paramDescription)
{
return paramDescription.TrimStart().StartsWith("params");
}
public virtual void RenameOrExcludeSpecialNames(SymInfo[] symInfos) { } public virtual void RenameOrExcludeSpecialNames(SymInfo[] symInfos) { }
@ -141,9 +125,48 @@ namespace PascalABCCompiler.Parsers
return null; return null;
} }
public abstract string GetArrayDescription(string elementType, int rank); public virtual string GetArrayDescription(string elementType, int rank)
{
if (rank == 1)
return "array of " + elementType;
else
{
StringBuilder sb = new StringBuilder();
sb.Append('[');
for (int i = 0; i < rank - 1; i++)
sb.Append(DelimiterInIndexer);
sb.Append(']');
return "array" + sb.ToString() + " of " + elementType;
}
}
public abstract string GetClassKeyword(class_keyword keyw); public virtual string GetClassKeyword(class_keyword keyw)
{
switch (keyw)
{
case class_keyword.Class: return "class";
case class_keyword.Interface: return "interface";
case class_keyword.Record: return "record";
case class_keyword.TemplateClass: return "template class";
case class_keyword.TemplateRecord: return "template record";
case class_keyword.TemplateInterface: return "template interface";
}
return null;
}
public virtual string GetKeyword(SymbolKind kind)
{
switch (kind)
{
case SymbolKind.Class: return "class";
case SymbolKind.Enum: return "enum";
case SymbolKind.Struct: return "record";
case SymbolKind.Type: return "type";
case SymbolKind.Interface: return "interface";
case SymbolKind.Null: return "nil";
}
return "";
}
public string GetCompiledTypeRepresentation(Type t, MemberInfo mi, ref int line, ref int col) public string GetCompiledTypeRepresentation(Type t, MemberInfo mi, ref int line, ref int col)
{ {
@ -609,7 +632,7 @@ namespace PascalABCCompiler.Parsers
public abstract string GetDescription(IBaseScope scope); public abstract string GetDescription(IBaseScope scope);
// поменять на abstract EVA // поменять на abstract EVA
public virtual string GetDocumentTemplate(string lineText, string Text, int line, int col, int pos) public virtual string GetDocumentTemplate(string lineText, string Text, int line, int col, int pos)
{ {
@ -918,16 +941,19 @@ namespace PascalABCCompiler.Parsers
return "string" + "[" + scope.Length + "]"; return "string" + "[" + scope.Length + "]";
} }
public abstract string GetKeyword(SymbolKind kind);
public KeywordKind GetKeywordKind(string name) public KeywordKind GetKeywordKind(string name)
{ {
if (KeywordsStorage.KeywordKinds.TryGetValue(name, out var kind)) if (LanguageInformation.KeywordsStorage.KeywordKinds.TryGetValue(name, out var kind))
return kind; return kind;
else else
return KeywordKind.None; return KeywordKind.None;
} }
public virtual string GetShortName(ICompiledConstructorScope scope)
{
return StringConstants.default_constructor_name;
}
public string GetShortName(ICompiledTypeScope scope) public string GetShortName(ICompiledTypeScope scope)
{ {
return GetShortTypeName(scope.CompiledType); return GetShortTypeName(scope.CompiledType);
@ -947,7 +973,6 @@ namespace PascalABCCompiler.Parsers
return GetShortTypeName(scope.CompiledMethod); return GetShortTypeName(scope.CompiledMethod);
} }
public abstract string GetShortName(ICompiledConstructorScope scope);
public string GetShortName(IProcScope scope) public string GetShortName(IProcScope scope)
{ {
@ -1433,9 +1458,9 @@ namespace PascalABCCompiler.Parsers
return sc.Name + (((sc as ITypeScope).TemplateArguments != null && !sc.Name.EndsWith("<>") && sc.Name != "class") ? "<>" : "") + "."; return sc.Name + (((sc as ITypeScope).TemplateArguments != null && !sc.Name.EndsWith("<>") && sc.Name != "class") ? "<>" : "") + ".";
} }
if (sc is IInterfaceUnitScope && SpecialModulesAliases != null) if (sc is IInterfaceUnitScope && LanguageInformation.SpecialModulesAliases != null)
{ {
var p = SpecialModulesAliases.FirstOrDefault(kv => kv.Value == sc.Name); var p = LanguageInformation.SpecialModulesAliases.FirstOrDefault(kv => kv.Value == sc.Name);
if (!p.Equals(default(KeyValuePair<string, string>))) if (!p.Equals(default(KeyValuePair<string, string>)))
return p.Key + "."; return p.Key + ".";
@ -1454,9 +1479,9 @@ namespace PascalABCCompiler.Parsers
return sc.Name + (((sc as ITypeScope).TemplateArguments != null && !sc.Name.EndsWith("<>")) ? "<>" : ""); return sc.Name + (((sc as ITypeScope).TemplateArguments != null && !sc.Name.EndsWith("<>")) ? "<>" : "");
} }
if (sc is IInterfaceUnitScope && SpecialModulesAliases != null) if (sc is IInterfaceUnitScope && LanguageInformation.SpecialModulesAliases != null)
{ {
var p = SpecialModulesAliases.FirstOrDefault(kv => kv.Value == sc.Name); var p = LanguageInformation.SpecialModulesAliases.FirstOrDefault(kv => kv.Value == sc.Name);
if (!p.Equals(default(KeyValuePair<string, string>))) if (!p.Equals(default(KeyValuePair<string, string>)))
return p.Key + "."; return p.Key + ".";
@ -1579,11 +1604,20 @@ namespace PascalABCCompiler.Parsers
public abstract string GetStandardTypeByKeyword(KeywordKind keyw); public abstract string GetStandardTypeByKeyword(KeywordKind keyw);
public abstract string GetStringForChar(char c); public virtual string GetStringForChar(char c)
{
return "'" + c.ToString() + "'";
}
public abstract string GetStringForSharpChar(int num); public virtual string GetStringForSharpChar(int num)
{
return "#" + num.ToString();
}
public abstract string GetStringForString(string s); public virtual string GetStringForString(string s)
{
return "'" + s + "'";
}
public abstract string GetSynonimDescription(ITypeScope scope); public abstract string GetSynonimDescription(ITypeScope scope);
@ -1633,14 +1667,23 @@ namespace PascalABCCompiler.Parsers
return null; return null;
} }
public abstract bool IsDefinitionIdentifierAfterKeyword(KeywordKind keyw); public virtual bool IsDefinitionIdentifierAfterKeyword(KeywordKind keyw)
{
if (keyw == PascalABCCompiler.Parsers.KeywordKind.Function || keyw == PascalABCCompiler.Parsers.KeywordKind.Constructor || keyw == PascalABCCompiler.Parsers.KeywordKind.Destructor || keyw == PascalABCCompiler.Parsers.KeywordKind.Type || keyw == PascalABCCompiler.Parsers.KeywordKind.Var
|| keyw == PascalABCCompiler.Parsers.KeywordKind.Unit || keyw == PascalABCCompiler.Parsers.KeywordKind.Const || keyw == PascalABCCompiler.Parsers.KeywordKind.Program || keyw == PascalABCCompiler.Parsers.KeywordKind.Punkt)
return true;
return false;
}
public bool IsKeyword(string value) public bool IsKeyword(string value)
{ {
return KeywordsStorage.KeywordsForIntellisenseSet.Contains(value); return LanguageInformation.KeywordsStorage.KeywordsForIntellisenseSet.Contains(value);
} }
public abstract bool IsMethodCallParameterSeparator(char key); public virtual bool IsMethodCallParameterSeparator(char key)
{
return key == ',';
}
public virtual bool IsNamespaceAfterKeyword(KeywordKind keyw) public virtual bool IsNamespaceAfterKeyword(KeywordKind keyw)
{ {
@ -1657,7 +1700,12 @@ namespace PascalABCCompiler.Parsers
return key == '('; return key == '(';
} }
public abstract bool IsTypeAfterKeyword(KeywordKind keyw); public virtual bool IsTypeAfterKeyword(KeywordKind keyw)
{
if (keyw == KeywordKind.Colon || keyw == KeywordKind.Of || keyw == KeywordKind.TypeDecl)
return true;
return false;
}
// перенести реализацию сюда EVA // перенести реализацию сюда EVA
public virtual string SkipNew(int off, string Text, ref KeywordKind keyw) public virtual string SkipNew(int off, string Text, ref KeywordKind keyw)
@ -1713,7 +1761,7 @@ namespace PascalABCCompiler.Parsers
{ {
keyword = KeywordKind.Raise; keyword = KeywordKind.Raise;
} }
else if (KeywordsStorage.KeywordsTreatedAsFunctions.Contains(s)) else if (LanguageInformation.KeywordsStorage.KeywordsTreatedAsFunctions.Contains(s))
{ {
keyword = KeywordKind.None; keyword = KeywordKind.None;
} }

View file

@ -8,11 +8,11 @@ namespace PascalABCCompiler.Parsers
{ {
public abstract class BaseParser : IParser public abstract class BaseParser : IParser
{ {
public List<Error> Errors { get; protected set; } = new List<Error>(); protected List<Error> Errors = new List<Error>();
public List<CompilerWarning> Warnings { get; protected set; } = new List<CompilerWarning>(); protected List<CompilerWarning> Warnings = new List<CompilerWarning>();
public List<compiler_directive> CompilerDirectives { get; protected set; } = new List<compiler_directive>(); protected List<compiler_directive> CompilerDirectives = new List<compiler_directive>();
public ILanguageInformation LanguageInformation { get; set; } public ILanguageInformation LanguageInformation { get; set; }
@ -71,8 +71,11 @@ namespace PascalABCCompiler.Parsers
private void InitializeBeforeParsing(List<Error> Errors, List<CompilerWarning> Warnings) private void InitializeBeforeParsing(List<Error> Errors, List<CompilerWarning> Warnings)
{ {
Errors.Clear();
Warnings.Clear();
this.Errors = Errors; this.Errors = Errors;
this.Warnings = Warnings; this.Warnings = Warnings;
this.CompilerDirectives = new List<compiler_directive>();
} }
protected virtual syntax_tree_node BuildTree(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings, ParseMode ParseMode, bool compilingNotMainProgram, List<string> DefinesList = null) protected virtual syntax_tree_node BuildTree(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings, ParseMode ParseMode, bool compilingNotMainProgram, List<string> DefinesList = null)
@ -134,10 +137,5 @@ namespace PascalABCCompiler.Parsers
protected abstract syntax_tree_node BuildTreeInStatementMode(string FileName, string Text); protected abstract syntax_tree_node BuildTreeInStatementMode(string FileName, string Text);
public virtual void Reset()
{
// если нужно - переопределяйте
}
} }
} }

View file

@ -0,0 +1,35 @@
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using PascalABCCompiler.ParserTools.Directives;
using System.Collections.Generic;
namespace PascalABCCompiler.Parsers
{
public abstract class DefaultLanguageInformation : ILanguageInformation
{
public abstract string Name { get; }
public abstract string Version { get; }
public abstract string Copyright { get; }
public abstract bool CaseSensitive { get; }
public abstract string[] FilesExtensions { get; }
public abstract string[] SystemUnitNames { get; }
public abstract BaseKeywords KeywordsStorage { get; }
public virtual bool SyntaxTreeIsConvertedAfterUsedModulesCompilation => false;
public virtual Dictionary<string, DirectiveInfo> ValidDirectives => null;
// Важно переопределять для реализации тестов
public virtual string CommentSymbol => "//";
public virtual Dictionary<string, string> SpecialModulesAliases => null;
}
}

View file

@ -6,10 +6,10 @@ using PascalABCCompiler.SyntaxTree;
namespace PascalABCCompiler.Parsers namespace PascalABCCompiler.Parsers
{ {
/// <summary> /// <summary>
/// Интерфейс, предоставляющий информацию интеллисенсу /// Информация о языке
/// </summary> /// </summary>
public interface ILanguageInformation public interface ILanguageInformation
{ {
/// <summary> /// <summary>
/// Название языка /// Название языка
@ -41,6 +41,43 @@ namespace PascalABCCompiler.Parsers
/// </summary> /// </summary>
string[] SystemUnitNames { get; } string[] SystemUnitNames { get; }
/// <summary>
/// Нужно ли вызывать конверторы синтаксического дерева, срабатывающие после компиляции зависимостей
/// </summary>
bool SyntaxTreeIsConvertedAfterUsedModulesCompilation { get; }
/// <summary>
/// Класс с информацией о ключевых словах языка
/// </summary>
BaseKeywords KeywordsStorage
{
get;
}
/// <summary>
/// Данные о всех поддерживаемых директивах компилятора
/// </summary>
Dictionary<string, ParserTools.Directives.DirectiveInfo> ValidDirectives { get; }
/// <summary>
/// Обозначение однострочного комментария (используется в TestRunner)
/// </summary>
string CommentSymbol { get; }
/// <summary>
/// Имена стандартных модулей, которые не совпадают с именами их файлов.
/// Можно задавать null.
/// </summary>
Dictionary<string, string> SpecialModulesAliases { get; }
}
/// <summary>
/// Интерфейс, предоставляющий информацию интеллисенсу
/// </summary>
public interface ILanguageIntellisenseSupport
{
ILanguageInformation LanguageInformation { get; set; }
/// <summary> /// <summary>
/// Получить полное описание элемента (в желтой подсказке) /// Получить полное описание элемента (в желтой подсказке)
/// </summary> /// </summary>
@ -176,30 +213,11 @@ namespace PascalABCCompiler.Parsers
int FindParamDelimForIndexer(string descriptionAfterOpeningParenthesis, int number); int FindParamDelimForIndexer(string descriptionAfterOpeningParenthesis, int number);
/// <summary>
/// Нужно ли вызывать конверторы синтаксического дерева, срабатывающие после компиляции зависимостей
/// </summary>
bool SyntaxTreeIsConvertedAfterUsedModulesCompilation { get; }
/// <summary> /// <summary>
/// Вызывать ли преобразователей синтаксического дерева в работе Intellisense /// Вызывать ли преобразователей синтаксического дерева в работе Intellisense
/// </summary> /// </summary>
bool ApplySyntaxTreeConvertersForIntellisense { get; } bool ApplySyntaxTreeConvertersForIntellisense { get; }
Dictionary<string, string> SpecialModulesAliases { get; }
BaseKeywords KeywordsStorage
{
get;
}
/// <summary>
/// Данные о всех поддерживаемых директивах компилятора
/// </summary>
Dictionary<string, ParserTools.Directives.DirectiveInfo> ValidDirectives { get; }
string CommentSymbol { get; }
string BodyStartBracket string BodyStartBracket
{ {
get; get;

View file

@ -3,22 +3,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using PascalABCCompiler.SyntaxTree; using PascalABCCompiler.SyntaxTree;
using PascalABCCompiler.Errors; using PascalABCCompiler.Errors;
using System;
namespace PascalABCCompiler.Parsers namespace PascalABCCompiler.Parsers
{ {
public enum ParseMode { Normal, Expression, Statement, Special, ForFormatter, TypeAsExpression }; public enum ParseMode { Normal, Expression, Statement, Special, ForFormatter, TypeAsExpression };
public interface IParser public interface IParser
{ {
List<Error> Errors { get; }
List<CompilerWarning> Warnings { get; }
List<compiler_directive> CompilerDirectives
{
get;
}
ILanguageInformation LanguageInformation { get; set; } ILanguageInformation LanguageInformation { get; set; }
compilation_unit GetCompilationUnit(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings, ParseMode parseMode, bool compilingNotMainProgram, List<string> DefinesList = null); compilation_unit GetCompilationUnit(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings, ParseMode parseMode, bool compilingNotMainProgram, List<string> DefinesList = null);
@ -30,8 +20,6 @@ namespace PascalABCCompiler.Parsers
statement GetStatement(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings); statement GetStatement(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings);
expression GetTypeAsExpression(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings); expression GetTypeAsExpression(string FileName, string Text, List<Error> Errors, List<CompilerWarning> Warnings);
void Reset();
} }

View file

@ -0,0 +1,38 @@
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using PascalABCCompiler.SyntaxTree;
namespace PascalABCCompiler.Parsers
{
/// <summary>
/// Базовый класс для парсера без поддержки построения частей дерева и построения дерева с пропуском ошибок (Special mode)
/// </summary>
public abstract class SimpleParser : BaseParser
{
protected override syntax_tree_node BuildTreeInExprMode(string FileName, string Text)
{
throw new System.NotImplementedException();
}
protected override syntax_tree_node BuildTreeInFormatterMode(string FileName, string Text)
{
throw new System.NotImplementedException();
}
protected override syntax_tree_node BuildTreeInSpecialMode(string FileName, string Text, bool compilingNotMainProgram)
{
throw new System.NotImplementedException();
}
protected override syntax_tree_node BuildTreeInStatementMode(string FileName, string Text)
{
throw new System.NotImplementedException();
}
protected override syntax_tree_node BuildTreeInTypeExprMode(string FileName, string Text)
{
throw new System.NotImplementedException();
}
}
}

View file

@ -71,17 +71,6 @@ namespace Languages.Pascal.Frontend.Wrapping
/// </summary> /// </summary>
public class PascalABCNewLanguageParser : BaseParser public class PascalABCNewLanguageParser : BaseParser
{ {
public override void Reset()
{
CompilerDirectives = new List<compiler_directive>();
Errors.Clear();
}
protected override void PreBuildTree(string FileName)
{
CompilerDirectives = new List<compiler_directive>();
}
private syntax_tree_node Parse(string Text, string fileName, bool buildTreeForFormatter = false, List<string> definesList = null) private syntax_tree_node Parse(string Text, string fileName, bool buildTreeForFormatter = false, List<string> definesList = null)
{ {
@ -115,8 +104,6 @@ namespace Languages.Pascal.Frontend.Wrapping
protected override syntax_tree_node BuildTreeInNormalMode(string FileName, string Text, bool compilingNotMainProgram, List<string> DefinesList = null) protected override syntax_tree_node BuildTreeInNormalMode(string FileName, string Text, bool compilingNotMainProgram, List<string> DefinesList = null)
{ {
Errors.Clear();
Warnings.Clear();
syntax_tree_node root = Parse(Text, FileName, false, DefinesList); syntax_tree_node root = Parse(Text, FileName, false, DefinesList);
if (Errors.Count > 0) if (Errors.Count > 0)
@ -163,14 +150,12 @@ namespace Languages.Pascal.Frontend.Wrapping
protected override syntax_tree_node BuildTreeInSpecialMode(string FileName, string Text, bool compilingNotMainProgram) protected override syntax_tree_node BuildTreeInSpecialMode(string FileName, string Text, bool compilingNotMainProgram)
{ {
Errors.Clear();
syntax_tree_node root = Parse(Text, FileName); syntax_tree_node root = Parse(Text, FileName);
return root; return root;
} }
protected override syntax_tree_node BuildTreeInFormatterMode(string FileName, string Text) protected override syntax_tree_node BuildTreeInFormatterMode(string FileName, string Text)
{ {
Errors.Clear();
syntax_tree_node root = Parse(Text, FileName, true); syntax_tree_node root = Parse(Text, FileName, true);
return root; return root;
} }

File diff suppressed because it is too large Load diff

View file

@ -15,6 +15,7 @@ namespace Languages.Pascal
public PascalABCLanguage() : base( public PascalABCLanguage() : base(
languageInformation: new Frontend.Data.PascalABCLanguageInformation(), languageInformation: new Frontend.Data.PascalABCLanguageInformation(),
languageIntellisenseSupport: new Frontend.Data.PascalABCIntellisenseSupport(),
parser: new Frontend.Wrapping.PascalABCNewLanguageParser(), parser: new Frontend.Wrapping.PascalABCNewLanguageParser(),
docParser: new Frontend.Documentation.PascalDocTagsLanguageParser(), docParser: new Frontend.Documentation.PascalDocTagsLanguageParser(),

File diff suppressed because it is too large Load diff

View file

@ -362,8 +362,8 @@ namespace VisualPascalABCPlugins
public interface IWidgetStatusContoller public interface IWidgetStatusContoller
{ {
void SetStartDebugEnabled(); void SetStartDebugAndRunEnabled();
void SetStartDebugDisabled(); void SetStartDebugAndRunDisabled();
void SetDebugStopDisabled(); void SetDebugStopDisabled();
void SetDebugStopEnabled(); void SetDebugStopEnabled();
void SetAddExprMenuVisible(bool val); void SetAddExprMenuVisible(bool val);
@ -372,10 +372,10 @@ namespace VisualPascalABCPlugins
void SetDebugPausedDisabled(); void SetDebugPausedDisabled();
void SetPlayButtonsVisible(bool val); void SetPlayButtonsVisible(bool val);
void SetStopEnabled(bool enabled); void SetStopEnabled(bool enabled);
void SetCompilingButtonsEnabled(bool Enabled); void SetCompilingAndRunButtonsEnabled(bool Enabled);
void SetDebugButtonsEnabled(bool val); void SetDebugButtonsEnabled(bool val);
void SetOptionsEnabled(bool val); void SetOptionsEnabled(bool val);
bool CompilingButtonsEnabled { get; set; } bool CompilingAndRunButtonsEnabled { get; set; }
void EnableCodeCompletionToolTips(bool val); void EnableCodeCompletionToolTips(bool val);
void ChangeContinueDebugNameOnStart(); void ChangeContinueDebugNameOnStart();
void ChangeStartDebugNameOnContinue(); void ChangeStartDebugNameOnContinue();

View file

@ -348,8 +348,8 @@ namespace VisualPascalABCPlugins
public interface IWidgetStatusContoller public interface IWidgetStatusContoller
{ {
void SetStartDebugEnabled(); void SetStartDebugAndRunEnabled();
void SetStartDebugDisabled(); void SetStartDebugAndRunDisabled();
void SetDebugStopDisabled(); void SetDebugStopDisabled();
void SetDebugStopEnabled(); void SetDebugStopEnabled();
void SetAddExprMenuVisible(bool val); void SetAddExprMenuVisible(bool val);
@ -358,10 +358,10 @@ namespace VisualPascalABCPlugins
void SetDebugPausedDisabled(); void SetDebugPausedDisabled();
void SetPlayButtonsVisible(bool val); void SetPlayButtonsVisible(bool val);
void SetStopEnabled(bool enabled); void SetStopEnabled(bool enabled);
void SetCompilingButtonsEnabled(bool Enabled); void SetCompilingAndRunButtonsEnabled(bool Enabled);
void SetDebugButtonsEnabled(bool val); void SetDebugButtonsEnabled(bool val);
void SetOptionsEnabled(bool val); void SetOptionsEnabled(bool val);
bool CompilingButtonsEnabled { get; set; } bool CompilingAndRunButtonsEnabled { get; set; }
void EnableCodeCompletionToolTips(bool val); void EnableCodeCompletionToolTips(bool val);
void ChangeContinueDebugNameOnStart(); void ChangeContinueDebugNameOnStart();
void ChangeStartDebugNameOnContinue(); void ChangeStartDebugNameOnContinue();

View file

@ -67,11 +67,11 @@ namespace ICSharpCode.TextEditor.Util
if (param_num == -1) if (param_num == -1)
return; return;
var languageInfo = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation; var languageIntellisenseSupport = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport;
int startIndex = basicDescription.IndexOf("(", basicDescription.IndexOf("(" + PascalABCCompiler.StringResources.Get("CODE_COMPLETION_EXTENSION")) + 1) + 1; int startIndex = basicDescription.IndexOf("(", basicDescription.IndexOf("(" + PascalABCCompiler.StringResources.Get("CODE_COMPLETION_EXTENSION")) + 1) + 1;
int paranthesisIndex = languageInfo.FindClosingParenthesis(basicDescription.Substring(startIndex), ')'); int paranthesisIndex = languageIntellisenseSupport.FindClosingParenthesis(basicDescription.Substring(startIndex), ')');
if (paranthesisIndex == -1) if (paranthesisIndex == -1)
return; return;
@ -84,7 +84,7 @@ namespace ICSharpCode.TextEditor.Util
if (bold_beg != 0) if (bold_beg != 0)
{ {
int paramDelimIndex = languageInfo.FindParamDelim(basicDescription.Substring(bold_beg), 1); int paramDelimIndex = languageIntellisenseSupport.FindParamDelim(basicDescription.Substring(bold_beg), 1);
if (paramDelimIndex == -1) if (paramDelimIndex == -1)
{ {
@ -105,7 +105,7 @@ namespace ICSharpCode.TextEditor.Util
{ {
string paramDescription = basicDescription.Substring(startIndex, paranthesisIndex); string paramDescription = basicDescription.Substring(startIndex, paranthesisIndex);
if (languageInfo.IsParams(paramDescription)) if (languageIntellisenseSupport.IsParams(paramDescription))
{ {
bold_beg = startIndex; bold_beg = startIndex;
bold_len = paranthesisIndex; bold_len = paranthesisIndex;
@ -115,15 +115,15 @@ namespace ICSharpCode.TextEditor.Util
{ {
string descriptionAfterBracket = basicDescription.Substring(startIndex); string descriptionAfterBracket = basicDescription.Substring(startIndex);
int paramDelimIndex = languageInfo.FindParamDelim(descriptionAfterBracket, paramsCount - 1); int paramDelimIndex = languageIntellisenseSupport.FindParamDelim(descriptionAfterBracket, paramsCount - 1);
if (paramDelimIndex != -1) if (paramDelimIndex != -1)
{ {
int paramDelimLength = languageInfo.ParameterDelimiter.Length; int paramDelimLength = languageIntellisenseSupport.ParameterDelimiter.Length;
string paramDescription = descriptionAfterBracket.Substring(paramDelimIndex + paramDelimLength, paranthesisIndex - paramDelimIndex - paramDelimLength); string paramDescription = descriptionAfterBracket.Substring(paramDelimIndex + paramDelimLength, paranthesisIndex - paramDelimIndex - paramDelimLength);
if (languageInfo.IsParams(paramDescription)) if (languageIntellisenseSupport.IsParams(paramDescription))
{ {
bold_beg = paramDelimIndex + startIndex + paramDelimLength; bold_beg = paramDelimIndex + startIndex + paramDelimLength;
bold_len = end_sk - bold_beg; bold_len = end_sk - bold_beg;
@ -133,12 +133,12 @@ namespace ICSharpCode.TextEditor.Util
} }
else else
{ {
int paramDelimIndex = languageInfo.FindParamDelim(basicDescription.Substring(startIndex), param_num - 1); int paramDelimIndex = languageIntellisenseSupport.FindParamDelim(basicDescription.Substring(startIndex), param_num - 1);
if (paramDelimIndex != -1) if (paramDelimIndex != -1)
{ {
bold_beg = paramDelimIndex + startIndex + languageInfo.ParameterDelimiter.Length; bold_beg = paramDelimIndex + startIndex + languageIntellisenseSupport.ParameterDelimiter.Length;
int secondParamDelimIndex = languageInfo.FindParamDelim(basicDescription.Substring(startIndex), param_num); int secondParamDelimIndex = languageIntellisenseSupport.FindParamDelim(basicDescription.Substring(startIndex), param_num);
if (secondParamDelimIndex == -1) if (secondParamDelimIndex == -1)
{ {

View file

@ -33,7 +33,7 @@ namespace VisualPascalABC
private System.Threading.Thread MainProgramThread = System.Threading.Thread.CurrentThread; private System.Threading.Thread MainProgramThread = System.Threading.Thread.CurrentThread;
private System.Threading.Thread StartingThread; private System.Threading.Thread StartingThread;
public delegate void SetFlagDelegate(bool flag); public delegate void SetFlagDelegate(bool flag);
private SetFlagDelegate SetCompilingButtonsEnabled; private SetFlagDelegate SetCompilingAndRunButtonsEnabled;
private SetFlagDelegate SetDebugButtonsEnabled; private SetFlagDelegate SetDebugButtonsEnabled;
public ConvertTextDelegate ConvertUnitTextProperty { get; set; } public ConvertTextDelegate ConvertUnitTextProperty { get; set; }
@ -67,7 +67,7 @@ namespace VisualPascalABC
Dictionary<string, CodeFileDocumentControl> OpenDocuments; Dictionary<string, CodeFileDocumentControl> OpenDocuments;
public VisualEnvironmentCompiler(InvokeDegegate beginInvoke, public VisualEnvironmentCompiler(InvokeDegegate beginInvoke,
SetFlagDelegate setCompilingButtonsEnabled, SetFlagDelegate setCompilingDebugEnabled, SetTextDelegate setStateText, SetFlagDelegate setCompilingAndRunButtonsEnabled, SetFlagDelegate setCompilingDebugEnabled, SetTextDelegate setStateText,
SetTextDelegate addTextToCompilerMessages, ToolStripMenuItem pluginsMenuItem, SetTextDelegate addTextToCompilerMessages, ToolStripMenuItem pluginsMenuItem,
ToolStrip pluginsToolStrip, ExecuteSourceLocationActionDelegate ExecuteSLAction, ToolStrip pluginsToolStrip, ExecuteSourceLocationActionDelegate ExecuteSLAction,
ExecuteVisualEnvironmentCompilerActionDelegate ExecuteVECAction, ExecuteVisualEnvironmentCompilerActionDelegate ExecuteVECAction,
@ -77,7 +77,7 @@ namespace VisualPascalABC
this.StandartDirectories = StandartDirectories; this.StandartDirectories = StandartDirectories;
this.ErrorsManager = ErrorsManager; this.ErrorsManager = ErrorsManager;
this.ChangeVisualEnvironmentState += onChangeVisualEnvironmentState; this.ChangeVisualEnvironmentState += onChangeVisualEnvironmentState;
SetCompilingButtonsEnabled = setCompilingButtonsEnabled; SetCompilingAndRunButtonsEnabled = setCompilingAndRunButtonsEnabled;
SetDebugButtonsEnabled = setCompilingDebugEnabled; SetDebugButtonsEnabled = setCompilingDebugEnabled;
SetStateText = setStateText; SetStateText = setStateText;
AddTextToCompilerMessages = addTextToCompilerMessages; AddTextToCompilerMessages = addTextToCompilerMessages;
@ -362,7 +362,7 @@ namespace VisualPascalABC
{ {
case PascalABCCompiler.CompilerState.CompilationStarting: case PascalABCCompiler.CompilerState.CompilationStarting:
RusName = VECStringResources.Get("STATE_START_COMPILING_ASSEMBLY{0}"); RusName = VECStringResources.Get("STATE_START_COMPILING_ASSEMBLY{0}");
SetCompilingButtonsEnabled(false); SetCompilingAndRunButtonsEnabled(false);
ParsedFiles.Clear(); ParsedFiles.Clear();
break; break;
case PascalABCCompiler.CompilerState.BeginCompileFile: RusName = VECStringResources.Get("STATE_BEGINCOMPILEFILE{0}"); break; case PascalABCCompiler.CompilerState.BeginCompileFile: RusName = VECStringResources.Get("STATE_BEGINCOMPILEFILE{0}"); break;
@ -407,21 +407,22 @@ namespace VisualPascalABC
if (!ThreadPool.QueueUserWorkItem(new WaitCallback(LoadPlugins))) if (!ThreadPool.QueueUserWorkItem(new WaitCallback(LoadPlugins)))
LoadPlugins(null); LoadPlugins(null);
SetCompilingButtonsEnabled(true); SetCompilingAndRunButtonsEnabled(true);
SetDebugButtonsEnabled(true); if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
SetDebugButtonsEnabled(true);
} }
} }
else else
{ {
if (Compiler == sender) if (Compiler == sender)
{ {
SetCompilingButtonsEnabled(true); SetCompilingAndRunButtonsEnabled(true);
} }
} }
break; break;
case PascalABCCompiler.CompilerState.Reloading: case PascalABCCompiler.CompilerState.Reloading:
if (Compiler == sender) if (Compiler == sender)
SetCompilingButtonsEnabled(false); SetCompilingAndRunButtonsEnabled(false);
RusName = VECStringResources.Get("STATE_RELOADING"); RusName = VECStringResources.Get("STATE_RELOADING");
break; break;
case PascalABCCompiler.CompilerState.CompilationFinished: case PascalABCCompiler.CompilerState.CompilationFinished:

View file

@ -261,6 +261,7 @@ namespace VisualPascalABC
this.StepOutButton.Visible = false; this.StepOutButton.Visible = false;
PlayPauseButtonsVisibleInPanel = PlayPauseButtonsVisibleInPanel; PlayPauseButtonsVisibleInPanel = PlayPauseButtonsVisibleInPanel;
SetDebugButtonsEnabled(false); SetDebugButtonsEnabled(false);
SetRunButtonsEnabled(false);
} }
AddOwnedForm(CompilerForm1 = new CompilerForm()); AddOwnedForm(CompilerForm1 = new CompilerForm());
@ -335,7 +336,7 @@ namespace VisualPascalABC
RunManager RunnerManager = (WorkbenchServiceFactory.RunService as WorkbenchRunService).RunnerManager; RunManager RunnerManager = (WorkbenchServiceFactory.RunService as WorkbenchRunService).RunnerManager;
VisualEnvironmentCompiler = new VisualEnvironmentCompiler( VisualEnvironmentCompiler = new VisualEnvironmentCompiler(
this.BeginInvoke, SetCompilingButtonsEnabled, SetDedugButtonsEnabled, SetStateText, this.BeginInvoke, SetCompilingAndRunButtonsEnabled, SetDebugButtonsEnabled, SetStateText,
AddTextToCompilerMessagesSync, miPlugins, toolStrip1, AddTextToCompilerMessagesSync, miPlugins, toolStrip1,
ExecuteSourceLocationAction, ExecuteVisualEnvironmentCompilerAction, ErrorsManager, RunnerManager, ExecuteSourceLocationAction, ExecuteVisualEnvironmentCompilerAction, ErrorsManager, RunnerManager,
WorkbenchServiceFactory.DebuggerManager, UserOptions, WorkbenchStorage.StandartDirectories, OpenDocuments, this); WorkbenchServiceFactory.DebuggerManager, UserOptions, WorkbenchStorage.StandartDirectories, OpenDocuments, this);
@ -403,9 +404,9 @@ namespace VisualPascalABC
WorkbenchServiceFactory.FileService.OpenFile(FileNameToWait, null); WorkbenchServiceFactory.FileService.OpenFile(FileNameToWait, null);
} }
SetStopEnabled(false); SetStopEnabled(false);
CompilingButtonsEnabled = CloseButtonsEnabled = SaveAllButtonsEnabled = SaveButtonsEnabled = false; CompilingAndRunButtonsEnabled = CloseButtonsEnabled = SaveAllButtonsEnabled = SaveButtonsEnabled = false;
SetDedugButtonsEnabled(false); SetDebugButtonsEnabled(false);
SetCompilingButtonsEnabled(false); SetCompilingAndRunButtonsEnabled(false);
HelpFileName = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.HelpFileName, WorkbenchStorage.StandartDirectories); HelpFileName = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.HelpFileName, WorkbenchStorage.StandartDirectories);
DotNetHelpFileName = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.DotNetHelpFileName, WorkbenchStorage.StandartDirectories); DotNetHelpFileName = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.DotNetHelpFileName, WorkbenchStorage.StandartDirectories);

View file

@ -20,7 +20,7 @@ namespace VisualPascalABC
public static void Rename(TextArea textArea) public static void Rename(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
IDocument doc = textArea.Document; IDocument doc = textArea.Document;
string textContent = doc.TextContent; string textContent = doc.TextContent;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
@ -60,7 +60,7 @@ namespace VisualPascalABC
public static void RenameUnit(string FileName, string new_val) public static void RenameUnit(string FileName, string new_val)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
IDocument doc = null; IDocument doc = null;
CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController(); CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController();
@ -121,11 +121,8 @@ namespace VisualPascalABC
public static List<Position> GetDefinitionPosition(TextArea textArea, bool only_check) public static List<Position> GetDefinitionPosition(TextArea textArea, bool only_check)
{ {
IParser parser = CodeCompletion.CodeCompletionController.CurrentParser; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return new List<Position>();
if (parser == null)
return new List<Position>();
IDocument doc = textArea.Document; IDocument doc = textArea.Document;
string textContent = doc.TextContent; string textContent = doc.TextContent;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
@ -137,7 +134,7 @@ namespace VisualPascalABC
// Проверка, что компилируем Паскаль временно EVA 10.11.2024 // Проверка, что компилируем Паскаль временно EVA 10.11.2024
if (parser == Languages.Facade.LanguageProvider.Instance.SelectLanguageByName(StringConstants.pascalLanguageName).Parser) if (CodeCompletion.CodeCompletionController.CurrentLanguage == Languages.Facade.LanguageProvider.Instance.MainLanguage)
{ {
if (expressionResult != full_expr && full_expr.StartsWith("(")) if (expressionResult != full_expr && full_expr.StartsWith("("))
return new List<Position>(); return new List<Position>();
@ -158,7 +155,7 @@ namespace VisualPascalABC
public static List<Position> GetRealizationPosition(TextArea textArea) public static List<Position> GetRealizationPosition(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return new List<Position>(); if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return new List<Position>();
IDocument doc = textArea.Document; IDocument doc = textArea.Document;
string textContent = doc.TextContent; string textContent = doc.TextContent;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
@ -172,7 +169,7 @@ namespace VisualPascalABC
public static List<SymbolsViewerSymbol> FindReferences(TextArea textArea) public static List<SymbolsViewerSymbol> FindReferences(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return new List<SymbolsViewerSymbol>(); if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return new List<SymbolsViewerSymbol>();
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
string full_expr; string full_expr;
string expressionResult = FindFullExpression(textArea.Document.TextContent, textArea, out ccp.keyword, out full_expr); string expressionResult = FindFullExpression(textArea.Document.TextContent, textArea, out ccp.keyword, out full_expr);
@ -181,7 +178,7 @@ namespace VisualPascalABC
public static void GotoRealization(TextArea textArea) public static void GotoRealization(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
position = GetRealizationPosition(textArea); position = GetRealizationPosition(textArea);
if (position == null || position.Count == 0) return; if (position == null || position.Count == 0) return;
if (position.Count == 1) if (position.Count == 1)
@ -210,7 +207,7 @@ namespace VisualPascalABC
public static bool CanGoTo(TextArea textArea) public static bool CanGoTo(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
List<Position> poses = GetDefinitionPosition(textArea, true); List<Position> poses = GetDefinitionPosition(textArea, true);
if (poses == null || poses.Count == 0) return false; if (poses == null || poses.Count == 0) return false;
foreach (Position pos in poses) foreach (Position pos in poses)
@ -223,7 +220,7 @@ namespace VisualPascalABC
public static bool CanGoToRealization(TextArea textArea) public static bool CanGoToRealization(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
List<Position> poses = GetRealizationPosition(textArea); List<Position> poses = GetRealizationPosition(textArea);
if (poses == null || poses.Count == 0) return false; if (poses == null || poses.Count == 0) return false;
foreach (Position pos in poses) foreach (Position pos in poses)
@ -238,7 +235,7 @@ namespace VisualPascalABC
{ {
try try
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
string full_expr; string full_expr;
string expressionResult = FindFullExpression(textArea.Document.TextContent, textArea, out ccp.keyword, out full_expr); string expressionResult = FindFullExpression(textArea.Document.TextContent, textArea, out ccp.keyword, out full_expr);
@ -259,7 +256,7 @@ namespace VisualPascalABC
{ {
try try
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
Position pos = new Position(); Position pos = new Position();
//string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos); //string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos);
@ -276,7 +273,7 @@ namespace VisualPascalABC
{ {
try try
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
Position pos = new Position(); Position pos = new Position();
//string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos); //string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos);
@ -299,7 +296,7 @@ namespace VisualPascalABC
private static TextArea _textArea; private static TextArea _textArea;
public static void GenerateOverridableMethods(TextArea textArea) public static void GenerateOverridableMethods(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
_textArea = textArea; _textArea = textArea;
int off = textArea.Caret.Offset; int off = textArea.Caret.Offset;
@ -329,7 +326,7 @@ namespace VisualPascalABC
public static void GenerateClassOrMethodRealization(TextArea textArea) public static void GenerateClassOrMethodRealization(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
Position pos = new Position(); Position pos = new Position();
//string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos); //string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos);
@ -459,12 +456,12 @@ namespace VisualPascalABC
public static bool GenerateCommentTemplate(TextArea textArea) public static bool GenerateCommentTemplate(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
//if (!should_insert_comment(textArea)) //if (!should_insert_comment(textArea))
// return false; // return false;
string lineText = get_next_line(textArea); string lineText = get_next_line(textArea);
string addit = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.GetDocumentTemplate( string addit = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDocumentTemplate(
lineText, textArea.Document.TextContent, textArea.Caret.Line, textArea.Caret.Column, textArea.Caret.Offset); lineText, textArea.Document.TextContent, textArea.Caret.Line, textArea.Caret.Column, textArea.Caret.Offset);
if (addit == null) if (addit == null)
return false; return false;
@ -506,7 +503,7 @@ namespace VisualPascalABC
public static void GotoDefinition(TextArea _textArea) public static void GotoDefinition(TextArea _textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
position = GetDefinitionPosition(_textArea, false); position = GetDefinitionPosition(_textArea, false);
if (position == null) return; if (position == null) return;
if (position.Count == 1) if (position.Count == 1)
@ -544,9 +541,9 @@ namespace VisualPascalABC
keyw = PascalABCCompiler.Parsers.KeywordKind.None; keyw = PascalABCCompiler.Parsers.KeywordKind.None;
string expr_without_brackets = null; string expr_without_brackets = null;
full_expr = null; full_expr = null;
if (CodeCompletion.CodeCompletionController.CurrentParser != null) if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
{ {
full_expr = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpressionFromAnyPosition(_textArea.Caret.Offset, Text, _textArea.Caret.Line, _textArea.Caret.Column, out keyw, out expr_without_brackets); full_expr = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpressionFromAnyPosition(_textArea.Caret.Offset, Text, _textArea.Caret.Line, _textArea.Caret.Column, out keyw, out expr_without_brackets);
return expr_without_brackets; return expr_without_brackets;
} }
return null; return null;
@ -554,7 +551,7 @@ namespace VisualPascalABC
private static string FindOnlyIdent(string Text, TextArea _textArea, ref string name) private static string FindOnlyIdent(string Text, TextArea _textArea, ref string name)
{ {
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindOnlyIdentifier(_textArea.Caret.Offset, Text, _textArea.Caret.Line, _textArea.Caret.Column, ref name); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindOnlyIdentifier(_textArea.Caret.Offset, Text, _textArea.Caret.Line, _textArea.Caret.Column, ref name);
} }
@ -642,7 +639,7 @@ namespace VisualPascalABC
if (!WorkbenchServiceFactory.Workbench.UserOptions.CodeCompletionDot) if (!WorkbenchServiceFactory.Workbench.UserOptions.CodeCompletionDot)
return; return;
if (CodeCompletion.CodeCompletionController.CurrentParser == null) if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return; return;
is_begin = true; is_begin = true;
@ -687,7 +684,7 @@ namespace VisualPascalABC
{ {
public override void Execute(TextArea textArea) public override void Execute(TextArea textArea)
{ {
if (WorkbenchServiceFactory.DebuggerManager.IsRunning) if (WorkbenchServiceFactory.DebuggerManager.IsRunning || !CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return; return;
WorkbenchServiceFactory.Workbench.ErrorsListWindow.ClearErrorList(); WorkbenchServiceFactory.Workbench.ErrorsListWindow.ClearErrorList();
VisualPABCSingleton.MainForm.CurrentCodeFileDocument.DeselectAll(); VisualPABCSingleton.MainForm.CurrentCodeFileDocument.DeselectAll();
@ -697,12 +694,14 @@ namespace VisualPascalABC
// MainForm.VisualEnvironmentCompiler.Compiler.ParsersController.Compile( // MainForm.VisualEnvironmentCompiler.Compiler.ParsersController.Compile(
// file_name, TextEditor.Text, null, Errors, PascalABCCompiler.Parsers.ParseMode.Normal); // file_name, TextEditor.Text, null, Errors, PascalABCCompiler.Parsers.ParseMode.Normal);
string text = WorkbenchServiceFactory.Workbench.VisualEnvironmentCompiler.SourceFilesProvider(VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName, PascalABCCompiler.SourceFileOperation.GetText) as string; string text = WorkbenchServiceFactory.Workbench.VisualEnvironmentCompiler.SourceFilesProvider(VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName, PascalABCCompiler.SourceFileOperation.GetText) as string;
PascalABCCompiler.SyntaxTree.compilation_unit cu = PascalABCCompiler.SyntaxTree.compilation_unit cu =
Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtensionSafe(VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName)?.Parser.GetCompilationUnitForFormatter( CodeCompletion.CodeCompletionController.CurrentLanguage.Parser.GetCompilationUnitForFormatter(
VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName, VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName,
text, //VisualPascalABC.Form1.Form1_object._currentCodeFileDocument.TextEditor.Text, text, //VisualPascalABC.Form1.Form1_object._currentCodeFileDocument.TextEditor.Text,
Errors, Errors,
new List<PascalABCCompiler.Errors.CompilerWarning>()); new List<PascalABCCompiler.Errors.CompilerWarning>());
if (Errors.Count == 0) if (Errors.Count == 0)
{ {
string formattedText = cf.FormatTree(text, cu, textArea.Caret.Line + 1, textArea.Caret.Column + 1); string formattedText = cf.FormatTree(text, cu, textArea.Caret.Line + 1, textArea.Caret.Column + 1);
@ -732,17 +731,18 @@ namespace VisualPascalABC
{ {
//try //try
{ {
if (!WorkbenchServiceFactory.Workbench.UserOptions.CodeCompletionDot)
return;
if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
textArea = _textArea; textArea = _textArea;
int off = textArea.Caret.Offset; int off = textArea.Caret.Offset;
string text = textArea.Document.TextContent.Substring(0, textArea.Caret.Offset); string text = textArea.Document.TextContent.Substring(0, textArea.Caret.Offset);
if (!WorkbenchServiceFactory.Workbench.UserOptions.CodeCompletionDot)
return;
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return;
CodeCompletionProvider completionDataProvider = new CodeCompletionProvider(); CodeCompletionProvider completionDataProvider = new CodeCompletionProvider();
completionDataProvider.preSelection = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindPattern(off, text, out var is_pattern); completionDataProvider.preSelection = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindPattern(off, text, out var is_pattern);
codeCompletionWindow = PABCNETCodeCompletionWindow.ShowCompletionWindow( codeCompletionWindow = PABCNETCodeCompletionWindow.ShowCompletionWindow(
VisualPABCSingleton.MainForm, // The parent window for the completion window VisualPABCSingleton.MainForm, // The parent window for the completion window

View file

@ -54,8 +54,8 @@ namespace VisualPascalABC
{ {
public static PascalABCCompiler.Parsers.KeywordKind TestForKeyword(string Text, int i) public static PascalABCCompiler.Parsers.KeywordKind TestForKeyword(string Text, int i)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser != null && CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation !=null) if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.TestForKeyword(Text, i); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.TestForKeyword(Text, i);
return PascalABCCompiler.Parsers.KeywordKind.None; return PascalABCCompiler.Parsers.KeywordKind.None;
} }

View file

@ -64,7 +64,7 @@ namespace VisualPascalABC
{ {
if (!WorkbenchServiceFactory.Workbench.UserOptions.AllowCodeCompletion || !VisualPABCSingleton.MainForm.VisualEnvironmentCompiler.compilerLoaded) if (!WorkbenchServiceFactory.Workbench.UserOptions.AllowCodeCompletion || !VisualPABCSingleton.MainForm.VisualEnvironmentCompiler.compilerLoaded)
return false; return false;
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
if (codeCompletionWindow != null) if (codeCompletionWindow != null)
{ {
// If completion window is open and wants to handle the key, don't let the text area // If completion window is open and wants to handle the key, don't let the text area
@ -93,8 +93,6 @@ namespace VisualPascalABC
} }
if (key == '.') if (key == '.')
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null)
return false;
if (!string.IsNullOrEmpty(WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.SelectionManager.SelectedText)) if (!string.IsNullOrEmpty(WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.SelectionManager.SelectedText))
{ {
WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Position = WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.SelectionManager.SelectionCollection[0].StartPosition; WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Position = WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.SelectionManager.SelectionCollection[0].StartPosition;
@ -123,7 +121,6 @@ namespace VisualPascalABC
} }
else if (key == '(' || key == '[' || key == ',') else if (key == '(' || key == '[' || key == ',')
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false;
if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionParams) if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionParams)
{ {
ICSharpCode.TextEditor.Gui.InsightWindow.IInsightDataProvider idp = new DefaultInsightDataProvider(-1, false, key); ICSharpCode.TextEditor.Gui.InsightWindow.IInsightDataProvider idp = new DefaultInsightDataProvider(-1, false, key);
@ -145,7 +142,6 @@ namespace VisualPascalABC
} }
else if (key == ' ') else if (key == ' ')
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false;
if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionDot) if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionDot)
{ {
PascalABCCompiler.Parsers.KeywordKind keyw = KeywordChecker.TestForKeyword(editor.Document.TextContent, editor.ActiveTextAreaControl.TextArea.Caret.Offset - 1); PascalABCCompiler.Parsers.KeywordKind keyw = KeywordChecker.TestForKeyword(editor.Document.TextContent, editor.ActiveTextAreaControl.TextArea.Caret.Offset - 1);
@ -171,7 +167,7 @@ namespace VisualPascalABC
} }
else if (key == '\n') else if (key == '\n')
{ {
if (VisualPABCSingleton.MainForm.UserOptions.AllowCodeCompletion && CodeCompletion.CodeCompletionController.CurrentParser != null) if (VisualPABCSingleton.MainForm.UserOptions.AllowCodeCompletion)
{ {
try try
{ {
@ -193,9 +189,8 @@ namespace VisualPascalABC
{ {
if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionDot) if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionDot)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false;
PascalABCCompiler.Parsers.KeywordKind keyw = KeywordChecker.TestForKeyword(editor.Document.TextContent, editor.ActiveTextAreaControl.TextArea.Caret.Offset - 1); PascalABCCompiler.Parsers.KeywordKind keyw = KeywordChecker.TestForKeyword(editor.Document.TextContent, editor.ActiveTextAreaControl.TextArea.Caret.Offset - 1);
if (CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.IsDefinitionIdentifierAfterKeyword(keyw)) if (CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsDefinitionIdentifierAfterKeyword(keyw))
return false; return false;
// если не первый символ выражения (предыдущий тоже буква или "_"), то не открываем новое окно // если не первый символ выражения (предыдущий тоже буква или "_"), то не открываем новое окно
@ -221,7 +216,6 @@ namespace VisualPascalABC
{ {
if (mainForm.UserOptions.AllowCodeFormatting) if (mainForm.UserOptions.AllowCodeFormatting)
{ {
if (CodeCompletion.CodeCompletionController.currentParser == null) return false;
string bracket = CodeCompletion.CodeCompletionController.currentParser.LanguageInformation.GetBodyStartBracket(); string bracket = CodeCompletion.CodeCompletionController.currentParser.LanguageInformation.GetBodyStartBracket();
string end_bracket = CodeCompletion.CodeCompletionController.currentParser.LanguageInformation.GetBodyEndBracket(); string end_bracket = CodeCompletion.CodeCompletionController.currentParser.LanguageInformation.GetBodyEndBracket();
if (bracket != null) if (bracket != null)

View file

@ -75,11 +75,7 @@ namespace VisualPascalABC
public void RegisterFileForParsing(string FileName) public void RegisterFileForParsing(string FileName)
{ {
if (Languages.Facade.LanguageProvider.Instance.HasLanguageForExtension(FileName)) filesToParse[FileName] = true;
{
filesToParse[FileName] = true;
CodeCompletion.CodeCompletionController.SetLanguage(FileName);
}
} }
public void CloseFile(string FileName) public void CloseFile(string FileName)

View file

@ -125,12 +125,12 @@ namespace VisualPascalABC
private string construct_header(string meth, CodeCompletion.ProcScope ps, int tabCount) private string construct_header(string meth, CodeCompletion.ProcScope ps, int tabCount)
{ {
//if (CodeCompletion.CodeCompletionController.currentParser != null) //if (CodeCompletion.CodeCompletionController.currentParser != null)
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.ConstructHeader(meth, ps, tabCount); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.ConstructHeader(meth, ps, tabCount);
} }
private string construct_header(CodeCompletion.ProcRealization ps, int tabCount) private string construct_header(CodeCompletion.ProcRealization ps, int tabCount)
{ {
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.ConstructHeader(ps, tabCount); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.ConstructHeader(ps, tabCount);
} }
public CodeCompletion.SymScope FindScopeByLocation(string fileName, int line, int col) public CodeCompletion.SymScope FindScopeByLocation(string fileName, int line, int col)
@ -294,8 +294,8 @@ namespace VisualPascalABC
public string FindExpression(int off, string Text, int line, int col) public string FindExpression(int off, string Text, int line, int col)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser != null) if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpression(off, Text, line, col, out keyword); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpression(off, Text, line, col, out keyword);
return null; return null;
} }
@ -324,14 +324,14 @@ namespace VisualPascalABC
try try
{ {
ILanguageInformation languageInformation = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation; ILanguage currentLanguage = CodeCompletion.CodeCompletionController.CurrentLanguage;
List<string> keywords; List<string> keywords;
bool isTypeAfterKeyword = false; bool isTypeAfterKeyword = false;
// если по смыслу должен вводиться тип данных // если по смыслу должен вводиться тип данных
if (languageInformation.IsTypeAfterKeyword(keyw)) if (currentLanguage.LanguageIntellisenseSupport.IsTypeAfterKeyword(keyw))
{ {
keywords = CodeCompletion.CodeCompletionNameHelper.Helper.GetTypeKeywords(); keywords = CodeCompletion.CodeCompletionNameHelper.Helper.GetTypeKeywords();
isTypeAfterKeyword = true; isTypeAfterKeyword = true;
@ -344,7 +344,7 @@ namespace VisualPascalABC
bool isNamespaceAfterKeyword = false; bool isNamespaceAfterKeyword = false;
// конструкция типа "uses" // конструкция типа "uses"
if (languageInformation.IsNamespaceAfterKeyword(keyw)) if (currentLanguage.LanguageIntellisenseSupport.IsNamespaceAfterKeyword(keyw))
{ {
isNamespaceAfterKeyword = true; isNamespaceAfterKeyword = true;
} }
@ -358,11 +358,9 @@ namespace VisualPascalABC
if (symInfos != null) if (symInfos != null)
{ {
bool languageCaseSensitive = LanguageProvider.Instance.SelectLanguageByExtension(FileName).CaseSensitive; currentLanguage.LanguageIntellisenseSupport.RenameOrExcludeSpecialNames(symInfos);
languageInformation.RenameOrExcludeSpecialNames(symInfos); AddCompletionDatasByFirstForSymInfos(resultList, charTyped, symInfos, currentLanguage.CaseSensitive);
AddCompletionDatasByFirstForSymInfos(resultList, charTyped, symInfos, languageCaseSensitive);
//resultList.Sort(); //resultList.Sort();
//defaultCompletionElement = resultList[0] as DefaultCompletionData; //defaultCompletionElement = resultList[0] as DefaultCompletionData;
@ -506,7 +504,7 @@ namespace VisualPascalABC
}; };
string expressionText = GetExpressionTextForCompletionData(off, text, line, col, string expressionText = GetExpressionTextForCompletionData(off, text, line, col,
currentLanguage.LanguageInformation, in context, out var insidePatternWithDots, out var ctrlOrShiftSpaceAfterDot, out var pattern); currentLanguage.LanguageIntellisenseSupport, in context, out var insidePatternWithDots, out var ctrlOrShiftSpaceAfterDot, out var pattern);
// добавляем ключевые слова в случае "ctrl + space", нажатых в "пустом" месте // добавляем ключевые слова в случае "ctrl + space", нажатых в "пустом" месте
if (!ctrlOrShiftSpaceAfterDot && context.ctrlSpace && string.IsNullOrEmpty(pattern)) if (!ctrlOrShiftSpaceAfterDot && context.ctrlSpace && string.IsNullOrEmpty(pattern))
@ -537,7 +535,7 @@ namespace VisualPascalABC
if (symInfos != null) if (symInfos != null)
{ {
currentLanguage.LanguageInformation.RenameOrExcludeSpecialNames(symInfos); currentLanguage.LanguageIntellisenseSupport.RenameOrExcludeSpecialNames(symInfos);
AddCompletionDatasForSymInfos(resultList, currentLanguage.CaseSensitive, symInfos, selectedSymInfo, lastUsedMember); AddCompletionDatasForSymInfos(resultList, currentLanguage.CaseSensitive, symInfos, selectedSymInfo, lastUsedMember);
} }
@ -689,7 +687,7 @@ namespace VisualPascalABC
/// <summary> /// <summary>
/// Получение текста выражения, введенного пользователем перед нажатием "триггерной" клавиши /// Получение текста выражения, введенного пользователем перед нажатием "триггерной" клавиши
/// </summary> /// </summary>
private string GetExpressionTextForCompletionData(int off, string text, int line, int col, ILanguageInformation languageInformation, in ActionContext context, out bool insidePatternWithDots, out bool ctrlOrShiftSpaceAfterDot, out string pattern) private string GetExpressionTextForCompletionData(int off, string text, int line, int col, ILanguageIntellisenseSupport languageIntellisenseSupport, in ActionContext context, out bool insidePatternWithDots, out bool ctrlOrShiftSpaceAfterDot, out string pattern)
{ {
string expressionText = null; string expressionText = null;
@ -700,7 +698,7 @@ namespace VisualPascalABC
if (context.ctrlSpace || context.shiftSpace) if (context.ctrlSpace || context.shiftSpace)
{ {
pattern = languageInformation.FindPattern(off, text, out var isPattern); pattern = languageIntellisenseSupport.FindPattern(off, text, out var isPattern);
// в конце выражения точка // в конце выражения точка
if (!isPattern && text[off - 1] == '.') if (!isPattern && text[off - 1] == '.')
@ -718,7 +716,7 @@ namespace VisualPascalABC
} }
else if (context.spaceAfterNew) else if (context.spaceAfterNew)
{ {
expressionText = languageInformation.SkipNew(off - 1, text, ref keyword); expressionText = languageIntellisenseSupport.SkipNew(off - 1, text, ref keyword);
} }
else if (context.dotPressed) // keywordKind != KeywordKind.Uses else if (context.dotPressed) // keywordKind != KeywordKind.Uses
{ {

View file

@ -3,13 +3,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.TextEditor; using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
namespace VisualPascalABC namespace VisualPascalABC
{ {
@ -19,11 +15,17 @@ namespace VisualPascalABC
public static void DefinitionByMouseClickManager_TextAreaMouseMove(object sender, MouseEventArgs e) public static void DefinitionByMouseClickManager_TextAreaMouseMove(object sender, MouseEventArgs e)
{ {
if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return;
makeWordUnderline(sender, e); makeWordUnderline(sender, e);
} }
public static void DefinitionByMouseClickManager_TextAreaMouseDown(object sender, EventArgs e) public static void DefinitionByMouseClickManager_TextAreaMouseDown(object sender, EventArgs e)
{ {
if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return;
TextArea textArea = (TextArea)sender; TextArea textArea = (TextArea)sender;
if (Control.ModifierKeys == Keys.Control && textArea.SelectionManager.SelectionCollection.Count == 0) if (Control.ModifierKeys == Keys.Control && textArea.SelectionManager.SelectionCollection.Count == 0)
{ {

View file

@ -31,8 +31,8 @@ namespace VisualPascalABC
private string FindExpression(int off, string Text, int line, int col) private string FindExpression(int off, string Text, int line, int col)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser != null) if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpressionForMethod(off, Text, line, col, pressed_key, ref num_param); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpressionForMethod(off, Text, line, col, pressed_key, ref num_param);
return null; return null;
} }
@ -42,7 +42,7 @@ namespace VisualPascalABC
{ {
if (setupOnlyOnce && this.textArea != null) if (setupOnlyOnce && this.textArea != null)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.IsMethodCallParameterSeparator(pressed_key)) if (CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsMethodCallParameterSeparator(pressed_key))
{ {
FindExpression(textArea.Caret.Offset, textArea.Document.TextContent.Substring(0, textArea.Caret.Offset), FindExpression(textArea.Caret.Offset, textArea.Document.TextContent.Substring(0, textArea.Caret.Offset),
textArea.Caret.Line, textArea.Caret.Column); textArea.Caret.Line, textArea.Caret.Column);
@ -71,9 +71,9 @@ namespace VisualPascalABC
if (dconv != null) if (dconv != null)
{ {
//if (pressed_key == '(' || pressed_key == ',') //if (pressed_key == '(' || pressed_key == ',')
if (CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.IsOpenBracketForMethodCall(pressed_key) || CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.IsMethodCallParameterSeparator(pressed_key)) if (CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsOpenBracketForMethodCall(pressed_key) || CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsMethodCallParameterSeparator(pressed_key))
methods = dconv.GetNameOfMethod(e, expr, line, col, num_param, ref defaultIndex, cur_param_num, out param_count); methods = dconv.GetNameOfMethod(e, expr, line, col, num_param, ref defaultIndex, cur_param_num, out param_count);
else if (CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.IsOpenBracketForIndex(pressed_key)) else if (CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsOpenBracketForIndex(pressed_key))
methods = dconv.GetIndex(e, line, col); methods = dconv.GetIndex(e, line, col);
} }
} }

View file

@ -8,7 +8,6 @@ using System.Windows.Forms;
using ICSharpCode.TextEditor; using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Gui.CompletionWindow; using ICSharpCode.TextEditor.Gui.CompletionWindow;
using PascalABCCompiler.Parsers;
namespace VisualPascalABC namespace VisualPascalABC
{ {
@ -29,9 +28,9 @@ namespace VisualPascalABC
//string expr = FindFullExpression(doc.TextContent, seg.Offset + logicPos.X,e.LogicalPosition.Line,e.LogicalPosition.Column); //string expr = FindFullExpression(doc.TextContent, seg.Offset + logicPos.X,e.LogicalPosition.Line,e.LogicalPosition.Column);
IParser parser = CodeCompletion.CodeCompletionController.CurrentParser; var currentLanguage = CodeCompletion.CodeCompletionController.CurrentLanguage;
string expr = parser.LanguageInformation.FindExpressionFromAnyPosition( string expr = currentLanguage.LanguageIntellisenseSupport.FindExpressionFromAnyPosition(
lineSegment.Offset + logicPos.X, doc.TextContent, e.LogicalPosition.Line, e.LogicalPosition.Column, out var keyw, out var exprWithoutBrackets); lineSegment.Offset + logicPos.X, doc.TextContent, e.LogicalPosition.Line, e.LogicalPosition.Column, out var keyw, out var exprWithoutBrackets);
// пока непонятно, когда такое может быть EVA // пока непонятно, когда такое может быть EVA
@ -44,25 +43,25 @@ namespace VisualPascalABC
List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>(); List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>();
List<PascalABCCompiler.Errors.CompilerWarning> Warnings = new List<PascalABCCompiler.Errors.CompilerWarning>(); List<PascalABCCompiler.Errors.CompilerWarning> Warnings = new List<PascalABCCompiler.Errors.CompilerWarning>();
PascalABCCompiler.SyntaxTree.expression expressionTree = parser.GetExpression("test" + Path.GetExtension(fileName), PascalABCCompiler.SyntaxTree.expression expressionTree = currentLanguage.Parser.GetExpression("test" + Path.GetExtension(fileName),
expr, Errors, Warnings); expr, Errors, Warnings);
// Пока добавили проверку, что анализируем Паскаль EVA // Пока добавили проверку, что анализируем Паскаль EVA
if (Errors.Count > 0 && parser == Languages.Facade.LanguageProvider.Instance.MainLanguage.Parser) if (Errors.Count > 0 && currentLanguage == Languages.Facade.LanguageProvider.Instance.MainLanguage)
{ {
string s = expr.TrimStart(); string s = expr.TrimStart();
if (s.Length > 0 && s[0] == '^') if (s.Length > 0 && s[0] == '^')
{ {
Errors.Clear(); Errors.Clear();
exprWithoutBrackets = exprWithoutBrackets.TrimStart().Substring(1); exprWithoutBrackets = exprWithoutBrackets.TrimStart().Substring(1);
expressionTree = parser.GetExpression("test" + Path.GetExtension(fileName), s.Substring(1), Errors, Warnings); expressionTree = currentLanguage.Parser.GetExpression("test" + Path.GetExtension(fileName), s.Substring(1), Errors, Warnings);
} }
} }
List<PascalABCCompiler.Errors.Error> Errors2 = new List<PascalABCCompiler.Errors.Error>(); List<PascalABCCompiler.Errors.Error> Errors2 = new List<PascalABCCompiler.Errors.Error>();
// проверка для выражения без скобок // проверка для выражения без скобок
PascalABCCompiler.SyntaxTree.expression expressionTree2 = parser.GetExpression("test" + Path.GetExtension(fileName), exprWithoutBrackets, Errors2, Warnings); PascalABCCompiler.SyntaxTree.expression expressionTree2 = currentLanguage.Parser.GetExpression("test" + Path.GetExtension(fileName), exprWithoutBrackets, Errors2, Warnings);
// если не получается, то сразу возврат // если не получается, то сразу возврат
if (expressionTree2 == null || Errors2.Count > 0) if (expressionTree2 == null || Errors2.Count > 0)
@ -118,7 +117,7 @@ namespace VisualPascalABC
{ {
if (!VisualPABCSingleton.MainForm.UserOptions.CodeCompletionHint) if (!VisualPABCSingleton.MainForm.UserOptions.CodeCompletionHint)
return; return;
if (CodeCompletion.CodeCompletionController.CurrentParser == null) if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return; return;
try try
{ {

View file

@ -304,7 +304,7 @@ namespace VisualPascalABC
public bool IsRunning = false; public bool IsRunning = false;
public string ExeFileName; public string ExeFileName;
public bool ShowDebugTabs=true; public bool ShowDebugTabs=true;
public PascalABCCompiler.Parsers.IParser parser = null; public Languages.Facade.ILanguage language = null;
EventHandler<EventArgs> debuggerStateEvent; EventHandler<EventArgs> debuggerStateEvent;
public DebugHelper() public DebugHelper()
@ -465,7 +465,7 @@ namespace VisualPascalABC
this.FullFileName = Path.Combine(Path.GetDirectoryName(fileName), this.FileName); this.FullFileName = Path.Combine(Path.GetDirectoryName(fileName), this.FileName);
this.ExeFileName = fileName; this.ExeFileName = fileName;
CurrentLine = 0; CurrentLine = 0;
this.parser = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtensionSafe(FullFileName)?.Parser; this.language = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtension(FullFileName);
this.PrevFullFileName = FullFileName; this.PrevFullFileName = FullFileName;
AssemblyHelper.LoadAssembly(fileName); AssemblyHelper.LoadAssembly(fileName);
dbg.ProcessStarted += debugProcessStarted; dbg.ProcessStarted += debugProcessStarted;
@ -534,7 +534,7 @@ namespace VisualPascalABC
//ChangeLocalVars(e.Process); //ChangeLocalVars(e.Process);
//if (e.Process.IsPaused) //if (e.Process.IsPaused)
WorkbenchServiceFactory.DebuggerOperationsService.RefreshPad(new FunctionItem(e.Process.SelectedFunction).SubItems); WorkbenchServiceFactory.DebuggerOperationsService.RefreshPad(new FunctionItem(e.Process.SelectedFunction).SubItems);
workbench.WidgetController.SetStartDebugEnabled(); workbench.WidgetController.SetStartDebugAndRunEnabled();
if (currentFunction != e.Process.SelectedFunction) if (currentFunction != e.Process.SelectedFunction)
{ {
if (WorkbenchServiceFactory.Workbench.DisassemblyWindow.IsVisible) if (WorkbenchServiceFactory.Workbench.DisassemblyWindow.IsVisible)
@ -601,7 +601,7 @@ namespace VisualPascalABC
private void debuggedProcess_Expired(object sender, EventArgs e) private void debuggedProcess_Expired(object sender, EventArgs e)
{ {
workbench.WidgetController.SetStartDebugEnabled(); workbench.WidgetController.SetStartDebugAndRunEnabled();
} }
private void debuggedProcess_ExceptionThrown(object sender, ExceptionEventArgs e) private void debuggedProcess_ExceptionThrown(object sender, ExceptionEventArgs e)
@ -666,7 +666,7 @@ namespace VisualPascalABC
workbench.ServiceContainer.EditorService.SetEditorDisabled(false); workbench.ServiceContainer.EditorService.SetEditorDisabled(false);
//RemoveMarker(frm.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Document); //RemoveMarker(frm.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Document);
evaluator = null; evaluator = null;
parser= null; language= null;
FileName = null; FileName = null;
handle = 0; handle = 0;
ExeFileName = null; ExeFileName = null;
@ -694,7 +694,7 @@ namespace VisualPascalABC
workbench.WidgetController.SetDebugTabsVisible(true); workbench.WidgetController.SetDebugTabsVisible(true);
workbench.WidgetController.SetPlayButtonsVisible(true); workbench.WidgetController.SetPlayButtonsVisible(true);
workbench.WidgetController.SetDebugStopEnabled();//e.Process.LogMessage += messageEventProc; workbench.WidgetController.SetDebugStopEnabled();//e.Process.LogMessage += messageEventProc;
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
workbench.WidgetController.ChangeStartDebugNameOnContinue(); workbench.WidgetController.ChangeStartDebugNameOnContinue();
workbench.WidgetController.EnableCodeCompletionToolTips(false); workbench.WidgetController.EnableCodeCompletionToolTips(false);
workbench.WidgetController.SetAddExprMenuVisible(true); workbench.WidgetController.SetAddExprMenuVisible(true);
@ -1239,7 +1239,7 @@ namespace VisualPascalABC
{ {
sb.Insert(0, '.'); sb.Insert(0, '.');
PascalABCCompiler.Parsers.KeywordKind keyw = PascalABCCompiler.Parsers.KeywordKind.None; PascalABCCompiler.Parsers.KeywordKind keyw = PascalABCCompiler.Parsers.KeywordKind.None;
string s = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation. string s = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.
FindExpression(i, text, 0, 0, out keyw); FindExpression(i, text, 0, 0, out keyw);
if (s != null) if (s != null)
{ {
@ -1598,7 +1598,7 @@ namespace VisualPascalABC
{ {
try try
{ {
workbench.WidgetController.SetStartDebugEnabled(); workbench.WidgetController.SetStartDebugAndRunEnabled();
dbg.Processes[0].Terminate(); dbg.Processes[0].Terminate();
} }
catch (System.Exception e) catch (System.Exception e)
@ -1614,7 +1614,7 @@ namespace VisualPascalABC
{ {
try try
{ {
workbench.WidgetController.SetStartDebugEnabled(); workbench.WidgetController.SetStartDebugAndRunEnabled();
dbg.Processes[0].Break(); dbg.Processes[0].Break();
} }
catch (System.Exception e) catch (System.Exception e)
@ -1680,7 +1680,7 @@ namespace VisualPascalABC
{ {
try try
{ {
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
if (debuggedProcess.SelectedFunction.Name == ".cctor") if (debuggedProcess.SelectedFunction.Name == ".cctor")
{ {
var sequencePoints = debuggedProcess.SelectedFunction.symMethod.SequencePoints; var sequencePoints = debuggedProcess.SelectedFunction.symMethod.SequencePoints;
@ -1708,7 +1708,7 @@ namespace VisualPascalABC
{ {
try try
{ {
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
dbg.Processes[0].Continue(); dbg.Processes[0].Continue();
CurrentLineBookmark.Remove(); CurrentLineBookmark.Remove();
} }
@ -1725,7 +1725,7 @@ namespace VisualPascalABC
{ {
try try
{ {
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
stepin_stmt = dbg.Processes[0].NextStatement; stepin_stmt = dbg.Processes[0].NextStatement;
dbg.Processes[0].StepInto(); dbg.Processes[0].StepInto();
CurrentLineBookmark.Remove(); CurrentLineBookmark.Remove();
@ -1745,7 +1745,7 @@ namespace VisualPascalABC
{ {
if (IsRunning) if (IsRunning)
{ {
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
dbg.Processes[0].StepOut(); dbg.Processes[0].StepOut();
CurrentLineBookmark.Remove(); CurrentLineBookmark.Remove();
} }
@ -1765,7 +1765,7 @@ namespace VisualPascalABC
{ {
//cur_brpt = dbg.AddBreakpoint(new SourcecodeSegment((frm.CurrentTabPage.ag as CodeFileDocumentControl).file_name,(frm.CurrentTabPage.ag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Line + 1,(frm.CurrentTabPage.Tag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Column + 1, //cur_brpt = dbg.AddBreakpoint(new SourcecodeSegment((frm.CurrentTabPage.ag as CodeFileDocumentControl).file_name,(frm.CurrentTabPage.ag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Line + 1,(frm.CurrentTabPage.Tag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Column + 1,
// (frm.CurrentTabPage.ag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Column+100), true); // (frm.CurrentTabPage.ag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Column+100), true);
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
currentBreakpoint = dbg.AddBreakpoint(WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.FileName, WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line + 1); currentBreakpoint = dbg.AddBreakpoint(WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.FileName, WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line + 1);
AddGoToBreakPoint(currentBreakpoint); AddGoToBreakPoint(currentBreakpoint);
Status = DebugStatus.None; Status = DebugStatus.None;

View file

@ -717,8 +717,8 @@ namespace VisualPascalABC
} }
else else
if (val.IsNull) if (val.IsNull)
if (WorkbenchServiceFactory.DebuggerManager.parser != null) if (WorkbenchServiceFactory.DebuggerManager.language != null)
return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetKeyword(PascalABCCompiler.Parsers.SymbolKind.Null); return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetKeyword(PascalABCCompiler.Parsers.SymbolKind.Null);
else else
return "nil"; return "nil";
else else

View file

@ -122,8 +122,8 @@ namespace VisualPascalABC
public static string WrapTypeName(DebugType type) public static string WrapTypeName(DebugType type)
{ {
if (type.IsArray) if (type.IsArray)
if (WorkbenchServiceFactory.DebuggerManager.parser != null) if (WorkbenchServiceFactory.DebuggerManager.language != null)
return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetArrayDescription(WrapTypeName(type.GetElementType()), type.GetArrayRank()); return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetArrayDescription(WrapTypeName(type.GetElementType()), type.GetArrayRank());
else else
return "array of " + WrapTypeName(type.GetElementType()); return "array of " + WrapTypeName(type.GetElementType());
return internalWrapTypeName(type.FullName); return internalWrapTypeName(type.FullName);
@ -182,23 +182,23 @@ namespace VisualPascalABC
private static string internalWrapTypeName(string name) private static string internalWrapTypeName(string name)
{ {
if (WorkbenchServiceFactory.DebuggerManager.parser != null) if (WorkbenchServiceFactory.DebuggerManager.language != null)
switch (name) switch (name)
{ {
case "System.Boolean": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(bool)); case "System.Boolean": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(bool));
case "System.Int32": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(int)); case "System.Int32": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(int));
case "System.Byte": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(byte)); case "System.Byte": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(byte));
case "System.Double": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(double)); case "System.Double": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(double));
case "System.String": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(string)); case "System.String": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(string));
case "System.Char": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(char)); case "System.Char": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(char));
case "System.SByte": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(sbyte)); case "System.SByte": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(sbyte));
case "System.Int16": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(short)); case "System.Int16": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(short));
case "System.UInt16": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(ushort)); case "System.UInt16": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(ushort));
case "System.UInt32": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(uint)); case "System.UInt32": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(uint));
case "System.Int64": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(long)); case "System.Int64": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(long));
case "System.UInt64": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(ulong)); case "System.UInt64": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(ulong));
case "System.Float32": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(float)); case "System.Float32": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(float));
case "System.IntPtr": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(Type.GetType("System.Void*")); case "System.IntPtr": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(Type.GetType("System.Void*"));
default: return name; default: return name;
} }
else else

View file

@ -464,7 +464,7 @@ namespace VisualPascalABC
void tsIntellisense_DropDownOpened(object sender, EventArgs e) void tsIntellisense_DropDownOpened(object sender, EventArgs e)
{ {
if (UserOptions.AllowCodeCompletion) if (UserOptions.AllowCodeCompletion && CodeCompletion.CodeCompletionController.IntellisenseAvailable())
{ {
//GotoAction ga = new GotoAction(); //GotoAction ga = new GotoAction();
TextArea ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea; TextArea ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea;
@ -474,18 +474,47 @@ namespace VisualPascalABC
//this.cmFindAllReferences.Enabled = ga.CanFindReferences(ta); //this.cmFindAllReferences.Enabled = ga.CanFindReferences(ta);
this.miGenerateRealization.Enabled = CodeCompletionActionsManager.CanGenerateRealization(ta); this.miGenerateRealization.Enabled = CodeCompletionActionsManager.CanGenerateRealization(ta);
} }
else
{
DisableIntellisenseDropDownOptions();
}
} }
private void OpeningContextMenu(object sender, CancelEventArgs args) private void OpeningContextMenu(object sender, CancelEventArgs args)
{ {
GotoAction ga = new GotoAction(); if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
TextArea ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea; {
this.cmGotoDefinition.Enabled = CodeCompletionActionsManager.CanGoTo(ta); // GotoAction ga = new GotoAction();
this.cmGotoRealization.Enabled = CodeCompletionActionsManager.CanGoToRealization(ta); TextArea ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea;
this.cmFindAllReferences.Enabled = CodeCompletionActionsManager.CanFindReferences(ta);
this.cmGenerateRealization.Enabled = CodeCompletionActionsManager.CanGenerateRealization(ta); this.cmGotoDefinition.Enabled = CodeCompletionActionsManager.CanGoTo(ta);
this.cmRename.Enabled = CodeCompletionActionsManager.CanGoTo(ta); this.cmGotoRealization.Enabled = CodeCompletionActionsManager.CanGoToRealization(ta);
} this.cmFindAllReferences.Enabled = CodeCompletionActionsManager.CanFindReferences(ta);
this.cmGenerateRealization.Enabled = CodeCompletionActionsManager.CanGenerateRealization(ta);
this.cmRename.Enabled = CodeCompletionActionsManager.CanGoTo(ta);
}
else
{
DisableIntellisenseContextMenuOptions();
}
}
private void DisableIntellisenseContextMenuOptions()
{
this.cmGotoDefinition.Enabled = false;
this.cmGotoRealization.Enabled = false;
this.cmFindAllReferences.Enabled = false;
this.cmGenerateRealization.Enabled = false;
this.cmRename.Enabled = false;
}
private void DisableIntellisenseDropDownOptions()
{
this.tsGotoDefinition.Enabled = false;
this.tsGotoRealization.Enabled = false;
this.tsFindAllReferences.Enabled = false;
this.miGenerateRealization.Enabled = false;
}
private void ClosingContextMenu(object sender, CancelEventArgs args) private void ClosingContextMenu(object sender, CancelEventArgs args)
{ {

View file

@ -114,11 +114,11 @@ namespace VisualPascalABC
string full_file_name = Path.Combine(Path.GetDirectoryName(ProjectFactory.Instance.CurrentProject.Path),frm.FileName); string full_file_name = Path.Combine(Path.GetDirectoryName(ProjectFactory.Instance.CurrentProject.Path),frm.FileName);
StreamWriter sw = File.CreateText(full_file_name); StreamWriter sw = File.CreateText(full_file_name);
ILanguageInformation languageInfo = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtension(frm.FileName).LanguageInformation; var languageIntellisenseSupport = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtension(frm.FileName).LanguageIntellisenseSupport;
if (frm.GetFileFilter() == FileType.Unit) if (frm.GetFileFilter() == FileType.Unit)
{ {
sw.Write(languageInfo.GetUnitTemplate(Path.GetFileNameWithoutExtension(frm.FileName))); sw.Write(languageIntellisenseSupport.GetUnitTemplate(Path.GetFileNameWithoutExtension(frm.FileName)));
} }
else else
{ {

View file

@ -55,7 +55,7 @@ namespace VisualPascalABC
public string Compile(PascalABCCompiler.IProjectInfo project, bool rebuild, string RuntimeServicesModule, bool ForRun, bool RunWithEnvironment) public string Compile(PascalABCCompiler.IProjectInfo project, bool rebuild, string RuntimeServicesModule, bool ForRun, bool RunWithEnvironment)
{ {
ProjectService.SaveProject(); ProjectService.SaveProject();
Workbench.WidgetController.CompilingButtonsEnabled = false; Workbench.WidgetController.CompilingAndRunButtonsEnabled = false;
Workbench.CompilerConsoleWindow.ClearConsole(); Workbench.CompilerConsoleWindow.ClearConsole();
CompilerOptions1.SourceFileName = project.Path; CompilerOptions1.SourceFileName = project.Path;
CompilerOptions1.OutputDirectory = project.OutputDirectory; CompilerOptions1.OutputDirectory = project.OutputDirectory;
@ -98,7 +98,7 @@ namespace VisualPascalABC
public string Compile(string FileName, bool rebuild, string RuntimeServicesModule, bool ForRun, bool RunWithEnvironment) public string Compile(string FileName, bool rebuild, string RuntimeServicesModule, bool ForRun, bool RunWithEnvironment)
{ {
Workbench.WidgetController.CompilingButtonsEnabled = false; Workbench.WidgetController.CompilingAndRunButtonsEnabled = false;
var UserOptions = Workbench.UserOptions; var UserOptions = Workbench.UserOptions;

View file

@ -87,7 +87,8 @@ namespace VisualPascalABC
} }
//CloseButtonsEnabled = OpenDocuments.Count > 1; //CloseButtonsEnabled = OpenDocuments.Count > 1;
ChangedSelectedTab(); ChangedSelectedTab();
if (FileName != null) // SS 09.08.08 if (FileName != null // SS 09.08.08
&& CodeCompletion.CodeCompletionController.IntellisenseAvailable())
WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(FileName); WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(FileName);
} }

View file

@ -95,7 +95,7 @@ namespace VisualPascalABC
case "string": case "string":
return false; return false;
} }
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
List<Position> poses = CodeCompletionActionsManager.GetDefinitionPosition(CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea, true); List<Position> poses = CodeCompletionActionsManager.GetDefinitionPosition(CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea, true);
if (poses == null || poses.Count == 0) return false; if (poses == null || poses.Count == 0) return false;
foreach (Position pos in poses) foreach (Position pos in poses)

View file

@ -119,7 +119,7 @@ namespace VisualPascalABC
if (ProjectFactory.Instance.ProjectLoaded) if (ProjectFactory.Instance.ProjectLoaded)
tabPage = DocumentService.GetTabPageForMainFile(); tabPage = DocumentService.GetTabPageForMainFile();
if (attachdbg && !Workbench.UserOptions.AlwaysAttachDebuggerAtStart) if (attachdbg && !Workbench.UserOptions.AlwaysAttachDebuggerAtStart)
fictive_attach = !startWithGoto && !needFirstBreakpoint && !DebuggerManager.HasBreakpoints(); fictive_attach = !startWithGoto && !needFirstBreakpoint && !DebuggerManager.HasBreakpoints() || !CodeCompletion.CodeCompletionController.IntellisenseAvailable();
WorkbenchServiceFactory.OperationsService.ClearOutputTextBoxForTabPage(tabPage); WorkbenchServiceFactory.OperationsService.ClearOutputTextBoxForTabPage(tabPage);
Workbench.ErrorsListWindow.ClearErrorList(); Workbench.ErrorsListWindow.ClearErrorList();
DesignerService.GenerateAllDesignersCode(); DesignerService.GenerateAllDesignersCode();

View file

@ -27,7 +27,7 @@ namespace VisualPascalABC
void ButtonsEnableDisable_RunStart() void ButtonsEnableDisable_RunStart()
{ {
Workbench.WidgetController.SetStopEnabled(true); Workbench.WidgetController.SetStopEnabled(true);
Workbench.WidgetController.SetCompilingButtonsEnabled(false); Workbench.WidgetController.SetCompilingAndRunButtonsEnabled(false);
Workbench.WidgetController.SetDebugButtonsEnabled(false); Workbench.WidgetController.SetDebugButtonsEnabled(false);
Workbench.WidgetController.SetOptionsEnabled(false); Workbench.WidgetController.SetOptionsEnabled(false);
} }
@ -35,8 +35,9 @@ namespace VisualPascalABC
void ButtonsEnableDisable_RunStop() void ButtonsEnableDisable_RunStop()
{ {
Workbench.WidgetController.SetStopEnabled(false); Workbench.WidgetController.SetStopEnabled(false);
Workbench.WidgetController.SetCompilingButtonsEnabled(true); Workbench.WidgetController.SetCompilingAndRunButtonsEnabled(true);
Workbench.WidgetController.SetDebugButtonsEnabled(true); if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
Workbench.WidgetController.SetDebugButtonsEnabled(true);
Workbench.WidgetController.SetOptionsEnabled(true); Workbench.WidgetController.SetOptionsEnabled(true);
} }

View file

@ -22,10 +22,10 @@ namespace VisualPascalABC
internal List<DockContent> BottomDockContent = new List<DockContent>(); internal List<DockContent> BottomDockContent = new List<DockContent>();
List<DockContent> VisibleBottomContent = new List<DockContent>(); List<DockContent> VisibleBottomContent = new List<DockContent>();
public bool CompilingButtonsEnabled public bool CompilingAndRunButtonsEnabled
{ {
get { return miRun.Enabled; } get { return miRun.Enabled; }
set { SetCompilingButtonsEnabled(value); } set { SetCompilingAndRunButtonsEnabled(value); }
} }
bool SaveButtonsEnabled bool SaveButtonsEnabled
@ -100,16 +100,17 @@ namespace VisualPascalABC
set { miNavigForw.Enabled = tsNavigForw.Enabled = value; } set { miNavigForw.Enabled = tsNavigForw.Enabled = value; }
} }
public void SetDedugButtonsEnabled(bool Enabled) /// <summary>
/// Активировать/Деактивировать все кнопки, относящиеся к дебагу.
/// </summary>
public void SetDebugButtonsEnabled(bool Enabled)
{ {
StepIntoButton.Enabled = StepOverButton.Enabled = StartDebugButton.Enabled = StepIntoButton.Enabled = StepOverButton.Enabled = StartDebugButton.Enabled =
mDEBUGSTARTToolStripMenuItem.Enabled = mSTEPOVERToolStripMenuItem.Enabled = mSTEPINToolStripMenuItem.Enabled = mRUNTOCURToolStripMenuItem.Enabled = Enabled; mDEBUGSTARTToolStripMenuItem.Enabled = mSTEPOVERToolStripMenuItem.Enabled =
mSTEPINToolStripMenuItem.Enabled = mRUNTOCURToolStripMenuItem.Enabled = Enabled;
//toolStrip1.Refresh(); //toolStrip1.Refresh();
} }
bool BottomDockContentVisible bool BottomDockContentVisible
{ {
get get
@ -317,7 +318,7 @@ namespace VisualPascalABC
} }
} }
public void SetCompilingButtonsEnabled(bool Enabled) public void SetCompilingAndRunButtonsEnabled(bool Enabled)
{ {
if (Enabled) if (Enabled)
{ {
@ -388,7 +389,7 @@ namespace VisualPascalABC
public void SetDebugStopEnabled() public void SetDebugStopEnabled()
{ {
SetCompilingButtonsEnabled(false); SetCompilingAndRunButtonsEnabled(false);
this.mDEBUGSTOPToolStripMenuItem.Enabled = true; this.mDEBUGSTOPToolStripMenuItem.Enabled = true;
this.mDEBUGENDToolStripMenuItem.Enabled = true; this.mDEBUGENDToolStripMenuItem.Enabled = true;
this.mSTEPToolStripMenuItem.Enabled = true; this.mSTEPToolStripMenuItem.Enabled = true;
@ -412,7 +413,7 @@ namespace VisualPascalABC
this.mDEBUGSTARTToolStripMenuItem.Text = Form1StringResources.Get("M_DEBUGSTART"); this.mDEBUGSTARTToolStripMenuItem.Text = Form1StringResources.Get("M_DEBUGSTART");
} }
public void SetStartDebugDisabled() public void SetStartDebugAndRunDisabled()
{ {
this.mDEBUGSTARTToolStripMenuItem.Enabled = false; this.mDEBUGSTARTToolStripMenuItem.Enabled = false;
this.StartDebugButton.Enabled = false; this.StartDebugButton.Enabled = false;
@ -429,7 +430,10 @@ namespace VisualPascalABC
SaveDebugContext(); SaveDebugContext();
} }
public void SetStartDebugEnabled() /// <summary>
/// Активирует кнопки для Debug и запуска программы
/// </summary>
public void SetStartDebugAndRunEnabled()
{ {
this.mDEBUGSTARTToolStripMenuItem.Enabled = true; this.mDEBUGSTARTToolStripMenuItem.Enabled = true;
this.StartDebugButton.Enabled = true; this.StartDebugButton.Enabled = true;
@ -439,6 +443,7 @@ namespace VisualPascalABC
this.StepOverButton.Enabled = true; this.StepOverButton.Enabled = true;
this.mRUNTOCURToolStripMenuItem.Enabled = true; this.mRUNTOCURToolStripMenuItem.Enabled = true;
this.mSTEPToolStripMenuItem.Enabled = true; this.mSTEPToolStripMenuItem.Enabled = true;
this.miRun.Enabled = true; this.miRun.Enabled = true;
this.StartButton.Enabled = true; this.StartButton.Enabled = true;
ChangeDebugButtons(false); ChangeDebugButtons(false);
@ -453,7 +458,7 @@ namespace VisualPascalABC
this.StepOutButton.Enabled = false; this.StepOutButton.Enabled = false;
if (!(clicked_stop_debug_in_menu && WorkbenchServiceFactory.RunService.IsRun() && debuggedPage != ActiveCodeFileDocument)) if (!(clicked_stop_debug_in_menu && WorkbenchServiceFactory.RunService.IsRun() && debuggedPage != ActiveCodeFileDocument))
{ {
SetCompilingButtonsEnabled(true); SetCompilingAndRunButtonsEnabled(true);
this.stopButton.Enabled = false; this.stopButton.Enabled = false;
this.miStop.Enabled = false; this.miStop.Enabled = false;
} }
@ -510,42 +515,17 @@ namespace VisualPascalABC
} }
} }
public void SetDebugButtonsEnabled(bool val) /// <summary>
/// Активировать/Деактивировать все кнопки, относящиеся к форматированию кода
/// </summary>
private void SetFormatButtonsEnabled(bool enabled)
{ {
if (val) tsFormat.Enabled = mFORMATToolStripMenuItem.Enabled = cmFormat.Enabled = enabled;
{ }
this.mDEBUGSTOPToolStripMenuItem.Enabled = false;
this.mDEBUGSTARTToolStripMenuItem.Enabled = false; private void SetRunButtonsEnabled(bool enabled)
this.StartDebugButton.Enabled = true; {
this.StopDebugButton.Enabled = true; miRun.Enabled = StartButton.Enabled = enabled;
this.StepOutButton.Enabled = false;
this.StepOverButton.Enabled = true;
this.StepIntoButton.Enabled = true;
this.mDEBUGSTARTToolStripMenuItem.Enabled = true;
this.mSTEPINToolStripMenuItem.Enabled = true;
this.mSTEPOVERToolStripMenuItem.Enabled = true;
this.mSTEPToolStripMenuItem.Enabled = false;
this.mRUNTOCURToolStripMenuItem.Enabled = true;
this.miRun.Enabled = true;
this.StartButton.Enabled = true;
}
else
{
this.mDEBUGSTOPToolStripMenuItem.Enabled = false;
this.mSTEPToolStripMenuItem.Enabled = false;
this.StartDebugButton.Enabled = false;
this.StopDebugButton.Enabled = false;
this.StepOutButton.Enabled = false;
this.StepOverButton.Enabled = false;
this.StepIntoButton.Enabled = false;
this.mDEBUGSTARTToolStripMenuItem.Enabled = false;
this.mSTEPINToolStripMenuItem.Enabled = false;
this.mSTEPOVERToolStripMenuItem.Enabled = false;
this.mRUNTOCURToolStripMenuItem.Enabled = false;
this.mSTEPToolStripMenuItem.Enabled = false;
this.miRun.Enabled = false;
this.StartButton.Enabled = false;
}
} }
bool mDEBUGSTOPToolStripMenuItem_Enabled; bool mDEBUGSTOPToolStripMenuItem_Enabled;

View file

@ -398,8 +398,19 @@ namespace VisualPascalABC
CurrentWebBrowserControl = null; CurrentWebBrowserControl = null;
SetFocusToEditor(); SetFocusToEditor();
} }
CodeCompletion.CodeCompletionController.SetLanguage(CurrentCodeFileDocument.FileName);
bool intellisenseAvailable = CodeCompletion.CodeCompletionController.IntellisenseAvailable();
SetFormatButtonsEnabled(intellisenseAvailable);
if (!intellisenseAvailable)
SetDebugButtonsEnabled(false); // активация кнопок произойдет ниже, если возможно
if (BakSelectedTab == CurrentCodeFileDocument) if (BakSelectedTab == CurrentCodeFileDocument)
return; return;
LastSelectedTab = BakSelectedTab; LastSelectedTab = BakSelectedTab;
BakSelectedTab = CurrentCodeFileDocument; BakSelectedTab = CurrentCodeFileDocument;
@ -420,8 +431,6 @@ namespace VisualPascalABC
OutputWindow.outputTextBox = OutputTextBoxs[CurrentCodeFileDocument]; OutputWindow.outputTextBox = OutputTextBoxs[CurrentCodeFileDocument];
} }
CodeCompletion.CodeCompletionController.SetLanguage(CurrentCodeFileDocument.FileName);
SetFocusToEditor(); SetFocusToEditor();
bool run = WorkbenchServiceFactory.RunService.IsRun(CurrentEXEFileName); bool run = WorkbenchServiceFactory.RunService.IsRun(CurrentEXEFileName);
WorkbenchServiceFactory.DebuggerManager.SetAsPossibleDebugPage(CurrentCodeFileDocument); WorkbenchServiceFactory.DebuggerManager.SetAsPossibleDebugPage(CurrentCodeFileDocument);
@ -435,16 +444,16 @@ namespace VisualPascalABC
if (VisualEnvironmentCompiler != null) if (VisualEnvironmentCompiler != null)
if (!debug) if (!debug)
{ {
SetCompilingButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded); SetCompilingAndRunButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded);
SetDebugButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded); SetDebugButtonsEnabled(intellisenseAvailable && !run && VisualEnvironmentCompiler.compilerLoaded);
} }
else else
{ {
SetCompilingButtonsEnabled(!debug); SetCompilingAndRunButtonsEnabled(!debug);
SetDebugButtonsAsByDebug(); SetDebugButtonsAsByDebug();
} }
else else
SetCompilingButtonsEnabled(false); SetCompilingAndRunButtonsEnabled(false);
SaveButtonsEnabled = CurrentCodeFileDocument.DocumentChanged; SaveButtonsEnabled = CurrentCodeFileDocument.DocumentChanged;
UpdateUndoRedoEnabled(); UpdateUndoRedoEnabled();
UpdateCutCopyButtonsEnabled(); UpdateCutCopyButtonsEnabled();

View file

@ -66,11 +66,11 @@ namespace ICSharpCode.TextEditor.Util
if (param_num == -1) if (param_num == -1)
return; return;
var languageInfo = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation; var languageIntellisenseSupport = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport;
int startIndex = basicDescription.IndexOf("(", basicDescription.IndexOf("(" + PascalABCCompiler.StringResources.Get("CODE_COMPLETION_EXTENSION")) + 1) + 1; int startIndex = basicDescription.IndexOf("(", basicDescription.IndexOf("(" + PascalABCCompiler.StringResources.Get("CODE_COMPLETION_EXTENSION")) + 1) + 1;
int paranthesisIndex = languageInfo.FindClosingParenthesis(basicDescription.Substring(startIndex), ')'); int paranthesisIndex = languageIntellisenseSupport.FindClosingParenthesis(basicDescription.Substring(startIndex), ')');
if (paranthesisIndex == -1) if (paranthesisIndex == -1)
return; return;
@ -83,7 +83,7 @@ namespace ICSharpCode.TextEditor.Util
if (bold_beg != 0) if (bold_beg != 0)
{ {
int paramDelimIndex = languageInfo.FindParamDelim(basicDescription.Substring(bold_beg), 1); int paramDelimIndex = languageIntellisenseSupport.FindParamDelim(basicDescription.Substring(bold_beg), 1);
if (paramDelimIndex == -1) if (paramDelimIndex == -1)
{ {
@ -104,7 +104,7 @@ namespace ICSharpCode.TextEditor.Util
{ {
string paramDescription = basicDescription.Substring(startIndex, paranthesisIndex); string paramDescription = basicDescription.Substring(startIndex, paranthesisIndex);
if (languageInfo.IsParams(paramDescription)) if (languageIntellisenseSupport.IsParams(paramDescription))
{ {
bold_beg = startIndex; bold_beg = startIndex;
bold_len = paranthesisIndex; bold_len = paranthesisIndex;
@ -114,15 +114,15 @@ namespace ICSharpCode.TextEditor.Util
{ {
string descriptionAfterBracket = basicDescription.Substring(startIndex); string descriptionAfterBracket = basicDescription.Substring(startIndex);
int paramDelimIndex = languageInfo.FindParamDelim(descriptionAfterBracket, paramsCount - 1); int paramDelimIndex = languageIntellisenseSupport.FindParamDelim(descriptionAfterBracket, paramsCount - 1);
if (paramDelimIndex != -1) if (paramDelimIndex != -1)
{ {
int paramDelimLength = languageInfo.ParameterDelimiter.Length; int paramDelimLength = languageIntellisenseSupport.ParameterDelimiter.Length;
string paramDescription = descriptionAfterBracket.Substring(paramDelimIndex + paramDelimLength, paranthesisIndex - paramDelimIndex - paramDelimLength); string paramDescription = descriptionAfterBracket.Substring(paramDelimIndex + paramDelimLength, paranthesisIndex - paramDelimIndex - paramDelimLength);
if (languageInfo.IsParams(paramDescription)) if (languageIntellisenseSupport.IsParams(paramDescription))
{ {
bold_beg = paramDelimIndex + startIndex + paramDelimLength; bold_beg = paramDelimIndex + startIndex + paramDelimLength;
bold_len = end_sk - bold_beg; bold_len = end_sk - bold_beg;
@ -132,12 +132,12 @@ namespace ICSharpCode.TextEditor.Util
} }
else else
{ {
int paramDelimIndex = languageInfo.FindParamDelim(basicDescription.Substring(startIndex), param_num - 1); int paramDelimIndex = languageIntellisenseSupport.FindParamDelim(basicDescription.Substring(startIndex), param_num - 1);
if (paramDelimIndex != -1) if (paramDelimIndex != -1)
{ {
bold_beg = paramDelimIndex + startIndex + languageInfo.ParameterDelimiter.Length; bold_beg = paramDelimIndex + startIndex + languageIntellisenseSupport.ParameterDelimiter.Length;
int secondParamDelimIndex = languageInfo.FindParamDelim(basicDescription.Substring(startIndex), param_num); int secondParamDelimIndex = languageIntellisenseSupport.FindParamDelim(basicDescription.Substring(startIndex), param_num);
if (secondParamDelimIndex == -1) if (secondParamDelimIndex == -1)
{ {

View file

@ -34,7 +34,7 @@ namespace VisualPascalABC
private System.Threading.Thread MainProgramThread = System.Threading.Thread.CurrentThread; private System.Threading.Thread MainProgramThread = System.Threading.Thread.CurrentThread;
private System.Threading.Thread StartingThread; private System.Threading.Thread StartingThread;
public delegate void SetFlagDelegate(bool flag); public delegate void SetFlagDelegate(bool flag);
private SetFlagDelegate SetCompilingButtonsEnabled; private SetFlagDelegate SetCompilingAndRunButtonsEnabled;
private SetFlagDelegate SetDebugButtonsEnabled; private SetFlagDelegate SetDebugButtonsEnabled;
public delegate void SetTextDelegate(string text); public delegate void SetTextDelegate(string text);
public delegate string ConvertUnitText(string FileName, string text); // Это пока только для шифрованного Tasks. В остальных случаях он нулевой public delegate string ConvertUnitText(string FileName, string text); // Это пока только для шифрованного Tasks. В остальных случаях он нулевой
@ -67,7 +67,7 @@ namespace VisualPascalABC
Dictionary<string, CodeFileDocumentControl> OpenDocuments; Dictionary<string, CodeFileDocumentControl> OpenDocuments;
public VisualEnvironmentCompiler(InvokeDegegate beginInvoke, public VisualEnvironmentCompiler(InvokeDegegate beginInvoke,
SetFlagDelegate setCompilingButtonsEnabled, SetFlagDelegate setCompilingDebugEnabled, SetTextDelegate setStateText, SetFlagDelegate setCompilingAndRunButtonsEnabled, SetFlagDelegate setCompilingDebugEnabled, SetTextDelegate setStateText,
SetTextDelegate addTextToCompilerMessages, ToolStripMenuItem pluginsMenuItem, SetTextDelegate addTextToCompilerMessages, ToolStripMenuItem pluginsMenuItem,
ToolStrip pluginsToolStrip, ExecuteSourceLocationActionDelegate ExecuteSLAction, ToolStrip pluginsToolStrip, ExecuteSourceLocationActionDelegate ExecuteSLAction,
ExecuteVisualEnvironmentCompilerActionDelegate ExecuteVECAction, ExecuteVisualEnvironmentCompilerActionDelegate ExecuteVECAction,
@ -77,7 +77,7 @@ namespace VisualPascalABC
this.StandartDirectories = StandartDirectories; this.StandartDirectories = StandartDirectories;
this.ErrorsManager = ErrorsManager; this.ErrorsManager = ErrorsManager;
this.ChangeVisualEnvironmentState += onChangeVisualEnvironmentState; this.ChangeVisualEnvironmentState += onChangeVisualEnvironmentState;
SetCompilingButtonsEnabled = setCompilingButtonsEnabled; SetCompilingAndRunButtonsEnabled = setCompilingAndRunButtonsEnabled;
SetDebugButtonsEnabled = setCompilingDebugEnabled; SetDebugButtonsEnabled = setCompilingDebugEnabled;
SetStateText = setStateText; SetStateText = setStateText;
AddTextToCompilerMessages = addTextToCompilerMessages; AddTextToCompilerMessages = addTextToCompilerMessages;
@ -351,7 +351,7 @@ namespace VisualPascalABC
{ {
case PascalABCCompiler.CompilerState.CompilationStarting: case PascalABCCompiler.CompilerState.CompilationStarting:
RusName = VECStringResources.Get("STATE_START_COMPILING_ASSEMBLY{0}"); RusName = VECStringResources.Get("STATE_START_COMPILING_ASSEMBLY{0}");
SetCompilingButtonsEnabled(false); SetCompilingAndRunButtonsEnabled(false);
ParsedFiles.Clear(); ParsedFiles.Clear();
break; break;
case PascalABCCompiler.CompilerState.BeginCompileFile: RusName = VECStringResources.Get("STATE_BEGINCOMPILEFILE{0}"); break; case PascalABCCompiler.CompilerState.BeginCompileFile: RusName = VECStringResources.Get("STATE_BEGINCOMPILEFILE{0}"); break;
@ -397,21 +397,22 @@ namespace VisualPascalABC
//if (!ThreadPool.QueueUserWorkItem(new WaitCallback(LoadPlugins))) //if (!ThreadPool.QueueUserWorkItem(new WaitCallback(LoadPlugins)))
// LoadPlugins(null); // LoadPlugins(null);
SetCompilingButtonsEnabled(true); SetCompilingAndRunButtonsEnabled(true);
SetDebugButtonsEnabled(true); if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
SetDebugButtonsEnabled(true);
} }
} }
else else
{ {
if (Compiler == sender) if (Compiler == sender)
{ {
SetCompilingButtonsEnabled(true); SetCompilingAndRunButtonsEnabled(true);
} }
} }
break; break;
case PascalABCCompiler.CompilerState.Reloading: case PascalABCCompiler.CompilerState.Reloading:
if (Compiler == sender) if (Compiler == sender)
SetCompilingButtonsEnabled(false); SetCompilingAndRunButtonsEnabled(false);
RusName = VECStringResources.Get("STATE_RELOADING"); RusName = VECStringResources.Get("STATE_RELOADING");
break; break;
case PascalABCCompiler.CompilerState.CompilationFinished: case PascalABCCompiler.CompilerState.CompilationFinished:

View file

@ -318,6 +318,7 @@ namespace VisualPascalABC
this.StepOutButton.Visible = false; this.StepOutButton.Visible = false;
PlayPauseButtonsVisibleInPanel = PlayPauseButtonsVisibleInPanel; PlayPauseButtonsVisibleInPanel = PlayPauseButtonsVisibleInPanel;
SetDebugButtonsEnabled(false); SetDebugButtonsEnabled(false);
SetRunButtonsEnabled(false);
} }
// Для Linux сделать все Debug-кнопки неактивными // Для Linux сделать все Debug-кнопки неактивными
@ -408,7 +409,7 @@ namespace VisualPascalABC
RunManager RunnerManager = (WorkbenchServiceFactory.RunService as WorkbenchRunService).RunnerManager; RunManager RunnerManager = (WorkbenchServiceFactory.RunService as WorkbenchRunService).RunnerManager;
VisualEnvironmentCompiler = new VisualEnvironmentCompiler( VisualEnvironmentCompiler = new VisualEnvironmentCompiler(
this.BeginInvoke, SetCompilingButtonsEnabled, SetDedugButtonsEnabled, SetStateText, this.BeginInvoke, SetCompilingAndRunButtonsEnabled, SetDebugButtonsEnabled, SetStateText,
AddTextToCompilerMessagesSync, miPlugins, toolStrip1, AddTextToCompilerMessagesSync, miPlugins, toolStrip1,
ExecuteSourceLocationAction, ExecuteVisualEnvironmentCompilerAction, ErrorsManager, RunnerManager, ExecuteSourceLocationAction, ExecuteVisualEnvironmentCompilerAction, ErrorsManager, RunnerManager,
WorkbenchServiceFactory.DebuggerManager, UserOptions, WorkbenchStorage.StandartDirectories, OpenDocuments, this); WorkbenchServiceFactory.DebuggerManager, UserOptions, WorkbenchStorage.StandartDirectories, OpenDocuments, this);
@ -493,10 +494,10 @@ namespace VisualPascalABC
WorkbenchServiceFactory.FileService.OpenFile(FileNameToWait, null); WorkbenchServiceFactory.FileService.OpenFile(FileNameToWait, null);
} }
SetStopEnabled(false); SetStopEnabled(false);
CompilingButtonsEnabled = CloseButtonsEnabled = SaveAllButtonsEnabled = SaveButtonsEnabled = false; CompilingAndRunButtonsEnabled = CloseButtonsEnabled = SaveAllButtonsEnabled = SaveButtonsEnabled = false;
if (DebuggerVisible) if (DebuggerVisible)
SetDedugButtonsEnabled(false); SetDebugButtonsEnabled(false);
SetCompilingButtonsEnabled(false); SetCompilingAndRunButtonsEnabled(false);
HelpFileName = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.HelpFileName, WorkbenchStorage.StandartDirectories); HelpFileName = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.HelpFileName, WorkbenchStorage.StandartDirectories);
DotNetHelpFileName = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.DotNetHelpFileName, WorkbenchStorage.StandartDirectories); DotNetHelpFileName = PascalABCCompiler.Tools.ReplaceAllKeys(Constants.DotNetHelpFileName, WorkbenchStorage.StandartDirectories);

View file

@ -20,7 +20,7 @@ namespace VisualPascalABC
public static void Rename(TextArea textArea) public static void Rename(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
IDocument doc = textArea.Document; IDocument doc = textArea.Document;
string textContent = doc.TextContent; string textContent = doc.TextContent;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
@ -60,7 +60,7 @@ namespace VisualPascalABC
public static void RenameUnit(string FileName, string new_val) public static void RenameUnit(string FileName, string new_val)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
IDocument doc = null; IDocument doc = null;
CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController(); CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController();
@ -120,10 +120,7 @@ namespace VisualPascalABC
public static List<Position> GetDefinitionPosition(TextArea textArea, bool only_check) public static List<Position> GetDefinitionPosition(TextArea textArea, bool only_check)
{ {
IParser parser = CodeCompletion.CodeCompletionController.CurrentParser; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return new List<Position>();
if (parser == null)
return new List<Position>();
IDocument doc = textArea.Document; IDocument doc = textArea.Document;
string textContent = doc.TextContent; string textContent = doc.TextContent;
@ -136,7 +133,7 @@ namespace VisualPascalABC
// Проверка, что компилируем Паскаль временно EVA 10.11.2024 // Проверка, что компилируем Паскаль временно EVA 10.11.2024
if (parser == Languages.Facade.LanguageProvider.Instance.SelectLanguageByName(StringConstants.pascalLanguageName).Parser) if (CodeCompletion.CodeCompletionController.CurrentLanguage == Languages.Facade.LanguageProvider.Instance.MainLanguage)
{ {
if (expressionResult != full_expr && full_expr.StartsWith("(")) if (expressionResult != full_expr && full_expr.StartsWith("("))
return new List<Position>(); return new List<Position>();
@ -157,7 +154,7 @@ namespace VisualPascalABC
public static List<Position> GetRealizationPosition(TextArea textArea) public static List<Position> GetRealizationPosition(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return new List<Position>(); if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return new List<Position>();
IDocument doc = textArea.Document; IDocument doc = textArea.Document;
string textContent = doc.TextContent; string textContent = doc.TextContent;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
@ -171,7 +168,7 @@ namespace VisualPascalABC
public static List<SymbolsViewerSymbol> FindReferences(TextArea textArea) public static List<SymbolsViewerSymbol> FindReferences(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return new List<SymbolsViewerSymbol>(); if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return new List<SymbolsViewerSymbol>();
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
string full_expr; string full_expr;
string expressionResult = FindFullExpression(textArea.Document.TextContent, textArea, out ccp.keyword, out full_expr); string expressionResult = FindFullExpression(textArea.Document.TextContent, textArea, out ccp.keyword, out full_expr);
@ -180,7 +177,7 @@ namespace VisualPascalABC
public static void GotoRealization(TextArea textArea) public static void GotoRealization(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
position = GetRealizationPosition(textArea); position = GetRealizationPosition(textArea);
if (position == null || position.Count == 0) return; if (position == null || position.Count == 0) return;
if (position.Count == 1) if (position.Count == 1)
@ -209,7 +206,7 @@ namespace VisualPascalABC
public static bool CanGoTo(TextArea textArea) public static bool CanGoTo(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
List<Position> poses = GetDefinitionPosition(textArea, true); List<Position> poses = GetDefinitionPosition(textArea, true);
if (poses == null || poses.Count == 0) return false; if (poses == null || poses.Count == 0) return false;
foreach (Position pos in poses) foreach (Position pos in poses)
@ -222,7 +219,7 @@ namespace VisualPascalABC
public static bool CanGoToRealization(TextArea textArea) public static bool CanGoToRealization(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
List<Position> poses = GetRealizationPosition(textArea); List<Position> poses = GetRealizationPosition(textArea);
if (poses == null || poses.Count == 0) return false; if (poses == null || poses.Count == 0) return false;
foreach (Position pos in poses) foreach (Position pos in poses)
@ -237,7 +234,7 @@ namespace VisualPascalABC
{ {
try try
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
string full_expr; string full_expr;
string expressionResult = FindFullExpression(textArea.Document.TextContent, textArea, out ccp.keyword, out full_expr); string expressionResult = FindFullExpression(textArea.Document.TextContent, textArea, out ccp.keyword, out full_expr);
@ -258,7 +255,7 @@ namespace VisualPascalABC
{ {
try try
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
Position pos = new Position(); Position pos = new Position();
//string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos); //string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos);
@ -275,7 +272,7 @@ namespace VisualPascalABC
{ {
try try
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
Position pos = new Position(); Position pos = new Position();
//string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos); //string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos);
@ -298,7 +295,7 @@ namespace VisualPascalABC
private static TextArea _textArea; private static TextArea _textArea;
public static void GenerateOverridableMethods(TextArea textArea) public static void GenerateOverridableMethods(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
_textArea = textArea; _textArea = textArea;
int off = textArea.Caret.Offset; int off = textArea.Caret.Offset;
@ -328,7 +325,7 @@ namespace VisualPascalABC
public static void GenerateClassOrMethodRealization(TextArea textArea) public static void GenerateClassOrMethodRealization(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
Position pos = new Position(); Position pos = new Position();
//string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos); //string text = "procedure Test(a : integer);\n begin \n x := 1; \n end;";//ccp.GetRealizationTextToAdd(out pos);
@ -458,12 +455,12 @@ namespace VisualPascalABC
public static bool GenerateCommentTemplate(TextArea textArea) public static bool GenerateCommentTemplate(TextArea textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
ccp = new CodeCompletionProvider(); ccp = new CodeCompletionProvider();
//if (!should_insert_comment(textArea)) //if (!should_insert_comment(textArea))
// return false; // return false;
string lineText = get_next_line(textArea); string lineText = get_next_line(textArea);
string addit = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.GetDocumentTemplate( string addit = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.GetDocumentTemplate(
lineText, textArea.Document.TextContent, textArea.Caret.Line, textArea.Caret.Column, textArea.Caret.Offset); lineText, textArea.Document.TextContent, textArea.Caret.Line, textArea.Caret.Column, textArea.Caret.Offset);
if (addit == null) if (addit == null)
return false; return false;
@ -505,7 +502,7 @@ namespace VisualPascalABC
public static void GotoDefinition(TextArea _textArea) public static void GotoDefinition(TextArea _textArea)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return;
position = GetDefinitionPosition(_textArea, false); position = GetDefinitionPosition(_textArea, false);
if (position == null) return; if (position == null) return;
if (position.Count == 1) if (position.Count == 1)
@ -543,9 +540,9 @@ namespace VisualPascalABC
keyw = PascalABCCompiler.Parsers.KeywordKind.None; keyw = PascalABCCompiler.Parsers.KeywordKind.None;
string expr_without_brackets = null; string expr_without_brackets = null;
full_expr = null; full_expr = null;
if (CodeCompletion.CodeCompletionController.CurrentParser != null) if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
{ {
full_expr = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpressionFromAnyPosition(_textArea.Caret.Offset, Text, _textArea.Caret.Line, _textArea.Caret.Column, out keyw, out expr_without_brackets); full_expr = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpressionFromAnyPosition(_textArea.Caret.Offset, Text, _textArea.Caret.Line, _textArea.Caret.Column, out keyw, out expr_without_brackets);
return expr_without_brackets; return expr_without_brackets;
} }
return null; return null;
@ -553,7 +550,7 @@ namespace VisualPascalABC
private static string FindOnlyIdent(string Text, TextArea _textArea, ref string name) private static string FindOnlyIdent(string Text, TextArea _textArea, ref string name)
{ {
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindOnlyIdentifier(_textArea.Caret.Offset, Text, _textArea.Caret.Line, _textArea.Caret.Column, ref name); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindOnlyIdentifier(_textArea.Caret.Offset, Text, _textArea.Caret.Line, _textArea.Caret.Column, ref name);
} }
@ -605,7 +602,7 @@ namespace VisualPascalABC
{ {
public override void Execute(TextArea textArea) public override void Execute(TextArea textArea)
{ {
if (WorkbenchServiceFactory.DebuggerManager.IsRunning) if (WorkbenchServiceFactory.DebuggerManager.IsRunning || !CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return; return;
WorkbenchServiceFactory.Workbench.ErrorsListWindow.ClearErrorList(); WorkbenchServiceFactory.Workbench.ErrorsListWindow.ClearErrorList();
VisualPABCSingleton.MainForm.CurrentCodeFileDocument.DeselectAll(); VisualPABCSingleton.MainForm.CurrentCodeFileDocument.DeselectAll();
@ -615,12 +612,14 @@ namespace VisualPascalABC
// MainForm.VisualEnvironmentCompiler.Compiler.ParsersController.Compile( // MainForm.VisualEnvironmentCompiler.Compiler.ParsersController.Compile(
// file_name, TextEditor.Text, null, Errors, PascalABCCompiler.Parsers.ParseMode.Normal); // file_name, TextEditor.Text, null, Errors, PascalABCCompiler.Parsers.ParseMode.Normal);
string text = WorkbenchServiceFactory.Workbench.VisualEnvironmentCompiler.SourceFilesProvider(VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName, PascalABCCompiler.SourceFileOperation.GetText) as string; string text = WorkbenchServiceFactory.Workbench.VisualEnvironmentCompiler.SourceFilesProvider(VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName, PascalABCCompiler.SourceFileOperation.GetText) as string;
PascalABCCompiler.SyntaxTree.compilation_unit cu = PascalABCCompiler.SyntaxTree.compilation_unit cu =
Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtensionSafe(VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName)?.Parser.GetCompilationUnitForFormatter( CodeCompletion.CodeCompletionController.CurrentLanguage.Parser.GetCompilationUnitForFormatter(
VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName, VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName,
text, //VisualPascalABC.Form1.Form1_object._currentCodeFileDocument.TextEditor.Text, text, //VisualPascalABC.Form1.Form1_object._currentCodeFileDocument.TextEditor.Text,
Errors, Errors,
new List<PascalABCCompiler.Errors.CompilerWarning>()); new List<PascalABCCompiler.Errors.CompilerWarning>());
if (Errors.Count == 0) if (Errors.Count == 0)
{ {
string formattedText = cf.FormatTree(text, cu, textArea.Caret.Line + 1, textArea.Caret.Column + 1); string formattedText = cf.FormatTree(text, cu, textArea.Caret.Line + 1, textArea.Caret.Column + 1);
@ -682,7 +681,7 @@ namespace VisualPascalABC
} }
if (!WorkbenchServiceFactory.Workbench.UserOptions.CodeCompletionDot) if (!WorkbenchServiceFactory.Workbench.UserOptions.CodeCompletionDot)
return; return;
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; if (CodeCompletion.CodeCompletionController.CurrentLanguage == null) return;
CodeCompletionProvider completionDataProvider = new CodeCompletionProvider(); CodeCompletionProvider completionDataProvider = new CodeCompletionProvider();
bool is_pattern = false; bool is_pattern = false;
@ -690,7 +689,7 @@ namespace VisualPascalABC
is_begin = true; is_begin = true;
completionDataProvider.preSelection = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindPattern(off, text, out is_pattern); completionDataProvider.preSelection = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindPattern(off, text, out is_pattern);
if (!is_pattern && off > 0 && text[off - 1] == '.') if (!is_pattern && off > 0 && text[off - 1] == '.')
key = '_';//was '$' key = '_';//was '$'

View file

@ -54,8 +54,8 @@ namespace VisualPascalABC
{ {
public static PascalABCCompiler.Parsers.KeywordKind TestForKeyword(string Text, int i) public static PascalABCCompiler.Parsers.KeywordKind TestForKeyword(string Text, int i)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser != null && CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation !=null) if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.TestForKeyword(Text, i); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.TestForKeyword(Text, i);
return PascalABCCompiler.Parsers.KeywordKind.None; return PascalABCCompiler.Parsers.KeywordKind.None;
} }

View file

@ -64,7 +64,7 @@ namespace VisualPascalABC
{ {
if (!WorkbenchServiceFactory.Workbench.UserOptions.AllowCodeCompletion || !VisualPABCSingleton.MainForm.VisualEnvironmentCompiler.compilerLoaded) if (!WorkbenchServiceFactory.Workbench.UserOptions.AllowCodeCompletion || !VisualPABCSingleton.MainForm.VisualEnvironmentCompiler.compilerLoaded)
return false; return false;
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
if (codeCompletionWindow != null) if (codeCompletionWindow != null)
{ {
// If completion window is open and wants to handle the key, don't let the text area // If completion window is open and wants to handle the key, don't let the text area
@ -93,8 +93,6 @@ namespace VisualPascalABC
} }
if (key == '.') if (key == '.')
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null)
return false;
if (!string.IsNullOrEmpty(WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.SelectionManager.SelectedText)) if (!string.IsNullOrEmpty(WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.SelectionManager.SelectedText))
{ {
WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Position = WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.SelectionManager.SelectionCollection[0].StartPosition; WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Position = WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.SelectionManager.SelectionCollection[0].StartPosition;
@ -124,7 +122,6 @@ namespace VisualPascalABC
} }
else if (key == '(' || key == '[' || key == ',') else if (key == '(' || key == '[' || key == ',')
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false;
if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionParams) if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionParams)
{ {
ICSharpCode.TextEditor.Gui.InsightWindow.IInsightDataProvider idp = new DefaultInsightDataProvider(-1, false, key); ICSharpCode.TextEditor.Gui.InsightWindow.IInsightDataProvider idp = new DefaultInsightDataProvider(-1, false, key);
@ -147,7 +144,6 @@ namespace VisualPascalABC
} }
else if (key == ' ') else if (key == ' ')
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false;
if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionDot) if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionDot)
{ {
PascalABCCompiler.Parsers.KeywordKind keyw = KeywordChecker.TestForKeyword(editor.Document.TextContent, editor.ActiveTextAreaControl.TextArea.Caret.Offset - 1); PascalABCCompiler.Parsers.KeywordKind keyw = KeywordChecker.TestForKeyword(editor.Document.TextContent, editor.ActiveTextAreaControl.TextArea.Caret.Offset - 1);
@ -173,7 +169,7 @@ namespace VisualPascalABC
} }
else if (key == '\n') else if (key == '\n')
{ {
if (VisualPABCSingleton.MainForm.UserOptions.AllowCodeCompletion && CodeCompletion.CodeCompletionController.CurrentParser != null) if (VisualPABCSingleton.MainForm.UserOptions.AllowCodeCompletion)
{ {
try try
{ {
@ -194,9 +190,8 @@ namespace VisualPascalABC
{ {
if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionDot) if (VisualPABCSingleton.MainForm.UserOptions.CodeCompletionDot)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false;
PascalABCCompiler.Parsers.KeywordKind keyw = KeywordChecker.TestForKeyword(editor.Document.TextContent, editor.ActiveTextAreaControl.TextArea.Caret.Offset - 1); PascalABCCompiler.Parsers.KeywordKind keyw = KeywordChecker.TestForKeyword(editor.Document.TextContent, editor.ActiveTextAreaControl.TextArea.Caret.Offset - 1);
if (CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.IsDefinitionIdentifierAfterKeyword(keyw)) if (CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsDefinitionIdentifierAfterKeyword(keyw))
return false; return false;
// если не первый символ выражения (предыдущий тоже буква или "_"), то не открываем новое окно // если не первый символ выражения (предыдущий тоже буква или "_"), то не открываем новое окно

View file

@ -76,11 +76,7 @@ namespace VisualPascalABC
public void RegisterFileForParsing(string FileName) public void RegisterFileForParsing(string FileName)
{ {
if (Languages.Facade.LanguageProvider.Instance.HasLanguageForExtension(FileName)) filesToParse[FileName] = true;
{
filesToParse[FileName] = true;
CodeCompletion.CodeCompletionController.SetLanguage(FileName);
}
} }
public void CloseFile(string FileName) public void CloseFile(string FileName)

View file

@ -126,12 +126,12 @@ namespace VisualPascalABC
private string construct_header(string meth, CodeCompletion.ProcScope ps, int tabCount) private string construct_header(string meth, CodeCompletion.ProcScope ps, int tabCount)
{ {
//if (CodeCompletion.CodeCompletionController.currentParser != null) //if (CodeCompletion.CodeCompletionController.currentParser != null)
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.ConstructHeader(meth, ps, tabCount); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.ConstructHeader(meth, ps, tabCount);
} }
private string construct_header(CodeCompletion.ProcRealization ps, int tabCount) private string construct_header(CodeCompletion.ProcRealization ps, int tabCount)
{ {
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.ConstructHeader(ps, tabCount); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.ConstructHeader(ps, tabCount);
} }
public CodeCompletion.SymScope FindScopeByLocation(string fileName, int line, int col) public CodeCompletion.SymScope FindScopeByLocation(string fileName, int line, int col)
@ -295,8 +295,8 @@ namespace VisualPascalABC
public string FindExpression(int off, string Text, int line, int col) public string FindExpression(int off, string Text, int line, int col)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser != null) if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpression(off, Text, line, col, out keyword); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpression(off, Text, line, col, out keyword);
return null; return null;
} }
@ -325,14 +325,14 @@ namespace VisualPascalABC
try try
{ {
ILanguageInformation languageInformation = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation; ILanguage currentLanguage = CodeCompletion.CodeCompletionController.CurrentLanguage;
List<string> keywords; List<string> keywords;
bool isTypeAfterKeyword = false; bool isTypeAfterKeyword = false;
// если по смыслу должен вводиться тип данных // если по смыслу должен вводиться тип данных
if (languageInformation.IsTypeAfterKeyword(keyw)) if (currentLanguage.LanguageIntellisenseSupport.IsTypeAfterKeyword(keyw))
{ {
keywords = CodeCompletion.CodeCompletionNameHelper.Helper.GetTypeKeywords(); keywords = CodeCompletion.CodeCompletionNameHelper.Helper.GetTypeKeywords();
isTypeAfterKeyword = true; isTypeAfterKeyword = true;
@ -345,7 +345,7 @@ namespace VisualPascalABC
bool isNamespaceAfterKeyword = false; bool isNamespaceAfterKeyword = false;
// конструкция типа "uses" // конструкция типа "uses"
if (languageInformation.IsNamespaceAfterKeyword(keyw)) if (currentLanguage.LanguageIntellisenseSupport.IsNamespaceAfterKeyword(keyw))
{ {
isNamespaceAfterKeyword = true; isNamespaceAfterKeyword = true;
} }
@ -359,11 +359,9 @@ namespace VisualPascalABC
if (symInfos != null) if (symInfos != null)
{ {
bool languageCaseSensitive = LanguageProvider.Instance.SelectLanguageByExtension(FileName).CaseSensitive; currentLanguage.LanguageIntellisenseSupport.RenameOrExcludeSpecialNames(symInfos);
languageInformation.RenameOrExcludeSpecialNames(symInfos); AddCompletionDatasByFirstForSymInfos(resultList, charTyped, symInfos, currentLanguage.CaseSensitive);
AddCompletionDatasByFirstForSymInfos(resultList, charTyped, symInfos, languageCaseSensitive);
//resultList.Sort(); //resultList.Sort();
//defaultCompletionElement = resultList[0] as DefaultCompletionData; //defaultCompletionElement = resultList[0] as DefaultCompletionData;
@ -507,7 +505,7 @@ namespace VisualPascalABC
}; };
string expressionText = GetExpressionTextForCompletionData(off, text, line, col, string expressionText = GetExpressionTextForCompletionData(off, text, line, col,
currentLanguage.LanguageInformation, in context, out var insidePatternWithDots, out var ctrlOrShiftSpaceAfterDot, out var pattern); currentLanguage.LanguageIntellisenseSupport, in context, out var insidePatternWithDots, out var ctrlOrShiftSpaceAfterDot, out var pattern);
// добавляем ключевые слова в случае "ctrl + space", нажатых в "пустом" месте // добавляем ключевые слова в случае "ctrl + space", нажатых в "пустом" месте
if (!ctrlOrShiftSpaceAfterDot && context.ctrlSpace && string.IsNullOrEmpty(pattern)) if (!ctrlOrShiftSpaceAfterDot && context.ctrlSpace && string.IsNullOrEmpty(pattern))
@ -538,7 +536,7 @@ namespace VisualPascalABC
if (symInfos != null) if (symInfos != null)
{ {
currentLanguage.LanguageInformation.RenameOrExcludeSpecialNames(symInfos); currentLanguage.LanguageIntellisenseSupport.RenameOrExcludeSpecialNames(symInfos);
AddCompletionDatasForSymInfos(resultList, currentLanguage.CaseSensitive, symInfos, selectedSymInfo, lastUsedMember); AddCompletionDatasForSymInfos(resultList, currentLanguage.CaseSensitive, symInfos, selectedSymInfo, lastUsedMember);
} }
@ -690,7 +688,7 @@ namespace VisualPascalABC
/// <summary> /// <summary>
/// Получение текста выражения, введенного пользователем перед нажатием "триггерной" клавиши /// Получение текста выражения, введенного пользователем перед нажатием "триггерной" клавиши
/// </summary> /// </summary>
private string GetExpressionTextForCompletionData(int off, string text, int line, int col, ILanguageInformation languageInformation, in ActionContext context, out bool insidePatternWithDots, out bool ctrlOrShiftSpaceAfterDot, out string pattern) private string GetExpressionTextForCompletionData(int off, string text, int line, int col, ILanguageIntellisenseSupport languageInformation, in ActionContext context, out bool insidePatternWithDots, out bool ctrlOrShiftSpaceAfterDot, out string pattern)
{ {
string expressionText = null; string expressionText = null;

View file

@ -19,11 +19,17 @@ namespace VisualPascalABC
public static void DefinitionByMouseClickManager_TextAreaMouseMove(object sender, MouseEventArgs e) public static void DefinitionByMouseClickManager_TextAreaMouseMove(object sender, MouseEventArgs e)
{ {
if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return;
makeWordUnderline(sender, e); makeWordUnderline(sender, e);
} }
public static void DefinitionByMouseClickManager_TextAreaMouseDown(object sender, EventArgs e) public static void DefinitionByMouseClickManager_TextAreaMouseDown(object sender, EventArgs e)
{ {
if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return;
TextArea textArea = (TextArea)sender; TextArea textArea = (TextArea)sender;
if (Control.ModifierKeys == Keys.Control && textArea.SelectionManager.SelectionCollection.Count == 0) if (Control.ModifierKeys == Keys.Control && textArea.SelectionManager.SelectionCollection.Count == 0)
{ {

View file

@ -31,8 +31,8 @@ namespace VisualPascalABC
private string FindExpression(int off, string Text, int line, int col) private string FindExpression(int off, string Text, int line, int col)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser != null) if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpressionForMethod(off, Text, line, col, pressed_key, ref num_param); return CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.FindExpressionForMethod(off, Text, line, col, pressed_key, ref num_param);
return null; return null;
} }
@ -42,7 +42,7 @@ namespace VisualPascalABC
{ {
if (setupOnlyOnce && this.textArea != null) if (setupOnlyOnce && this.textArea != null)
{ {
if (CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.IsMethodCallParameterSeparator(pressed_key)) if (CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsMethodCallParameterSeparator(pressed_key))
{ {
FindExpression(textArea.Caret.Offset, textArea.Document.TextContent.Substring(0, textArea.Caret.Offset), FindExpression(textArea.Caret.Offset, textArea.Document.TextContent.Substring(0, textArea.Caret.Offset),
textArea.Caret.Line, textArea.Caret.Column); textArea.Caret.Line, textArea.Caret.Column);
@ -71,9 +71,9 @@ namespace VisualPascalABC
if (dconv != null) if (dconv != null)
{ {
//if (pressed_key == '(' || pressed_key == ',') //if (pressed_key == '(' || pressed_key == ',')
if (CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.IsOpenBracketForMethodCall(pressed_key) || CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.IsMethodCallParameterSeparator(pressed_key)) if (CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsOpenBracketForMethodCall(pressed_key) || CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsMethodCallParameterSeparator(pressed_key))
methods = dconv.GetNameOfMethod(e, expr, line, col, num_param, ref defaultIndex, cur_param_num, out param_count); methods = dconv.GetNameOfMethod(e, expr, line, col, num_param, ref defaultIndex, cur_param_num, out param_count);
else if (CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.IsOpenBracketForIndex(pressed_key)) else if (CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.IsOpenBracketForIndex(pressed_key))
methods = dconv.GetIndex(e, line, col); methods = dconv.GetIndex(e, line, col);
} }
} }

View file

@ -8,7 +8,6 @@ using System.Windows.Forms;
using ICSharpCode.TextEditor; using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Gui.CompletionWindow; using ICSharpCode.TextEditor.Gui.CompletionWindow;
using PascalABCCompiler.Parsers;
namespace VisualPascalABC namespace VisualPascalABC
{ {
@ -29,9 +28,9 @@ namespace VisualPascalABC
//string expr = FindFullExpression(doc.TextContent, seg.Offset + logicPos.X,e.LogicalPosition.Line,e.LogicalPosition.Column); //string expr = FindFullExpression(doc.TextContent, seg.Offset + logicPos.X,e.LogicalPosition.Line,e.LogicalPosition.Column);
IParser parser = CodeCompletion.CodeCompletionController.CurrentParser; var currentLanguage = CodeCompletion.CodeCompletionController.CurrentLanguage;
string expr = parser.LanguageInformation.FindExpressionFromAnyPosition( string expr = currentLanguage.LanguageIntellisenseSupport.FindExpressionFromAnyPosition(
lineSegment.Offset + logicPos.X, doc.TextContent, e.LogicalPosition.Line, e.LogicalPosition.Column, out var keyw, out var exprWithoutBrackets); lineSegment.Offset + logicPos.X, doc.TextContent, e.LogicalPosition.Line, e.LogicalPosition.Column, out var keyw, out var exprWithoutBrackets);
// пока непонятно, когда такое может быть EVA // пока непонятно, когда такое может быть EVA
@ -44,25 +43,25 @@ namespace VisualPascalABC
List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>(); List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>();
List<PascalABCCompiler.Errors.CompilerWarning> Warnings = new List<PascalABCCompiler.Errors.CompilerWarning>(); List<PascalABCCompiler.Errors.CompilerWarning> Warnings = new List<PascalABCCompiler.Errors.CompilerWarning>();
PascalABCCompiler.SyntaxTree.expression expressionTree = parser.GetExpression("test" + Path.GetExtension(fileName), PascalABCCompiler.SyntaxTree.expression expressionTree = currentLanguage.Parser.GetExpression("test" + Path.GetExtension(fileName),
expr, Errors, Warnings); expr, Errors, Warnings);
// Пока добавили проверку, что анализируем Паскаль EVA // Пока добавили проверку, что анализируем Паскаль EVA
if (Errors.Count > 0 && parser == Languages.Facade.LanguageProvider.Instance.MainLanguage.Parser) if (Errors.Count > 0 && currentLanguage == Languages.Facade.LanguageProvider.Instance.MainLanguage)
{ {
string s = expr.TrimStart(); string s = expr.TrimStart();
if (s.Length > 0 && s[0] == '^') if (s.Length > 0 && s[0] == '^')
{ {
Errors.Clear(); Errors.Clear();
exprWithoutBrackets = exprWithoutBrackets.TrimStart().Substring(1); exprWithoutBrackets = exprWithoutBrackets.TrimStart().Substring(1);
expressionTree = parser.GetExpression("test" + Path.GetExtension(fileName), s.Substring(1), Errors, Warnings); expressionTree = currentLanguage.Parser.GetExpression("test" + Path.GetExtension(fileName), s.Substring(1), Errors, Warnings);
} }
} }
List<PascalABCCompiler.Errors.Error> Errors2 = new List<PascalABCCompiler.Errors.Error>(); List<PascalABCCompiler.Errors.Error> Errors2 = new List<PascalABCCompiler.Errors.Error>();
// проверка для выражения без скобок // проверка для выражения без скобок
PascalABCCompiler.SyntaxTree.expression expressionTree2 = parser.GetExpression("test" + Path.GetExtension(fileName), exprWithoutBrackets, Errors2, Warnings); PascalABCCompiler.SyntaxTree.expression expressionTree2 = currentLanguage.Parser.GetExpression("test" + Path.GetExtension(fileName), exprWithoutBrackets, Errors2, Warnings);
// если не получается, то сразу возврат // если не получается, то сразу возврат
if (expressionTree2 == null || Errors2.Count > 0) if (expressionTree2 == null || Errors2.Count > 0)
@ -123,7 +122,7 @@ namespace VisualPascalABC
{ {
if (!VisualPABCSingleton.MainForm.UserOptions.CodeCompletionHint) if (!VisualPABCSingleton.MainForm.UserOptions.CodeCompletionHint)
return; return;
if (CodeCompletion.CodeCompletionController.CurrentParser == null) if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable())
return; return;
try try
{ {

View file

@ -315,7 +315,7 @@ namespace VisualPascalABC
public bool IsRunning = false; public bool IsRunning = false;
public string ExeFileName; public string ExeFileName;
public bool ShowDebugTabs=true; public bool ShowDebugTabs=true;
public PascalABCCompiler.Parsers.IParser parser = null; public Languages.Facade.ILanguage language = null;
EventHandler<EventArgs> debuggerStateEvent; EventHandler<EventArgs> debuggerStateEvent;
private Mono.Debugging.Soft.SoftDebuggerSession monoDebuggerSession; private Mono.Debugging.Soft.SoftDebuggerSession monoDebuggerSession;
private Mono.Debugging.Client.StackFrame stackFrame; private Mono.Debugging.Client.StackFrame stackFrame;
@ -485,7 +485,7 @@ namespace VisualPascalABC
this.FullFileName = Path.Combine(Path.GetDirectoryName(fileName), this.FileName); this.FullFileName = Path.Combine(Path.GetDirectoryName(fileName), this.FileName);
this.ExeFileName = fileName; this.ExeFileName = fileName;
CurrentLine = 0; CurrentLine = 0;
this.parser = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtensionSafe(FullFileName)?.Parser; this.language = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtension(FullFileName);
this.PrevFullFileName = FullFileName; this.PrevFullFileName = FullFileName;
AssemblyHelper.LoadAssembly(fileName); AssemblyHelper.LoadAssembly(fileName);
//dbg.ProcessStarted += debugProcessStarted; //dbg.ProcessStarted += debugProcessStarted;
@ -509,7 +509,7 @@ namespace VisualPascalABC
this.FullFileName = Path.Combine(Path.GetDirectoryName(fileName), this.FileName); this.FullFileName = Path.Combine(Path.GetDirectoryName(fileName), this.FileName);
this.ExeFileName = fileName; this.ExeFileName = fileName;
CurrentLine = 0; CurrentLine = 0;
this.parser = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtensionSafe(FullFileName)?.Parser; this.language = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtension(FullFileName);
this.PrevFullFileName = FullFileName; this.PrevFullFileName = FullFileName;
AssemblyHelper.LoadAssembly(fileName); AssemblyHelper.LoadAssembly(fileName);
@ -541,7 +541,7 @@ namespace VisualPascalABC
workbench.WidgetController.SetDebugTabsVisible(true); workbench.WidgetController.SetDebugTabsVisible(true);
workbench.WidgetController.SetPlayButtonsVisible(true); workbench.WidgetController.SetPlayButtonsVisible(true);
workbench.WidgetController.SetDebugStopEnabled();//e.Process.LogMessage += messageEventProc; workbench.WidgetController.SetDebugStopEnabled();//e.Process.LogMessage += messageEventProc;
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
workbench.WidgetController.ChangeStartDebugNameOnContinue(); workbench.WidgetController.ChangeStartDebugNameOnContinue();
workbench.WidgetController.EnableCodeCompletionToolTips(false); workbench.WidgetController.EnableCodeCompletionToolTips(false);
workbench.WidgetController.SetAddExprMenuVisible(true); workbench.WidgetController.SetAddExprMenuVisible(true);
@ -597,7 +597,7 @@ namespace VisualPascalABC
workbench.ServiceContainer.EditorService.SetEditorDisabled(false); workbench.ServiceContainer.EditorService.SetEditorDisabled(false);
//RemoveMarker(frm.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Document); //RemoveMarker(frm.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Document);
evaluator = null; evaluator = null;
parser = null; language = null;
FileName = null; FileName = null;
handle = 0; handle = 0;
ExeFileName = null; ExeFileName = null;
@ -642,7 +642,7 @@ namespace VisualPascalABC
if (evaluator != null) if (evaluator != null)
evaluator.SetCurrentMonoFrame(monoDebuggerSession, stackFrame); evaluator.SetCurrentMonoFrame(monoDebuggerSession, stackFrame);
JumpToCurrentLine(); JumpToCurrentLine();
workbench.WidgetController.SetStartDebugEnabled(); workbench.WidgetController.SetStartDebugAndRunEnabled();
WorkbenchServiceFactory.DebuggerOperationsService.RefreshPad(new FunctionItem(stackFrame).SubItems); WorkbenchServiceFactory.DebuggerOperationsService.RefreshPad(new FunctionItem(stackFrame).SubItems);
} }
@ -662,7 +662,7 @@ namespace VisualPascalABC
if (evaluator != null) if (evaluator != null)
evaluator.SetCurrentMonoFrame(monoDebuggerSession, stackFrame); evaluator.SetCurrentMonoFrame(monoDebuggerSession, stackFrame);
JumpToCurrentLine(); JumpToCurrentLine();
workbench.WidgetController.SetStartDebugEnabled(); workbench.WidgetController.SetStartDebugAndRunEnabled();
} }
Function currentFunction; Function currentFunction;
@ -785,7 +785,7 @@ namespace VisualPascalABC
private void debuggedProcess_Expired(object sender, EventArgs e) private void debuggedProcess_Expired(object sender, EventArgs e)
{ {
workbench.WidgetController.SetStartDebugEnabled(); workbench.WidgetController.SetStartDebugAndRunEnabled();
} }
private void debuggedProcess_ExceptionThrown(object sender, ExceptionEventArgs e) private void debuggedProcess_ExceptionThrown(object sender, ExceptionEventArgs e)
@ -850,7 +850,7 @@ namespace VisualPascalABC
workbench.ServiceContainer.EditorService.SetEditorDisabled(false); workbench.ServiceContainer.EditorService.SetEditorDisabled(false);
//RemoveMarker(frm.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Document); //RemoveMarker(frm.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Document);
evaluator = null; evaluator = null;
parser= null; language= null;
FileName = null; FileName = null;
handle = 0; handle = 0;
ExeFileName = null; ExeFileName = null;
@ -894,7 +894,7 @@ namespace VisualPascalABC
workbench.WidgetController.SetDebugTabsVisible(true); workbench.WidgetController.SetDebugTabsVisible(true);
workbench.WidgetController.SetPlayButtonsVisible(true); workbench.WidgetController.SetPlayButtonsVisible(true);
workbench.WidgetController.SetDebugStopEnabled();//e.Process.LogMessage += messageEventProc; workbench.WidgetController.SetDebugStopEnabled();//e.Process.LogMessage += messageEventProc;
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
workbench.WidgetController.ChangeStartDebugNameOnContinue(); workbench.WidgetController.ChangeStartDebugNameOnContinue();
workbench.WidgetController.EnableCodeCompletionToolTips(false); workbench.WidgetController.EnableCodeCompletionToolTips(false);
workbench.WidgetController.SetAddExprMenuVisible(true); workbench.WidgetController.SetAddExprMenuVisible(true);
@ -1466,7 +1466,7 @@ namespace VisualPascalABC
{ {
sb.Insert(0, '.'); sb.Insert(0, '.');
PascalABCCompiler.Parsers.KeywordKind keyw = PascalABCCompiler.Parsers.KeywordKind.None; PascalABCCompiler.Parsers.KeywordKind keyw = PascalABCCompiler.Parsers.KeywordKind.None;
string s = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation. string s = CodeCompletion.CodeCompletionController.CurrentLanguage.LanguageIntellisenseSupport.
FindExpression(i, text, 0, 0, out keyw); FindExpression(i, text, 0, 0, out keyw);
if (s != null) if (s != null)
{ {
@ -2011,7 +2011,7 @@ namespace VisualPascalABC
{ {
try try
{ {
workbench.WidgetController.SetStartDebugEnabled(); workbench.WidgetController.SetStartDebugAndRunEnabled();
dbg.Processes[0].Terminate(); dbg.Processes[0].Terminate();
} }
catch (System.Exception e) catch (System.Exception e)
@ -2027,7 +2027,7 @@ namespace VisualPascalABC
{ {
try try
{ {
workbench.WidgetController.SetStartDebugEnabled(); workbench.WidgetController.SetStartDebugAndRunEnabled();
dbg.Processes[0].Break(); dbg.Processes[0].Break();
} }
catch (System.Exception e) catch (System.Exception e)
@ -2093,7 +2093,7 @@ namespace VisualPascalABC
{ {
try try
{ {
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
CurrentLineBookmark.Remove(); CurrentLineBookmark.Remove();
monoDebuggerSession.NextLine(); monoDebuggerSession.NextLine();
@ -2114,7 +2114,7 @@ namespace VisualPascalABC
{ {
try try
{ {
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
monoDebuggerSession.Continue(); monoDebuggerSession.Continue();
CurrentLineBookmark.Remove(); CurrentLineBookmark.Remove();
} }
@ -2134,7 +2134,7 @@ namespace VisualPascalABC
{ {
try try
{ {
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
stepin_stmt = monoDebuggerSession.ActiveThread.Backtrace.GetFrame(0).SourceLocation; stepin_stmt = monoDebuggerSession.ActiveThread.Backtrace.GetFrame(0).SourceLocation;
monoDebuggerSession.StepLine(); monoDebuggerSession.StepLine();
CurrentLineBookmark.Remove(); CurrentLineBookmark.Remove();
@ -2157,7 +2157,7 @@ namespace VisualPascalABC
{ {
if (IsRunning) if (IsRunning)
{ {
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
monoDebuggerSession.StepOut(); monoDebuggerSession.StepOut();
CurrentLineBookmark.Remove(); CurrentLineBookmark.Remove();
} }
@ -2177,7 +2177,7 @@ namespace VisualPascalABC
{ {
//cur_brpt = dbg.AddBreakpoint(new SourcecodeSegment((frm.CurrentTabPage.ag as CodeFileDocumentControl).file_name,(frm.CurrentTabPage.ag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Line + 1,(frm.CurrentTabPage.Tag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Column + 1, //cur_brpt = dbg.AddBreakpoint(new SourcecodeSegment((frm.CurrentTabPage.ag as CodeFileDocumentControl).file_name,(frm.CurrentTabPage.ag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Line + 1,(frm.CurrentTabPage.Tag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Column + 1,
// (frm.CurrentTabPage.ag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Column+100), true); // (frm.CurrentTabPage.ag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Column+100), true);
workbench.WidgetController.SetStartDebugDisabled(); workbench.WidgetController.SetStartDebugAndRunDisabled();
currentBreakpoint = monoDebuggerSession.Breakpoints.Add(WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.FileName, WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line + 1); currentBreakpoint = monoDebuggerSession.Breakpoints.Add(WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.FileName, WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line + 1);
AddGoToBreakPoint(currentBreakpoint); AddGoToBreakPoint(currentBreakpoint);
Status = DebugStatus.None; Status = DebugStatus.None;

View file

@ -132,8 +132,8 @@ namespace VisualPascalABC
public static string WrapTypeName(DebugType type) public static string WrapTypeName(DebugType type)
{ {
if (type.IsArray) if (type.IsArray)
if (WorkbenchServiceFactory.DebuggerManager.parser != null) if (WorkbenchServiceFactory.DebuggerManager.language != null)
return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetArrayDescription(WrapTypeName(type.GetElementType()), type.GetArrayRank()); return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetArrayDescription(WrapTypeName(type.GetElementType()), type.GetArrayRank());
else else
return "array of " + WrapTypeName(type.GetElementType()); return "array of " + WrapTypeName(type.GetElementType());
return internalWrapTypeName(type.FullName); return internalWrapTypeName(type.FullName);
@ -192,23 +192,23 @@ namespace VisualPascalABC
private static string internalWrapTypeName(string name) private static string internalWrapTypeName(string name)
{ {
if (WorkbenchServiceFactory.DebuggerManager.parser != null) if (WorkbenchServiceFactory.DebuggerManager.language != null)
switch (name) switch (name)
{ {
case "System.Boolean": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(bool)); case "System.Boolean": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(bool));
case "System.Int32": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(int)); case "System.Int32": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(int));
case "System.Byte": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(byte)); case "System.Byte": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(byte));
case "System.Double": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(double)); case "System.Double": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(double));
case "System.String": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(string)); case "System.String": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(string));
case "System.Char": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(char)); case "System.Char": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(char));
case "System.SByte": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(sbyte)); case "System.SByte": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(sbyte));
case "System.Int16": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(short)); case "System.Int16": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(short));
case "System.UInt16": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(ushort)); case "System.UInt16": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(ushort));
case "System.UInt32": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(uint)); case "System.UInt32": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(uint));
case "System.Int64": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(long)); case "System.Int64": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(long));
case "System.UInt64": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(ulong)); case "System.UInt64": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(ulong));
case "System.Float32": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(typeof(float)); case "System.Float32": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(typeof(float));
case "System.IntPtr": return WorkbenchServiceFactory.DebuggerManager.parser.LanguageInformation.GetShortTypeName(Type.GetType("System.Void*")); case "System.IntPtr": return WorkbenchServiceFactory.DebuggerManager.language.LanguageIntellisenseSupport.GetShortTypeName(Type.GetType("System.Void*"));
default: return name; default: return name;
} }
else else

View file

@ -462,7 +462,7 @@ namespace VisualPascalABC
void tsIntellisense_DropDownOpened(object sender, EventArgs e) void tsIntellisense_DropDownOpened(object sender, EventArgs e)
{ {
if (UserOptions.AllowCodeCompletion) if (UserOptions.AllowCodeCompletion && CodeCompletion.CodeCompletionController.IntellisenseAvailable())
{ {
//GotoAction ga = new GotoAction(); //GotoAction ga = new GotoAction();
TextArea ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea; TextArea ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea;
@ -470,21 +470,50 @@ namespace VisualPascalABC
this.tsGotoRealization.Enabled = CodeCompletionActionsManager.CanGoToRealization(ta); this.tsGotoRealization.Enabled = CodeCompletionActionsManager.CanGoToRealization(ta);
this.tsFindAllReferences.Enabled = CodeCompletionActionsManager.CanFindReferences(ta); this.tsFindAllReferences.Enabled = CodeCompletionActionsManager.CanFindReferences(ta);
//this.cmFindAllReferences.Enabled = ga.CanFindReferences(ta); //this.cmFindAllReferences.Enabled = ga.CanFindReferences(ta);
this.miGenerateRealization.Enabled = CodeCompletionActionsManager.CanGenerateRealization(ta); this.miGenerateRealization.Enabled = CodeCompletionActionsManager.CanGenerateRealization(ta);
}
else
{
DisableIntellisenseDropDownOptions();
} }
} }
private void OpeningContextMenu(object sender, CancelEventArgs args) private void OpeningContextMenu(object sender, CancelEventArgs args)
{ {
GotoAction ga = new GotoAction(); if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
TextArea ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea; {
this.cmGotoDefinition.Enabled = CodeCompletionActionsManager.CanGoTo(ta); // GotoAction ga = new GotoAction();
this.cmGotoRealization.Enabled = CodeCompletionActionsManager.CanGoToRealization(ta); TextArea ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea;
this.cmFindAllReferences.Enabled = CodeCompletionActionsManager.CanFindReferences(ta);
this.cmGenerateRealization.Enabled = CodeCompletionActionsManager.CanGenerateRealization(ta); this.cmGotoDefinition.Enabled = CodeCompletionActionsManager.CanGoTo(ta);
this.cmRename.Enabled = CodeCompletionActionsManager.CanGoTo(ta); this.cmGotoRealization.Enabled = CodeCompletionActionsManager.CanGoToRealization(ta);
} this.cmFindAllReferences.Enabled = CodeCompletionActionsManager.CanFindReferences(ta);
this.cmGenerateRealization.Enabled = CodeCompletionActionsManager.CanGenerateRealization(ta);
this.cmRename.Enabled = CodeCompletionActionsManager.CanGoTo(ta);
}
else
{
DisableIntellisenseContextMenuOptions();
}
}
private void DisableIntellisenseContextMenuOptions()
{
this.cmGotoDefinition.Enabled = false;
this.cmGotoRealization.Enabled = false;
this.cmFindAllReferences.Enabled = false;
this.cmGenerateRealization.Enabled = false;
this.cmRename.Enabled = false;
}
private void DisableIntellisenseDropDownOptions()
{
this.tsGotoDefinition.Enabled = false;
this.tsGotoRealization.Enabled = false;
this.tsFindAllReferences.Enabled = false;
this.miGenerateRealization.Enabled = false;
}
private void ClosingContextMenu(object sender, CancelEventArgs args) private void ClosingContextMenu(object sender, CancelEventArgs args)
{ {
this.cmRename.Enabled = true; this.cmRename.Enabled = true;

View file

@ -99,11 +99,11 @@ namespace VisualPascalABC
string full_file_name = Path.Combine(Path.GetDirectoryName(ProjectFactory.Instance.CurrentProject.Path),frm.FileName); string full_file_name = Path.Combine(Path.GetDirectoryName(ProjectFactory.Instance.CurrentProject.Path),frm.FileName);
StreamWriter sw = File.CreateText(full_file_name); StreamWriter sw = File.CreateText(full_file_name);
ILanguageInformation languageInfo = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtension(frm.FileName).LanguageInformation; var languageIntellisenseSupport = Languages.Facade.LanguageProvider.Instance.SelectLanguageByExtension(frm.FileName).LanguageIntellisenseSupport;
if (frm.GetFileFilter() == FileType.Unit) if (frm.GetFileFilter() == FileType.Unit)
{ {
sw.Write(languageInfo.GetUnitTemplate(Path.GetFileNameWithoutExtension(frm.FileName))); sw.Write(languageIntellisenseSupport.GetUnitTemplate(Path.GetFileNameWithoutExtension(frm.FileName)));
} }
else else
{ {

View file

@ -53,7 +53,7 @@ namespace VisualPascalABC
public string Compile(PascalABCCompiler.IProjectInfo project, bool rebuild, string RuntimeServicesModule, bool ForRun, bool RunWithEnvironment) public string Compile(PascalABCCompiler.IProjectInfo project, bool rebuild, string RuntimeServicesModule, bool ForRun, bool RunWithEnvironment)
{ {
ProjectService.SaveProject(); ProjectService.SaveProject();
Workbench.WidgetController.CompilingButtonsEnabled = false; Workbench.WidgetController.CompilingAndRunButtonsEnabled = false;
Workbench.CompilerConsoleWindow.ClearConsole(); Workbench.CompilerConsoleWindow.ClearConsole();
CompilerOptions1.SourceFileName = project.Path; CompilerOptions1.SourceFileName = project.Path;
CompilerOptions1.OutputDirectory = project.OutputDirectory; CompilerOptions1.OutputDirectory = project.OutputDirectory;
@ -98,7 +98,7 @@ namespace VisualPascalABC
public string Compile(string FileName, bool rebuild, string RuntimeServicesModule, bool ForRun, bool RunWithEnvironment) public string Compile(string FileName, bool rebuild, string RuntimeServicesModule, bool ForRun, bool RunWithEnvironment)
{ {
Workbench.WidgetController.CompilingButtonsEnabled = false; Workbench.WidgetController.CompilingAndRunButtonsEnabled = false;
var UserOptions = Workbench.UserOptions; var UserOptions = Workbench.UserOptions;

View file

@ -94,7 +94,8 @@ namespace VisualPascalABC
} }
//CloseButtonsEnabled = OpenDocuments.Count > 1; //CloseButtonsEnabled = OpenDocuments.Count > 1;
ChangedSelectedTab(); ChangedSelectedTab();
if (FileName != null) // SS 09.08.08 if (FileName != null // SS 09.08.08
&& CodeCompletion.CodeCompletionController.IntellisenseAvailable())
WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(FileName); WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(FileName);
} }

View file

@ -95,7 +95,7 @@ namespace VisualPascalABC
case "string": case "string":
return false; return false;
} }
if (CodeCompletion.CodeCompletionController.CurrentParser == null) return false; if (!CodeCompletion.CodeCompletionController.IntellisenseAvailable()) return false;
List<Position> poses = CodeCompletionActionsManager.GetDefinitionPosition(CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea, true); List<Position> poses = CodeCompletionActionsManager.GetDefinitionPosition(CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea, true);
if (poses == null || poses.Count == 0) return false; if (poses == null || poses.Count == 0) return false;
foreach (Position pos in poses) foreach (Position pos in poses)

View file

@ -108,7 +108,7 @@ namespace VisualPascalABC
if (ProjectFactory.Instance.ProjectLoaded) if (ProjectFactory.Instance.ProjectLoaded)
tabPage = DocumentService.GetTabPageForMainFile(); tabPage = DocumentService.GetTabPageForMainFile();
if (attachdbg && !Workbench.UserOptions.AlwaysAttachDebuggerAtStart) if (attachdbg && !Workbench.UserOptions.AlwaysAttachDebuggerAtStart)
fictive_attach = !startWithGoto && !needFirstBreakpoint && !DebuggerManager.HasBreakpoints(); fictive_attach = !startWithGoto && !needFirstBreakpoint && !DebuggerManager.HasBreakpoints() || !CodeCompletion.CodeCompletionController.IntellisenseAvailable();
WorkbenchServiceFactory.OperationsService.ClearOutputTextBoxForTabPage(tabPage); WorkbenchServiceFactory.OperationsService.ClearOutputTextBoxForTabPage(tabPage);
Workbench.ErrorsListWindow.ClearErrorList(); Workbench.ErrorsListWindow.ClearErrorList();
//DesignerService.GenerateAllDesignersCode(); //DesignerService.GenerateAllDesignersCode();

View file

@ -27,7 +27,7 @@ namespace VisualPascalABC
void ButtonsEnableDisable_RunStart() void ButtonsEnableDisable_RunStart()
{ {
Workbench.WidgetController.SetStopEnabled(true); Workbench.WidgetController.SetStopEnabled(true);
Workbench.WidgetController.SetCompilingButtonsEnabled(false); Workbench.WidgetController.SetCompilingAndRunButtonsEnabled(false);
Workbench.WidgetController.SetDebugButtonsEnabled(false); Workbench.WidgetController.SetDebugButtonsEnabled(false);
Workbench.WidgetController.SetOptionsEnabled(false); Workbench.WidgetController.SetOptionsEnabled(false);
} }
@ -35,8 +35,9 @@ namespace VisualPascalABC
void ButtonsEnableDisable_RunStop() void ButtonsEnableDisable_RunStop()
{ {
Workbench.WidgetController.SetStopEnabled(false); Workbench.WidgetController.SetStopEnabled(false);
Workbench.WidgetController.SetCompilingButtonsEnabled(true); Workbench.WidgetController.SetCompilingAndRunButtonsEnabled(true);
Workbench.WidgetController.SetDebugButtonsEnabled(true); if (CodeCompletion.CodeCompletionController.IntellisenseAvailable())
Workbench.WidgetController.SetDebugButtonsEnabled(true);
Workbench.WidgetController.SetOptionsEnabled(true); Workbench.WidgetController.SetOptionsEnabled(true);
} }

View file

@ -22,10 +22,10 @@ namespace VisualPascalABC
internal List<DockContent> BottomDockContent = new List<DockContent>(); internal List<DockContent> BottomDockContent = new List<DockContent>();
List<DockContent> VisibleBottomContent = new List<DockContent>(); List<DockContent> VisibleBottomContent = new List<DockContent>();
public bool CompilingButtonsEnabled public bool CompilingAndRunButtonsEnabled
{ {
get { return miRun.Enabled; } get { return miRun.Enabled; }
set { SetCompilingButtonsEnabled(value); } set { SetCompilingAndRunButtonsEnabled(value); }
} }
bool SaveButtonsEnabled bool SaveButtonsEnabled
@ -100,18 +100,18 @@ namespace VisualPascalABC
set { miNavigForw.Enabled = tsNavigForw.Enabled = value; } set { miNavigForw.Enabled = tsNavigForw.Enabled = value; }
} }
public void SetDedugButtonsEnabled(bool Enabled) /// <summary>
/// Активировать/Деактивировать все кнопки, относящиеся к дебагу.
/// </summary>
public void SetDebugButtonsEnabled(bool Enabled)
{ {
if (!DebuggerVisible)
return;
StepIntoButton.Enabled = StepOverButton.Enabled = StartDebugButton.Enabled = StepIntoButton.Enabled = StepOverButton.Enabled = StartDebugButton.Enabled =
mDEBUGSTARTToolStripMenuItem.Enabled = mSTEPOVERToolStripMenuItem.Enabled = mSTEPINToolStripMenuItem.Enabled = mRUNTOCURToolStripMenuItem.Enabled = Enabled; mDEBUGSTARTToolStripMenuItem.Enabled = mSTEPOVERToolStripMenuItem.Enabled =
mSTEPINToolStripMenuItem.Enabled = mRUNTOCURToolStripMenuItem.Enabled = Enabled;
//toolStrip1.Refresh(); //toolStrip1.Refresh();
} }
bool BottomDockContentVisible bool BottomDockContentVisible
{ {
@ -322,7 +322,7 @@ namespace VisualPascalABC
} }
} }
public void SetCompilingButtonsEnabled(bool Enabled) public void SetCompilingAndRunButtonsEnabled(bool Enabled)
{ {
if (Enabled) if (Enabled)
{ {
@ -393,7 +393,7 @@ namespace VisualPascalABC
public void SetDebugStopEnabled() public void SetDebugStopEnabled()
{ {
SetCompilingButtonsEnabled(false); SetCompilingAndRunButtonsEnabled(false);
this.mDEBUGSTOPToolStripMenuItem.Enabled = true; this.mDEBUGSTOPToolStripMenuItem.Enabled = true;
this.mDEBUGENDToolStripMenuItem.Enabled = true; this.mDEBUGENDToolStripMenuItem.Enabled = true;
this.mSTEPToolStripMenuItem.Enabled = true; this.mSTEPToolStripMenuItem.Enabled = true;
@ -417,7 +417,7 @@ namespace VisualPascalABC
this.mDEBUGSTARTToolStripMenuItem.Text = Form1StringResources.Get("M_DEBUGSTART"); this.mDEBUGSTARTToolStripMenuItem.Text = Form1StringResources.Get("M_DEBUGSTART");
} }
public void SetStartDebugDisabled() public void SetStartDebugAndRunDisabled()
{ {
this.mDEBUGSTARTToolStripMenuItem.Enabled = false; this.mDEBUGSTARTToolStripMenuItem.Enabled = false;
this.StartDebugButton.Enabled = false; this.StartDebugButton.Enabled = false;
@ -434,7 +434,10 @@ namespace VisualPascalABC
SaveDebugContext(); SaveDebugContext();
} }
public void SetStartDebugEnabled() /// <summary>
/// Активирует кнопки для Debug и запуска программы
/// </summary>
public void SetStartDebugAndRunEnabled()
{ {
this.mDEBUGSTARTToolStripMenuItem.Enabled = true; this.mDEBUGSTARTToolStripMenuItem.Enabled = true;
this.StartDebugButton.Enabled = true; this.StartDebugButton.Enabled = true;
@ -444,6 +447,7 @@ namespace VisualPascalABC
this.StepOverButton.Enabled = true; this.StepOverButton.Enabled = true;
this.mRUNTOCURToolStripMenuItem.Enabled = true; this.mRUNTOCURToolStripMenuItem.Enabled = true;
this.mSTEPToolStripMenuItem.Enabled = true; this.mSTEPToolStripMenuItem.Enabled = true;
this.miRun.Enabled = true; this.miRun.Enabled = true;
this.StartButton.Enabled = true; this.StartButton.Enabled = true;
ChangeDebugButtons(false); ChangeDebugButtons(false);
@ -458,7 +462,7 @@ namespace VisualPascalABC
this.StepOutButton.Enabled = false; this.StepOutButton.Enabled = false;
if (!(clicked_stop_debug_in_menu && WorkbenchServiceFactory.RunService.IsRun() && debuggedPage != ActiveCodeFileDocument)) if (!(clicked_stop_debug_in_menu && WorkbenchServiceFactory.RunService.IsRun() && debuggedPage != ActiveCodeFileDocument))
{ {
SetCompilingButtonsEnabled(true); SetCompilingAndRunButtonsEnabled(true);
this.stopButton.Enabled = false; this.stopButton.Enabled = false;
this.miStop.Enabled = false; this.miStop.Enabled = false;
} }
@ -518,44 +522,17 @@ namespace VisualPascalABC
} }
} }
public void SetDebugButtonsEnabled(bool val) /// <summary>
/// Активировать/Деактивировать все кнопки, относящиеся к форматированию кода
/// </summary>
private void SetFormatButtonsEnabled(bool enabled)
{ {
if (!DebuggerVisible) tsFormat.Enabled = mFORMATToolStripMenuItem.Enabled = cmFormat.Enabled = enabled;
return; }
if (val)
{ private void SetRunButtonsEnabled(bool enabled)
this.mDEBUGSTOPToolStripMenuItem.Enabled = false; {
this.mDEBUGSTARTToolStripMenuItem.Enabled = false; miRun.Enabled = StartButton.Enabled = enabled;
this.StartDebugButton.Enabled = true;
this.StopDebugButton.Enabled = true;
this.StepOutButton.Enabled = false;
this.StepOverButton.Enabled = true;
this.StepIntoButton.Enabled = true;
this.mDEBUGSTARTToolStripMenuItem.Enabled = true;
this.mSTEPINToolStripMenuItem.Enabled = true;
this.mSTEPOVERToolStripMenuItem.Enabled = true;
this.mSTEPToolStripMenuItem.Enabled = false;
this.mRUNTOCURToolStripMenuItem.Enabled = true;
this.miRun.Enabled = true;
this.StartButton.Enabled = true;
}
else
{
this.mDEBUGSTOPToolStripMenuItem.Enabled = false;
this.mSTEPToolStripMenuItem.Enabled = false;
this.StartDebugButton.Enabled = false;
this.StopDebugButton.Enabled = false;
this.StepOutButton.Enabled = false;
this.StepOverButton.Enabled = false;
this.StepIntoButton.Enabled = false;
this.mDEBUGSTARTToolStripMenuItem.Enabled = false;
this.mSTEPINToolStripMenuItem.Enabled = false;
this.mSTEPOVERToolStripMenuItem.Enabled = false;
this.mRUNTOCURToolStripMenuItem.Enabled = false;
this.mSTEPToolStripMenuItem.Enabled = false;
this.miRun.Enabled = false;
this.StartButton.Enabled = false;
}
} }
bool mDEBUGSTOPToolStripMenuItem_Enabled; bool mDEBUGSTOPToolStripMenuItem_Enabled;

View file

@ -410,8 +410,19 @@ namespace VisualPascalABC
CurrentWebBrowserControl = null; CurrentWebBrowserControl = null;
SetFocusToEditor(); SetFocusToEditor();
} }
CodeCompletion.CodeCompletionController.SetLanguage(CurrentCodeFileDocument.FileName);
bool intellisenseAvailable = CodeCompletion.CodeCompletionController.IntellisenseAvailable();
SetFormatButtonsEnabled(intellisenseAvailable);
if (!intellisenseAvailable)
SetDebugButtonsEnabled(false); // активация кнопок произойдет ниже, если возможно
if (BakSelectedTab == CurrentCodeFileDocument) if (BakSelectedTab == CurrentCodeFileDocument)
return; return;
LastSelectedTab = BakSelectedTab; LastSelectedTab = BakSelectedTab;
BakSelectedTab = CurrentCodeFileDocument; BakSelectedTab = CurrentCodeFileDocument;
@ -432,8 +443,6 @@ namespace VisualPascalABC
OutputWindow.outputTextBox = OutputTextBoxs[CurrentCodeFileDocument]; OutputWindow.outputTextBox = OutputTextBoxs[CurrentCodeFileDocument];
} }
CodeCompletion.CodeCompletionController.SetLanguage(CurrentCodeFileDocument.FileName);
SetFocusToEditor(); SetFocusToEditor();
bool run = WorkbenchServiceFactory.RunService.IsRun(CurrentEXEFileName); bool run = WorkbenchServiceFactory.RunService.IsRun(CurrentEXEFileName);
WorkbenchServiceFactory.DebuggerManager.SetAsPossibleDebugPage(CurrentCodeFileDocument); WorkbenchServiceFactory.DebuggerManager.SetAsPossibleDebugPage(CurrentCodeFileDocument);
@ -447,16 +456,16 @@ namespace VisualPascalABC
if (VisualEnvironmentCompiler != null) if (VisualEnvironmentCompiler != null)
if (!debug) if (!debug)
{ {
SetCompilingButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded); SetCompilingAndRunButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded);
SetDebugButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded); SetDebugButtonsEnabled(intellisenseAvailable && !run && VisualEnvironmentCompiler.compilerLoaded);
} }
else else
{ {
SetCompilingButtonsEnabled(!debug); SetCompilingAndRunButtonsEnabled(!debug);
SetDebugButtonsAsByDebug(); SetDebugButtonsAsByDebug();
} }
else else
SetCompilingButtonsEnabled(false); SetCompilingAndRunButtonsEnabled(false);
SaveButtonsEnabled = CurrentCodeFileDocument.DocumentChanged; SaveButtonsEnabled = CurrentCodeFileDocument.DocumentChanged;
UpdateUndoRedoEnabled(); UpdateUndoRedoEnabled();
UpdateCutCopyButtonsEnabled(); UpdateCutCopyButtonsEnabled();

View file

@ -1,5 +1,5 @@
### Шаг 1 ### Шаг 1
Необходимо создать папку, называющуюся так же, как Ваш язык в папке *AdditionalLanguages*, расположенной в корне репозитория. Далее создать в ней два обязательных проекта. Это проект парсера Вашего языка, а также проект, содержащий класс Вашего языка (унаследованный от класса `BaseLanguage`, находящегося в стандартном проекте `LanguageIntegrator`) и класс "базы данных" языка (унаследованный от класса `BaseLanguageInformation` из проекта `ParserTools`). Необходимо создать папку, называющуюся так же, как Ваш язык в папке *AdditionalLanguages*, расположенной в корне репозитория. Далее создать в ней два обязательных проекта. Это проект парсера Вашего языка, а также проект, содержащий класс Вашего языка (унаследованный от класса `BaseLanguage`, находящегося в стандартном проекте `LanguageIntegrator`) и класс "базы данных" языка (унаследованный от класса `DefaultLanguageInformation` или напрямую от интерфейса `ILanguageInformation` из проекта `ParserTools`).
Для совместимости целевой платформой Ваших проектов должна быть *.NET Framework 4.0*. В свойствах проекта и для Release, и для Debug версии должен быть выбран выходной путь `..\..\..\bin\`. Для совместимости целевой платформой Ваших проектов должна быть *.NET Framework 4.0*. В свойствах проекта и для Release, и для Debug версии должен быть выбран выходной путь `..\..\..\bin\`.
@ -9,30 +9,32 @@
### Шаг 2 ### Шаг 2
В проекты Вы добавляете все необходимые для работы ссылки. Вам точно понадобятся ссылки на проекты `ParserTools`, `Errors`, `SyntaxTree` в проекте Вашего парсера и на проекты `LanguageIntegrator`, `ParserTools`, `SyntaxTree` в проекте с наследником `BaseLanguage`. В проекты Вы добавляете все необходимые для работы ссылки. Вам точно понадобятся ссылки на проекты `ParserTools`, `Errors`, `SyntaxTree` в проекте Вашего парсера и на проекты `LanguageIntegrator`, `ParserTools`, `SyntaxTree` в проекте с наследником `BaseLanguage`.
### Шаг 3 ### Шаг 3
Вам нужно унаследовать Ваш парсер (который является оберткой над GPPG парсером) от класса `BaseParser`, либо напрямую реализовать интерфейс `IParser`, если Вы не хотите пользоваться функциональностью из `BaseParser`. Вам нужно унаследовать Ваш парсер (который является оберткой над GPPG парсером) от класса `BaseParser`, либо от класса `SimpleParser`, если Вы не хотите на начальном этапе реализовывать методы парсера для поддержки Intellisense.
Класс `BaseParser` содержит абстрактные методы, обязательные к реализации, самый главный из которых называется `BuildTreeInNormalMode`. Он отвечает за построение синтаксического дерева программы при обычном процессе компиляции. Остальные методы относятся к *Intellisense* и их реализация может быть пустой на первое время. Класс `BaseParser` содержит абстрактные методы, обязательные к реализации, самый главный из которых называется `BuildTreeInNormalMode`. Он отвечает за построение синтаксического дерева программы при обычном процессе компиляции. Остальные методы в основном относятся к *Intellisense*.
Для реализации `BuildTreeInNormalMode` Вам потребуется вызвать в этом методе сгенерированный GPPG парсер Вашего языка. Возвращаемое значение должно быть корнем полученного в результате парсинга синтаксического дерева. Для реализации `BuildTreeInNormalMode` Вам потребуется вызвать в этом методе сгенерированный GPPG парсер Вашего языка. Возвращаемое значение должно быть корнем полученного в результате парсинга синтаксического дерева.
Для реализации парсера Вы можете также использовать такие базовые абстрактные классы как `BaseKeywords` и `BaseParserTools`. Для реализации парсера Вы можете также использовать такие базовые абстрактные классы как `BaseKeywords` и `BaseParserTools`.
### Шаг 4 ### Шаг 4
Для реализации методов в наследнике `BaseLanguageInformation` на первое время можно взять методы из `PascalABCLanguageInformation`, они используются в системе *Intellisense*. Но Вам также нужно задать следующие параметры языка: Для реализации свойств в наследнике `DefaultLanguageInformation` Вам нужно задать следующие параметры языка:
1) имя языка, версия языка, строка с указанием авторских прав 1) имя языка, версия языка, строка с указанием авторских прав
2) расширения файлов Вашего языка 2) расширения файлов Вашего языка
3) имена стандартных модулей языка 3) имена стандартных модулей языка
4) чувствительность к регистру 4) чувствительность к регистру
и т. д. и т. д.
Обращайте внимание на документирующие комментарии к свойствам.
### Шаг 5 ### Шаг 5
В сделанном Вами наследнике `BaseLanguage` Вы пишете конструктор, который передает в `base()` следующие параметры: В сделанном Вами наследнике `BaseLanguage` Вы пишете конструктор, который передает в `base()` следующие параметры:
1) класс "базы данных" языка, хранящий информацию в основном необходимую для Intellisense (наследник `BaseLanguageInformation`). 1) класс "базы данных" языка, хранящий информацию в основном необходимую для Intellisense (наследник `DefaultLanguageInformation`).
2) парсер Вашего языка (наследник `BaseParser`) 2) класс с методами для поддержки Intellisense (если его нет, можно передавать `null`)
3) парсер XML-комментариев (если его нет, то можно передавать `null`) 3) парсер Вашего языка (наследник `BaseParser`)
4) список преобразователей синтаксического дерева с одним обязательным элементом (для него можно взять стандартную базовую версию под названием `DefaultSyntaxTreeConverter`) 4) парсер XML-комментариев (если его нет, то можно передавать `null`)
5) список преобразователей синтаксического дерева с одним обязательным элементом (для него можно взять стандартную базовую версию под названием `DefaultSyntaxTreeConverter`)
Также Вы реализуете метод `SetSemanticConstants`, в котором задаете необходимые параметры (значения переменных) из файла *SemanticRulesConstants.cs* (проект TreeConverter). При необходимости Вы можете переопределить метод `SetSemanticConstants`, в котором нужно задавать необходимые параметры (значения переменных) из файла *SemanticRulesConstants.cs* (проект TreeConverter). Для простого языка этого может не потребоваться.
И наконец, реализуете метод `SetSyntaxTreeToSemanticTreeConverter`, в котором создаете новый экземпляр преобразователя синтаксического дерева в семантическое (присваиваете его свойству `SyntaxTreeToSemanticTreeConverter`). Для простых языков в качестве преобразователя можно присваивать И наконец, реализуете метод `SetSyntaxTreeToSemanticTreeConverter`, в котором создаете новый экземпляр преобразователя синтаксического дерева в семантическое (присваиваете его свойству `SyntaxTreeToSemanticTreeConverter`). Для простых языков в качестве преобразователя можно присваивать
экземпляр класса `syntax_tree_visitor`, получив его следующим образом: `LanguageProvider.Instance.MainLanguage.SyntaxTreeToSemanticTreeConverter`. экземпляр класса `syntax_tree_visitor`, получив его следующим образом: `LanguageProvider.Instance.MainLanguage.SyntaxTreeToSemanticTreeConverter`.