[Monodevelop-patches-list] r2732 - in trunk/MonoDevelop/Extras/BooBinding: . Parser
Peter Johanson <latexer@gentoo.org>
pjohanson at mono-cvs.ximian.com
Wed Aug 10 09:27:32 EDT 2005
Author: pjohanson
Date: 2005-08-10 09:27:32 -0400 (Wed, 10 Aug 2005)
New Revision: 2732
Modified:
trunk/MonoDevelop/Extras/BooBinding/ChangeLog
trunk/MonoDevelop/Extras/BooBinding/Parser/BooParser.boo
trunk/MonoDevelop/Extras/BooBinding/Parser/ExpressionFinder.boo
trunk/MonoDevelop/Extras/BooBinding/Parser/ExpressionTypeVisitor.boo
trunk/MonoDevelop/Extras/BooBinding/Parser/Resolver.boo
trunk/MonoDevelop/Extras/BooBinding/Parser/ReturnType.boo
trunk/MonoDevelop/Extras/BooBinding/Parser/VariableLookupVisitor.boo
trunk/MonoDevelop/Extras/BooBinding/Parser/Visitor.boo
Log:
Add better error reporting via logging by type.
Modified: trunk/MonoDevelop/Extras/BooBinding/ChangeLog
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/ChangeLog 2005-08-10 13:22:12 UTC (rev 2731)
+++ trunk/MonoDevelop/Extras/BooBinding/ChangeLog 2005-08-10 13:27:32 UTC (rev 2732)
@@ -1,3 +1,13 @@
+2005-08-10 Peter Johanson <latexer at gentoo.org>
+
+ * Parser/ExpressionTypeVisitor.boo:
+ * Parser/Resolver.boo:
+ * Parser/ReturnType.boo:
+ * Parser/ExpressionFinder.boo:
+ * Parser/BooParser.boo:
+ * Parser/VariableLookupVisitor.boo:
+ * Parser/Visitor.boo: Add better error reporting via logging by type.
+
2005-08-09 Lluis Sanchez Gual <lluis at novell.com>
* Parser/ReturnType.boo:
Modified: trunk/MonoDevelop/Extras/BooBinding/Parser/BooParser.boo
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/Parser/BooParser.boo 2005-08-10 13:22:12 UTC (rev 2731)
+++ trunk/MonoDevelop/Extras/BooBinding/Parser/BooParser.boo 2005-08-10 13:27:32 UTC (rev 2732)
@@ -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(parserContext as IParserContext, caretLine as int, caretColumn as int, fileName as string) as ArrayList:
- //print "Ctrl-Space (${caretLine}/${caretColumn})"
+ Log ("Ctrl-Space (${caretLine}/${caretColumn})")
try:
return Resolver(parserContext).CtrlSpace(caretLine, caretColumn, fileName)
except e:
@@ -159,26 +158,29 @@
return Resolver (parserContext).IsAsResolve (expression, caretLineNumber, caretColumn, fileName, fileContent)
def Resolve(parserContext as IParserContext, 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(parserContext).Resolve(expression, caretLineNumber, caretColumn, fileName, fileContent)
except e:
- //ShowException(e)
+ Error (e.ToString ())
return null
def MonodocResolver(parserContext as IParserContext, 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(parserContext).MonodocResolver(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.ToString (), message)
+
+ static def Error (type, message):
+ MonoDevelop.Services.Runtime.LoggingService.Error (type.ToString (), message)
Modified: trunk/MonoDevelop/Extras/BooBinding/Parser/ExpressionFinder.boo
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/Parser/ExpressionFinder.boo 2005-08-10 13:22:12 UTC (rev 2731)
+++ trunk/MonoDevelop/Extras/BooBinding/Parser/ExpressionFinder.boo 2005-08-10 13:27:32 UTC (rev 2732)
@@ -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)
Modified: trunk/MonoDevelop/Extras/BooBinding/Parser/ExpressionTypeVisitor.boo
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/Parser/ExpressionTypeVisitor.boo 2005-08-10 13:22:12 UTC (rev 2731)
+++ trunk/MonoDevelop/Extras/BooBinding/Parser/ExpressionTypeVisitor.boo 2005-08-10 13:27:32 UTC (rev 2732)
@@ -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
Modified: trunk/MonoDevelop/Extras/BooBinding/Parser/Resolver.boo
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/Parser/Resolver.boo 2005-08-10 13:22:12 UTC (rev 2731)
+++ trunk/MonoDevelop/Extras/BooBinding/Parser/Resolver.boo 2005-08-10 13:27:32 UTC (rev 2732)
@@ -76,7 +76,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
@@ -116,9 +116,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 of '${method.Name}'")
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
@@ -129,16 +129,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
@@ -247,7 +247,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:
@@ -294,10 +294,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:
@@ -324,16 +325,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:
@@ -374,47 +375,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 = _parserContext.GetClass (s, true, true)
@@ -423,10 +424,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:
@@ -452,3 +453,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)
+
Modified: trunk/MonoDevelop/Extras/BooBinding/Parser/ReturnType.boo
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/Parser/ReturnType.boo 2005-08-10 13:22:12 UTC (rev 2731)
+++ trunk/MonoDevelop/Extras/BooBinding/Parser/ReturnType.boo 2005-08-10 13:27:32 UTC (rev 2732)
@@ -66,12 +66,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:
@@ -120,6 +120,9 @@
override def ToString():
return "[${GetType().Name} Name=${FullyQualifiedName}]"
+
+ private def Error (message):
+ BooParser.Error (self.GetType (), message)
/////////////////////////////////////
/// Namespace Return Type ///
Modified: trunk/MonoDevelop/Extras/BooBinding/Parser/VariableLookupVisitor.boo
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/Parser/VariableLookupVisitor.boo 2005-08-10 13:22:12 UTC (rev 2731)
+++ trunk/MonoDevelop/Extras/BooBinding/Parser/VariableLookupVisitor.boo 2005-08-10 13:27:32 UTC (rev 2732)
@@ -62,6 +62,7 @@
Finish(node.Initializer)
override def OnBinaryExpression(node as BinaryExpression):
+ BooParser.Log (self.GetType (), "Binary expression: '${node}'")
if node.Operator == BinaryOperatorType.Assign and node.Left isa ReferenceExpression:
reference as ReferenceExpression = node.Left
if reference.Name == _lookFor:
Modified: trunk/MonoDevelop/Extras/BooBinding/Parser/Visitor.boo
===================================================================
--- trunk/MonoDevelop/Extras/BooBinding/Parser/Visitor.boo 2005-08-10 13:22:12 UTC (rev 2731)
+++ trunk/MonoDevelop/Extras/BooBinding/Parser/Visitor.boo 2005-08-10 13:27:32 UTC (rev 2732)
@@ -61,9 +61,7 @@
try:
Visit(CompileUnit)
except e:
- print e.ToString()
- //msg as IMessageService = ServiceManager.Services.GetService(typeof(IMessageService))
- //msg.ShowError(e)
+ Error (e.ToString ())
private def GetModifier(m as AST.TypeMember) as ModifierEnum:
r = ModifierEnum.None
@@ -122,7 +120,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 +146,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 +185,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 +204,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 +237,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 +251,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 +274,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 +283,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-patches-list
mailing list