提交 6ca43e7a 编写于 作者: P Petr Houška

Cleanup - reorder helpers in SyntaxFacts services.

上级 9a24ddf7
......@@ -1815,6 +1815,21 @@ public bool IsOnTypeHeader(SyntaxNode root, int position)
return position >= start && position <= end;
}
public bool IsPartOfPropertyDeclarationHeader(SyntaxNode node)
{
var propertyDeclaration = node.GetAncestor<PropertyDeclarationSyntax>();
if (propertyDeclaration == null)
{
return false;
}
var start = propertyDeclaration.AttributeLists.LastOrDefault()?.GetLastToken().GetNextToken().SpanStart ??
propertyDeclaration.SpanStart;
var end = propertyDeclaration.Identifier.FullSpan.End;
return node.Span.Start >= start && node.Span.End <= end;
}
public bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position)
{
var token = root.FindToken(position);
......@@ -1951,21 +1966,6 @@ public void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out S
return null;
}
public bool IsPartOfPropertyDeclarationHeader(SyntaxNode node)
{
var propertyDeclaration = node.GetAncestor<PropertyDeclarationSyntax>();
if (propertyDeclaration == null)
{
return false;
}
var start = propertyDeclaration.AttributeLists.LastOrDefault()?.GetLastToken().GetNextToken().SpanStart ??
propertyDeclaration.SpanStart;
var end = propertyDeclaration.Identifier.FullSpan.End;
return node.Span.Start >= start && node.Span.End <= end;
}
public SyntaxNode GetContainingPropertyDeclaration(SyntaxNode node) => node.GetAncestor<PropertyDeclarationSyntax>();
public SyntaxList<SyntaxNode> GetAttributeLists(SyntaxNode node) => CSharpSyntaxGenerator.GetAttributeLists(node);
......
......@@ -297,7 +297,6 @@ internal interface ISyntaxFactsService : ILanguageService
bool IsQueryKeyword(SyntaxToken token);
bool IsThrowExpression(SyntaxNode node);
bool IsElementAccessExpression(SyntaxNode node);
bool IsPartOfPropertyDeclarationHeader(SyntaxNode node);
bool IsIndexerMemberCRef(SyntaxNode node);
SyntaxNode GetContainingPropertyDeclaration(SyntaxNode node);
bool IsIdentifierStartCharacter(char c);
......@@ -409,6 +408,7 @@ internal interface ISyntaxFactsService : ILanguageService
ImmutableArray<SyntaxNode> GetSelectedFieldsAndProperties(SyntaxNode root, TextSpan textSpan, bool allowPartialSelection);
bool IsOnTypeHeader(SyntaxNode root, int position);
bool IsPartOfPropertyDeclarationHeader(SyntaxNode node);
bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position);
// Walks the tree, starting from contextNode, looking for the first construct
......
......@@ -1754,6 +1754,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return position >= start AndAlso position <= _end
End Function
Public Function IsPartOfPropertyDeclarationHeader(node As SyntaxNode) As Boolean Implements ISyntaxFactsService.IsPartOfPropertyDeclarationHeader
Dim propertyDeclaration = node.GetAncestor(Of PropertyStatementSyntax)()
If propertyDeclaration Is Nothing Then
Return False
End If
Dim start = If(propertyDeclaration.AttributeLists.LastOrDefault()?.GetLastToken().GetNextToken().SpanStart, propertyDeclaration.SpanStart)
Dim [end] = If(propertyDeclaration.AsClause?.FullSpan.[End], propertyDeclaration.Identifier.FullSpan.End)
Return node.Span.Start >= start AndAlso node.Span.[End] <= [end]
End Function
Public Function IsBetweenTypeMembers(sourceText As SourceText, root As SyntaxNode, position As Integer) As Boolean Implements ISyntaxFactsService.IsBetweenTypeMembers
Dim token = root.FindToken(position)
Dim typeDecl = token.GetAncestor(Of TypeBlockSyntax)
......@@ -1945,18 +1957,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return MyBase.SpansPreprocessorDirective(tokens)
End Function
Public Function IsPartOfPropertyDeclarationHeader(node As SyntaxNode) As Boolean Implements ISyntaxFactsService.IsPartOfPropertyDeclarationHeader
Dim propertyDeclaration = node.GetAncestor(Of PropertyStatementSyntax)()
If propertyDeclaration Is Nothing Then
Return False
End If
Dim start = If(propertyDeclaration.AttributeLists.LastOrDefault()?.GetLastToken().GetNextToken().SpanStart, propertyDeclaration.SpanStart)
Dim [end] = If(propertyDeclaration.AsClause?.FullSpan.[End], propertyDeclaration.Identifier.FullSpan.End)
Return node.Span.Start >= start AndAlso node.Span.[End] <= [end]
End Function
Public Function GetContainingPropertyDeclaration(node As SyntaxNode) As SyntaxNode Implements ISyntaxFactsService.GetContainingPropertyDeclaration
Return node.GetAncestor(Of PropertyStatementSyntax)
End Function
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册