use of jadx.api.JavaClass in project jadx by skylot.
the class DbgUtils method getTopClassBySig.
public static JClass getTopClassBySig(String clsSig, MainWindow mainWindow) {
clsSig = DbgUtils.classSigToFullName(clsSig);
JavaClass cls = mainWindow.getWrapper().getDecompiler().searchJavaClassOrItsParentByOrigFullName(clsSig);
if (cls != null) {
JClass jc = mainWindow.getCacheObject().getNodeCache().makeFrom(cls);
return jc.getRootClass();
}
return null;
}
use of jadx.api.JavaClass in project jadx by skylot.
the class JadxTokenMaker method mergeLongClassNames.
@NotNull
private Token mergeLongClassNames(Token prev, Token current, boolean annotation) {
int offset = current.getTextOffset();
if (annotation) {
offset++;
}
JavaNode javaNode = codeArea.getJavaNodeAtOffset(offset);
if (javaNode instanceof JavaClass) {
String name = javaNode.getName();
String lexeme = current.getLexeme();
if (annotation && lexeme.length() > 1) {
lexeme = lexeme.substring(1);
}
if (!lexeme.equals(name) && isClassNameStart(javaNode, lexeme)) {
// try to replace long class name with one token
Token replace = concatTokensUntil(current, name);
if (replace != null && prev instanceof TokenImpl) {
TokenImpl impl = ((TokenImpl) prev);
impl.setNextToken(replace);
current = replace;
}
}
}
return current;
}
use of jadx.api.JavaClass in project jadx by skylot.
the class RenameDialog method processPackage.
private void processPackage(List<JavaNode> toUpdate) {
String rawFullPkg = ((JPackage) node).getFullName();
String rawFullPkgDot = rawFullPkg + ".";
for (JavaClass cls : mainWindow.getWrapper().getClasses()) {
String clsPkg = cls.getClassNode().getClassInfo().getPackage();
// search all classes in package
if (clsPkg.equals(rawFullPkg) || clsPkg.startsWith(rawFullPkgDot)) {
toUpdate.add(cls);
// also include all usages (for import fix)
toUpdate.addAll(cls.getUseIn());
}
}
}
use of jadx.api.JavaClass in project jadx by skylot.
the class CaretPositionFix method save.
/**
* Save caret position by anchor to token under caret
*/
public void save() {
try {
linesCount = codeArea.getLineCount();
int pos = codeArea.getCaretPosition();
line = codeArea.getLineOfOffset(pos);
lineOffset = pos - codeArea.getLineStartOffset(line);
tokenInfo = getTokenInfoByOffset(codeArea.getTokenListForLine(line), pos);
JClass cls = codeArea.getJClass();
if (cls != null) {
JavaClass topParentClass = cls.getJavaNode().getTopParentClass();
Object ann = topParentClass.getAnnotationAt(new CodePosition(line));
if (ann instanceof ICodeRawOffset) {
codeRawOffset = ((ICodeRawOffset) ann).getOffset();
CodeLinesInfo codeLinesInfo = new CodeLinesInfo(topParentClass);
JavaNode javaNodeAtLine = codeLinesInfo.getJavaNodeByLine(line);
if (javaNodeAtLine != null) {
javaNodeLine = javaNodeAtLine.getDecompiledLine();
}
}
}
LOG.debug("Saved position data: line={}, lineOffset={}, token={}, codeRawOffset={}, javaNodeLine={}", line, lineOffset, tokenInfo, codeRawOffset, javaNodeLine);
} catch (Exception e) {
LOG.error("Failed to save caret position before refresh", e);
line = -1;
}
}
use of jadx.api.JavaClass in project jadx by skylot.
the class CodeLinesInfo method addClass.
private void addClass(JavaClass cls, boolean includeFields) {
map.put(cls.getDecompiledLine(), cls);
for (JavaClass innerCls : cls.getInnerClasses()) {
map.put(innerCls.getDecompiledLine(), innerCls);
addClass(innerCls, includeFields);
}
for (JavaMethod mth : cls.getMethods()) {
map.put(mth.getDecompiledLine(), mth);
}
if (includeFields) {
for (JavaField field : cls.getFields()) {
map.put(field.getDecompiledLine(), field);
}
}
}
Aggregations