Search in sources :

Example 1 with FunctionalExpressionStub

use of com.intellij.psi.impl.java.stubs.FunctionalExpressionStub in project intellij-community by JetBrains.

the class ClassPresentationUtil method getFunctionalExpressionPresentation.

public static String getFunctionalExpressionPresentation(PsiFunctionalExpression functionalExpression, boolean qualified) {
    final StubElement stub = ((StubBasedPsiElementBase<?>) functionalExpression).getGreenStub();
    final String lambdaText = stub instanceof FunctionalExpressionStub ? ((FunctionalExpressionStub) stub).getPresentableText() : PsiExpressionTrimRenderer.render(functionalExpression);
    return PsiBundle.message("class.context.display", lambdaText, getContextName(functionalExpression, qualified));
}
Also used : FunctionalExpressionStub(com.intellij.psi.impl.java.stubs.FunctionalExpressionStub) StubElement(com.intellij.psi.stubs.StubElement) StubBasedPsiElementBase(com.intellij.extapi.psi.StubBasedPsiElementBase)

Example 2 with FunctionalExpressionStub

use of com.intellij.psi.impl.java.stubs.FunctionalExpressionStub in project intellij-community by JetBrains.

the class JavaFunctionalExpressionPresentationTest method doTest.

private void doTest(@Language("JAVA") @NotNull String funExprText, @NotNull String expectedPresentableString) {
    final PsiFileImpl file = assertInstanceOf(configureByText(JavaFileType.INSTANCE, funExprText), PsiFileImpl.class);
    //stub based test
    final FunctionalExpressionStub functionalExpressionStub = StreamEx.of(file.calcStubTree().getPlainList()).select(FunctionalExpressionStub.class).collect(MoreCollectors.onlyOne()).orElse(null);
    assertNotNull(functionalExpressionStub);
    assertEquals("Comparing with stub based rendering", expectedPresentableString, functionalExpressionStub.getPresentableText());
    //ast based test
    final PsiExpression psi = assertInstanceOf(functionalExpressionStub.getPsi(), PsiExpression.class);
    assertEquals("Comparing with AST based rendering", expectedPresentableString, PsiExpressionTrimRenderer.render(psi));
}
Also used : FunctionalExpressionStub(com.intellij.psi.impl.java.stubs.FunctionalExpressionStub) PsiFileImpl(com.intellij.psi.impl.source.PsiFileImpl)

Aggregations

FunctionalExpressionStub (com.intellij.psi.impl.java.stubs.FunctionalExpressionStub)2 StubBasedPsiElementBase (com.intellij.extapi.psi.StubBasedPsiElementBase)1 PsiFileImpl (com.intellij.psi.impl.source.PsiFileImpl)1 StubElement (com.intellij.psi.stubs.StubElement)1