276 references to ReplaceNode
Microsoft.AspNetCore.App.CodeFixes (7)
Authorization\AddAuthorizationBuilderFixer.cs (1)
139root.ReplaceNode(diagnosticTarget, invocation)));
DetectMismatchedParameterOptionalityFixer.cs (1)
49return document.WithSyntaxRoot(root.ReplaceNode(parameterSyntax, newParam));
Http\HeaderDictionaryAddFixer.cs (2)
75root.ReplaceNode(diagnosticTarget, invocation.WithAdditionalAnnotations(Simplifier.AddImportsAnnotation, annotation)))); 103return Task.FromResult(document.WithSyntaxRoot(root.ReplaceNode(diagnosticTarget, assignment)));
Http\HeaderDictionaryIndexerFixer.cs (1)
60return document.WithSyntaxRoot(root.ReplaceNode(elementAccessExpressionSyntax, newExpression));
RouteParameterUnusedParameterFixer.cs (1)
98var updatedSyntaxTree = root.ReplaceNode(methodSyntax, updatedMethod);
WebApplicationBuilderFixer.cs (1)
81return Task.FromResult(document.WithSyntaxRoot(root.ReplaceNode(diagnosticTarget, invocation)));
Microsoft.AspNetCore.Components.Analyzers (1)
ComponentParametersShouldBePublicCodeFixProvider.cs (1)
56var newSyntaxRoot = root.ReplaceNode(declarationNode, updatedDeclarationNode);
Microsoft.AspNetCore.Components.SdkAnalyzers (1)
ComponentParametersShouldBePublicCodeFixProvider.cs (1)
56var newSyntaxRoot = root.ReplaceNode(declarationNode, updatedDeclarationNode);
Microsoft.CodeAnalysis.CodeStyle (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (1)
201=> semanticRootOfOriginalExpression.ReplaceNode(this.OriginalExpression, annotatedReplacedExpression);
Microsoft.CodeAnalysis.CodeStyle.Fixes (14)
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (2)
102return Task.FromResult(document.WithSyntaxRoot(root.ReplaceNode(finalTarget, replacement))); 131return (currentTarget.Parent, currentTarget.Parent.ReplaceNode(currentTarget, currentReplacement).WithAdditionalAnnotations(Simplifier.Annotation));
src\Analyzers\Core\CodeFixes\AddExplicitCast\Fixer.cs (1)
210var newRoot = root.ReplaceNode(oldArgumentList, GenerateNewArgumentList(oldArgumentList, newArguments));
src\Analyzers\Core\CodeFixes\DocumentationComments\AbstractAddDocCommentNodesCodeFixProvider.cs (1)
121var newRoot = root.ReplaceNode(docCommentNode, newDocComment.WithAdditionalAnnotations(Formatter.Annotation));
src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (1)
195var newRoot = root.ReplaceNode(node, newNode);
src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (1)
107var newRoot = root.ReplaceNode(node, newNode);
src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchStatementCodeFixProvider.cs (1)
50var newRoot = root.ReplaceNode(switchNode, newSwitchNode);
src\Analyzers\Core\CodeFixes\UseConditionalExpression\ForAssignment\AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
142var updatedLocalDeclaration = localDeclaration.ReplaceNode(variable, updatedVariable);
src\Analyzers\Core\CodeFixes\UseNullPropagation\AbstractUseNullPropagationCodeFixProvider.cs (2)
250return whenPart.ReplaceNode(memberAccess, 261return whenPart.ReplaceNode(elementAccess,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
251var currentRoot = root.ReplaceNode(destinationDeclaration, transformedDeclaration);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.cs (1)
243return state.DeclarationStatement.ReplaceNode(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Simplification\AbstractSimplificationService.cs (2)
241? nodeOrToken.Parent.ReplaceNode(nodeOrToken.AsNode()!, currentNodeOrToken.AsNode()!) 256var newRoot = root.ReplaceNode(nodeOrToken.AsNode()!, currentNode.WithAdditionalAnnotations(marker));
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
197var newRoot = root.ReplaceNode(
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (12)
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (1)
364nodeToReplace, nodeToReplace.ReplaceNode(identifier, declarationExpression)
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpAddYieldCodeFixProvider.cs (1)
79root = root.ReplaceNode(returnStatement, yieldStatement);
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpChangeToIEnumerableCodeFixProvider.cs (4)
78newDocument = document.WithSyntaxRoot(root.ReplaceNode(node, newMethodDeclarationSyntax)); 84newDocument = document.WithSyntaxRoot(root.ReplaceNode(node, newOperator)); 90newDocument = document.WithSyntaxRoot(root.ReplaceNode(oldAccessor, oldAccessor.WithType(newReturnType))); 96newDocument = document.WithSyntaxRoot(root.ReplaceNode(oldIndexer, oldIndexer.WithType(newReturnType)));
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (1)
186localFunctionWithNewParameters = localFunctionWithNewParameters.ReplaceNode(
src\Analyzers\CSharp\CodeFixes\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (2)
82currentProperty = currentProperty.ReplaceNode( 90return currentProperty.ReplaceNode(
src\Analyzers\CSharp\CodeFixes\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs (1)
66var newWhenTrueStatement = whenTrueStatement.ReplaceNode(assignment, newAssignment);
src\Analyzers\CSharp\CodeFixes\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationCodeFixProvider.cs (1)
74return root.ReplaceNode(objectCreation, implicitObject);
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpIsAndCastCheckCodeFixProvider.cs (1)
90var newIf = currentIf.ReplaceNode(currentIf.Condition, updatedCondition);
Microsoft.CodeAnalysis.CSharp.EditorFeatures (1)
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (1)
73var newRoot = root.ReplaceNode(
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (2)
CodeGeneration\SyntaxGeneratorTests.cs (1)
45var newRoot = root.ReplaceNode(statement, replacement);
Diagnostics\FixAllProvider\BatchFixerTests.cs (1)
83var newRoot = root.ReplaceNode(node, newNode);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (8)
Attributes\AttributeTests.cs (5)
751var newRoot = root.ReplaceNode(attrSyntax, attrSyntax.WithArgumentList(SyntaxFactory.ParseAttributeArgumentList("()"))); 816var newRoot = root.ReplaceNode(attrSyntax, attrSyntax.WithArgumentList(SyntaxFactory.ParseAttributeArgumentList("()"))); 857var newRoot = root.ReplaceNode(attrSyntax, attrSyntax.WithArgumentList(SyntaxFactory.ParseAttributeArgumentList("()"))); 898var newRoot = root.ReplaceNode(attrSyntax, attrSyntax.WithArgumentList(SyntaxFactory.ParseAttributeArgumentList("()"))); 937var newRoot = root.ReplaceNode(attrSyntax, attrSyntax.WithArgumentList(SyntaxFactory.ParseAttributeArgumentList("()")));
Semantics\OutVarTests.cs (3)
32462var node1 = node0.ReplaceNode(one, decl); 34291syntaxTree = syntaxTree.GetCompilationUnitRoot().ReplaceNode(rankSpecifierOld, rankSpecifierNew).SyntaxTree; 34505syntaxTree = syntaxTree.GetCompilationUnitRoot().ReplaceNode(rankSpecifierOld, rankSpecifierNew).SyntaxTree;
Microsoft.CodeAnalysis.CSharp.Features (41)
AddImport\CSharpAddImportFeatureService.cs (1)
503return nameSyntax.ReplaceNode(aliasQualifiedName, aliasQualifiedName.Name);
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs (3)
308return scope.ReplaceNode( 352var newLabeledStatement = labeledStatement.ReplaceNode(newLocalDeclaration, SyntaxFactory.ParseStatement("")); 353return newScope.ReplaceNode(labeledStatement, newLabeledStatement);
CodeRefactorings\SyncNamespace\CSharpChangeNamespaceService.cs (1)
254return root.ReplaceNode(
CodeRefactorings\UseRecursivePatterns\UseRecursivePatternsCodeRefactoringProvider.cs (5)
114var replacement = isPatternExpression.ReplaceNode(containingPattern, rewrittenPattern); 115return root.ReplaceNode(logicalAnd, AdjustBinaryExpressionOperands(logicalAnd, replacement)); 131return root.ReplaceNode(logicalAnd, AdjustBinaryExpressionOperands(logicalAnd, replacement)); 137return root.ReplaceNode(logicalAnd, AdjustBinaryExpressionOperands(logicalAnd, replacement)); 144return root.ReplaceNode(logicalAnd, AdjustBinaryExpressionOperands(logicalAnd, replacement));
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (2)
441nodesBeforeLocal = [parentStatement.ReplaceNode(invocationExpression, initializer.WithAdditionalAnnotations(Simplifier.Annotation))]; 454nodesAfterLocal = [parentStatement.ReplaceNode(invocationExpression, variableLocal.WithAdditionalAnnotations(Simplifier.Annotation))];
ConvertProgram\ConvertProgramTransform_ProgramMain.cs (1)
97method = method.ReplaceNode(arrayType.ElementType, PredefinedType(StringKeyword));
EncapsulateField\CSharpEncapsulateFieldService.cs (1)
62root = root.ReplaceNode(declarator, updatedDeclarator);
ExtractMethod\CSharpMethodExtractor.cs (1)
192document = document.WithSyntaxRoot(root.ReplaceNode(originalMethodDefinition, methodDefinition));
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (1)
659root.ReplaceNode(methodDefinition, newMethodDefinition), cancellationToken).ConfigureAwait(false);
FullyQualify\CSharpFullyQualifyService.cs (2)
65return root.ReplaceNode(usingDirective, newUsingDirective); 68return root.ReplaceNode(simpleName, qualifiedName);
IntroduceVariable\CSharpIntroduceLocalForExpressionCodeRefactoringProvider.cs (2)
66localDeclaration = localDeclaration.ReplaceNode(value, expression.WithoutLeadingTrivia()); 82deconstruction = deconstruction.ReplaceNode(binary.Right, expression.WithoutLeadingTrivia());
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (2)
331root = root.ReplaceNode(root.GetCurrentNode(statement), 355var newRoot = root.ReplaceNode(innermostCommonBlock, finalInnerMostBlock);
ReplaceConditionalWithStatements\CSharpReplaceConditionalWithStatementsCodeRefactoringProvider.cs (2)
73localDeclarationStatement = localDeclarationStatement.ReplaceNode( 78return localDeclarationStatement.ReplaceNode(
ReplacePropertyWithMethods\CSharpReplacePropertyWithMethodsService.ConvertValueToParamRewriter.cs (2)
29return node.ReplaceNode(node.Name, ConvertToParam(node.Name)) 35? node.ReplaceNode(node.Name, ConvertToParam(node.Name))
ReplacePropertyWithMethods\CSharpReplacePropertyWithMethodsService.ConvertValueToReturnsRewriter.cs (2)
26? node.ReplaceNode(node.Name, ConvertToReturns(node.Name)) 31? node.ReplaceNode(node.Name, ConvertToReturns(node.Name))
SimplifyTypeNames\SimplifyTypeNamesCodeFixProvider.cs (1)
60annotatedexpressionSyntax = annotatedexpressionSyntax.ReplaceNode(right, right.WithAdditionalAnnotations(Simplifier.Annotation));
Snippets\CSharpSnippetHelpers.cs (1)
56var updatedTargetStatement = targetNode.ReplaceNode(block, updatedBlock);
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (1)
364nodeToReplace, nodeToReplace.ReplaceNode(identifier, declarationExpression)
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpAddYieldCodeFixProvider.cs (1)
79root = root.ReplaceNode(returnStatement, yieldStatement);
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (1)
186localFunctionWithNewParameters = localFunctionWithNewParameters.ReplaceNode(
src\Analyzers\CSharp\CodeFixes\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (2)
82currentProperty = currentProperty.ReplaceNode( 90return currentProperty.ReplaceNode(
src\Analyzers\CSharp\CodeFixes\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs (1)
66var newWhenTrueStatement = whenTrueStatement.ReplaceNode(assignment, newAssignment);
src\Analyzers\CSharp\CodeFixes\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationCodeFixProvider.cs (1)
74return root.ReplaceNode(objectCreation, implicitObject);
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpIsAndCastCheckCodeFixProvider.cs (1)
90var newIf = currentIf.ReplaceNode(currentIf.Condition, updatedCondition);
UseExpressionBody\UseExpressionBodyCodeRefactoringProvider.cs (2)
181var updatedParent = parent.ReplaceNode(declaration, updatedDeclaration) 184return root.ReplaceNode(parent, updatedParent);
UseExpressionBodyForLambda\UseExpressionBodyForLambdaCodeRefactoringProvider.cs (1)
203var newRoot = root.ReplaceNode(declaration, updatedDeclaration);
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (4)
IOperation\IOperationTests_IVariableDeclaration.cs (4)
1218syntaxTree = syntaxTree.GetCompilationUnitRoot().ReplaceNode(rankSpecifierOld, rankSpecifierNew).SyntaxTree; 2304syntaxTree = syntaxTree.GetCompilationUnitRoot().ReplaceNode(rankSpecifierOld, rankSpecifierNew).SyntaxTree; 2365syntaxTree = syntaxTree.GetCompilationUnitRoot().ReplaceNode(rankSpecifierOld, rankSpecifierNew).SyntaxTree; 2833syntaxTree = syntaxTree.GetCompilationUnitRoot().ReplaceNode(rankSpecifierOld, rankSpecifierNew).SyntaxTree;
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (3)
Semantics\InitOnlyMemberTests.cs (1)
3142var speculatedMethod = accessorDecl.ReplaceNode(accessorDecl.Body, blockStatement);
Semantics\NullableReferenceTypesTests.cs (1)
146458var newIfStatement = ifStatement.ReplaceNode(cast, replaceWith);
Semantics\SuppressAccessibilityChecksTests.cs (1)
217var speculatedMethod = accessorDecl.ReplaceNode(accessorDecl.Body, blockStatement);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (17)
Compilation\GetSemanticInfoTests.cs (1)
4877var newStatement = statement.ReplaceNode(statement.Declaration.Variables[0].Initializer.Value, newSyntax);
Compilation\SemanticModelAPITests.cs (16)
1558newEqualsValue = param.ReplaceNode(equalsValue, newEqualsValue).Default; 2092newSyntax = oldSyntax.ReplaceNode(oldSyntax.DescendantNodes().OfType<CastExpressionSyntax>().Single(), newArgument); 2109newSyntax = oldSyntax.ReplaceNode(oldSyntax.DescendantNodes().OfType<CastExpressionSyntax>().Single(), newArgument); 2191var speculatedStatement = statement.ReplaceNode(initializer.Value, SyntaxFactory.ParseExpression("0")); 2225var speculatedStatement = statement.ReplaceNode(expression, SyntaxFactory.ParseExpression("0")); 2233var newSpeculatedStatement = statement.ReplaceNode(expression, SyntaxFactory.ParseExpression("1.1")); 2352var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2448var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2490var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2535var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2567var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2584speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2598speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2638var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2675var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2774var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (16)
Syntax\SyntaxAnnotationTests.cs (5)
165var newRoot = tree.GetCompilationUnitRoot().ReplaceNode(node, annotatedNode); 175var twiceAnnotatedRoot = newRoot.ReplaceNode(node2, twiceAnnotatedNode); 289var newRoot = tree.GetCompilationUnitRoot().ReplaceNode(lastChildOfFirstNode, annotatedNode); 542return root.ReplaceNode(oldNodeOrToken.AsNode(), newNodeOrToken.AsNode()); 595newRoot = syntaxTree.GetCompilationUnitRoot().ReplaceNode(nodeOrToken.AsNode(), newNode);
Syntax\SyntaxDiffingTests.cs (2)
319var newRoot = root.ReplaceNode(node, newNode); 381var newRoot = root.ReplaceNode(node, newNode);
Syntax\SyntaxNodeTests.cs (2)
2081var expr2 = bex.ReplaceNode(bex.Right, SyntaxFactory.ParseExpression("c")); 3604root = root.ReplaceNode(ThirdUsingClause, newUsingClause);
Syntax\SyntaxRewriterTests.cs (3)
350Assert.Same(tree, tree.GetCompilationUnitRoot().ReplaceNode(typeName, typeName).SyntaxTree); 351var newRoot = tree.GetCompilationUnitRoot().ReplaceNode(typeName, SyntaxFactory.ParseTypeName("Class2<U>")); 366var newRoot = root.ReplaceNode(before, after);
Syntax\TrackNodeTests.cs (4)
70var replacedExpr = trackedExpr.ReplaceNode(currentA, newA); 85var replacedExpr = trackedExpr.ReplaceNode(currentA, newA); 100var replacedExpr = trackedExpr.ReplaceNode(currentA, SyntaxFactory.IdentifierName("c")); 112var replacedExpr = trackedExpr.ReplaceNode(currentA, SyntaxFactory.IdentifierName("c"));
Microsoft.CodeAnalysis.CSharp.Workspaces (10)
Rename\CSharpRenameRewriterLanguageService.cs (2)
291var speculativeTree = originalNode.SyntaxTree.GetRoot(_cancellationToken).ReplaceNode(originalNode, newNode); 306speculativeTree = originalNode.SyntaxTree.GetRoot(_cancellationToken).ReplaceNode(originalNode, newNode);
Simplification\CSharpSimplificationService.Expander.cs (2)
497replacement = replacement.ReplaceNode( 513replacement = replacement.ReplaceNode(
Simplification\Reducers\CSharpCastReducer.Rewriter.cs (1)
60var reducedAncestor = topmostExpressionAncestor.ReplaceNode(node, reducedNode);
Simplification\Reducers\CSharpMiscellaneousReducer.cs (1)
49var newLambda = oldLambda.ReplaceNode(parameterSyntax, newParameterSyntax);
Simplification\Simplifiers\MemberAccessExpressionSimplifier.cs (1)
81return IsEntirelySimpleNames(parent.ReplaceNode(memberAccessExpression, memberAccessExpression.Name));
Simplification\Simplifiers\NameSimplifier.cs (1)
666var newCastExpression = castExpression.ReplaceNode(castExpression.Type, simplifiedNode);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
197var newRoot = root.ReplaceNode(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (1)
109return root.ReplaceNode(firstOuterNamespaceWithUsings, newNamespace);
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (4)
CodeGeneration\SyntaxGeneratorTests.cs (1)
4583var newRoot = root.ReplaceNode(decl, newDecl);
Formatting\FormattingElasticTriviaTests.cs (1)
113var newRoot = root.ReplaceNode(decl, newDecl);
Formatting\FormattingTreeEditTests.cs (2)
44var root1 = root.ReplaceNode(param, g.AddAttributes(param, g.Attribute("MyAttr"))); 58var root2 = root.ReplaceNode(method, g.AddAttributes(method, g.Attribute("MyAttr")));
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (3)
CodeGeneration\CodeGenerationTests.cs (3)
316testContext.Result = testContext.Document.WithSyntaxRoot((await testContext.Document.GetSyntaxRootAsync()).ReplaceNode(oldSyntax, newSyntax)); 332testContext.Result = testContext.Document.WithSyntaxRoot((await testContext.Document.GetSyntaxRootAsync()).ReplaceNode(oldMemberSyntax, newMemberSyntax)); 614testContext.Result = testContext.Document.WithSyntaxRoot(testContext.SemanticModel.SyntaxTree.GetRoot().ReplaceNode(declarationNode, updatedDeclarationNode));
Microsoft.CodeAnalysis.Features (23)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.LocalSuppressMessageCodeAction.cs (1)
33var newRoot = root.ReplaceNode<SyntaxNode>(TargetNode_TestOnly, newTargetNode);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaHelpers.cs (1)
61var newRoot = root.ReplaceNode(nodeWithTokens, newNode);
ConvertLinq\AbstractConvertLinqQueryToForEachProvider.cs (1)
77return root.ReplaceNode(Source, Destinations[0]);
EncapsulateField\AbstractEncapsulateFieldService.cs (1)
178document = document.WithSyntaxRoot(fieldDeclaration.SyntaxTree.GetRoot(cancellationToken).ReplaceNode(fieldDeclaration.GetSyntax(cancellationToken),
IntroduceParameter\IntroduceParameterDocumentRewriter.cs (1)
336var expressionsWithConditionalAccessors = conditionalRoot.ReplaceNode(invocation, newMethodInvocation);
InvertIf\AbstractInvertIfCodeRefactoringProvider.cs (3)
444return root.ReplaceNode(ifNode, updatedIf); 456return root.ReplaceNode(ifNode, updatedIf); 467return root.ReplaceNode(ifNode, updatedIf);
NameTupleElement\AbstractNameTupleElementCodeRefactoringProvider.cs (1)
87var newRoot = root.ReplaceNode(argument, newArgument);
ReplaceConditionalWithStatements\AbstractReplaceConditionalWithStatementsCodeRefactoringProvider.cs (1)
300var containerWithConditionalReplaced = container.ReplaceNode(conditionalExpression, TryConvert(expression, conditionalType).WithTriviaFrom(conditionalExpression));
ReplacePropertyWithMethods\AbstractReplacePropertyWithMethodsService.cs (3)
348return _expression.ReplaceNode(_identifierName, newIdentifierName); 372_expression.ReplaceNode(_identifierName, newIdentifierName), 399var updatedExpression = _expression.ReplaceNode(_identifierName, newIdentifierName);
Shared\Extensions\DocumentExtensions.cs (1)
40var newRoot = root.ReplaceNode(oldNode, newNode);
Shared\Utilities\AnnotatedSymbolMapping.cs (1)
61currentRoots[typeNode.SyntaxTree] = typeNodeRoot.ReplaceNode(typeNode, typeNode.WithAdditionalAnnotations(typeNodeAnnotation));
SplitOrMergeIfStatements\AbstractSplitIfStatementCodeRefactoringProvider.cs (1)
107var right = rootExpression.ReplaceNode(token.Parent, parentRight);
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (1)
131return (currentTarget.Parent, currentTarget.Parent.ReplaceNode(currentTarget, currentReplacement).WithAdditionalAnnotations(Simplifier.Annotation));
src\Analyzers\Core\CodeFixes\AddExplicitCast\Fixer.cs (1)
210var newRoot = root.ReplaceNode(oldArgumentList, GenerateNewArgumentList(oldArgumentList, newArguments));
src\Analyzers\Core\CodeFixes\PopulateSwitch\AbstractPopulateSwitchStatementCodeFixProvider.cs (1)
50var newRoot = root.ReplaceNode(switchNode, newSwitchNode);
src\Analyzers\Core\CodeFixes\UseConditionalExpression\ForAssignment\AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
142var updatedLocalDeclaration = localDeclaration.ReplaceNode(variable, updatedVariable);
src\Analyzers\Core\CodeFixes\UseNullPropagation\AbstractUseNullPropagationCodeFixProvider.cs (2)
250return whenPart.ReplaceNode(memberAccess, 261return whenPart.ReplaceNode(elementAccess,
UseNamedArguments\AbstractUseNamedArgumentsCodeRefactoringProvider.cs (1)
146var newRoot = root.ReplaceNode(argumentList, newArgumentList);
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (2)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\StatementSyntaxExtensions.vb (1)
125Return methodBlock.ReplaceNode(methodBlock.BlockStatement, newBegin)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxNodeExtensions.vb (1)
750Return tree.GetRoot().ReplaceNode(oldBlock, newBlock)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (7)
src\Analyzers\VisualBasic\CodeFixes\Iterator\VisualBasicChangeToYieldCodeFixProvider.vb (1)
44root = root.ReplaceNode(returnStatement, yieldStatement)
src\Analyzers\VisualBasic\CodeFixes\Iterator\VisualBasicConvertToIteratorCodeFixProvider.vb (2)
127Return root.ReplaceNode(methodStatementNode, newFunctionNode) 136Return root.ReplaceNode(lambdaNode.SubOrFunctionHeader, newHeader)
src\Analyzers\VisualBasic\CodeFixes\UseCollectionInitializer\VisualBasicUseCollectionInitializerCodeFixProvider.vb (1)
52Dim newStatement = statement.ReplaceNode(
src\Analyzers\VisualBasic\CodeFixes\UseConditionalExpression\VisualBasicUseConditionalExpressionForAssignmentCodeFixProvider.vb (1)
52Return statement.ReplaceNode(declarator, declarator.WithAdditionalAnnotations(Simplifier.Annotation))
src\Analyzers\VisualBasic\CodeFixes\UseObjectInitializer\VisualBasicUseObjectInitializerCodeFixProvider.vb (1)
39Dim newStatement = statement.ReplaceNode(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ParameterSyntaxExtensions.vb (1)
21Dim newLambda = oldLambda.ReplaceNode(parameter, newParameterSyntax)
Microsoft.CodeAnalysis.VisualBasic.Features (21)
CodeFixes\CorrectNextControlVariable\CorrectNextControlVariableCodeFixProvider.CodeAction.vb (1)
31Dim updatedRoot = root.ReplaceNode(_node, _newNode)
CodeFixes\GenerateEndConstruct\GenerateEndConstructCodeFixProvider.vb (2)
177updatedProperty = updatedProperty.ReplaceNode(getter, getter.WithEndBlockStatement(SyntaxFactory.EndGetStatement())) 182updatedProperty = updatedProperty.ReplaceNode(setter, setter.WithEndBlockStatement(SyntaxFactory.EndSetStatement()))
CodeFixes\IncorrectFunctionReturnType\IncorrectFunctionReturnTypeCodeFixProvider.vb (1)
81Dim newRoot = root.ReplaceNode(node, rewrittenNode)
EncapsulateField\VisualBasicEncapsulateFieldService.vb (1)
63Return root.ReplaceNode(fieldDeclaration, updatedDeclaration)
ExtractInterface\VisualBasicExtractInterfaceService.vb (3)
141docToRootMap(currentDocId) = currentRoot.ReplaceNode(method, method.WithImplementsClause(GetUpdatedImplementsClause(method.ImplementsClause, qualifiedName))) 147docToRootMap(currentDocId) = currentRoot.ReplaceNode([event], [event].WithImplementsClause(GetUpdatedImplementsClause([event].ImplementsClause, qualifiedName))) 153docToRootMap(currentDocId) = currentRoot.ReplaceNode(prop, prop.WithImplementsClause(GetUpdatedImplementsClause(prop.ImplementsClause, qualifiedName)))
FullyQualify\VisualBasicFullyQualifyService.vb (1)
71Return root.ReplaceNode(simpleName, qualifiedName)
ReplaceConditionalWithStatementsCodeRefactoringProvider\VisualBasicReplaceConditionalWithStatementsCodeRefactoringProvider.vb (1)
69Return localDeclarationStatement.ReplaceNode(
ReplaceMethodWithProperty\VisualBasicReplaceMethodWithPropertyService.vb (1)
208expression.ReplaceNode(name, newName),
ReplacePropertyWithMethods\VisualBasicReplacePropertyWithMethods.ConvertValueToParamRewriter.vb (2)
30Return node.ReplaceNode(node.Name, ConvertToParam(node.Name)) _ 36node.ReplaceNode(node.Name, ConvertToParam(node.Name)),
ReplacePropertyWithMethods\VisualBasicReplacePropertyWithMethods.ConvertValueToReturnsRewriter.vb (2)
27node.ReplaceNode(node.Name, ConvertToReturns(node.Name)), 33node.ReplaceNode(node.Name, ConvertToReturns(node.Name)),
src\Analyzers\VisualBasic\CodeFixes\Iterator\VisualBasicChangeToYieldCodeFixProvider.vb (1)
44root = root.ReplaceNode(returnStatement, yieldStatement)
src\Analyzers\VisualBasic\CodeFixes\Iterator\VisualBasicConvertToIteratorCodeFixProvider.vb (2)
127Return root.ReplaceNode(methodStatementNode, newFunctionNode) 136Return root.ReplaceNode(lambdaNode.SubOrFunctionHeader, newHeader)
src\Analyzers\VisualBasic\CodeFixes\UseCollectionInitializer\VisualBasicUseCollectionInitializerCodeFixProvider.vb (1)
52Dim newStatement = statement.ReplaceNode(
src\Analyzers\VisualBasic\CodeFixes\UseConditionalExpression\VisualBasicUseConditionalExpressionForAssignmentCodeFixProvider.vb (1)
52Return statement.ReplaceNode(declarator, declarator.WithAdditionalAnnotations(Simplifier.Annotation))
src\Analyzers\VisualBasic\CodeFixes\UseObjectInitializer\VisualBasicUseObjectInitializerCodeFixProvider.vb (1)
39Dim newStatement = statement.ReplaceNode(
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (3)
Compilation\SemanticModelAPITests.vb (3)
1139Dim speculatedStatement = statement.ReplaceNode(initializer.Value, SyntaxFactory.ParseExpression("0")) 1171Dim speculatedStatement = DirectCast(statement.ReplaceNode(expression, SyntaxFactory.ParseExpression("0")), LocalDeclarationStatementSyntax) 1180Dim newSpeculatedStatement = DirectCast(statement.ReplaceNode(expression, SyntaxFactory.ParseExpression("1.1")), LocalDeclarationStatementSyntax)
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (14)
Syntax\SyntaxAnnotationTests.vb (5)
151Dim newRoot = tree.GetRoot().ReplaceNode(node, annotatedNode) 161Dim twiceAnnotatedRoot = newRoot.ReplaceNode(node2, twiceAnnotatedNode) 271Dim newRoot = tree.GetRoot().ReplaceNode(lastChildOfFirstNode, annotatedNode) 499Return root.ReplaceNode(oldNodeOrToken.AsNode(), newNodeOrToken.AsNode()) 540newRoot = tree.GetRoot().ReplaceNode(nodeOrToken.AsNode(), newNode)
TestSyntaxNodes.vb (9)
1248simpleTree = simpleTree.ReplaceNode(firstOper, SyntaxFactory.StringLiteralExpression(SyntaxFactory.StringLiteralToken("""Hi""", "Hi"))) 1252simpleTree = simpleTree.ReplaceNode(firstOper, SyntaxFactory.StringLiteralExpression(SyntaxFactory.StringLiteralToken("""ha""", "ha"))) 1256simpleTree = simpleTree.ReplaceNode(secondOper, SyntaxFactory.StringLiteralExpression(SyntaxFactory.MissingStringLiteral())) 1260simpleTree = simpleTree.ReplaceNode(newSecondOper, SyntaxFactory.StringLiteralExpression(SyntaxFactory.StringLiteralToken("""Bye""", "Bye"))) 1276Dim expr2 = expr.ReplaceNode(bex.Right, SyntaxFactory.ParseExpression("c")) 1905tree = tree.ReplaceNode(op, newOp) 2855Root = Root.ReplaceNode(oldImportClause, newImportsClause) 3280Root = Root.ReplaceNode(Root.Members(1), Module2) 3290Root = Root.ReplaceNode(Root.Members(2), Module3)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (12)
CodeCleanup\AsyncOrIteratorFunctionReturnTypeFixer.vb (1)
204newTypeSyntax = newTypeSyntax.ReplaceNode(currentTypeArgument, newTypeArgument) _
Rename\VisualBasicRenameRewriterLanguageService.vb (2)
190Dim speculativeTree = originalNode.SyntaxTree.GetRoot(_cancellationToken).ReplaceNode(originalNode, newNode) 212speculativeTree = originalNode.SyntaxTree.GetRoot(_cancellationToken).ReplaceNode(originalNode, expandedNewNode)
Simplification\Simplifiers\ExpressionSimplifier.vb (1)
284Dim parentReplacement = parent.ReplaceNode(parent.Expression, replacementNode)
Simplification\Simplifiers\NameSimplifier.vb (1)
340Dim parentReplacement = parent.ReplaceNode(parent.Left, replacementNode)
Simplification\VisualBasicSimplificationService.Expander.vb (1)
533replacement = replacement.ReplaceNode(
Simplification\VisualBasicSimplificationService.vb (3)
138Return originalNode.ReplaceNode(DirectCast(originalNode, AsNewClauseSyntax).NewExpression, DirectCast(reducedNode, EqualsValueSyntax).Value) 144reducedMethod = reducedMethod.ReplaceNode(reducedMethod.BlockStatement, originalMethod.BlockStatement) 145Return reducedMethod.ReplaceNode(reducedMethod.EndBlockStatement, originalMethod.EndBlockStatement)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\StatementSyntaxExtensions.vb (1)
125Return methodBlock.ReplaceNode(methodBlock.BlockStatement, newBegin)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxNodeExtensions.vb (1)
750Return tree.GetRoot().ReplaceNode(oldBlock, newBlock)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ParameterSyntaxExtensions.vb (1)
21Dim newLambda = oldLambda.ReplaceNode(parameter, newParameterSyntax)
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (4)
Formatting\FormattingTests.vb (4)
3777root = root.ReplaceNode(implementsStatement, implementsStatement.NormalizeWhitespace(elasticTrivia:=True).WithAdditionalAnnotations(goo)) 3780root = root.ReplaceNode(field, field.NormalizeWhitespace(elasticTrivia:=True).WithAdditionalAnnotations(goo)) 3782root = root.ReplaceNode(prop, prop.NormalizeWhitespace(elasticTrivia:=True).WithAdditionalAnnotations(goo)) 3785root = root.ReplaceNode(method, method.NormalizeWhitespace(elasticTrivia:=True).WithAdditionalAnnotations(goo))
Microsoft.CodeAnalysis.Workspaces (8)
Editing\SyntaxGenerator.cs (3)
1380=> (newDeclaration != null) ? root.ReplaceNode(node, newDeclaration) : RemoveNode(root, node); 1490return root.ReplaceNode(original, combinedTriviaReplacement); 1533var newRoot = root.ReplaceNode(node, trackedFirst);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (1)
201=> semanticRootOfOriginalExpression.ReplaceNode(this.OriginalExpression, annotatedReplacedExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
251var currentRoot = root.ReplaceNode(destinationDeclaration, transformedDeclaration);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.cs (1)
243return state.DeclarationStatement.ReplaceNode(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Simplification\AbstractSimplificationService.cs (2)
241? nodeOrToken.Parent.ReplaceNode(nodeOrToken.AsNode()!, currentNodeOrToken.AsNode()!) 256var newRoot = root.ReplaceNode(nodeOrToken.AsNode()!, currentNode.WithAdditionalAnnotations(marker));
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (1)
VisualStudioMSBuildWorkspaceTests.cs (1)
342var newRoot = root.ReplaceNode(decl, newDecl);
Microsoft.CodeAnalysis.Workspaces.UnitTests (6)
CodeCleanup\CodeCleanupTests.cs (4)
198root = root.ReplaceNode(@class, classWithMember); 219root = root.ReplaceNode(@class, classWithMember); 240root = root.ReplaceNode(@class, classWithMember); 310root = root.ReplaceNode(accessor, newAccessor);
SolutionTests\SolutionTests.cs (1)
3241newSyntaxRoot = syntaxRoot.ReplaceNode(classNode, classNode.WithModifiers(VB.SyntaxFactory.TokenList(VB.SyntaxFactory.ParseToken("Public"))));
SyntaxNodeTests.cs (1)
113trackedRoot = trackedRoot.ReplaceNode(currentClassDecl, classDeclWithField);
Microsoft.ML.InternalCodeAnalyzer (3)
ContractsCheckNameofFixProvider.cs (3)
172var newRoot = root.ReplaceNode(nameArg.Expression, nameofExp); 179var newNameofExp = nameofExp.ReplaceNode(nameofExp.ArgumentList.Arguments[0].Expression, exp.WithoutTrivia()); 183var newRoot = root.ReplaceNode(nameArg.Expression, newNameofExp);
Microsoft.VisualStudio.LanguageServices.CSharp (5)
CodeModel\CSharpCodeModelService.cs (5)
935typeNode = typeNode.ReplaceNode(member, constructor); 940typeNode = typeNode.ReplaceNode(member, destructor); 2745return node.ReplaceNode(oldType, newType); 2782newEnumDeclaration = newEnumDeclaration.ReplaceNode(lastMember, lastMember.WithTrailingTrivia(trailingTrivia)); 3241enumDeclaration = enumDeclaration.ReplaceNode(lastMember, lastMember.WithTrailingTrivia(SyntaxTriviaList.Empty));
Microsoft.VisualStudio.LanguageServices.VisualBasic (15)
CodeModel\VisualBasicCodeModelService.vb (15)
3012delegateStatement = delegateStatement.ReplaceNode(oldType, newType) 3046eventStatement = eventStatement.ReplaceNode(oldType, newType) 3076eventStatement = eventStatement.ReplaceNode(oldType, newType) 3101newFirstParameter = firstParameter.ReplaceNode(oldType, newType) 3110newAccessorBlock = accessorBlock.ReplaceNode(firstParameter, newFirstParameter) 3124newAccessorBlock = accessorBlock.ReplaceNode(accessorBlock.BlockStatement.ParameterList, newParameterList) 3130eventBlock = eventBlock.ReplaceNode(accessorBlock, newAccessorBlock) 3184declareStatement = declareStatement.ReplaceNode(oldType, newType) 3236methodStatement = methodStatement.ReplaceNode(oldType, newType) 3295parameter = parameter.ReplaceNode(oldType, newType) 3323propertyStatement = propertyStatement.ReplaceNode(oldType, newType) 3365newFirstParameter = firstParameter.ReplaceNode(oldType, newType) 3374newAccessorBlock = accessorBlock.ReplaceNode(firstParameter, newFirstParameter) 3379propertyBlock = propertyBlock.ReplaceNode(accessorBlock, newAccessorBlock) 3406variableDeclarator = variableDeclarator.ReplaceNode(oldType, newType)
System.Text.RegularExpressions.Generator (2)
UpgradeToGeneratedRegexCodeFixer.cs (2)
176newTypeDeclarationOrCompilationUnit = newTypeDeclarationOrCompilationUnit.ReplaceNode(nodeToFix, WithTrivia(replacement, nodeToFix)); 240return document.WithSyntaxRoot(root.ReplaceNode(typeDeclarationOrCompilationUnit, newTypeDeclarationOrCompilationUnit));
System.Windows.Forms.Analyzers.CodeFixes.CSharp (2)
System\Windows\Forms\CSharp\CodeFixes\AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.cs (2)
98root = root.ReplaceNode(propertyDeclarationSyntax, newProperty); 148root.ReplaceNode(
System.Windows.Forms.Analyzers.CodeFixes.VisualBasic (2)
AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.vb (2)
112root = root.ReplaceNode(propertyDeclarationSyntax, newProperty) 164root.ReplaceNode(