ISyntaxFactsService.cs 21.7 KB
Newer Older
1
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.
P
Pilchie 已提交
2

3
using System;
P
Pilchie 已提交
4
using System.Collections.Generic;
C
CyrusNajmabadi 已提交
5
using System.Collections.Immutable;
P
Pilchie 已提交
6
using System.Threading;
7
using Microsoft.CodeAnalysis.Host;
P
Pilchie 已提交
8 9 10 11 12 13 14
using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis.LanguageServices
{
    internal interface ISyntaxFactsService : ILanguageService
    {
        bool IsCaseSensitive { get; }
15
        StringComparer StringComparer { get; }
16

17
        SyntaxTrivia ElasticMarker { get; }
C
CyrusNajmabadi 已提交
18 19
        SyntaxTrivia ElasticCarriageReturnLineFeed { get; }

20
        bool SupportsIndexingInitializer(ParseOptions options);
21
        bool SupportsThrowExpression(ParseOptions options);
P
Pilchie 已提交
22

23 24
        SyntaxToken ParseToken(string text);

25
        bool IsAwaitKeyword(SyntaxToken token);
P
Pilchie 已提交
26 27 28 29 30 31 32 33
        bool IsIdentifier(SyntaxToken token);
        bool IsGlobalNamespaceKeyword(SyntaxToken token);
        bool IsVerbatimIdentifier(SyntaxToken token);
        bool IsOperator(SyntaxToken token);
        bool IsPredefinedType(SyntaxToken token);
        bool IsPredefinedType(SyntaxToken token, PredefinedType type);
        bool IsPredefinedOperator(SyntaxToken token);
        bool IsPredefinedOperator(SyntaxToken token, PredefinedOperator op);
C
Cyrus Najmabadi 已提交
34 35 36 37 38 39

        /// <summary>
        /// Returns 'true' if this a 'reserved' keyword for the language.  A 'reserved' keyword is a
        /// identifier that is always treated as being a special keyword, regardless of where it is
        /// found in the token stream.  Examples of this are tokens like <see langword="class"/> and
        /// <see langword="Class"/> in C# and VB respectively.
C
Cyrus Najmabadi 已提交
40 41 42 43 44 45 46
        /// 
        /// Importantly, this does *not* include contextual keywords.  If contextual keywords are
        /// important for your scenario, use <see cref="IsContextualKeyword"/> or <see
        /// cref="ISyntaxFactsServiceExtensions.IsReservedOrContextualKeyword"/>.  Also, consider using
        /// <see cref="ISyntaxFactsServiceExtensions.IsWord"/> if all you need is the ability to know 
        /// if this is effectively any identifier in the language, regardless of whether the language
        /// is treating it as a keyword or not.
C
Cyrus Najmabadi 已提交
47
        /// </summary>
D
dotnet-bot 已提交
48
        bool IsReservedKeyword(SyntaxToken token);
C
Cyrus Najmabadi 已提交
49 50

        /// <summary>
C
Cyrus Najmabadi 已提交
51 52 53 54 55 56 57 58
        /// Returns <see langword="true"/> if this a 'contextual' keyword for the language.  A
        /// 'contextual' keyword is a identifier that is only treated as being a special keyword in
        /// certain *syntactic* contexts.  Examples of this is 'yield' in C#.  This is only a
        /// keyword if used as 'yield return' or 'yield break'.  Importantly, identifiers like <see
        /// langword="var"/>, <see langword="dynamic"/> and <see langword="nameof"/> are *not*
        /// 'contextual' keywords.  This is because they are not treated as keywords depending on
        /// the syntactic context around them.  Instead, the language always treats them identifiers
        /// that have special *semantic* meaning if they end up not binding to an existing symbol.
C
Cyrus Najmabadi 已提交
59
        /// 
C
Cyrus Najmabadi 已提交
60 61 62 63 64
        /// Importantly, if <paramref name="token"/> is not in the syntactic construct where the
        /// language thinks an identifier should be contextually treated as a keyword, then this
        /// will return <see langword="false"/>.
        /// 
        /// Or, in other words, the parser must be able to identify these cases in order to be a
C
Cyrus Najmabadi 已提交
65 66
        /// contextual keyword.  If identification happens afterwards, it's not contextual.
        /// </summary>
P
Pilchie 已提交
67
        bool IsContextualKeyword(SyntaxToken token);
C
Cyrus Najmabadi 已提交
68 69 70 71 72

        /// <summary>
        /// The set of identifiers that have special meaning directly after the `#` token in a
        /// preprocessor directive.  For example `if` or `pragma`.
        /// </summary>
P
Pilchie 已提交
73 74
        bool IsPreprocessorKeyword(SyntaxToken token);
        bool IsHashToken(SyntaxToken token);
C
Cyrus Najmabadi 已提交
75

P
Pilchie 已提交
76
        bool IsLiteral(SyntaxToken token);
77
        bool IsStringLiteralOrInterpolatedStringLiteral(SyntaxToken token);
78

79 80
        bool IsNumericLiteral(SyntaxToken token);
        bool IsCharacterLiteral(SyntaxToken token);
P
Pilchie 已提交
81
        bool IsStringLiteral(SyntaxToken token);
C
CyrusNajmabadi 已提交
82
        bool IsVerbatimStringLiteral(SyntaxToken token);
83 84
        bool IsInterpolatedStringTextToken(SyntaxToken token);
        bool IsStringLiteralExpression(SyntaxNode node);
85

P
Pilchie 已提交
86 87
        bool IsTypeNamedVarInVariableOrFieldDeclaration(SyntaxToken token, SyntaxNode parent);
        bool IsTypeNamedDynamic(SyntaxToken token, SyntaxNode parent);
P
Paul Vick 已提交
88
        bool IsUsingOrExternOrImport(SyntaxNode node);
P
Paul Vick 已提交
89 90
        bool IsGlobalAttribute(SyntaxNode node);
        bool IsDeclaration(SyntaxNode node);
P
Pilchie 已提交
91

C
CyrusNajmabadi 已提交
92 93
        bool IsRegularComment(SyntaxTrivia trivia);
        bool IsDocumentationComment(SyntaxTrivia trivia);
C
CyrusNajmabadi 已提交
94
        bool IsElastic(SyntaxTrivia trivia);
C
CyrusNajmabadi 已提交
95

96
        bool IsDocumentationComment(SyntaxNode node);
97 98
        bool IsNumericLiteralExpression(SyntaxNode node);
        bool IsNullLiteralExpression(SyntaxNode node);
99
        bool IsDefaultLiteralExpression(SyntaxNode node);
100
        bool IsLiteralExpression(SyntaxNode node);
C
Cyrus Najmabadi 已提交
101 102 103 104
        bool IsFalseLiteralExpression(SyntaxNode node);
        bool IsTrueLiteralExpression(SyntaxNode node);
        bool IsThisExpression(SyntaxNode node);
        bool IsBaseExpression(SyntaxNode node);
105

P
Pilchie 已提交
106 107 108
        string GetText(int kind);
        bool IsInInactiveRegion(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken);
        bool IsInNonUserCode(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken);
109
        bool IsEntirelyWithinStringOrCharOrNumericLiteral(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken);
110
        bool IsPossibleTupleContext(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken);
P
Pilchie 已提交
111 112 113 114 115 116 117

        bool TryGetPredefinedType(SyntaxToken token, out PredefinedType type);
        bool TryGetPredefinedOperator(SyntaxToken token, out PredefinedOperator op);
        bool TryGetExternalSourceInfo(SyntaxNode directive, out ExternalSourceInfo info);

        bool IsObjectCreationExpressionType(SyntaxNode node);
        bool IsObjectCreationExpression(SyntaxNode node);
118 119
        SyntaxNode GetObjectCreationInitializer(SyntaxNode node);
        SyntaxNode GetObjectCreationType(SyntaxNode node);
120

121
        bool IsBinaryExpression(SyntaxNode node);
C
Cyrus Najmabadi 已提交
122
        void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
C
Cheryl Borley 已提交
123

124 125
        void GetPartsOfConditionalExpression(SyntaxNode node, out SyntaxNode condition, out SyntaxNode whenTrue, out SyntaxNode whenFalse);

126 127 128
        bool IsCastExpression(SyntaxNode node);
        void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out SyntaxNode expression);

P
Pilchie 已提交
129
        bool IsInvocationExpression(SyntaxNode node);
130
        bool IsExpressionOfInvocationExpression(SyntaxNode node);
C
Cyrus Najmabadi 已提交
131
        void GetPartsOfInvocationExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList);
