* Added experimental branch
* Enabled fix imports in experimental
This commit is contained in:
parent
33c1888228
commit
82c6ada992
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="pyUML"
|
||||
label="PyUML Feature"
|
||||
id="pyUML-experimental"
|
||||
label="PyUML Feature (Experimental)"
|
||||
version="1.2.2"
|
||||
provider-name="Freie University Berlin, Germany, Martin Dittmar">
|
||||
|
||||
@ -104,7 +104,6 @@ This Agreement is governed by the laws of the State of New York and the intellec
|
||||
</license>
|
||||
|
||||
<requires>
|
||||
<import feature="org.python.pydev.feature"/>
|
||||
<import plugin="org.eclipse.core.resources"/>
|
||||
<import plugin="org.eclipse.core.runtime"/>
|
||||
<import plugin="org.eclipse.jface"/>
|
||||
@ -122,11 +121,12 @@ This Agreement is governed by the laws of the State of New York and the intellec
|
||||
<import plugin="org.python.pydev.core"/>
|
||||
<import plugin="org.python.pydev.parser"/>
|
||||
<import plugin="org.eclipse.uml2.diagram.clazz"/>
|
||||
<import feature="org.python.pydev.feature"/>
|
||||
</requires>
|
||||
|
||||
<plugin
|
||||
id="pyUml"
|
||||
download-size="541"
|
||||
id="pyUml-experimental"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
@ -1,7 +1,7 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: PyUML
|
||||
Bundle-SymbolicName: pyUml;singleton:=true
|
||||
Bundle-Name: PyUML (Experimental)
|
||||
Bundle-SymbolicName: pyUml-experimental;singleton:=true
|
||||
Bundle-Version: 1.2.2
|
||||
Bundle-Activator: pyUML.plugin.Activator
|
||||
Eclipse-LazyStart: true
|
||||
|
@ -1022,81 +1022,81 @@ public class PythonTreeClass extends PythonTreeNode {
|
||||
* @return true, if anything was changed, false otherwise
|
||||
*/
|
||||
public boolean fixImports(Classifier modelClass) throws PyUMLSynchronizeCodeException{
|
||||
return false; // See issues in FIXME below
|
||||
// // iterate over all superclasses in project
|
||||
// Map<String, String> superClassPackages = new HashMap<String, String>();
|
||||
// for (PythonTreeClass superClass : this.getModelGeneralizationsInProject(modelClass)) {
|
||||
//
|
||||
// // get package structure, e.g. mypackage.subpackage.MyClass
|
||||
// String packageDef = "";
|
||||
// PythonTreePackage superPackage = superClass.getParent();
|
||||
// while (superPackage != null && (! (superPackage instanceof PythonTreeRoot))) {
|
||||
// packageDef = superPackage.getName() + "." + packageDef;
|
||||
// superPackage = superPackage.getParent();
|
||||
// }
|
||||
// String superClassModuleName = superClass.inFile.getName().replace(".py", "");
|
||||
// packageDef += superClassModuleName;
|
||||
// superClassPackages.put(superClass.getName(), packageDef);
|
||||
// }
|
||||
//
|
||||
// // find import statements in code
|
||||
// // suppose, that all import statements are at the beginning of the
|
||||
// // file, only white or comment lines can be above them.
|
||||
// String[] fileContent = this.inFile.getFileContent().split("\n");
|
||||
// int lineNo = 0;
|
||||
// String line = "";
|
||||
// if (superClassPackages.size() > 0) {
|
||||
// do {
|
||||
// line = fileContent[lineNo];
|
||||
// String[] importParts = getImport(line);
|
||||
// if (importParts != null){
|
||||
// String className = importParts[0];
|
||||
// String packageDef = importParts[1];
|
||||
// String comment = importParts[2];
|
||||
// // if class is imported, but package changed -> rewrite line!
|
||||
// // FIXME: This is messed up since an import may be done without a "from" statement;
|
||||
// // it might look like "import mypackage" and refer to it by "mypackage.MyClass"
|
||||
// // or even like "import mypackage.mysubpackage as myalias"...
|
||||
// // therefore I disable import fixing as long as this issue has not been solved
|
||||
// // by Jakob
|
||||
// if (superClassPackages.containsKey(className) &&
|
||||
// ( ! packageDef.equals(superClassPackages.get(className)))) {
|
||||
// String newString = "from " + superClassPackages.get(className) + " import " + className + comment;
|
||||
// FileRefactoring.replaceLine(this.inFile, lineNo, newString, true);
|
||||
// this.setChanged(null, lineNo);
|
||||
// return true;
|
||||
// }
|
||||
// if (superClassPackages.containsKey(className) && superClassPackages.get(className).equals(packageDef)) {
|
||||
// // line is OK -> remove them from new-import-to-insert-list
|
||||
// superClassPackages.remove(className);
|
||||
// }
|
||||
// }
|
||||
// lineNo ++;
|
||||
// } while(line.matches("[\\s]*[#]?") || line.matches("from.*import.*")||line.matches("import.*"));
|
||||
//
|
||||
// // now, all lines were analyzed; the needed import, that were not covered
|
||||
// // by a line, must be inserted now!
|
||||
// if (superClassPackages.size() == 0)
|
||||
// return false;
|
||||
//
|
||||
// String insertLines = "";
|
||||
// for (String superClassName : superClassPackages.keySet()) {
|
||||
// String packageLine = superClassPackages.get(superClassName);
|
||||
// insertLines += "from " + packageLine + " import " + superClassName + "\n";
|
||||
// }
|
||||
// // if last line is empty, don't insert new empty line
|
||||
// if (lineNo == 1)
|
||||
// // no empty lines are in fron of the insertion -> insert empty line
|
||||
// insertLines += "\n";
|
||||
// else if (line.length() > 0 && (! fileContent[lineNo-2].matches("^[\\s]*$"))) {
|
||||
// insertLines += "\n";
|
||||
// }
|
||||
// FileRefactoring.insertAtLine(this.inFile, lineNo-1, insertLines);
|
||||
// this.setChanged(null, lineNo);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// return false; // See issues in FIXME below
|
||||
// iterate over all superclasses in project
|
||||
Map<String, String> superClassPackages = new HashMap<String, String>();
|
||||
for (PythonTreeClass superClass : this.getModelGeneralizationsInProject(modelClass)) {
|
||||
|
||||
// get package structure, e.g. mypackage.subpackage.MyClass
|
||||
String packageDef = "";
|
||||
PythonTreePackage superPackage = superClass.getParent();
|
||||
while (superPackage != null && (! (superPackage instanceof PythonTreeRoot))) {
|
||||
packageDef = superPackage.getName() + "." + packageDef;
|
||||
superPackage = superPackage.getParent();
|
||||
}
|
||||
String superClassModuleName = superClass.inFile.getName().replace(".py", "");
|
||||
packageDef += superClassModuleName;
|
||||
superClassPackages.put(superClass.getName(), packageDef);
|
||||
}
|
||||
|
||||
// find import statements in code
|
||||
// suppose, that all import statements are at the beginning of the
|
||||
// file, only white or comment lines can be above them.
|
||||
String[] fileContent = this.inFile.getFileContent().split("\n");
|
||||
int lineNo = 0;
|
||||
String line = "";
|
||||
if (superClassPackages.size() > 0) {
|
||||
do {
|
||||
line = fileContent[lineNo];
|
||||
String[] importParts = getImport(line);
|
||||
if (importParts != null){
|
||||
String className = importParts[0];
|
||||
String packageDef = importParts[1];
|
||||
String comment = importParts[2];
|
||||
// if class is imported, but package changed -> rewrite line!
|
||||
// FIXME: This is messed up since an import may be done without a "from" statement;
|
||||
// it might look like "import mypackage" and refer to it by "mypackage.MyClass"
|
||||
// or even like "import mypackage.mysubpackage as myalias"...
|
||||
// therefore I disable import fixing as long as this issue has not been solved
|
||||
// by Jakob
|
||||
if (superClassPackages.containsKey(className) &&
|
||||
( ! packageDef.equals(superClassPackages.get(className)))) {
|
||||
String newString = "from " + superClassPackages.get(className) + " import " + className + comment;
|
||||
FileRefactoring.replaceLine(this.inFile, lineNo, newString, true);
|
||||
this.setChanged(null, lineNo);
|
||||
return true;
|
||||
}
|
||||
if (superClassPackages.containsKey(className) && superClassPackages.get(className).equals(packageDef)) {
|
||||
// line is OK -> remove them from new-import-to-insert-list
|
||||
superClassPackages.remove(className);
|
||||
}
|
||||
}
|
||||
lineNo ++;
|
||||
} while(line.matches("[\\s]*[#]?") || line.matches("from.*import.*")||line.matches("import.*"));
|
||||
|
||||
// now, all lines were analyzed; the needed import, that were not covered
|
||||
// by a line, must be inserted now!
|
||||
if (superClassPackages.size() == 0)
|
||||
return false;
|
||||
|
||||
String insertLines = "";
|
||||
for (String superClassName : superClassPackages.keySet()) {
|
||||
String packageLine = superClassPackages.get(superClassName);
|
||||
insertLines += "from " + packageLine + " import " + superClassName + "\n";
|
||||
}
|
||||
// if last line is empty, don't insert new empty line
|
||||
if (lineNo == 1)
|
||||
// no empty lines are in fron of the insertion -> insert empty line
|
||||
insertLines += "\n";
|
||||
else if (line.length() > 0 && (! fileContent[lineNo-2].matches("^[\\s]*$"))) {
|
||||
insertLines += "\n";
|
||||
}
|
||||
FileRefactoring.insertAtLine(this.inFile, lineNo-1, insertLines);
|
||||
this.setChanged(null, lineNo);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,20 +3,59 @@
|
||||
<repository name='file:/home/didi/workspace/pyUml_updatesite/ - artifacts' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1.0.0'>
|
||||
<properties size='2'>
|
||||
<property name='p2.compressed' value='false'/>
|
||||
<property name='p2.timestamp' value='1244719702943'/>
|
||||
<property name='p2.timestamp' value='1244720592729'/>
|
||||
</properties>
|
||||
<mappings size='3'>
|
||||
<rule filter='(& (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
|
||||
<rule filter='(& (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
|
||||
<rule filter='(& (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
|
||||
</mappings>
|
||||
<artifacts size='10'>
|
||||
<artifacts size='14'>
|
||||
<artifact classifier='org.eclipse.update.feature' id='pyUML' version='1.2.1'>
|
||||
<properties size='2'>
|
||||
<property name='artifact.size' value='4963'/>
|
||||
<property name='download.size' value='4963'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='osgi.bundle' id='pyUml' version='1.2.0'>
|
||||
<properties size='3'>
|
||||
<property name='artifact.size' value='551466'/>
|
||||
<property name='download.size' value='551466'/>
|
||||
<property name='download.contentType' value='application/zip'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='org.eclipse.update.feature' id='pyUML-experimental' version='1.2.2'>
|
||||
<properties size='2'>
|
||||
<property name='artifact.size' value='4976'/>
|
||||
<property name='download.size' value='4976'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='osgi.bundle' id='pyUml-experimental' version='1.2.2'>
|
||||
<properties size='3'>
|
||||
<property name='artifact.size' value='556653'/>
|
||||
<property name='download.size' value='556653'/>
|
||||
<property name='download.contentType' value='application/zip'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='org.eclipse.update.feature' id='pyUML' version='1.2.1'>
|
||||
<properties size='2'>
|
||||
<property name='artifact.size' value='4980'/>
|
||||
<property name='download.size' value='4980'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='org.eclipse.update.feature' id='pyUML-experimental' version='1.2.2'>
|
||||
<properties size='2'>
|
||||
<property name='artifact.size' value='4980'/>
|
||||
<property name='download.size' value='4980'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='osgi.bundle' id='pyUml-experimental' version='1.2.2'>
|
||||
<properties size='3'>
|
||||
<property name='artifact.size' value='556646'/>
|
||||
<property name='download.size' value='556646'/>
|
||||
<property name='download.contentType' value='application/zip'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='osgi.bundle' id='pyUml' version='1.2.0'>
|
||||
<properties size='3'>
|
||||
<property name='artifact.size' value='554276'/>
|
||||
@ -36,13 +75,6 @@
|
||||
<property name='download.size' value='4974'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='osgi.bundle' id='pyUml' version='1.2.0'>
|
||||
<properties size='3'>
|
||||
<property name='artifact.size' value='551466'/>
|
||||
<property name='download.size' value='551466'/>
|
||||
<property name='download.contentType' value='application/zip'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='org.eclipse.update.feature' id='pyUML' version='1.2.0'>
|
||||
<properties size='2'>
|
||||
<property name='artifact.size' value='725'/>
|
||||
@ -62,12 +94,6 @@
|
||||
<property name='download.size' value='4980'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='org.eclipse.update.feature' id='pyUML' version='1.2.1'>
|
||||
<properties size='2'>
|
||||
<property name='artifact.size' value='4980'/>
|
||||
<property name='download.size' value='4980'/>
|
||||
</properties>
|
||||
</artifact>
|
||||
<artifact classifier='osgi.bundle' id='pyUml' version='1.2.2'>
|
||||
<properties size='3'>
|
||||
<property name='artifact.size' value='555052'/>
|
||||
|
File diff suppressed because one or more lines are too long
BIN
pyUml_updatesite/features/pyUML-experimental_1.2.2.jar
Executable file
BIN
pyUml_updatesite/features/pyUML-experimental_1.2.2.jar
Executable file
Binary file not shown.
BIN
pyUml_updatesite/plugins/pyUml-experimental_1.2.2.jar
Executable file
BIN
pyUml_updatesite/plugins/pyUml-experimental_1.2.2.jar
Executable file
Binary file not shown.
@ -12,9 +12,13 @@
|
||||
<feature url="features/pyUML_1.2.2.jar" id="pyUML" version="1.2.2">
|
||||
<category name="Eclipse PyUML"/>
|
||||
</feature>
|
||||
<feature url="features/pyUML-experimental_1.2.2.jar" id="pyUML-experimental" version="1.2.2">
|
||||
<category name="Eclipse PyUML Experimental"/>
|
||||
</feature>
|
||||
<category-def name="Eclipse PyUML" label="Eclipse PyUML">
|
||||
<description>
|
||||
A UML Roundtrip Tool for Python
|
||||
</description>
|
||||
</category-def>
|
||||
<category-def name="Eclipse PyUML Experimental" label="Eclipse PyUML Experimental"/>
|
||||
</site>
|
||||
|
Loading…
Reference in New Issue
Block a user