Fix Bug #1 -> Superclasses in the form Outerclass.Innerclass are no more reproduced in Python just as a Innerclass, but as Outerclass.Innerclass

This commit is contained in:
polki 2008-04-10 21:54:34 +00:00
parent 997f68e0f3
commit bb149cb7f2
2 changed files with 29 additions and 7 deletions

View File

@ -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,

View File

@ -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);
}
}
}