| 33 | |
| 34 | class TypeResolver { |
| 35 | public void setup(ClassInstance rootCls, NameType nameType, CompilationUnit cu) { |
| 36 | this.rootCls = rootCls; |
| 37 | this.env = rootCls.getEnv(); |
| 38 | this.nameType = nameType; |
| 39 | |
| 40 | if (cu.getPackageDeclaration().isPresent()) { |
| 41 | pkg = cu.getPackageDeclaration().get().getNameAsString().replace('.', '/'); |
| 42 | wildcardImports.add(pkg.concat("/")); |
| 43 | } else { |
| 44 | pkg = null; |
| 45 | wildcardImports.add(""); |
| 46 | } |
| 47 | |
| 48 | wildcardImports.add("java/lang/"); |
| 49 | |
| 50 | for (ImportDeclaration imp : cu.getImports()) { |
| 51 | if (imp.isStatic()) continue; |
| 52 | |
| 53 | if (imp.isAsterisk()) { |
| 54 | wildcardImports.add(imp.getNameAsString().replace('.', '/').concat("/")); |
| 55 | } else { |
| 56 | String name = imp.getNameAsString(); |
| 57 | int pos = name.lastIndexOf('.'); |
| 58 | |
| 59 | if (pos != -1) imports.put(name.substring(pos + 1), name.replace('.', '/')); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | public ClassInstance getCls(Node node) { |
| 65 | StringBuilder sb = new StringBuilder(); |