use of com.intellij.navigation.ItemPresentation in project intellij-community by JetBrains.
the class XPathEvalAction method showUsageView.
public static void showUsageView(@NotNull final Project project, MyUsageTarget usageTarget, Factory<UsageSearcher> searcherFactory, final EditExpressionAction editAction) {
final UsageViewPresentation presentation = new UsageViewPresentation();
presentation.setTargetsNodeText("XPath Expression");
presentation.setCodeUsages(false);
presentation.setCodeUsagesString("Found Matches");
presentation.setNonCodeUsagesString("Result");
presentation.setUsagesString("XPath Result");
presentation.setUsagesWord("match");
final ItemPresentation targetPresentation = usageTarget.getPresentation();
if (targetPresentation != null) {
presentation.setTabText(StringUtil.shortenTextWithEllipsis("XPath '" + targetPresentation.getPresentableText() + '\'', 60, 0, true));
} else {
presentation.setTabText("XPath");
}
presentation.setScopeText("XML Files");
presentation.setOpenInNewTab(FindSettings.getInstance().isShowResultsInSeparateView());
final FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation(presentation);
processPresentation.setProgressIndicatorFactory(() -> new FindProgressIndicator(project, "XML Document(s)"));
processPresentation.setShowPanelIfOnlyOneUsage(true);
processPresentation.setShowNotFoundMessage(true);
final UsageTarget[] usageTargets = { usageTarget };
UsageViewManager.getInstance(project).searchAndShowUsages(usageTargets, searcherFactory, processPresentation, presentation, new UsageViewManager.UsageViewStateListener() {
@Override
public void usageViewCreated(@NotNull UsageView usageView) {
usageView.addButtonToLowerPane(editAction, "&Edit Expression");
}
@Override
public void findingUsagesFinished(UsageView usageView) {
}
});
}
use of com.intellij.navigation.ItemPresentation in project intellij-community by JetBrains.
the class YAMLKeyValueImpl method getPresentation.
@Override
public ItemPresentation getPresentation() {
final YAMLFile yamlFile = (YAMLFile) getContainingFile();
final PsiElement value = getValue();
return new ItemPresentation() {
public String getPresentableText() {
if (value instanceof YAMLScalar) {
return getValueText();
}
return getName();
}
public String getLocationString() {
return "[" + yamlFile.getName() + "]";
}
public Icon getIcon(boolean open) {
return YAMLKeyValueImpl.this.getIcon(0);
}
};
}
use of com.intellij.navigation.ItemPresentation in project intellij-community by JetBrains.
the class PyStructureViewTest method testInvalidatedElement.
// EA-83566
public void testInvalidatedElement() {
myFixture.configureByText("a.py", "def f():\n" + " pass");
final PyFunction function = myFixture.findElementByText("f", PyFunction.class);
final PyStructureViewElement node = new PyStructureViewElement(function);
WriteCommandAction.runWriteCommandAction(myFixture.getProject(), function::delete);
assertNull(node.getValue());
final ItemPresentation presentation = node.getPresentation();
assertNotNull(presentation);
final Icon icon = presentation.getIcon(false);
assertNull(icon);
}
use of com.intellij.navigation.ItemPresentation in project intellij-plugins by JetBrains.
the class AbstractDartComponentImpl method getPresentation.
@Override
public ItemPresentation getPresentation() {
return new ItemPresentation() {
@Override
public String getPresentableText() {
final StringBuilder result = new StringBuilder();
result.append(getComponentName());
final DartComponentType type = DartComponentType.typeOf(AbstractDartComponentImpl.this);
if ((type == DartComponentType.METHOD || type == DartComponentType.FUNCTION || type == DartComponentType.CONSTRUCTOR || type == DartComponentType.OPERATOR) && !(isGetter() || isSetter())) {
final String parameterList = DartPresentableUtil.getPresentableParameterList(AbstractDartComponentImpl.this);
result.append("(").append(parameterList).append(")");
}
if (type == DartComponentType.METHOD || type == DartComponentType.FIELD || type == DartComponentType.FUNCTION || type == DartComponentType.OPERATOR) {
final DartReturnType returnType = PsiTreeUtil.getChildOfType(AbstractDartComponentImpl.this, DartReturnType.class);
final DartType dartType = PsiTreeUtil.getChildOfType(AbstractDartComponentImpl.this, DartType.class);
if (returnType != null) {
result.append(" ").append(DartPresentableUtil.RIGHT_ARROW).append(" ");
result.append(DartPresentableUtil.buildTypeText(AbstractDartComponentImpl.this, returnType, null));
} else if (dartType != null) {
result.append(" ").append(DartPresentableUtil.RIGHT_ARROW).append(" ");
result.append(DartPresentableUtil.buildTypeText(AbstractDartComponentImpl.this, dartType, null));
}
}
return result.toString();
}
@Nullable
private String getComponentName() {
String name = getName();
if (DartComponentType.typeOf(AbstractDartComponentImpl.this) == DartComponentType.CONSTRUCTOR) {
DartClass dartClass = PsiTreeUtil.getParentOfType(AbstractDartComponentImpl.this, DartClass.class);
if (dartClass == null) {
return name;
}
return StringUtil.isEmpty(name) ? dartClass.getName() : dartClass.getName() + "." + name;
}
return name;
}
@Override
public String getLocationString() {
if (!isValid()) {
return "";
}
if (!(AbstractDartComponentImpl.this instanceof DartClass)) {
final DartClass dartClass = PsiTreeUtil.getParentOfType(AbstractDartComponentImpl.this, DartClass.class);
if (dartClass != null) {
return dartClass.getName();
}
}
DartExecutionScope root = PsiTreeUtil.getTopmostParentOfType(AbstractDartComponentImpl.this, DartExecutionScope.class);
DartPartOfStatement partOfStatement = PsiTreeUtil.getChildOfType(root, DartPartOfStatement.class);
return partOfStatement == null ? null : partOfStatement.getLibraryName();
}
@Override
public Icon getIcon(boolean open) {
return AbstractDartComponentImpl.this.getIcon(0);
}
};
}
use of com.intellij.navigation.ItemPresentation in project intellij-plugins by JetBrains.
the class ReferenceExpressionPsiTest method testSimpleReference.
public void testSimpleReference() {
final OgnlReferenceExpression expression = parse("exp");
final ItemPresentation presentation = expression.getPresentation();
assertNotNull(presentation);
assertEquals("exp", presentation.getPresentableText());
assertNull(expression.getType());
final PsiReference reference = expression.getReference();
assertNotNull(reference);
assertEquals("exp", reference.getCanonicalText());
assertEquals(expression.getNavigationElement(), reference.resolve());
}
Aggregations