提交 3d47c50d 编写于 作者: J jasonmalinowski

Pass CancellationTokens when we have one. (changeset 1407253)

上级 ebc795d4
......@@ -15,7 +15,7 @@ internal class CSharpDeclarationComputer : DeclarationComputer
public static ImmutableArray<DeclarationInfo> GetDeclarationsInSpan(SemanticModel model, TextSpan span, bool getSymbol, CancellationToken cancellationToken)
{
var builder = ArrayBuilder<DeclarationInfo>.GetInstance();
ComputeDeclarations(model, model.SyntaxTree.GetRoot(),
ComputeDeclarations(model, model.SyntaxTree.GetRoot(cancellationToken),
(node, level) => !node.Span.OverlapsWith(span) || InvalidLevel(level),
getSymbol, builder, null, cancellationToken);
return builder.ToImmutable();
......
......@@ -1896,7 +1896,7 @@ public override IParameterSymbol GetDeclaredSymbol(ParameterSyntax declarationSy
if (memberModel != null)
{
// Could be parameter of lambda.
return memberModel.GetDeclaredSymbol(declarationSyntax);
return memberModel.GetDeclaredSymbol(declarationSyntax, cancellationToken);
}
return GetDeclaredNonLambdaParameterSymbol(declarationSyntax, cancellationToken);
......
......@@ -27,7 +27,7 @@ public static void ReportUnprocessed(SyntaxTree tree, TextSpan? filterSpanWithin
if (tree.ReportDocumentationCommentDiagnostics())
{
UnprocessedDocumentationCommentFinder finder = new UnprocessedDocumentationCommentFinder(diagnostics, filterSpanWithinTree, cancellationToken);
finder.Visit(tree.GetRoot());
finder.Visit(tree.GetRoot(cancellationToken));
}
}
......
......@@ -20,7 +20,7 @@ public NamespaceDeclarationSyntaxReference(SyntaxReference reference)
protected override SyntaxNode Translate(SyntaxReference reference, CancellationToken cancellationToken)
{
var node = (CSharpSyntaxNode)reference.GetSyntax();
var node = (CSharpSyntaxNode)reference.GetSyntax(cancellationToken);
// If the node is a name syntax, it's something like "X" or "X.Y" in :
// namespace X.Y.Z
......
......@@ -344,10 +344,10 @@ public override SyntaxNode GetSyntax(CancellationToken cancellationToken)
// Note: It's important for us to maintain identity of nodes/trees, so we find
// the equivalent node in our CountedSyntaxTree.
countedSyntaxTree.AccessCount++;
var nodeInUnderlying = underlyingSyntaxReference.GetSyntax();
var nodeInUnderlying = underlyingSyntaxReference.GetSyntax(cancellationToken);
var token = countedSyntaxTree.GetCompilationUnitRoot().FindToken(nodeInUnderlying.SpanStart);
var token = countedSyntaxTree.GetCompilationUnitRoot(cancellationToken).FindToken(nodeInUnderlying.SpanStart);
for (var node = token.Parent; node != null; node = node.Parent)
{
if (node.Span == nodeInUnderlying.Span && node.RawKind == nodeInUnderlying.RawKind)
......
......@@ -47,7 +47,7 @@ internal override Task<Document> GetUpdatedDocumentAsync(Document document, Sema
var invokeParent = identifier.GetAncestor<InvocationExpressionSyntax>();
if (invokeParent != null)
{
var methodSymbol = model.GetSymbolInfo(identifier).Symbol as IMethodSymbol;
var methodSymbol = model.GetSymbolInfo(identifier, cancellationToken).Symbol as IMethodSymbol;
if (methodSymbol != null && CanAddStringComparison(methodSymbol))
{
// append a new StringComparison.Ordinal argument
......
......@@ -39,7 +39,7 @@ internal override Task<Document> GetUpdatedDocumentAsync(Document document, Sema
{
// could be either a [DllImport] or [MarshalAs] attribute
var attribute = (AttributeSyntax)nodeToFix;
var attributeType = model.GetSymbolInfo(attribute).Symbol;
var attributeType = model.GetSymbolInfo(attribute, cancellationToken).Symbol;
var arguments = attribute.ArgumentList.Arguments;
if (dllImportType.Equals(attributeType.ContainingType))
{
......
......@@ -46,7 +46,7 @@ internal override Task<Document> GetUpdatedDocumentAsync(Document document, Sema
}
var factory = document.GetLanguageService<SyntaxGenerator>();
var symbol = model.GetDeclaredSymbol(syntaxNode);
var symbol = model.GetDeclaredSymbol(syntaxNode, cancellationToken);
// handle a case where a local in the Dipose method with the same name by generating this (or ClassName) and simplifying it
var path = symbol.IsStatic
......
......@@ -60,7 +60,7 @@ private SyntaxNode GetExplicitlyAssignedField(IFieldSymbol originalField, Syntax
private async Task<Document> GetUpdatedDocumentForRuleNameRenameAsync(Document document, IFieldSymbol field, CancellationToken cancellationToken)
{
var newSolution = await Rename.Renamer.RenameSymbolAsync(document.Project.Solution, field, "None", null).ConfigureAwait(false);
var newSolution = await Rename.Renamer.RenameSymbolAsync(document.Project.Solution, field, "None", null, cancellationToken).ConfigureAwait(false);
return newSolution.GetDocument(document.Id);
}
......@@ -93,7 +93,7 @@ private async Task ApplyRuleNameMultipleZeroAsync(SymbolEditor editor, INamedTyp
}
else
{
await editor.EditOneDeclarationAsync(field, (e, d) => e.RemoveNode(d)); // removes the field declaration
await editor.EditOneDeclarationAsync(field, (e, d) => e.RemoveNode(d), cancellationToken); // removes the field declaration
makeNextFieldExplicit = true;
}
}
......@@ -111,7 +111,7 @@ private async Task ApplyRuleNameNoZeroValueAsync(SymbolEditor editor, INamedType
{
if (CA1008DiagnosticAnalyzer.IsMemberNamedNone(field))
{
await editor.EditOneDeclarationAsync(field, (e, d) => e.RemoveNode(d));
await editor.EditOneDeclarationAsync(field, (e, d) => e.RemoveNode(d), cancellationToken);
}
}
......
......@@ -37,7 +37,7 @@ private static SyntaxNode GetDeclaration(ISymbol symbol)
internal override Task<Document> GetUpdatedDocumentAsync(Document document, SemanticModel model, SyntaxNode root, SyntaxNode nodeToFix, Diagnostic diagnostic, CancellationToken cancellationToken)
{
var classSymbol = (INamedTypeSymbol)model.GetDeclaredSymbol(nodeToFix);
var classSymbol = (INamedTypeSymbol)model.GetDeclaredSymbol(nodeToFix, cancellationToken);
var instanceConstructors = classSymbol.InstanceConstructors.Where(t => t.DeclaredAccessibility == Accessibility.Public).Select(t => GetDeclaration(t)).Where(d => d != null).ToList();
var generator = SyntaxGenerator.GetGenerator(document);
var newRoot = root.ReplaceNodes(instanceConstructors, (original, rewritten) => generator.WithAccessibility(original, Accessibility.Protected));
......
......@@ -61,11 +61,11 @@ private static SyntaxNode AddFlagsAttribute(Workspace workspace, SyntaxNode enum
private static SyntaxNode RemoveFlagsAttribute(Workspace workspace, SemanticModel model, SyntaxNode enumTypeSyntax, INamedTypeSymbol flagsAttributeType, CancellationToken cancellationToken)
{
var enumType = model.GetDeclaredSymbol(enumTypeSyntax) as INamedTypeSymbol;
var enumType = model.GetDeclaredSymbol(enumTypeSyntax, cancellationToken) as INamedTypeSymbol;
Contract.ThrowIfNull(enumType);
var flagsAttribute = enumType.GetAttributes().First(a => a.AttributeClass == flagsAttributeType);
var attributeNode = flagsAttribute.ApplicationSyntaxReference.GetSyntax();
var attributeNode = flagsAttribute.ApplicationSyntaxReference.GetSyntax(cancellationToken);
var generator = SyntaxGenerator.GetGenerator(workspace, enumTypeSyntax.Language);
return generator.RemoveNode(enumTypeSyntax, attributeNode);
......
......@@ -94,7 +94,7 @@ protected override void AnalyzeSymbol(INamedTypeSymbol symbol, Compilation compi
Contract.ThrowIfNull(missingValues);
var missingValuesString = missingValues.Select(v => v.ToString()).Aggregate((i, j) => i + ", " + j);
var location = GetDiagnosticLocation(symbol.DeclaringSyntaxReferences[0].GetSyntax());
var location = GetDiagnosticLocation(symbol.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken));
addDiagnostic(location.CreateDiagnostic(Rule2217, symbol.Name, missingValuesString));
}
}
......@@ -104,7 +104,7 @@ protected override void AnalyzeSymbol(INamedTypeSymbol symbol, Compilation compi
// Ignore continguous value enums to reduce noise.
if (!IsContiguous(memberValues) && ShouldBeFlags(memberValues))
{
var location = GetDiagnosticLocation(symbol.DeclaringSyntaxReferences[0].GetSyntax());
var location = GetDiagnosticLocation(symbol.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken));
addDiagnostic(location.CreateDiagnostic(Rule1027, symbol.Name));
}
}
......
......@@ -31,7 +31,7 @@ protected sealed override string GetCodeFixDescription(Diagnostic diagnostic)
internal async override Task<Document> GetUpdatedDocumentAsync(Document document, SemanticModel model, SyntaxNode root, SyntaxNode nodeToFix, Diagnostic diagnostic, CancellationToken cancellationToken)
{
var symbol = model.GetDeclaredSymbol(nodeToFix);
var symbol = model.GetDeclaredSymbol(nodeToFix, cancellationToken);
var generator = SyntaxGenerator.GetGenerator(document);
// There was no constructor and so the diagnostic was on the type. Generate a serlialization ctor.
......
......@@ -37,11 +37,11 @@ internal async override Task<IEnumerable<CodeAction>> GetFixesAsync(Document doc
actions = SpecializedCollections.SingletonEnumerable(codeAction);
// Fix 2: If the type of the field is defined in source, then add the serializable attribute to the type.
var fieldSymbol = model.GetDeclaredSymbol(nodeToFix) as IFieldSymbol;
var fieldSymbol = model.GetDeclaredSymbol(nodeToFix, cancellationToken) as IFieldSymbol;
var type = fieldSymbol.Type;
if (type.Locations.Any(l => l.IsInSource))
{
var typeDeclNode = type.DeclaringSyntaxReferences.First().GetSyntax();
var typeDeclNode = type.DeclaringSyntaxReferences.First().GetSyntax(cancellationToken);
var serializableAttr = generator.Attribute(generator.TypeExpression(WellKnownTypes.SerializableAttribute(model.Compilation)));
var newTypeDeclNode = generator.AddAttributes(typeDeclNode, serializableAttr);
......
......@@ -67,7 +67,7 @@ public override string Title
protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
{
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var methodSymbol = semanticModel.GetDeclaredSymbol(declaration);
var methodSymbol = semanticModel.GetDeclaredSymbol(declaration, cancellationToken);
var compilation = await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
var cancellationTokenType = compilation.GetTypeByMetadataName("System.Threading.CancellationToken");
......@@ -75,7 +75,7 @@ protected override async Task<Document> GetChangedDocumentAsync(CancellationToke
var nonCancellationTokenParameters = new List<ParameterSyntax>();
foreach (var param in declaration.ParameterList.Parameters)
{
var paramSymbol = semanticModel.GetDeclaredSymbol(param);
var paramSymbol = semanticModel.GetDeclaredSymbol(param, cancellationToken);
if (paramSymbol.Type.Equals(cancellationTokenType))
{
cancellationTokenParameters.Add(param);
......
......@@ -67,7 +67,7 @@ public override void AfterReturn(IBraceCompletionSession session, CancellationTo
// first add one line in between, and format braces
if (session.SubjectBuffer.GetOption(FeatureOnOffOptions.AutoFormattingOnCloseBrace))
{
document.InsertText(session.ClosingPoint.GetPosition(session.SubjectBuffer.CurrentSnapshot) - 1, Environment.NewLine);
document.InsertText(session.ClosingPoint.GetPosition(session.SubjectBuffer.CurrentSnapshot) - 1, Environment.NewLine, cancellationToken);
FormatTrackingSpan(session, GetFormattingRules(document));
}
......
......@@ -58,7 +58,7 @@ private bool PossibleTypeArgument(ITextSnapshot snapshot, SyntaxToken token, Can
}
var model = document.GetSemanticModelAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var info = model.GetSymbolInfo(node.Left);
var info = model.GetSymbolInfo(node.Left, cancellationToken);
return info.CandidateSymbols.Any(IsGenericTypeOrMethod);
}
......
......@@ -81,7 +81,7 @@ protected override async Task<IEnumerable<CompletionItem>> GetItemsWorkerAsync(D
var typeDeclaration = attachedToken.GetAncestor<TypeDeclarationSyntax>();
if (typeDeclaration != null)
{
declaredSymbol = semanticModel.GetDeclaredSymbol(typeDeclaration);
declaredSymbol = semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken);
}
}
......
......@@ -307,7 +307,7 @@ private static void AddEnumMemberSpan(ISymbol symbol, SyntaxTree tree, List<Text
protected internal override VirtualTreePoint? GetSymbolItemNavigationPoint(Document document, NavigationBarSymbolItem item, CancellationToken cancellationToken)
{
var compilation = document.Project.GetCompilationAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var symbols = item.NavigationSymbolId.Resolve(compilation);
var symbols = item.NavigationSymbolId.Resolve(compilation, cancellationToken: cancellationToken);
var symbol = symbols.Symbol;
......
......@@ -160,7 +160,7 @@ private bool TryGetComIndexers(SemanticModel semanticModel, ExpressionSyntax exp
if (indexers.Any() && expression is MemberAccessExpressionSyntax)
{
expressionType = semanticModel.GetTypeInfo(((MemberAccessExpressionSyntax)expression).Expression).Type;
expressionType = semanticModel.GetTypeInfo(((MemberAccessExpressionSyntax)expression).Expression, cancellationToken).Type;
return true;
}
......
......@@ -71,7 +71,7 @@ protected override Task<Solution> GetChangedSolutionAsync(CancellationToken canc
solution = solution.AddProject(ProjectInfo.Create(s_addedProjectId, VersionStamp.Create(), AddedProjectName, AddedProjectName, LanguageNames.CSharp));
// Change a document - This will result in IWpfTextView previews.
solution = solution.WithDocumentSyntaxRoot(_oldDocument.Id, CSharpSyntaxTree.ParseText(ChangedDocumentText).GetRoot());
solution = solution.WithDocumentSyntaxRoot(_oldDocument.Id, CSharpSyntaxTree.ParseText(ChangedDocumentText, cancellationToken: cancellationToken).GetRoot(cancellationToken));
return Task.FromResult(solution);
}
......
......@@ -28,7 +28,7 @@ public void NavigateToSymbolItem(Document document, NavigationBarSymbolItem item
{
var symbolNavigationService = document.Project.Solution.Workspace.Services.GetService<ISymbolNavigationService>();
var symbolInfo = item.NavigationSymbolId.Resolve(document.Project.GetCompilationAsync(cancellationToken).WaitAndGetResult(cancellationToken), ignoreAssemblyKey: true);
var symbolInfo = item.NavigationSymbolId.Resolve(document.Project.GetCompilationAsync(cancellationToken).WaitAndGetResult(cancellationToken), ignoreAssemblyKey: true, cancellationToken: cancellationToken);
var symbol = symbolInfo.GetAnySymbol();
// Do not allow third party navigation to types or constructors
......
......@@ -131,7 +131,7 @@ public async Task<IEnumerable<AbstractCallFinder>> CreateFinders(ISymbol symbol,
public void NavigateTo(SymbolKey id, Project project, CancellationToken cancellationToken)
{
var compilation = project.GetCompilationAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var resolution = id.Resolve(compilation);
var resolution = id.Resolve(compilation, cancellationToken: cancellationToken);
project.Solution.Workspace.Services.GetService<ISymbolNavigationService>().TryNavigateToSymbol(resolution.Symbol, project, usePreviewTab: true);
}
}
......
......@@ -73,7 +73,7 @@ private async Task SearchAsync(ICallHierarchySearchCallback callback, CallHierar
var workspace = _project.Solution.Workspace;
var currentProject = workspace.CurrentSolution.GetProject(_project.Id);
var compilation = await currentProject.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
var resolution = _symbol.Resolve(compilation);
var resolution = _symbol.Resolve(compilation, cancellationToken: cancellationToken);
var documents = this.Documents ?? IncludeDocuments(scope, currentProject);
......
......@@ -143,7 +143,7 @@ private Document DetermineNewDocument(MemberInsertionCompletionItem completionIt
// Resolve member and type in our new, forked, solution
var semanticModel = document.GetSemanticModelAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var containingType = semanticModel.GetEnclosingSymbol<INamedTypeSymbol>(line.Start, cancellationToken);
var resolution = completionItem.SymbolId.Resolve(semanticModel.Compilation);
var resolution = completionItem.SymbolId.Resolve(semanticModel.Compilation, cancellationToken: cancellationToken);
var overriddenMember = GetResolvedSymbol(resolution, line.Extent.Span.ToTextSpan());
// CodeGenerationOptions containing before and after
......@@ -155,15 +155,15 @@ private Document DetermineNewDocument(MemberInsertionCompletionItem completionIt
Document memberContainingDocument = null;
if (generatedMember.Kind == SymbolKind.Method)
{
memberContainingDocument = codeGenService.AddMethodAsync(document.Project.Solution, containingType, (IMethodSymbol)generatedMember, options).WaitAndGetResult(cancellationToken);
memberContainingDocument = codeGenService.AddMethodAsync(document.Project.Solution, containingType, (IMethodSymbol)generatedMember, options, cancellationToken).WaitAndGetResult(cancellationToken);
}
else if (generatedMember.Kind == SymbolKind.Property)
{
memberContainingDocument = codeGenService.AddPropertyAsync(document.Project.Solution, containingType, (IPropertySymbol)generatedMember, options).WaitAndGetResult(cancellationToken);
memberContainingDocument = codeGenService.AddPropertyAsync(document.Project.Solution, containingType, (IPropertySymbol)generatedMember, options, cancellationToken).WaitAndGetResult(cancellationToken);
}
else if (generatedMember.Kind == SymbolKind.Event)
{
memberContainingDocument = codeGenService.AddEventAsync(document.Project.Solution, containingType, (IEventSymbol)generatedMember, options).WaitAndGetResult(cancellationToken);
memberContainingDocument = codeGenService.AddEventAsync(document.Project.Solution, containingType, (IEventSymbol)generatedMember, options, cancellationToken).WaitAndGetResult(cancellationToken);
}
return memberContainingDocument;
......
......@@ -282,7 +282,7 @@ internal async Task<SymbolMappingResult> MapSymbolAsync(Document document, Symbo
}
var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
var resolutionResult = symbolId.Resolve(compilation, ignoreAssemblyKey: true);
var resolutionResult = symbolId.Resolve(compilation, ignoreAssemblyKey: true, cancellationToken: cancellationToken);
if (resolutionResult.Symbol == null)
{
return null;
......
......@@ -52,7 +52,7 @@ protected override Task<IEnumerable<CodeActionOperation>> ComputeOperationsAsync
if (textBuffer.Properties.TryGetProperty(typeof(StateMachine), out stateMachine))
{
TrackingSession trackingSession;
if (stateMachine.CanInvokeRename(out trackingSession))
if (stateMachine.CanInvokeRename(out trackingSession, cancellationToken: cancellationToken))
{
var snapshotSpan = stateMachine.TrackingSession.TrackingSpan.GetSpan(stateMachine.Buffer.CurrentSnapshot);
var str = string.Format(EditorFeaturesResources.RenameTo, stateMachine.TrackingSession.OriginalName, snapshotSpan.GetText());
......
......@@ -21,7 +21,7 @@ private sealed class SymbolMappingService : ISymbolMappingService
public async Task<SymbolMappingResult> MapSymbolAsync(Document document, SymbolKey symbolId, CancellationToken cancellationToken)
{
var compilation = await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
var symbol = symbolId.Resolve(compilation).Symbol;
var symbol = symbolId.Resolve(compilation, cancellationToken: cancellationToken).Symbol;
if (symbol != null)
{
return new SymbolMappingResult(document.Project, symbol);
......
......@@ -26,7 +26,7 @@ internal sealed class CSharpChangeSignatureService : AbstractChangeSignatureServ
public override ISymbol GetInvocationSymbol(Document document, int position, bool restrictToDeclarations, CancellationToken cancellationToken)
{
var tree = document.GetSyntaxTreeAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var token = tree.GetRoot().FindToken(position != tree.Length ? position : Math.Max(0, position - 1));
var token = tree.GetRoot(cancellationToken).FindToken(position != tree.Length ? position : Math.Max(0, position - 1));
var ancestorDeclarationKinds = restrictToDeclarations ? invokableAncestorKinds.Add(SyntaxKind.Block) : invokableAncestorKinds;
SyntaxNode matchingNode = token.Parent.AncestorsAndSelf().FirstOrDefault(n => ancestorDeclarationKinds.Contains(n.Kind()));
......@@ -49,7 +49,7 @@ public override ISymbol GetInvocationSymbol(Document document, int position, boo
if (token.Parent.AncestorsAndSelf().Any(a => a == objectCreation.Type))
{
var typeSymbol = semanticModel.GetSymbolInfo(objectCreation.Type).Symbol;
var typeSymbol = semanticModel.GetSymbolInfo(objectCreation.Type, cancellationToken).Symbol;
if (typeSymbol != null && typeSymbol.IsKind(SymbolKind.NamedType) && (typeSymbol as ITypeSymbol).TypeKind == TypeKind.Delegate)
{
return typeSymbol;
......@@ -264,7 +264,7 @@ private SyntaxNode GetNodeContainingTargetNode(SyntaxNode matchingNode)
var invocation = updatedNode as InvocationExpressionSyntax;
var semanticModel = document.GetSemanticModelAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var symbolInfo = semanticModel.GetSymbolInfo(originalNode as InvocationExpressionSyntax);
var symbolInfo = semanticModel.GetSymbolInfo(originalNode as InvocationExpressionSyntax, cancellationToken);
var methodSymbol = symbolInfo.Symbol as IMethodSymbol;
var isReducedExtensionMethod = false;
......@@ -516,12 +516,12 @@ public override async Task<IEnumerable<ISymbol>> DetermineCascadedSymbolsFromDel
n =>
{
if (!n.IsKind(SyntaxKind.IdentifierName) ||
!semanticModel.GetMemberGroup(n).Any())
!semanticModel.GetMemberGroup(n, cancellationToken).Any())
{
return false;
}
ISymbol convertedType = semanticModel.GetTypeInfo(n).ConvertedType;
ISymbol convertedType = semanticModel.GetTypeInfo(n, cancellationToken).ConvertedType;
if (convertedType != null)
{
......@@ -530,12 +530,12 @@ public override async Task<IEnumerable<ISymbol>> DetermineCascadedSymbolsFromDel
if (convertedType != null)
{
convertedType = SymbolFinder.FindSourceDefinitionAsync(convertedType, document.Project.Solution).WaitAndGetResult(cancellationToken) ?? convertedType;
convertedType = SymbolFinder.FindSourceDefinitionAsync(convertedType, document.Project.Solution, cancellationToken).WaitAndGetResult(cancellationToken) ?? convertedType;
}
return convertedType == symbol.ContainingType;
})
.Select(n => semanticModel.GetSymbolInfo(n).Symbol);
.Select(n => semanticModel.GetSymbolInfo(n, cancellationToken).Symbol);
return convertedMethodGroups;
}
......
......@@ -59,7 +59,7 @@ public override ImmutableArray<string> FixableDiagnosticIds
CancellationToken cancellationToken)
{
var invocationExpression = node.ChildNodes().FirstOrDefault(n => n.IsKind(SyntaxKind.InvocationExpression));
var methodSymbol = semanticModel.GetSymbolInfo(invocationExpression).Symbol as IMethodSymbol;
var methodSymbol = semanticModel.GetSymbolInfo(invocationExpression, cancellationToken).Symbol as IMethodSymbol;
if (methodSymbol == null)
{
return null;
......
......@@ -28,7 +28,7 @@ private class ReferenceRewriter : CSharpSyntaxRewriter
CancellationToken cancellationToken)
{
this.semanticModel = semanticModel;
this.localSymbol = (ILocalSymbol)semanticModel.GetDeclaredSymbol(variableDeclarator);
this.localSymbol = (ILocalSymbol)semanticModel.GetDeclaredSymbol(variableDeclarator, cancellationToken);
this.variableDeclarator = variableDeclarator;
this.expressionToInline = expressionToInline;
this.cancellationToken = cancellationToken;
......
......@@ -199,7 +199,7 @@ private async Task<Document> InlineTemporaryAsync(Document document, VariableDec
.Select(ident => GetTopMostParentingExpression(ident))
.Distinct();
var originalInitializerSymbolInfo = semanticModel.GetSymbolInfo(variableDeclarator.Initializer.Value);
var originalInitializerSymbolInfo = semanticModel.GetSymbolInfo(variableDeclarator.Initializer.Value, cancellationToken);
// Make each topmost parenting statement or Equals Clause Expressions semantically explicit.
updatedDocument = await updatedDocument.ReplaceNodesAsync(topmostParentingExpressions, (o, n) => Simplifier.Expand(n, semanticModel, workspace, cancellationToken: cancellationToken), cancellationToken).ConfigureAwait(false);
......
......@@ -143,7 +143,7 @@ private bool IsComparisonOfZeroAndSomethingNeverLessThanZero(BinaryExpressionSyn
SemanticModel semanticModel,
CancellationToken cancellationToken)
{
var numericValue = semanticModel.GetConstantValue(numericLiteralExpression);
var numericValue = semanticModel.GetConstantValue(numericLiteralExpression, cancellationToken);
if (numericValue.HasValue && numericValue.Value is int && (int)numericValue.Value == 0)
{
var symbol = semanticModel.GetSymbolInfo(variableExpression, cancellationToken).Symbol;
......
......@@ -60,7 +60,7 @@ private class State
this.VariableDeclaration = this.DeclarationStatement.Declaration;
this.VariableDeclarator = this.VariableDeclaration.Variables[0];
this.OutermostBlock = (BlockSyntax)this.DeclarationStatement.Parent;
this.LocalSymbol = (ILocalSymbol)document.SemanticModel.GetDeclaredSymbol(this.VariableDeclarator);
this.LocalSymbol = (ILocalSymbol)document.SemanticModel.GetDeclaredSymbol(this.VariableDeclarator, cancellationToken);
if (this.LocalSymbol == null)
{
// This can happen in broken code, for example: "{ object x; object }"
......
......@@ -174,7 +174,7 @@ private StatementSyntax CreateMergedDeclarationStatement(State state, StatementS
{
// Type inference. Only merge if types match.
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var rightType = semanticModel.GetTypeInfo(expression.Right);
var rightType = semanticModel.GetTypeInfo(expression.Right, cancellationToken);
return (localSymbol.Type == null && rightType.Type == null) || localSymbol.Type.Equals(rightType.Type);
}
else
......
......@@ -95,8 +95,8 @@ protected override async Task<IEnumerable<CompletionItem>> GetItemsWorkerAsync(D
{
// cref "a.|"
var parent = token.Parent as QualifiedCrefSyntax;
var leftType = semanticModel.GetTypeInfo(parent.Container).Type;
var leftSymbol = semanticModel.GetSymbolInfo(parent.Container).Symbol;
var leftType = semanticModel.GetTypeInfo(parent.Container, cancellationToken).Type;
var leftSymbol = semanticModel.GetSymbolInfo(parent.Container, cancellationToken).Symbol;
var container = leftSymbol ?? leftType;
......
......@@ -73,7 +73,7 @@ protected override SyntaxNode GetObjectCreationNewExpression(SyntaxTree tree, in
protected override async Task<AbstractSyntaxContext> CreateContext(Document document, int position, CancellationToken cancellationToken)
{
var semanticModel = await document.GetCSharpSemanticModelForSpanAsync(new TextSpan(position, 0)).ConfigureAwait(false);
var semanticModel = await document.GetCSharpSemanticModelForSpanAsync(new TextSpan(position, 0), cancellationToken).ConfigureAwait(false);
return CSharpSyntaxContext.CreateContext(document.Project.Solution.Workspace, semanticModel, position, cancellationToken);
}
......
......@@ -29,7 +29,8 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
context.IsTypeDeclarationContext(
validModifiers: ValidModifiers,
validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
canBePartial: false);
canBePartial: false,
cancellationToken: cancellationToken);
}
}
}
......@@ -78,7 +78,7 @@ protected async override Task<SyntaxNode> RewriteFieldNameAndAccessibility(strin
declarator = root.GetAnnotatedNodes<VariableDeclaratorSyntax>(tempAnnotation).First();
declaration = declarator.Parent as VariableDeclarationSyntax;
var field = semanticModel.GetDeclaredSymbol(declarator) as IFieldSymbol;
var field = semanticModel.GetDeclaredSymbol(declarator, cancellationToken) as IFieldSymbol;
var fieldToAdd = declarationAnnotation.AddAnnotationToSymbol(CodeGenerationSymbolFactory.CreateFieldSymbol(
field.GetAttributes(),
......@@ -125,7 +125,7 @@ protected override async Task<IEnumerable<IFieldSymbol>> GetFieldsAsync(Document
declarators = declarations.SelectMany(d => d.Variables.Where(v => v.Span.IntersectsWith(span)));
}
return declarators.Select(d => semanticModel.GetDeclaredSymbol(d) as IFieldSymbol)
return declarators.Select(d => semanticModel.GetDeclaredSymbol(d, cancellationToken) as IFieldSymbol)
.WhereNotNull()
.Where(f => f.Name.Length != 0);
}
......
......@@ -230,7 +230,7 @@ protected override bool TryGetNameParts(ExpressionSyntax expression, out IList<s
return false;
}
var leftSymbol = semanticModel.GetSymbolInfo(((MemberAccessExpressionSyntax)nameOrMemberAccessExpression).Expression).Symbol;
var leftSymbol = semanticModel.GetSymbolInfo(((MemberAccessExpressionSyntax)nameOrMemberAccessExpression).Expression, cancellationToken).Symbol;
var token = simpleName.GetLastToken().GetNextToken();
// We let only the Namespace to be left of the Dot
......@@ -279,7 +279,7 @@ protected override bool TryGetNameParts(ExpressionSyntax expression, out IList<s
var parent = simpleName.Parent as QualifiedNameSyntax;
if (parent != null)
{
var leftSymbol = semanticModel.GetSymbolInfo(parent.Left).Symbol;
var leftSymbol = semanticModel.GetSymbolInfo(parent.Left, cancellationToken).Symbol;
if (leftSymbol != null && leftSymbol.IsKind(SymbolKind.Namespace))
{
......@@ -587,7 +587,7 @@ protected override bool IsConversionImplicit(Compilation compilation, ITypeSymbo
var enclosingNamespace = GetDeclaringNamespace(containerList, 0, compilationUnit);
if (enclosingNamespace != null)
{
var enclosingNamespaceSymbol = semanticModel.GetSymbolInfo(enclosingNamespace.Name);
var enclosingNamespaceSymbol = semanticModel.GetSymbolInfo(enclosingNamespace.Name, cancellationToken);
if (enclosingNamespaceSymbol.Symbol != null)
{
return Tuple.Create((INamespaceSymbol)enclosingNamespaceSymbol.Symbol,
......
......@@ -48,7 +48,7 @@ internal partial class CSharpIntroduceVariableService
SyntaxFactory.EqualsValueClause(expression.WithoutTrailingTrivia().WithoutLeadingTrivia())))));
var anonymousMethodParameters = GetAnonymousMethodParameters(document, expression, cancellationToken);
var lambdas = anonymousMethodParameters.SelectMany(p => p.ContainingSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).AsEnumerable())
var lambdas = anonymousMethodParameters.SelectMany(p => p.ContainingSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax(cancellationToken)).AsEnumerable())
.Where(n => n is ParenthesizedLambdaExpressionSyntax || n is SimpleLambdaExpressionSyntax)
.ToSet();
......
......@@ -83,7 +83,7 @@ protected override bool CanFind(IMethodSymbol symbol)
var convertedAnonymousFunctions = nodes.Where(n => syntaxFactsService.IsAnonymousFunction(n))
.Where(n =>
{
ISymbol convertedType = semanticModel.GetTypeInfo(n).ConvertedType;
ISymbol convertedType = semanticModel.GetTypeInfo(n, cancellationToken).ConvertedType;
if (convertedType != null)
{
......
......@@ -370,7 +370,7 @@ protected bool ExpressionBinds(SyntaxNode expression, SemanticModel semanticMode
// See if the name binds to something other then the error type. If it does, there's nothing further we need to do.
// For extension methods, however, we will continue to search if there exists any better matched method.
cancellationToken.ThrowIfCancellationRequested();
var symbolInfo = semanticModel.GetSymbolInfo(expression);
var symbolInfo = semanticModel.GetSymbolInfo(expression, cancellationToken);
if (symbolInfo.CandidateReason == CandidateReason.OverloadResolutionFailure && !checkForExtensionMethods)
{
return true;
......
......@@ -107,7 +107,7 @@ public async Task<IEnumerable<CodeFix>> GetSuppressionsAsync(Document document,
// Find the start token to attach leading pragma disable warning directive.
var root = await syntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
SyntaxTrivia containingTrivia = root.FindTrivia(span.Start);
var lines = syntaxTree.GetText().Lines;
var lines = syntaxTree.GetText(cancellationToken).Lines;
int indexOfLine;
if (containingTrivia == default(SyntaxTrivia))
{
......
......@@ -116,7 +116,7 @@ private async Task<Result> EncapsulateFieldResultAsync(Document document, TextSp
{
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var compilation = semanticModel.Compilation;
var currentField = field.GetSymbolKey().Resolve(compilation).Symbol as IFieldSymbol;
var currentField = field.GetSymbolKey().Resolve(compilation, cancellationToken: cancellationToken).Symbol as IFieldSymbol;
// We couldn't resolve this field. skip it
if (currentField == null)
......@@ -154,8 +154,8 @@ private async Task<Result> EncapsulateFieldAsync(IFieldSymbol field, Document do
// Annotate the field declarations so we can find it after rename.
var fieldDeclaration = field.DeclaringSyntaxReferences.First();
var declarationAnnotation = new SyntaxAnnotation();
document = document.WithSyntaxRoot(fieldDeclaration.SyntaxTree.GetRoot().ReplaceNode(fieldDeclaration.GetSyntax(),
fieldDeclaration.GetSyntax().WithAdditionalAnnotations(declarationAnnotation)));
document = document.WithSyntaxRoot(fieldDeclaration.SyntaxTree.GetRoot(cancellationToken).ReplaceNode(fieldDeclaration.GetSyntax(cancellationToken),
fieldDeclaration.GetSyntax(cancellationToken).WithAdditionalAnnotations(declarationAnnotation)));
var solution = document.Project.Solution;
......@@ -179,7 +179,7 @@ private async Task<Result> EncapsulateFieldAsync(IFieldSymbol field, Document do
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var compilation = semanticModel.Compilation;
field = field.GetSymbolKey().Resolve(compilation).Symbol as IFieldSymbol;
field = field.GetSymbolKey().Resolve(compilation, cancellationToken: cancellationToken).Symbol as IFieldSymbol;
Solution solutionNeedingProperty = null;
// We couldn't resolve field after annotating its declaration. Bail
......@@ -209,7 +209,7 @@ private async Task<Result> EncapsulateFieldAsync(IFieldSymbol field, Document do
semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
compilation = semanticModel.Compilation;
field = field.GetSymbolKey().Resolve(compilation).Symbol as IFieldSymbol;
field = field.GetSymbolKey().Resolve(compilation, cancellationToken: cancellationToken).Symbol as IFieldSymbol;
}
}
......
......@@ -276,7 +276,7 @@ public ExtractInterfaceResult ExtractInterfaceFromAnalyzedType(ExtractInterfaceT
private static Solution GetSolutionWithFormattedInterfaceDocument(Document unformattedInterfaceDocument, CancellationToken cancellationToken)
{
Solution solutionWithInterfaceDocument;
var formattedRoot = Formatter.Format(unformattedInterfaceDocument.GetSyntaxRootAsync(cancellationToken).WaitAndGetResult(cancellationToken), unformattedInterfaceDocument.Project.Solution.Workspace);
var formattedRoot = Formatter.Format(unformattedInterfaceDocument.GetSyntaxRootAsync(cancellationToken).WaitAndGetResult(cancellationToken), unformattedInterfaceDocument.Project.Solution.Workspace, cancellationToken: cancellationToken);
var rootToSimplify = formattedRoot.WithAdditionalAnnotations(Simplifier.Annotation);
var finalInterfaceDocument = Simplifier.ReduceAsync(unformattedInterfaceDocument.WithSyntaxRoot(rootToSimplify), cancellationToken: cancellationToken).WaitAndGetResult(cancellationToken);
......
......@@ -40,7 +40,7 @@ protected override Task<Document> GetChangedDocumentAsync(CancellationToken canc
{
var workspace = document.Project.Solution.Workspace;
var declarationService = document.Project.LanguageServices.GetService<ISymbolDeclarationService>();
var constructor = declarationService.GetDeclarations(state.DelegatedConstructor).Select(r => r.GetSyntax()).First();
var constructor = declarationService.GetDeclarations(state.DelegatedConstructor).Select(r => r.GetSyntax(cancellationToken)).First();
var newConstructor = constructor;
newConstructor = CodeGenerator.AddParameterDeclarations(newConstructor, parameters.Skip(state.DelegatedConstructor.Parameters.Length), workspace);
......
......@@ -116,7 +116,7 @@ private partial class State
return false;
}
var semanticInfo = semanticModel.GetSymbolInfo(this.SimpleNameOrMemberAccessExpression);
var semanticInfo = semanticModel.GetSymbolInfo(this.SimpleNameOrMemberAccessExpression, cancellationToken);
if (cancellationToken.IsCancellationRequested)
{
return false;
......
......@@ -185,7 +185,7 @@ internal new class State : AbstractGenerateParameterizedMemberService<TService,
cancellationToken.ThrowIfCancellationRequested();
// If the name bound with errors, then this is a candidate for generate method.
var semanticInfo = semanticModel.GetSymbolInfo(this.SimpleNameOrMemberAccessExpression);
var semanticInfo = semanticModel.GetSymbolInfo(this.SimpleNameOrMemberAccessExpression, cancellationToken);
if (semanticInfo.GetAllSymbols().Any(s => s.Kind == SymbolKind.Local || s.Kind == SymbolKind.Parameter) &&
!service.AreSpecialOptionsActive(semanticModel))
{
......
......@@ -70,7 +70,8 @@ private SyntaxNode GetNewRoot(CancellationToken cancellationToken)
return codeGenService.AddStatements(
root,
SpecializedCollections.SingletonEnumerable(localStatement),
options: new CodeGenerationOptions(beforeThisLocation: state.IdentifierToken.GetLocation()));
options: new CodeGenerationOptions(beforeThisLocation: state.IdentifierToken.GetLocation()),
cancellationToken: cancellationToken);
}
}
}
......
......@@ -228,7 +228,7 @@ internal bool CanGenerateLocal()
// Now, try to bind the invocation and see if it succeeds or not. if it succeeds and
// binds uniquely, then we don't need to offer this quick fix.
cancellationToken.ThrowIfCancellationRequested();
var semanticInfo = semanticModel.GetSymbolInfo(this.SimpleNameOrMemberAccessExpressionOpt);
var semanticInfo = semanticModel.GetSymbolInfo(this.SimpleNameOrMemberAccessExpressionOpt, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
if (semanticInfo.Symbol != null)
......
......@@ -364,7 +364,7 @@ private bool GenerateStruct(TService service, SemanticModel semanticModel, Cance
TExpressionSyntax leftSide,
CancellationToken cancellationToken)
{
var leftSideInfo = semanticModel.GetSymbolInfo(leftSide);
var leftSideInfo = semanticModel.GetSymbolInfo(leftSide, cancellationToken);
if (leftSideInfo.Symbol != null)
{
......
......@@ -129,7 +129,7 @@ private bool CanGenerateIntoContainingNamespace(SemanticDocument document, Synta
var declarationService = document.Project.LanguageServices.GetService<ISymbolDeclarationService>();
var decl = declarationService.GetDeclarations(containingNamespace)
.Where(r => r.SyntaxTree == node.SyntaxTree)
.Select(r => r.GetSyntax())
.Select(r => r.GetSyntax(cancellationToken))
.FirstOrDefault(node.GetAncestorsOrThis<SyntaxNode>().Contains);
return
......
......@@ -86,7 +86,7 @@ public State(TService service, SemanticDocument document)
return false;
}
this.IsConstant = this.Document.SemanticModel.GetConstantValue(this.Expression).HasValue;
this.IsConstant = this.Document.SemanticModel.GetConstantValue(this.Expression, cancellationToken).HasValue;
// Note: the ordering of these clauses are important. They go, generally, from
// innermost to outermost order.
......
......@@ -30,7 +30,7 @@ private partial class State
}
// Can't extract out an anonymous type used in a constructor initializer.
var info = this.Document.SemanticModel.GetTypeInfo(this.Expression);
var info = this.Document.SemanticModel.GetTypeInfo(this.Expression, cancellationToken);
if (info.Type.ContainsAnonymousType())
{
return false;
......
......@@ -37,7 +37,7 @@ private partial class State
}
// Can't extract out an anonymous type used in a field initializer.
var info = this.Document.SemanticModel.GetTypeInfo(this.Expression);
var info = this.Document.SemanticModel.GetTypeInfo(this.Expression, cancellationToken);
if (info.Type.ContainsAnonymousType())
{
return false;
......
......@@ -24,7 +24,7 @@ private partial class State
return false;
}
var info = this.Document.SemanticModel.GetTypeInfo(this.Expression);
var info = this.Document.SemanticModel.GetTypeInfo(this.Expression, cancellationToken);
if (info.Type == null || info.Type.SpecialType == SpecialType.System_Void)
{
return false;
......
......@@ -85,7 +85,7 @@ public static async Task<Location> GetLocationInGeneratedSourceAsync(SymbolKey s
{
var location = symbolId.Resolve(
await generatedDocument.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false),
ignoreAssemblyKey: true)
ignoreAssemblyKey: true, cancellationToken: cancellationToken)
.GetAllSymbols()
.Select(s => s.Locations.Where(loc => loc.IsInSource).FirstOrDefault())
.WhereNotNull()
......
......@@ -173,11 +173,11 @@ public static IEnumerable<SymbolDisplayPart> GetDocumentationParts(this ISymbol
var globalNamespace = semanticModel.Compilation.GlobalNamespace;
var documentation = symbol.TypeSwitch(
(IParameterSymbol parameter) => parameter.ContainingSymbol.OriginalDefinition.GetDocumentationComment().GetParameterText(symbol.Name),
(ITypeParameterSymbol typeParam) => typeParam.ContainingSymbol.GetDocumentationComment().GetTypeParameterText(symbol.Name),
(IParameterSymbol parameter) => parameter.ContainingSymbol.OriginalDefinition.GetDocumentationComment(cancellationToken: cancellationToken).GetParameterText(symbol.Name),
(ITypeParameterSymbol typeParam) => typeParam.ContainingSymbol.GetDocumentationComment(cancellationToken: cancellationToken).GetTypeParameterText(symbol.Name),
(IMethodSymbol method) => GetMethodDocumentation(method),
(IAliasSymbol alias) => alias.Target.GetDocumentationComment().SummaryText,
_ => symbol.GetDocumentationComment().SummaryText);
(IAliasSymbol alias) => alias.Target.GetDocumentationComment(cancellationToken: cancellationToken).SummaryText,
_ => symbol.GetDocumentationComment(cancellationToken: cancellationToken).SummaryText);
if (documentation != null)
{
......
......@@ -107,7 +107,7 @@ public static RefKind GetRefKind(this ArgumentSyntax argument)
{
// If a parameter appears to have a void return type, then just use 'object'
// instead.
var typeInfo = semanticModel.GetTypeInfo(argument.Expression);
var typeInfo = semanticModel.GetTypeInfo(argument.Expression, cancellationToken);
if (typeInfo.Type != null && typeInfo.Type.SpecialType == SpecialType.System_Void)
{
return semanticModel.Compilation.ObjectType;
......
......@@ -2176,7 +2176,7 @@ public static bool IsNameOfContext(this SyntaxTree syntaxTree, int position, Sem
return true;
}
return semanticModelOpt.GetSymbolInfo(parentExpression).Symbol == null;
return semanticModelOpt.GetSymbolInfo(parentExpression, cancellationToken).Symbol == null;
}
return false;
......@@ -2369,7 +2369,7 @@ public static bool IsEnumTypeMemberAccessContext(this SyntaxTree syntaxTree, Sem
}
var memberAccess = (MemberAccessExpressionSyntax)token.Parent;
var leftHandBinding = semanticModel.GetSymbolInfo(memberAccess.Expression);
var leftHandBinding = semanticModel.GetSymbolInfo(memberAccess.Expression, cancellationToken);
var symbol = leftHandBinding.GetBestOrAllSymbols().FirstOrDefault();
if (symbol == null)
......
......@@ -35,7 +35,7 @@ internal static class CrefSyntaxExtensions
(memberCref.Kind() == SyntaxKind.NameMemberCref))
{
var nameMemberCref = ((NameMemberCrefSyntax)memberCref).Name;
var symbolInfo = semanticModel.GetSymbolInfo(nameMemberCref);
var symbolInfo = semanticModel.GetSymbolInfo(nameMemberCref, cancellationToken);
var symbol = symbolInfo.Symbol;
if (symbol == null)
......
......@@ -821,7 +821,7 @@ private static bool TryReplaceWithAlias(this ExpressionSyntax node, SemanticMode
return false;
}
var symbol = semanticModel.GetSymbolInfo(node).Symbol;
var symbol = semanticModel.GetSymbolInfo(node, cancellationToken).Symbol;
// If the Symbol is a contrcutor get its containing type
if (symbol.IsConstructor())
......@@ -869,7 +869,7 @@ private static bool TryReplaceWithAlias(this ExpressionSyntax node, SemanticMode
}
if (node.Kind() == SyntaxKind.IdentifierName &&
semanticModel.GetAliasInfo((IdentifierNameSyntax)node) != null)
semanticModel.GetAliasInfo((IdentifierNameSyntax)node, cancellationToken) != null)
{
return false;
}
......@@ -886,7 +886,7 @@ private static bool TryReplaceWithAlias(this ExpressionSyntax node, SemanticMode
var qualifiedName = (QualifiedNameSyntax)node;
if (!qualifiedName.Right.HasAnnotation(Simplifier.SpecialTypeAnnotation))
{
var type = semanticModel.GetTypeInfo(node).Type;
var type = semanticModel.GetTypeInfo(node, cancellationToken).Type;
if (type != null)
{
var keywordKind = GetPredefinedKeywordKind(type.SpecialType);
......@@ -903,7 +903,7 @@ private static bool TryReplaceWithAlias(this ExpressionSyntax node, SemanticMode
var aliasQualifiedNameSyntax = (AliasQualifiedNameSyntax)node;
if (!aliasQualifiedNameSyntax.Name.HasAnnotation(Simplifier.SpecialTypeAnnotation))
{
var type = semanticModel.GetTypeInfo(node).Type;
var type = semanticModel.GetTypeInfo(node, cancellationToken).Type;
if (type != null)
{
var keywordKind = GetPredefinedKeywordKind(type.SpecialType);
......@@ -1290,7 +1290,7 @@ private static int GetNamespaceId(SyntaxList<MemberDeclarationSyntax> members, N
if (PreferPredefinedTypeKeywordInDeclarations(name, optionSet, semanticModel) ||
PreferPredefinedTypeKeywordInMemberAccess(name, optionSet, semanticModel))
{
var type = semanticModel.GetTypeInfo(name).Type;
var type = semanticModel.GetTypeInfo(name, cancellationToken).Type;
if (type != null)
{
var keywordKind = GetPredefinedKeywordKind(type.SpecialType);
......@@ -1700,7 +1700,7 @@ private static bool HidingTypeParameterSymbolExists(ISymbol candidateSymbol, Lis
if (memberAccess.Expression.Kind() == SyntaxKind.BaseExpression)
{
var enclosingNamedType = semanticModel.GetEnclosingNamedType(memberAccess.SpanStart, cancellationToken);
var symbol = semanticModel.GetSymbolInfo(memberAccess.Name).Symbol;
var symbol = semanticModel.GetSymbolInfo(memberAccess.Name, cancellationToken).Symbol;
if (enclosingNamedType != null &&
!enclosingNamedType.IsSealed &&
symbol != null &&
......@@ -1985,7 +1985,7 @@ private static bool IsThisOrTypeOrNamespace(MemberAccessExpressionSyntax memberA
return true;
}
var type = semanticModel.GetTypeInfo(simpleName).Type;
var type = semanticModel.GetTypeInfo(simpleName, cancellationToken).Type;
// the variable cannot be initialized to a method group or an anonymous function
if (type != null &&
......@@ -1994,7 +1994,7 @@ private static bool IsThisOrTypeOrNamespace(MemberAccessExpressionSyntax memberA
return true;
}
var initializerType = semanticModel.GetTypeInfo(equalsValueClause.Value).Type;
var initializerType = semanticModel.GetTypeInfo(equalsValueClause.Value, cancellationToken).Type;
if (!type.Equals(initializerType))
{
......@@ -2005,7 +2005,7 @@ private static bool IsThisOrTypeOrNamespace(MemberAccessExpressionSyntax memberA
var possibleSameLocals = equalsValueClause.DescendantNodesAndSelf().Where(n => n.Kind() == SyntaxKind.IdentifierName && ((IdentifierNameSyntax)n).Identifier.ValueText.Equals(identifier.ValueText));
var anyUse = possibleSameLocals.Any(n =>
{
var symbol = semanticModel.GetSymbolInfo(n).Symbol;
var symbol = semanticModel.GetSymbolInfo(n, cancellationToken).Symbol;
if (symbol != null && symbol.Kind == SymbolKind.Local)
{
return true;
......
......@@ -234,7 +234,7 @@ public static IEnumerable<BaseTypeSyntax> GetAllBaseListTypes(this TypeDeclarati
var isPartialType = typeNode.Modifiers.Any(m => m.Kind() == SyntaxKind.PartialKeyword);
if (isPartialType)
{
var typeSymbol = model.GetDeclaredSymbol(typeNode);
var typeSymbol = model.GetDeclaredSymbol(typeNode, cancellationToken);
if (typeSymbol != null)
{
foreach (var syntaxRef in typeSymbol.DeclaringSyntaxReferences)
......
......@@ -93,7 +93,7 @@ internal class CSharpRecommendationService : AbstractRecommendationService
}
else if (context.IsDestructorTypeContext)
{
return SpecializedCollections.SingletonEnumerable(context.SemanticModel.GetDeclaredSymbol(context.ContainingTypeOrEnumDeclaration));
return SpecializedCollections.SingletonEnumerable(context.SemanticModel.GetDeclaredSymbol(context.ContainingTypeOrEnumDeclaration, cancellationToken));
}
return SpecializedCollections.EmptyEnumerable<ISymbol>();
......@@ -173,7 +173,7 @@ internal class CSharpRecommendationService : AbstractRecommendationService
{
var enclosingSymbol = context.LeftToken.Parent
.AncestorsAndSelf()
.Select(n => context.SemanticModel.GetDeclaredSymbol(n))
.Select(n => context.SemanticModel.GetDeclaredSymbol(n, cancellationToken))
.WhereNotNull()
.FirstOrDefault();
......
......@@ -366,7 +366,7 @@ public async Task<Solution> OpenSolutionAsync(string solutionFilePath, Cancellat
var absoluteSolutionPath = this.GetAbsoluteSolutionPath(solutionFilePath, Environment.CurrentDirectory);
using (this.dataGuard.DisposableWait())
using (this.dataGuard.DisposableWait(cancellationToken))
{
this.SetSolutionProperties(absoluteSolutionPath);
}
......@@ -379,7 +379,7 @@ public async Task<Solution> OpenSolutionAsync(string solutionFilePath, Cancellat
var invalidProjects = new List<ProjectInSolution>();
// seed loaders from known project types
using (this.dataGuard.DisposableWait())
using (this.dataGuard.DisposableWait(cancellationToken))
{
foreach (var project in solutionFile.ProjectsInOrder)
{
......
......@@ -380,7 +380,7 @@ public virtual async Task<Solution> TryMergeFixesAsync(Solution oldSolution, IEn
mergeTasks[i] = Task.Run(async () =>
{
var appliedChanges = (await documentsToMerge[0].GetTextChangesAsync(oldDocument).ConfigureAwait(false)).ToList();
var appliedChanges = (await documentsToMerge[0].GetTextChangesAsync(oldDocument, cancellationToken).ConfigureAwait(false)).ToList();
foreach (var document in documentsToMerge.Skip(1))
{
......@@ -431,7 +431,7 @@ public virtual async Task<Solution> TryMergeFixesAsync(Solution oldSolution, IEn
var successfullyMergedChanges = new List<TextChange>();
int cumulativeChangeIndex = 0;
foreach (var change in await newDocument.GetTextChangesAsync(oldDocument).ConfigureAwait(false))
foreach (var change in await newDocument.GetTextChangesAsync(oldDocument, cancellationToken).ConfigureAwait(false))
{
while (cumulativeChangeIndex < cumulativeChanges.Count && cumulativeChanges[cumulativeChangeIndex].Span.End < change.Span.Start)
{
......
......@@ -24,7 +24,7 @@ internal abstract partial class AbstractCodeGenerationService
public bool CanAddTo(ISymbol destination, Solution solution, CancellationToken cancellationToken)
{
var declarations = symbolDeclarationService.GetDeclarations(destination);
return declarations.Any(r => CanAddTo(r.GetSyntax(), solution, cancellationToken));
return declarations.Any(r => CanAddTo(r.GetSyntax(cancellationToken), solution, cancellationToken));
}
protected static SyntaxToken GetEndToken(SyntaxNode node)
......
......@@ -104,14 +104,14 @@ public async Task<ISymbol> GetCurrentSymbolAsync(ISymbol symbol, CancellationTok
var symbolId = DocumentationCommentId.CreateDeclarationId(symbol);
// check to see if symbol is from current solution
var project = this.currentSolution.GetProject(symbol.ContainingAssembly);
var project = this.currentSolution.GetProject(symbol.ContainingAssembly, cancellationToken);
if (project != null)
{
return await GetSymbolAsync(this.currentSolution, project.Id, symbolId, cancellationToken).ConfigureAwait(false);
}
// check to see if it is from original solution
project = this.originalSolution.GetProject(symbol.ContainingAssembly);
project = this.originalSolution.GetProject(symbol.ContainingAssembly, cancellationToken);
if (project != null)
{
return await GetSymbolAsync(this.currentSolution, project.Id, symbolId, cancellationToken).ConfigureAwait(false);
......@@ -298,7 +298,7 @@ private void CheckSymbolArgument(ISymbol currentSymbol, ISymbol argSymbol)
// try to find new symbol by looking up via original declaration
var model = await newDoc.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var newDeclaration = model.SyntaxTree.GetRoot().GetCurrentNode(declaration);
var newDeclaration = model.SyntaxTree.GetRoot(cancellationToken).GetCurrentNode(declaration);
if (newDeclaration != null)
{
var newSymbol = model.GetDeclaredSymbol(newDeclaration, cancellationToken);
......
......@@ -40,7 +40,7 @@ public static class SymbolEditorExtensions
var model = await doc.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var gen = SyntaxGenerator.GetGenerator(doc);
var typeRef = gen.GetBaseAndInterfaceTypes(decl).FirstOrDefault(r => model.GetTypeInfo(r).Type.Equals(baseOrInterfaceType));
var typeRef = gen.GetBaseAndInterfaceTypes(decl).FirstOrDefault(r => model.GetTypeInfo(r, cancellationToken).Type.Equals(baseOrInterfaceType));
if (typeRef != null)
{
return typeRef;
......
......@@ -140,7 +140,7 @@ private static IEnumerable<Project> GetProjects(Solution solution, IEnumerable<P
// Find the projects that reference this assembly.
var sourceProject = solution.GetProject(containingAssembly);
var sourceProject = solution.GetProject(containingAssembly, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
// 1) Compute all the dependent projects (submission + non-submission) and their InternalsVisibleTo semantics to the definition project.
......@@ -240,7 +240,7 @@ private static async Task AddSubmissionDependentProjectsAsync(Solution solution,
var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
if (compilation.PreviousSubmission != null)
{
var referencedProject = solution.GetProject(compilation.PreviousSubmission.Assembly);
var referencedProject = solution.GetProject(compilation.PreviousSubmission.Assembly, cancellationToken);
List<ProjectId> referencingSubmissions = null;
if (!projectIdsToReferencingSubmissionIds.TryGetValue(referencedProject.Id, out referencingSubmissions))
......
......@@ -249,7 +249,7 @@ internal static class DependentTypeFinder
{
cancellationToken.ThrowIfCancellationRequested();
var resolvedSymbols = id.Resolve(compilation).GetAllSymbols();
var resolvedSymbols = id.Resolve(compilation, cancellationToken: cancellationToken).GetAllSymbols();
foreach (var resolvedSymbol in resolvedSymbols)
{
var mappedSymbol = await SymbolFinder.FindSourceDefinitionAsync(resolvedSymbol, solution, cancellationToken).ConfigureAwait(false) ?? resolvedSymbol;
......
......@@ -117,7 +117,7 @@ private static ISymbol GetContainer(ISymbol symbol)
{
var service = document.GetLanguageService<ISymbolDeclarationService>();
var declarations = service.GetDeclarations(container);
var tokens = declarations.SelectMany(r => r.GetSyntax().DescendantTokens());
var tokens = declarations.SelectMany(r => r.GetSyntax(cancellationToken).DescendantTokens());
var name = symbol.Name;
var syntaxFacts = document.GetLanguageService<ISyntaxFactsService>();
......
......@@ -70,7 +70,7 @@ protected override bool CanFind(IParameterSymbol symbol)
if (parameter.ContainingSymbol.IsAnonymousFunction())
{
var parameterNode = parameter.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).FirstOrDefault();
var parameterNode = parameter.DeclaringSyntaxReferences.Select(r => r.GetSyntax(cancellationToken)).FirstOrDefault();
if (parameterNode != null)
{
var document = solution.GetDocument(parameterNode.SyntaxTree);
......@@ -81,7 +81,7 @@ protected override bool CanFind(IParameterSymbol symbol)
{
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var lambdaNode = parameter.ContainingSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).FirstOrDefault();
var lambdaNode = parameter.ContainingSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax(cancellationToken)).FirstOrDefault();
var convertedType = semanticModel.GetTypeInfo(lambdaNode, cancellationToken).ConvertedType;
if (convertedType != null)
......@@ -138,7 +138,7 @@ protected override bool CanFind(IParameterSymbol symbol)
SignatureComparer.Instance.HaveSameSignatureAndConstraintsAndReturnTypeAndAccessors(parameter.ContainingSymbol, symbol.ContainingSymbol, syntaxFacts.IsCaseSensitive) &&
ParameterNamesMatch(syntaxFacts, (IMethodSymbol)parameter.ContainingSymbol, (IMethodSymbol)symbol.ContainingSymbol))
{
var lambdaNode = symbol.ContainingSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).FirstOrDefault();
var lambdaNode = symbol.ContainingSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax(cancellationToken)).FirstOrDefault();
var convertedType2 = semanticModel.GetTypeInfo(lambdaNode, cancellationToken).ConvertedType;
if (convertedType1.Equals(convertedType2))
......@@ -203,7 +203,7 @@ private SyntaxNode GetContainer(SemanticModel semanticModel, SyntaxNode paramete
var namedType = containingMethod.ContainingType as INamedTypeSymbol;
if (namedType != null && namedType.IsDelegateType() && namedType.AssociatedSymbol != null)
{
var eventNode = namedType.AssociatedSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).FirstOrDefault();
var eventNode = namedType.AssociatedSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax(cancellationToken)).FirstOrDefault();
if (eventNode != null)
{
var document = solution.GetDocument(eventNode.SyntaxTree);
......
......@@ -106,7 +106,7 @@ public static partial class SymbolFinder
return null;
}
var project = solution.GetProject(symbol.ContainingAssembly);
var project = solution.GetProject(symbol.ContainingAssembly, cancellationToken);
if (project != null)
{
var symbolId = symbol.GetSymbolKey();
......
......@@ -141,7 +141,7 @@ private static async Task AddDeclarationsAsync(Project project, Compilation star
// Return symbols from skeleton assembly in this case so that symbols have the same language as startingCompilation.
list.AddRange(
FilterByCriteria(compilation.GetSymbolsWithName(predicate, filter, cancellationToken), filter)
.Select(s => s.GetSymbolKey().Resolve(startingCompilation).Symbol).WhereNotNull());
.Select(s => s.GetSymbolKey().Resolve(startingCompilation, cancellationToken: cancellationToken).Symbol).WhereNotNull());
}
else
{
......
......@@ -102,7 +102,7 @@ internal async Task<LinkedFileMergeSessionResult> MergeDiffsAsync(IMergeConflict
}
var originalDocument = oldSolution.GetDocument(linkedDocumentGroup.First());
var originalSourceText = await originalDocument.GetTextAsync().ConfigureAwait(false);
var originalSourceText = await originalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
// Add comments in source explaining diffs that could not be merged
......
......@@ -247,7 +247,7 @@ private static bool TryGetValue(IDictionary<string, ISymbol> dictionary, string
{
// Call accessors directly if C# overriding VB
if (document.Project.Language == LanguageNames.CSharp
&& SymbolFinder.FindSourceDefinitionAsync(overriddenProperty, document.Project.Solution)
&& SymbolFinder.FindSourceDefinitionAsync(overriddenProperty, document.Project.Solution, cancellationToken)
.WaitAndGetResult(CancellationToken.None).Language == LanguageNames.VisualBasic)
{
var getName = overriddenProperty.GetMethod != null ? overriddenProperty.GetMethod.Name : null;
......
......@@ -76,7 +76,7 @@ public override SymbolKeyResolution Resolve(Compilation compilation, bool ignore
foreach (var token in node.DescendantNodes())
{
var symbol = semanticModel.GetDeclaredSymbol(token) as TSymbol;
var symbol = semanticModel.GetDeclaredSymbol(token, cancellationToken) as TSymbol;
if (symbol != null && Equals(compilation.IsCaseSensitive, symbol.Name, name))
{
......
......@@ -68,7 +68,7 @@ private IEnumerable<IMethodSymbol> Resolve(Compilation compilation, INamedTypeSy
if (typeArgumentKeysOpt != null)
{
typeArguments = typeArgumentKeysOpt.Select(a => a.Resolve(compilation).Symbol as ITypeSymbol).ToArray();
typeArguments = typeArgumentKeysOpt.Select(a => a.Resolve(compilation, cancellationToken: cancellationToken).Symbol as ITypeSymbol).ToArray();
if (typeArguments.Any(a => a == null))
{
......
......@@ -1876,7 +1876,7 @@ internal async Task<Solution> WithFrozenPartialCompilationIncludingSpecificDocum
var doc = this.GetDocument(documentId);
var tree = await doc.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
using (this.StateLock.DisposableWait())
using (this.StateLock.DisposableWait(cancellationToken))
{
// in progress solutions are disabled for some testing
Workspace ws = this.Workspace as Workspace;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册