public ICodeActionEdit GetEdit(CancellationToken cancellationToken) { var tree = (SyntaxTree)document.GetSyntaxTree(cancellationToken); var semanticModel = (SemanticModel)document.GetSemanticModel(cancellationToken); var property = getProperty(field.Parent as ClassDeclarationSyntax,semanticModel); // Move member var fieldMover = new FieldMover(semanticModel, semanticModel.GetDeclaredSymbol(field), field, property, parentClass); //visit the current tree and store the root of the new modified tree var newRoot = fieldMover.Visit(tree.Root); //transform the code to match the new syntax tree return editFactory.CreateTreeTransformEdit(document.Project.Solution, tree, newRoot); }
public ICodeActionEdit GetEdit(CancellationToken cancellationToken) { var tree = (SyntaxTree)document.GetSyntaxTree(cancellationToken); var semanticModel = (SemanticModel)document.GetSemanticModel(cancellationToken); var property = getProperty(field.Parent as ClassDeclarationSyntax, semanticModel); // Move member var fieldMover = new FieldMover(semanticModel, semanticModel.GetDeclaredSymbol(field), field, property, parentClass); //visit the current tree and store the root of the new modified tree var newRoot = fieldMover.Visit(tree.Root); //transform the code to match the new syntax tree return(editFactory.CreateTreeTransformEdit(document.Project.Solution, tree, newRoot)); }