mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ExpressionUtils#getAssignment now returns simple assignments only (not compound assignments)
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public boolean testAnyMatch(List<String> data) {
|
||||
int x = 10;
|
||||
if (data.stream().map(String::trim).anyMatch(String::isEmpty)) {
|
||||
x *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public boolean testAnyMatch(List<String> data) {
|
||||
int x = 10;
|
||||
for(String str : da<caret>ta) {
|
||||
String trimmed = str.trim();
|
||||
if(trimmed.isEmpty()) {
|
||||
x *= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+6
-3
@@ -720,10 +720,10 @@ public class ExpressionUtils {
|
||||
|
||||
/**
|
||||
* Returns assignment expression if supplied element is a statement which contains assignment expression
|
||||
* or it's an assignment expression itself
|
||||
* or it's an assignment expression itself. Only simple assignments are returned (like a = b, not a+= b).
|
||||
*
|
||||
* @param element element to get assignment expression from
|
||||
* @return extracted assignment or null if assignment is not found
|
||||
* @return extracted assignment or null if assignment is not found or assignment is compound
|
||||
*/
|
||||
@Contract("null -> null")
|
||||
public static PsiAssignmentExpression getAssignment(PsiElement element) {
|
||||
@@ -731,7 +731,10 @@ public class ExpressionUtils {
|
||||
element = ((PsiExpressionStatement)element).getExpression();
|
||||
}
|
||||
if (element instanceof PsiAssignmentExpression) {
|
||||
return (PsiAssignmentExpression)element;
|
||||
PsiAssignmentExpression assignment = (PsiAssignmentExpression)element;
|
||||
if(assignment.getOperationTokenType().equals(JavaTokenType.EQ)) {
|
||||
return assignment;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user