Commit 13ae388e authored by Anna.Kozlova's avatar Anna.Kozlova
Browse files

show functional type instead of not helpful <lambda expression> type in type information popup

parent 2ef3685d
Showing with 16 additions and 0 deletions
+16 -0
......@@ -37,6 +37,12 @@ public class JavaTypeProvider extends ExpressionTypeProvider<PsiExpression> {
@Override
public String getInformationHint(@NotNull PsiExpression element) {
PsiType type = element.getType();
if (type instanceof PsiLambdaExpressionType) {
type = ((PsiLambdaExpressionType)type).getExpression().getFunctionalInterfaceType();
}
else if (type instanceof PsiMethodReferenceType) {
type = ((PsiMethodReferenceType)type).getExpression().getFunctionalInterfaceType();
}
String text = type == null ? "<unknown>" : type.getPresentableText();
return StringUtil.escapeXml(text);
}
......
......@@ -36,6 +36,16 @@ public class JavaTypeProviderTest extends LightCodeInsightTestCase {
"</table>");
}
public void testFunctionalType() {
doTest(" void test() {\n" +
" Runnable r = <selection>() -> {}</selection>;\n" +
" }", "Runnable",
"<table>" +
"<tr><td align='left' valign='top' style='color:#909090'>Type:</td><td>Runnable</td></tr>" +
"<tr><td align='left' valign='top' style='color:#909090'>Nullability:</td><td>non-null</td></tr>" +
"</table>");
}
public void testTypeConstraint() {
doTest(" void x(Object a) {\n" +
" if(a instanceof String || a instanceof Number) {\n" +
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment