AS3 goto definition on imports

This commit is contained in:
Jindra Petřík
2021-02-26 19:59:11 +01:00
parent 76a5fe169b
commit 5afdba0600
3 changed files with 15 additions and 7 deletions

View File

@@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
## [Unreleased]
### Added
- AS3 goto definition on imports
### Fixed
- #1336 AS3 direct editation - Regexp / character escaping
- #1615 Turning off Checking for modifications disables SWF loading
@@ -13,6 +16,7 @@ All notable changes to this project will be documented in this file.
- AS3 decompilation - do not show setslot on activation when has same name as method parameter
- #1450 AS3 direct editation - handling types from same package
- AS3 goto definition for types in another ABC tag
- AS3 goto definition for obfuscated names
### Changed
- #1616 Close SWF menuitem is last in the context menu

View File

@@ -256,7 +256,14 @@ public abstract class Trait implements Cloneable, Serializable {
Collections.sort(imports);
for (DottedChain imp : imports) {
if (imp.size() > 1) { //No imports from root package
writer.appendNoHilight("import " + imp.toPrintableString(true) + ";").newLine();
writer.appendNoHilight("import ");
if (!imp.isTopLevel()) {
writer.appendNoHilight(imp.getWithoutLast().toPrintableString(true));
writer.appendNoHilight(".");
}
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, imp.getLast()), HighlightSpecialType.TYPE_NAME, imp.toRawString());
writer.appendNoHilight(";").newLine();
hasImport = true;
}
}

View File

@@ -869,7 +869,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
decompiledTextArea.setLinkHandler(new LinkHandler() {
@Override
public boolean isLink(Token token) {
return hasDeclaration(token.start);
return hasDeclaration(token);
}
@Override
@@ -1099,18 +1099,15 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
cancelDecompiledButton.setEnabled(value);
}
private boolean hasDeclaration(int pos) {
private boolean hasDeclaration(Token t) {
if (decompiledTextArea == null) {
return false; //?
}
SyntaxDocument sd = (SyntaxDocument) decompiledTextArea.getDocument();
Token currentChartoken = sd.getTokenAt(pos);
Token nextChartoken = sd.getTokenAt(pos + 1);
Token t = currentChartoken != null && currentChartoken.length == 1 ? currentChartoken : nextChartoken;
if (t == null || (t.type != TokenType.IDENTIFIER && t.type != TokenType.KEYWORD && t.type != TokenType.REGEX)) {
return false;
}
int pos = t.start;
Reference<Integer> abcIndex = new Reference<>(0);
Reference<Integer> classIndex = new Reference<>(0);
Reference<Integer> traitIndex = new Reference<>(0);