From bb149cb7f22f78d32f6233f94c55e316bdd14c96 Mon Sep 17 00:00:00 2001 From: polki Date: Thu, 10 Apr 2008 21:54:34 +0000 Subject: [PATCH] Fix Bug #1 -> Superclasses in the form Outerclass.Innerclass are no more reproduced in Python just as a Innerclass, but as Outerclass.Innerclass --- pyUml/META-INF/MANIFEST.MF | 2 +- .../src/pyUML/pythonTree/PythonTreeClass.java | 34 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/pyUml/META-INF/MANIFEST.MF b/pyUml/META-INF/MANIFEST.MF index a95a1c7..e5368d8 100755 --- a/pyUml/META-INF/MANIFEST.MF +++ b/pyUml/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: PyUML Bundle-SymbolicName: pyUml;singleton:=true -Bundle-Version: 0.9 +Bundle-Version: 1.0.1 Bundle-Activator: pyUML.plugin.Activator Eclipse-LazyStart: true Bundle-ClassPath: lib/refactoring.jar, diff --git a/pyUml/src/pyUML/pythonTree/PythonTreeClass.java b/pyUml/src/pyUML/pythonTree/PythonTreeClass.java index e807923..2f61cf9 100755 --- a/pyUml/src/pyUML/pythonTree/PythonTreeClass.java +++ b/pyUml/src/pyUML/pythonTree/PythonTreeClass.java @@ -33,7 +33,6 @@ import org.eclipse.uml2.uml.Realization; import org.eclipse.uml2.uml.Relationship; import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.VisibilityKind; -import org.eclipse.uml2.uml.internal.impl.RealizationImpl; import org.python.pydev.parser.jython.ast.Assign; import org.python.pydev.parser.jython.ast.Attribute; import org.python.pydev.parser.jython.ast.ClassDef; @@ -47,6 +46,7 @@ import org.python.pydev.parser.jython.ast.stmtType; import pyUML.backend.EclipseHelperMethods; import pyUML.backend.GlobalConstants; +import pyUML.backend.JavaHelperMethods; import pyUML.backend.ParseHelpers; import pyUML.exceptions.PyUMLCancelledException; import pyUML.exceptions.PyUMLParseException; @@ -155,7 +155,8 @@ public class PythonTreeClass extends PythonTreeNode{ root.getClassDict().put(structuredName, this); root.getClassNameDict().put(structuredName, this.name); - for (exprType superClass: this.astNode.bases) { + for (int i=0; i < this.astNode.bases.length; i++) { + exprType superClass = this.astNode.bases[i]; if (superClass instanceof Name) { String superName = ((Name)superClass).id; String superClassPackString = this.getPackFromImports(superName); @@ -163,11 +164,32 @@ public class PythonTreeClass extends PythonTreeNode{ this.superClasses.add(superClassPackString); } else if (superClass instanceof Attribute) { + // Just extract the content in the paranthesis without + // any further analysis + // This can be a subclass or a class under a package + /// -> this cannot be recognized + Attribute superAtt = (Attribute) superClass; - String superName = ((NameTok)superAtt.attr).id; - String packages = ((Name)superAtt.value).id; - String packageStructure = "/" + packages.replace(".", "/") + "/"; - this.superClasses.add(packageStructure+superName); + String line = FileRefactoring.getLine(inFile, superAtt.beginLine); + + // find i'th component of bases -> current component + String separator = "("; + for (int j=0; j <= i; j++) { + if (j > 0) + separator = ","; + line = line.substring(line.indexOf(separator) + 1); + } + + if ( i < this.astNode.bases.length - 1) + separator = ","; + else + separator = ")"; + + String superClassFullName = line.substring(0, line.indexOf(separator)); + superClassFullName = superClassFullName.replaceAll("[\\s]", ""); + + + this.superClasses.add(superClassFullName); } } }