Skip to content

Commit

Permalink
Merge pull request #63247 from dotnet/merges/main-to-main-vs-deps
Browse files Browse the repository at this point in the history
Merge main to main-vs-deps
  • Loading branch information
dotnet-bot authored Aug 6, 2022
2 parents d35ab64 + e1eeada commit 5f774b3
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ private static async Task AddLocationSpanAsync(Location location, Solution solut
var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);
var token = root.FindToken(location.SourceSpan.Start, findInsideTrivia: true);

return syntaxFacts.IsGenericName(token.Parent) || syntaxFacts.IsIndexerMemberCRef(token.Parent)
return syntaxFacts.IsGenericName(token.Parent) || syntaxFacts.IsIndexerMemberCref(token.Parent)
? new DocumentSpan(document, token.Span)
: new DocumentSpan(document, location.SourceSpan);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private static async Task<ImmutableArray<FinderLocation>> FindIndexerReferencesA
.Where(node =>
syntaxFacts.IsElementAccessExpression(node) ||
syntaxFacts.IsConditionalAccessExpression(node) ||
syntaxFacts.IsIndexerMemberCRef(node));
syntaxFacts.IsIndexerMemberCref(node));
using var _ = ArrayBuilder<FinderLocation>.GetInstance(out var locations);

foreach (var node in indexerReferenceExpresssions)
Expand Down Expand Up @@ -232,7 +232,7 @@ private static async Task<ImmutableArray<FinderLocation>> FindIndexerReferencesA
}
else
{
Debug.Assert(syntaxFacts.IsIndexerMemberCRef(node));
Debug.Assert(syntaxFacts.IsIndexerMemberCref(node));
return ComputeIndexerMemberCRefInformationAsync(symbol, state, node, cancellationToken);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static SyntaxTreeIndex CreateIndex(
containsUsingStatement = containsUsingStatement || syntaxFacts.IsUsingStatement(node);
containsQueryExpression = containsQueryExpression || syntaxFacts.IsQueryExpression(node);
containsElementAccess = containsElementAccess || syntaxFacts.IsElementAccessExpression(node);
containsIndexerMemberCref = containsIndexerMemberCref || syntaxFacts.IsIndexerMemberCRef(node);
containsIndexerMemberCref = containsIndexerMemberCref || syntaxFacts.IsIndexerMemberCref(node);

containsDeconstruction = containsDeconstruction || syntaxFacts.IsDeconstructionAssignment(node)
|| syntaxFacts.IsDeconstructionForEachStatement(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,6 @@ public bool IsElementAccessExpression(SyntaxNode? node)
public SyntaxNode? ConvertToSingleLine(SyntaxNode? node, bool useElasticTrivia = false)
=> node.ConvertToSingleLine(useElasticTrivia);

public bool IsIndexerMemberCRef(SyntaxNode? node)
=> node.IsKind(SyntaxKind.IndexerMemberCref);

public SyntaxNode? GetContainingMemberDeclaration(SyntaxNode root, int position, bool useFullSpan = true)
{
var end = root.FullSpan.End;
Expand Down Expand Up @@ -1350,12 +1347,6 @@ public SyntaxNode GetExpressionOfForeachStatement(SyntaxNode node)
public SyntaxNode GetExpressionOfExpressionStatement(SyntaxNode node)
=> ((ExpressionStatementSyntax)node).Expression;

public bool IsIsTypeExpression([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.IsExpression);

public bool IsIsNotTypeExpression([NotNullWhen(true)] SyntaxNode? node)
=> false;

public void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode
{
Expand Down Expand Up @@ -1433,9 +1424,6 @@ public SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(Syn
throw ExceptionUtilities.UnexpectedValue(trivia.Kind());
}

public bool IsIsPatternExpression([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.IsPatternExpression);

public void GetPartsOfAnyIsTypeExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode type)
{
var isPatternExpression = (BinaryExpressionSyntax)node;
Expand All @@ -1454,18 +1442,6 @@ public void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left,
public bool IsAnyPattern([NotNullWhen(true)] SyntaxNode? node)
=> node is PatternSyntax;

public bool IsConstantPattern([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.ConstantPattern);

public bool IsDeclarationPattern([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.DeclarationPattern);

public bool IsRecursivePattern([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.RecursivePattern);

public bool IsVarPattern([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.VarPattern);

public SyntaxNode GetExpressionOfConstantPattern(SyntaxNode node)
=> ((ConstantPatternSyntax)node).Expression;

Expand All @@ -1492,24 +1468,9 @@ public bool SupportsNotPattern(ParseOptions options)
public bool SupportsIsNotTypeExpression(ParseOptions options)
=> false;

public bool IsAndPattern([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.AndPattern);

public bool IsBinaryPattern([NotNullWhen(true)] SyntaxNode? node)
=> node is BinaryPatternSyntax;

public bool IsNotPattern([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.NotPattern);

public bool IsOrPattern([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.OrPattern);

public bool IsParenthesizedPattern([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.ParenthesizedPattern);

public bool IsTypePattern([NotNullWhen(true)] SyntaxNode? node)
=> node.IsKind(SyntaxKind.TypePattern);

public bool IsUnaryPattern([NotNullWhen(true)] SyntaxNode? node)
=> node is UnaryPatternSyntax;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public TSyntaxKind Convert<TSyntaxKind>(int kind) where TSyntaxKind : struct
public int? ImplicitObjectCreationExpression => (int)SyntaxKind.ImplicitObjectCreationExpression;
public int? IndexExpression => (int)SyntaxKind.IndexExpression;
public int InvocationExpression => (int)SyntaxKind.InvocationExpression;
public int? IsPatternExpression => (int)SyntaxKind.IsPatternExpression;
public int IsTypeExpression => (int)SyntaxKind.IsExpression;
public int? IsNotTypeExpression => null;
public int LogicalAndExpression => (int)SyntaxKind.LogicalAndExpression;
public int LogicalOrExpression => (int)SyntaxKind.LogicalOrExpression;
public int LogicalNotExpression => (int)SyntaxKind.LogicalNotExpression;
Expand All @@ -90,6 +93,16 @@ public TSyntaxKind Convert<TSyntaxKind>(int kind) where TSyntaxKind : struct
public int? ThrowExpression => (int)SyntaxKind.ThrowExpression;
public int TupleExpression => (int)SyntaxKind.TupleExpression;

public int? AndPattern => (int)SyntaxKind.AndPattern;
public int? ConstantPattern => (int)SyntaxKind.ConstantPattern;
public int? DeclarationPattern => (int)SyntaxKind.DeclarationPattern;
public int? NotPattern => (int)SyntaxKind.NotPattern;
public int? OrPattern => (int)SyntaxKind.OrPattern;
public int? ParenthesizedPattern => (int)SyntaxKind.ParenthesizedPattern;
public int? RecursivePattern => (int)SyntaxKind.RecursivePattern;
public int? TypePattern => (int)SyntaxKind.TypePattern;
public int? VarPattern => (int)SyntaxKind.VarPattern;

public int EndOfFileToken => (int)SyntaxKind.EndOfFileToken;
public int AwaitKeyword => (int)SyntaxKind.AwaitKeyword;
public int AsyncKeyword => (int)SyntaxKind.AsyncKeyword;
Expand Down Expand Up @@ -126,5 +139,6 @@ public TSyntaxKind Convert<TSyntaxKind>(int kind) where TSyntaxKind : struct
public int Interpolation => (int)SyntaxKind.Interpolation;
public int InterpolatedStringExpression => (int)SyntaxKind.InterpolatedStringExpression;
public int InterpolatedStringText => (int)SyntaxKind.InterpolatedStringText;
public int? IndexerMemberCref => (int)SyntaxKind.IndexerMemberCref;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,6 @@ internal interface ISyntaxFacts

bool IsDeclarationExpression([NotNullWhen(true)] SyntaxNode? node);

bool IsIsTypeExpression([NotNullWhen(true)] SyntaxNode? node);
bool IsIsNotTypeExpression([NotNullWhen(true)] SyntaxNode? node);

bool IsIsPatternExpression([NotNullWhen(true)] SyntaxNode? node);

bool IsConversionExpression([NotNullWhen(true)] SyntaxNode? node);
bool IsCastExpression([NotNullWhen(true)] SyntaxNode? node);

Expand Down Expand Up @@ -368,7 +363,6 @@ void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
bool IsBaseConstructorInitializer(SyntaxToken token);
bool IsQueryKeyword(SyntaxToken token);
bool IsElementAccessExpression([NotNullWhen(true)] SyntaxNode? node);
bool IsIndexerMemberCRef([NotNullWhen(true)] SyntaxNode? node);
bool IsIdentifierStartCharacter(char c);
bool IsIdentifierPartCharacter(char c);
bool IsIdentifierEscapeCharacter(char c);
Expand Down Expand Up @@ -461,18 +455,8 @@ void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
bool IsPropertyPatternClause(SyntaxNode node);

bool IsAnyPattern([NotNullWhen(true)] SyntaxNode? node);

bool IsAndPattern([NotNullWhen(true)] SyntaxNode? node);
bool IsBinaryPattern([NotNullWhen(true)] SyntaxNode? node);
bool IsConstantPattern([NotNullWhen(true)] SyntaxNode? node);
bool IsDeclarationPattern([NotNullWhen(true)] SyntaxNode? node);
bool IsNotPattern([NotNullWhen(true)] SyntaxNode? node);
bool IsOrPattern([NotNullWhen(true)] SyntaxNode? node);
bool IsParenthesizedPattern([NotNullWhen(true)] SyntaxNode? node);
bool IsRecursivePattern([NotNullWhen(true)] SyntaxNode? node);
bool IsTypePattern([NotNullWhen(true)] SyntaxNode? node);
bool IsUnaryPattern([NotNullWhen(true)] SyntaxNode? node);
bool IsVarPattern([NotNullWhen(true)] SyntaxNode? node);

SyntaxNode GetExpressionOfConstantPattern(SyntaxNode node);
SyntaxNode GetTypeOfTypePattern(SyntaxNode node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,15 @@ public static bool IsInterpolatedStringText(this ISyntaxFacts syntaxFacts, [NotN
public static bool IsInvocationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.InvocationExpression;

public static bool IsIsTypeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.IsTypeExpression;

public static bool IsIsNotTypeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.IsNotTypeExpression;

public static bool IsIsPatternExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.IsPatternExpression;

public static bool IsLogicalAndExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.LogicalAndExpression;

Expand Down Expand Up @@ -838,6 +847,37 @@ public static bool ContainsGlobalStatement(this ISyntaxFacts syntaxFacts, Syntax

#endregion

#region pattern

public static bool IsAndPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.AndPattern;

public static bool IsConstantPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.ConstantPattern;

public static bool IsDeclarationPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.DeclarationPattern;

public static bool IsNotPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.NotPattern;

public static bool IsOrPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.OrPattern;

public static bool IsParenthesizedPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.ParenthesizedPattern;

public static bool IsRecursivePattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.RecursivePattern;

public static bool IsTypePattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.TypePattern;

public static bool IsVarPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.VarPattern;

#endregion

#region statements

public static bool IsExpressionStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
Expand Down Expand Up @@ -907,6 +947,13 @@ public static bool IsEqualsValueClause(this ISyntaxFacts syntaxFacts, [NotNullWh

#endregion

#region other

public static bool IsIndexerMemberCref(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
=> node?.RawKind == syntaxFacts.SyntaxKinds.IndexerMemberCref;

#endregion

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ internal interface ISyntaxKinds
int? IndexExpression { get; }
int InterpolatedStringExpression { get; }
int InvocationExpression { get; }
int IsTypeExpression { get; }
int? IsNotTypeExpression { get; }
int? IsPatternExpression { get; }
int LogicalAndExpression { get; }
int LogicalOrExpression { get; }
int LogicalNotExpression { get; }
Expand All @@ -139,6 +142,20 @@ internal interface ISyntaxKinds

#endregion

#region patterns

int? AndPattern { get; }
int? ConstantPattern { get; }
int? DeclarationPattern { get; }
int? NotPattern { get; }
int? OrPattern { get; }
int? ParenthesizedPattern { get; }
int? RecursivePattern { get; }
int? TypePattern { get; }
int? VarPattern { get; }

#endregion

#region statements

int ExpressionStatement { get; }
Expand Down Expand Up @@ -181,6 +198,7 @@ internal interface ISyntaxKinds

int Interpolation { get; }
int InterpolatedStringText { get; }
int? IndexerMemberCref { get; }

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.LanguageServices
Return node.Kind = SyntaxKind.InvocationExpression OrElse node.Kind = SyntaxKind.DictionaryAccessExpression
End Function

Public Function IsIndexerMemberCRef(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsIndexerMemberCRef
Return False
End Function

Public Function GetContainingMemberDeclaration(root As SyntaxNode, position As Integer, Optional useFullSpan As Boolean = True) As SyntaxNode Implements ISyntaxFacts.GetContainingMemberDeclaration
Dim [end] = root.FullSpan.End
If [end] = 0 Then
Expand Down Expand Up @@ -1432,14 +1428,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.LanguageServices
Return DirectCast(node, ExpressionStatementSyntax).Expression
End Function

Public Function IsIsTypeExpression(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsIsTypeExpression
Return node.IsKind(SyntaxKind.TypeOfIsExpression)
End Function

Public Function IsIsNotTypeExpression(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsIsNotTypeExpression
Return node.IsKind(SyntaxKind.TypeOfIsNotExpression)
End Function

Public Sub GetPartsOfTupleExpression(Of TArgumentSyntax As SyntaxNode)(node As SyntaxNode, ByRef openParen As SyntaxToken, ByRef arguments As SeparatedSyntaxList(Of TArgumentSyntax), ByRef closeParen As SyntaxToken) Implements ISyntaxFacts.GetPartsOfTupleExpression
Dim tupleExpr = DirectCast(node, TupleExpressionSyntax)
openParen = tupleExpr.OpenParenToken
Expand Down Expand Up @@ -1664,58 +1652,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.LanguageServices
Return DirectCast(options, VisualBasicParseOptions).LanguageVersion >= LanguageVersion.VisualBasic14
End Function

Public Function IsIsPatternExpression(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsIsPatternExpression
Return False
End Function

Public Function IsAnyPattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsAnyPattern
Return False
End Function

Public Function IsAndPattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsAndPattern
Return False
End Function

Public Function IsBinaryPattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsBinaryPattern
Return False
End Function

Public Function IsConstantPattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsConstantPattern
Return False
End Function

Public Function IsDeclarationPattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsDeclarationPattern
Return False
End Function

Public Function IsNotPattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsNotPattern
Return False
End Function

Public Function IsOrPattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsOrPattern
Return False
End Function

Public Function IsParenthesizedPattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsParenthesizedPattern
Return False
End Function

Public Function IsRecursivePattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsRecursivePattern
Return False
End Function

Public Function IsUnaryPattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsUnaryPattern
Return False
End Function

Public Function IsTypePattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsTypePattern
Return False
End Function

Public Function IsVarPattern(node As SyntaxNode) As Boolean Implements ISyntaxFacts.IsVarPattern
Return False
End Function

Public Sub GetPartsOfAnyIsTypeExpression(node As SyntaxNode, ByRef expression As SyntaxNode, ByRef type As SyntaxNode) Implements ISyntaxFacts.GetPartsOfAnyIsTypeExpression
Dim typeOfExpression = DirectCast(node, TypeOfExpressionSyntax)
expression = typeOfExpression.Expression
Expand Down
Loading

0 comments on commit 5f774b3

Please sign in to comment.