Browse Source

Fixed XAML parser (was adding 'null' as top-level type).

Added exception handling to CSharpSemanticHighlighter.
newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
158219a218
  1. 12
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs
  2. 5
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParsedFile.cs
  3. 1
      src/Main/Base/Project/Src/Services/RefactoringService/Reference.cs
  4. 9
      src/Main/SharpDevelop/Parser/ParserService.cs

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

@ -36,6 +36,7 @@ namespace CSharpBinding
List<IDocumentLine> invalidLines = new List<IDocumentLine>(); List<IDocumentLine> invalidLines = new List<IDocumentLine>();
List<CachedLine> cachedLines = new List<CachedLine>(); List<CachedLine> cachedLines = new List<CachedLine>();
bool hasCrashed;
int lineNumber; int lineNumber;
HighlightedLine line; HighlightedLine line;
@ -184,6 +185,10 @@ namespace CSharpBinding
public HighlightedLine HighlightLine(int lineNumber) public HighlightedLine HighlightLine(int lineNumber)
{ {
IDocumentLine documentLine = textEditor.Document.GetLineByNumber(lineNumber); IDocumentLine documentLine = textEditor.Document.GetLineByNumber(lineNumber);
if (hasCrashed) {
// don't highlight anymore after we've crashed
return new HighlightedLine(textEditor.Document, documentLine);
}
ITextSourceVersion newVersion = textEditor.Document.Version; ITextSourceVersion newVersion = textEditor.Document.Version;
CachedLine cachedLine = null; CachedLine cachedLine = null;
for (int i = 0; i < cachedLines.Count; i++) { for (int i = 0; i < cachedLines.Count; i++) {
@ -225,7 +230,12 @@ 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;
parseInfo.CompilationUnit.AcceptVisitor(this); try {
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;
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);

5
src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParsedFile.cs

@ -43,7 +43,10 @@ namespace ICSharpCode.XamlBinding
file.errors.AddRange(document.SyntaxErrors.Select(err => new Error(ErrorType.Error, err.Description))); file.errors.AddRange(document.SyntaxErrors.Select(err => new Error(ErrorType.Error, err.Description)));
var visitor = new XamlDocumentVisitor(file, fileContent); var visitor = new XamlDocumentVisitor(file, fileContent);
visitor.VisitDocument(document); visitor.VisitDocument(document);
file.topLevel = new[] { visitor.TypeDefinition }; if (visitor.TypeDefinition != null)
file.topLevel = new[] { visitor.TypeDefinition };
else
file.topLevel = new IUnresolvedTypeDefinition[0];
file.lastWriteTime = DateTime.UtcNow; file.lastWriteTime = DateTime.UtcNow;
return file; return file;

1
src/Main/Base/Project/Src/Services/RefactoringService/Reference.cs

@ -15,7 +15,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring
/// </summary> /// </summary>
public class Reference : SearchResultMatch public class Reference : SearchResultMatch
{ {
DomRegion region;
ResolveResult resolveResult; ResolveResult resolveResult;
public Reference(DomRegion region, ResolveResult resolveResult, int offset, int length, HighlightedInlineBuilder builder) public Reference(DomRegion region, ResolveResult resolveResult, int offset, int length, HighlightedInlineBuilder builder)

9
src/Main/SharpDevelop/Parser/ParserService.cs

@ -84,15 +84,6 @@ namespace ICSharpCode.SharpDevelop.Parser
} }
#endregion #endregion
#region Load Solution Projects Thread
public bool LoadSolutionProjectsThreadRunning {
get { return false; }
}
public event EventHandler LoadSolutionProjectsThreadStarted;
public event EventHandler LoadSolutionProjectsThreadEnded;
#endregion
#region Compilation #region Compilation
public ICompilation GetCompilation(IProject project) public ICompilation GetCompilation(IProject project)
{ {

Loading…
Cancel
Save