[MonoDevelop] Logging by type.

Peter Johanson latexer at gentoo.org
Sat Aug 6 01:37:41 EDT 2005


Hey all,

I was getting really tired of commenting and uncommenting a
gazillion things when working on the boo parsing code, so i decided to
do a little loggin' love.

Attached is a patch that lets you send logging messages and have them
associated by type to a different log4net log. The end result is, one
can modify the MonoDevelop.exe.config to dis/enable seeing all sorts of
log entries, based on fairly configurable filters.

The first patch implements the API, and gives a small example of what
can be done by getting the ResourceManager using the new API, and then
modifying the MonoDevelop.exe.config to so that all those d*mn,
"WARNING can't find stock blah blah" messages no longer show.

The second patch shows the changes for boo that'd make my life easier
when debugging those sorts of things.

Thoughts?

-pete

PS - The one change that might make sense is to take a first parameter
of a string instead of a type, which would allow arbitrarily named log4net logs,
not just those named after types.

PPS - I know there was some discussion of these sorts of things not so long ago,
and I've flagrantly *not* searched back in my logs to see the outcome. I'll do
that after sending this email. (:

-- 
Peter Johanson
<latexer at gentoo.org>
-------------- next part --------------
Index: Core/src/MonoDevelop.Base/Services/DefaultLoggingService.cs
===================================================================
--- Core/src/MonoDevelop.Base/Services/DefaultLoggingService.cs	(revision 2710)
+++ Core/src/MonoDevelop.Base/Services/DefaultLoggingService.cs	(working copy)
@@ -132,6 +132,12 @@
 			GetLogger().Debug (message, t);
 			OnLogAppended ("Debug", message + t.ToString());
 		}
+
+		public void Debug (Type type, object message, Exception t)
+		{
+			GetLogger(type).Debug (message, t);
+			OnLogAppended ("Debug", message + t.ToString());
+		}
 		
 		public void Info (object message, Exception t)
 		{
@@ -139,17 +145,35 @@
 			OnLogAppended ("Info", message + t.ToString());
 		}
 		
+		public void Info (Type type, object message, Exception t)
+		{
+			GetLogger(type).Info (message, t);
+			OnLogAppended ("Info", message + t.ToString());
+		}
+		
 		public void Warn (object message, Exception t)
 		{
 			GetLogger().Warn (message, t);
 			OnLogAppended ("Warn", message + t.ToString());
 		}
 
+		public void Warn (Type type, object message, Exception t)
+		{
+			GetLogger(type).Warn (message, t);
+			OnLogAppended ("Warn", message + t.ToString());
+		}
+
 		public void Error (object message, Exception t)
 		{
 			GetLogger().Error (message, t);
 			OnLogAppended ("Error", message + t.ToString());
 		}
+
+		public void Error (Type type, object message, Exception t)
+		{
+			GetLogger(type).Error (message, t);
+			OnLogAppended ("Error", message + t.ToString());
+		}
 		
 		public void Fatal (object message, Exception t)
 		{
@@ -157,6 +181,12 @@
 			OnLogAppended ("Fatal", message + t.ToString());
 		}
 
+		public void Fatal (Type type, object message, Exception t)
+		{
+			GetLogger(type).Fatal (message, t);
+			OnLogAppended ("Fatal", message + t.ToString());
+		}
+
 		public void DebugFormat (string format, params object[] args)
 		{
 			GetLogger().DebugFormat (format, args);
@@ -223,17 +253,35 @@
 			OnLogAppended ("Debug", String.Format(provider, format, args));
 		}
 		
+		public void DebugFormat(Type type, IFormatProvider provider, string format, params object[] args)
+		{
+			GetLogger(type).DebugFormat (provider, format, args);
+			OnLogAppended ("Debug", String.Format(provider, format, args));
+		}
+		
 		public void InfoFormat(IFormatProvider provider, string format, params object[] args)
 		{
 			GetLogger().InfoFormat (provider, format, args);
 			OnLogAppended ("Info", String.Format(provider, format, args));
 		}
 
+		public void InfoFormat(Type type, IFormatProvider provider, string format, params object[] args)
+		{
+			GetLogger(type).InfoFormat (provider, format, args);
+			OnLogAppended ("Info", String.Format(provider, format, args));
+		}
+
 		public void WarnFormat(IFormatProvider provider, string format, params object[] args)
 		{
 			GetLogger().WarnFormat (provider, format, args);
 			OnLogAppended ("Warn", String.Format(provider, format, args));
 		}
