[Monodevelop-patches-list] r1467 - in trunk/MonoDevelop/src: AddIns/BackendBindings/CSharpBinding/Parser AddIns/DisplayBindings/SourceEditor/Gui Libraries/SharpRefactory/src/Parser/generated Main/Base/Internal/Parser Main/Base/Internal/Parser/Implementations

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Fri Apr 16 03:18:43 EDT 2004


Author: tberman
Date: 2004-04-16 03:18:42 -0400 (Fri, 16 Apr 2004)
New Revision: 1467

Modified:
   trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorWidget.cs
   trunk/MonoDevelop/src/Libraries/SharpRefactory/src/Parser/generated/Error.cs
   trunk/MonoDevelop/src/Main/Base/Internal/Parser/ICompilationUnitBase.cs
   trunk/MonoDevelop/src/Main/Base/Internal/Parser/Implementations/AbstractCompilationUnit.cs
Log:
working a bit on setting up underlined parsing errors, it doesnt exactly work yet though, so the event hook is commented out for now. will finish later


Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs	2004-04-16 03:18:32 UTC (rev 1466)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs	2004-04-16 07:18:42 UTC (rev 1467)
@@ -84,6 +84,7 @@
 			visitor.Visit(p.compilationUnit, null);
 			visitor.Cu.ErrorsDuringCompile = p.Errors.count > 0;
 			visitor.Cu.Tag = p.compilationUnit;
+			visitor.Cu.ErrorOutput = p.Errors.ErrorOutput;
 			RetrieveRegions(visitor.Cu, lexer.SpecialTracker);
 			return visitor.Cu;
 		}

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs	2004-04-16 03:18:32 UTC (rev 1466)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorBuffer.cs	2004-04-16 07:18:42 UTC (rev 1467)
@@ -8,6 +8,7 @@
 using MonoDevelop.Core.Services;
 using MonoDevelop.Services;
 using MonoDevelop.Core.AddIns.Codons;
+using MonoDevelop.Internal.Parser;
 
 using System;
 using System.IO;
@@ -63,9 +64,29 @@
 		SourceLanguagesManager slm = new SourceLanguagesManager ();
 		TextTag markup;
 		TextTag complete_ahead;
+		TextTag compilation_error;
 		TextMark complete_end;
 		AtomicUndo atomic_undo;
+		SourceEditorView view;
+
+		public SourceEditorView View
+		{
+			get {
+				return view;
+			}
+			set {
+				view = value;
+			}
+		}
 		
+		
+		IParserService ps = (IParserService)ServiceManager.Services.GetService (typeof (IParserService));
+
+		public SourceEditorBuffer (SourceEditorView view) : this ()
+		{
+			this.view = view;
+		}
+		
 		public SourceEditorBuffer () : base (new SourceTagTable ())
 		{
 			markup = new TextTag ("breakpoint");
@@ -74,8 +95,52 @@
 			complete_ahead = new TextTag ("complete_ahead");
 			complete_ahead.Foreground = "grey";
 			TagTable.Add (complete_ahead);
+			compilation_error = new TextTag ("compilation_error");
+			compilation_error.Underline = Pango.Underline.Single;
+			TagTable.Add (compilation_error);
 			complete_end = CreateMark (null, StartIter, true);
+			//ps.ParseInformationChanged += new ParseInformationEventHandler (parseChanged);
 		}
+			int[] point = new int [2];
+			
+		public void parseChanged (object o, ParseInformationEventArgs e)
+		{
+			if (view != null) {
+				if (view.ParentEditor.DisplayBinding.ContentName == e.FileName){
+					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;
+							Console.WriteLine ("line: {0} col: {1}", pieces[2], pieces[4]);
+							point[0] = Convert.ToInt32 (pieces[2]) - 1;
+							point[1] = Convert.ToInt32 (pieces[4]);
+							GLib.Idle.Add (new GLib.IdleHandler (addMarkup));
+						}
+					}
+					else {
+						//Clear errors
+					}
+				}
+			}
+		}
+
+		bool addMarkup ()
+		{
+			if (point[0] == 0 && point[1] == 0)
+				return false;
+
+			Console.WriteLine ("line: {0} col: {1}", point[0], point[1]);
+			TextIter start = GetIterAtLine (point[0]);
+			start.LineOffset = point[1];
+			Console.WriteLine (start.Char);
+			TextIter end = start;
+			end.ForwardToLineEnd ();
+			ApplyTag (compilation_error, start, end);
+			point[0] = 0;
+			point[1] = 0;
+			return false;
+		}		
 		
 		public void MarkupLine (int linenumber)
 		{
@@ -85,13 +150,13 @@
 			end_line.ForwardToLineEnd ();
 			ApplyTag (markup, begin_line, end_line);
 		}