132

133 134
        SyntaxNode GetExpressionOfExpressionStatement(SyntaxNode node);

135
        bool IsAwaitExpression(SyntaxNode node);
136 137
        bool IsExpressionOfAwaitExpression(SyntaxNode node);
        SyntaxNode GetExpressionOfAwaitExpression(SyntaxNode node);
P
Pilchie 已提交
138

139
        bool IsLogicalAndExpression(SyntaxNode node);
C
Cheryl Borley 已提交
140
        bool IsLogicalOrExpression(SyntaxNode node);
141
        bool IsLogicalNotExpression(SyntaxNode node);
C
Cheryl Borley 已提交
142 143 144
        bool IsConditionalAnd(SyntaxNode node);
        bool IsConditionalOr(SyntaxNode node);

145
        bool IsTupleExpression(SyntaxNode node);
146 147 148
        void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
            out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode;

149 150
        bool IsTupleType(SyntaxNode node);

151
        SyntaxNode GetOperandOfPrefixUnaryExpression(SyntaxNode node);
C
Cheryl Borley 已提交
152
        SyntaxToken GetOperatorTokenOfPrefixUnaryExpression(SyntaxNode node);
153

154

155 156 157
        // Left side of = assignment.
        bool IsLeftSideOfAssignment(SyntaxNode node);

158
        bool IsSimpleAssignmentStatement(SyntaxNode statement);
C
CyrusNajmabadi 已提交
159
        void GetPartsOfAssignmentStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
C
Cyrus Najmabadi 已提交
160
        void GetPartsOfAssignmentExpressionOrStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
161

162 163 164 165 166 167 168 169
        // Left side of any assignment (for example  *=  or += )
        bool IsLeftSideOfAnyAssignment(SyntaxNode node);
        SyntaxNode GetRightHandSideOfAssignment(SyntaxNode node);

        bool IsInferredAnonymousObjectMemberDeclarator(SyntaxNode node);
        bool IsOperandOfIncrementExpression(SyntaxNode node);
        bool IsOperandOfIncrementOrDecrementExpression(SyntaxNode node);

170 171 172
        bool IsLeftSideOfDot(SyntaxNode node);
        SyntaxNode GetRightSideOfDot(SyntaxNode node);

P
Pilchie 已提交
173
        bool IsRightSideOfQualifiedName(SyntaxNode node);
174

175 176 177
        bool IsNameOfMemberAccessExpression(SyntaxNode node);
        bool IsExpressionOfMemberAccessExpression(SyntaxNode node);

178
        SyntaxNode GetNameOfMemberAccessExpression(SyntaxNode node);
179 180 181

        /// <summary>
        /// Returns the expression node the member is being accessed off of.  If <paramref name="allowImplicitTarget"/>
182 183
        /// is <see langword="false"/>, this will be the node directly to the left of the dot-token.  If <paramref name="allowImplicitTarget"/>
        /// is <see langword="true"/>, then this can return another node in the tree that the member will be accessed
184 185 186 187
        /// off of.  For example, in VB, if you have a member-access-expression of the form ".Length" then this
        /// may return the expression in the surrounding With-statement.
        /// </summary>
        SyntaxNode GetExpressionOfMemberAccessExpression(SyntaxNode node, bool allowImplicitTarget = false);
C
Cyrus Najmabadi 已提交
188
        void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name);
P
Pilchie 已提交
189

190 191
        SyntaxNode GetTargetOfMemberBinding(SyntaxNode node);

192
        bool IsSimpleMemberAccessExpression(SyntaxNode node);
P
Pilchie 已提交
193
        bool IsPointerMemberAccessExpression(SyntaxNode node);
194

P
Pilchie 已提交
195
        bool IsNamedParameter(SyntaxNode node);
C
Cyrus Najmabadi 已提交
196
        SyntaxToken? GetNameOfParameter(SyntaxNode node);
197
        SyntaxNode GetDefaultOfParameter(SyntaxNode node);
198
        SyntaxNode GetParameterList(SyntaxNode node);
P
Pilchie 已提交
199 200 201

        bool IsSkippedTokensTrivia(SyntaxNode node);

202 203
        bool IsWhitespaceTrivia(SyntaxTrivia trivia);
        bool IsEndOfLineTrivia(SyntaxTrivia trivia);
204
        bool IsDocumentationCommentExteriorTrivia(SyntaxTrivia trivia);
205

C
Cyrus Najmabadi 已提交
206
        void GetPartsOfElementAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList);
207

P
Pilchie 已提交
208
        SyntaxNode GetExpressionOfArgument(SyntaxNode node);
209
        SyntaxNode GetExpressionOfInterpolation(SyntaxNode node);
P
Pilchie 已提交
210
        SyntaxNode GetNameOfAttribute(SyntaxNode node);
211

