Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
13ae388e
Commit
13ae388e
authored
6 years ago
by
Anna.Kozlova
Browse files
Options
Download
Email Patches
Plain Diff
show functional type instead of not helpful <lambda expression> type in type information popup
parent
2ef3685d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/java-impl/src/com/intellij/codeInsight/hint/JavaTypeProvider.java
+6
-0
...l/src/com/intellij/codeInsight/hint/JavaTypeProvider.java
java/java-tests/testSrc/com/intellij/codeInsight/hint/JavaTypeProviderTest.java
+10
-0
...c/com/intellij/codeInsight/hint/JavaTypeProviderTest.java
with
16 additions
and
0 deletions
+16
-0
java/java-impl/src/com/intellij/codeInsight/hint/JavaTypeProvider.java
+
6
-
0
View file @
13ae388e
...
...
@@ -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
);
}
...
...
This diff is collapsed.
Click to expand it.
java/java-tests/testSrc/com/intellij/codeInsight/hint/JavaTypeProviderTest.java
+
10
-
0
View file @
13ae388e
...
...
@@ -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"
+
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help