Update lint diagnostics to Uast 1.0.8
This commit is contained in:
@@ -973,8 +973,8 @@ public class UElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitDeclarationsExpression(UVariableDeclarationsExpression node) {
|
||||
List<VisitingDetector> list = mNodePsiTypeDetectors.get(UVariableDeclarationsExpression.class);
|
||||
public boolean visitDeclarationsExpression(UDeclarationsExpression node) {
|
||||
List<VisitingDetector> list = mNodePsiTypeDetectors.get(UDeclarationsExpression.class);
|
||||
if (list != null) {
|
||||
for (VisitingDetector v : list) {
|
||||
v.getVisitor().visitDeclarationsExpression(node);
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.intellij.psi.*;
|
||||
import org.jetbrains.uast.*;
|
||||
import org.jetbrains.uast.expressions.UReferenceExpression;
|
||||
import org.jetbrains.uast.java.JavaAbstractUExpression;
|
||||
import org.jetbrains.uast.java.JavaUVariableDeclarationsExpression;
|
||||
import org.jetbrains.uast.java.JavaUDeclarationsExpression;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -301,7 +301,7 @@ public class UastLintUtils {
|
||||
if (element instanceof UExpression) {
|
||||
node = (UExpression) element;
|
||||
} else if (element instanceof UVariable) {
|
||||
node = new JavaUVariableDeclarationsExpression(
|
||||
node = new JavaUDeclarationsExpression(
|
||||
null, Collections.singletonList(((UVariable) element)));
|
||||
} else {
|
||||
throw new IllegalArgumentException("element must be an expression or an UVariable");
|
||||
|
||||
+3
-3
@@ -730,7 +730,7 @@ public class ConstantEvaluator {
|
||||
} else {
|
||||
return left.doubleValue() > right.doubleValue();
|
||||
}
|
||||
} else if (operator == UastBinaryOperator.GREATER_OR_EQUAL) {
|
||||
} else if (operator == UastBinaryOperator.GREATER_OR_EQUALS) {
|
||||
if (isInteger) {
|
||||
return left.longValue() >= right.longValue();
|
||||
} else {
|
||||
@@ -742,7 +742,7 @@ public class ConstantEvaluator {
|
||||
} else {
|
||||
return left.doubleValue() < right.doubleValue();
|
||||
}
|
||||
} else if (operator == UastBinaryOperator.LESS_OR_EQUAL) {
|
||||
} else if (operator == UastBinaryOperator.LESS_OR_EQUALS) {
|
||||
if (isInteger) {
|
||||
return left.longValue() <= right.longValue();
|
||||
} else {
|
||||
@@ -1162,7 +1162,7 @@ public class ConstantEvaluator {
|
||||
|
||||
private static boolean elementHasLevel(UElement node) {
|
||||
return !(node instanceof UBlockExpression
|
||||
|| node instanceof UVariableDeclarationsExpression);
|
||||
|| node instanceof UDeclarationsExpression);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ public class AnnotationDetector extends Detector implements Detector.UastScanner
|
||||
return false;
|
||||
}
|
||||
// Only flag local variables and parameters (not classes, fields and methods)
|
||||
if (!(parent instanceof UVariableDeclarationsExpression
|
||||
if (!(parent instanceof UDeclarationsExpression
|
||||
|| parent instanceof ULocalVariable
|
||||
|| parent instanceof UParameter)) {
|
||||
return false;
|
||||
@@ -414,12 +414,12 @@ public class AnnotationDetector extends Detector implements Detector.UastScanner
|
||||
UElement parent = node.getContainingElement();
|
||||
PsiType type;
|
||||
|
||||
if (parent instanceof UVariableDeclarationsExpression) {
|
||||
List<UVariable> elements = ((UVariableDeclarationsExpression) parent).getVariables();
|
||||
if (parent instanceof UDeclarationsExpression) {
|
||||
List<UDeclaration> elements = ((UDeclarationsExpression) parent).getDeclarations();
|
||||
if (!elements.isEmpty()) {
|
||||
UVariable element = elements.get(0);
|
||||
UDeclaration element = elements.get(0);
|
||||
if (element instanceof ULocalVariable) {
|
||||
type = element.getType();
|
||||
type = ((ULocalVariable) element).getType();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2628,8 +2628,8 @@ public class ApiDetector extends ResourceXmlDetector
|
||||
@Nullable UIfExpression ifStatement,
|
||||
@NonNull UBinaryExpression binary) {
|
||||
UastBinaryOperator tokenType = binary.getOperator();
|
||||
if (tokenType == UastBinaryOperator.GREATER || tokenType == UastBinaryOperator.GREATER_OR_EQUAL ||
|
||||
tokenType == UastBinaryOperator.LESS_OR_EQUAL || tokenType == UastBinaryOperator.LESS ||
|
||||
if (tokenType == UastBinaryOperator.GREATER || tokenType == UastBinaryOperator.GREATER_OR_EQUALS ||
|
||||
tokenType == UastBinaryOperator.LESS_OR_EQUALS || tokenType == UastBinaryOperator.LESS ||
|
||||
tokenType == UastBinaryOperator.EQUALS || tokenType == UastBinaryOperator.IDENTITY_EQUALS) {
|
||||
UExpression left = binary.getLeftOperand();
|
||||
if (left instanceof UReferenceExpression) {
|
||||
@@ -2655,7 +2655,7 @@ public class ApiDetector extends ResourceXmlDetector
|
||||
boolean fromThen = ifStatement == null || prev == ifStatement.getThenExpression();
|
||||
boolean fromElse = ifStatement != null && prev == ifStatement.getElseExpression();
|
||||
assert fromThen == !fromElse;
|
||||
if (tokenType == UastBinaryOperator.GREATER_OR_EQUAL) {
|
||||
if (tokenType == UastBinaryOperator.GREATER_OR_EQUALS) {
|
||||
// if (SDK_INT >= ICE_CREAM_SANDWICH) { <call> } else { ... }
|
||||
return level >= api && fromThen;
|
||||
}
|
||||
@@ -2663,7 +2663,7 @@ public class ApiDetector extends ResourceXmlDetector
|
||||
// if (SDK_INT > ICE_CREAM_SANDWICH) { <call> } else { ... }
|
||||
return level >= api - 1 && fromThen;
|
||||
}
|
||||
else if (tokenType == UastBinaryOperator.LESS_OR_EQUAL) {
|
||||
else if (tokenType == UastBinaryOperator.LESS_OR_EQUALS) {
|
||||
// if (SDK_INT <= ICE_CREAM_SANDWICH) { ... } else { <call> }
|
||||
return level >= api - 1 && fromElse;
|
||||
}
|
||||
@@ -2755,7 +2755,7 @@ public class ApiDetector extends ResourceXmlDetector
|
||||
}
|
||||
}
|
||||
if (level != -1) {
|
||||
if (tokenType == UastBinaryOperator.GREATER_OR_EQUAL) {
|
||||
if (tokenType == UastBinaryOperator.GREATER_OR_EQUALS) {
|
||||
// if (SDK_INT >= ICE_CREAM_SANDWICH && <call>
|
||||
return level >= api;
|
||||
}
|
||||
|
||||
-1
@@ -28,7 +28,6 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.uast.*;
|
||||
import org.jetbrains.uast.expressions.UInstanceExpression;
|
||||
import org.jetbrains.uast.expressions.UTypeReferenceExpression;
|
||||
import org.jetbrains.uast.util.UastExpressionUtils;
|
||||
import org.jetbrains.uast.visitor.AbstractUastVisitor;
|
||||
|
||||
Reference in New Issue
Block a user