+		
+		public void WarnFormat(Type type, IFormatProvider provider, string format, params object[] args)
+		{
+			GetLogger(type).WarnFormat (provider, format, args);
+			OnLogAppended ("Warn", String.Format(provider, format, args));
+		}
 
 		public void ErrorFormat(IFormatProvider provider, string format, params object[] args)
 		{
@@ -241,12 +289,24 @@
 			OnLogAppended ("Error", String.Format(provider, format, args));
 		}
 
+		public void ErrorFormat(Type type, IFormatProvider provider, string format, params object[] args)
+		{
+			GetLogger(type).ErrorFormat (provider, format, args);
+			OnLogAppended ("Error", String.Format(provider, format, args));
+		}
+
 		public void FatalFormat(IFormatProvider provider, string format, params object[] args)
 		{
 			GetLogger().FatalFormat (provider, format, args);
 			OnLogAppended ("Fatal", String.Format(provider, format, args));
 		}
 
+		public void FatalFormat(Type type, IFormatProvider provider, string format, params object[] args)
+		{
+			GetLogger(type).FatalFormat (provider, format, args);
+			OnLogAppended ("Fatal", String.Format(provider, format, args));
+		}
+
 		public void OnLogAppended(string level, string message)
 		{
 			if (LogAppended != null) {
Index: Core/src/MonoDevelop.Base/Services/ILoggingService.cs
===================================================================
--- Core/src/MonoDevelop.Base/Services/ILoggingService.cs	(revision 2710)
+++ Core/src/MonoDevelop.Base/Services/ILoggingService.cs	(working copy)
@@ -20,6 +20,12 @@
 		void Warn(object message);
 		void Error(object message);
 		void Fatal(object message);
+		
+		void Debug(Type type, object message);
+		void Info(Type type, object message);
+		void Warn(Type type, object message);
+		void Error(Type type, object message);
+		void Fatal(Type type, object message);
 
 		/* Log a message object and exception */
 		void Debug(object message, Exception t);
@@ -28,6 +34,12 @@
 		void Error(object message, Exception t);
 		void Fatal(object message, Exception t);
 
+		void Debug(Type type, object message, Exception t);
+		void Info(Type type, object message, Exception t);
+		void Warn(Type type, object message, Exception t);
+		void Error(Type type, object message, Exception t);
+		void Fatal(Type type, object message, Exception t);
+
 		/* Log a message string using the System.String.Format syntax */
 		void DebugFormat(string format, params object[] args);
 		void InfoFormat(string format, params object[] args);
@@ -35,6 +47,12 @@
 		void ErrorFormat(string format, params object[] args);
 		void FatalFormat(string format, params object[] args);
 
+		void DebugFormat(Type type, string format, params object[] args);
+		void InfoFormat(Type type, string format, params object[] args);
+		void WarnFormat(Type type, string format, params object[] args);
+		void ErrorFormat(Type type, string format, params object[] args);
+		void FatalFormat(Type type, string format, params object[] args);
+
 		/* Log a message string using the System.String.Format syntax */
 		void DebugFormat(IFormatProvider provider, string format, params object[] args);
 		void InfoFormat(IFormatProvider provider, string format, params object[] args);
@@ -42,6 +60,12 @@
 		void ErrorFormat(IFormatProvider provider, string format, params object[] args);
 		void FatalFormat(IFormatProvider provider, string format, params object[] args);
 
+		void DebugFormat(Type type, IFormatProvider provider, string format, params object[] args);
+		void InfoFormat(Type type, IFormatProvider provider, string format, params object[] args);
+		void WarnFormat(Type type, IFormatProvider provider, string format, params object[] args);
+		void ErrorFormat(Type type, IFormatProvider provider, string format, params object[] args);
+		void FatalFormat(Type type, IFormatProvider provider, string format, params object[] args);
+
 		event LogAppendedHandler LogAppended;
 	}
 
Index: Core/src/MonoDevelop.Base/Services/ResourceService.cs
===================================================================
--- Core/src/MonoDevelop.Base/Services/ResourceService.cs	(revision 2710)
+++ Core/src/MonoDevelop.Base/Services/ResourceService.cs	(working copy)
@@ -213,7 +213,7 @@
 			catch (GLib.GException ex) {
 				// just discard the exception, the icon simply can't be
 				// loaded
-				Runtime.LoggingService.InfoFormat("Warning: can't load " + filename +
+				Runtime.LoggingService.Info(typeof(ResourceService), "Warning: can't load " + filename +
 				                   " icon file");
 			}
 		}
@@ -235,7 +235,7 @@
 			if (s != null)
 				return s;
 			
-			Runtime.LoggingService.InfoFormat("WARNING Could not find stock {0}", filename);
+			Runtime.LoggingService.InfoFormat(typeof(ResourceService), "WARNING Could not find stock {0}", filename);
 			
 			return filename;
 		}