C
Cyrus Najmabadi 已提交
212
        bool IsConditionalAccessExpression(SyntaxNode node);
C
Cyrus Najmabadi 已提交
213 214 215 216 217 218 219
        void GetPartsOfConditionalAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull);

        bool IsMemberBindingExpression(SyntaxNode node);
        void GetPartsOfMemberBindingExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode name);

        bool IsPostfixUnaryExpression(SyntaxNode node);
        void GetPartsOfPostfixUnaryExpression(SyntaxNode node, out SyntaxNode operand, out SyntaxToken operatorToken);
C
Cyrus Najmabadi 已提交
220

C
Cheryl Borley 已提交
221 222 223 224
        bool IsParenthesizedExpression(SyntaxNode node);
        SyntaxNode GetExpressionOfParenthesizedExpression(SyntaxNode node);

        bool IsIfStatement(SyntaxNode node);
225

P
Pilchie 已提交
226
        SyntaxToken GetIdentifierOfGenericName(SyntaxNode node);
227 228
        SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node);
        SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node);
229
        SyntaxNode GetTypeOfVariableDeclarator(SyntaxNode node);
230

C
CyrusNajmabadi 已提交
231 232 233 234 235
        /// <summary>
        /// True if this is an argument with just an expression and nothing else (i.e. no ref/out,
        /// no named params, no omitted args).
        /// </summary>
        bool IsSimpleArgument(SyntaxNode node);
236
        bool IsArgument(SyntaxNode node);
P
Pilchie 已提交
237
        RefKind GetRefKindOfArgument(SyntaxNode node);
C
CyrusNajmabadi 已提交
238

P
Pilchie 已提交
239
        void GetNameAndArityOfSimpleName(SyntaxNode node, out string name, out int arity);
240 241
        bool LooksGeneric(SyntaxNode simpleName);

242
        SyntaxList<SyntaxNode> GetContentsOfInterpolatedString(SyntaxNode interpolatedString);
243 244 245 246
        SeparatedSyntaxList<SyntaxNode> GetArgumentsOfInvocationExpression(SyntaxNode node);
        SeparatedSyntaxList<SyntaxNode> GetArgumentsOfObjectCreationExpression(SyntaxNode node);
        SeparatedSyntaxList<SyntaxNode> GetArgumentsOfArgumentList(SyntaxNode node);

P
Pilchie 已提交
247
        bool IsUsingDirectiveName(SyntaxNode node);
248
        bool IsIdentifierName(SyntaxNode node);
P
Pilchie 已提交
249
        bool IsGenericName(SyntaxNode node);
250
        bool IsQualifiedName(SyntaxNode node);
P
Pilchie 已提交
251 252 253 254 255 256

        bool IsAttribute(SyntaxNode node);
        bool IsAttributeName(SyntaxNode node);

        bool IsAttributeNamedArgumentIdentifier(SyntaxNode node);
        bool IsObjectInitializerNamedAssignmentIdentifier(SyntaxNode node);
257
        bool IsObjectInitializerNamedAssignmentIdentifier(SyntaxNode node, out SyntaxNode initializedInstance);
P
Pilchie 已提交
258 259 260 261 262

        bool IsDirective(SyntaxNode node);
        bool IsForEachStatement(SyntaxNode node);
        bool IsLockStatement(SyntaxNode node);
        bool IsUsingStatement(SyntaxNode node);
263 264 265
        bool IsStatement(SyntaxNode node);
        bool IsParameter(SyntaxNode node);
        bool IsVariableDeclarator(SyntaxNode node);
266 267
        bool IsDeconstructionAssignment(SyntaxNode node);
        bool IsDeconstructionForEachStatement(SyntaxNode node);
P
Pilchie 已提交
268

269 270 271 272 273 274 275 276 277 278 279 280 281 282
        /// <summary>
        /// Returns true for nodes that represent the body of a method.
        /// 
        /// For VB this will be 
        /// MethodBlockBaseSyntax.  This will be true for things like constructor, method, operator
        /// bodies as well as accessor bodies.  It will not be true for things like sub() function()
        /// lambdas.  
        /// 
        /// For C# this will be the BlockSyntax or ArrowExpressionSyntax for a 
        /// method/constructor/deconstructor/operator/accessor.  It will not be included for local
        /// functions.
        /// </summary>
        bool IsMethodBody(SyntaxNode node);

283
        bool IsReturnStatement(SyntaxNode node);
C
CyrusNajmabadi 已提交
284
        SyntaxNode GetExpressionOfReturnStatement(SyntaxNode node);
