|
8 | 8 | import me.darknet.assembler.compiler.Compiler; |
9 | 9 | import me.darknet.assembler.compiler.CompilerOptions; |
10 | 10 | import me.darknet.assembler.compiler.InheritanceChecker; |
| 11 | +import me.darknet.assembler.compiler.TypeAwareness; |
11 | 12 | import me.darknet.assembler.error.Error; |
12 | 13 | import me.darknet.assembler.error.Result; |
13 | 14 | import me.darknet.assembler.printer.AnnotationHolder; |
@@ -80,6 +81,26 @@ private void refreshContext() { |
80 | 81 | @Nonnull |
81 | 82 | protected abstract Compiler getCompiler(); |
82 | 83 |
|
| 84 | + @Nonnull |
| 85 | + protected TypeAwareness getTypeAwareness() { |
| 86 | + return new TypeAwareness() { |
| 87 | + @Override |
| 88 | + public boolean isAwareOf(String type) { |
| 89 | + return inheritanceGraph.getVertex(type) != null; |
| 90 | + } |
| 91 | + |
| 92 | + @Override |
| 93 | + public String notifyUnknownType(String type) { |
| 94 | + // TODO: We should have 'assembler.missingtypewarning' in the lang files, but we're not in the UI module |
| 95 | + // so we can't reference it here... |
| 96 | + return "Type '" + type + "' is not present in the workspace. StackMapTable references to it will degrade to 'java/lang/Object'\n" + |
| 97 | + "Consider either:\n" + |
| 98 | + "- Adding a dependency containing the class to the workspace.\n" + |
| 99 | + "- Enabling workspace phantom generation under 'All Services > Analysis > Phantom generator'."; |
| 100 | + } |
| 101 | + }; |
| 102 | + } |
| 103 | + |
83 | 104 | @Nonnull |
84 | 105 | protected InheritanceChecker getInheritanceChecker() { |
85 | 106 | return new InheritanceChecker() { |
@@ -145,6 +166,7 @@ protected Result<R> compile(@Nonnull List<ASTElement> elements, @Nonnull PathNod |
145 | 166 |
|
146 | 167 | CompilerOptions<? extends CompilerOptions<?>> options = getCompilerOptions(); |
147 | 168 | options.version(getClassVersion(info)) |
| 169 | + .awareness(getTypeAwareness()) |
148 | 170 | .inheritanceChecker(getInheritanceChecker()); |
149 | 171 |
|
150 | 172 | if (element.type() != ElementType.CLASS) { |
|
0 commit comments