Search in sources :

Example 1 with LocationPresentation

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;
}
Also used : LocationPresentation(com.intellij.navigation.LocationPresentation) ItemPresentation(com.intellij.navigation.ItemPresentation) PsiTreeElementBase(com.intellij.ide.structureView.impl.common.PsiTreeElementBase) Nullable(org.jetbrains.annotations.Nullable) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)1 PsiTreeElementBase (com.intellij.ide.structureView.impl.common.PsiTreeElementBase)1 ItemPresentation (com.intellij.navigation.ItemPresentation)1 LocationPresentation (com.intellij.navigation.LocationPresentation)1 Nullable (org.jetbrains.annotations.Nullable)1