P
Pilchie 已提交
285

286
        bool IsLocalDeclarationStatement(SyntaxNode node);
287 288
        bool IsLocalFunctionStatement(SyntaxNode node);

289 290 291 292
        bool IsDeclaratorOfLocalDeclarationStatement(SyntaxNode declarator, SyntaxNode localDeclarationStatement);
        SeparatedSyntaxList<SyntaxNode> GetVariablesOfLocalDeclarationStatement(SyntaxNode node);
        SyntaxNode GetInitializerOfVariableDeclarator(SyntaxNode node);
        SyntaxNode GetValueOfEqualsValueClause(SyntaxNode node);
293

P
Pilchie 已提交
294 295 296
        bool IsThisConstructorInitializer(SyntaxToken token);
        bool IsBaseConstructorInitializer(SyntaxToken token);
        bool IsQueryExpression(SyntaxNode node);
297
        bool IsQueryKeyword(SyntaxToken token);
298
        bool IsThrowExpression(SyntaxNode node);
P
Pilchie 已提交
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
        bool IsElementAccessExpression(SyntaxNode node);
        bool IsIndexerMemberCRef(SyntaxNode node);

        bool IsIdentifierStartCharacter(char c);
        bool IsIdentifierPartCharacter(char c);
        bool IsIdentifierEscapeCharacter(char c);
        bool IsStartOfUnicodeEscapeSequence(char c);

        bool IsValidIdentifier(string identifier);
        bool IsVerbatimIdentifier(string identifier);

        /// <summary>
        /// Returns true if the given character is a character which may be included in an
        /// identifier to specify the type of a variable.
        /// </summary>
        bool IsTypeCharacter(char c);

        bool IsBindableToken(SyntaxToken token);

        bool IsInStaticContext(SyntaxNode node);
        bool IsUnsafeContext(SyntaxNode node);

        bool IsInNamespaceOrTypeContext(SyntaxNode node);

        bool IsAnonymousFunction(SyntaxNode n);

        bool IsInConstantContext(SyntaxNode node);
        bool IsInConstructor(SyntaxNode node);
        bool IsMethodLevelMember(SyntaxNode node);
        bool IsTopLevelNodeWithMembers(SyntaxNode node);
        bool HasIncompleteParentMember(SyntaxNode node);

331 332 333 334
        bool IsExecutableBlock(SyntaxNode node);
        SyntaxList<SyntaxNode> GetExecutableBlockStatements(SyntaxNode node);
        SyntaxNode FindInnermostCommonExecutableBlock(IEnumerable<SyntaxNode> nodes);

335 336 337
        bool AreEquivalent(SyntaxToken token1, SyntaxToken token2);
        bool AreEquivalent(SyntaxNode node1, SyntaxNode node2);

338 339
        string GetDisplayName(SyntaxNode node, DisplayNameOptions options, string rootNamespace = null);

P
Pilchie 已提交
340
        SyntaxNode GetContainingTypeDeclaration(SyntaxNode root, int position);
341
        SyntaxNode GetContainingMemberDeclaration(SyntaxNode root, int position, bool useFullSpan = true);
P
Pilchie 已提交
342 343 344 345 346
        SyntaxNode GetContainingVariableDeclaratorOfFieldDeclaration(SyntaxNode node);

        SyntaxToken FindTokenOnLeftOfPosition(SyntaxNode node, int position, bool includeSkipped = true, bool includeDirectives = false, bool includeDocumentationComments = false);
        SyntaxToken FindTokenOnRightOfPosition(SyntaxNode node, int position, bool includeSkipped = true, bool includeDirectives = false, bool includeDocumentationComments = false);

C
Cyrus Najmabadi 已提交
347 348
        void GetPartsOfParenthesizedExpression(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen);
        SyntaxNode Parenthesize(SyntaxNode expression, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true);
349
        SyntaxNode WalkDownParentheses(SyntaxNode node);
P
Pilchie 已提交
350

351
        SyntaxNode ConvertToSingleLine(SyntaxNode node, bool useElasticTrivia = false);
P
Pilchie 已提交
352 353 354

        SyntaxToken ToIdentifierToken(string name);
        List<SyntaxNode> GetMethodLevelMembers(SyntaxNode root);
C
Cyrus Najmabadi 已提交
355
        SyntaxList<SyntaxNode> GetMembersOfTypeDeclaration(SyntaxNode typeDeclaration);