Index: Core/src/MonoDevelop.Startup/app.config
===================================================================
--- Core/src/MonoDevelop.Startup/app.config	(revision 2710)
+++ Core/src/MonoDevelop.Startup/app.config	(working copy)
@@ -8,6 +8,15 @@
 			<layout type="log4net.Layout.PatternLayout">
 				<conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
 			</layout>
+
+			<filter type="log4net.Filter.LoggerMatchFilter">
+				<loggerToMatch value="MonoDevelop.Core.Services.ResourceService" />
+				<acceptOnMatch value="false" />
+			</filter>
+			<filter type="log4net.Filter.LoggerMatchFilter">
+				<loggerToMatch value="BooBinding.Parser" />
+				<acceptOnMatch value="false" />
+			</filter>
 		</appender>
 		<root>
 			<priority value="ALL" />
-------------- next part --------------
Index: Extras/BooBinding/Parser/ExpressionTypeVisitor.boo
===================================================================
--- Extras/BooBinding/Parser/ExpressionTypeVisitor.boo	(revision 2710)
+++ Extras/BooBinding/Parser/ExpressionTypeVisitor.boo	(working copy)
@@ -32,9 +32,15 @@
 
 class ExpressionTypeVisitor(DepthFirstVisitor):
 	protected override def OnError(node as Node, error as Exception):
-		//BooParser.ShowException(error)
+		Error (error.ToString ())
 		super(node, error)
 	
+	private def Log (message):
+		BooParser.Log (self.GetType (), message)
+	
+	private def Error (message):
+		BooParser.Error (self.GetType (), message)
+
 	[Property(ReturnType)]
 	_returnType as IReturnType
 	
@@ -71,9 +77,9 @@
 	
 	private def Debug(node):
 		if node == null:
-			print "-- null --"
+			Log ("-- null --")
 		else:
-			print "${node.ToString()} - ${node.GetType().FullName}"
+			Log ("${node.ToString()} - ${node.GetType().FullName}")
 	
 	override def OnCallableBlockExpression(node as CallableBlockExpression):
 		Debug(node)
@@ -106,7 +112,7 @@
 	private def ProcessMethod(node as MethodInvocationExpression, name as string, c as IClass) as bool:
 		return false if c == null
 		possibleOverloads = FindMethods(c, name, node.Arguments.Count)
-		//print "found ${possibleOverloads.Count} overloads (multiple overloads not supported yet)"
+		Log ("found ${possibleOverloads.Count} overloads (multiple overloads not supported yet)")
 		if possibleOverloads.Count >= 1:
 			SetReturnType(cast(IMethod, possibleOverloads[0]).ReturnType)
 			return true
Index: Extras/BooBinding/Parser/Resolver.boo
===================================================================
--- Extras/BooBinding/Parser/Resolver.boo	(revision 2710)
+++ Extras/BooBinding/Parser/Resolver.boo	(working copy)
@@ -80,7 +80,7 @@
 
 	#region Helper methods
 	private def ResolveCurrentMember() as IMember:
-		print "Getting current method... caretLine = ${_caretLine}, caretColumn = ${_caretColumn}"
+		Log ("Getting current method... caretLine = ${_caretLine}, caretColumn = ${_caretColumn}")
 		return null if _callingClass == null
 		best as IMember = null
 		line = 0
@@ -120,9 +120,9 @@
 				return para.ReturnType if para.Name == name
 			if method.Node != null and method.Node.Body != null:
 				varLookup = VariableLookupVisitor(Resolver: self, LookFor: name)
-				print "Visiting method body..."
+				Log ("Visiting method body...")
 				varLookup.Visit(method.Node.Body)
-				print "Finished visiting method body!"
+				Log ("Finished visiting method body!")
 				return varLookup.ReturnType
 		elif member isa Property:
 			property as Property = member
@@ -133,16 +133,16 @@
 			if property.Node != null:
 				varLookup = VariableLookupVisitor(Resolver: self, LookFor: name)
 				// TODO: visit only the correct body
-				print "Visiting property body..."
+				Log ("Visiting property body...")
 				varLookup.Visit(property.Node.Getter) unless property.Node.Getter == null
 				varLookup.Visit(property.Node.Setter) unless property.Node.Setter == null
-				print "Finished visiting property body!"
+				Log ("Finished visiting property body!")
 				/*
 				if varLookup.ReturnType is null:
-					print "null return type!"
+					Log ("null return type!")
 					return ReturnType("System.Object")
 					*/
-				print "ReturnType: ${varLookup.ReturnType}"
+				Log ("ReturnType: ${varLookup.ReturnType}")
 				return varLookup.ReturnType
 		return null
 	
@@ -252,7 +252,7 @@
 		cu = parseInfo.MostRecentCompilationUnit as CompilationUnit
 		_compilationUnit = cu
 		if _compilationUnit == null:
-			print "BooResolver: No parse information!"
+			Log ("BooResolver: No parse information!")
 			return false
 		_callingClass = GetInnermostClass(cu)
 		if _callingClass == null:
@@ -298,10 +298,11 @@
 			
 			expr = Boo.Lang.Parser.BooParser.ParseExpression("expression", expression)
 			return null if expr isa AST.IntegerLiteralExpression
+			Log ("Using an expression type visitor!")
 			visitor = ExpressionTypeVisitor(Resolver : self)
 			visitor.Visit(expr)
 			retType = visitor.ReturnType
-			//Print ("result", retType)
+			Log ("result: ${retType}")
 			if visitor.ReturnClass != null:
 				returnClass = visitor.ReturnClass
 			elif retType != null:
@@ -328,16 +329,16 @@
 		   (_showStatic and not ((member.Modifiers & ModifierEnum.Static) == ModifierEnum.Static))):
 			return false
 		
-//		print("Testing Accessibility")
+		Log ("Testing Accessibility")
 		return IsAccessible(c, member)
 	
 	def IsAccessible(c as IClass, member as IDecoration) as bool:
-//		print("member.Modifiers = " + member.Modifiers)
+		Log ("member.Modifiers = " + member.Modifiers)
 		if ((member.Modifiers & ModifierEnum.Internal) == ModifierEnum.Internal):
 			return true
 
 		if ((member.Modifiers & ModifierEnum.Public) == ModifierEnum.Public):
-//			print("IsAccessible")
+			Log ("IsAccessible")
 			return true
 
 		if (member.Modifiers & ModifierEnum.Protected) == ModifierEnum.Protected:
@@ -378,47 +379,47 @@
 	
 	def ListMembers(members as ArrayList, curType as IClass, showStatic as bool) as ArrayList:
 		_showStatic = showStatic
-//		print("LIST MEMBERS!!!")
-//		print("_showStatic = " + _showStatic)
-//		print(curType.InnerClasses.Count + " classes")
-//		print(curType.Properties.Count + " properties")
-//		print(curType.Methods.Count + " methods")
-//		print(curType.Events.Count + " events")
-//		print(curType.Fields.Count + " fields")
+		Log ("LIST MEMBERS!!!")
+		Log ("_showStatic = " + _showStatic)
+		Log (curType.InnerClasses.Count + " classes")
+		Log (curType.Properties.Count + " properties")
+		Log (curType.Methods.Count + " methods")
+		Log (curType.Events.Count + " events")
+		Log (curType.Fields.Count + " fields")
 		if _showStatic:
 			for c as IClass in curType.InnerClasses:
 				if IsAccessible(curType, c):
 					members.Add(c)
-//					print("Member added")
+					Log ("Member added")
 
 		for p as IProperty in curType.Properties:
 			if (MustBeShowen(curType, p)):
 				members.Add(p)
-//				print("Member added")
+				Log ("Member added")
 
-//		print("ADDING METHODS!!!")
+		Log ("ADDING METHODS!!!")
 		for m as IMethod in curType.Methods:
-//			print("Method : " + m)
+			Log ("Method : " + m)
 			if (MustBeShowen(curType, m)):
 				members.Add(m)
-//				print("Member added")
+				Log ("Member added")
 
 		for e as IEvent in curType.Events:
 			if (MustBeShowen(curType, e)):
 				members.Add(e)
