bug fix #720
This commit is contained in:
parent
748669aaec
commit
5305657e43
|
|
@ -450,6 +450,7 @@ namespace CodeCompletion
|
|||
if (si == null)
|
||||
si = visitor.cur_scope;
|
||||
}
|
||||
|
||||
SymInfo[] elems = null;
|
||||
if (si == null) return null;
|
||||
if (pattern == null || pattern == "")
|
||||
|
|
|
|||
|
|
@ -4865,6 +4865,14 @@ namespace CodeCompletion
|
|||
}
|
||||
}
|
||||
|
||||
public ICompiledTypeScope[] GetCompiledGenericArguments()
|
||||
{
|
||||
List<ICompiledTypeScope> types = new List<ICompiledTypeScope>();
|
||||
foreach (Type t in ctn.GetGenericArguments())
|
||||
types.Add(TypeTable.get_compiled_type(t));
|
||||
return types.ToArray();
|
||||
}
|
||||
|
||||
internal static TypeScope get_type_instance(Type t, List<TypeScope> generic_args)
|
||||
{
|
||||
if (t.IsGenericParameter)
|
||||
|
|
|
|||
|
|
@ -1063,7 +1063,7 @@ namespace CodeCompletion
|
|||
return sc;
|
||||
if (si == null)
|
||||
si = new SymInfo(t.Name, SymbolKind.Type, t.FullName);
|
||||
sc = new CompiledScope(si,t);
|
||||
sc = new CompiledScope(si, t);
|
||||
type_cache[t] = sc;
|
||||
return sc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1782,7 +1782,16 @@ namespace PascalABCCompiler.Parsers
|
|||
if (!class_generic_table.ContainsKey(class_generic_args[i].Name))
|
||||
class_generic_table.Add(class_generic_args[i].Name, j);
|
||||
if (scope.GenericArgs != null && scope.GenericArgs.Count > j)
|
||||
generic_param_args[class_generic_args[i].Name] = GetSimpleDescription(scope.DeclaringType.GenericInstances[0]);
|
||||
{
|
||||
if (scope.DeclaringType.GenericInstances.Length > 0)
|
||||
generic_param_args[class_generic_args[i].Name] = GetSimpleDescription(scope.DeclaringType.GenericInstances[0]);
|
||||
else if (scope.DeclaringType is ICompiledTypeScope)
|
||||
{
|
||||
Type ctn = (scope.DeclaringType as ICompiledTypeScope).CompiledType;
|
||||
if (ctn.IsGenericType && !ctn.IsGenericTypeDefinition)
|
||||
generic_param_args[class_generic_args[i].Name] = GetSimpleDescriptionForCompiledType((scope.DeclaringType as ICompiledTypeScope).GetCompiledGenericArguments()[0]);
|
||||
}
|
||||
}
|
||||
else if (scope.DeclaringType.TemplateArguments != null && scope.DeclaringType.TemplateArguments.Length > j)
|
||||
generic_param_args[class_generic_args[i].Name] = scope.DeclaringType.TemplateArguments[j];
|
||||
}
|
||||
|
|
@ -1809,9 +1818,22 @@ namespace PascalABCCompiler.Parsers
|
|||
int ind = class_generic_table[tt[i].Name];
|
||||
if (scope.GenericArgs != null && scope.GenericArgs.Count > ind)
|
||||
{
|
||||
sb.Append(GetSimpleDescription(scope.DeclaringType.GenericInstances[ind]));
|
||||
if (!generic_param_args.ContainsKey(tt[i].Name))
|
||||
generic_param_args.Add(tt[i].Name, GetSimpleDescription(scope.DeclaringType.GenericInstances[ind]));
|
||||
if (scope.DeclaringType.GenericInstances.Length > ind)
|
||||
{
|
||||
sb.Append(GetSimpleDescription(scope.DeclaringType.GenericInstances[ind]));
|
||||
if (!generic_param_args.ContainsKey(tt[i].Name))
|
||||
generic_param_args.Add(tt[i].Name, GetSimpleDescription(scope.DeclaringType.GenericInstances[ind]));
|
||||
}
|
||||
else if (scope.DeclaringType is ICompiledTypeScope)
|
||||
{
|
||||
Type ctn = (scope.DeclaringType as ICompiledTypeScope).CompiledType;
|
||||
if (ctn.IsGenericType && !ctn.IsGenericTypeDefinition)
|
||||
{
|
||||
sb.Append(GetSimpleDescription((scope.DeclaringType as ICompiledTypeScope).GetCompiledGenericArguments()[ind]));
|
||||
if (!generic_param_args.ContainsKey(tt[i].Name))
|
||||
generic_param_args.Add(tt[i].Name, GetSimpleDescription((scope.DeclaringType as ICompiledTypeScope).GetCompiledGenericArguments()[ind]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -674,6 +674,8 @@ namespace PascalABCCompiler.Parsers
|
|||
{
|
||||
get;
|
||||
}
|
||||
|
||||
ICompiledTypeScope[] GetCompiledGenericArguments();
|
||||
}
|
||||
|
||||
public interface ICompiledMethodScope : IProcScope
|
||||
|
|
|
|||
|
|
@ -398,11 +398,18 @@ namespace VisualPascalABC
|
|||
string expr = null;
|
||||
bool ctrl_space = charTyped == '\0' || charTyped == '_';
|
||||
bool shift_space = charTyped == '\0';
|
||||
bool inside_dot_pattern = false;
|
||||
bool new_space = keyw == PascalABCCompiler.Parsers.KeywordKind.New;
|
||||
if (ctrl_space)
|
||||
{
|
||||
bool is_pattern = false;
|
||||
pattern = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindPattern(off, Text, out is_pattern);
|
||||
if (is_pattern && Text[off - pattern.Length - 1] == '.')
|
||||
{
|
||||
inside_dot_pattern = true;
|
||||
expr = FindExpression(off - pattern.Length - 1, Text, line, col);
|
||||
}
|
||||
|
||||
}
|
||||
else if (new_space)
|
||||
{
|
||||
|
|
@ -412,7 +419,8 @@ namespace VisualPascalABC
|
|||
if (!new_space && keyw != PascalABCCompiler.Parsers.KeywordKind.Uses)
|
||||
if (charTyped != '$')
|
||||
expr = FindExpression(off, Text, line, col);
|
||||
else expr = FindExpression(off - 1, Text, line, col);
|
||||
else
|
||||
expr = FindExpression(off - 1, Text, line, col);
|
||||
List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>();
|
||||
PascalABCCompiler.SyntaxTree.expression e = null;
|
||||
if (ctrl_space && !shift_space && (pattern == null || pattern == ""))
|
||||
|
|
@ -424,7 +432,7 @@ namespace VisualPascalABC
|
|||
resultList.Add(new UserDefaultCompletionData(key, null, ImagesProvider.IconNumberKeyword, false));
|
||||
}
|
||||
}
|
||||
if (!ctrl_space && expr != null)
|
||||
if ((!ctrl_space || inside_dot_pattern) && expr != null)
|
||||
{
|
||||
e = WorkbenchServiceFactory.Workbench.VisualEnvironmentCompiler.StandartCompiler.ParsersController.GetTypeAsExpression("test" + System.IO.Path.GetExtension(FileName), expr, Errors, new List<PascalABCCompiler.Errors.CompilerWarning>());
|
||||
if (e == null)
|
||||
|
|
@ -457,20 +465,37 @@ namespace VisualPascalABC
|
|||
else
|
||||
mis = CodeCompletion.DomConverter.standard_units;
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
if (!ctrl_space)
|
||||
{
|
||||
CodeCompletion.SymScope dot_sc = null;
|
||||
mis = dconv.GetName(e, expr, line, col, keyword, ref dot_sc);
|
||||
if (dot_sc != null && VisualPABCSingleton.MainForm.UserOptions.EnableSmartIntellisense)
|
||||
{
|
||||
CodeCompletion.SymScope dot_sc = null;
|
||||
mis = dconv.GetName(e, expr, line, col, keyword, ref dot_sc);
|
||||
if (dot_sc != null && VisualPABCSingleton.MainForm.UserOptions.EnableSmartIntellisense)
|
||||
{
|
||||
CompletionDataDispatcher.AddMemberBeforeDot(dot_sc);
|
||||
last_used_member = CompletionDataDispatcher.GetRecentUsedMember(dot_sc);
|
||||
}
|
||||
CompletionDataDispatcher.AddMemberBeforeDot(dot_sc);
|
||||
last_used_member = CompletionDataDispatcher.GetRecentUsedMember(dot_sc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CodeCompletion.SymScope dot_sc = null;
|
||||
if (inside_dot_pattern)
|
||||
{
|
||||
List<SymInfo> si_list = new List<SymInfo>();
|
||||
SymInfo[] from_list = dconv.GetName(e, expr, line, col, keyword, ref dot_sc);
|
||||
for (int i = 0; i< from_list.Length; i++)
|
||||
{
|
||||
if (from_list[i].name.StartsWith(pattern))
|
||||
si_list.Add(from_list[i]);
|
||||
}
|
||||
mis = si_list.ToArray();
|
||||
}
|
||||
|
||||
else
|
||||
mis = dconv.GetNameByPattern(pattern, line, col, charTyped == '_', VisualPABCSingleton.MainForm.UserOptions.CodeCompletionNamespaceVisibleRange);
|
||||
}
|
||||
|
||||
}
|
||||
Hashtable cache = null;
|
||||
if (!CodeCompletion.CodeCompletionController.CurrentParser.CaseSensitive)
|
||||
|
|
|
|||
Loading…
Reference in a new issue