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
e7743c0b
Commit
e7743c0b
authored
6 years ago
by
Anna Kozlova
Browse files
Options
Download
Email Patches
Plain Diff
disable redundant lambda parameter type for annotated vars (IDEA-194413)
parent
8933f25a
Branches unavailable
Tags unavailable
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/java-impl/src/com/intellij/codeInspection/lambda/RedundantLambdaParameterTypeInspection.java
+14
-5
...ection/lambda/RedundantLambdaParameterTypeInspection.java
with
14 additions
and
5 deletions
+14
-5
java/java-impl/src/com/intellij/codeInspection/lambda/RedundantLambdaParameterTypeInspection.java
+
14
-
5
View file @
e7743c0b
...
...
@@ -37,9 +37,14 @@ public class RedundantLambdaParameterTypeInspection extends AbstractBaseJavaLoca
final
PsiLambdaExpression
expression
=
(
PsiLambdaExpression
)
parent
;
final
PsiParameter
[]
parameters
=
parameterList
.
getParameters
();
for
(
PsiParameter
parameter
:
parameters
)
{
if
(
parameter
.
getTypeElement
()
==
null
)
return
false
;
if
(!
PsiUtil
.
isLanguageLevel11OrHigher
(
parameterList
)
&&
AnonymousCanBeLambdaInspection
.
hasRuntimeAnnotations
(
parameter
,
Collections
.
emptySet
()))
return
false
;
PsiTypeElement
typeElement
=
parameter
.
getTypeElement
();
if
(
typeElement
==
null
)
return
false
;
if
(!
PsiUtil
.
isLanguageLevel11OrHigher
(
parameterList
))
{
if
(
AnonymousCanBeLambdaInspection
.
hasRuntimeAnnotations
(
parameter
,
Collections
.
emptySet
()))
{
return
false
;
}
}
else
if
(
typeElement
.
isInferredType
()
&&
keepVarType
(
parameter
))
return
false
;
}
if
(
parameters
.
length
==
0
)
return
false
;
final
PsiType
functionalInterfaceType
=
expression
.
getFunctionalInterfaceType
();
...
...
@@ -72,8 +77,7 @@ public class RedundantLambdaParameterTypeInspection extends AbstractBaseJavaLoca
if
(
lambdaExpression
!=
null
)
{
final
PsiParameter
[]
parameters
=
lambdaExpression
.
getParameterList
().
getParameters
();
if
(
PsiUtil
.
isLanguageLevel11OrHigher
(
lambdaExpression
)
&&
Arrays
.
stream
(
parameters
).
anyMatch
(
parameter
->
parameter
.
hasModifierProperty
(
PsiModifier
.
FINAL
)
||
parameter
.
getAnnotations
().
length
>
0
))
{
Arrays
.
stream
(
parameters
).
anyMatch
(
parameter
->
keepVarType
(
parameter
)))
{
for
(
PsiParameter
parameter
:
parameters
)
{
PsiTypeElement
element
=
parameter
.
getTypeElement
();
if
(
element
!=
null
)
{
...
...
@@ -96,6 +100,11 @@ public class RedundantLambdaParameterTypeInspection extends AbstractBaseJavaLoca
}
}
private
static
boolean
keepVarType
(
PsiParameter
parameter
)
{
return
parameter
.
hasModifierProperty
(
PsiModifier
.
FINAL
)
||
parameter
.
getAnnotations
().
length
>
0
;
}
private
static
class
LambdaParametersFix
implements
LocalQuickFix
{
@Nls
@NotNull
...
...
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