P
Pilchie 已提交
356 357 358 359

        bool ContainsInMemberBody(SyntaxNode node, TextSpan span);
        int GetMethodLevelMemberId(SyntaxNode root, SyntaxNode node);
        SyntaxNode GetMethodLevelMember(SyntaxNode root, int memberId);
360
        TextSpan GetInactiveRegionSpanAroundPosition(SyntaxTree tree, int position, CancellationToken cancellationToken);
P
Pilchie 已提交
361

362 363 364 365 366 367
        /// <summary>
        /// Given a <see cref="SyntaxNode"/>, return the <see cref="TextSpan"/> representing the span of the member body
        /// it is contained within. This <see cref="TextSpan"/> is used to determine whether speculative binding should be
        /// used in performance-critical typing scenarios. Note: if this method fails to find a relevant span, it returns
        /// an empty <see cref="TextSpan"/> at position 0.
        /// </summary>
P
Pilchie 已提交
368 369 370 371 372 373 374 375 376 377 378 379
        TextSpan GetMemberBodySpanForSpeculativeBinding(SyntaxNode node);

        /// <summary>
        /// Returns the parent node that binds to the symbols that the IDE prefers for features like
        /// Quick Info and Find All References. For example, if the token is part of the type of
        /// an object creation, the parenting object creation expression is returned so that binding
        /// will return constructor symbols.
        /// </summary>
        SyntaxNode GetBindableParent(SyntaxToken token);

        IEnumerable<SyntaxNode> GetConstructors(SyntaxNode root, CancellationToken cancellationToken);
        bool TryGetCorrespondingOpenBrace(SyntaxToken token, out SyntaxToken openBrace);
380 381 382 383 384 385

        /// <summary>
        /// Given a <see cref="SyntaxNode"/>, that represents and argument return the string representation of
        /// that arguments name.
        /// </summary>
        string GetNameForArgument(SyntaxNode argument);
386

C
CyrusNajmabadi 已提交
387
        ImmutableArray<SyntaxNode> GetSelectedMembers(SyntaxNode root, TextSpan textSpan);
388 389 390
        bool IsOnTypeHeader(SyntaxNode root, int position);
        bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position);

391 392 393 394 395
        // Walks the tree, starting from contextNode, looking for the first construct
        // with a missing close brace.  If found, the close brace will be added and the
        // updates root will be returned.  The context node in that new tree will also
        // be returned.
        void AddFirstMissingCloseBrace(
D
dotnet-bot 已提交
396
            SyntaxNode root, SyntaxNode contextNode,
397
            out SyntaxNode newRoot, out SyntaxNode newContextNode);
398

399
        SyntaxNode GetNextExecutableStatement(SyntaxNode statement);
400

401 402 403
        ImmutableArray<SyntaxTrivia> GetLeadingBlankLines(SyntaxNode node);
        TSyntaxNode GetNodeWithoutLeadingBlankLines<TSyntaxNode>(TSyntaxNode node) where TSyntaxNode : SyntaxNode;

404
        ImmutableArray<SyntaxTrivia> GetFileBanner(SyntaxNode root);
405
        ImmutableArray<SyntaxTrivia> GetFileBanner(SyntaxToken firstToken);
406 407 408

        bool ContainsInterleavedDirective(SyntaxNode node, CancellationToken cancellationToken);
        bool ContainsInterleavedDirective(ImmutableArray<SyntaxNode> nodes, CancellationToken cancellationToken);
409

410
        string GetBannerText(SyntaxNode documentationCommentTriviaSyntax, int maxBannerLength, CancellationToken cancellationToken);
C
CyrusNajmabadi 已提交
411 412 413

        SyntaxTokenList GetModifiers(SyntaxNode node);
        SyntaxNode WithModifiers(SyntaxNode node, SyntaxTokenList modifiers);
414 415

        Location GetDeconstructionReferenceLocation(SyntaxNode node);
416 417

        SyntaxToken? GetDeclarationIdentifierIfOverride(SyntaxToken token);
418 419

        bool SpansPreprocessorDirective(IEnumerable<SyntaxNode> nodes);
P
Pilchie 已提交
420
    }
421 422 423 424 425 426 427 428 429 430 431

    [Flags]
    internal enum DisplayNameOptions
    {
        None = 0,
        IncludeMemberKeyword = 1,
        IncludeNamespaces = 1 << 1,
        IncludeParameters = 1 << 2,
        IncludeType = 1 << 3,
        IncludeTypeParameters = 1 << 4
    }
S
Sam Harwell 已提交
432
}