Commit df9ae295 authored by Jan S's avatar Jan S Committed by skylot

feat: make the import class name clickable (#378)

parent 8c348c93
...@@ -91,7 +91,24 @@ public class ClassGen { ...@@ -91,7 +91,24 @@ public class ClassGen {
Collections.sort(sortImports); Collections.sort(sortImports);
for (String imp : sortImports) { for (String imp : sortImports) {
clsCode.startLine("import ").add(imp).add(';'); ClassInfo importClassInfo = ClassInfo.fromName(cls.dex().root(), imp);
ClassNode classNode = cls.dex().resolveClass(importClassInfo);
// Clickable element seems to be limited by the next dot, therefore
// we can't just use the complete class name including packagename
int clsDotIdx = imp.lastIndexOf('.');
String pkg = "";
if (clsDotIdx >= 0) {
pkg = imp.substring(0, clsDotIdx + 1);
imp = imp.substring(clsDotIdx + 1);
}
clsCode.startLine("import ");
clsCode.add(pkg);
if (classNode != null) {
// attach the clickable link info to the class name
clsCode.attachAnnotation(classNode);
}
clsCode.add(imp);
clsCode.add(';');
} }
clsCode.newLine(); clsCode.newLine();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment