From 8d9eec0c549ba3553c7eb26c297886b4ab4f2661 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 24 Feb 2013 18:02:17 +0100 Subject: [PATCH] Use ThrowIfCancellationRequested() --- .../Analysis/SemanticHighlightingVisitor.cs | 15 ++++++--------- .../Resolver/CSharpAstResolver.cs | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ICSharpCode.NRefactory.CSharp/Analysis/SemanticHighlightingVisitor.cs b/ICSharpCode.NRefactory.CSharp/Analysis/SemanticHighlightingVisitor.cs index 24a7ef22aa..03c21a406a 100644 --- a/ICSharpCode.NRefactory.CSharp/Analysis/SemanticHighlightingVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Analysis/SemanticHighlightingVisitor.cs @@ -155,7 +155,8 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis if (end.IsNull) return; Debug.Assert(node == end.Parent); - for (var child = node.FirstChild; child != end && !cancellationToken.IsCancellationRequested; child = child.NextSibling) { + for (var child = node.FirstChild; child != end; child = child.NextSibling) { + cancellationToken.ThrowIfCancellationRequested(); if (child.StartLocation < regionEnd && child.EndLocation > regionStart) child.AcceptVisitor(this); } @@ -168,7 +169,8 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis protected void VisitChildrenAfter(AstNode node, AstNode start) { Debug.Assert(start.IsNull || start.Parent == node); - for (var child = (start.IsNull ? node.FirstChild : start.NextSibling); child != null && !cancellationToken.IsCancellationRequested; child = child.NextSibling) { + for (var child = (start.IsNull ? node.FirstChild : start.NextSibling); child != null; child = child.NextSibling) { + cancellationToken.ThrowIfCancellationRequested(); if (child.StartLocation < regionEnd && child.EndLocation > regionStart) child.AcceptVisitor(this); } @@ -213,6 +215,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis break; } // "value" is handled in VisitIdentifierExpression() + // "alias" is handled in VisitExternAliasDeclaration() } public override void VisitSimpleType(SimpleType simpleType) @@ -257,7 +260,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis Expression target = invocationExpression.Target; if (target is IdentifierExpression || target is MemberReferenceExpression || target is PointerReferenceExpression) { var invocationRR = resolver.Resolve(invocationExpression, cancellationToken) as CSharpInvocationResolveResult; - if (invocationRR != null && IsInactiveConditionalMethod(invocationRR.Member)) { + if (invocationRR != null && invocationExpression.Parent is ExpressionStatement && IsInactiveConditionalMethod(invocationRR.Member)) { // mark the whole invocation statement as inactive code Colorize(invocationExpression.Parent, inactiveCodeColor); return; @@ -342,12 +345,6 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration) { -// var result = resolver.Resolve (methodDeclaration, cancellationToken) as MemberResolveResult; -// if (IsInactiveConditionalMethod(result.Member as IMethod)) { -// Colorize(methodDeclaration, inactiveCodeColor); -// return; -// } -// var nameToken = methodDeclaration.NameToken; VisitChildrenUntil(methodDeclaration, nameToken); if (!methodDeclaration.PrivateImplementationType.IsNull) { diff --git a/ICSharpCode.NRefactory.CSharp/Resolver/CSharpAstResolver.cs b/ICSharpCode.NRefactory.CSharp/Resolver/CSharpAstResolver.cs index 6b33502c70..5d29d549e4 100644 --- a/ICSharpCode.NRefactory.CSharp/Resolver/CSharpAstResolver.cs +++ b/ICSharpCode.NRefactory.CSharp/Resolver/CSharpAstResolver.cs @@ -244,7 +244,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver } /// - /// Gets the expected type for the specified node. This is the type being that a node is being converted to. + /// Gets the expected type for the specified node. This is the type that a node is being converted to. /// public IType GetExpectedType(Expression expr, CancellationToken cancellationToken = default(CancellationToken)) {