Browse Source

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

Added exception handling to CSharpSemanticHighlighter.
newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
158219a218
  1. 10
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs
  2. 3
      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

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

@ -36,6 +36,7 @@ namespace CSharpBinding @@ -36,6 +36,7 @@ namespace CSharpBinding
List<IDocumentLine> invalidLines = new List<IDocumentLine>();
List<CachedLine> cachedLines = new List<CachedLine>();
bool hasCrashed;
int lineNumber;
HighlightedLine line;
@ -184,6 +185,10 @@ namespace CSharpBinding @@ -184,6 +185,10 @@ namespace CSharpBinding
public HighlightedLine HighlightLine(int 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;
CachedLine cachedLine = null;
for (int i = 0; i < cachedLines.Count; i++) {
@ -225,7 +230,12 @@ namespace CSharpBinding @@ -225,7 +230,12 @@ namespace CSharpBinding
HighlightedLine line = new HighlightedLine(textEditor.Document, documentLine);
this.line = line;
this.lineNumber = lineNumber;
try {
parseInfo.CompilationUnit.AcceptVisitor(this);
} catch (Exception ex) {
hasCrashed = true;
throw new ApplicationException("Error highlighting line " + lineNumber, ex);
}
this.line = null;
this.resolver = null;
Debug.WriteLine("Semantic highlighting for line {0} - added {1} sections", lineNumber, line.Sections.Count);

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

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

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

@ -15,7 +15,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -15,7 +15,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring
/// </summary>
public class Reference : SearchResultMatch
{
DomRegion region;
ResolveResult resolveResult;
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 @@ -84,15 +84,6 @@ namespace ICSharpCode.SharpDevelop.Parser
}
#endregion
#region Load Solution Projects Thread
public bool LoadSolutionProjectsThreadRunning {
get { return false; }
}
public event EventHandler LoadSolutionProjectsThreadStarted;
public event EventHandler LoadSolutionProjectsThreadEnded;
#endregion
#region Compilation
public ICompilation GetCompilation(IProject project)
{

Loading…
Cancel
Save