use of com.intellij.navigation.LocationPresentation 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