use of jadx.api.data.annotations.ICodeRawOffset 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;
}
}
Aggregations