本文整理汇总了C#中Microsoft.CodeAnalysis.Document.GetSemanticModelAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Document.GetSemanticModelAsync方法的具体用法?C# Document.GetSemanticModelAsync怎么用?C# Document.GetSemanticModelAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.Document
的用法示例。
在下文中一共展示了Document.GetSemanticModelAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRefactoringsAsync
public async Task<IEnumerable<CodeAction>> GetRefactoringsAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken)
{
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var node = root.FindNode(textSpan);
var switchStatementNode = node as SwitchStatementSyntax;
if (switchStatementNode == null)
return null;
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var memberEx = switchStatementNode.Expression as MemberAccessExpressionSyntax;
if (memberEx == null)
return null;
var symbolInfo = semanticModel.GetTypeInfo(memberEx.Name);
var enumTypeInfo = symbolInfo.Type;
if (enumTypeInfo.TypeKind != TypeKind.Enum)
return null;
var enumName = enumTypeInfo.Name;
var nameSpace = enumTypeInfo.ContainingNamespace.Name;
var enumType = Type.GetType(nameSpace + "." + enumName);
if (enumType == null)
return null;
return new[] { CodeAction.Create("Explode Switch", c => ExplodeSwitch(document, root, semanticModel, switchStatementNode, c)) };
}
示例2: MakeMock
private static async Task<Document> MakeMock(Document document, SyntaxNode invokationSyntax,
CancellationToken cancellationToken)
{
var testSemanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var testInitMethodDecl = TestSemanticHelper.GetTestInitializeMethod(testSemanticModel);
var declaredFields = testInitMethodDecl.Parent.ChildNodes().OfType<FieldDeclarationSyntax>().ToArray();
var suts = testInitMethodDecl.GetSuts(testSemanticModel, declaredFields);
var memberAccessExpressions = invokationSyntax.DescendantNodes()
.OfType<ExpressionSyntax>()
.Where(x => x is InvocationExpressionSyntax || x is MemberAccessExpressionSyntax)
.Select(expr =>
{
var memberAccess = expr as MemberAccessExpressionSyntax;
var invokationExpression = expr as InvocationExpressionSyntax;
var expression = invokationExpression == null ? memberAccess : invokationExpression.Expression;
return expression;
});
var invokedMethodsOfMocks = memberAccessExpressions.SelectMany(expressionSyntax => MocksAnalyzingEngine.GetInvokedMethodsOfMock(expressionSyntax, testSemanticModel, suts))
.DistinctBy(x => string.Join(",", x.FieldsToSetup.SelectMany(y => y.Field.Select(z => z))) + "," + x.MethodOrPropertySymbol)
.ToArray();
if (invokedMethodsOfMocks.Length == 0)
return document;
var editor = await DocumentEditor.CreateAsync(document, cancellationToken).ConfigureAwait(false);
ChangesMaker.ApplyChanges(invokationSyntax, editor, invokedMethodsOfMocks);
return editor.GetChangedDocument();
}
示例3: MakeAutoPropertyAsync
public async static Task<Solution> MakeAutoPropertyAsync(Document document, SyntaxNode root, PropertyDeclarationSyntax property, CancellationToken cancellationToken)
{
var semanticModel = await document.GetSemanticModelAsync(cancellationToken);
var getterReturn = (ReturnStatementSyntax)property.AccessorList.Accessors.First(a => a.Keyword.ValueText == "get").Body.Statements.First();
var returnIdentifier = (IdentifierNameSyntax)(getterReturn.Expression is MemberAccessExpressionSyntax ? ((MemberAccessExpressionSyntax)getterReturn.Expression).Name : getterReturn.Expression);
var returnIdentifierSymbol = semanticModel.GetSymbolInfo(returnIdentifier).Symbol;
var variableDeclarator = (VariableDeclaratorSyntax)returnIdentifierSymbol.DeclaringSyntaxReferences.First().GetSyntax();
var fieldDeclaration = variableDeclarator.FirstAncestorOfType<FieldDeclarationSyntax>();
root = root.TrackNodes(returnIdentifier, fieldDeclaration, property);
document = document.WithSyntaxRoot(root);
root = await document.GetSyntaxRootAsync(cancellationToken);
semanticModel = await document.GetSemanticModelAsync(cancellationToken);
returnIdentifier = root.GetCurrentNode(returnIdentifier);
returnIdentifierSymbol = semanticModel.GetSymbolInfo(returnIdentifier).Symbol;
var newProperty = GetSimpleProperty(property, variableDeclarator)
.WithTriviaFrom(property)
.WithAdditionalAnnotations(Formatter.Annotation);
var newSolution = await Renamer.RenameSymbolAsync(document.Project.Solution, returnIdentifierSymbol, property.Identifier.ValueText, document.Project.Solution.Workspace.Options, cancellationToken);
document = newSolution.GetDocument(document.Id);
root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
root = root.InsertNodesAfter(root.GetCurrentNode(property), new[] { newProperty });
var multipleVariableDeclaration = fieldDeclaration.Declaration.Variables.Count > 1;
if (multipleVariableDeclaration)
{
var newfieldDeclaration = fieldDeclaration.WithDeclaration(fieldDeclaration.Declaration.RemoveNode(variableDeclarator, SyntaxRemoveOptions.KeepNoTrivia));
root = root.RemoveNode(root.GetCurrentNode<SyntaxNode>(property), SyntaxRemoveOptions.KeepNoTrivia);
root = root.ReplaceNode(root.GetCurrentNode(fieldDeclaration), newfieldDeclaration);
}
else
{
root = root.RemoveNodes(root.GetCurrentNodes<SyntaxNode>(new SyntaxNode[] { fieldDeclaration, property }), SyntaxRemoveOptions.KeepNoTrivia);
}
document = document.WithSyntaxRoot(root);
return document.Project.Solution;
}
示例4: OrdonnerAssignations
/// <summary>
/// Réordonne les assignations d'un constructeur.
/// </summary>
/// <param name="document">Le document.</param>
/// <param name="constructeur">Le constructeur.</param>
/// <param name="jetonAnnulation">Le jeton d'annulation.</param>
/// <returns>Le nouveau document.</returns>
private async Task<Document> OrdonnerAssignations(Document document, ConstructorDeclarationSyntax constructeur, CancellationToken jetonAnnulation)
{
// On récupère la racine et le modèle sémantique.
var racine = await document
.GetSyntaxRootAsync(jetonAnnulation)
.ConfigureAwait(false);
var modèleSémantique = await document.GetSemanticModelAsync(jetonAnnulation);
// On récupère le corps du constructeur.
var corps = constructeur.ChildNodes().First(nœud => nœud as BlockSyntax != null) as BlockSyntax;
// On récupère toutes les conditions sur les paramètres.
var conditions = Partagé.TrouveConditionsParametres(corps.Statements, constructeur.ParameterList, modèleSémantique);
// On récupère les assignations et on les ordonne.
var assignations = Partagé.TrouverAssignations(corps.Statements, modèleSémantique)
.OrderBy(e => e.ToString());
// On construit le nouveau corps du constructeur.
var corpsOrdonné = corps.WithStatements(
SyntaxFactory.List(
conditions
.Concat(assignations)
.Concat(corps.Statements
.Except(conditions)
.Except(assignations))));
// Et on met à jour la racine.
var nouvelleRacine = racine.ReplaceNode(corps, corpsOrdonné);
return document.WithSyntaxRoot(nouvelleRacine);
}
示例5: InsertStopwatchToMeasureTime
private async Task<Document> InsertStopwatchToMeasureTime(Document document, IdentifierNameSyntax node, CancellationToken cancellationToken) {
SemanticModel semanticModel = await document.GetSemanticModelAsync(cancellationToken);
var nodes = new List<Tuple<SyntaxNode, SyntaxNode>>();
SyntaxNode nodeLine = GetRootNodeOfLine(node);
SyntaxNode newNode = CommentLine(nodeLine);
newNode = newNode.WithTrailingTrivia(newNode.GetTrailingTrivia()
.AddRange(nodeLine.GetLeadingTrivia())
.Add(SyntaxFactory.SyntaxTrivia(SyntaxKind.SingleLineCommentTrivia, "timer.Stop();"))
.Add(SyntaxFactory.EndOfLine(Environment.NewLine))
.AddRange(nodeLine.GetLeadingTrivia())
.Add(SyntaxFactory.SyntaxTrivia(SyntaxKind.SingleLineCommentTrivia, "TimeSpan elapsed = timer.Elapsed;"))
.Add(SyntaxFactory.EndOfLine(Environment.NewLine)));
nodes.Add(new Tuple<SyntaxNode, SyntaxNode>(nodeLine, newNode));
var methodDeclaration = node.FirstAncestorOfType(typeof(MethodDeclarationSyntax)) as MethodDeclarationSyntax;
if (semanticModel == null) { return document; }
SyntaxNode firstGetTime = TimeMeasurementCodeAnalyzer.GetNodesUsedToGetCurrentTime(semanticModel, methodDeclaration).First();
nodeLine = GetRootNodeOfLine(firstGetTime);
newNode = CommentLine(nodeLine);
newNode = newNode.WithTrailingTrivia(newNode.GetTrailingTrivia()
.AddRange(nodeLine.GetLeadingTrivia())
.Add(SyntaxFactory.SyntaxTrivia(SyntaxKind.SingleLineCommentTrivia, "var timer = Stopwatch.StartNew();"))
.Add(SyntaxFactory.EndOfLine(Environment.NewLine)));
nodes.Add(new Tuple<SyntaxNode, SyntaxNode>(nodeLine, newNode));
document = await this.ReplaceNodesInDocumentAsync(document, cancellationToken, nodes.ToArray());
return await this.CheckNamespaceUsageAsync(document, cancellationToken, "System.Diagnostics");
}
开发者ID:vuder,项目名称:CodingStandardCodeAnalyzers,代码行数:31,代码来源:TimeMeasurementCodeAnalyzerCodeFixProvider.cs
示例6: CreateMixin
private async Task<Solution> CreateMixin(
IMixinCommand mixinCommand,
Document document,
ClassWithSourceCode childClass,
CancellationToken cancellationToken)
{
// get service provider and read settings from storage
var serviceProvider = Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider;
var settings = new Settings(serviceProvider);
var model = await document.GetSemanticModelAsync(cancellationToken);
if (mixinCommand.CanExecute(childClass,settings))
{
// execute the command => we get a new class declaration
var newClassDeclaration = mixinCommand.Execute(childClass.SourceCode, model,settings);
// replace the old class declaration in the syntax tree
var root = await model.SyntaxTree.GetRootAsync(cancellationToken);
var newRoot = root.ReplaceNode(childClass.SourceCode, newClassDeclaration);
// create a new document from the new syntax tree
var newDocument = document.WithSyntaxRoot(newRoot);
return newDocument.Project.Solution;
}
return null;
}
示例7: RepairXmlCommentAsync
private async Task<Document> RepairXmlCommentAsync(Document document, MethodDeclarationSyntax methodSyntax, CancellationToken cancellationToken)
{
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var methodSymbol = model.GetDeclaredSymbol(methodSyntax);
var xml = methodSymbol.GetDocumentationCommentXml();
var documentTrivia = methodSyntax.GetLeadingTrivia().Where(n => n.Kind() == SyntaxKind.SingleLineDocumentationCommentTrivia).Last();
var documentText = documentTrivia.ToFullString().TrimEnd();
var invalidXml = Regex.Replace(documentText, @"^\s*///", "", RegexOptions.Multiline);
var newXml = RpairXml(invalidXml);
var newDocumentCommentText = Regex.Replace(newXml, @"^", "///", RegexOptions.Multiline) + "\r\n";
var newDocumentTrivia = SyntaxFactory.ParseLeadingTrivia(newDocumentCommentText)[0];
var newRoot = root.ReplaceTrivia(documentTrivia, newDocumentTrivia.WithAdditionalAnnotations(Formatter.Annotation));
var newDocument = document.WithSyntaxRoot(newRoot);
return newDocument;
}
开发者ID:miya2000,项目名称:DocumentationCommentAnalyzer,代码行数:26,代码来源:DocumentationCommentAnalyzerCodeFixProvider.cs
示例8: RenameType
private async Task<Solution> RenameType(Document document, BaseTypeDeclarationSyntax typeDecl, CancellationToken cancellationToken)
{
try
{
var newName = GetDocumentName(document);
// Get the symbol representing the type to be renamed.
var semanticModel = await document.GetSemanticModelAsync(cancellationToken);
var typeSymbol = semanticModel.GetDeclaredSymbol(typeDecl, cancellationToken);
// Produce a new solution that has all references to that type renamed, including the declaration.
var originalSolution = document.Project.Solution;
var optionSet = originalSolution.Workspace.Options;
var newSolution = await Renamer.RenameSymbolAsync(document.Project.Solution, typeSymbol, newName, optionSet, cancellationToken).ConfigureAwait(false);
// Return the new solution with the now-uppercase type name.
return newSolution;
}
catch (Exception e)
{
LogException(e);
return document.Project.Solution;
}
}
示例9: CallAsExtensionAsync
private static async Task<Document> CallAsExtensionAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
{
var root = (CompilationUnitSyntax)await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var diagnosticSpan = diagnostic.Location.SourceSpan;
var staticInvocationExpression = root
.FindToken(diagnosticSpan.Start)
.Parent.AncestorsAndSelf()
.OfType<InvocationExpressionSyntax>()
.First();
var childNodes = staticInvocationExpression.ChildNodes();
var parameterExpressions = CallExtensionMethodAsExtensionAnalyzer.GetParameterExpressions(childNodes);
var firstArgument = parameterExpressions.FirstOrDefault();
var callerMethod = childNodes.OfType<MemberAccessExpressionSyntax>().FirstOrDefault();
root = ReplaceStaticCallWithExtionMethodCall(
root,
staticInvocationExpression,
firstArgument,
callerMethod.Name,
CallExtensionMethodAsExtensionAnalyzer.CreateArgumentListSyntaxFrom(parameterExpressions.Skip(1))
).WithAdditionalAnnotations(Formatter.Annotation);
var semanticModel = await document.GetSemanticModelAsync();
root = ImportNeededNamespace(root, semanticModel, callerMethod).WithAdditionalAnnotations(Formatter.Annotation);
var newDocument = document.WithSyntaxRoot(root);
return newDocument;
}
示例10: MakeUppercaseAsync
async Task<Document> MakeUppercaseAsync(Document document, InvocationExpressionSyntax invocation,
CancellationToken cancellationToken)
{
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var typeSymbol = semanticModel.GetSymbolInfo(invocation.Expression, cancellationToken).Symbol;
var nfluentCheck = semanticModel.Compilation.NFluentCheckType();
if (typeSymbol == null || nfluentCheck == null) return document;
var newMethod = typeSymbol.Name == "AreEqual" ? "IsEqualTo" : "IsNotEqualTo";
var checkThat = CheckThat(nfluentCheck, invocation.ArgumentList.Arguments[1]);
var replacement = InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
checkThat,
IdentifierName(newMethod)),
ArgumentList(SingletonSeparatedList(invocation.ArgumentList.Arguments[0])))
.WithTriviaFrom(invocation);
var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var newSyntaxRoot = syntaxRoot.ReplaceNode(invocation, replacement);
var newDocument = document.WithSyntaxRoot(newSyntaxRoot);
var withUsings = await UsingHelpers.AddUsingsAsync(newDocument, replacement, cancellationToken,
nfluentCheck.ContainingNamespace);
return withUsings;
}
示例11: CreateInterpolatedString
private async Task<Document> CreateInterpolatedString(InvocationExpressionSyntax invocation, Document document, CancellationToken cancellationToken)
{
Assert(invocation.ArgumentList != null);
Assert(invocation.ArgumentList.Arguments.Count >= 2);
Assert(invocation.ArgumentList.Arguments[0].Expression.IsKind(SyntaxKind.StringLiteralExpression));
var semanticModel = await document.GetSemanticModelAsync(cancellationToken);
var arguments = invocation.ArgumentList.Arguments;
var text = ((LiteralExpressionSyntax)arguments[0].Expression).Token.ToString();
var builder = ImmutableArray.CreateBuilder<ExpressionSyntax>();
for (int i = 1; i < arguments.Count; i++)
{
builder.Add(CastAndParenthesize(arguments[i].Expression, semanticModel));
}
var expandedArguments = builder.ToImmutable();
var interpolatedString = (InterpolatedStringExpressionSyntax)SyntaxFactory.ParseExpression("$" + text);
var newInterpolatedString = InterpolatedStringRewriter.Visit(interpolatedString, expandedArguments);
var root = await document.GetSyntaxRootAsync(cancellationToken);
var newRoot = root.ReplaceNode(invocation, newInterpolatedString);
return document.WithSyntaxRoot(newRoot);
}
示例12: RemoveUnnecessaryUsings
private static Document RemoveUnnecessaryUsings(Document doc, Compilation compilation)
{
#region CodeContracts
Contract.Requires(doc != null);
Contract.Requires(compilation != null);
Contract.Ensures(Contract.Result<Document>() != null);
#endregion CodeContracts
var st = doc.GetSyntaxTreeAsync().Result;
var sm = doc.GetSemanticModelAsync().Result;
//var assembly = Assembly.LoadFrom(@"C:\cci\Microsoft.Research\Imported\Tools\Roslyn\v4.5.1\Microsoft.CodeAnalysis.CSharp.Features.dll");
//var assembly = Assembly.LoadFrom(@"C:\cci\Microsoft.Research\CCTools\ReviewBot\bin\Debug\Microsoft.CodeAnalysis.CSharp.Features.dll");
//var assembly = Assembly.LoadFrom(@"..\..\..\packages\Microsoft.CodeAnalysis.Features.0.7.4040207-beta\lib\net45\Microsoft.CodeAnalysis.CSharp.Features.dll");
//var assembly = Assembly.LoadFrom(@"C:\Users\t-scottc\Desktop\Signed_20140201.1\Microsoft.CodeAnalysis.CSharp.Features.dll");
//var assembly = Assembly.LoadFrom(@"C:\Users\t-scottc\workspace\roslyn\Binaries\Debug\Microsoft.CodeAnalysis.CSharp.Workspaces.dll");
Assembly assembly;
if (TryGetMicrosoftCodeAnalysisCSharpFeatures(out assembly))
{
var type = assembly.GetType("Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports.CSharpRemoveUnnecessaryImportsService");
var method = type.GetMethod("RemoveUnnecessaryImports");
var service = Activator.CreateInstance(type);
return method.Invoke(service, new object[] { doc, sm, st.GetRoot(), CancellationToken.None }) as Document;
}
else
{
Output.WriteWarning("Can't run the refactoring to remove using");
return doc;
}
}
示例13: GetInfoAsync
internal static async Task<DebugLocationInfo> GetInfoAsync(Document document, int position, CancellationToken cancellationToken)
{
string name = null;
int lineOffset = 0;
// Note that we get the current partial solution here. Technically, this means that we may
// not fully understand the signature of the member. But that's ok. We just need this
// symbol so we can create a display string to put into the debugger. If we try to
// find the document in the "CurrentSolution" then when we try to get the semantic
// model below then it might take a *long* time as all dependent compilations are built.
var tree = await document.GetCSharpSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);
var token = root.FindToken(position);
SyntaxNode memberDecl = token.GetAncestor<MemberDeclarationSyntax>();
// field or event field declarations may contain multiple variable declarators. Try finding the correct one.
// If the position does not point to one, try using the first one.
if (memberDecl != null &&
(memberDecl.Kind() == SyntaxKind.FieldDeclaration || memberDecl.Kind() == SyntaxKind.EventFieldDeclaration))
{
SeparatedSyntaxList<VariableDeclaratorSyntax> variableDeclarators = ((BaseFieldDeclarationSyntax)memberDecl).Declaration.Variables;
foreach (var declarator in variableDeclarators)
{
if (declarator.FullSpan.Contains(token.FullSpan))
{
memberDecl = declarator;
break;
}
}
if (memberDecl == null)
{
memberDecl = variableDeclarators.Count > 0 ? variableDeclarators[0] : null;
}
}
if (memberDecl != null)
{
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var memberSymbol = semanticModel.GetDeclaredSymbol(memberDecl, cancellationToken);
if (memberSymbol != null)
{
var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
var lineNumber = text.Lines.GetLineFromPosition(position).LineNumber;
var accessor = token.GetAncestor<AccessorDeclarationSyntax>();
var memberLine = accessor == null
? text.Lines.GetLineFromPosition(memberDecl.SpanStart).LineNumber
: text.Lines.GetLineFromPosition(accessor.SpanStart).LineNumber;
name = memberSymbol.ToDisplayString(s_nameFormat);
lineOffset = lineNumber - memberLine;
return new DebugLocationInfo(name, lineOffset);
}
}
return default(DebugLocationInfo);
}
示例14: VisitDocument
protected override void VisitDocument(Document document, SyntaxNode root)
{
CSharpSyntaxWalker walker;
SemanticModel semanticModel = (SemanticModel)document.GetSemanticModelAsync().Result;
if (bool.Parse(ConfigurationManager.AppSettings["IsCPUAsyncDetectionEnabled"]))
{
walker = new CPUAsyncDetectionWalker { Result = Result, SemanticModel = semanticModel, Document = document };
walker.Visit(root);
}
if (bool.Parse(ConfigurationManager.AppSettings["IsAsyncAwaitDetectionEnabled"]))
{
walker = new AsyncAwaitConsultingDetectionWalker { Result = Result, SemanticModel = semanticModel, Document = document };
walker.Visit(root);
}
if (bool.Parse(ConfigurationManager.AppSettings["IsComplexPatternDetectionEnabled"]))
{
walker = new ComplexPatternDetectionWalker { Result = Result, SemanticModel = semanticModel, Document = document };
walker.Visit(root);
}
if (bool.Parse(ConfigurationManager.AppSettings["IsAsyncLibraryDetectionWalkerEnabled"]))
{
walker = new AsyncLibraryDetectionWalker { Result = Result, SemanticModel = semanticModel, Document = document };
walker.Visit(root);
}
}
示例15: ChangePropertySetAsync
private async static Task<Document> ChangePropertySetAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken, FixType fixType)
{
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var diagnosticSpan = diagnostic.Location.SourceSpan;
var propertyStatement = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType<PropertyDeclarationSyntax>().First();
var semanticModel = await document.GetSemanticModelAsync(cancellationToken);
var getAcessor = (propertyStatement.AccessorList.Accessors[0].Keyword.Text == "get") ? propertyStatement.AccessorList.Accessors[0] : propertyStatement.AccessorList.Accessors[1];
var setAcessor = (propertyStatement.AccessorList.Accessors[0].Keyword.Text == "set") ? propertyStatement.AccessorList.Accessors[0] : propertyStatement.AccessorList.Accessors[1];
var privateprotectedModifier = SyntaxFactory.Token(fixType == FixType.PrivateFix ? SyntaxKind.PrivateKeyword : SyntaxKind.ProtectedKeyword)
.WithAdditionalAnnotations(Formatter.Annotation);
var modifiers = setAcessor.Modifiers.Add(privateprotectedModifier);
setAcessor = setAcessor.WithModifiers(modifiers);
var newProperty = SyntaxFactory.PropertyDeclaration(propertyStatement.Type, propertyStatement.Identifier)
.WithModifiers(propertyStatement.Modifiers)
.WithAccessorList(SyntaxFactory.AccessorList(SyntaxFactory.List<AccessorDeclarationSyntax>(new AccessorDeclarationSyntax[] { getAcessor, setAcessor })))
.WithLeadingTrivia(propertyStatement.GetLeadingTrivia()).WithTrailingTrivia(propertyStatement.GetTrailingTrivia())
.WithAdditionalAnnotations(Formatter.Annotation);
var newRoot = root.ReplaceNode(propertyStatement, newProperty);
var newDocument = document.WithSyntaxRoot(newRoot);
return newDocument;
}