Browse Source

Fix crash in semantic highlighter when highlighting a method call with explicitly provided type arguments.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
f877fdf87b
  1. 35
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs

35
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs

@ -230,11 +230,15 @@ namespace CSharpBinding
HighlightedLine line = new HighlightedLine(textEditor.Document, documentLine); HighlightedLine line = new HighlightedLine(textEditor.Document, documentLine);
this.line = line; this.line = line;
this.lineNumber = lineNumber; this.lineNumber = lineNumber;
try { if (Debugger.IsAttached) {
parseInfo.CompilationUnit.AcceptVisitor(this); parseInfo.CompilationUnit.AcceptVisitor(this);
} catch (Exception ex) { } else {
hasCrashed = true; try {
throw new ApplicationException("Error highlighting line " + lineNumber, ex); parseInfo.CompilationUnit.AcceptVisitor(this);
} catch (Exception ex) {
hasCrashed = true;
throw new ApplicationException("Error highlighting line " + lineNumber, ex);
}
} }
this.line = null; this.line = null;
this.resolver = null; this.resolver = null;
@ -346,13 +350,24 @@ namespace CSharpBinding
public override void VisitInvocationExpression(InvocationExpression invocationExpression) public override void VisitInvocationExpression(InvocationExpression invocationExpression)
{ {
Expression target = invocationExpression.Target; Expression target = invocationExpression.Target;
target.AcceptVisitor(this); if (target is IdentifierExpression || target is MemberReferenceExpression || target is PointerReferenceExpression) {
// apply color to target's target
var rr = resolver.Resolve(invocationExpression) as CSharpInvocationResolveResult; target.GetChildByRole(Roles.TargetExpression).AcceptVisitor(this);
if (rr != null && !rr.IsDelegateInvocation) {
if (target is IdentifierExpression || target is MemberReferenceExpression || target is PointerReferenceExpression) { // highlight the method call
Colorize(target.GetChildByRole(Roles.Identifier), methodCallColor); var identifier = target.GetChildByRole(Roles.Identifier);
var invocationRR = resolver.Resolve(invocationExpression) as CSharpInvocationResolveResult;
if (invocationRR != null && !invocationRR.IsDelegateInvocation) {
Colorize(identifier, methodCallColor);
} else {
ResolveResult targetRR = resolver.Resolve(target);
Colorize(identifier, GetColor(targetRR));
} }
foreach (AstNode node in target.GetChildrenByRole(Roles.TypeArgument))
node.AcceptVisitor(this);
} else {
target.AcceptVisitor(this);
} }
foreach (AstNode node in invocationExpression.Arguments) foreach (AstNode node in invocationExpression.Arguments)

Loading…
Cancel
Save