internal static Document PerformAction(Document document, SyntaxNode root, TypeSyntax type) { var newRoot = root.ReplaceNode((SyntaxNode) type, SyntaxFactory.IdentifierName("var") .WithLeadingTrivia(type.GetLeadingTrivia()) .WithTrailingTrivia(type.GetTrailingTrivia()) ); return document.WithSyntaxRoot(newRoot); }
static Document PerformAction(Document document, SemanticModel model, SyntaxNode root, ITypeSymbol type, TypeSyntax typeSyntax) { var newRoot = root.ReplaceNode((SyntaxNode) typeSyntax, SyntaxFactory.ParseTypeName(type.ToMinimalDisplayString(model, typeSyntax.SpanStart)) .WithLeadingTrivia(typeSyntax.GetLeadingTrivia()) .WithTrailingTrivia(typeSyntax.GetTrailingTrivia()) ); return document.WithSyntaxRoot(newRoot); }
public static TRoot ReplaceType <TRoot>(this TRoot node, TypeSyntax type) where TRoot : SyntaxNode { string value = HlslKnownTypes.GetMappedName(type.ToString()); // If the HLSL mapped full type name equals the original type, just return the input node if (value == type.ToString()) { return(node); } // Process and return the type name TypeSyntax newType = SyntaxFactory.ParseTypeName(value).WithLeadingTrivia(type.GetLeadingTrivia()).WithTrailingTrivia(type.GetTrailingTrivia()); return(node.ReplaceNode(type, newType)); }
public static TypeSyntax Trivia(this TypeSyntax node, TypeSyntax that) { return node.WithLeadingTrivia(that.GetLeadingTrivia()).WithTrailingTrivia(that.GetTrailingTrivia()); }