use of com.intellij.ide.structureView.impl.common.PsiTreeElementBase in project ideavim by JetBrains.
the class PsiHelper method addNavigationElements.
private static void addNavigationElements(@NotNull TreeElement root, @NotNull TIntArrayList navigationOffsets, boolean start) {
if (root instanceof PsiTreeElementBase) {
PsiElement element = ((PsiTreeElementBase) root).getValue();
int offset;
if (start) {
offset = element.getTextRange().getStartOffset();
if (element.getLanguage().getID().equals("JAVA")) {
// HACK: for Java classes and methods, we want to jump to the opening brace
int textOffset = element.getTextOffset();
int braceIndex = element.getText().indexOf('{', textOffset - offset);
if (braceIndex >= 0) {
offset += braceIndex;
}
}
} else {
offset = element.getTextRange().getEndOffset() - 1;
}
if (!navigationOffsets.contains(offset)) {
navigationOffsets.add(offset);
}
}
for (TreeElement child : root.getChildren()) {
addNavigationElements(child, navigationOffsets, start);
}
}
use of com.intellij.ide.structureView.impl.common.PsiTreeElementBase in project intellij-community by JetBrains.
the class FileStructurePopup method getSpeedSearchText.
@Nullable
public static String getSpeedSearchText(final Object userObject) {
String text = String.valueOf(userObject);
if (text != null) {
if (userObject instanceof StructureViewComponent.StructureViewTreeElementWrapper) {
final TreeElement value = ((StructureViewComponent.StructureViewTreeElementWrapper) userObject).getValue();
if (value instanceof PsiTreeElementBase && ((PsiTreeElementBase) value).isSearchInLocationString()) {
final String locationString = ((PsiTreeElementBase) value).getLocationString();
if (!StringUtil.isEmpty(locationString)) {
String locationPrefix = null;
String locationSuffix = null;
if (value instanceof LocationPresentation) {
locationPrefix = ((LocationPresentation) value).getLocationPrefix();
locationSuffix = ((LocationPresentation) value).getLocationSuffix();
}
return text + StringUtil.notNullize(locationPrefix, LocationPresentation.DEFAULT_LOCATION_PREFIX) + locationString + StringUtil.notNullize(locationSuffix, LocationPresentation.DEFAULT_LOCATION_SUFFIX);
}
}
}
return text;
}
// see com.intellij.ide.util.treeView.NodeDescriptor.toString
if (userObject instanceof StructureViewComponent.StructureViewTreeElementWrapper) {
return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Nullable
@Override
public String compute() {
final ItemPresentation presentation = ((StructureViewComponent.StructureViewTreeElementWrapper) userObject).getValue().getPresentation();
return presentation.getPresentableText();
}
});
}
return null;
}
Aggregations