|
|
|
@ -372,27 +372,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var contextList = new CompletionDataWrapper (this); |
|
|
|
var contextList = new CompletionDataWrapper (this); |
|
|
|
if (identifierStart == null) { |
|
|
|
|
|
|
|
var unit = ParseStub ("get; }", false); |
|
|
|
|
|
|
|
var node = unit.GetNodeAt (location, cn => !(cn is CSharpTokenNode)); |
|
|
|
|
|
|
|
if (node is Accessor) |
|
|
|
|
|
|
|
node = node.Parent; |
|
|
|
|
|
|
|
if (node is PropertyDeclaration) { |
|
|
|
|
|
|
|
contextList.AddCustom ("get"); |
|
|
|
|
|
|
|
contextList.AddCustom ("set"); |
|
|
|
|
|
|
|
AddKeywords (contextList, accessorModifierKeywords); |
|
|
|
|
|
|
|
} else if (node is CustomEventDeclaration) { |
|
|
|
|
|
|
|
contextList.AddCustom ("add"); |
|
|
|
|
|
|
|
contextList.AddCustom ("remove"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
AddContextCompletion (contextList, GetState (), null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return contextList.Result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(char.IsLetter (completionChar) || completionChar == '_') && (identifierStart == null || !(identifierStart.Item2 is ArrayInitializerExpression))) |
|
|
|
if (!(char.IsLetter (completionChar) || completionChar == '_') && (identifierStart == null || !(identifierStart.Item2 is ArrayInitializerExpression))) |
|
|
|
return controlSpace ? DefaultControlSpaceItems () : null; |
|
|
|
return controlSpace ? HandleAccessorContext () ?? DefaultControlSpaceItems () : null; |
|
|
|
char prevCh = offset > 2 ? document.GetCharAt (offset - 2) : '\0'; |
|
|
|
char prevCh = offset > 2 ? document.GetCharAt (offset - 2) : '\0'; |
|
|
|
char nextCh = offset < document.TextLength ? document.GetCharAt (offset) : ' '; |
|
|
|
char nextCh = offset < document.TextLength ? document.GetCharAt (offset) : ' '; |
|
|
|
const string allowedChars = ";,[(){}+-*/%^?:&|~!<>="; |
|
|
|
const string allowedChars = ";,[(){}+-*/%^?:&|~!<>="; |
|
|
|
@ -408,6 +390,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
if (!char.IsLetterOrDigit (last) && last != '_') |
|
|
|
if (!char.IsLetterOrDigit (last) && last != '_') |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (identifierStart == null) |
|
|
|
|
|
|
|
return HandleAccessorContext () ?? DefaultControlSpaceItems (); |
|
|
|
|
|
|
|
|
|
|
|
CSharpResolver csResolver; |
|
|
|
CSharpResolver csResolver; |
|
|
|
AstNode n = identifierStart.Item2; |
|
|
|
AstNode n = identifierStart.Item2; |
|
|
|
if (n is ArrayInitializerExpression) { |
|
|
|
if (n is ArrayInitializerExpression) { |
|
|
|
@ -427,7 +413,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (n != null/* && !(identifierStart.Item2 is TypeDeclaration)*/) { |
|
|
|
if (n != null/* && !(identifierStart.Item2 is TypeDeclaration)*/) { |
|
|
|
csResolver = new CSharpResolver (ctx, System.Threading.CancellationToken.None); |
|
|
|
csResolver = new CSharpResolver (ctx, System.Threading.CancellationToken.None); |
|
|
|
var nodes = new List<AstNode> (); |
|
|
|
var nodes = new List<AstNode> (); |
|
|
|
@ -544,6 +529,27 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<ICompletionData> HandleAccessorContext () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var unit = ParseStub ("get; }", false); |
|
|
|
|
|
|
|
var node = unit.GetNodeAt (location, cn => !(cn is CSharpTokenNode)); |
|
|
|
|
|
|
|
if (node is Accessor) |
|
|
|
|
|
|
|
node = node.Parent; |
|
|
|
|
|
|
|
var contextList = new CompletionDataWrapper (this); |
|
|
|
|
|
|
|
if (node is PropertyDeclaration) { |
|
|
|
|
|
|
|
contextList.AddCustom ("get"); |
|
|
|
|
|
|
|
contextList.AddCustom ("set"); |
|
|
|
|
|
|
|
AddKeywords (contextList, accessorModifierKeywords); |
|
|
|
|
|
|
|
} else if (node is CustomEventDeclaration) { |
|
|
|
|
|
|
|
contextList.AddCustom ("add"); |
|
|
|
|
|
|
|
contextList.AddCustom ("remove"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return contextList.Result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<ICompletionData> DefaultControlSpaceItems () |
|
|
|
IEnumerable<ICompletionData> DefaultControlSpaceItems () |
|
|
|
{ |
|
|
|
{ |
|
|
|
var wrapper = new CompletionDataWrapper (this); |
|
|
|
var wrapper = new CompletionDataWrapper (this); |
|
|
|
@ -562,8 +568,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
node = Unit.GetNodeAt (location); |
|
|
|
node = Unit.GetNodeAt (location); |
|
|
|
rr = ResolveExpression (CSharpParsedFile, node, Unit); |
|
|
|
rr = ResolveExpression (CSharpParsedFile, node, Unit); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
AddContextCompletion (wrapper, rr != null && (node is Expression) ? rr.Item2 : GetState (), node); |
|
|
|
AddContextCompletion (wrapper, rr != null ? rr.Item2 : GetState (), node); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return wrapper.Result; |
|
|
|
return wrapper.Result; |
|
|
|
} |
|
|
|
} |
|
|
|
|