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
c08578a8
Commit
c08578a8
authored
6 years ago
by
Tagir Valeev
Browse files
Options
Download
Email Patches
Plain Diff
AnonymousCanBeLambdaInspection: support parenthesized anonymous class
parent
7f984004
Branches unavailable
Tags unavailable
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
+1
-1
...tellij/codeInspection/AnonymousCanBeLambdaInspection.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterParenthesized.java
+6
-0
...nalyzer/quickFix/anonymous2lambda/afterParenthesized.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeParenthesized.java
+10
-0
...alyzer/quickFix/anonymous2lambda/beforeParenthesized.java
with
17 additions
and
1 deletion
+17
-1
java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
+
1
-
1
View file @
c08578a8
...
...
@@ -199,7 +199,7 @@ public class AnonymousCanBeLambdaInspection extends AbstractBaseJavaLocalInspect
boolean
reportNotAnnotatedInterfaces
,
@NotNull
Set
<
String
>
ignoredRuntimeAnnotations
)
{
PsiElement
parent
=
aClass
.
getParent
();
final
PsiElement
lambdaContext
=
parent
!=
null
?
parent
.
getParent
()
:
null
;
final
PsiElement
lambdaContext
=
parent
!=
null
?
PsiUtil
.
skipParenthesizedExprUp
(
parent
.
getParent
()
)
:
null
;
if
(
lambdaContext
==
null
||
!
LambdaUtil
.
isValidLambdaContext
(
lambdaContext
)
&&
!(
lambdaContext
instanceof
PsiReferenceExpression
))
return
false
;
return
isLambdaForm
(
aClass
,
acceptParameterizedFunctionTypes
,
reportNotAnnotatedInterfaces
,
ignoredRuntimeAnnotations
);
}
...
...
This diff is collapsed.
Click to expand it.
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterParenthesized.java
0 → 100644
+
6
-
0
View file @
c08578a8
// "Replace with lambda" "true"
class
Test
{
private
void
doSomething
()
{
((
Runnable
)
()
->
System
.
out
.
println
()).
run
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeParenthesized.java
0 → 100644
+
10
-
0
View file @
c08578a8
// "Replace with lambda" "true"
class
Test
{
private
void
doSomething
()
{
(
new
<
caret
>
Runnable
()
{
public
void
run
()
{
System
.
out
.
println
();
}
}).
run
();
}
}
\ No newline at end of file
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