| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cb7e08d commit 344dcb3
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1296,8 +1296,16 @@ protected Class<?> findClassIfExists(String className){ | |||
| 1296 | 1296 | ||
| 1297 | 1297 | for (ImportStatement impS : imports) { | |
| 1298 | 1298 | String temp = impS.getPackageName(); | |
| 1299 | - if (impS.isStarredImport() && className.indexOf('.') == -1) { | ||
| 1300 | - temp = impS.getPackageName() + "." + className; | ||
| 1299 | + if (impS.isStarredImport()) { // case of starred import: pkg.foo.* | ||
| 1300 | + if (className.indexOf('.') == -1) { | ||
| 1301 | + temp = impS.getPackageName() + "." + className; | ||
| 1302 | + } else { | ||
| 1303 | + continue; | ||
| 1304 | + } | ||
| 1305 | + } else { // case of class import: pkg.foo.MyClass | ||
| 1306 | + if (!impS.getImportedClassName().equals(className)) { | ||
| 1307 | + continue; | ||
| 1308 | + } | ||
| 1301 | 1309 | } | |
| 1302 | 1310 | tehClass = loadClass(temp); | |
| 1303 | 1311 | if (tehClass != null) { | |
@@ -1309,8 +1317,16 @@ protected Class<?> findClassIfExists(String className){ | |||
| 1309 | 1317 | ||
| 1310 | 1318 | for (ImportStatement impS : errorCheckerService.codeFolderImports) { | |
| 1311 | 1319 | String temp = impS.getPackageName(); | |
| 1312 | - if (impS.isStarredImport() && className.indexOf('.') == -1) { | ||
| 1313 | - temp = impS.getPackageName() + "." + className; | ||
| 1320 | + if (impS.isStarredImport()) { // case of starred import: pkg.foo.* | ||
| 1321 | + if (className.indexOf('.') == -1) { | ||
| 1322 | + temp = impS.getPackageName() + "." + className; | ||
| 1323 | + } else { | ||
| 1324 | + continue; | ||
| 1325 | + } | ||
| 1326 | + } else { // case of class import: pkg.foo.MyClass | ||
| 1327 | + if (!impS.getImportedClassName().equals(className)) { | ||
| 1328 | + continue; | ||
| 1329 | + } | ||
| 1314 | 1330 | } | |
| 1315 | 1331 | tehClass = loadClass(temp); | |
| 1316 | 1332 | if (tehClass != null) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,9 +78,26 @@ public int getLineNumber() { | |||
| 78 | 78 | } | |
| 79 | 79 | ||
| 80 | 80 | public boolean isStarredImport() { | |
| 81 | - String ret = new String(importName.trim()); | ||
| 82 | - if(ret.endsWith(";")) | ||
| 81 | + String ret = importName.trim(); | ||
| 82 | + if(ret.endsWith(";")) { | ||
| 83 | 83 | ret = ret.substring(0, ret.length() - 1).trim(); | |
| 84 | + } | ||
| 84 | 85 | return ret.endsWith(".*"); | |
| 85 | 86 | } | |
| 87 | + | ||
| 88 | + public String getImportedClassName() { | ||
| 89 | + if (isStarredImport()) { | ||
| 90 | + return null; | ||
| 91 | + } else { | ||
| 92 | + String ret = importName.trim(); | ||
| 93 | + if(ret.endsWith(";")) { | ||
| 94 | + ret = ret.substring(0, ret.length() - 1).trim(); | ||
| 95 | + } | ||
| 96 | + if (ret.lastIndexOf('.') != -1) { | ||
| 97 | + return ret.substring(ret.lastIndexOf('.') + 1); | ||
| 98 | + } else { | ||
| 99 | + return null; | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + } | ||
| 86 | 103 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments