Microsoft.CodeAnalysis.CSharp.Workspaces Determine the classification type for a given token. The token. The correct syntactic classification for the token. Worker is an utility class that can classify a list of tokens or a tree within a requested span The implementation is generic and can produce any kind of classification artifacts T T is normally either ClassificationSpan or a Tuple (for testing purposes) and constructed via provided factory. Moves the trailing trivia from the node's previous token to the end of the node Parenthesize the left hand size of a member access, invocation or element access expression Analyzes if type information is obvious to the reader by simply looking at the assignment expression. accepts null, to be able to cater to codegen features that are about to generate a local declaration and do not have this information to pass in. Things (like analyzers) that do have a local declaration already, should pass this in. Looks for types that have static methods that return the same type as the container. e.g: int.Parse, XElement.Load, Tuple.Create etc. If we have a method ToXXX and its return type is also XXX, then type name is apparent e.g: Convert.ToString. If there are type arguments on either side of assignment, we match type names instead of type equality to account for inferred generic type arguments. e.g: Tuple.Create(0, true) returns Tuple<X,y> which isn't the same as type Tuple. otherwise, we match for type equivalence A strongly-typed resource class, for looking up localized strings, etc. Returns the cached ResourceManager instance used by this class. Overrides the current thread's CurrentUICulture property for all resource lookups using this strongly typed resource class. Looks up a localized string similar to Cannot retrieve the Span of a null syntax reference.. Looks up a localized string similar to Code-block preferences. Looks up a localized string similar to Expected string or char literal. Looks up a localized string similar to Expression-bodied members. Looks up a localized string similar to Implement Interface. Looks up a localized string similar to Indentation preferences. Looks up a localized string similar to Namespace can not be added in this destination.. Looks up a localized string similar to No available location found to add statements to.. Looks up a localized string similar to Node does not descend from root.. Looks up a localized string similar to Node not in parent's child list. Looks up a localized string similar to Null-checking preferences. Looks up a localized string similar to Only attributes, constructor initializers, expressions or statements can be made explicit. Looks up a localized string similar to Pattern matching preferences. Looks up a localized string similar to R&emove and Sort Usings. Looks up a localized string similar to &Sort Usings. Looks up a localized string similar to Space preferences. Looks up a localized string similar to Trivia is not associated with token. Looks up a localized string similar to 'using' directive preferences. Looks up a localized string similar to var preferences. Looks up a localized string similar to Wrapping preferences. A hashset containing the short names of all namespace members A hashset containing the short names of all extension methods Returns the parameter to which this argument is passed. If is true, the last parameter will be returned if it is params parameter and the index of the specified argument is greater than the number of parameters. Returns the parameter to which this argument is passed. If is true, the last parameter will be returned if it is params parameter and the index of the specified argument is greater than the number of parameters. Returns null if the is a named argument. Available if is or . Available if is or . Available if is or . Is this a possible position for an await statement (`await using` or `await foreach`)? Are you possibly typing a tuple type or expression? This is used to suppress colon as a completion trigger (so that you can type element names). This is also used to recommend some keywords (like var). Are you possibly in the designation part of a deconstruction? This is used to enter suggestion mode (suggestions become soft-selected). If inside a parenthesized or tuple expression, unwrap the nestings and return the container. Adds to if it does not contain an anonymous type and binds to the same type at the given . If this declaration or identifier is part of a deconstruction, find the deconstruction. If found, returns either an assignment expression or a foreach variable statement. Returns null otherwise. copied from SyntaxExtensions.GetContainingDeconstruction Determines if and together contain a superset of the symbols in . Compares symbols by their original definition. Checks if the SyntaxNode is a name of a namespace declaration. To be a namespace name, the syntax must be parented by an namespace declaration and the node itself must be equal to the declaration's Name property. Tells if the Member access is the starting part of a Dynamic Invocation Return true, if the member access is the starting point of a Dynamic Invocation Returns the predefined keyword kind for a given . The of this type. The keyword kind for a given special type, or SyntaxKind.None if the type name is not a predefined type. We always unilaterally add "global::" to all named types/namespaces. This will then be trimmed off if possible by calls to Operator precedence classes from section 7.3.1 of the C# language specification. Decomposes a name or member access expression into its component parts. The name or member access expression. The qualifier (or left-hand-side) of the name expression. This may be null if there is no qualifier. The name of the expression. The number of generic type parameters. Given an argument node, tries to generate an appropriate name that can be used for that argument. Given an expression node, tries to generate an appropriate name that can be used for that expression. Determine if the given array contains the given kind. Array to search Sought value True if contains the value. PERF: Not using Array.IndexOf here because it results in a call to IndexOf on the default EqualityComparer for SyntaxKind.The default comparer for SyntaxKind is the ObjectEqualityComparer which results in boxing allocations. Returns the list of using directives that affect . The list will be returned in top down order. Returns true if the passed in node contains an interleaved pp directive. i.e. The following returns false: void Goo() { #if true #endif } #if true void Goo() { } #endif but these return true: #if true void Goo() { #endif } void Goo() { #if true } #endif #if true void Goo() { #else } #endif i.e. the method returns true if it contains a PP directive that belongs to a grouping constructs (like #if/#endif or #region/#endregion), but the grouping construct isn't entirely contained within the span of the node. Similar to except that the span to check for interleaved directives can be specified separately to the node passed in. Breaks up the list of provided nodes, based on how they are interspersed with pp directives, into groups. Within these groups nodes can be moved around safely, without breaking any pp constructs. Returns child node or token that contains given position. This is a copy of that also returns the index of the child node. Returns all of the trivia to the left of this token up to the previous token (concatenates the previous token's trailing trivia and this token's leading trivia). Determines whether the given SyntaxToken is the first token on a line in the specified SourceText. Retrieves all trivia after this token, including it's trailing trivia and the leading trivia of the next token. Lexically, find the last token that looks like it's part of this generic name. The "name" of the generic identifier, last token before the "&" The last token in the name This is related to the code in Returns true if this token is something that looks like a C# keyword. This includes actual keywords, contextual keywords, and even 'var' and 'dynamic' Takes an INCLUSIVE range of trivia from the trivia list. Determines whether the specified TypeSyntax is actually 'var'. Builds up the suffix to show for something with parameters in navigate-to. While it would be nice to just use the compiler SymbolDisplay API for this, it would be too expensive as it requires going back to Symbols (which requires creating compilations, etc.) in a perf sensitive area. So, instead, we just build a reasonable suffix using the pure syntax that a user provided. That means that if they wrote "Method(System.Int32 i)" we'll show that as "Method(System.Int32)" not "Method(int)". Given that this is actually what the user wrote, and it saves us from ever having to go back to symbols/compilations, this is well worth it, even if it does mean we have to create our own 'symbol display' logic here. Placed in the Zeroth column of the text editor Placed at one less indent to the current context Placed at the same indent as the current context Single Spacing Ignore Formatting Remove Spacing this holds onto changes made by formatting engine. trivia factory. it will cache some commonly used trivia to reduce memory footprint and heap allocation represents a general trivia between two tokens. slightly more expensive than others since it needs to calculate stuff unlike other cases Checks whether currentToken is the opening paren of a deconstruction-declaration in var form, such as var (x, y) = ... Check whether the currentToken is a comma and is a delimiter between arguments inside a tuple expression. This class allows the Code Style layer to light up support for new language features when available at runtime while compiling against an older version of the Roslyn assemblies. This will only compile if and have the same value. The subtraction will overflow if is greater, and the conversion to an unsigned value after negation will overflow if is greater. Represents a syntax reference that doesn't actually hold onto the referenced node. Instead, enough data is held onto so that the node can be recovered and returned if necessary. Represents a syntax reference that was passed a null reference to a node. In this case, we just hold onto the weak tree reference and throw if any invalid properties are accessed. Represents a syntax reference that doesn't actually hold onto the referenced node. Instead, enough data is held onto so that the node can be recovered and returned if necessary. Represents a syntax tree that only has a weak reference to its underlying data. This way it can be passed around without forcing the underlying full tree to stay alive. Think of it more as a key that can be used to identify a tree rather than the tree itself. Gets the top most enclosing statement or CrefSyntax as target to call MakeExplicit on. It's either the enclosing statement, or if this statement is inside of a lambda expression, the enclosing statement of this lambda. The token to get the complexification target for. Gets the semantic model for the given node. If the node belongs to the syntax tree of the original semantic model, then returns originalSemanticModel. Otherwise, returns a speculative model. The assumption for the later case is that span start position of the given node in it's syntax tree is same as the span start of the original node in the original syntax tree. Computes a list of nodes and tokens that need to be reduced in the given syntax root. Complexify makes inferred names explicit for tuple elements and anonymous type members. This class considers which ones of those can be simplified (after the refactoring was done). If the inferred name of the member matches, the explicit name (from Complexify) can be removed. Whether or not converting would transition the code to the style the user prefers. i.e. if the user likes var for everything, and you have int i = 0 then will be . However, if the user likes var for everything and you have var i = 0, then it's still possible to convert that, it would just be for because it goes against the user's preferences. In general, most features should only convert the type if is . The one exception is the refactoring, which is explicitly there to still let people convert things quickly, even if it's going against their stated style. Returns true if type information could be gleaned by simply looking at the given statement. This typically means that the type name occurs in right hand side of an assignment. checks if the type represented by the given symbol is one of the simple types defined in the compiler. From the IDE perspective, we also include object and string to be simplified to var. considers string and object but the compiler's implementation of IsIntrinsicType does not. Returns true for type that are arrays/nullable/pointer types of special types Analyzes the assignment expression and rejects a given declaration if it is unsuitable for explicit typing. false, if explicit typing cannot be used. true, otherwise. Analyzes the assignment expression and rejects a given declaration if it is unsuitable for implicit typing. false, if implicit typing cannot be used. true, otherwise. this help finding a range of tokens to format based on given ending token Helper class to analyze the semantic effects of a speculated syntax node replacement on the parenting nodes. Given an expression node from a syntax tree and a new expression from a different syntax tree, it replaces the expression with the new expression to create a speculated syntax tree. It uses the original tree's semantic model to create a speculative semantic model and verifies that the syntax replacement doesn't break the semantics of any parenting nodes of the original expression. Creates a semantic analyzer for speculative syntax replacement. Original expression to be replaced. New expression to replace the original expression. Semantic model of node's syntax tree. Cancellation token. True if semantic analysis should be skipped for the replaced node and performed starting from parent of the original and replaced nodes. This could be the case when custom verifications are required to be done by the caller or semantics of the replaced expression are different from the original expression. True if semantic analysis should fail when any of the invocation expression ancestors of in original code has overload resolution failures. Determines whether performing the syntax replacement in one of the sibling nodes of the given lambda expressions will change the lambda binding semantics. This is done by first determining the lambda parameters whose type differs in the replaced lambda node. For each of these parameters, we find the descendant identifier name nodes in the lambda body and check if semantics of any of the parenting nodes of these identifier nodes have changed in the replaced lambda. Checks if the conversion might change the resultant boxed type. Similar boxing checks are performed elsewhere, but in this case we need to perform the check on the entire conditional expression. This will make sure the resultant cast is proper for the type of the conditional expression. Defines the known values for . Braces are allowed, but not preferred. The value 0 is important for serialization compatibility in . Prior to the use of this enum, the serialized value was the value . Braces are preferred where allowed except in the following limited situations: Braces are not required for the embedded statement of an else clause when the embedded statement is an if statement. In a sequence of consecutive using statements, only the last statement requires braces. In a sequence of consecutive lock statements, only the last statement requires braces. In a sequence of consecutive fixed statements, only the last statement requires braces. The value 1 is important for serialization compatibility in . Prior to the use of this enum, the serialized value was the value . Braces are always allowed, and generally preferred except in limited situations involving single-line statements and expressions: Braces may be omitted in the cases described for . Braces may be omitted when the entire statement is placed on one line. For a statement that contains one or more embedded statements, braces may be omitted when every embedded statement fits on one line, and the part preceding the embedded statement is placed on one line. If any embedded statement uses braces, braces are preferred for all embedded statements of the same parent statement. For the purposes of evaluating this rule, if the embedded statement following an else keyword is an if statement, the embedded statements of the nested if statement are treated as children of the parent statement of the else keyword.