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));
}
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));
}
Aggregations