提交 1285d254 编写于 作者: C Cyrus Najmabadi

Don't have 'Keyword' map to 'ReservedKeyword' and 'ContextualKeyword' it just...

Don't have 'Keyword' map to 'ReservedKeyword' and 'ContextualKeyword' it just ends up confusing people with terminology.
上级 d7c58102
......@@ -56,7 +56,7 @@ private IInlineRenameInfo GetRenameInfo(Document document, int position, Cancell
Document document, SyntaxToken triggerToken, CancellationToken cancellationToken)
{
var syntaxFactsService = document.GetLanguageService<ISyntaxFactsService>();
if (syntaxFactsService.IsKeyword(triggerToken))
if (syntaxFactsService.IsReservedOrContextualKeyword(triggerToken))
{
return new FailureInlineRenameInfo(EditorFeaturesResources.You_must_rename_an_identifier);
}
......
......@@ -8,6 +8,7 @@
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Simplification;
using Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.Collections;
using Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.InternalElements;
......@@ -541,7 +542,7 @@ internal EnvDTE.CodeElement CodeElementFromPosition(int position, EnvDTE.vsCMEle
// If both tokens are touching, we prefer identifiers and keywords to
// separators. Note that the language doesn't allow both tokens to be a
// keyword or identifier.
if (SyntaxFactsService.IsKeyword(rightToken) ||
if (SyntaxFactsService.IsReservedOrContextualKeyword(rightToken) ||
SyntaxFactsService.IsIdentifier(rightToken))
{
token = rightToken;
......
......@@ -81,26 +81,14 @@ public bool IsOperator(SyntaxToken token)
(SyntaxFacts.IsAssignmentExpressionOperatorToken(kind) && token.Parent is AssignmentExpressionSyntax);
}
public bool IsKeyword(SyntaxToken token)
{
var kind = (SyntaxKind)token.RawKind;
return
SyntaxFacts.IsKeywordKind(kind); // both contextual and reserved keywords
}
public bool IsReservedKeyword(SyntaxToken token)
=> SyntaxFacts.IsReservedKeyword(token.Kind());
public bool IsContextualKeyword(SyntaxToken token)
{
var kind = (SyntaxKind)token.RawKind;
return
SyntaxFacts.IsContextualKeyword(kind);
}
=> SyntaxFacts.IsContextualKeyword(token.Kind());
public bool IsPreprocessorKeyword(SyntaxToken token)
{
var kind = (SyntaxKind)token.RawKind;
return
SyntaxFacts.IsPreprocessorKeyword(kind);
}
=> SyntaxFacts.IsPreprocessorKeyword(token.Kind());
public bool IsHashToken(SyntaxToken token)
{
......
......@@ -31,7 +31,7 @@ internal interface ISyntaxFactsService : ILanguageService
bool IsPredefinedType(SyntaxToken token, PredefinedType type);
bool IsPredefinedOperator(SyntaxToken token);
bool IsPredefinedOperator(SyntaxToken token, PredefinedOperator op);
bool IsKeyword(SyntaxToken token);
bool IsReservedKeyword(SyntaxToken token);
bool IsContextualKeyword(SyntaxToken token);
bool IsPreprocessorKeyword(SyntaxToken token);
bool IsHashToken(SyntaxToken token);
......
......@@ -32,11 +32,13 @@ public static bool IsLegalIdentifier(this ISyntaxFactsService syntaxFacts, strin
return true;
}
public static bool IsReservedOrContextualKeyword(this ISyntaxFactsService syntaxFacts, SyntaxToken token)
=> syntaxFacts.IsReservedKeyword(token) || syntaxFacts.IsContextualKeyword(token);
public static bool IsWord(this ISyntaxFactsService syntaxFacts, SyntaxToken token)
{
return syntaxFacts.IsIdentifier(token)
|| syntaxFacts.IsKeyword(token)
|| syntaxFacts.IsContextualKeyword(token)
|| syntaxFacts.IsReservedOrContextualKeyword(token)
|| syntaxFacts.IsPreprocessorKeyword(token);
}
......
......@@ -327,7 +327,8 @@ private static string TrimNameToAfterLastDot(string name)
if (location.IsInSource)
{
var token = location.FindToken(cancellationToken);
if (!syntaxFacts.IsKeyword(token) && token.ValueText == referencedSymbol.Name)
if (!syntaxFacts.IsReservedOrContextualKeyword(token) &&
token.ValueText == referencedSymbol.Name)
{
results.Add(new RenameLocation(location, solution.GetDocument(location.SourceTree).Id));
}
......
......@@ -56,7 +56,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CaseCorrection
If _syntaxFactsService.IsIdentifier(newToken) Then
Return VisitIdentifier(token, newToken)
ElseIf _syntaxFactsService.IsKeyword(newToken) OrElse _syntaxFactsService.IsContextualKeyword(newToken) Then
ElseIf _syntaxFactsService.IsReservedOrContextualKeyword(newToken) Then
Return VisitKeyword(newToken)
ElseIf token.IsNumericLiteral() Then
Return VisitNumericLiteral(newToken)
......
......@@ -101,8 +101,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return token.IsContextualKeyword()
End Function
Public Function IsKeyword(token As SyntaxToken) As Boolean Implements ISyntaxFactsService.IsKeyword
Return token.IsKeyword()
Public Function IsReservedKeyword(token As SyntaxToken) As Boolean Implements ISyntaxFactsService.IsReservedKeyword
Return token.IsReservedKeyword()
End Function
Public Function IsPreprocessorKeyword(token As SyntaxToken) As Boolean Implements ISyntaxFactsService.IsPreprocessorKeyword
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册