use of com.intellij.execution.filters.LineNumbersMapping in project intellij-community by JetBrains.
the class CompoundPositionManager method locationsOfLine.
@Override
@NotNull
public List<Location> locationsOfLine(@NotNull final ReferenceType type, @NotNull SourcePosition position) {
VirtualFile file = position.getFile().getVirtualFile();
if (file != null) {
LineNumbersMapping mapping = file.getUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY);
if (mapping != null) {
int line = mapping.sourceToBytecode(position.getLine() + 1);
if (line > -1) {
position = SourcePosition.createFromLine(position.getFile(), line - 1);
}
}
}
final SourcePosition finalPosition = position;
return iterate(positionManager -> positionManager.locationsOfLine(type, finalPosition), Collections.emptyList(), position);
}
use of com.intellij.execution.filters.LineNumbersMapping in project intellij-community by JetBrains.
the class ByteCodeViewerComponent method setText.
public void setText(final String bytecode, PsiElement element) {
int offset = 0;
VirtualFile file = PsiUtilCore.getVirtualFile(element);
if (file != null) {
final Document document = FileDocumentManager.getInstance().getDocument(file);
if (document != null) {
int lineNumber = document.getLineNumber(element.getTextOffset());
LineNumbersMapping mapping = file.getUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY);
if (mapping != null) {
int mappedLine = mapping.sourceToBytecode(lineNumber);
while (mappedLine == -1 && lineNumber < document.getLineCount()) {
mappedLine = mapping.sourceToBytecode(++lineNumber);
}
if (mappedLine > 0) {
lineNumber = mappedLine;
}
}
offset = bytecode.indexOf("LINENUMBER " + lineNumber);
while (offset == -1 && lineNumber < document.getLineCount()) {
offset = bytecode.indexOf("LINENUMBER " + (lineNumber++));
}
}
}
setText(bytecode, Math.max(0, offset));
}
Aggregations