-//				print("Member added")
+				Log ("Member added")
 
 		for f as IField in curType.Fields:
 			if (MustBeShowen(curType, f)):
 				members.Add(f)
-//				print("Member added")
+				Log ("Member added")
 			else:
 				//// enum fields must be shown here if present
 				if (curType.ClassType == ClassType.Enum):
 					members.Add(f) if (IsAccessible(curType,f))
-//					print("Member {0} added", f.FullyQualifiedName)
+					Log ("Member ${f.FullyQualifiedName} added")
 
-//		print("ClassType = " + curType.ClassType)
+		Log ("ClassType = " + curType.ClassType)
 		if (curType.ClassType == ClassType.Interface and not _showStatic):
 			for s as string in curType.BaseTypes:
 				baseClass = _parserService.GetClass (_project, s, true, true)
@@ -427,10 +428,10 @@
 		else:
 			baseClass = BaseClass(curType)
 			if (baseClass != null):
-//				print("Base Class = " + baseClass.FullyQualifiedName)
+				Log ("Base Class = " + baseClass.FullyQualifiedName)
 				ListMembers(members, baseClass, _showStatic)
 
-//		print("listing finished")
+		Log ("listing finished")
 		return members
 
 	def GetResolvedClass (cls as IClass) as IClass:
@@ -456,3 +457,10 @@
 				return GetInnermostClass(c)
 
 		return GetResolvedClass (curClass)
+
+	private def Log (message):
+		BooParser.Log (self.GetType(), message)
+	
+	private def Error (message):
+		BooParser.Error (self.GetType(), message)
+	
Index: Extras/BooBinding/Parser/ReturnType.boo
===================================================================
--- Extras/BooBinding/Parser/ReturnType.boo	(revision 2710)
+++ Extras/BooBinding/Parser/ReturnType.boo	(working copy)
@@ -65,12 +65,12 @@
 			if ar.ElementType isa AST.SimpleTypeReference:
 				super.FullyQualifiedName = cast(AST.SimpleTypeReference, ar.ElementType).Name
 			else:
-				print ("Got unknown TypeReference in Array: ${t}")
+				Error ("Got unknown TypeReference in Array: ${t}")
 				super.FullyQualifiedName = "<Error>"
 		else:
 			super.arrayDimensions = array(int, 0)
 			super.FullyQualifiedName = "<Error>"
-			print ("Got unknown TypeReference ${t}")
+			Error ("Got unknown TypeReference ${t}")
 	
 	static def CreateReturnType(node as AST.Node) as IReturnType:
 		if node isa AST.Field:
@@ -119,6 +119,9 @@
 	
 	override def ToString():
 		return "[${GetType().Name} Name=${FullyQualifiedName}]"
+	
+	private def Error (message):
+		BooParser.Error (self.GetType (), message)
 
 /////////////////////////////////////
 ///     Namespace Return Type     ///
Index: Extras/BooBinding/Parser/ExpressionFinder.boo
===================================================================
--- Extras/BooBinding/Parser/ExpressionFinder.boo	(revision 2710)
+++ Extras/BooBinding/Parser/ExpressionFinder.boo	(working copy)
@@ -49,7 +49,7 @@
 	
 	def FindExpression(inText as string, offset as int) as string:
 		return null if inText == null
-		print "Trying quickfind for ${offset}"
+		Log ("Trying quickfind for ${offset}")
 		// OK, first try a kind of "quick find"
 		i = offset + 1
 		forbidden = '"\'/#)]}'
@@ -62,7 +62,7 @@
 				start = i + 1
 				break
 			if forbidden.IndexOf(c) >= 0:
-				print "Quickfind failed: got ${c}"
+				Log ("Quickfind failed: got ${c}")
 				break
 			if Char.IsWhiteSpace(c):
 				if i > 6 and inText.Substring(i - 6, 6) == "import":
@@ -75,7 +75,7 @@
 		
 		inText = SimplifyCode(inText, offset)
 		if inText == null:
-			print 'SimplifyCode returned null (cursor is in comment/string???)'
+			Log ('SimplifyCode returned null (cursor is in comment/string???)')
 			return null
 		// inText now has no comments or string literals, but the same meaning in
 		// terms of the type system
@@ -124,7 +124,7 @@
 				wasSpace = false
 				b.Append(c)
 			i += 1