-
+		
 		public void UnMarkupLine (int line)
 		{
 			ClearMarks (SourceMarkerType.ExecutionMark);
 			RemoveTag (markup, StartIter, EndIter);
 		}
-
+		
 		public void DropCompleteAhead ()
 		{
 			if (GetIterAtMark (complete_end).Offset == 0)
@@ -516,15 +581,21 @@
 
 		public char GetCharAt (int offset)
 		{
+			/*if (offset < 0)
+			  offset = 0;
+			  TextIter begin_iter = GetIterAtOffset (offset);
+			  TextIter next_iter = begin_iter;
+			  next_iter.ForwardChar ();
+			  string text = GetText (begin_iter, next_iter, true);
+			  if (text != null && text.Length >= 1)
+			  return text[0];*/
+			//New test implementation
 			if (offset < 0)
 				offset = 0;
-			TextIter begin_iter = GetIterAtOffset (offset);
-			TextIter next_iter = begin_iter;
-			next_iter.ForwardChar ();
-			string text = GetText (begin_iter, next_iter, true);
-			if (text != null && text.Length >= 1)
-				return text[0];
-			return ' ';
+			TextIter iter = GetIterAtOffset (offset);
+			if (iter.Equals (TextIter.Zero))
+				return ' ';
+			return iter.Char[0];
 		}
 
 		public string GetText (int start, int length)

Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorWidget.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorWidget.cs	2004-04-16 03:18:32 UTC (rev 1466)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorWidget.cs	2004-04-16 07:18:42 UTC (rev 1467)
@@ -29,6 +29,7 @@
 			Buffer = new SourceEditorBuffer ();	
 			View = new SourceEditorView (Buffer, this);
 			Buffer.Highlight = true;
+			Buffer.View = View;
 			
 			View.SetMarkerPixbuf ("SourceEditorBookmark", new Gdk.Pixbuf (drag_icon_xpm));
 			View.SetMarkerPixbuf ("ExecutionMark", new Gdk.Pixbuf ("../data/resources/icons/ExecutionMarker.png"));

Modified: trunk/MonoDevelop/src/Libraries/SharpRefactory/src/Parser/generated/Error.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/SharpRefactory/src/Parser/generated/Error.cs	2004-04-16 03:18:32 UTC (rev 1466)
+++ trunk/MonoDevelop/src/Libraries/SharpRefactory/src/Parser/generated/Error.cs	2004-04-16 07:18:42 UTC (rev 1467)
@@ -34,13 +34,13 @@
 	
 		void DefaultCodeError (int line, int col, int n)
 		{
-			errorText.Append(String.Format("-- line {0} col {1}: error {2}", line, col, n));
+			errorText.Append(String.Format("-- line {0} col {1} : error {2}", line, col, n));
 			errorText.Append("\n");
 			count++;
 		}
 	
 		void DefaultMsgError (int line, int col, string s) {
-			errorText.Append(String.Format("-- line {0} col {1}: {2}", line, col, s));
+			errorText.Append(String.Format("-- line {0} col {1} : {2}", line, col, s));
 			errorText.Append("\n");
 			count++;
 		}

Modified: trunk/MonoDevelop/src/Main/Base/Internal/Parser/ICompilationUnitBase.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Internal/Parser/ICompilationUnitBase.cs	2004-04-16 03:18:32 UTC (rev 1466)
+++ trunk/MonoDevelop/src/Main/Base/Internal/Parser/ICompilationUnitBase.cs	2004-04-16 07:18:42 UTC (rev 1467)
@@ -16,6 +16,11 @@
 			get;
 			set;
 		}
+
+		string ErrorOutput {
+			get;
+			set;
+		}
 		
 		object Tag {
 			get;

Modified: trunk/MonoDevelop/src/Main/Base/Internal/Parser/Implementations/AbstractCompilationUnit.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Internal/Parser/Implementations/AbstractCompilationUnit.cs	2004-04-16 03:18:32 UTC (rev 1466)
+++ trunk/MonoDevelop/src/Main/Base/Internal/Parser/Implementations/AbstractCompilationUnit.cs	2004-04-16 07:18:42 UTC (rev 1467)
@@ -43,6 +43,7 @@
 		protected bool errorsDuringCompile = false;
 		protected object tag               = null;
 		protected ArrayList foldingRegions = new ArrayList();
+		protected string erroroutput = String.Empty;
 		
 		public bool ErrorsDuringCompile {
 			get {
@@ -52,6 +53,15 @@
 				errorsDuringCompile = value;
 			}
 		}
+
+		public string ErrorOutput {
+			get {
+				return erroroutput;
+			}
+			set {
+				erroroutput = value;
+			}
+		}
 		
 		public object Tag {
 			get {




More information about the Monodevelop-patches-list mailing list