mirror of
https://github.com/processing/processing4.git
synced 2026-01-30 03:41:15 +01:00
fixed bug in parsing imports with auto completion
This commit is contained in:
@@ -1296,8 +1296,16 @@ public class ASTGenerator {
|
||||
|
||||
for (ImportStatement impS : imports) {
|
||||
String temp = impS.getPackageName();
|
||||
if (impS.isStarredImport() && className.indexOf('.') == -1) {
|
||||
temp = impS.getPackageName() + "." + className;
|
||||
if (impS.isStarredImport()) { // case of starred import: pkg.foo.*
|
||||
if (className.indexOf('.') == -1) {
|
||||
temp = impS.getPackageName() + "." + className;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else { // case of class import: pkg.foo.MyClass
|
||||
if (!impS.getImportedClassName().equals(className)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
tehClass = loadClass(temp);
|
||||
if (tehClass != null) {
|
||||
@@ -1309,8 +1317,16 @@ public class ASTGenerator {
|
||||
|
||||
for (ImportStatement impS : errorCheckerService.codeFolderImports) {
|
||||
String temp = impS.getPackageName();
|
||||
if (impS.isStarredImport() && className.indexOf('.') == -1) {
|
||||
temp = impS.getPackageName() + "." + className;
|
||||
if (impS.isStarredImport()) { // case of starred import: pkg.foo.*
|
||||
if (className.indexOf('.') == -1) {
|
||||
temp = impS.getPackageName() + "." + className;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else { // case of class import: pkg.foo.MyClass
|
||||
if (!impS.getImportedClassName().equals(className)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
tehClass = loadClass(temp);
|
||||
if (tehClass != null) {
|
||||
|
||||
@@ -78,9 +78,26 @@ public class ImportStatement {
|
||||
}
|
||||
|
||||
public boolean isStarredImport() {
|
||||
String ret = new String(importName.trim());
|
||||
if(ret.endsWith(";"))
|
||||
String ret = importName.trim();
|
||||
if(ret.endsWith(";")) {
|
||||
ret = ret.substring(0, ret.length() - 1).trim();
|
||||
}
|
||||
return ret.endsWith(".*");
|
||||
}
|
||||
|
||||
public String getImportedClassName() {
|
||||
if (isStarredImport()) {
|
||||
return null;
|
||||
} else {
|
||||
String ret = importName.trim();
|
||||
if(ret.endsWith(";")) {
|
||||
ret = ret.substring(0, ret.length() - 1).trim();
|
||||
}
|
||||
if (ret.lastIndexOf('.') != -1) {
|
||||
return ret.substring(ret.lastIndexOf('.') + 1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user