提交 dedba13d 编写于 作者: D Dustin Campbell

Code review feedback for C# and VB cref completion clean up

上级 f74d5081
......@@ -59,11 +59,6 @@ public override async Task ProduceCompletionListAsync(CompletionListContext cont
var token = tree.FindTokenOnLeftOfPosition(position, cancellationToken)
.GetPreviousTokenIfTouchingWord(position);
if (token.Kind() == SyntaxKind.None)
{
return;
}
// To get a Speculative SemanticModel (which is much faster), we need to
// walk up to the node the DocumentationTrivia is attached to.
var parentNode = token.Parent.FirstAncestorOrSelf<DocumentationCommentTriviaSyntax>()?.ParentTrivia.Token.Parent;
......@@ -218,8 +213,8 @@ private static TextSpan GetTextChangeSpan(SourceText text, int position)
return CommonCompletionUtilities.GetTextChangeSpan(
text,
position,
(ch) => CompletionUtilities.IsTextChangeSpanStartCharacter(ch) || ch == '{',
(ch) => CompletionUtilities.IsWordCharacter(ch) || ch == '{' || ch == '}');
ch => CompletionUtilities.IsTextChangeSpanStartCharacter(ch) || ch == '{',
ch => CompletionUtilities.IsWordCharacter(ch) || ch == '{' || ch == '}');
}
private IEnumerable<CompletionItem> CreateCompletionItems(
......
......@@ -7,6 +7,7 @@ Imports Microsoft.CodeAnalysis.Completion
Imports Microsoft.CodeAnalysis.Completion.Providers
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.Providers
......@@ -31,12 +32,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.Providers
Dim cancellationToken = context.CancellationToken
Dim tree = Await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(False)
Dim token = tree.FindTokenOnLeftOfPosition(position, cancellationToken) _
.GetPreviousTokenIfTouchingWord(position)
If token.Kind = SyntaxKind.None Then
Return
End If
Dim token = tree.GetTargetToken(position, cancellationToken)
If IsCrefTypeParameterContext(token) Then
Return
......
......@@ -394,7 +394,7 @@ public static ImmutableArray<IParameterSymbol> GetParameters(this ISymbol symbol
{
return symbol.TypeSwitch(
(IMethodSymbol m) => m.Parameters,
(IPropertySymbol p) => p.Parameters,
(IPropertySymbol nt) => nt.Parameters,
_ => ImmutableArray.Create<IParameterSymbol>());
}
......@@ -416,7 +416,8 @@ public static ImmutableArray<ITypeSymbol> GetTypeArguments(this ISymbol symbol)
public static ImmutableArray<ITypeSymbol> GetAllTypeArguments(this ISymbol symbol)
{
var results = new List<ITypeSymbol>(symbol.GetTypeArguments());
var results = ImmutableArray.CreateBuilder<ITypeSymbol>();
results.AddRange(symbol.GetTypeArguments());
var containingType = symbol.ContainingType;
while (containingType != null)
......@@ -425,7 +426,7 @@ public static ImmutableArray<ITypeSymbol> GetAllTypeArguments(this ISymbol symbo
containingType = containingType.ContainingType;
}
return ImmutableArray.CreateRange(results);
return results.AsImmutable();
}
public static bool IsAttribute(this ISymbol symbol)
......@@ -517,12 +518,6 @@ public static bool IsUnsafe(this ISymbol member)
return compilation.ObjectType;
}
public static bool IsDeprecated(this ISymbol symbol)
{
// TODO(cyrusn): Implement this
return false;
}
public static bool IsStaticType(this ISymbol symbol)
{
return symbol != null && symbol.Kind == SymbolKind.NamedType && symbol.IsStatic;
......
......@@ -27,7 +27,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery
End If
token = token.GetPreviousToken()
Loop
Return token
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册