Skip to content

Commit

Permalink
feat: make the import class name clickable (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpstotz authored and skylot committed Oct 25, 2018
1 parent 8c348c9 commit df9ae29
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,24 @@ public CodeWriter makeClass() throws CodegenException {
Collections.sort(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();

Expand Down

0 comments on commit df9ae29

Please sign in to comment.