[Monodevelop-patches-list] r2219 - in trunk/MonoDevelop/Core/src: AddIns/BackendBindings/CSharpBinding AddIns/BackendBindings/CSharpBinding/Parser AddIns/DisplayBindings/SourceEditor AddIns/DisplayBindings/SourceEditor/Gui ICSharpCode.SharpRefactory ICSharpCode.SharpRefactory/src/Parser/generated MonoDevelop.Base MonoDevelop.Base/Internal/Parser MonoDevelop.Base/Internal/Parser/Implementations
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Tue Feb 1 00:54:44 EST 2005
Author: jluke
Date: 2005-02-01 00:54:44 -0500 (Tue, 01 Feb 2005)
New Revision: 2219
Modified:
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/ChangeLog
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs
trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs
trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Makefile.am
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/Error.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/ICompilationUnitBase.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/Implementations/AbstractCompilationUnit.cs
Log:
change the parser errors to be accessed easier
and get closer to displaying errors better
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/ChangeLog 2005-02-01 04:21:19 UTC (rev 2218)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/ChangeLog 2005-02-01 05:54:44 UTC (rev 2219)
@@ -1,3 +1,7 @@
+2005-02-01 John Luke <john.luke at gmail.com>
+
+ * Parser/Parser.cs: use ErrorInfo
+
2005-01-28 John Luke <john.luke at gmail.com>
* Parser/Resolver.cs (IsAccessible):
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs 2005-02-01 04:21:19 UTC (rev 2218)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs 2005-02-01 05:54:44 UTC (rev 2219)
@@ -98,7 +98,7 @@
visitor.Visit(p.compilationUnit, null);
visitor.Cu.ErrorsDuringCompile = p.Errors.count > 0;
visitor.Cu.Tag = p.compilationUnit;
- visitor.Cu.ErrorOutput = p.Errors.ErrorOutput;
+ visitor.Cu.ErrorInformation = p.Errors.ErrorInformation;
RetrieveRegions(visitor.Cu, lexer.SpecialTracker);
foreach (IClass c in visitor.Cu.Classes)
c.Region.FileName = fileName;
Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog 2005-02-01 04:21:19 UTC (rev 2218)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/ChangeLog 2005-02-01 05:54:44 UTC (rev 2219)
@@ -1,3 +1,8 @@
+2005-02-01 John Luke <john.luke at gmail.com>
+
+ * Gui.SourceEditorBuffer.cs: use ErrorInfo
+ and error underline improvements
+
2005-01-31 John Luke <john.luke at gmail.com>
* EditorBindings.glade:
Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs 2005-02-01 04:21:19 UTC (rev 2218)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs 2005-02-01 05:54:44 UTC (rev 2219)
@@ -15,6 +15,7 @@
using System.Collections;
using System.Runtime.InteropServices;
+using ICSharpCode.SharpRefactory.Parser;
using GtkSourceView;
namespace MonoDevelop.SourceEditor.Gui
@@ -74,7 +75,6 @@
SourceEditorView view;
int highlightLine = -1;
bool underlineErrors = true;
- ArrayList points;
IParserService ps = (IParserService)ServiceManager.GetService (typeof (IParserService));
@@ -90,7 +90,6 @@
underlineErrors = value;
/* still too broken to leave on
if (underlineErrors) {
- points = new ArrayList ();
ps.ParseInformationChanged += (ParseInformationEventHandler) Runtime.DispatchService.GuiDispatch (new ParseInformationEventHandler (ParseChanged));
}
else {
@@ -122,48 +121,39 @@
TagTable.Add (highlightLineTag);
}
- public void ParseChanged (object o, ParseInformationEventArgs e)
+ void ParseChanged (object o, ParseInformationEventArgs e)
{
if (view != null) {
if (view.ParentEditor.DisplayBinding.ContentName == e.FileName) {
+
+ RemoveTag (compilation_error, StartIter, EndIter);
+
if (e.ParseInformation.MostRecentCompilationUnit.ErrorsDuringCompile) {
- string[] errors = e.ParseInformation.MostRecentCompilationUnit.ErrorOutput.Split ('\n');
- foreach (string error in errors) {
- string[] pieces = error.Split (' ');
- if (pieces.Length == 1)
- continue;
- int[] point = new int[2];
- point[0] = Convert.ToInt32 (pieces[2]) - 1;
- point[1] = Convert.ToInt32 (pieces[4]) - 1;
- points.Add (point);
+ ErrorInfo[] errors = e.ParseInformation.MostRecentCompilationUnit.ErrorInformation;
+ foreach (ErrorInfo error in errors) {
+ // adjust to 0 base
+ DrawError (error.Line - 1, error.Column - 1);
}
}
- else {
- points.Clear ();
- }
- DrawErrors ();
}
}
}
- bool DrawErrors ()
+ // FIXME: underlines under keywords get ignored
+ void DrawError (int line, int column)
{
- // FIXME: clear old ones nicer
- RemoveTag (compilation_error, StartIter, EndIter);
- if (!underlineErrors)
- return false;
+ //Console.WriteLine ("error at: {0} {1}", line, column);
+ TextIter start = GetIterAtLine (line);
+ if (column < start.CharsInLine)
+ start.LineOffset = column;
- foreach (int[] point in points) {
- //Console.WriteLine ("Error is line: {0} col: {1}", point[0], point[1]);
- // FIXME: maybe we can be more precise
- TextIter start = GetIterAtLineOffset (point[0], point[1]);
- TextIter end = start;
+ TextIter end = start;
+ if (!end.EndsLine ())
end.ForwardToLineEnd ();
- ApplyTag (compilation_error, start, end);
- }
- // keep it running
- return true;
+ // FIXME: we can either skip or go backwards
+ if (GetText (start, end, false).Trim () != "")
+ ApplyTag (compilation_error, start, end);
}
public void MarkupLine (int linenumber)
Modified: trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Makefile.am 2005-02-01 04:21:19 UTC (rev 2218)
+++ trunk/MonoDevelop/Core/src/AddIns/DisplayBindings/SourceEditor/Makefile.am 2005-02-01 05:54:44 UTC (rev 2219)
@@ -80,6 +80,7 @@
/r:$(top_builddir)/build/bin/MonoDevelop.Base.dll \
/r:$(top_builddir)/build/bin/MonoDevelop.Gui.Utils.dll \
/r:$(top_builddir)/build/bin/MonoDevelop.Gui.Widgets.dll \
+ /r:$(top_builddir)/build/bin/ICSharpCode.SharpRefactory.dll \
$(GTK_SHARP_LIBS) \
$(GNOME_VFS_SHARP_LIBS) \
$(GLADE_SHARP_LIBS) \
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog 2005-02-01 04:21:19 UTC (rev 2218)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog 2005-02-01 05:54:44 UTC (rev 2219)
@@ -1,5 +1,11 @@
2005-01-31 John Luke <john.luke at gmail.com>
+ * src/Parser/generated/Error.cs: lets not
+ force people to parse the error message
+ instead use an ErrorInfo struct
+
+2005-01-31 John Luke <john.luke at gmail.com>
+
* src/Lexer/Lexer.cs:
* src/Parser/generated/cs.ATG:
* src/Parser/generated/Parser.cs:
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/Error.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/Error.cs 2005-02-01 04:21:19 UTC (rev 2218)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/Error.cs 2005-02-01 05:54:44 UTC (rev 2219)
@@ -1,48 +1,63 @@
using System;
-using System.Text;
+using System.Collections;
namespace ICSharpCode.SharpRefactory.Parser
{
public delegate void ErrorCodeProc(int line, int col, int n);
public delegate void ErrorMsgProc(int line, int col, string msg);
+
+ public struct ErrorInfo
+ {
+ public int Column;
+ public int Line;
+ public string Message;
+
+ public ErrorInfo (int line, int column, string message)
+ {
+ Column = column;
+ Line = line;
+ Message = message;
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("-- line {0} col {1} : {2}", Line, Column, Message);
+ }
+ }
public class Errors
{
- public int count = 0; // number of errors detected
+ public int count = 0; // number of errors detected
public ErrorCodeProc SynErr;
public ErrorCodeProc SemErr;
public ErrorMsgProc Error;
- StringBuilder errorText = new StringBuilder();
-
- public string ErrorOutput {
- get {
- return errorText.ToString();
- }
- }
+ ArrayList errorInfo;
+
public Errors()
{
+ errorInfo = new ArrayList ();
SynErr = new ErrorCodeProc(DefaultCodeError); // syntactic errors
SemErr = new ErrorCodeProc(DefaultCodeError); // semantic errors
Error = new ErrorMsgProc(DefaultMsgError); // user defined string based errors
}
+
+ public ErrorInfo[] ErrorInformation
+ {
+ get {
+ return (ErrorInfo[]) errorInfo.ToArray (typeof (ErrorInfo));
+ }
+ }
- // public void Exception (string s)
- // {
- // Console.WriteLine(s);
- // System.Environment.Exit(0);
- // }
-
void DefaultCodeError (int line, int col, int n)
{
- errorText.Append(String.Format("-- line {0} col {1} : error {2}", line, col, n));
- errorText.Append("\n");
+ errorInfo.Add (new ErrorInfo (line, col, String.Format ("error {0}", n)));
count++;
}
void DefaultMsgError (int line, int col, string s) {
- errorText.Append(String.Format("-- line {0} col {1} : {2}", line, col, s));
- errorText.Append("\n");
+ errorInfo.Add (new ErrorInfo (line, col, s));
count++;
}
- } // Errors
+ }
}
+
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-02-01 04:21:19 UTC (rev 2218)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-02-01 05:54:44 UTC (rev 2219)
@@ -1,3 +1,8 @@
+2005-02-02 John Luke <john.luke at gmail.com>
+
+ * Parser/ICompilationUnitBase.cs:
+ * Parser/Implementations/AbstractCompilationUnit.cs: adjust to ErrorInfo
+
2005-01-31 Lluis Sanchez Gual <lluis at novell.com>
* Services/Project/DefaultProjectService.cs: In BuildActiveCombine(),
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/ICompilationUnitBase.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/ICompilationUnitBase.cs 2005-02-01 04:21:19 UTC (rev 2218)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/ICompilationUnitBase.cs 2005-02-01 05:54:44 UTC (rev 2219)
@@ -7,6 +7,7 @@
using System.Collections;
using System.Collections.Specialized;
+using ICSharpCode.SharpRefactory.Parser;
namespace MonoDevelop.Internal.Parser
{
@@ -17,7 +18,7 @@
set;
}
- string ErrorOutput {
+ ErrorInfo[] ErrorInformation {
get;
set;
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/Implementations/AbstractCompilationUnit.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/Implementations/AbstractCompilationUnit.cs 2005-02-01 04:21:19 UTC (rev 2218)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/Implementations/AbstractCompilationUnit.cs 2005-02-01 05:54:44 UTC (rev 2219)
@@ -7,6 +7,7 @@
using System;
using System.Collections;
using System.Collections.Specialized;
+using ICSharpCode.SharpRefactory.Parser;
namespace MonoDevelop.Internal.Parser
{
@@ -43,7 +44,7 @@
protected bool errorsDuringCompile = false;
protected object tag = null;
protected ArrayList foldingRegions = new ArrayList();
- protected string erroroutput = String.Empty;
+ protected ErrorInfo[] errorInfo;
public bool ErrorsDuringCompile {
get {
@@ -54,12 +55,12 @@
}
}
- public string ErrorOutput {
+ public ErrorInfo[] ErrorInformation {
get {
- return erroroutput;
+ return errorInfo;
}
set {
- erroroutput = value;
+ errorInfo = value;
}
}
More information about the Monodevelop-patches-list
mailing list