mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
lambda: ignore results of assignment is used for expression lambda (IDEA-125473)
This commit is contained in:
+2
-4
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
package com.siyeh.ig.assignment;
|
||||
|
||||
import com.intellij.psi.PsiAssignmentExpression;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpressionListStatement;
|
||||
import com.intellij.psi.PsiExpressionStatement;
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
@@ -57,6 +54,7 @@ public class NestedAssignmentInspection extends BaseInspection {
|
||||
}
|
||||
final PsiElement grandparent = parent.getParent();
|
||||
if (parent instanceof PsiExpressionStatement ||
|
||||
parent instanceof PsiLambdaExpression ||
|
||||
grandparent instanceof PsiExpressionListStatement) {
|
||||
return;
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.assignment;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
|
||||
public class NestedAssignmentInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testLambda() throws Exception {
|
||||
doTest("class Test {" +
|
||||
" {" +
|
||||
" int[] array = new int[1];" +
|
||||
" Runnable r = () -> array[0] = 0;" +
|
||||
" }" +
|
||||
"}");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new NestedAssignmentInspection();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user