Update lint diagnostics to Uast 1.0.8

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