本文整理汇总了C#中Microsoft.CodeAnalysis.SyntaxNode.WithoutAnnotations方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxNode.WithoutAnnotations方法的具体用法?C# SyntaxNode.WithoutAnnotations怎么用?C# SyntaxNode.WithoutAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.SyntaxNode
的用法示例。
在下文中一共展示了SyntaxNode.WithoutAnnotations方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SimplifyName
private static SyntaxNode SimplifyName(
SyntaxNode node,
SemanticModel semanticModel,
OptionSet optionSet,
CancellationToken cancellationToken)
{
SyntaxNode replacementNode;
TextSpan issueSpan;
if (node.CSharpKind() == SyntaxKind.QualifiedCref)
{
var crefSyntax = (QualifiedCrefSyntax)node;
CrefSyntax crefReplacement;
if (!crefSyntax.TryReduceOrSimplifyExplicitName(semanticModel, out crefReplacement, out issueSpan, cancellationToken))
{
return node;
}
replacementNode = crefReplacement;
}
else
{
var expressionSyntax = (ExpressionSyntax)node;
ExpressionSyntax expressionReplacement;
if (!expressionSyntax.TryReduceOrSimplifyExplicitName(semanticModel, out expressionReplacement, out issueSpan, optionSet, cancellationToken))
{
return node;
}
replacementNode = expressionReplacement;
}
node = node.CopyAnnotationsTo(replacementNode).WithAdditionalAnnotations(Formatter.Annotation);
return node.WithoutAnnotations(Simplifier.Annotation);
}
示例2: Complexify
private SyntaxNode Complexify(SyntaxNode originalNode, SyntaxNode newNode)
{
_isProcessingComplexifiedSpans = true;
_modifiedSubSpans = new List<ValueTuple<TextSpan, TextSpan>>();
var annotation = new SyntaxAnnotation();
newNode = newNode.WithAdditionalAnnotations(annotation);
var speculativeTree = originalNode.SyntaxTree.GetRoot(_cancellationToken).ReplaceNode(originalNode, newNode);
newNode = speculativeTree.GetAnnotatedNodes<SyntaxNode>(annotation).First();
_speculativeModel = GetSemanticModelForNode(newNode, _semanticModel);
Debug.Assert(_speculativeModel != null, "expanding a syntax node which cannot be speculated?");
var oldSpan = originalNode.Span;
var expandParameter = originalNode.GetAncestorsOrThis(n => n is SimpleLambdaExpressionSyntax || n is ParenthesizedLambdaExpressionSyntax).Count() == 0;
newNode = _simplificationService.Expand(newNode,
_speculativeModel,
annotationForReplacedAliasIdentifier: null,
expandInsideNode: null,
expandParameter: expandParameter,
cancellationToken: _cancellationToken);
speculativeTree = originalNode.SyntaxTree.GetRoot(_cancellationToken).ReplaceNode(originalNode, newNode);
newNode = speculativeTree.GetAnnotatedNodes<SyntaxNode>(annotation).First();
_speculativeModel = GetSemanticModelForNode(newNode, _semanticModel);
newNode = base.Visit(newNode);
var newSpan = newNode.Span;
newNode = newNode.WithoutAnnotations(annotation);
newNode = _renameAnnotations.WithAdditionalAnnotations(newNode, new RenameNodeSimplificationAnnotation() { OriginalTextSpan = oldSpan });
_renameSpansTracker.AddComplexifiedSpan(_documentId, oldSpan, new TextSpan(oldSpan.Start, newSpan.Length), _modifiedSubSpans);
_modifiedSubSpans = null;
_isProcessingComplexifiedSpans = false;
_speculativeModel = null;
return newNode;
}
示例3: Visit
public override SyntaxNode Visit(SyntaxNode node)
{
node = base.Visit(node);
if (node != null && node.ContainsAnnotations && node.GetAnnotations(s_renameAnnotationName).Any())
{
node = node.WithoutAnnotations(s_renameAnnotationName);
}
return node;
}
示例4: GetUpdatedDocumentAsync
public override async Task<Document> GetUpdatedDocumentAsync(
Document document,
IList<Tuple<INamedTypeSymbol, IList<ISymbol>>> unimplementedMembers,
INamedTypeSymbol classOrStructType,
SyntaxNode classOrStructDecl,
CancellationToken cancellationToken)
{
var result = document;
var compilation = await result.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
// Add an annotation to the type declaration node so that we can find it again to append the dispose pattern implementation below.
result = await result.ReplaceNodeAsync(
classOrStructDecl,
classOrStructDecl.WithAdditionalAnnotations(s_implementingTypeAnnotation),
cancellationToken).ConfigureAwait(false);
var root = await result.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
classOrStructDecl = root.GetAnnotatedNodes(s_implementingTypeAnnotation).Single();
compilation = await result.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
classOrStructType = classOrStructType.GetSymbolKey().Resolve(compilation, cancellationToken: cancellationToken).Symbol as INamedTypeSymbol;
// Use the code generation service to generate all unimplemented members except those that are
// part of the dispose pattern. We can't use the code generation service to implement the dispose
// pattern since the code generation service doesn't support injection of the custom boiler
// plate code required for implementing the dispose pattern.
var idisposable = TryGetSymbolForIDisposable(compilation);
result = await base.GetUpdatedDocumentAsync(
result,
unimplementedMembers.Where(m => !m.Item1.Equals(idisposable)).ToList(),
classOrStructType,
classOrStructDecl,
cancellationToken).ConfigureAwait(false);
// Now append the dispose pattern implementation.
root = await result.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
classOrStructDecl = root.GetAnnotatedNodes(s_implementingTypeAnnotation).Single();
compilation = await result.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
classOrStructType = classOrStructType.GetSymbolKey().Resolve(compilation, cancellationToken: cancellationToken).Symbol as INamedTypeSymbol;
result = Service.ImplementDisposePattern(result, root, classOrStructType, classOrStructDecl.SpanStart, Explicitly);
// Remove the annotation since we don't need it anymore.
root = await result.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
classOrStructDecl = root.GetAnnotatedNodes(s_implementingTypeAnnotation).Single();
result = await result.ReplaceNodeAsync(
classOrStructDecl,
classOrStructDecl.WithoutAnnotations(s_implementingTypeAnnotation),
cancellationToken).ConfigureAwait(false);
return result;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:49,代码来源:AbstractImplementInterfaceService.DisposePatternCodeAction.cs