-		print "Expression is '${b}'"
+		Log ("Expression is '${b}'")
 		return b.ToString().Trim()
 	
 	// this method makes boo source code "simpler" by removing all comments
@@ -212,3 +212,6 @@
 			return inStringResult.ToString()
 		else:
 			return null
+	
+	private def Log (message):
+		BooParser.Log (self.GetType(), message)
Index: Extras/BooBinding/Parser/BooParser.boo
===================================================================
--- Extras/BooBinding/Parser/BooParser.boo	(revision 2710)
+++ Extras/BooBinding/Parser/BooParser.boo	(working copy)
@@ -65,7 +65,7 @@
 		return Parse(fileName, content)
 	
 	def Parse(fileName as string, fileContent as string) as ICompilationUnitBase:
-		//print "Parse ${fileName} with content"
+		Log ("Parse ${fileName} with content")
 		
 		cr = char('\r')
 		ln = char('\n')
@@ -128,8 +128,7 @@
 			// somehow the SD parser thread goes into an endless loop if this flag is not set
 			visitor.Cu.ErrorsDuringCompile = true //context.Errors.Count > 0
 		except e:
-			//ShowException(e)
-			print "ShowException ${e}"
+			Error (e.ToString ())
 
 		for c as IClass in visitor.Cu.Classes:
 			if c.Region is not null:
@@ -148,7 +147,7 @@
 		return visitor.Cu
 	
 	def CtrlSpace(parserService as IParserService, project as Project, caretLine as int, caretColumn as int, fileName as string) as ArrayList:
-		//print "Ctrl-Space (${caretLine}/${caretColumn})"
+		Log ("Ctrl-Space (${caretLine}/${caretColumn})")
 		try:
 			return Resolver(project).CtrlSpace(parserService, caretLine, caretColumn, fileName)
 		except e:
@@ -159,26 +158,29 @@
 		return Resolver (project).IsAsResolve (parserService, expression, caretLineNumber, caretColumn, fileName, fileContent)
 
 	def Resolve(parserService as IParserService, project as Project, expression as string, caretLineNumber as int, caretColumn as int, fileName as string, fileContent as string) as ResolveResult:
-		//print "Resolve ${expression} (${caretLineNumber}/${caretColumn})"
+		Log ("Resolve ${expression} (${caretLineNumber}/${caretColumn})")
 		try:
 			return Resolver(project).Resolve(parserService, expression, caretLineNumber, caretColumn, fileName, fileContent)
 		except e:
-			//ShowException(e)
+			Error (e.ToString ())
 			return null
 
 	def MonodocResolver(parserService as IParserService, project as Project, expression as string, caretLineNumber as int, caretColumn as int, fileName as string, fileContent as string) as string:
-		//print "MonodocResolver ${expression} (${caretLineNumber}/${caretColumn})"
+		Log ("MonodocResolver ${expression} (${caretLineNumber}/${caretColumn})")
 		try:
 			return Resolver(project).MonodocResolver(parserService, expression, caretLineNumber, caretColumn, fileName, fileContent)
 		except e:
 			//ShowException(e)
 			return null
 	
-	/*
-	static def ShowException(e as Exception):
-		//messageService as IMessageService = ServiceManager.Services.GetService(typeof(IMessageService))
-		//messageService.ShowError(e.ToString())
-		retur
-	*/
+	private def Log (message):
+		Log (self.GetType(), message)
 
+	private def Error (message):
+		Error (self.GetType(), message)
 
+	static def Log (type, message):
+		MonoDevelop.Services.Runtime.LoggingService.Debug (type, message)
+	
+	static def Error (type, message):
+		MonoDevelop.Services.Runtime.LoggingService.Error (type, message)
Index: Extras/BooBinding/Parser/Visitor.boo
===================================================================
--- Extras/BooBinding/Parser/Visitor.boo	(revision 2710)
+++ Extras/BooBinding/Parser/Visitor.boo	(working copy)
@@ -61,7 +61,7 @@
 		try:
 			Visit(CompileUnit)
 		except e:
-			print e.ToString()
+			Error (e.ToString ())
 			//msg as IMessageService = ServiceManager.Services.GetService(typeof(IMessageService))
 			//msg.ShowError(e)
 	
@@ -122,7 +122,7 @@
 		_cu.Usings.Add(u)
 	
 	override def OnCallableDefinition(node as AST.CallableDefinition):
