|
|
|
|
@ -48,14 +48,14 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -48,14 +48,14 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
public string EolMarker { get; set; } |
|
|
|
|
|
|
|
|
|
public string IndentString { get; set; } |
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Result properties
|
|
|
|
|
public bool AutoCompleteEmptyMatch; |
|
|
|
|
public bool AutoSelect; |
|
|
|
|
public string DefaultCompletionString; |
|
|
|
|
public bool CloseOnSquareBrackets; |
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public CSharpCompletionEngine(IDocument document, ICompletionContextProvider completionContextProvider, ICompletionDataFactory factory, IProjectContent content, CSharpTypeResolveContext ctx) : base (content, completionContextProvider, ctx) |
|
|
|
|
{ |
|
|
|
|
@ -212,6 +212,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -212,6 +212,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
resolveResult.Item2 |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return CreateCompletionData( |
|
|
|
|
location, |
|
|
|
|
resolveResult.Item1, |
|
|
|
|
@ -312,11 +314,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -312,11 +314,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
return null; |
|
|
|
|
case '>': |
|
|
|
|
if (!IsInsideDocComment()) { |
|
|
|
|
if (offset > 2 && document.GetCharAt (offset - 2) == '-' && !IsInsideCommentStringOrDirective()) { |
|
|
|
|
return HandleMemberReferenceCompletion(GetExpressionBeforeCursor()); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
string lineText = document.GetText(document.GetLineByNumber(location.Line)); |
|
|
|
|
int startIndex = Math.Min(location.Column - 1, lineText.Length - 1); |
|
|
|
|
|
|
|
|
|
while (startIndex >= 0 && lineText [startIndex] != '<') { |
|
|
|
|
--startIndex; |
|
|
|
|
if (lineText [startIndex] == '/') { |
|
|
|
|
@ -384,7 +388,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -384,7 +388,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
} |
|
|
|
|
// completionContext = CompletionWidget.CreateCodeCompletionContext (cpos2);
|
|
|
|
|
// int currentParameter2 = MethodParameterDataProvider.GetCurrentParameterIndex (CompletionWidget, completionContext) - 1;
|
|
|
|
|
// return CreateParameterCompletion (CreateResolver (), location, ExpressionContext.MethodBody, provider.Methods, currentParameter);
|
|
|
|
|
// return CreateParameterCompletion (CreateResolver (), location, ExpressionContext.MethodBody, provider.Methods, currentParameter);
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
// Completion on space:
|
|
|
|
|
@ -415,15 +419,15 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -415,15 +419,15 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
AutoCompleteEmptyMatch = false; |
|
|
|
|
return proposeNameList.Result; |
|
|
|
|
} |
|
|
|
|
// int tokenIndex = offset;
|
|
|
|
|
// string token = GetPreviousToken (ref tokenIndex, false);
|
|
|
|
|
// if (result.ExpressionContext == ExpressionContext.ObjectInitializer) {
|
|
|
|
|
// resolver = CreateResolver ();
|
|
|
|
|
// ExpressionContext exactContext = new NewCSharpExpressionFinder (dom).FindExactContextForObjectInitializer (document, resolver.Unit, Document.FileName, resolver.CallingType);
|
|
|
|
|
// IReturnType objectInitializer = ((ExpressionContext.TypeExpressionContext)exactContext).UnresolvedType;
|
|
|
|
|
// if (objectInitializer != null && objectInitializer.ArrayDimensions == 0 && objectInitializer.PointerNestingLevel == 0 && (token == "{" || token == ","))
|
|
|
|
|
// return CreateCtrlSpaceCompletionData (completionContext, result);
|
|
|
|
|
// }
|
|
|
|
|
// int tokenIndex = offset;
|
|
|
|
|
// string token = GetPreviousToken (ref tokenIndex, false);
|
|
|
|
|
// if (result.ExpressionContext == ExpressionContext.ObjectInitializer) {
|
|
|
|
|
// resolver = CreateResolver ();
|
|
|
|
|
// ExpressionContext exactContext = new NewCSharpExpressionFinder (dom).FindExactContextForObjectInitializer (document, resolver.Unit, Document.FileName, resolver.CallingType);
|
|
|
|
|
// IReturnType objectInitializer = ((ExpressionContext.TypeExpressionContext)exactContext).UnresolvedType;
|
|
|
|
|
// if (objectInitializer != null && objectInitializer.ArrayDimensions == 0 && objectInitializer.PointerNestingLevel == 0 && (token == "{" || token == ","))
|
|
|
|
|
// return CreateCtrlSpaceCompletionData (completionContext, result);
|
|
|
|
|
// }
|
|
|
|
|
if (token == "=") { |
|
|
|
|
int j = tokenIndex; |
|
|
|
|
string prevToken = GetPreviousToken(ref j, false); |
|
|
|
|
@ -485,30 +489,30 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -485,30 +489,30 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
AutoCompleteEmptyMatch = false; |
|
|
|
|
return wrapper.Result; |
|
|
|
|
} |
|
|
|
|
//
|
|
|
|
|
// if (resolvedType.FullName == DomReturnType.Bool.FullName) {
|
|
|
|
|
// CompletionDataList completionList = new ProjectDomCompletionDataList ();
|
|
|
|
|
// CompletionDataCollector cdc = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location);
|
|
|
|
|
// completionList.AutoCompleteEmptyMatch = false;
|
|
|
|
|
// cdc.Add ("true", "md-keyword");
|
|
|
|
|
// cdc.Add ("false", "md-keyword");
|
|
|
|
|
// resolver.AddAccessibleCodeCompletionData (result.ExpressionContext, cdc);
|
|
|
|
|
// return completionList;
|
|
|
|
|
// }
|
|
|
|
|
// if (resolvedType.ClassType == ClassType.Delegate && token == "=") {
|
|
|
|
|
// CompletionDataList completionList = new ProjectDomCompletionDataList ();
|
|
|
|
|
// string parameterDefinition = AddDelegateHandlers (completionList, resolvedType);
|
|
|
|
|
// string varName = GetPreviousMemberReferenceExpression (tokenIndex);
|
|
|
|
|
// completionList.Add (new EventCreationCompletionData (document, varName, resolvedType, null, parameterDefinition, resolver.CallingMember, resolvedType));
|
|
|
|
|
//
|
|
|
|
|
// CompletionDataCollector cdc = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location);
|
|
|
|
|
// resolver.AddAccessibleCodeCompletionData (result.ExpressionContext, cdc);
|
|
|
|
|
// foreach (var data in completionList) {
|
|
|
|
|
// if (data is MemberCompletionData)
|
|
|
|
|
// ((MemberCompletionData)data).IsDelegateExpected = true;
|
|
|
|
|
// }
|
|
|
|
|
// return completionList;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (resolvedType.FullName == DomReturnType.Bool.FullName) {
|
|
|
|
|
// CompletionDataList completionList = new ProjectDomCompletionDataList ();
|
|
|
|
|
// CompletionDataCollector cdc = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location);
|
|
|
|
|
// completionList.AutoCompleteEmptyMatch = false;
|
|
|
|
|
// cdc.Add ("true", "md-keyword");
|
|
|
|
|
// cdc.Add ("false", "md-keyword");
|
|
|
|
|
// resolver.AddAccessibleCodeCompletionData (result.ExpressionContext, cdc);
|
|
|
|
|
// return completionList;
|
|
|
|
|
// }
|
|
|
|
|
// if (resolvedType.ClassType == ClassType.Delegate && token == "=") {
|
|
|
|
|
// CompletionDataList completionList = new ProjectDomCompletionDataList ();
|
|
|
|
|
// string parameterDefinition = AddDelegateHandlers (completionList, resolvedType);
|
|
|
|
|
// string varName = GetPreviousMemberReferenceExpression (tokenIndex);
|
|
|
|
|
// completionList.Add (new EventCreationCompletionData (document, varName, resolvedType, null, parameterDefinition, resolver.CallingMember, resolvedType));
|
|
|
|
|
//
|
|
|
|
|
// CompletionDataCollector cdc = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location);
|
|
|
|
|
// resolver.AddAccessibleCodeCompletionData (result.ExpressionContext, cdc);
|
|
|
|
|
// foreach (var data in completionList) {
|
|
|
|
|
// if (data is MemberCompletionData)
|
|
|
|
|
// ((MemberCompletionData)data).IsDelegateExpected = true;
|
|
|
|
|
// }
|
|
|
|
|
// return completionList;
|
|
|
|
|
// }
|
|
|
|
|
return null; |
|
|
|
|
case "+=": |
|
|
|
|
case "-=": |
|
|
|
|
@ -716,19 +720,19 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -716,19 +720,19 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// var astResolver = new CSharpAstResolver(
|
|
|
|
|
// GetState(),
|
|
|
|
|
// identifierStart.Unit,
|
|
|
|
|
// CSharpParsedFile
|
|
|
|
|
// );
|
|
|
|
|
//
|
|
|
|
|
// foreach (var type in CreateFieldAction.GetValidTypes(astResolver, (Expression)n)) {
|
|
|
|
|
// if (type.Kind == TypeKind.Delegate) {
|
|
|
|
|
// AddDelegateHandlers(contextList, type, false, false);
|
|
|
|
|
// AutoSelect = false;
|
|
|
|
|
// AutoCompleteEmptyMatch = false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// var astResolver = new CSharpAstResolver(
|
|
|
|
|
// GetState(),
|
|
|
|
|
// identifierStart.Unit,
|
|
|
|
|
// CSharpParsedFile
|
|
|
|
|
// );
|
|
|
|
|
//
|
|
|
|
|
// foreach (var type in CreateFieldAction.GetValidTypes(astResolver, (Expression)n)) {
|
|
|
|
|
// if (type.Kind == TypeKind.Delegate) {
|
|
|
|
|
// AddDelegateHandlers(contextList, type, false, false);
|
|
|
|
|
// AutoSelect = false;
|
|
|
|
|
// AutoCompleteEmptyMatch = false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Handle object/enumerable initialzer expressions: "new O () { P$"
|
|
|
|
|
@ -912,71 +916,71 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -912,71 +916,71 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
identifierStart.Node |
|
|
|
|
); |
|
|
|
|
return contextList.Result; |
|
|
|
|
// if (stub.Parent is BlockStatement)
|
|
|
|
|
|
|
|
|
|
// result = FindExpression (dom, completionContext, -1);
|
|
|
|
|
// if (result == null)
|
|
|
|
|
// return null;
|
|
|
|
|
// else if (result.ExpressionContext != ExpressionContext.IdentifierExpected) {
|
|
|
|
|
// triggerWordLength = 1;
|
|
|
|
|
// bool autoSelect = true;
|
|
|
|
|
// IType returnType = null;
|
|
|
|
|
// if ((prevCh == ',' || prevCh == '(') && GetParameterCompletionCommandOffset (out cpos)) {
|
|
|
|
|
// ctx = CompletionWidget.CreateCodeCompletionContext (cpos);
|
|
|
|
|
// NRefactoryParameterDataProvider dataProvider = ParameterCompletionCommand (ctx) as NRefactoryParameterDataProvider;
|
|
|
|
|
// if (dataProvider != null) {
|
|
|
|
|
// int i = dataProvider.GetCurrentParameterIndex (CompletionWidget, ctx) - 1;
|
|
|
|
|
// foreach (var method in dataProvider.Methods) {
|
|
|
|
|
// if (i < method.Parameters.Count) {
|
|
|
|
|
// returnType = dom.GetType (method.Parameters [i].ReturnType);
|
|
|
|
|
// autoSelect = returnType == null || returnType.ClassType != ClassType.Delegate;
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// // Bug 677531 - Auto-complete doesn't always highlight generic parameter in method signature
|
|
|
|
|
// //if (result.ExpressionContext == ExpressionContext.TypeName)
|
|
|
|
|
// // autoSelect = false;
|
|
|
|
|
// CompletionDataList dataList = CreateCtrlSpaceCompletionData (completionContext, result);
|
|
|
|
|
// AddEnumMembers (dataList, returnType);
|
|
|
|
|
// dataList.AutoSelect = autoSelect;
|
|
|
|
|
// return dataList;
|
|
|
|
|
// } else {
|
|
|
|
|
// result = FindExpression (dom, completionContext, 0);
|
|
|
|
|
// tokenIndex = offset;
|
|
|
|
|
//
|
|
|
|
|
// // check foreach case, unfortunately the expression finder is too dumb to handle full type names
|
|
|
|
|
// // should be overworked if the expression finder is replaced with a mcs ast based analyzer.
|
|
|
|
|
// var possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // starting letter
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // varname
|
|
|
|
|
//
|
|
|
|
|
// // read return types to '(' token
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // varType
|
|
|
|
|
// if (possibleForeachToken == ">") {
|
|
|
|
|
// while (possibleForeachToken != null && possibleForeachToken != "(") {
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // (
|
|
|
|
|
// if (possibleForeachToken == ".")
|
|
|
|
|
// while (possibleForeachToken != null && possibleForeachToken != "(")
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false);
|
|
|
|
|
// }
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // foreach
|
|
|
|
|
//
|
|
|
|
|
// if (possibleForeachToken == "foreach") {
|
|
|
|
|
// result.ExpressionContext = ExpressionContext.ForeachInToken;
|
|
|
|
|
// } else {
|
|
|
|
|
// return null;
|
|
|
|
|
// // result.ExpressionContext = ExpressionContext.IdentifierExpected;
|
|
|
|
|
// }
|
|
|
|
|
// result.Expression = "";
|
|
|
|
|
// result.Region = DomRegion.Empty;
|
|
|
|
|
//
|
|
|
|
|
// return CreateCtrlSpaceCompletionData (completionContext, result);
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
// if (stub.Parent is BlockStatement)
|
|
|
|
|
|
|
|
|
|
// result = FindExpression (dom, completionContext, -1);
|
|
|
|
|
// if (result == null)
|
|
|
|
|
// return null;
|
|
|
|
|
// else if (result.ExpressionContext != ExpressionContext.IdentifierExpected) {
|
|
|
|
|
// triggerWordLength = 1;
|
|
|
|
|
// bool autoSelect = true;
|
|
|
|
|
// IType returnType = null;
|
|
|
|
|
// if ((prevCh == ',' || prevCh == '(') && GetParameterCompletionCommandOffset (out cpos)) {
|
|
|
|
|
// ctx = CompletionWidget.CreateCodeCompletionContext (cpos);
|
|
|
|
|
// NRefactoryParameterDataProvider dataProvider = ParameterCompletionCommand (ctx) as NRefactoryParameterDataProvider;
|
|
|
|
|
// if (dataProvider != null) {
|
|
|
|
|
// int i = dataProvider.GetCurrentParameterIndex (CompletionWidget, ctx) - 1;
|
|
|
|
|
// foreach (var method in dataProvider.Methods) {
|
|
|
|
|
// if (i < method.Parameters.Count) {
|
|
|
|
|
// returnType = dom.GetType (method.Parameters [i].ReturnType);
|
|
|
|
|
// autoSelect = returnType == null || returnType.ClassType != ClassType.Delegate;
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// // Bug 677531 - Auto-complete doesn't always highlight generic parameter in method signature
|
|
|
|
|
// //if (result.ExpressionContext == ExpressionContext.TypeName)
|
|
|
|
|
// // autoSelect = false;
|
|
|
|
|
// CompletionDataList dataList = CreateCtrlSpaceCompletionData (completionContext, result);
|
|
|
|
|
// AddEnumMembers (dataList, returnType);
|
|
|
|
|
// dataList.AutoSelect = autoSelect;
|
|
|
|
|
// return dataList;
|
|
|
|
|
// } else {
|
|
|
|
|
// result = FindExpression (dom, completionContext, 0);
|
|
|
|
|
// tokenIndex = offset;
|
|
|
|
|
//
|
|
|
|
|
// // check foreach case, unfortunately the expression finder is too dumb to handle full type names
|
|
|
|
|
// // should be overworked if the expression finder is replaced with a mcs ast based analyzer.
|
|
|
|
|
// var possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // starting letter
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // varname
|
|
|
|
|
//
|
|
|
|
|
// // read return types to '(' token
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // varType
|
|
|
|
|
// if (possibleForeachToken == ">") {
|
|
|
|
|
// while (possibleForeachToken != null && possibleForeachToken != "(") {
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // (
|
|
|
|
|
// if (possibleForeachToken == ".")
|
|
|
|
|
// while (possibleForeachToken != null && possibleForeachToken != "(")
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false);
|
|
|
|
|
// }
|
|
|
|
|
// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // foreach
|
|
|
|
|
//
|
|
|
|
|
// if (possibleForeachToken == "foreach") {
|
|
|
|
|
// result.ExpressionContext = ExpressionContext.ForeachInToken;
|
|
|
|
|
// } else {
|
|
|
|
|
// return null;
|
|
|
|
|
// // result.ExpressionContext = ExpressionContext.IdentifierExpected;
|
|
|
|
|
// }
|
|
|
|
|
// result.Expression = "";
|
|
|
|
|
// result.Region = DomRegion.Empty;
|
|
|
|
|
//
|
|
|
|
|
// return CreateCtrlSpaceCompletionData (completionContext, result);
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
@ -1143,7 +1147,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -1143,7 +1147,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
return wrapper.Result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
/* if (Unit != null && (node == null || node is TypeDeclaration)) { |
|
|
|
|
/* if (Unit != null && (node == null || node is TypeDeclaration)) { |
|
|
|
|
var constructor = Unit.GetNodeAt<ConstructorDeclaration>( |
|
|
|
|
location.Line, |
|
|
|
|
location.Column - 3 |
|
|
|
|
@ -1441,65 +1445,65 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -1441,65 +1445,65 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
return wrapper.Result; |
|
|
|
|
case "case": |
|
|
|
|
return CreateCaseCompletionData(location); |
|
|
|
|
// case ",":
|
|
|
|
|
// case ":":
|
|
|
|
|
// if (result.ExpressionContext == ExpressionContext.InheritableType) {
|
|
|
|
|
// IType cls = NRefactoryResolver.GetTypeAtCursor (Document.CompilationUnit, Document.FileName, new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset));
|
|
|
|
|
// CompletionDataList completionList = new ProjectDomCompletionDataList ();
|
|
|
|
|
// List<string > namespaceList = GetUsedNamespaces ();
|
|
|
|
|
// var col = new CSharpTextEditorCompletion.CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, null, location);
|
|
|
|
|
// bool isInterface = false;
|
|
|
|
|
// HashSet<string > baseTypeNames = new HashSet<string> ();
|
|
|
|
|
// if (cls != null) {
|
|
|
|
|
// baseTypeNames.Add (cls.Name);
|
|
|
|
|
// if (cls.ClassType == ClassType.Struct)
|
|
|
|
|
// isInterface = true;
|
|
|
|
|
// }
|
|
|
|
|
// int tokenIndex = offset;
|
|
|
|
|
//
|
|
|
|
|
// // Search base types " : [Type1, ... ,TypeN,] <Caret>"
|
|
|
|
|
// string token = null;
|
|
|
|
|
// do {
|
|
|
|
|
// token = GetPreviousToken (ref tokenIndex, false);
|
|
|
|
|
// if (string.IsNullOrEmpty (token))
|
|
|
|
|
// break;
|
|
|
|
|
// token = token.Trim ();
|
|
|
|
|
// if (Char.IsLetterOrDigit (token [0]) || token [0] == '_') {
|
|
|
|
|
// IType baseType = dom.SearchType (Document.CompilationUnit, cls, result.Region.Start, token);
|
|
|
|
|
// if (baseType != null) {
|
|
|
|
|
// if (baseType.ClassType != ClassType.Interface)
|
|
|
|
|
// isInterface = true;
|
|
|
|
|
// baseTypeNames.Add (baseType.Name);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } while (token != ":");
|
|
|
|
|
// foreach (object o in dom.GetNamespaceContents (namespaceList, true, true)) {
|
|
|
|
|
// IType type = o as IType;
|
|
|
|
|
// if (type != null && (type.IsStatic || type.IsSealed || baseTypeNames.Contains (type.Name) || isInterface && type.ClassType != ClassType.Interface)) {
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// if (o is Namespace && !namespaceList.Any (ns => ns.StartsWith (((Namespace)o).FullName)))
|
|
|
|
|
// continue;
|
|
|
|
|
// col.Add (o);
|
|
|
|
|
// }
|
|
|
|
|
// // Add inner classes
|
|
|
|
|
// Stack<IType > innerStack = new Stack<IType> ();
|
|
|
|
|
// innerStack.Push (cls);
|
|
|
|
|
// while (innerStack.Count > 0) {
|
|
|
|
|
// IType curType = innerStack.Pop ();
|
|
|
|
|
// if (curType == null)
|
|
|
|
|
// continue;
|
|
|
|
|
// foreach (IType innerType in curType.InnerTypes) {
|
|
|
|
|
// if (innerType != cls)
|
|
|
|
|
// // don't add the calling class as possible base type
|
|
|
|
|
// col.Add (innerType);
|
|
|
|
|
// }
|
|
|
|
|
// if (curType.DeclaringType != null)
|
|
|
|
|
// innerStack.Push (curType.DeclaringType);
|
|
|
|
|
// }
|
|
|
|
|
// return completionList;
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
// case ",":
|
|
|
|
|
// case ":":
|
|
|
|
|
// if (result.ExpressionContext == ExpressionContext.InheritableType) {
|
|
|
|
|
// IType cls = NRefactoryResolver.GetTypeAtCursor (Document.CompilationUnit, Document.FileName, new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset));
|
|
|
|
|
// CompletionDataList completionList = new ProjectDomCompletionDataList ();
|
|
|
|
|
// List<string > namespaceList = GetUsedNamespaces ();
|
|
|
|
|
// var col = new CSharpTextEditorCompletion.CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, null, location);
|
|
|
|
|
// bool isInterface = false;
|
|
|
|
|
// HashSet<string > baseTypeNames = new HashSet<string> ();
|
|
|
|
|
// if (cls != null) {
|
|
|
|
|
// baseTypeNames.Add (cls.Name);
|
|
|
|
|
// if (cls.ClassType == ClassType.Struct)
|
|
|
|
|
// isInterface = true;
|
|
|
|
|
// }
|
|
|
|
|
// int tokenIndex = offset;
|
|
|
|
|
//
|
|
|
|
|
// // Search base types " : [Type1, ... ,TypeN,] <Caret>"
|
|
|
|
|
// string token = null;
|
|
|
|
|
// do {
|
|
|
|
|
// token = GetPreviousToken (ref tokenIndex, false);
|
|
|
|
|
// if (string.IsNullOrEmpty (token))
|
|
|
|
|
// break;
|
|
|
|
|
// token = token.Trim ();
|
|
|
|
|
// if (Char.IsLetterOrDigit (token [0]) || token [0] == '_') {
|
|
|
|
|
// IType baseType = dom.SearchType (Document.CompilationUnit, cls, result.Region.Start, token);
|
|
|
|
|
// if (baseType != null) {
|
|
|
|
|
// if (baseType.ClassType != ClassType.Interface)
|
|
|
|
|
// isInterface = true;
|
|
|
|
|
// baseTypeNames.Add (baseType.Name);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } while (token != ":");
|
|
|
|
|
// foreach (object o in dom.GetNamespaceContents (namespaceList, true, true)) {
|
|
|
|
|
// IType type = o as IType;
|
|
|
|
|
// if (type != null && (type.IsStatic || type.IsSealed || baseTypeNames.Contains (type.Name) || isInterface && type.ClassType != ClassType.Interface)) {
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// if (o is Namespace && !namespaceList.Any (ns => ns.StartsWith (((Namespace)o).FullName)))
|
|
|
|
|
// continue;
|
|
|
|
|
// col.Add (o);
|
|
|
|
|
// }
|
|
|
|
|
// // Add inner classes
|
|
|
|
|
// Stack<IType > innerStack = new Stack<IType> ();
|
|
|
|
|
// innerStack.Push (cls);
|
|
|
|
|
// while (innerStack.Count > 0) {
|
|
|
|
|
// IType curType = innerStack.Pop ();
|
|
|
|
|
// if (curType == null)
|
|
|
|
|
// continue;
|
|
|
|
|
// foreach (IType innerType in curType.InnerTypes) {
|
|
|
|
|
// if (innerType != cls)
|
|
|
|
|
// // don't add the calling class as possible base type
|
|
|
|
|
// col.Add (innerType);
|
|
|
|
|
// }
|
|
|
|
|
// if (curType.DeclaringType != null)
|
|
|
|
|
// innerStack.Push (curType.DeclaringType);
|
|
|
|
|
// }
|
|
|
|
|
// return completionList;
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
case "is": |
|
|
|
|
case "as": |
|
|
|
|
if (currentType == null) { |
|
|
|
|
@ -1528,55 +1532,55 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -1528,55 +1532,55 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
t => t.GetDefinition() == null || def == null || t.GetDefinition().IsDerivedFrom(def) ? t : null, |
|
|
|
|
m => false); |
|
|
|
|
return isAsWrapper.Result; |
|
|
|
|
// {
|
|
|
|
|
// CompletionDataList completionList = new ProjectDomCompletionDataList ();
|
|
|
|
|
// ExpressionResult expressionResult = FindExpression (dom, completionContext, wordStart - document.Caret.Offset);
|
|
|
|
|
// NRefactoryResolver resolver = CreateResolver ();
|
|
|
|
|
// ResolveResult resolveResult = resolver.Resolve (expressionResult, new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset));
|
|
|
|
|
// if (resolveResult != null && resolveResult.ResolvedType != null) {
|
|
|
|
|
// CompletionDataCollector col = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location);
|
|
|
|
|
// IType foundType = null;
|
|
|
|
|
// if (word == "as") {
|
|
|
|
|
// ExpressionContext exactContext = new NewCSharpExpressionFinder (dom).FindExactContextForAsCompletion (document, Document.CompilationUnit, Document.FileName, resolver.CallingType);
|
|
|
|
|
// if (exactContext is ExpressionContext.TypeExpressionContext) {
|
|
|
|
|
// foundType = resolver.SearchType (((ExpressionContext.TypeExpressionContext)exactContext).Type);
|
|
|
|
|
// AddAsCompletionData (col, foundType);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (foundType == null)
|
|
|
|
|
// foundType = resolver.SearchType (resolveResult.ResolvedType);
|
|
|
|
|
//
|
|
|
|
|
// if (foundType != null) {
|
|
|
|
|
// if (foundType.ClassType == ClassType.Interface)
|
|
|
|
|
// foundType = resolver.SearchType (DomReturnType.Object);
|
|
|
|
|
//
|
|
|
|
|
// foreach (IType type in dom.GetSubclasses (foundType)) {
|
|
|
|
|
// if (type.IsSpecialName || type.Name.StartsWith ("<"))
|
|
|
|
|
// continue;
|
|
|
|
|
// AddAsCompletionData (col, type);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// List<string > namespaceList = GetUsedNamespaces ();
|
|
|
|
|
// foreach (object o in dom.GetNamespaceContents (namespaceList, true, true)) {
|
|
|
|
|
// if (o is IType) {
|
|
|
|
|
// IType type = (IType)o;
|
|
|
|
|
// if (type.ClassType != ClassType.Interface || type.IsSpecialName || type.Name.StartsWith ("<"))
|
|
|
|
|
// continue;
|
|
|
|
|
// // if (foundType != null && !dom.GetInheritanceTree (foundType).Any (x => x.FullName == type.FullName))
|
|
|
|
|
// // continue;
|
|
|
|
|
// AddAsCompletionData (col, type);
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// if (o is Namespace)
|
|
|
|
|
// continue;
|
|
|
|
|
// col.Add (o);
|
|
|
|
|
// }
|
|
|
|
|
// return completionList;
|
|
|
|
|
// }
|
|
|
|
|
// result.ExpressionContext = ExpressionContext.TypeName;
|
|
|
|
|
// return CreateCtrlSpaceCompletionData (completionContext, result);
|
|
|
|
|
// }
|
|
|
|
|
// {
|
|
|
|
|
// CompletionDataList completionList = new ProjectDomCompletionDataList ();
|
|
|
|
|
// ExpressionResult expressionResult = FindExpression (dom, completionContext, wordStart - document.Caret.Offset);
|
|
|
|
|
// NRefactoryResolver resolver = CreateResolver ();
|
|
|
|
|
// ResolveResult resolveResult = resolver.Resolve (expressionResult, new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset));
|
|
|
|
|
// if (resolveResult != null && resolveResult.ResolvedType != null) {
|
|
|
|
|
// CompletionDataCollector col = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location);
|
|
|
|
|
// IType foundType = null;
|
|
|
|
|
// if (word == "as") {
|
|
|
|
|
// ExpressionContext exactContext = new NewCSharpExpressionFinder (dom).FindExactContextForAsCompletion (document, Document.CompilationUnit, Document.FileName, resolver.CallingType);
|
|
|
|
|
// if (exactContext is ExpressionContext.TypeExpressionContext) {
|
|
|
|
|
// foundType = resolver.SearchType (((ExpressionContext.TypeExpressionContext)exactContext).Type);
|
|
|
|
|
// AddAsCompletionData (col, foundType);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (foundType == null)
|
|
|
|
|
// foundType = resolver.SearchType (resolveResult.ResolvedType);
|
|
|
|
|
//
|
|
|
|
|
// if (foundType != null) {
|
|
|
|
|
// if (foundType.ClassType == ClassType.Interface)
|
|
|
|
|
// foundType = resolver.SearchType (DomReturnType.Object);
|
|
|
|
|
//
|
|
|
|
|
// foreach (IType type in dom.GetSubclasses (foundType)) {
|
|
|
|
|
// if (type.IsSpecialName || type.Name.StartsWith ("<"))
|
|
|
|
|
// continue;
|
|
|
|
|
// AddAsCompletionData (col, type);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// List<string > namespaceList = GetUsedNamespaces ();
|
|
|
|
|
// foreach (object o in dom.GetNamespaceContents (namespaceList, true, true)) {
|
|
|
|
|
// if (o is IType) {
|
|
|
|
|
// IType type = (IType)o;
|
|
|
|
|
// if (type.ClassType != ClassType.Interface || type.IsSpecialName || type.Name.StartsWith ("<"))
|
|
|
|
|
// continue;
|
|
|
|
|
// // if (foundType != null && !dom.GetInheritanceTree (foundType).Any (x => x.FullName == type.FullName))
|
|
|
|
|
// // continue;
|
|
|
|
|
// AddAsCompletionData (col, type);
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// if (o is Namespace)
|
|
|
|
|
// continue;
|
|
|
|
|
// col.Add (o);
|
|
|
|
|
// }
|
|
|
|
|
// return completionList;
|
|
|
|
|
// }
|
|
|
|
|
// result.ExpressionContext = ExpressionContext.TypeName;
|
|
|
|
|
// return CreateCtrlSpaceCompletionData (completionContext, result);
|
|
|
|
|
// }
|
|
|
|
|
case "override": |
|
|
|
|
// Look for modifiers, in order to find the beginning of the declaration
|
|
|
|
|
int firstMod = wordStart; |
|
|
|
|
@ -1646,7 +1650,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -1646,7 +1650,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
return wrapper.Result; |
|
|
|
|
case "new": |
|
|
|
|
int j = offset - 4; |
|
|
|
|
// string token = GetPreviousToken (ref j, true);
|
|
|
|
|
// string token = GetPreviousToken (ref j, true);
|
|
|
|
|
|
|
|
|
|
IType hintType = null; |
|
|
|
|
var expressionOrVariableDeclaration = GetNewExpressionAt(j); |
|
|
|
|
@ -2082,16 +2086,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -2082,16 +2086,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
bool result = true; |
|
|
|
|
// easy case, projects are the same
|
|
|
|
|
/*// if (type1.ProjectContent == type2.ProjectContent) {
|
|
|
|
|
// result = true;
|
|
|
|
|
// } else
|
|
|
|
|
// result = true;
|
|
|
|
|
// } else
|
|
|
|
|
if (type1.ProjectContent != null) { |
|
|
|
|
// maybe type2 hasn't project dom set (may occur in some cases), check if the file is in the project
|
|
|
|
|
//TODO !!
|
|
|
|
|
// result = type1.ProjectContent.Annotation<MonoDevelop.Projects.Project> ().GetProjectFile (type2.Region.FileName) != null;
|
|
|
|
|
// result = type1.ProjectContent.Annotation<MonoDevelop.Projects.Project> ().GetProjectFile (type2.Region.FileName) != null;
|
|
|
|
|
result = false; |
|
|
|
|
} else if (type2.ProjectContent != null) { |
|
|
|
|
//TODO!!
|
|
|
|
|
// result = type2.ProjectContent.Annotation<MonoDevelop.Projects.Project> ().GetProjectFile (type1.Region.FileName) != null;
|
|
|
|
|
// result = type2.ProjectContent.Annotation<MonoDevelop.Projects.Project> ().GetProjectFile (type1.Region.FileName) != null;
|
|
|
|
|
result = false; |
|
|
|
|
} else { |
|
|
|
|
// should never happen !
|
|
|
|
|
@ -2293,6 +2297,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -2293,6 +2297,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IType type = resolveResult.Type; |
|
|
|
|
if (resolvedNode.Parent is PointerReferenceExpression && (type is PointerType)) { |
|
|
|
|
type = ((PointerType)type).ElementType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//var typeDef = resolveResult.Type.GetDefinition();
|
|
|
|
|
var result = new CompletionDataWrapper(this); |
|
|
|
|
bool includeStaticMembers = false; |
|
|
|
|
@ -2525,7 +2533,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -2525,7 +2533,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
|
|
|
|
|
baseUnit = ParseStub("a", false); |
|
|
|
|
var curNode = baseUnit.GetNodeAt(location); |
|
|
|
|
|
|
|
|
|
// hack for local variable declaration missing ';' issue - remove that if it works.
|
|
|
|
|
if (curNode is EntityDeclaration || baseUnit.GetNodeAt<Expression>(location) == null && baseUnit.GetNodeAt<MemberType>(location) == null) { |
|
|
|
|
baseUnit = ParseStub("a"); |
|
|
|
|
@ -2550,6 +2557,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -2550,6 +2557,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
if (type != null) { |
|
|
|
|
return new ExpressionResult((AstNode)type.Target, baseUnit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var pref = baseUnit.GetNodeAt<PointerReferenceExpression>(location); |
|
|
|
|
if (pref != null) { |
|
|
|
|
return new ExpressionResult((AstNode)pref.Target, baseUnit); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
AstNode expr = null; |
|
|
|
|
if (mref != null) { |
|
|
|
|
@ -2780,7 +2792,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -2780,7 +2792,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Helper methods
|
|
|
|
|
string GetPreviousToken(ref int i, bool allowLineChange) |
|
|
|
|
@ -2816,7 +2828,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -2816,7 +2828,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
return document.GetText(i, endOffset - i); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Preprocessor
|
|
|
|
|
|
|
|
|
|
@ -2837,7 +2849,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -2837,7 +2849,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
yield return factory.CreateLiteralCompletionData("region"); |
|
|
|
|
yield return factory.CreateLiteralCompletionData("endregion"); |
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Xml Comments
|
|
|
|
|
static readonly List<string> commentTags = new List<string>(new string[] { |
|
|
|
|
@ -3009,7 +3021,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -3009,7 +3021,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Keywords
|
|
|
|
|
static string[] expressionLevelKeywords = new string [] { |
|
|
|
|
@ -3084,7 +3096,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -3084,7 +3096,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
"ref", |
|
|
|
|
"params" |
|
|
|
|
}; |
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|