Browse Source

Highlight inactive conditional attributes.

Highlight type name in constructor/destructor declaration.
Handle InvalidCastException when reading a corrupted serialized project content.
newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
8ba973b1b9
  1. 42
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs
  2. 3
      src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs

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

@ -252,7 +252,7 @@ namespace CSharpBinding @@ -252,7 +252,7 @@ namespace CSharpBinding
}
this.line = null;
this.resolver = null;
Debug.WriteLine("Semantic highlighting for line {0} - added {1} sections", lineNumber, line.Sections.Count);
//Debug.WriteLine("Semantic highlighting for line {0} - added {1} sections", lineNumber, line.Sections.Count);
if (textEditor.Document.Version != null) {
cachedLines.Add(new CachedLine(line, textEditor.Document.Version));
}
@ -438,6 +438,36 @@ namespace CSharpBinding @@ -438,6 +438,36 @@ namespace CSharpBinding
}
}
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
HandleConstructorOrDestructor(constructorDeclaration);
}
public override void VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration)
{
HandleConstructorOrDestructor(destructorDeclaration);
}
void HandleConstructorOrDestructor(AstNode constructorDeclaration)
{
for (AstNode child = constructorDeclaration.FirstChild; child != null; child = child.NextSibling) {
if (child.StartLocation.Line <= lineNumber && child.EndLocation.Line >= lineNumber) {
if (child.Role == Roles.Identifier) {
// child == constructorDeclaration.NameToken
var currentTypeDef = resolver.GetResolverStateBefore(constructorDeclaration).CurrentTypeDefinition;
if (currentTypeDef != null && ((Identifier)child).Name == currentTypeDef.Name) {
if (currentTypeDef.IsReferenceType == true)
Colorize(child, referenceTypeColor);
else if (currentTypeDef.IsReferenceType == false)
Colorize(child, valueTypeColor);
}
} else {
child.AcceptVisitor(this);
}
}
}
}
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{
// Type declarations often contain #if directives, so we must make sure
@ -499,6 +529,16 @@ namespace CSharpBinding @@ -499,6 +529,16 @@ namespace CSharpBinding
Colorize(comment, inactiveCodeColor);
}
}
public override void VisitAttribute(ICSharpCode.NRefactory.CSharp.Attribute attribute)
{
ITypeDefinition attrDef = resolver.Resolve(attribute.Type).Type.GetDefinition();
if (attrDef != null && IsInactiveConditional(attrDef.Attributes)) {
Colorize(attribute, inactiveCodeColor);
return;
}
VisitChildren(attribute);
}
#endregion
}
}

3
src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs

@ -162,6 +162,9 @@ namespace ICSharpCode.SharpDevelop.Parser @@ -162,6 +162,9 @@ namespace ICSharpCode.SharpDevelop.Parser
} catch (SerializationException ex) {
LoggingService.Warn(ex);
return null;
} catch (InvalidCastException ex) {
LoggingService.Warn(ex);
return null;
}
}

Loading…
Cancel
Save