-		//print "OnCallableDefinition: ${node.FullName}"
+		Log ("OnCallableDefinition: ${node.FullName}")
 		region = GetRegion(node)
 		modifier = GetModifier(node)
 		c = Class(_cu, ClassType.Delegate, modifier, region)
@@ -148,29 +148,31 @@
 		EnterTypeDefinition(node, ClassType.Enum)
 		return super(node)
 	
+	/*
 	override def EnterModule(node as AST.Module):
 		EnterTypeDefinition(node, ClassType.Class) unless _firstModule
 		_firstModule = false
 		return super(node)
+		*/
 	
 	private def EnterTypeDefinition(node as AST.TypeDefinition, classType as ClassType):
 		try:
-			//print "Enter ${node.GetType().Name} (${node.FullName})"
+			Log ("Enter ${node.GetType().Name} (${node.FullName})")
 			region = GetClientRegion(node)
 			modifier = GetModifier(node)
 			c = Class(_cu, classType, modifier, region)
 			c.FullyQualifiedName = node.FullName
 			c.Documentation = node.Documentation
 			if _currentClass.Count > 0:
-				cast(Class, _currentClass.Peek()).InnerClasses.Add(c)
+				cast(Class, _currentClass.Peek()).InnerClasses.Add(c) unless c.Name.StartsWith ("___")
 			else:
-				_cu.Classes.Add(c)
+				_cu.Classes.Add(c) unless c.Name.StartsWith ("___")
 			if node.BaseTypes != null:
 				for r as AST.SimpleTypeReference in node.BaseTypes:
 					c.BaseTypes.Add(r.Name)
 			_currentClass.Push(c)
 		except ex:
-			print ex.ToString()
+			Error (ex.ToString ())
 			raise
 	
 	override def LeaveClassDefinition(node as AST.ClassDefinition):
@@ -185,13 +187,15 @@
 		LeaveTypeDefinition(node)
 		super(node)
 	
+	/*
 	override def LeaveModule(node as AST.Module):
 		LeaveTypeDefinition(node) unless _currentClass.Count == 0
 		super(node)
+		*/
 	
 	private def LeaveTypeDefinition(node as AST.TypeDefinition):
 		c as Class = _currentClass.Pop()
-		//print "Leave ${node.GetType().Name} ${node.FullName} (Class = ${c.FullyQualifiedName})"
+		Log ("Leave ${node.GetType().Name} ${node.FullName} (Class = ${c.FullyQualifiedName})")
 		c.UpdateModifier()
 	
 	override def OnMethod(node as AST.Method):
@@ -202,7 +206,7 @@
 			method = GetMethod(node)
 			cast(Class, _currentClass.Peek()).Methods.Add(method)
 		except ex:
-			print ex.ToString()
+			Error (ex.ToString ())
 			raise
 	
 	private def GetMethod(node as AST.Method):
@@ -235,12 +239,12 @@
 			field.SetModifiers(ModifierEnum.Const | ModifierEnum.SpecialName)
 			c.Fields.Add(field)
 		except x:
-			print x
+			Error (x.ToString ())
 			raise
 	
 	override def OnField(node as AST.Field):
 		try:
-			//print "Field ${node.Name}"
+			Log ("Field ${node.Name}")
 			if node.Name.StartsWith("___"):
 				return
 
@@ -249,7 +253,7 @@
 			field.Documentation = node.Documentation
 			c.Fields.Add(field)
 		except ex:
-			print ex.ToString()
+			Error (ex.ToString ())
 			raise
 	
 	override def OnProperty(node as AST.Property):
@@ -272,7 +276,7 @@
 			property.Node = node
 			cast(Class, _currentClass.Peek()).Properties.Add(property)
 		except ex:
-			print ex.ToString()
+			Error (ex.ToString ())
 			raise
 	
 	override def OnEvent (node as AST.Event):
@@ -281,9 +285,15 @@
 			ev.Documentation = node.Documentation
 			cast(Class, _currentClass.Peek()).Events.Add(ev)
 		except ex:
-			print ex
+			Error (ex.ToString ())
 			raise
 	
+	private def Log (message):
+		BooParser.Log (self.GetType(), message)
+	
+	private def Error (message):
+		BooParser.Error (self.GetType(), message)
+	
 	/*
 	// TODO: Detect indexer method and add it as Indexer
 	override def Visit(indexerDeclaration as AST.IndexerDeclaration, data as object) as object:


More information about the Monodevelop-list mailing list