Исправление неправильных изменений в LanguageInformation (#3319)
* Fix inaccuracy * Delete useless variable * Implement refreshing description before showing it in Intellisense windows * Fix inaccuracies * Add GetDescriptionForArray and GetDescriptionForDelegate in SPythonLanguageInfo
This commit is contained in:
parent
9e9a0469b3
commit
20a1436129
|
|
@ -819,13 +819,13 @@ namespace Languages.SPython.Frontend.Data
|
|||
return false;
|
||||
}
|
||||
|
||||
public override string FindExpressionFromAnyPosition(int off, string Text, int line, int col, out string expr_without_brackets)
|
||||
public override string FindExpressionFromAnyPosition(int off, string Text, int line, int col, out KeywordKind keyw, out string expr_without_brackets)
|
||||
{
|
||||
int i = off - 1;
|
||||
|
||||
// это например вызов метода без параметров
|
||||
expr_without_brackets = null;
|
||||
var keyw = KeywordKind.None;
|
||||
keyw = KeywordKind.None;
|
||||
if (i < 0)
|
||||
return "";
|
||||
bool is_char = false;
|
||||
|
|
@ -1029,135 +1029,25 @@ namespace Languages.SPython.Frontend.Data
|
|||
{
|
||||
case ScopeKind.Type: return GetDescriptionForType(scope as ITypeScope);
|
||||
case ScopeKind.CompiledType: return GetDescriptionForCompiledType(scope as ICompiledTypeScope);
|
||||
case ScopeKind.Delegate: return GetDescriptionForDelegate(scope as IProcType);
|
||||
case ScopeKind.Procedure: return GetDescriptionForProcedure(scope as IProcScope);
|
||||
case ScopeKind.ElementScope: return GetDescriptionForElementScope(scope as IElementScope);
|
||||
case ScopeKind.TypeSynonim: return GetSynonimDescription(scope as ITypeSynonimScope);
|
||||
case ScopeKind.Namespace: return GetDescriptionForNamespace(scope as INamespaceScope);
|
||||
case ScopeKind.CompiledMethod: return GetDescriptionForCompiledMethod(scope as ICompiledMethodScope);
|
||||
|
||||
/*case ScopeKind.Array: return GetDescriptionForArray(scope as IArrayScope);
|
||||
case ScopeKind.Enum: return GetDescriptionForEnum(scope as IEnumScope);
|
||||
case ScopeKind.Set: return GetDescriptionForSet(scope as ISetScope);
|
||||
case ScopeKind.Array: return GetDescriptionForArray(scope as IArrayScope);
|
||||
|
||||
|
||||
|
||||
/*case ScopeKind.Set: return GetDescriptionForSet(scope as ISetScope);
|
||||
|
||||
case ScopeKind.CompiledField: return GetDescriptionForCompiledField(scope as ICompiledFieldScope);
|
||||
case ScopeKind.CompiledProperty: return GetDescriptionForCompiledProperty(scope as ICompiledPropertyScope);
|
||||
|
||||
|
||||
case ScopeKind.CompiledConstructor: return GetDescriptionForCompiledConstructor(scope as ICompiledConstructorScope);*/
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected string GetDescriptionForProcedure(IProcScope scope)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
string extensionType = null;
|
||||
if (scope.IsExtension && scope.Parameters.Length > 0)
|
||||
{
|
||||
extensionType = GetSimpleDescription(scope.Parameters[0].Type);
|
||||
}
|
||||
if (scope.IsExtension)
|
||||
{
|
||||
if (extensionType != null && extensionType.IndexOf(' ') != -1)
|
||||
{
|
||||
sb.Append("(" + PascalABCCompiler.StringResources.Get("CODE_COMPLETION_EXTENSION") + " " + extensionType + ") ");
|
||||
extensionType = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("(" + PascalABCCompiler.StringResources.Get("CODE_COMPLETION_EXTENSION") + ") ");
|
||||
}
|
||||
}
|
||||
|
||||
if (scope.IsStatic) sb.Append("static ");
|
||||
if (scope.IsConstructor())
|
||||
sb.Append("constructor ");
|
||||
else
|
||||
sb.Append("def ");
|
||||
/*if (scope.ReturnType == null)
|
||||
sb.Append("procedure ");
|
||||
else
|
||||
sb.Append("function ");*/
|
||||
if (!scope.IsConstructor())
|
||||
{
|
||||
if (extensionType != null)
|
||||
{
|
||||
sb.Append(extensionType + ".");
|
||||
sb.Append(scope.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(GetTopScopeName(scope.TopScope));
|
||||
sb.Append(scope.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(GetTopScopeNameWithoutDot(scope.TopScope));
|
||||
}
|
||||
|
||||
sb.Append(GetGenericString(scope.TemplateParameters));
|
||||
sb.Append('(');
|
||||
IElementScope[] parameters = scope.Parameters;
|
||||
for (int i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
if (scope.IsExtension && i == 0)
|
||||
continue;
|
||||
sb.Append(GetSimpleDescription(parameters[i]));
|
||||
if (i < parameters.Length - 1)
|
||||
{
|
||||
sb.Append("; ");
|
||||
}
|
||||
}
|
||||
sb.Append(')');
|
||||
if (scope.ReturnType != null && !scope.IsConstructor() && !(scope.ReturnType is IProcType && (scope.ReturnType as IProcType).Target == scope))
|
||||
sb.Append(" " + ReturnTypeDelimiter + " " + GetSimpleDescription(scope.ReturnType));
|
||||
//if (scope.IsStatic) sb.Append("; static");
|
||||
if (scope.IsVirtual) sb.Append("; ");
|
||||
else if (scope.IsAbstract) sb.Append("; abstract");
|
||||
else if (scope.IsOverride) sb.Append("; override");
|
||||
else if (scope.IsReintroduce) sb.Append("; reintroduce");
|
||||
sb.Append(';');
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected string GetDescriptionForElementScope(IElementScope scope)
|
||||
{
|
||||
string type_name = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (scope.Type == null) type_name = "";
|
||||
else
|
||||
type_name = GetSimpleDescription(scope.Type);
|
||||
if (type_name.StartsWith("$"))
|
||||
type_name = type_name.Substring(1, type_name.Length - 1);
|
||||
switch (scope.ElemKind)
|
||||
{
|
||||
case SymbolKind.Variable: sb.Append("var " + GetTopScopeName(scope.TopScope) + scope.Name + ((type_name != "") ? ": " + type_name : "")); break;
|
||||
case SymbolKind.Parameter: sb.Append(kind_of_param(scope) + "parameter " + scope.Name + ": " + type_name + (scope.ConstantValue != null ? (":=" + scope.ConstantValue.ToString()) : "")); break;
|
||||
case SymbolKind.Field:
|
||||
if (scope.IsStatic)
|
||||
sb.Append("static ");
|
||||
else
|
||||
sb.Append("var ");
|
||||
sb.Append(GetTopScopeName(scope.TopScope) + scope.Name + ": " + type_name);
|
||||
// append_modifiers(sb, scope);
|
||||
//if (scope.IsStatic) sb.Append("; static");
|
||||
if (scope.IsReadOnly) sb.Append("; readonly");
|
||||
break;
|
||||
|
||||
}
|
||||
sb.Append(';');
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected override string kind_of_param(IElementScope scope)
|
||||
{
|
||||
switch (scope.ParamKind)
|
||||
{
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.const_parametr: return "const ";
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.var_parametr: return "var ";
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.params_parametr: return "params ";
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.out_parametr: return "out ";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
@ -1328,6 +1218,7 @@ namespace Languages.SPython.Frontend.Data
|
|||
{
|
||||
case ScopeKind.Type: return GetSimpleDescriptionForType(scope as ITypeScope);
|
||||
case ScopeKind.CompiledType: return GetSimpleDescriptionForCompiledType(scope as ICompiledTypeScope, false);
|
||||
case ScopeKind.Delegate: return GetDescriptionForDelegate(scope as IProcType);
|
||||
case ScopeKind.Procedure: return GetSimpleDescriptionForProcedure(scope as IProcScope);
|
||||
case ScopeKind.ElementScope: return GetSimpleDescriptionForElementScope(scope as IElementScope);
|
||||
case ScopeKind.TypeSynonim: return GetSimpleSynonimDescription(scope as ITypeSynonimScope);
|
||||
|
|
@ -1335,8 +1226,9 @@ namespace Languages.SPython.Frontend.Data
|
|||
case ScopeKind.UnitInterface: return GetDescriptionForModule(scope as IInterfaceUnitScope);
|
||||
case ScopeKind.Namespace: return GetDescriptionForNamespace(scope as INamespaceScope);
|
||||
case ScopeKind.CompiledMethod: return GetDescriptionForCompiledMethod(scope as ICompiledMethodScope);
|
||||
case ScopeKind.Enum: return GetDescriptionForEnum(scope as IEnumScope);
|
||||
|
||||
/*case ScopeKind.Enum: return GetDescriptionForEnum(scope as IEnumScope);
|
||||
/*
|
||||
case ScopeKind.Set: return GetDescriptionForSet(scope as ISetScope);
|
||||
|
||||
case ScopeKind.CompiledField: return GetDescriptionForCompiledField(scope as ICompiledFieldScope);
|
||||
|
|
@ -1368,88 +1260,6 @@ namespace Languages.SPython.Frontend.Data
|
|||
return scope.Name;
|
||||
}
|
||||
|
||||
protected string GetDescriptionForArray(IArrayScope scope)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("array");
|
||||
ITypeScope[] inds = scope.Indexers;
|
||||
if (!scope.IsDynamic)
|
||||
{
|
||||
sb.Append('[');
|
||||
for (int i = 0; i < inds.Length; i++)
|
||||
{
|
||||
sb.Append(GetSimpleDescription(inds[i]));
|
||||
if (i < inds.Length - 1) sb.Append(',');
|
||||
}
|
||||
sb.Append(']');
|
||||
}
|
||||
if (scope.ElementType != null)
|
||||
{
|
||||
string s = GetSimpleDescription(scope.ElementType);
|
||||
if (s.Length > 0 && s[0] == '$') s = s.Substring(1, s.Length - 1);
|
||||
sb.Append(" of " + s);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string GetSimpleDescriptionForCompiledType(ICompiledTypeScope scope, bool fullName)
|
||||
{
|
||||
if (scope.CompiledType.Name != null && scope.CompiledType.Name.Contains("Func`"))
|
||||
{
|
||||
return getLambdaRepresentation(scope, true);
|
||||
}
|
||||
else if (scope.CompiledType.Name != null && scope.CompiledType.Name.Contains("Action`"))
|
||||
{
|
||||
return getLambdaRepresentation(scope, false);
|
||||
}
|
||||
else if (scope.CompiledType.Name != null && scope.CompiledType.Name.Contains("Predicate`1"))
|
||||
{
|
||||
return getLambdaRepresentation(scope, false);
|
||||
}
|
||||
if (scope.CompiledType.Name == "IEnumerable`1")
|
||||
{
|
||||
ITypeScope[] instances = scope.GenericInstances;
|
||||
if (instances != null && instances.Length > 0)
|
||||
{
|
||||
return "sequence of " + GetSimpleDescriptionWithoutNamespace(instances[0]);
|
||||
}
|
||||
else
|
||||
return "sequence of T";
|
||||
}
|
||||
else if (scope.CompiledType.Name != null && scope.CompiledType.Name.Contains("Tuple`"))
|
||||
{
|
||||
ITypeScope[] instances = scope.GenericInstances;
|
||||
if (instances != null && instances.Length > 0)
|
||||
{
|
||||
return get_tuple_string(instances);
|
||||
}
|
||||
else
|
||||
return "(T1,...)";
|
||||
}
|
||||
else
|
||||
{
|
||||
string s = !fullName ? GetShortTypeName(scope.CompiledType) : GetFullTypeName(scope.CompiledType);
|
||||
ITypeScope[] instances = scope.GenericInstances;
|
||||
if (instances != null && instances.Length > 0)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
int ind = s.IndexOf(GenericTypesStartBracket);
|
||||
if (ind != -1) sb.Append(s.Substring(0, ind));
|
||||
else
|
||||
sb.Append(s);
|
||||
sb.Append(GenericTypesStartBracket);
|
||||
for (int i = 0; i < instances.Length; i++)
|
||||
{
|
||||
sb.Append(GetSimpleDescriptionWithoutNamespace(instances[i]));
|
||||
if (i < instances.Length - 1) sb.Append(", ");
|
||||
}
|
||||
sb.Append(GenericTypesEndBracket);
|
||||
s = sb.ToString();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetStandardTypeByKeyword(KeywordKind keyw)
|
||||
{
|
||||
switch (keyw)
|
||||
|
|
|
|||
|
|
@ -65,14 +65,13 @@ namespace PascalABCCompiler.Parsers
|
|||
// перенести сюда реализацию EVA
|
||||
public abstract string FindExpressionForMethod(int off, string Text, int line, int col, char pressed_key, ref int num_param);
|
||||
|
||||
public string FindExpressionFromAnyPosition(int off, string Text, int line, int col, out KeywordKind keyw, out string expr_without_brackets)
|
||||
public string FindExpressionFromAnyPosition(int off, string Text, int line, int col, out string expr_without_brackets)
|
||||
{
|
||||
keyw = KeywordKind.None;
|
||||
return FindExpressionFromAnyPosition(off, Text, line, col, out expr_without_brackets);
|
||||
return FindExpressionFromAnyPosition(off, Text, line, col, out _, out expr_without_brackets);
|
||||
}
|
||||
|
||||
// перенести сюда реализацию EVA
|
||||
public abstract string FindExpressionFromAnyPosition(int off, string Text, int line, int col, out string expr_without_brackets);
|
||||
public abstract string FindExpressionFromAnyPosition(int off, string Text, int line, int col, out KeywordKind keyw, out string expr_without_brackets);
|
||||
|
||||
public virtual string FindOnlyIdentifier(int off, string Text, int line, int col, ref string name)
|
||||
{
|
||||
|
|
@ -216,7 +215,7 @@ namespace PascalABCCompiler.Parsers
|
|||
sb.Append(GetSimpleDescription(parameters[i]));
|
||||
if (i < parameters.Length - 1)
|
||||
{
|
||||
sb.Append("; ");
|
||||
sb.Append(ParameterDelimiter + " ");
|
||||
}
|
||||
}
|
||||
sb.Append(')');
|
||||
|
|
@ -287,6 +286,150 @@ namespace PascalABCCompiler.Parsers
|
|||
}
|
||||
}
|
||||
|
||||
protected string GetDescriptionForEnum(IEnumScope scope)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
sb.Append('(');
|
||||
for (int i = 0; i < scope.EnumConsts.Length; i++)
|
||||
{
|
||||
sb.Append(scope.EnumConsts[i]);
|
||||
if (i < scope.EnumConsts.Length - 1)
|
||||
sb.Append(',');
|
||||
if (i >= 2)
|
||||
{
|
||||
sb.Append("...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
sb.Append(')');
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private void append_modifiers(StringBuilder sb, IElementScope scope)
|
||||
{
|
||||
if (scope.IsVirtual) sb.Append("; ");
|
||||
if (scope.IsAbstract) sb.Append("; abstract");
|
||||
if (scope.IsOverride) sb.Append("; override");
|
||||
//if (scope.IsStatic) sb.Append("; static");
|
||||
if (scope.IsReintroduce) sb.Append("; reintroduce");
|
||||
}
|
||||
|
||||
protected string get_index_description(IElementScope scope)
|
||||
{
|
||||
ITypeScope[] indexers = scope.Indexers;
|
||||
if (indexers == null || indexers.Length == 0) return "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append('[');
|
||||
for (int i = 0; i < indexers.Length; i++)
|
||||
{
|
||||
sb.Append(GetSimpleDescription(indexers[i]));
|
||||
if (i < indexers.Length - 1)
|
||||
sb.Append(',');
|
||||
}
|
||||
sb.Append(']');
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected string GetDescriptionForElementScope(IElementScope scope)
|
||||
{
|
||||
string type_name = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (scope.Type == null) type_name = "";
|
||||
else
|
||||
type_name = GetSimpleDescription(scope.Type);
|
||||
if (type_name.StartsWith("$"))
|
||||
type_name = type_name.Substring(1, type_name.Length - 1);
|
||||
switch (scope.ElemKind)
|
||||
{
|
||||
case SymbolKind.Variable: sb.Append("var " + GetTopScopeName(scope.TopScope) + scope.Name + ((type_name != "") ? ": " + type_name : "")); break;
|
||||
case SymbolKind.Parameter: sb.Append(kind_of_param(scope) + "parameter " + scope.Name + ": " + type_name + (scope.ConstantValue != null ? (":=" + scope.ConstantValue.ToString()) : "")); break;
|
||||
case SymbolKind.Constant:
|
||||
{
|
||||
if (scope.ConstantValue == null)
|
||||
sb.Append("const " + GetTopScopeName(scope.TopScope) + scope.Name + ": " + type_name);
|
||||
else sb.Append("const " + GetTopScopeName(scope.TopScope) + scope.Name + ": " + type_name + " = " + scope.ConstantValue.ToString());
|
||||
}
|
||||
break;
|
||||
case SymbolKind.Event:
|
||||
if (scope.IsStatic) sb.Append("static ");
|
||||
sb.Append("event " + GetTopScopeName(scope.TopScope) + scope.Name + ": " + type_name);
|
||||
append_modifiers(sb, scope);
|
||||
break;
|
||||
case SymbolKind.Field:
|
||||
if (scope.IsStatic)
|
||||
sb.Append("static ");
|
||||
else
|
||||
sb.Append("var ");
|
||||
sb.Append(GetTopScopeName(scope.TopScope) + scope.Name + ": " + type_name);
|
||||
append_modifiers(sb, scope);
|
||||
//if (scope.IsStatic) sb.Append("; static");
|
||||
if (scope.IsReadOnly) sb.Append("; readonly");
|
||||
break;
|
||||
case SymbolKind.Property:
|
||||
if (scope.IsStatic)
|
||||
sb.Append("static ");
|
||||
sb.Append("property " + GetTopScopeName(scope.TopScope) + scope.Name + get_index_description(scope) + ": " + type_name);
|
||||
if (scope.IsReadOnly)
|
||||
sb.Append("; readonly");
|
||||
append_modifiers(sb, scope);
|
||||
break;
|
||||
|
||||
}
|
||||
sb.Append(';');
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected string GetDescriptionForArray(IArrayScope scope)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("array");
|
||||
ITypeScope[] inds = scope.Indexers;
|
||||
if (!scope.IsDynamic)
|
||||
{
|
||||
sb.Append('[');
|
||||
for (int i = 0; i < inds.Length; i++)
|
||||
{
|
||||
sb.Append(GetSimpleDescription(inds[i]));
|
||||
if (i < inds.Length - 1) sb.Append(',');
|
||||
}
|
||||
sb.Append(']');
|
||||
}
|
||||
if (scope.ElementType != null)
|
||||
{
|
||||
string s = GetSimpleDescription(scope.ElementType);
|
||||
if (s.Length > 0 && s[0] == '$') s = s.Substring(1, s.Length - 1);
|
||||
sb.Append(" of " + s);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected string GetDescriptionForDelegate(IProcType t)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (t.Target.ReturnType != null || ProcedureName == null)
|
||||
sb.Append(FunctionName);
|
||||
else sb.Append(ProcedureName);
|
||||
IElementScope[] prms = t.Target.Parameters;
|
||||
if (prms.Length > 0)
|
||||
{
|
||||
sb.Append('(');
|
||||
for (int i = 0; i < prms.Length; i++)
|
||||
{
|
||||
sb.Append(GetSimpleDescription(prms[i]));
|
||||
if (i < prms.Length - 1)
|
||||
{
|
||||
sb.Append(ParameterDelimiter + " ");
|
||||
}
|
||||
}
|
||||
sb.Append(')');
|
||||
}
|
||||
if (t.Target.ReturnType != null)
|
||||
{
|
||||
sb.Append(ReturnTypeDelimiter + " " + GetSimpleDescription(t.Target.ReturnType));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public abstract string GetKeyword(SymbolKind kind);
|
||||
|
||||
public KeywordKind GetKeywordKind(string name)
|
||||
|
|
@ -738,7 +881,17 @@ namespace PascalABCCompiler.Parsers
|
|||
return sc.Name;
|
||||
}
|
||||
|
||||
protected abstract string kind_of_param(IElementScope scope);
|
||||
protected string kind_of_param(IElementScope scope)
|
||||
{
|
||||
switch (scope.ParamKind)
|
||||
{
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.const_parametr: return "const ";
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.var_parametr: return "var ";
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.params_parametr: return "params ";
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.out_parametr: return "out ";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected string GetSimpleDescriptionForElementScope(IElementScope scope)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -796,12 +796,7 @@ namespace PascalABCCompiler.Parsers
|
|||
}
|
||||
|
||||
public interface IArrayScope : ITypeScope
|
||||
{
|
||||
ITypeScope[] Indexers
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
{
|
||||
bool IsDynamic
|
||||
{
|
||||
get;
|
||||
|
|
|
|||
|
|
@ -342,33 +342,6 @@ namespace Languages.Pascal.Frontend.Data
|
|||
return null;
|
||||
}
|
||||
|
||||
protected string GetDescriptionForDelegate(IProcType t)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (t.Target.ReturnType != null)
|
||||
sb.Append("function");
|
||||
else sb.Append("procedure");
|
||||
IElementScope[] prms = t.Target.Parameters;
|
||||
if (prms.Length > 0)
|
||||
{
|
||||
sb.Append('(');
|
||||
for (int i = 0; i < prms.Length; i++)
|
||||
{
|
||||
sb.Append(GetSimpleDescription(prms[i]));
|
||||
if (i < prms.Length - 1)
|
||||
{
|
||||
sb.Append("; ");
|
||||
}
|
||||
}
|
||||
sb.Append(')');
|
||||
}
|
||||
if (t.Target.ReturnType != null)
|
||||
{
|
||||
sb.Append(ReturnTypeDelimiter + " " + GetSimpleDescription(t.Target.ReturnType));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected override string GetFullTypeName(Type ctn, bool no_alias = true)
|
||||
{
|
||||
TypeCode tc = Type.GetTypeCode(ctn);
|
||||
|
|
@ -1013,30 +986,6 @@ namespace Languages.Pascal.Frontend.Data
|
|||
return s;
|
||||
}
|
||||
|
||||
protected string GetDescriptionForArray(IArrayScope scope)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("array");
|
||||
ITypeScope[] inds = scope.Indexers;
|
||||
if (!scope.IsDynamic)
|
||||
{
|
||||
sb.Append('[');
|
||||
for (int i = 0; i < inds.Length; i++)
|
||||
{
|
||||
sb.Append(GetSimpleDescription(inds[i]));
|
||||
if (i < inds.Length - 1) sb.Append(',');
|
||||
}
|
||||
sb.Append(']');
|
||||
}
|
||||
if (scope.ElementType != null)
|
||||
{
|
||||
string s = GetSimpleDescription(scope.ElementType);
|
||||
if (s.Length > 0 && s[0] == '$') s = s.Substring(1, s.Length - 1);
|
||||
sb.Append(" of " + s);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected string GetDescriptionForDiapason(IDiapasonScope scope)
|
||||
{
|
||||
return scope.Left.ToString() + ".." + scope.Right.ToString();
|
||||
|
|
@ -1077,25 +1026,6 @@ namespace Languages.Pascal.Frontend.Data
|
|||
return s;
|
||||
}
|
||||
|
||||
protected string GetDescriptionForEnum(IEnumScope scope)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
sb.Append('(');
|
||||
for (int i = 0; i < scope.EnumConsts.Length; i++)
|
||||
{
|
||||
sb.Append(scope.EnumConsts[i]);
|
||||
if (i < scope.EnumConsts.Length - 1)
|
||||
sb.Append(',');
|
||||
if (i >= 2)
|
||||
{
|
||||
sb.Append("...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
sb.Append(')');
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected string GetDescriptionForSet(ISetScope scope)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
|
|
@ -1109,92 +1039,6 @@ namespace Languages.Pascal.Frontend.Data
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected override string kind_of_param(IElementScope scope)
|
||||
{
|
||||
switch (scope.ParamKind)
|
||||
{
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.const_parametr: return "const ";
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.var_parametr: return "var ";
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.params_parametr: return "params ";
|
||||
case PascalABCCompiler.SyntaxTree.parametr_kind.out_parametr: return "out ";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected string get_index_description(IElementScope scope)
|
||||
{
|
||||
ITypeScope[] indexers = scope.Indexers;
|
||||
if (indexers == null || indexers.Length == 0) return "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append('[');
|
||||
for (int i = 0; i < indexers.Length; i++)
|
||||
{
|
||||
sb.Append(GetSimpleDescription(indexers[i]));
|
||||
if (i < indexers.Length - 1)
|
||||
sb.Append(',');
|
||||
}
|
||||
sb.Append(']');
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private void append_modifiers(StringBuilder sb, IElementScope scope)
|
||||
{
|
||||
if (scope.IsVirtual) sb.Append("; ");
|
||||
if (scope.IsAbstract) sb.Append("; abstract");
|
||||
if (scope.IsOverride) sb.Append("; override");
|
||||
//if (scope.IsStatic) sb.Append("; static");
|
||||
if (scope.IsReintroduce) sb.Append("; reintroduce");
|
||||
}
|
||||
|
||||
protected string GetDescriptionForElementScope(IElementScope scope)
|
||||
{
|
||||
string type_name = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (scope.Type == null) type_name = "";
|
||||
else
|
||||
type_name = GetSimpleDescription(scope.Type);
|
||||
if (type_name.StartsWith("$"))
|
||||
type_name = type_name.Substring(1, type_name.Length - 1);
|
||||
switch (scope.ElemKind)
|
||||
{
|
||||
case SymbolKind.Variable: sb.Append("var " + GetTopScopeName(scope.TopScope) + scope.Name + ((type_name != "") ? ": " + type_name : "")); break;
|
||||
case SymbolKind.Parameter: sb.Append(kind_of_param(scope) + "parameter " + scope.Name + ": " + type_name + (scope.ConstantValue != null ? (":=" + scope.ConstantValue.ToString()) : "")); break;
|
||||
case SymbolKind.Constant:
|
||||
{
|
||||
if (scope.ConstantValue == null)
|
||||
sb.Append("const " + GetTopScopeName(scope.TopScope) + scope.Name + ": " + type_name);
|
||||
else sb.Append("const " + GetTopScopeName(scope.TopScope) + scope.Name + ": " + type_name + " = " + scope.ConstantValue.ToString());
|
||||
}
|
||||
break;
|
||||
case SymbolKind.Event:
|
||||
if (scope.IsStatic) sb.Append("static ");
|
||||
sb.Append("event " + GetTopScopeName(scope.TopScope) + scope.Name + ": " + type_name);
|
||||
append_modifiers(sb, scope);
|
||||
break;
|
||||
case SymbolKind.Field:
|
||||
if (scope.IsStatic)
|
||||
sb.Append("static ");
|
||||
else
|
||||
sb.Append("var ");
|
||||
sb.Append(GetTopScopeName(scope.TopScope) + scope.Name + ": " + type_name);
|
||||
append_modifiers(sb, scope);
|
||||
//if (scope.IsStatic) sb.Append("; static");
|
||||
if (scope.IsReadOnly) sb.Append("; readonly");
|
||||
break;
|
||||
case SymbolKind.Property:
|
||||
if (scope.IsStatic)
|
||||
sb.Append("static ");
|
||||
sb.Append("property " + GetTopScopeName(scope.TopScope) + scope.Name + get_index_description(scope) + ": " + type_name);
|
||||
if (scope.IsReadOnly)
|
||||
sb.Append("; readonly");
|
||||
append_modifiers(sb, scope);
|
||||
break;
|
||||
|
||||
}
|
||||
sb.Append(';');
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string GetDescriptionForCompiledField(FieldInfo fi)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
@ -2132,13 +1976,13 @@ namespace Languages.Pascal.Frontend.Data
|
|||
|
||||
}
|
||||
|
||||
public override string FindExpressionFromAnyPosition(int off, string Text, int line, int col, out string expr_without_brackets)
|
||||
public override string FindExpressionFromAnyPosition(int off, string Text, int line, int col, out KeywordKind keyw, out string expr_without_brackets)
|
||||
{
|
||||
int i = off - 1;
|
||||
|
||||
// это например вызов метода без параметров
|
||||
expr_without_brackets = null;
|
||||
var keyw = KeywordKind.None;
|
||||
keyw = KeywordKind.None;
|
||||
if (i < 0)
|
||||
return "";
|
||||
bool is_char = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue