diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2012-07-25 16:19:20 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2012-07-25 16:19:20 +0400 |
commit | f83e772e54a230938dca24bf2110c96733b906c8 (patch) | |
tree | 3ee039c6015587c92adce3bd4c7528f9a1727ebf /main/contrib | |
parent | 3781956cafd4de8e942856c30c245f8806baedbf (diff) |
[Completion] Fixed some issues in the delegate completion.
Diffstat (limited to 'main/contrib')
-rw-r--r-- | main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs | 1697 |
1 files changed, 855 insertions, 842 deletions
diff --git a/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs b/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs index 62ca8d9939..030e4cf044 100644 --- a/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs +++ b/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs @@ -117,7 +117,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion var nonWsResult = MagicKeyCompletion( document.GetCharAt(offset), controlSpace - ); + ); if (nonWsResult != null) { var text = new HashSet<string>(result.Select(r => r.CompletionText)); result = result.Concat(nonWsResult.Where(r => !text.Contains(r.CompletionText))); @@ -135,26 +135,26 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (type is PrimitiveType) { var pt = (PrimitiveType)type; switch (pt.Keyword) { - case "object": - yield return "o"; - yield return "obj"; - break; - case "bool": - yield return "b"; - yield return "pred"; - break; - case "double": - case "float": - case "decimal": - yield return "d"; - yield return "f"; - yield return "m"; - break; - default: - yield return "i"; - yield return "j"; - yield return "k"; - break; + case "object": + yield return "o"; + yield return "obj"; + break; + case "bool": + yield return "b"; + yield return "pred"; + break; + case "double": + case "float": + case "decimal": + yield return "d"; + yield return "f"; + yield return "m"; + break; + default: + yield return "i"; + yield return "j"; + yield return "k"; + break; } yield break; } @@ -210,7 +210,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion resolveResult.Item1, expr.Node, resolveResult.Item2 - ); + ); } @@ -219,7 +219,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion resolveResult.Item1, expr.Node, resolveResult.Item2 - ); + ); } bool IsInPreprocessorDirective() @@ -292,80 +292,80 @@ namespace ICSharpCode.NRefactory.CSharp.Completion { Tuple<ResolveResult, CSharpResolver> resolveResult; switch (completionChar) { - // Magic key completion - case ':': - case '.': - if (IsInsideCommentStringOrDirective()) { - return Enumerable.Empty<ICompletionData>(); - } - return HandleMemberReferenceCompletion(GetExpressionBeforeCursor()); - case '#': - if (!IsInPreprocessorDirective()) - return null; - return GetDirectiveCompletionData(); - // XML doc completion - case '<': - if (IsInsideDocComment()) { - return GetXmlDocumentationCompletionData(); - } - if (controlSpace) { - return DefaultControlSpaceItems(); - } + // Magic key completion + case ':': + case '.': + if (IsInsideCommentStringOrDirective()) { + return Enumerable.Empty<ICompletionData>(); + } + return HandleMemberReferenceCompletion(GetExpressionBeforeCursor()); + case '#': + if (!IsInPreprocessorDirective()) return null; - case '>': - if (!IsInsideDocComment()) { - if (offset > 2 && document.GetCharAt(offset - 2) == '-' && !IsInsideCommentStringOrDirective()) { - return HandleMemberReferenceCompletion(GetExpressionBeforeCursor()); - } - return null; + return GetDirectiveCompletionData(); + // XML doc completion + case '<': + if (IsInsideDocComment()) { + return GetXmlDocumentationCompletionData(); + } + if (controlSpace) { + return DefaultControlSpaceItems(); + } + return null; + case '>': + if (!IsInsideDocComment()) { + if (offset > 2 && document.GetCharAt(offset - 2) == '-' && !IsInsideCommentStringOrDirective()) { + return HandleMemberReferenceCompletion(GetExpressionBeforeCursor()); } - 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] == '/') { - // already closed. - startIndex = -1; - break; - } + 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] == '/') { + // already closed. + startIndex = -1; + break; } + } - if (startIndex >= 0) { - int endIndex = startIndex; - while (endIndex <= location.Column && endIndex < lineText.Length && !Char.IsWhiteSpace (lineText [endIndex])) { - endIndex++; - } - string tag = endIndex - startIndex - 1 > 0 ? lineText.Substring( + if (startIndex >= 0) { + int endIndex = startIndex; + while (endIndex <= location.Column && endIndex < lineText.Length && !Char.IsWhiteSpace (lineText [endIndex])) { + endIndex++; + } + string tag = endIndex - startIndex - 1 > 0 ? lineText.Substring( startIndex + 1, endIndex - startIndex - 2 - ) : null; - if (!string.IsNullOrEmpty(tag) && commentTags.IndexOf(tag) >= 0) { - document.Insert(offset, "</" + tag + ">", AnchorMovementType.BeforeInsertion); - } + ) : null; + if (!string.IsNullOrEmpty(tag) && commentTags.IndexOf(tag) >= 0) { + document.Insert(offset, "</" + tag + ">", AnchorMovementType.BeforeInsertion); } - return null; + } + return null; - // Parameter completion - case '(': - if (IsInsideCommentStringOrDirective()) { - return null; - } - var invoke = GetInvocationBeforeCursor(true); - if (invoke == null) { - if (controlSpace) - return DefaultControlSpaceItems(invoke); - return null; - } - if (invoke.Node is TypeOfExpression) { - return CreateTypeList(); - } - var invocationResult = ResolveExpression(invoke); - if (invocationResult == null) { - return null; - } - var methodGroup = invocationResult.Item1 as MethodGroupResolveResult; - if (methodGroup != null) { - return CreateParameterCompletion( + // Parameter completion + case '(': + if (IsInsideCommentStringOrDirective()) { + return null; + } + var invoke = GetInvocationBeforeCursor(true); + if (invoke == null) { + if (controlSpace) + return DefaultControlSpaceItems(invoke); + return null; + } + if (invoke.Node is TypeOfExpression) { + return CreateTypeList(); + } + var invocationResult = ResolveExpression(invoke); + if (invocationResult == null) { + return null; + } + var methodGroup = invocationResult.Item1 as MethodGroupResolveResult; + if (methodGroup != null) { + return CreateParameterCompletion( methodGroup, invocationResult.Item2, invoke.Node, @@ -373,52 +373,52 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 0, controlSpace ); - } + } - if (controlSpace) { - return DefaultControlSpaceItems(invoke); - } + if (controlSpace) { + return DefaultControlSpaceItems(invoke); + } + return null; + case '=': + return controlSpace ? DefaultControlSpaceItems() : null; + case ',': + int cpos2; + if (!GetParameterCompletionCommandOffset(out cpos2)) { return null; - case '=': - return controlSpace ? DefaultControlSpaceItems() : null; - case ',': - int cpos2; - if (!GetParameterCompletionCommandOffset(out cpos2)) { - return null; - } + } // completionContext = CompletionWidget.CreateCodeCompletionContext (cpos2); // int currentParameter2 = MethodParameterDataProvider.GetCurrentParameterIndex (CompletionWidget, completionContext) - 1; // return CreateParameterCompletion (CreateResolver (), location, ExpressionContext.MethodBody, provider.Methods, currentParameter); - break; + break; - // Completion on space: - case ' ': - int tokenIndex = offset; - string token = GetPreviousToken(ref tokenIndex, false); - if (IsInsideCommentStringOrDirective()) { - if (IsInPreprocessorDirective()) - return HandleKeywordCompletion(tokenIndex, token); - return null; - } + // Completion on space: + case ' ': + int tokenIndex = offset; + string token = GetPreviousToken(ref tokenIndex, false); + if (IsInsideCommentStringOrDirective()) { + if (IsInPreprocessorDirective()) + return HandleKeywordCompletion(tokenIndex, token); + return null; + } // check propose name, for context <variable name> <ctrl+space> (but only in control space context) //IType isAsType = null; - var isAsExpression = GetExpressionAt(offset); - if (controlSpace && isAsExpression != null && isAsExpression.Node is VariableDeclarationStatement && token != "new") { - var parent = isAsExpression.Node as VariableDeclarationStatement; - var proposeNameList = new CompletionDataWrapper(this); - if (parent.Variables.Count != 1) - return DefaultControlSpaceItems(isAsExpression, controlSpace); + var isAsExpression = GetExpressionAt(offset); + if (controlSpace && isAsExpression != null && isAsExpression.Node is VariableDeclarationStatement && token != "new") { + var parent = isAsExpression.Node as VariableDeclarationStatement; + var proposeNameList = new CompletionDataWrapper(this); + if (parent.Variables.Count != 1) + return DefaultControlSpaceItems(isAsExpression, controlSpace); - foreach (var possibleName in GenerateNameProposals (parent.Type)) { - if (possibleName.Length > 0) { - proposeNameList.Result.Add(factory.CreateLiteralCompletionData(possibleName.ToString())); - } + foreach (var possibleName in GenerateNameProposals (parent.Type)) { + if (possibleName.Length > 0) { + proposeNameList.Result.Add(factory.CreateLiteralCompletionData(possibleName.ToString())); } - - AutoSelect = false; - AutoCompleteEmptyMatch = false; - return proposeNameList.Result; } + + AutoSelect = false; + AutoCompleteEmptyMatch = false; + return proposeNameList.Result; + } // int tokenIndex = offset; // string token = GetPreviousToken (ref tokenIndex, false); // if (result.ExpressionContext == ExpressionContext.ObjectInitializer) { @@ -428,67 +428,67 @@ namespace ICSharpCode.NRefactory.CSharp.Completion // 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); - if (prevToken == "=" || prevToken == "+" || prevToken == "-") { - token = prevToken + token; - tokenIndex = j; - } + if (token == "=") { + int j = tokenIndex; + string prevToken = GetPreviousToken(ref j, false); + if (prevToken == "=" || prevToken == "+" || prevToken == "-") { + token = prevToken + token; + tokenIndex = j; + } + } + switch (token) { + case "(": + case ",": + int cpos; + if (!GetParameterCompletionCommandOffset(out cpos)) { + break; } - switch (token) { - case "(": - case ",": - int cpos; - if (!GetParameterCompletionCommandOffset(out cpos)) { - break; - } - int currentParameter = GetCurrentParameterIndex(cpos - 1, this.offset) - 1; - if (currentParameter < 0) { - return null; - } - invoke = GetInvocationBeforeCursor(token == "("); - if (invoke == null) { - return null; - } - invocationResult = ResolveExpression(invoke); - if (invocationResult == null) { - return null; - } - methodGroup = invocationResult.Item1 as MethodGroupResolveResult; - if (methodGroup != null) { - return CreateParameterCompletion( + int currentParameter = GetCurrentParameterIndex(cpos - 1, this.offset) - 1; + if (currentParameter < 0) { + return null; + } + invoke = GetInvocationBeforeCursor(token == "("); + if (invoke == null) { + return null; + } + invocationResult = ResolveExpression(invoke); + if (invocationResult == null) { + return null; + } + methodGroup = invocationResult.Item1 as MethodGroupResolveResult; + if (methodGroup != null) { + return CreateParameterCompletion( methodGroup, invocationResult.Item2, invoke.Node, invoke.Unit, currentParameter, controlSpace); - } - return null; - case "=": - case "==": - GetPreviousToken(ref tokenIndex, false); - var expressionOrVariableDeclaration = GetExpressionAt(tokenIndex); - if (expressionOrVariableDeclaration == null) { - return null; - } + } + return null; + case "=": + case "==": + GetPreviousToken(ref tokenIndex, false); + var expressionOrVariableDeclaration = GetExpressionAt(tokenIndex); + if (expressionOrVariableDeclaration == null) { + return null; + } - resolveResult = ResolveExpression(expressionOrVariableDeclaration); + resolveResult = ResolveExpression(expressionOrVariableDeclaration); - if (resolveResult == null) { - return null; - } - if (resolveResult.Item1.Type.Kind == TypeKind.Enum) { - var wrapper = new CompletionDataWrapper(this); - AddContextCompletion( + if (resolveResult == null) { + return null; + } + if (resolveResult.Item1.Type.Kind == TypeKind.Enum) { + var wrapper = new CompletionDataWrapper(this); + AddContextCompletion( wrapper, resolveResult.Item2, expressionOrVariableDeclaration.Node); - AddEnumMembers(wrapper, resolveResult.Item1.Type, resolveResult.Item2); - AutoCompleteEmptyMatch = false; - return wrapper.Result; - } + AddEnumMembers(wrapper, resolveResult.Item1.Type, resolveResult.Item2); + AutoCompleteEmptyMatch = false; + return wrapper.Result; + } // // if (resolvedType.FullName == DomReturnType.Bool.FullName) { // CompletionDataList completionList = new ProjectDomCompletionDataList (); @@ -513,50 +513,50 @@ namespace ICSharpCode.NRefactory.CSharp.Completion // } // return completionList; // } - return null; - case "+=": - case "-=": - GetPreviousToken(ref tokenIndex, false); + return null; + case "+=": + case "-=": + GetPreviousToken(ref tokenIndex, false); - expressionOrVariableDeclaration = GetExpressionAt(tokenIndex); - if (expressionOrVariableDeclaration == null) { - return null; - } + expressionOrVariableDeclaration = GetExpressionAt(tokenIndex); + if (expressionOrVariableDeclaration == null) { + return null; + } - resolveResult = ResolveExpression(expressionOrVariableDeclaration); - if (resolveResult == null) { - return null; - } + resolveResult = ResolveExpression(expressionOrVariableDeclaration); + if (resolveResult == null) { + return null; + } - var mrr = resolveResult.Item1 as MemberResolveResult; - if (mrr != null) { - var evt = mrr.Member as IEvent; - if (evt == null) { - return null; - } - var delegateType = evt.ReturnType; - if (delegateType.Kind != TypeKind.Delegate) { - return null; - } + var mrr = resolveResult.Item1 as MemberResolveResult; + if (mrr != null) { + var evt = mrr.Member as IEvent; + if (evt == null) { + return null; + } + var delegateType = evt.ReturnType; + if (delegateType.Kind != TypeKind.Delegate) { + return null; + } - var wrapper = new CompletionDataWrapper(this); - if (currentType != null) { - // bool includeProtected = DomType.IncludeProtected (dom, typeFromDatabase, resolver.CallingType); - foreach (var method in ctx.CurrentTypeDefinition.Methods) { - if (MatchDelegate(delegateType, method) /*&& method.IsAccessibleFrom (dom, resolver.CallingType, resolver.CallingMember, includeProtected) &&*/) { - wrapper.AddMember(method); - // data.SetText (data.CompletionText + ";"); - } - } + var wrapper = new CompletionDataWrapper(this); + if (currentType != null) { + // bool includeProtected = DomType.IncludeProtected (dom, typeFromDatabase, resolver.CallingType); + foreach (var method in ctx.CurrentTypeDefinition.Methods) { + if (MatchDelegate(delegateType, method) /*&& method.IsAccessibleFrom (dom, resolver.CallingType, resolver.CallingMember, includeProtected) &&*/) { + wrapper.AddMember(method); + // data.SetText (data.CompletionText + ";"); } - if (token == "+=") { - string parameterDefinition = AddDelegateHandlers( + } + } + if (token == "+=") { + string parameterDefinition = AddDelegateHandlers( wrapper, delegateType - ); - string varName = GetPreviousMemberReferenceExpression(tokenIndex); - wrapper.Result.Add( + ); + string varName = GetPreviousMemberReferenceExpression(tokenIndex); + wrapper.Result.Add( factory.CreateEventCreationCompletionData( varName, delegateType, @@ -564,423 +564,423 @@ namespace ICSharpCode.NRefactory.CSharp.Completion parameterDefinition, currentMember, currentType) - ); - } + ); + } - return wrapper.Result; - } - return null; - case ":": - if (currentMember == null) { - token = GetPreviousToken(ref tokenIndex, false); - token = GetPreviousToken(ref tokenIndex, false); - if (token == "enum") - return HandleEnumContext(); - var wrapper = new CompletionDataWrapper(this); + return wrapper.Result; + } + return null; + case ":": + if (currentMember == null) { + token = GetPreviousToken(ref tokenIndex, false); + token = GetPreviousToken(ref tokenIndex, false); + if (token == "enum") + return HandleEnumContext(); + var wrapper = new CompletionDataWrapper(this); - AddTypesAndNamespaces( + AddTypesAndNamespaces( wrapper, GetState(), null, t => currentType != null && !currentType.ReflectionName.Equals(t.ReflectionName) ? t : null - ); - return wrapper.Result; - } - return null; + ); + return wrapper.Result; } + return null; + } - var keywordCompletion = HandleKeywordCompletion(tokenIndex, token); - if (keywordCompletion == null && controlSpace) { - goto default; - } - return keywordCompletion; - // Automatic completion - default: - if (IsInsideCommentStringOrDirective()) { + var keywordCompletion = HandleKeywordCompletion(tokenIndex, token); + if (keywordCompletion == null && controlSpace) { + goto default; + } + return keywordCompletion; + // Automatic completion + default: + if (IsInsideCommentStringOrDirective()) { + return null; + } + if (IsInLinqContext(offset)) { + if (!controlSpace && !(char.IsLetter(completionChar) || completionChar == '_')) { return null; } - if (IsInLinqContext(offset)) { - if (!controlSpace && !(char.IsLetter(completionChar) || completionChar == '_')) { - return null; - } - tokenIndex = offset; + tokenIndex = offset; + token = GetPreviousToken(ref tokenIndex, false); + // token last typed + if (!char.IsWhiteSpace(completionChar) && !linqKeywords.Contains(token)) { token = GetPreviousToken(ref tokenIndex, false); - // token last typed - if (!char.IsWhiteSpace(completionChar) && !linqKeywords.Contains(token)) { - token = GetPreviousToken(ref tokenIndex, false); - } - // token last typed + } + // token last typed - if (linqKeywords.Contains(token)) { - if (token == "from") { - // after from no auto code completion. - return null; - } - return DefaultControlSpaceItems(); + if (linqKeywords.Contains(token)) { + if (token == "from") { + // after from no auto code completion. + return null; } - var dataList = new CompletionDataWrapper(this); - AddKeywords(dataList, linqKeywords); - return dataList.Result; + return DefaultControlSpaceItems(); } - if (currentType != null && currentType.Kind == TypeKind.Enum) { - return HandleEnumContext(); + var dataList = new CompletionDataWrapper(this); + AddKeywords(dataList, linqKeywords); + return dataList.Result; + } + if (currentType != null && currentType.Kind == TypeKind.Enum) { + return HandleEnumContext(); + } + var contextList = new CompletionDataWrapper(this); + var identifierStart = GetExpressionAtCursor(); + if (identifierStart != null) { + if (identifierStart.Node is TypeParameterDeclaration) { + return null; } - var contextList = new CompletionDataWrapper(this); - var identifierStart = GetExpressionAtCursor(); - if (identifierStart != null) { - if (identifierStart.Node is TypeParameterDeclaration) { - return null; - } - if (identifierStart.Node is MemberReferenceExpression) { - return HandleMemberReferenceCompletion( + if (identifierStart.Node is MemberReferenceExpression) { + return HandleMemberReferenceCompletion( new ExpressionResult( ((MemberReferenceExpression)identifierStart.Node).Target, identifierStart.Unit ) ); - } - - if (identifierStart.Node is Identifier) { - // May happen in variable names - return controlSpace ? DefaultControlSpaceItems(identifierStart) : null; - } - if (identifierStart.Node is VariableInitializer && location <= ((VariableInitializer)identifierStart.Node).NameToken.EndLocation) { - return controlSpace ? HandleAccessorContext() ?? DefaultControlSpaceItems(identifierStart) : null; - } + } - if (identifierStart.Node is CatchClause) { - if (((CatchClause)identifierStart.Node).VariableNameToken.Contains(location)) { - return null; - } - return HandleCatchClauseType(identifierStart); - } + if (identifierStart.Node is Identifier) { + // May happen in variable names + return controlSpace ? DefaultControlSpaceItems(identifierStart) : null; } - if (!(char.IsLetter(completionChar) || completionChar == '_') && (!controlSpace || identifierStart == null || !(identifierStart.Node.Parent is ArrayInitializerExpression))) { + if (identifierStart.Node is VariableInitializer && location <= ((VariableInitializer)identifierStart.Node).NameToken.EndLocation) { return controlSpace ? HandleAccessorContext() ?? DefaultControlSpaceItems(identifierStart) : null; } - - char prevCh = offset > 2 ? document.GetCharAt(offset - 2) : ';'; - char nextCh = offset < document.TextLength ? document.GetCharAt(offset) : ' '; - const string allowedChars = ";,.[](){}+-*/%^?:&|~!<>="; - if (!Char.IsWhiteSpace(nextCh) && allowedChars.IndexOf(nextCh) < 0) { - return null; - } - if (!(Char.IsWhiteSpace(prevCh) || allowedChars.IndexOf(prevCh) >= 0)) { - return null; + + if (identifierStart.Node is CatchClause) { + if (((CatchClause)identifierStart.Node).VariableNameToken.Contains(location)) { + return null; + } + return HandleCatchClauseType(identifierStart); } + } + if (!(char.IsLetter(completionChar) || completionChar == '_') && (!controlSpace || identifierStart == null || !(identifierStart.Node.Parent is ArrayInitializerExpression))) { + return controlSpace ? HandleAccessorContext() ?? DefaultControlSpaceItems(identifierStart) : null; + } + + char prevCh = offset > 2 ? document.GetCharAt(offset - 2) : ';'; + char nextCh = offset < document.TextLength ? document.GetCharAt(offset) : ' '; + const string allowedChars = ";,.[](){}+-*/%^?:&|~!<>="; + if (!Char.IsWhiteSpace(nextCh) && allowedChars.IndexOf(nextCh) < 0) { + return null; + } + if (!(Char.IsWhiteSpace(prevCh) || allowedChars.IndexOf(prevCh) >= 0)) { + return null; + } // Do not pop up completion on identifier identifier (should be handled by keyword completion). - tokenIndex = offset - 1; - token = GetPreviousToken(ref tokenIndex, false); - if (token == "class" || token == "interface" || token == "struct" || token == "enum" || token == "namespace") { - // after these always follows a name - return null; - } - var keywordresult = HandleKeywordCompletion(tokenIndex, token); - if (keywordresult != null) { - return keywordresult; - } + tokenIndex = offset - 1; + token = GetPreviousToken(ref tokenIndex, false); + if (token == "class" || token == "interface" || token == "struct" || token == "enum" || token == "namespace") { + // after these always follows a name + return null; + } + var keywordresult = HandleKeywordCompletion(tokenIndex, token); + if (keywordresult != null) { + return keywordresult; + } - int prevTokenIndex = tokenIndex; - var prevToken2 = GetPreviousToken(ref prevTokenIndex, false); - if (prevToken2 == "delegate") { - // after these always follows a name - return null; - } + int prevTokenIndex = tokenIndex; + var prevToken2 = GetPreviousToken(ref prevTokenIndex, false); + if (prevToken2 == "delegate") { + // after these always follows a name + return null; + } - if (identifierStart == null && !string.IsNullOrEmpty(token) && !IsInsideCommentStringOrDirective() && (prevToken2 == ";" || prevToken2 == "{" || prevToken2 == "}")) { - char last = token [token.Length - 1]; - if (char.IsLetterOrDigit(last) || last == '_' || token == ">") { - return HandleKeywordCompletion(tokenIndex, token); - } + if (identifierStart == null && !string.IsNullOrEmpty(token) && !IsInsideCommentStringOrDirective() && (prevToken2 == ";" || prevToken2 == "{" || prevToken2 == "}")) { + char last = token [token.Length - 1]; + if (char.IsLetterOrDigit(last) || last == '_' || token == ">") { + return HandleKeywordCompletion(tokenIndex, token); } + } - if (identifierStart == null) { - var accCtx = HandleAccessorContext(); - if (accCtx != null) { - return accCtx; - } - return DefaultControlSpaceItems(null, controlSpace); - } - CSharpResolver csResolver; - AstNode n = identifierStart.Node; - if (n != null && n.Parent is AnonymousTypeCreateExpression) { - AutoSelect = false; + if (identifierStart == null) { + var accCtx = HandleAccessorContext(); + if (accCtx != null) { + return accCtx; } + return DefaultControlSpaceItems(null, controlSpace); + } + CSharpResolver csResolver; + AstNode n = identifierStart.Node; + if (n != null && n.Parent is AnonymousTypeCreateExpression) { + AutoSelect = false; + } // Handle foreach (type name _ - if (n is IdentifierExpression) { - var prev = n.GetPrevNode() as ForeachStatement; - if (prev != null && prev.InExpression.IsNull) { - if (controlSpace) { - contextList.AddCustom("in"); - return contextList.Result; - } - return null; + if (n is IdentifierExpression) { + var prev = n.GetPrevNode() as ForeachStatement; + if (prev != null && prev.InExpression.IsNull) { + if (controlSpace) { + contextList.AddCustom("in"); + return contextList.Result; } - - // 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; - // } - // } + 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; + // } + // } + } // Handle object/enumerable initialzer expressions: "new O () { P$" - if (n is IdentifierExpression && n.Parent is ArrayInitializerExpression) { - var result = HandleObjectInitializer(identifierStart.Unit, n); - if (result != null) - return result; - } + if (n is IdentifierExpression && n.Parent is ArrayInitializerExpression) { + var result = HandleObjectInitializer(identifierStart.Unit, n); + if (result != null) + return result; + } - if (n != null && n.Parent is InvocationExpression) { - var invokeParent = (InvocationExpression)n.Parent; - var invokeResult = ResolveExpression( + if (n != null && n.Parent is InvocationExpression) { + var invokeParent = (InvocationExpression)n.Parent; + var invokeResult = ResolveExpression( invokeParent.Target ); - var mgr = invokeResult != null ? invokeResult.Item1 as MethodGroupResolveResult : null; - if (mgr != null) { - int idx = 0; - foreach (var arg in invokeParent.Arguments) { - if (arg == n) { - break; - } - idx++; + var mgr = invokeResult != null ? invokeResult.Item1 as MethodGroupResolveResult : null; + if (mgr != null) { + int idx = 0; + foreach (var arg in invokeParent.Arguments) { + if (arg == n) { + break; } + idx++; + } - foreach (var method in mgr.Methods) { + foreach (var method in mgr.Methods) { + if (idx < method.Parameters.Count && method.Parameters [idx].Type.Kind == TypeKind.Delegate) { + AutoSelect = false; + AutoCompleteEmptyMatch = false; + } + foreach (var p in method.Parameters) { + contextList.AddNamedParameterVariable(p); + } + } + idx++; + foreach (var list in mgr.GetEligibleExtensionMethods (true)) { + foreach (var method in list) { if (idx < method.Parameters.Count && method.Parameters [idx].Type.Kind == TypeKind.Delegate) { AutoSelect = false; AutoCompleteEmptyMatch = false; } - foreach (var p in method.Parameters) { - contextList.AddNamedParameterVariable(p); - } - } - idx++; - foreach (var list in mgr.GetEligibleExtensionMethods (true)) { - foreach (var method in list) { - if (idx < method.Parameters.Count && method.Parameters [idx].Type.Kind == TypeKind.Delegate) { - AutoSelect = false; - AutoCompleteEmptyMatch = false; - } - } } } } + } - if (n != null && n.Parent is ObjectCreateExpression) { - var invokeResult = ResolveExpression(n.Parent); - var mgr = invokeResult != null ? invokeResult.Item1 as ResolveResult : null; - if (mgr != null) { - foreach (var constructor in mgr.Type.GetConstructors ()) { - foreach (var p in constructor.Parameters) { - contextList.AddVariable(p); - } + if (n != null && n.Parent is ObjectCreateExpression) { + var invokeResult = ResolveExpression(n.Parent); + var mgr = invokeResult != null ? invokeResult.Item1 as ResolveResult : null; + if (mgr != null) { + foreach (var constructor in mgr.Type.GetConstructors ()) { + foreach (var p in constructor.Parameters) { + contextList.AddVariable(p); } } } + } - if (n is IdentifierExpression) { - var bop = n.Parent as BinaryOperatorExpression; - Expression evaluationExpr = null; + if (n is IdentifierExpression) { + var bop = n.Parent as BinaryOperatorExpression; + Expression evaluationExpr = null; - if (bop != null && bop.Right == n && (bop.Operator == BinaryOperatorType.Equality || bop.Operator == BinaryOperatorType.InEquality)) { - evaluationExpr = bop.Left; - } - // check for compare to enum case - if (evaluationExpr != null) { - resolveResult = ResolveExpression(evaluationExpr); - if (resolveResult != null && resolveResult.Item1.Type.Kind == TypeKind.Enum) { - var wrapper = new CompletionDataWrapper(this); - AddContextCompletion( + if (bop != null && bop.Right == n && (bop.Operator == BinaryOperatorType.Equality || bop.Operator == BinaryOperatorType.InEquality)) { + evaluationExpr = bop.Left; + } + // check for compare to enum case + if (evaluationExpr != null) { + resolveResult = ResolveExpression(evaluationExpr); + if (resolveResult != null && resolveResult.Item1.Type.Kind == TypeKind.Enum) { + var wrapper = new CompletionDataWrapper(this); + AddContextCompletion( wrapper, resolveResult.Item2, evaluationExpr ); - AddEnumMembers(wrapper, resolveResult.Item1.Type, resolveResult.Item2); - AutoCompleteEmptyMatch = false; - return wrapper.Result; - } + AddEnumMembers(wrapper, resolveResult.Item1.Type, resolveResult.Item2); + AutoCompleteEmptyMatch = false; + return wrapper.Result; } } + } - if (n is Identifier && n.Parent is ForeachStatement) { - if (controlSpace) { - return DefaultControlSpaceItems(); - } - return null; + if (n is Identifier && n.Parent is ForeachStatement) { + if (controlSpace) { + return DefaultControlSpaceItems(); } + return null; + } - if (n is ArrayInitializerExpression) { - // check for new [] {...} expression -> no need to resolve the type there - var parent = n.Parent as ArrayCreateExpression; - if (parent != null && parent.Type.IsNull) { - return DefaultControlSpaceItems(); - } + if (n is ArrayInitializerExpression) { + // check for new [] {...} expression -> no need to resolve the type there + var parent = n.Parent as ArrayCreateExpression; + if (parent != null && parent.Type.IsNull) { + return DefaultControlSpaceItems(); + } - var initalizerResult = ResolveExpression(n.Parent); + var initalizerResult = ResolveExpression(n.Parent); - var concreteNode = identifierStart.Unit.GetNodeAt<IdentifierExpression>(location); - // check if we're on the right side of an initializer expression - if (concreteNode != null && concreteNode.Parent != null && concreteNode.Parent.Parent != null && concreteNode.Identifier != "a" && concreteNode.Parent.Parent is NamedExpression) { - return DefaultControlSpaceItems(); - } - if (initalizerResult != null && initalizerResult.Item1.Type.Kind != TypeKind.Unknown) { + var concreteNode = identifierStart.Unit.GetNodeAt<IdentifierExpression>(location); + // check if we're on the right side of an initializer expression + if (concreteNode != null && concreteNode.Parent != null && concreteNode.Parent.Parent != null && concreteNode.Identifier != "a" && concreteNode.Parent.Parent is NamedExpression) { + return DefaultControlSpaceItems(); + } + if (initalizerResult != null && initalizerResult.Item1.Type.Kind != TypeKind.Unknown) { - foreach (var property in initalizerResult.Item1.Type.GetProperties ()) { - if (!property.IsPublic) { - continue; - } - contextList.AddMember(property); + foreach (var property in initalizerResult.Item1.Type.GetProperties ()) { + if (!property.IsPublic) { + continue; } - foreach (var field in initalizerResult.Item1.Type.GetFields ()) { - if (!field.IsPublic) { - continue; - } - contextList.AddMember(field); + contextList.AddMember(property); + } + foreach (var field in initalizerResult.Item1.Type.GetFields ()) { + if (!field.IsPublic) { + continue; } - return contextList.Result; + contextList.AddMember(field); } - return DefaultControlSpaceItems(); + return contextList.Result; } - if (IsAttributeContext(n)) { - // add attribute targets - if (currentType == null) { - contextList.AddCustom("assembly"); - contextList.AddCustom("module"); - contextList.AddCustom("type"); - } else { - contextList.AddCustom("param"); - contextList.AddCustom("field"); - contextList.AddCustom("property"); - contextList.AddCustom("method"); - contextList.AddCustom("event"); - } - contextList.AddCustom("return"); + return DefaultControlSpaceItems(); + } + if (IsAttributeContext(n)) { + // add attribute targets + if (currentType == null) { + contextList.AddCustom("assembly"); + contextList.AddCustom("module"); + contextList.AddCustom("type"); + } else { + contextList.AddCustom("param"); + contextList.AddCustom("field"); + contextList.AddCustom("property"); + contextList.AddCustom("method"); + contextList.AddCustom("event"); } - if (n is MemberType) { - resolveResult = ResolveExpression( + contextList.AddCustom("return"); + } + if (n is MemberType) { + resolveResult = ResolveExpression( ((MemberType)n).Target ); - return CreateTypeAndNamespaceCompletionData( + return CreateTypeAndNamespaceCompletionData( location, resolveResult.Item1, ((MemberType)n).Target, resolveResult.Item2 ); + } + if (n != null/* && !(identifierStart.Item2 is TypeDeclaration)*/) { + csResolver = new CSharpResolver(ctx); + var nodes = new List<AstNode>(); + nodes.Add(n); + if (n.Parent is ICSharpCode.NRefactory.CSharp.Attribute) { + nodes.Add(n.Parent); } - if (n != null/* && !(identifierStart.Item2 is TypeDeclaration)*/) { - csResolver = new CSharpResolver(ctx); - var nodes = new List<AstNode>(); - nodes.Add(n); - if (n.Parent is ICSharpCode.NRefactory.CSharp.Attribute) { - nodes.Add(n.Parent); - } - var astResolver = CompletionContextProvider.GetResolver(csResolver, identifierStart.Unit); - astResolver.ApplyNavigator(new NodeListResolveVisitorNavigator(nodes)); - try { - csResolver = astResolver.GetResolverStateBefore(n); - } catch (Exception) { - csResolver = GetState(); - } - // add attribute properties. - if (n.Parent is ICSharpCode.NRefactory.CSharp.Attribute) { - var resolved = astResolver.Resolve(n.Parent); - if (resolved != null && resolved.Type != null) { - foreach (var property in resolved.Type.GetProperties (p => p.Accessibility == Accessibility.Public)) { - contextList.AddMember(property); - } - foreach (var field in resolved.Type.GetFields (p => p.Accessibility == Accessibility.Public)) { - contextList.AddMember(field); - } + var astResolver = CompletionContextProvider.GetResolver(csResolver, identifierStart.Unit); + astResolver.ApplyNavigator(new NodeListResolveVisitorNavigator(nodes)); + try { + csResolver = astResolver.GetResolverStateBefore(n); + } catch (Exception) { + csResolver = GetState(); + } + // add attribute properties. + if (n.Parent is ICSharpCode.NRefactory.CSharp.Attribute) { + var resolved = astResolver.Resolve(n.Parent); + if (resolved != null && resolved.Type != null) { + foreach (var property in resolved.Type.GetProperties (p => p.Accessibility == Accessibility.Public)) { + contextList.AddMember(property); + } + foreach (var field in resolved.Type.GetFields (p => p.Accessibility == Accessibility.Public)) { + contextList.AddMember(field); } } - } else { - csResolver = GetState(); } + } else { + csResolver = GetState(); + } // identifier has already started with the first letter - offset--; - AddContextCompletion( + offset--; + AddContextCompletion( contextList, csResolver, identifierStart.Node ); - return contextList.Result; - // if (stub.Parent is BlockStatement) + 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; + // 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; } @@ -989,7 +989,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion { Func<IType, IType> typePred = delegate (IType type) { if (type.GetAllBaseTypes().Any(t => t.ReflectionName == "System.Exception")) - return type; + return type; return null; }; if (identifierStart.Node is CatchClause) { @@ -1000,7 +1000,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion identifierStart.Node, typePred, m => false - ); + ); return wrapper.Result; } @@ -1011,7 +1011,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion identifierStart.Node, resolveResult.Item2, typePred - ); + ); } string[] validEnumBaseTypes = { @@ -1114,7 +1114,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion location.Line, location.Column + 2, n => n is Expression || n is AstType - ); + ); rr = ResolveExpression(node); } if (node is Identifier && node.Parent is ForeachStatement) { @@ -1200,7 +1200,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion wrapper.AddVariable(variable); } } - + if (state.CurrentMember is IParameterizedMember && !(node is AstType)) { var param = (IParameterizedMember)state.CurrentMember; foreach (var p in param.Parameters) { @@ -1295,7 +1295,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion // Add 'this' keyword for first parameter (extension method case) if (node != null && node.Parent is ParameterDeclaration && - node.Parent.PrevSibling != null && node.Parent.PrevSibling.Role == Roles.LPar) { + node.Parent.PrevSibling != null && node.Parent.PrevSibling.Role == Roles.LPar) { wrapper.AddCustom("this"); } } @@ -1436,254 +1436,254 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return null; } switch (word) { - case "namespace": + case "namespace": + return null; + case "using": + if (currentType != null) { return null; - case "using": - if (currentType != null) { - return null; - } - var wrapper = new CompletionDataWrapper(this); - AddTypesAndNamespaces(wrapper, GetState(), null, t => null); - 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 "is": - case "as": - if (currentType == null) { - return null; - } - IType isAsType = null; - var isAsExpression = GetExpressionAt(wordStart); - if (isAsExpression != null) { - var parent = isAsExpression.Node.Parent; - if (parent is VariableInitializer) { - parent = parent.Parent; - } - if (parent is VariableDeclarationStatement) { - var resolved = ResolveExpression(parent); - if (resolved != null) { - isAsType = resolved.Item1.Type; - } + } + var wrapper = new CompletionDataWrapper(this); + AddTypesAndNamespaces(wrapper, GetState(), null, t => null); + 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 "is": + case "as": + if (currentType == null) { + return null; + } + IType isAsType = null; + var isAsExpression = GetExpressionAt(wordStart); + if (isAsExpression != null) { + var parent = isAsExpression.Node.Parent; + if (parent is VariableInitializer) { + parent = parent.Parent; + } + if (parent is VariableDeclarationStatement) { + var resolved = ResolveExpression(parent); + if (resolved != null) { + isAsType = resolved.Item1.Type; } } - var isAsWrapper = new CompletionDataWrapper(this); - var def = isAsType != null ? isAsType.GetDefinition() : null; - AddTypesAndNamespaces( + } + var isAsWrapper = new CompletionDataWrapper(this); + var def = isAsType != null ? isAsType.GetDefinition() : null; + AddTypesAndNamespaces( isAsWrapper, GetState(), null, 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); - // } - case "override": + 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); + // } + case "override": // Look for modifiers, in order to find the beginning of the declaration - int firstMod = wordStart; - int i = wordStart; - for (int n = 0; n < 3; n++) { - string mod = GetPreviousToken(ref i, true); - if (mod == "public" || mod == "protected" || mod == "private" || mod == "internal" || mod == "sealed") { - firstMod = i; - } else if (mod == "static") { - // static methods are not overridable - return null; - } else { - break; - } - } - if (!IsLineEmptyUpToEol()) { + int firstMod = wordStart; + int i = wordStart; + for (int n = 0; n < 3; n++) { + string mod = GetPreviousToken(ref i, true); + if (mod == "public" || mod == "protected" || mod == "private" || mod == "internal" || mod == "sealed") { + firstMod = i; + } else if (mod == "static") { + // static methods are not overridable return null; + } else { + break; } - if (currentType != null && (currentType.Kind == TypeKind.Class || currentType.Kind == TypeKind.Struct)) { - string modifiers = document.GetText(firstMod, wordStart - firstMod); - return GetOverrideCompletionData(currentType, modifiers); - } + } + if (!IsLineEmptyUpToEol()) { return null; - case "partial": + } + if (currentType != null && (currentType.Kind == TypeKind.Class || currentType.Kind == TypeKind.Struct)) { + string modifiers = document.GetText(firstMod, wordStart - firstMod); + return GetOverrideCompletionData(currentType, modifiers); + } + return null; + case "partial": // Look for modifiers, in order to find the beginning of the declaration - firstMod = wordStart; - i = wordStart; - for (int n = 0; n < 3; n++) { - string mod = GetPreviousToken(ref i, true); - if (mod == "public" || mod == "protected" || mod == "private" || mod == "internal" || mod == "sealed") { - firstMod = i; - } else if (mod == "static") { - // static methods are not overridable - return null; - } else { - break; - } - } - if (!IsLineEmptyUpToEol()) { + firstMod = wordStart; + i = wordStart; + for (int n = 0; n < 3; n++) { + string mod = GetPreviousToken(ref i, true); + if (mod == "public" || mod == "protected" || mod == "private" || mod == "internal" || mod == "sealed") { + firstMod = i; + } else if (mod == "static") { + // static methods are not overridable return null; + } else { + break; } - var state = GetState(); - - if (state.CurrentTypeDefinition != null && (state.CurrentTypeDefinition.Kind == TypeKind.Class || state.CurrentTypeDefinition.Kind == TypeKind.Struct)) { - string modifiers = document.GetText(firstMod, wordStart - firstMod); - return GetPartialCompletionData(state.CurrentTypeDefinition, modifiers); - } + } + if (!IsLineEmptyUpToEol()) { return null; + } + var state = GetState(); - case "public": - case "protected": - case "private": - case "internal": - case "sealed": - case "static": - var accessorContext = HandleAccessorContext(); - if (accessorContext != null) { - return accessorContext; - } - wrapper = new CompletionDataWrapper(this); - state = GetState(); - if (currentType != null) { - AddTypesAndNamespaces(wrapper, state, null, null, m => false); - AddKeywords(wrapper, primitiveTypesKeywords); - } - AddKeywords(wrapper, typeLevelKeywords); - return wrapper.Result; - case "new": - int j = offset - 4; + if (state.CurrentTypeDefinition != null && (state.CurrentTypeDefinition.Kind == TypeKind.Class || state.CurrentTypeDefinition.Kind == TypeKind.Struct)) { + string modifiers = document.GetText(firstMod, wordStart - firstMod); + return GetPartialCompletionData(state.CurrentTypeDefinition, modifiers); + } + return null; + + case "public": + case "protected": + case "private": + case "internal": + case "sealed": + case "static": + var accessorContext = HandleAccessorContext(); + if (accessorContext != null) { + return accessorContext; + } + wrapper = new CompletionDataWrapper(this); + state = GetState(); + if (currentType != null) { + AddTypesAndNamespaces(wrapper, state, null, null, m => false); + AddKeywords(wrapper, primitiveTypesKeywords); + } + AddKeywords(wrapper, typeLevelKeywords); + return wrapper.Result; + case "new": + int j = offset - 4; // string token = GetPreviousToken (ref j, true); - IType hintType = null; - var expressionOrVariableDeclaration = GetNewExpressionAt(j); - if (expressionOrVariableDeclaration == null) - return null; - var astResolver = CompletionContextProvider.GetResolver(GetState(), expressionOrVariableDeclaration.Unit); - hintType = CreateFieldAction.GetValidTypes( + IType hintType = null; + var expressionOrVariableDeclaration = GetNewExpressionAt(j); + if (expressionOrVariableDeclaration == null) + return null; + var astResolver = CompletionContextProvider.GetResolver(GetState(), expressionOrVariableDeclaration.Unit); + hintType = CreateFieldAction.GetValidTypes( astResolver, expressionOrVariableDeclaration.Node as Expression ) .FirstOrDefault(); - return CreateTypeCompletionData(hintType); - case "yield": - var yieldDataList = new CompletionDataWrapper(this); - DefaultCompletionString = "return"; - yieldDataList.AddCustom("break"); - yieldDataList.AddCustom("return"); - return yieldDataList.Result; - case "in": - var inList = new CompletionDataWrapper(this); + return CreateTypeCompletionData(hintType); + case "yield": + var yieldDataList = new CompletionDataWrapper(this); + DefaultCompletionString = "return"; + yieldDataList.AddCustom("break"); + yieldDataList.AddCustom("return"); + return yieldDataList.Result; + case "in": + var inList = new CompletionDataWrapper(this); - var expr = GetExpressionAtCursor(); - var rr = ResolveExpression(expr); + var expr = GetExpressionAtCursor(); + var rr = ResolveExpression(expr); - AddContextCompletion( + AddContextCompletion( inList, rr != null ? rr.Item2 : GetState(), expr.Node ); - return inList.Result; + return inList.Result; } return null; } @@ -1740,12 +1740,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion var lookup = new MemberLookup( ctx.CurrentTypeDefinition, Compilation.MainAssembly - ); + ); typeCallback = (data, t) => { //check if type is in inheritance tree. if (hintType.GetDefinition() != null && - t.GetDefinition() != null && - t.GetDefinition().IsDerivedFrom(hintType.GetDefinition())) { + t.GetDefinition() != null && + t.GetDefinition().IsDerivedFrom(hintType.GetDefinition())) { data.CompletionCategory = derivedTypesCategory; } }; @@ -1761,8 +1761,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (!t.GetConstructors().Any(m => lookup.IsAccessible( m, isProtectedAllowed - ) - )) { + ) + )) { return null; } } @@ -1822,16 +1822,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion int j = declarationBegin; for (int i = 0; i < 3; i++) { switch (GetPreviousToken(ref j, true)) { - case "public": - case "protected": - case "private": - case "internal": - case "sealed": - case "override": - declarationBegin = j; - break; - case "static": - return null; // don't add override completion for static members + case "public": + case "protected": + case "private": + case "internal": + case "sealed": + case "override": + declarationBegin = j; + break; + case "static": + return null; // don't add override completion for static members } } AddVirtuals( @@ -1840,7 +1840,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion modifiers, type.Resolve(ctx), declarationBegin - ); + ); return wrapper.Result; } @@ -1851,16 +1851,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion int j = declarationBegin; for (int i = 0; i < 3; i++) { switch (GetPreviousToken(ref j, true)) { - case "public": - case "protected": - case "private": - case "internal": - case "sealed": - case "override": - declarationBegin = j; - break; - case "static": - return null; // don't add override completion for static members + case "public": + case "protected": + case "private": + case "internal": + case "sealed": + case "override": + declarationBegin = j; + break; + case "static": + return null; // don't add override completion for static members } } @@ -1882,8 +1882,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion declarationBegin, method.DeclaringTypeDefinition, method - ) - ); + ) + ); } return wrapper.Result; @@ -1926,13 +1926,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion declarationBegin, currentType, m - ); + ); // check if the member is already implemented bool foundMember = curType.GetMembers().Any(cm => SignatureComparer.Ordinal.Equals( cm, m - ) && cm.DeclaringTypeDefinition == curType.GetDefinition() - ); + ) && cm.DeclaringTypeDefinition == curType.GetDefinition() + ); if (foundMember) { continue; } @@ -2014,34 +2014,47 @@ namespace ICSharpCode.NRefactory.CSharp.Completion "delegate", "Creates anonymous delegate.", "delegate {" + EolMarker + thisLineIndent + IndentString + "|" + delegateEndString - ); + ); } var sb = new StringBuilder("("); var sbWithoutTypes = new StringBuilder("("); + var state = GetState(); + var builder = new TypeSystemAstBuilder(state); + for (int k = 0; k < delegateMethod.Parameters.Count; k++) { if (k > 0) { sb.Append(", "); sbWithoutTypes.Append(", "); } - var parameterType = delegateMethod.Parameters [k].Type; - sb.Append(GetShortType(parameterType, GetState())); - sb.Append(" "); - sb.Append(delegateMethod.Parameters [k].Name); + var convertedParameter = builder.ConvertParameter (delegateMethod.Parameters [k]); + if (convertedParameter.ParameterModifier == ParameterModifier.Params) + convertedParameter.ParameterModifier = ParameterModifier.None; + sb.Append(convertedParameter.GetText (FormattingPolicy)); sbWithoutTypes.Append(delegateMethod.Parameters [k].Name); } + sb.Append(")"); sbWithoutTypes.Append(")"); completionList.AddCustom( "delegate" + sb, "Creates anonymous delegate.", "delegate" + sb + " {" + EolMarker + thisLineIndent + IndentString + "|" + delegateEndString - ); - if (!completionList.Result.Any(data => data.DisplayText == sbWithoutTypes.ToString())) { + ); + + if (!completionList.Result.Any(data => data.DisplayText == sb.ToString())) { + completionList.AddCustom( + sb.ToString(), + "Creates typed lambda expression.", + sb + " => |" + (addSemicolon ? ";" : "") + ); + } + + if (!delegateMethod.Parameters.Any (p => p.IsOut || p.IsRef) && !completionList.Result.Any(data => data.DisplayText == sbWithoutTypes.ToString())) { completionList.AddCustom( sbWithoutTypes.ToString(), "Creates lambda expression.", sbWithoutTypes + " => |" + (addSemicolon ? ";" : "") - ); + ); } /* TODO:Make factory method out of it. // It's needed to temporarly disable inserting auto matching bracket because the anonymous delegates are selectable with '(' @@ -2075,7 +2088,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion calledType, currentMember, includeProtected - ); + ); } if (member.IsProtected && !(member.DeclaringTypeDefinition.IsProtectedOrInternal && !includeProtected)) { @@ -2103,7 +2116,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion // should never happen ! result = true; }*/ - return member.IsProtectedAndInternal ? includeProtected && result : result; + return member.IsProtectedAndInternal ? includeProtected && result : result; } if (!(currentMember is IType) && (currentMember.DeclaringTypeDefinition == null || member.DeclaringTypeDefinition == null)) { @@ -2215,7 +2228,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion parameterDefinition, currentMember, currentType) - ); + ); } } @@ -2310,7 +2323,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion var lookup = new MemberLookup( ctx.CurrentTypeDefinition, Compilation.MainAssembly - ); + ); if (resolveResult is LocalResolveResult) { @@ -2340,7 +2353,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion resolveResult, ((IdentifierExpression)resolvedNode).Identifier, out trr - )) { + )) { if (currentMember != null && mrr.Member.IsStatic ^ currentMember.IsStatic) { skipNonStaticMembers = true; @@ -2593,8 +2606,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } tref.ReplaceWith(expr); } - exit: - return new ExpressionResult((AstNode)expr, baseUnit); + exit: + return new ExpressionResult((AstNode)expr, baseUnit); } ExpressionResult GetExpressionAtCursor() @@ -2612,7 +2625,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion AstNode expr = baseUnit.GetNodeAt( location, n => n is IdentifierExpression || n is MemberReferenceExpression - ); + ); if (expr == null) { expr = baseUnit.GetNodeAt<AstType>(location.Line, location.Column - 1); @@ -2623,12 +2636,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (expr == null && baseUnit.GetNodeAt<EmptyStatement>( location.Line, location.Column - ) != null) { + ) != null) { tmpUnit = baseUnit = ParseStub("a();", false); expr = baseUnit.GetNodeAt<InvocationExpression>( location.Line, location.Column + 1 - ); + ); } if (expr == null) { @@ -2636,7 +2649,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion expr = baseUnit.GetNodeAt<IdentifierExpression>( location.Line, location.Column - 1 - ); + ); if (expr == null) { expr = baseUnit.GetNodeAt<MemberType>(location.Line, location.Column - 1); } @@ -2647,7 +2660,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion expr = baseUnit.GetNodeAt( location, n => n is IdentifierExpression || n is MemberReferenceExpression || n is CatchClause - ); + ); } // try statement @@ -2655,7 +2668,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion expr = tmpUnit.GetNodeAt<SwitchStatement>( location.Line, location.Column - 1 - ); + ); baseUnit = tmpUnit; } @@ -2677,7 +2690,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion var forStmt = tmpUnit.GetNodeAt<ForeachStatement>( location.Line, location.Column - 3 - ); + ); if (forStmt != null && forStmt.EmbeddedStatement.IsNull) { forStmt.VariableNameToken = Identifier.Create("stub"); expr = forStmt.VariableNameToken; @@ -2688,7 +2701,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion expr = tmpUnit.GetNodeAt<VariableInitializer>( location.Line, location.Column - 1 - ); + ); baseUnit = tmpUnit; } @@ -2698,7 +2711,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion expr = baseUnit.GetNodeAt<TypeParameterDeclaration>( location.Line, location.Column - 1 - ); + ); } // try parameter declaration method @@ -2707,7 +2720,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion expr = baseUnit.GetNodeAt<TypeParameterDeclaration>( location.Line, location.Column - 1 - ); + ); } // try expression in anonymous type "new { sample = x$" case @@ -2716,7 +2729,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion expr = baseUnit.GetNodeAt<AnonymousTypeCreateExpression>( location.Line, location.Column - ); + ); if (expr != null) { expr = baseUnit.GetNodeAt<Expression>(location.Line, location.Column) ?? expr; } @@ -2746,7 +2759,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion var expr = completionUnit.GetNodeAt( loc, n => n is Expression || n is VariableDeclarationStatement - ); + ); if (expr == null) { return null; } @@ -2868,14 +2881,14 @@ namespace ICSharpCode.NRefactory.CSharp.Completion "summary", "value" } - ); + ); string GetLastClosingXmlCommentTag() { var line = document.GetLineByNumber(location.Line); - restart: - string lineText = document.GetText(line); + restart: + string lineText = document.GetText(line); if (!lineText.Trim().StartsWith("///")) return null; int startIndex = Math.Min(location.Column - 1, lineText.Length - 1) - 1; @@ -2914,105 +2927,105 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (closingTag != null) { yield return factory.CreateLiteralCompletionData( "/" + closingTag + ">" - ); + ); } yield return factory.CreateLiteralCompletionData( "c", "Set text in a code-like font" - ); + ); yield return factory.CreateLiteralCompletionData( "code", "Set one or more lines of source code or program output" - ); + ); yield return factory.CreateLiteralCompletionData( "example", "Indicate an example" - ); + ); yield return factory.CreateLiteralCompletionData( "exception", "Identifies the exceptions a method can throw", "exception cref=\"|\"></exception>" - ); + ); yield return factory.CreateLiteralCompletionData( "include", "Includes comments from a external file", "include file=\"|\" path=\"\">" - ); + ); yield return factory.CreateLiteralCompletionData( "list", "Create a list or table", "list type=\"|\">" - ); + ); yield return factory.CreateLiteralCompletionData( "listheader", "Define the heading row" - ); + ); yield return factory.CreateLiteralCompletionData( "item", "Defines list or table item" - ); + ); yield return factory.CreateLiteralCompletionData("term", "A term to define"); yield return factory.CreateLiteralCompletionData( "description", "Describes a list item" - ); + ); yield return factory.CreateLiteralCompletionData( "para", "Permit structure to be added to text" - ); + ); yield return factory.CreateLiteralCompletionData( "param", "Describe a parameter for a method or constructor", "param name=\"|\">" - ); + ); yield return factory.CreateLiteralCompletionData( "paramref", "Identify that a word is a parameter name", "paramref name=\"|\"/>" - ); + ); yield return factory.CreateLiteralCompletionData( "permission", "Document the security accessibility of a member", "permission cref=\"|\"" - ); + ); yield return factory.CreateLiteralCompletionData( "remarks", "Describe a type" - ); + ); yield return factory.CreateLiteralCompletionData( "returns", "Describe the return value of a method" - ); + ); yield return factory.CreateLiteralCompletionData( "see", "Specify a link", "see cref=\"|\"/>" - ); + ); yield return factory.CreateLiteralCompletionData( "seealso", "Generate a See Also entry", "seealso cref=\"|\"/>" - ); + ); yield return factory.CreateLiteralCompletionData( "summary", "Describe a member of a type" - ); + ); yield return factory.CreateLiteralCompletionData( "typeparam", "Describe a type parameter for a generic type or method" - ); + ); yield return factory.CreateLiteralCompletionData( "typeparamref", "Identify that a word is a type parameter name" - ); + ); yield return factory.CreateLiteralCompletionData( "value", "Describe a property" - ); + ); } #endregion |