Update to UAST 0.12
This commit is contained in:
+1
-1
@@ -102,7 +102,7 @@ class ResourceFoldingBuilder : FoldingBuilderEx() {
|
|||||||
|
|
||||||
val element = getOutermostQualified() ?: this
|
val element = getOutermostQualified() ?: this
|
||||||
|
|
||||||
(element.containingElement as? UCallExpression)?.run {
|
(element.uastParent as? UCallExpression)?.run {
|
||||||
if (isFoldableGetResourceValueCall()) {
|
if (isFoldableGetResourceValueCall()) {
|
||||||
return getOutermostQualified()?.createFoldingDescriptor() ?: createFoldingDescriptor()
|
return getOutermostQualified()?.createFoldingDescriptor() ?: createFoldingDescriptor()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2622,7 +2622,7 @@ public class LintDriver {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
scope = scope.getContainingElement();
|
scope = scope.getUastParent();
|
||||||
if (scope instanceof PsiFile) {
|
if (scope instanceof PsiFile) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ public class UElementVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cls = cls.getUastSuperClass();
|
cls = cls.getSuperClass();
|
||||||
depth++;
|
depth++;
|
||||||
if (depth == 500) {
|
if (depth == 500) {
|
||||||
// Shouldn't happen in practice; this prevents the IDE from
|
// Shouldn't happen in practice; this prevents the IDE from
|
||||||
|
|||||||
@@ -16,41 +16,6 @@
|
|||||||
|
|
||||||
package com.android.tools.klint.detector.api;
|
package com.android.tools.klint.detector.api;
|
||||||
|
|
||||||
import static com.android.SdkConstants.ANDROID_MANIFEST_XML;
|
|
||||||
import static com.android.SdkConstants.ANDROID_PREFIX;
|
|
||||||
import static com.android.SdkConstants.ANDROID_URI;
|
|
||||||
import static com.android.SdkConstants.ATTR_LOCALE;
|
|
||||||
import static com.android.SdkConstants.BIN_FOLDER;
|
|
||||||
import static com.android.SdkConstants.DOT_GIF;
|
|
||||||
import static com.android.SdkConstants.DOT_JPEG;
|
|
||||||
import static com.android.SdkConstants.DOT_JPG;
|
|
||||||
import static com.android.SdkConstants.DOT_PNG;
|
|
||||||
import static com.android.SdkConstants.DOT_WEBP;
|
|
||||||
import static com.android.SdkConstants.DOT_XML;
|
|
||||||
import static com.android.SdkConstants.FN_BUILD_GRADLE;
|
|
||||||
import static com.android.SdkConstants.ID_PREFIX;
|
|
||||||
import static com.android.SdkConstants.NEW_ID_PREFIX;
|
|
||||||
import static com.android.SdkConstants.TOOLS_URI;
|
|
||||||
import static com.android.SdkConstants.UTF_8;
|
|
||||||
import static com.android.ide.common.resources.configuration.FolderConfiguration.QUALIFIER_SPLITTER;
|
|
||||||
import static com.android.ide.common.resources.configuration.LocaleQualifier.BCP_47_PREFIX;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_BOOLEAN;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_BOOLEAN_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_BYTE;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_BYTE_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_CHAR;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_CHARACTER_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_DOUBLE;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_DOUBLE_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_FLOAT;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_FLOAT_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_INT;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_INTEGER_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_LONG;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_LONG_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_SHORT;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_SHORT_WRAPPER;
|
|
||||||
|
|
||||||
import com.android.annotations.NonNull;
|
import com.android.annotations.NonNull;
|
||||||
import com.android.annotations.Nullable;
|
import com.android.annotations.Nullable;
|
||||||
import com.android.builder.model.AndroidProject;
|
import com.android.builder.model.AndroidProject;
|
||||||
@@ -78,21 +43,14 @@ import com.google.common.base.Splitter;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.intellij.psi.CommonClassNames;
|
import com.intellij.psi.*;
|
||||||
import com.intellij.psi.PsiClassType;
|
import lombok.ast.ImportDeclaration;
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiImportStatement;
|
|
||||||
import com.intellij.psi.PsiLiteral;
|
|
||||||
import com.intellij.psi.PsiParenthesizedExpression;
|
|
||||||
import com.intellij.psi.PsiType;
|
|
||||||
import com.intellij.psi.PsiWhiteSpace;
|
|
||||||
|
|
||||||
import org.jetbrains.uast.UElement;
|
|
||||||
import org.jetbrains.uast.UParenthesizedExpression;
|
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode;
|
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
import org.jetbrains.org.objectweb.asm.tree.ClassNode;
|
import org.jetbrains.org.objectweb.asm.tree.ClassNode;
|
||||||
import org.jetbrains.org.objectweb.asm.tree.FieldNode;
|
import org.jetbrains.org.objectweb.asm.tree.FieldNode;
|
||||||
|
import org.jetbrains.uast.UElement;
|
||||||
|
import org.jetbrains.uast.UParenthesizedExpression;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
@@ -100,17 +58,15 @@ import org.w3c.dom.NodeList;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.ArrayDeque;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
import lombok.ast.ImportDeclaration;
|
import static com.android.SdkConstants.*;
|
||||||
|
import static com.android.ide.common.resources.configuration.FolderConfiguration.QUALIFIER_SPLITTER;
|
||||||
|
import static com.android.ide.common.resources.configuration.LocaleQualifier.BCP_47_PREFIX;
|
||||||
|
import static com.android.tools.klint.client.api.JavaParser.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1299,7 +1255,7 @@ public class LintUtils {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static UElement skipParentheses(@Nullable UElement element) {
|
public static UElement skipParentheses(@Nullable UElement element) {
|
||||||
while (element instanceof UParenthesizedExpression) {
|
while (element instanceof UParenthesizedExpression) {
|
||||||
element = element.getContainingElement();
|
element = element.getUastParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class AnnotationDetector extends Detector implements Detector.UastScanner
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FQCN_SUPPRESS_LINT.equals(type)) {
|
if (FQCN_SUPPRESS_LINT.equals(type)) {
|
||||||
UElement parent = annotation.getContainingElement();
|
UElement parent = annotation.getUastParent();
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -218,8 +218,8 @@ public class AnnotationDetector extends Detector implements Detector.UastScanner
|
|||||||
} else if (type.startsWith(SUPPORT_ANNOTATIONS_PREFIX)) {
|
} else if (type.startsWith(SUPPORT_ANNOTATIONS_PREFIX)) {
|
||||||
if (CHECK_RESULT_ANNOTATION.equals(type)) {
|
if (CHECK_RESULT_ANNOTATION.equals(type)) {
|
||||||
// Check that the return type of this method is not void!
|
// Check that the return type of this method is not void!
|
||||||
if (annotation.getContainingElement() instanceof UMethod) {
|
if (annotation.getUastParent() instanceof UMethod) {
|
||||||
UMethod method = (UMethod) annotation.getContainingElement();
|
UMethod method = (UMethod) annotation.getUastParent();
|
||||||
if (!method.isConstructor()
|
if (!method.isConstructor()
|
||||||
&& PsiType.VOID.equals(method.getReturnType())) {
|
&& PsiType.VOID.equals(method.getReturnType())) {
|
||||||
mContext.report(ANNOTATION_USAGE, annotation.getPsi(),
|
mContext.report(ANNOTATION_USAGE, annotation.getPsi(),
|
||||||
@@ -284,7 +284,7 @@ public class AnnotationDetector extends Detector implements Detector.UastScanner
|
|||||||
PERMISSION_ANNOTATION_WRITE.equals(type)) {
|
PERMISSION_ANNOTATION_WRITE.equals(type)) {
|
||||||
// Check that if there are no arguments, this is specified on a parameter,
|
// Check that if there are no arguments, this is specified on a parameter,
|
||||||
// and conversely, on methods and fields there is a valid argument.
|
// and conversely, on methods and fields there is a valid argument.
|
||||||
if (annotation.getContainingElement() instanceof UMethod) {
|
if (annotation.getUastParent() instanceof UMethod) {
|
||||||
String value = PermissionRequirement.getAnnotationStringValue(annotation, ATTR_VALUE);
|
String value = PermissionRequirement.getAnnotationStringValue(annotation, ATTR_VALUE);
|
||||||
String[] anyOf = PermissionRequirement.getAnnotationStringValues(annotation, ATTR_ANY_OF);
|
String[] anyOf = PermissionRequirement.getAnnotationStringValues(annotation, ATTR_ANY_OF);
|
||||||
String[] allOf = PermissionRequirement.getAnnotationStringValues(annotation, ATTR_ALL_OF);
|
String[] allOf = PermissionRequirement.getAnnotationStringValues(annotation, ATTR_ALL_OF);
|
||||||
@@ -342,7 +342,7 @@ public class AnnotationDetector extends Detector implements Detector.UastScanner
|
|||||||
|
|
||||||
private void checkTargetType(@NonNull UAnnotation node, @NonNull String type1,
|
private void checkTargetType(@NonNull UAnnotation node, @NonNull String type1,
|
||||||
@Nullable String type2, boolean allowCollection) {
|
@Nullable String type2, boolean allowCollection) {
|
||||||
UElement parent = node.getContainingElement();
|
UElement parent = node.getUastParent();
|
||||||
PsiType type;
|
PsiType type;
|
||||||
|
|
||||||
if (parent instanceof UDeclarationsExpression) {
|
if (parent instanceof UDeclarationsExpression) {
|
||||||
|
|||||||
@@ -851,7 +851,7 @@ public class ApiDetector extends ResourceXmlDetector
|
|||||||
|
|
||||||
// It's okay to reference the constant as a case constant (since that
|
// It's okay to reference the constant as a case constant (since that
|
||||||
// code path won't be taken) or in a condition of an if statement
|
// code path won't be taken) or in a condition of an if statement
|
||||||
UElement curr = node.getContainingElement();
|
UElement curr = node.getUastParent();
|
||||||
while (curr != null) {
|
while (curr != null) {
|
||||||
if (curr instanceof USwitchClauseExpression) {
|
if (curr instanceof USwitchClauseExpression) {
|
||||||
List<UExpression> caseValues = ((USwitchClauseExpression) curr).getCaseValues();
|
List<UExpression> caseValues = ((USwitchClauseExpression) curr).getCaseValues();
|
||||||
@@ -869,7 +869,7 @@ public class ApiDetector extends ResourceXmlDetector
|
|||||||
} else if (curr instanceof UMethod || curr instanceof UClass) {
|
} else if (curr instanceof UMethod || curr instanceof UClass) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
curr = curr.getContainingElement();
|
curr = curr.getUastParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -1536,7 +1536,7 @@ public class ApiDetector extends ResourceXmlDetector
|
|||||||
return targetApi;
|
return targetApi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scope = scope.getContainingElement();
|
scope = scope.getUastParent();
|
||||||
if (scope instanceof PsiFile) {
|
if (scope instanceof PsiFile) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1730,7 +1730,7 @@ public class ApiDetector extends ResourceXmlDetector
|
|||||||
int api,
|
int api,
|
||||||
JavaContext context
|
JavaContext context
|
||||||
) {
|
) {
|
||||||
UElement current = element.getContainingElement();
|
UElement current = element.getUastParent();
|
||||||
UElement prev = element;
|
UElement prev = element;
|
||||||
while (current != null) {
|
while (current != null) {
|
||||||
if (current instanceof UIfExpression) {
|
if (current instanceof UIfExpression) {
|
||||||
@@ -1747,7 +1747,7 @@ public class ApiDetector extends ResourceXmlDetector
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
prev = current;
|
prev = current;
|
||||||
current = current.getContainingElement();
|
current = current.getUastParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -16,36 +16,28 @@
|
|||||||
|
|
||||||
package com.android.tools.klint.checks;
|
package com.android.tools.klint.checks;
|
||||||
|
|
||||||
import static com.android.SdkConstants.CLASS_VIEW;
|
|
||||||
import static com.android.SdkConstants.SUPPORT_ANNOTATIONS_PREFIX;
|
|
||||||
import static com.android.tools.klint.checks.SupportAnnotationDetector.filterRelevantAnnotations;
|
|
||||||
import static com.android.tools.klint.detector.api.LintUtils.skipParentheses;
|
|
||||||
|
|
||||||
import com.android.annotations.NonNull;
|
import com.android.annotations.NonNull;
|
||||||
import com.android.annotations.Nullable;
|
import com.android.annotations.Nullable;
|
||||||
import com.android.tools.klint.client.api.JavaEvaluator;
|
import com.android.tools.klint.client.api.JavaEvaluator;
|
||||||
import com.android.tools.klint.detector.api.Category;
|
import com.android.tools.klint.detector.api.*;
|
||||||
import com.android.tools.klint.detector.api.Detector;
|
|
||||||
import com.android.tools.klint.detector.api.Implementation;
|
|
||||||
import com.android.tools.klint.detector.api.Issue;
|
|
||||||
import com.android.tools.klint.detector.api.JavaContext;
|
|
||||||
import com.android.tools.klint.detector.api.Location;
|
|
||||||
import com.android.tools.klint.detector.api.Scope;
|
|
||||||
import com.android.tools.klint.detector.api.Severity;
|
|
||||||
import com.intellij.psi.PsiAnnotation;
|
import com.intellij.psi.PsiAnnotation;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.PsiMethod;
|
import com.intellij.psi.PsiMethod;
|
||||||
|
|
||||||
import org.jetbrains.uast.UElement;
|
import org.jetbrains.uast.UElement;
|
||||||
import org.jetbrains.uast.UMethod;
|
import org.jetbrains.uast.UMethod;
|
||||||
import org.jetbrains.uast.USuperExpression;
|
|
||||||
import org.jetbrains.uast.UReferenceExpression;
|
import org.jetbrains.uast.UReferenceExpression;
|
||||||
|
import org.jetbrains.uast.USuperExpression;
|
||||||
import org.jetbrains.uast.visitor.AbstractUastVisitor;
|
import org.jetbrains.uast.visitor.AbstractUastVisitor;
|
||||||
import org.jetbrains.uast.visitor.UastVisitor;
|
import org.jetbrains.uast.visitor.UastVisitor;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.android.SdkConstants.CLASS_VIEW;
|
||||||
|
import static com.android.SdkConstants.SUPPORT_ANNOTATIONS_PREFIX;
|
||||||
|
import static com.android.tools.klint.checks.SupportAnnotationDetector.filterRelevantAnnotations;
|
||||||
|
import static com.android.tools.klint.detector.api.LintUtils.skipParentheses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes sure that methods call super when overriding methods.
|
* Makes sure that methods call super when overriding methods.
|
||||||
*/
|
*/
|
||||||
@@ -185,7 +177,7 @@ public class CallSuperDetector extends Detector implements Detector.UastScanner
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean visitSuperExpression(USuperExpression node) {
|
public boolean visitSuperExpression(USuperExpression node) {
|
||||||
UElement parent = skipParentheses(node.getContainingElement());
|
UElement parent = skipParentheses(node.getUastParent());
|
||||||
if (parent instanceof UReferenceExpression) {
|
if (parent instanceof UReferenceExpression) {
|
||||||
PsiElement resolved = ((UReferenceExpression) parent).resolve();
|
PsiElement resolved = ((UReferenceExpression) parent).resolve();
|
||||||
if (mMethod.equals(resolved)) {
|
if (mMethod.equals(resolved)) {
|
||||||
|
|||||||
@@ -16,54 +16,16 @@
|
|||||||
|
|
||||||
package com.android.tools.klint.checks;
|
package com.android.tools.klint.checks;
|
||||||
|
|
||||||
import static com.android.SdkConstants.CLASS_CONTENTPROVIDER;
|
|
||||||
import static com.android.SdkConstants.CLASS_CONTEXT;
|
|
||||||
import static com.android.tools.klint.detector.api.LintUtils.skipParentheses;
|
|
||||||
import static org.jetbrains.uast.UastUtils.getOutermostQualified;
|
|
||||||
import static org.jetbrains.uast.UastUtils.getParentOfType;
|
|
||||||
import static org.jetbrains.uast.UastUtils.getQualifiedChain;
|
|
||||||
|
|
||||||
import com.android.SdkConstants;
|
import com.android.SdkConstants;
|
||||||
import com.android.annotations.NonNull;
|
import com.android.annotations.NonNull;
|
||||||
import com.android.annotations.Nullable;
|
import com.android.annotations.Nullable;
|
||||||
import com.android.tools.klint.client.api.JavaEvaluator;
|
import com.android.tools.klint.client.api.JavaEvaluator;
|
||||||
import com.android.tools.klint.detector.api.Category;
|
import com.android.tools.klint.detector.api.*;
|
||||||
import com.android.tools.klint.detector.api.Detector;
|
|
||||||
import com.android.tools.klint.detector.api.Implementation;
|
|
||||||
import com.android.tools.klint.detector.api.Issue;
|
|
||||||
import com.android.tools.klint.detector.api.JavaContext;
|
|
||||||
import com.android.tools.klint.detector.api.Location;
|
|
||||||
import com.android.tools.klint.detector.api.Scope;
|
|
||||||
import com.android.tools.klint.detector.api.Severity;
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.psi.PsiClass;
|
import com.intellij.psi.*;
|
||||||
import com.intellij.psi.PsiClassType;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiField;
|
|
||||||
import com.intellij.psi.PsiLocalVariable;
|
|
||||||
import com.intellij.psi.PsiMethod;
|
|
||||||
import com.intellij.psi.PsiType;
|
|
||||||
import com.intellij.psi.PsiVariable;
|
|
||||||
|
|
||||||
import com.intellij.psi.util.InheritanceUtil;
|
import com.intellij.psi.util.InheritanceUtil;
|
||||||
import com.intellij.util.containers.Predicate;
|
import com.intellij.util.containers.Predicate;
|
||||||
import org.jetbrains.uast.UBinaryExpression;
|
import org.jetbrains.uast.*;
|
||||||
import org.jetbrains.uast.UCallExpression;
|
|
||||||
import org.jetbrains.uast.UDoWhileExpression;
|
|
||||||
import org.jetbrains.uast.UElement;
|
|
||||||
import org.jetbrains.uast.UExpression;
|
|
||||||
import org.jetbrains.uast.UField;
|
|
||||||
import org.jetbrains.uast.UIfExpression;
|
|
||||||
import org.jetbrains.uast.ULocalVariable;
|
|
||||||
import org.jetbrains.uast.UMethod;
|
|
||||||
import org.jetbrains.uast.UQualifiedReferenceExpression;
|
|
||||||
import org.jetbrains.uast.UReturnExpression;
|
|
||||||
import org.jetbrains.uast.UUnaryExpression;
|
|
||||||
import org.jetbrains.uast.UVariable;
|
|
||||||
import org.jetbrains.uast.UWhileExpression;
|
|
||||||
import org.jetbrains.uast.UastCallKind;
|
|
||||||
import org.jetbrains.uast.UastUtils;
|
|
||||||
import org.jetbrains.uast.UReferenceExpression;
|
|
||||||
import org.jetbrains.uast.util.UastExpressionUtils;
|
import org.jetbrains.uast.util.UastExpressionUtils;
|
||||||
import org.jetbrains.uast.visitor.AbstractUastVisitor;
|
import org.jetbrains.uast.visitor.AbstractUastVisitor;
|
||||||
import org.jetbrains.uast.visitor.UastVisitor;
|
import org.jetbrains.uast.visitor.UastVisitor;
|
||||||
@@ -71,6 +33,11 @@ import org.jetbrains.uast.visitor.UastVisitor;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.android.SdkConstants.CLASS_CONTENTPROVIDER;
|
||||||
|
import static com.android.SdkConstants.CLASS_CONTEXT;
|
||||||
|
import static com.android.tools.klint.detector.api.LintUtils.skipParentheses;
|
||||||
|
import static org.jetbrains.uast.UastUtils.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for missing {@code recycle} calls on resources that encourage it, and
|
* Checks for missing {@code recycle} calls on resources that encourage it, and
|
||||||
* for missing {@code commit} calls on FragmentTransactions, etc.
|
* for missing {@code commit} calls on FragmentTransactions, etc.
|
||||||
@@ -718,10 +685,10 @@ public class CleanupDetector extends Detector implements Detector.UastScanner {
|
|||||||
// apply if the return value is not considered
|
// apply if the return value is not considered
|
||||||
|
|
||||||
UElement qualifiedNode = node;
|
UElement qualifiedNode = node;
|
||||||
UElement parent = skipParentheses(node.getContainingElement());
|
UElement parent = skipParentheses(node.getUastParent());
|
||||||
while (parent instanceof UReferenceExpression) {
|
while (parent instanceof UReferenceExpression) {
|
||||||
qualifiedNode = parent;
|
qualifiedNode = parent;
|
||||||
parent = skipParentheses(parent.getContainingElement());
|
parent = skipParentheses(parent.getUastParent());
|
||||||
}
|
}
|
||||||
boolean returnValueIgnored = true;
|
boolean returnValueIgnored = true;
|
||||||
|
|
||||||
@@ -761,7 +728,7 @@ public class CleanupDetector extends Detector implements Detector.UastScanner {
|
|||||||
public static PsiVariable getVariableElement(@NonNull UCallExpression rhs,
|
public static PsiVariable getVariableElement(@NonNull UCallExpression rhs,
|
||||||
boolean allowChainedCalls) {
|
boolean allowChainedCalls) {
|
||||||
UElement parent = skipParentheses(
|
UElement parent = skipParentheses(
|
||||||
UastUtils.getQualifiedParentOrThis(rhs).getContainingElement());
|
UastUtils.getQualifiedParentOrThis(rhs).getUastParent());
|
||||||
|
|
||||||
// Handle some types of chained calls; e.g. you might have
|
// Handle some types of chained calls; e.g. you might have
|
||||||
// var = prefs.edit().put(key,value)
|
// var = prefs.edit().put(key,value)
|
||||||
@@ -769,9 +736,9 @@ public class CleanupDetector extends Detector implements Detector.UastScanner {
|
|||||||
if (allowChainedCalls) {
|
if (allowChainedCalls) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if ((parent instanceof UQualifiedReferenceExpression)) {
|
if ((parent instanceof UQualifiedReferenceExpression)) {
|
||||||
UElement parentParent = skipParentheses(parent.getContainingElement());
|
UElement parentParent = skipParentheses(parent.getUastParent());
|
||||||
if ((parentParent instanceof UQualifiedReferenceExpression)) {
|
if ((parentParent instanceof UQualifiedReferenceExpression)) {
|
||||||
parent = skipParentheses(parentParent.getContainingElement());
|
parent = skipParentheses(parentParent.getUastParent());
|
||||||
} else if (parentParent instanceof UVariable
|
} else if (parentParent instanceof UVariable
|
||||||
|| parentParent instanceof UBinaryExpression) {
|
|| parentParent instanceof UBinaryExpression) {
|
||||||
parent = parentParent;
|
parent = parentParent;
|
||||||
|
|||||||
+6
-21
@@ -16,36 +16,21 @@
|
|||||||
|
|
||||||
package com.android.tools.klint.checks;
|
package com.android.tools.klint.checks;
|
||||||
|
|
||||||
import static com.android.SdkConstants.CLASS_CONTEXT;
|
|
||||||
import static com.android.SdkConstants.CLASS_VIEW;
|
|
||||||
import static com.android.SdkConstants.CLASS_VIEWGROUP;
|
|
||||||
import static com.android.SdkConstants.DOT_LAYOUT_PARAMS;
|
|
||||||
import static com.android.SdkConstants.R_STYLEABLE_PREFIX;
|
|
||||||
import static com.android.tools.klint.detector.api.LintUtils.skipParentheses;
|
|
||||||
|
|
||||||
import com.android.annotations.NonNull;
|
import com.android.annotations.NonNull;
|
||||||
import com.android.annotations.Nullable;
|
import com.android.annotations.Nullable;
|
||||||
import com.android.tools.klint.detector.api.Category;
|
import com.android.tools.klint.detector.api.*;
|
||||||
import com.android.tools.klint.detector.api.Detector;
|
|
||||||
import com.android.tools.klint.detector.api.Implementation;
|
|
||||||
import com.android.tools.klint.detector.api.Issue;
|
|
||||||
import com.android.tools.klint.detector.api.JavaContext;
|
|
||||||
import com.android.tools.klint.detector.api.Scope;
|
|
||||||
import com.android.tools.klint.detector.api.Severity;
|
|
||||||
import com.intellij.psi.PsiClass;
|
import com.intellij.psi.PsiClass;
|
||||||
import com.intellij.psi.util.InheritanceUtil;
|
import com.intellij.psi.util.InheritanceUtil;
|
||||||
import com.intellij.psi.util.PsiTreeUtil;
|
import com.intellij.psi.util.PsiTreeUtil;
|
||||||
|
import org.jetbrains.uast.*;
|
||||||
import org.jetbrains.uast.UCallExpression;
|
|
||||||
import org.jetbrains.uast.UClass;
|
|
||||||
import org.jetbrains.uast.UExpression;
|
|
||||||
import org.jetbrains.uast.UMethod;
|
|
||||||
import org.jetbrains.uast.UastUtils;
|
|
||||||
import org.jetbrains.uast.visitor.UastVisitor;
|
import org.jetbrains.uast.visitor.UastVisitor;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.android.SdkConstants.*;
|
||||||
|
import static com.android.tools.klint.detector.api.LintUtils.skipParentheses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes sure that custom views use a declare styleable that matches
|
* Makes sure that custom views use a declare styleable that matches
|
||||||
* the name of the custom view
|
* the name of the custom view
|
||||||
@@ -89,7 +74,7 @@ public class CustomViewDetector extends Detector implements Detector.UastScanner
|
|||||||
@Override
|
@Override
|
||||||
public void visitMethod(@NonNull JavaContext context, @Nullable UastVisitor visitor,
|
public void visitMethod(@NonNull JavaContext context, @Nullable UastVisitor visitor,
|
||||||
@NonNull UCallExpression node, @NonNull UMethod method) {
|
@NonNull UCallExpression node, @NonNull UMethod method) {
|
||||||
if (skipParentheses(node.getContainingElement()) instanceof UExpression) {
|
if (skipParentheses(node.getUastParent()) instanceof UExpression) {
|
||||||
if (!context.getEvaluator().isMemberInSubClassOf(method, CLASS_CONTEXT, false)) {
|
if (!context.getEvaluator().isMemberInSubClassOf(method, CLASS_CONTEXT, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class CutPasteDetector extends Detector implements Detector.UastScanner {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static String getLhs(@NonNull UCallExpression call) {
|
private static String getLhs(@NonNull UCallExpression call) {
|
||||||
UElement parent = call.getContainingElement();
|
UElement parent = call.getUastParent();
|
||||||
while (parent != null && !(parent instanceof UBlockExpression)) {
|
while (parent != null && !(parent instanceof UBlockExpression)) {
|
||||||
if (parent instanceof ULocalVariable) {
|
if (parent instanceof ULocalVariable) {
|
||||||
return ((ULocalVariable) parent).getName();
|
return ((ULocalVariable) parent).getName();
|
||||||
@@ -152,7 +152,7 @@ public class CutPasteDetector extends Detector implements Detector.UastScanner {
|
|||||||
return aa.getReceiver().asSourceString();
|
return aa.getReceiver().asSourceString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent = parent.getContainingElement();
|
parent = parent.getUastParent();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@ public class CutPasteDetector extends Detector implements Detector.UastScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static UExpression getBreakedExpression(UBreakExpression node) {
|
private static UExpression getBreakedExpression(UBreakExpression node) {
|
||||||
UElement parent = node.getContainingElement();
|
UElement parent = node.getUastParent();
|
||||||
String label = node.getLabel();
|
String label = node.getLabel();
|
||||||
while (parent != null) {
|
while (parent != null) {
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
@@ -306,13 +306,13 @@ public class CutPasteDetector extends Detector implements Detector.UastScanner {
|
|||||||
return (UExpression) parent;
|
return (UExpression) parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent = parent.getContainingElement();
|
parent = parent.getUastParent();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UExpression getContinuedExpression(UContinueExpression node) {
|
private static UExpression getContinuedExpression(UContinueExpression node) {
|
||||||
UElement parent = node.getContainingElement();
|
UElement parent = node.getUastParent();
|
||||||
String label = node.getLabel();
|
String label = node.getLabel();
|
||||||
while (parent != null) {
|
while (parent != null) {
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
@@ -327,7 +327,7 @@ public class CutPasteDetector extends Detector implements Detector.UastScanner {
|
|||||||
return (UExpression) parent;
|
return (UExpression) parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent = parent.getContainingElement();
|
parent = parent.getUastParent();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-39
@@ -16,51 +16,17 @@
|
|||||||
|
|
||||||
package com.android.tools.klint.checks;
|
package com.android.tools.klint.checks;
|
||||||
|
|
||||||
import static com.android.SdkConstants.SUPPORT_LIB_ARTIFACT;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_BOOLEAN;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_BOOLEAN_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_BYTE_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_CHARACTER_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_DOUBLE_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_FLOAT_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_INT;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_INTEGER_WRAPPER;
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_LONG_WRAPPER;
|
|
||||||
import static com.android.tools.klint.detector.api.LintUtils.skipParentheses;
|
|
||||||
|
|
||||||
import com.android.annotations.NonNull;
|
import com.android.annotations.NonNull;
|
||||||
import com.android.annotations.Nullable;
|
import com.android.annotations.Nullable;
|
||||||
import com.android.tools.klint.client.api.JavaEvaluator;
|
import com.android.tools.klint.client.api.JavaEvaluator;
|
||||||
import com.android.tools.klint.detector.api.Category;
|
import com.android.tools.klint.detector.api.*;
|
||||||
import com.android.tools.klint.detector.api.Detector;
|
|
||||||
import com.android.tools.klint.detector.api.Implementation;
|
|
||||||
import com.android.tools.klint.detector.api.Issue;
|
|
||||||
import com.android.tools.klint.detector.api.JavaContext;
|
|
||||||
import com.android.tools.klint.detector.api.Scope;
|
|
||||||
import com.android.tools.klint.detector.api.Severity;
|
|
||||||
import com.android.tools.klint.detector.api.TextFormat;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.collect.Sets.SetView;
|
import com.google.common.collect.Sets.SetView;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.PsiField;
|
import com.intellij.psi.PsiField;
|
||||||
import com.intellij.psi.PsiMethod;
|
import com.intellij.psi.PsiMethod;
|
||||||
import com.intellij.psi.PsiType;
|
import com.intellij.psi.PsiType;
|
||||||
|
import org.jetbrains.uast.*;
|
||||||
import org.jetbrains.uast.UBinaryExpression;
|
|
||||||
import org.jetbrains.uast.UCallExpression;
|
|
||||||
import org.jetbrains.uast.UElement;
|
|
||||||
import org.jetbrains.uast.UExpression;
|
|
||||||
import org.jetbrains.uast.UIfExpression;
|
|
||||||
import org.jetbrains.uast.UMethod;
|
|
||||||
import org.jetbrains.uast.UParenthesizedExpression;
|
|
||||||
import org.jetbrains.uast.UPrefixExpression;
|
|
||||||
import org.jetbrains.uast.UQualifiedReferenceExpression;
|
|
||||||
import org.jetbrains.uast.USimpleNameReferenceExpression;
|
|
||||||
import org.jetbrains.uast.USuperExpression;
|
|
||||||
import org.jetbrains.uast.UThisExpression;
|
|
||||||
import org.jetbrains.uast.UThrowExpression;
|
|
||||||
import org.jetbrains.uast.UastUtils;
|
|
||||||
import org.jetbrains.uast.UReferenceExpression;
|
|
||||||
import org.jetbrains.uast.util.UastExpressionUtils;
|
import org.jetbrains.uast.util.UastExpressionUtils;
|
||||||
import org.jetbrains.uast.visitor.AbstractUastVisitor;
|
import org.jetbrains.uast.visitor.AbstractUastVisitor;
|
||||||
import org.jetbrains.uast.visitor.UastVisitor;
|
import org.jetbrains.uast.visitor.UastVisitor;
|
||||||
@@ -70,6 +36,10 @@ import java.util.Collection;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.android.SdkConstants.SUPPORT_LIB_ARTIFACT;
|
||||||
|
import static com.android.tools.klint.client.api.JavaParser.*;
|
||||||
|
import static com.android.tools.klint.detector.api.LintUtils.skipParentheses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for performance issues in Java files, such as memory allocations during
|
* Looks for performance issues in Java files, such as memory allocations during
|
||||||
* drawing operations and using HashMap instead of SparseArray.
|
* drawing operations and using HashMap instead of SparseArray.
|
||||||
@@ -237,7 +207,7 @@ public class JavaPerformanceDetector extends Detector implements Detector.UastSc
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mFlagAllocations
|
if (mFlagAllocations
|
||||||
&& !(skipParentheses(node.getContainingElement()) instanceof UThrowExpression)
|
&& !(skipParentheses(node.getUastParent()) instanceof UThrowExpression)
|
||||||
&& mCheckAllocations) {
|
&& mCheckAllocations) {
|
||||||
// Make sure we're still inside the method declaration that marked
|
// Make sure we're still inside the method declaration that marked
|
||||||
// mInDraw as true, in case we've left it and we're in a static
|
// mInDraw as true, in case we've left it and we're in a static
|
||||||
@@ -316,7 +286,7 @@ public class JavaPerformanceDetector extends Detector implements Detector.UastSc
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
private static boolean isLazilyInitialized(UElement node) {
|
private static boolean isLazilyInitialized(UElement node) {
|
||||||
UElement curr = node.getContainingElement();
|
UElement curr = node.getUastParent();
|
||||||
while (curr != null) {
|
while (curr != null) {
|
||||||
if (curr instanceof UMethod) {
|
if (curr instanceof UMethod) {
|
||||||
return false;
|
return false;
|
||||||
@@ -347,7 +317,7 @@ public class JavaPerformanceDetector extends Detector implements Detector.UastSc
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
curr = curr.getContainingElement();
|
curr = curr.getUastParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -16,36 +16,18 @@
|
|||||||
|
|
||||||
package com.android.tools.klint.checks;
|
package com.android.tools.klint.checks;
|
||||||
|
|
||||||
import static com.android.tools.klint.client.api.JavaParser.TYPE_STRING;
|
|
||||||
|
|
||||||
import com.android.annotations.NonNull;
|
import com.android.annotations.NonNull;
|
||||||
import com.android.annotations.Nullable;
|
import com.android.annotations.Nullable;
|
||||||
import com.android.tools.klint.client.api.JavaEvaluator;
|
import com.android.tools.klint.client.api.JavaEvaluator;
|
||||||
import com.android.tools.klint.client.api.UastLintUtils;
|
import com.android.tools.klint.client.api.UastLintUtils;
|
||||||
import com.android.tools.klint.detector.api.Category;
|
import com.android.tools.klint.detector.api.*;
|
||||||
import com.android.tools.klint.detector.api.ConstantEvaluator;
|
import com.intellij.psi.*;
|
||||||
import com.android.tools.klint.detector.api.Detector;
|
|
||||||
import com.android.tools.klint.detector.api.Implementation;
|
|
||||||
import com.android.tools.klint.detector.api.Issue;
|
|
||||||
import com.android.tools.klint.detector.api.JavaContext;
|
|
||||||
import com.android.tools.klint.detector.api.Location;
|
|
||||||
import com.android.tools.klint.detector.api.Scope;
|
|
||||||
import com.android.tools.klint.detector.api.Severity;
|
|
||||||
import com.intellij.psi.PsiClass;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiNamedElement;
|
|
||||||
import com.intellij.psi.PsiParameterList;
|
|
||||||
import com.intellij.psi.PsiVariable;
|
|
||||||
|
|
||||||
import org.jetbrains.uast.*;
|
import org.jetbrains.uast.*;
|
||||||
import org.jetbrains.uast.visitor.UastVisitor;
|
import org.jetbrains.uast.visitor.UastVisitor;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import static com.android.tools.klint.client.api.JavaParser.TYPE_STRING;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detector for finding inefficiencies and errors in logging calls.
|
* Detector for finding inefficiencies and errors in logging calls.
|
||||||
@@ -142,7 +124,7 @@ public class LogDetector extends Detector implements Detector.UastScanner {
|
|||||||
|
|
||||||
String name = method.getName();
|
String name = method.getName();
|
||||||
boolean withinConditional = IS_LOGGABLE.equals(name) ||
|
boolean withinConditional = IS_LOGGABLE.equals(name) ||
|
||||||
checkWithinConditional(context, node.getContainingElement(), node);
|
checkWithinConditional(context, node.getUastParent(), node);
|
||||||
|
|
||||||
// See if it's surrounded by an if statement (and it's one of the non-error, spammy
|
// See if it's surrounded by an if statement (and it's one of the non-error, spammy
|
||||||
// log methods (info, verbose, etc))
|
// log methods (info, verbose, etc))
|
||||||
@@ -249,7 +231,7 @@ public class LogDetector extends Detector implements Detector.UastScanner {
|
|||||||
|| curr instanceof UClass) { // static block
|
|| curr instanceof UClass) { // static block
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
curr = curr.getContainingElement();
|
curr = curr.getUastParent();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-18
@@ -17,28 +17,13 @@
|
|||||||
package com.android.tools.klint.checks;
|
package com.android.tools.klint.checks;
|
||||||
|
|
||||||
|
|
||||||
import static com.android.tools.klint.checks.CutPasteDetector.isReachableFrom;
|
|
||||||
|
|
||||||
import com.android.annotations.NonNull;
|
import com.android.annotations.NonNull;
|
||||||
import com.android.annotations.Nullable;
|
import com.android.annotations.Nullable;
|
||||||
import com.android.tools.klint.client.api.JavaEvaluator;
|
import com.android.tools.klint.client.api.JavaEvaluator;
|
||||||
import com.android.tools.klint.detector.api.Category;
|
import com.android.tools.klint.detector.api.*;
|
||||||
import com.android.tools.klint.detector.api.Detector;
|
|
||||||
import com.android.tools.klint.detector.api.Implementation;
|
|
||||||
import com.android.tools.klint.detector.api.Issue;
|
|
||||||
import com.android.tools.klint.detector.api.JavaContext;
|
|
||||||
import com.android.tools.klint.detector.api.Scope;
|
|
||||||
import com.android.tools.klint.detector.api.Severity;
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.intellij.psi.PsiClass;
|
import com.intellij.psi.*;
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiField;
|
|
||||||
import com.intellij.psi.PsiLocalVariable;
|
|
||||||
import com.intellij.psi.PsiMethod;
|
|
||||||
import com.intellij.psi.PsiParameter;
|
|
||||||
import com.intellij.psi.PsiVariable;
|
|
||||||
|
|
||||||
import org.jetbrains.uast.*;
|
import org.jetbrains.uast.*;
|
||||||
import org.jetbrains.uast.util.UastExpressionUtils;
|
import org.jetbrains.uast.util.UastExpressionUtils;
|
||||||
import org.jetbrains.uast.visitor.AbstractUastVisitor;
|
import org.jetbrains.uast.visitor.AbstractUastVisitor;
|
||||||
@@ -47,6 +32,8 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.android.tools.klint.checks.CutPasteDetector.isReachableFrom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks related to RecyclerView usage.
|
* Checks related to RecyclerView usage.
|
||||||
*/
|
*/
|
||||||
@@ -171,7 +158,7 @@ public class RecyclerViewDetector extends Detector implements Detector.UastScann
|
|||||||
// want
|
// want
|
||||||
UExpression statement = UastUtils.getParentOfType(reference, UExpression.class, true);
|
UExpression statement = UastUtils.getParentOfType(reference, UExpression.class, true);
|
||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
parentToChildren.put(statement.getContainingElement(), reference);
|
parentToChildren.put(statement.getUastParent(), reference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -79,7 +79,7 @@ public class ServiceCastDetector extends Detector implements Detector.UastScanne
|
|||||||
public void visitMethod(@NonNull JavaContext context, @Nullable UastVisitor visitor,
|
public void visitMethod(@NonNull JavaContext context, @Nullable UastVisitor visitor,
|
||||||
@NonNull UCallExpression call, @NonNull UMethod method) {
|
@NonNull UCallExpression call, @NonNull UMethod method) {
|
||||||
UElement parent = LintUtils.skipParentheses(
|
UElement parent = LintUtils.skipParentheses(
|
||||||
UastUtils.getQualifiedParentOrThis(call).getContainingElement());
|
UastUtils.getQualifiedParentOrThis(call).getUastParent());
|
||||||
if (UastExpressionUtils.isTypeCast(parent)) {
|
if (UastExpressionUtils.isTypeCast(parent)) {
|
||||||
UBinaryExpressionWithType cast = (UBinaryExpressionWithType) parent;
|
UBinaryExpressionWithType cast = (UBinaryExpressionWithType) parent;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -734,7 +734,7 @@ public class SupportAnnotationDetector extends Detector implements Detector.Uast
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isExpressionValueUnused(UExpression expression) {
|
private static boolean isExpressionValueUnused(UExpression expression) {
|
||||||
return getQualifiedParentOrThis(expression).getContainingElement()
|
return getQualifiedParentOrThis(expression).getUastParent()
|
||||||
instanceof UBlockExpression;
|
instanceof UBlockExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,6 @@
|
|||||||
|
|
||||||
package com.android.tools.klint.checks;
|
package com.android.tools.klint.checks;
|
||||||
|
|
||||||
import static com.android.SdkConstants.ANDROID_URI;
|
|
||||||
import static com.android.SdkConstants.ATTR_CLASS;
|
|
||||||
import static com.android.SdkConstants.ATTR_ID;
|
|
||||||
import static com.android.SdkConstants.DOT_XML;
|
|
||||||
import static com.android.SdkConstants.ID_PREFIX;
|
|
||||||
import static com.android.SdkConstants.NEW_ID_PREFIX;
|
|
||||||
import static com.android.SdkConstants.VIEW_TAG;
|
|
||||||
|
|
||||||
import com.android.annotations.NonNull;
|
import com.android.annotations.NonNull;
|
||||||
import com.android.annotations.Nullable;
|
import com.android.annotations.Nullable;
|
||||||
import com.android.ide.common.res2.AbstractResourceRepository;
|
import com.android.ide.common.res2.AbstractResourceRepository;
|
||||||
@@ -33,51 +25,20 @@ import com.android.ide.common.resources.ResourceUrl;
|
|||||||
import com.android.resources.ResourceFolderType;
|
import com.android.resources.ResourceFolderType;
|
||||||
import com.android.resources.ResourceType;
|
import com.android.resources.ResourceType;
|
||||||
import com.android.tools.klint.client.api.LintClient;
|
import com.android.tools.klint.client.api.LintClient;
|
||||||
import com.android.tools.klint.detector.api.Category;
|
import com.android.tools.klint.detector.api.*;
|
||||||
import com.android.tools.klint.detector.api.Context;
|
|
||||||
import com.android.tools.klint.detector.api.Detector;
|
|
||||||
import com.android.tools.klint.detector.api.Implementation;
|
|
||||||
import com.android.tools.klint.detector.api.Issue;
|
|
||||||
import com.android.tools.klint.detector.api.JavaContext;
|
|
||||||
import com.android.tools.klint.detector.api.LintUtils;
|
|
||||||
import com.android.tools.klint.detector.api.ResourceEvaluator;
|
|
||||||
import com.android.tools.klint.detector.api.ResourceXmlDetector;
|
|
||||||
import com.android.tools.klint.detector.api.Scope;
|
|
||||||
import com.android.tools.klint.detector.api.Severity;
|
|
||||||
import com.android.tools.klint.detector.api.Speed;
|
|
||||||
import com.android.tools.klint.detector.api.XmlContext;
|
|
||||||
import com.android.utils.XmlUtils;
|
import com.android.utils.XmlUtils;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.*;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import com.intellij.psi.PsiClassType;
|
import com.intellij.psi.PsiClassType;
|
||||||
import com.intellij.psi.PsiType;
|
import com.intellij.psi.PsiType;
|
||||||
|
import org.jetbrains.uast.*;
|
||||||
import org.jetbrains.uast.UBinaryExpressionWithType;
|
|
||||||
import org.jetbrains.uast.UCallExpression;
|
|
||||||
import org.jetbrains.uast.UElement;
|
|
||||||
import org.jetbrains.uast.UExpression;
|
|
||||||
import org.jetbrains.uast.UMethod;
|
|
||||||
import org.jetbrains.uast.UParenthesizedExpression;
|
|
||||||
import org.jetbrains.uast.visitor.UastVisitor;
|
import org.jetbrains.uast.visitor.UastVisitor;
|
||||||
import org.w3c.dom.Attr;
|
import org.w3c.dom.*;
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import static com.android.SdkConstants.*;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/** Detector for finding inconsistent usage of views and casts
|
/** Detector for finding inconsistent usage of views and casts
|
||||||
* <p>
|
* <p>
|
||||||
@@ -189,11 +150,11 @@ public class ViewTypeDetector extends ResourceXmlDetector implements Detector.Ua
|
|||||||
}
|
}
|
||||||
assert method.getName().equals("findViewById");
|
assert method.getName().equals("findViewById");
|
||||||
UElement node = LintUtils.skipParentheses(call);
|
UElement node = LintUtils.skipParentheses(call);
|
||||||
while (node != null && node.getContainingElement() instanceof UParenthesizedExpression) {
|
while (node != null && node.getUastParent() instanceof UParenthesizedExpression) {
|
||||||
node = node.getContainingElement();
|
node = node.getUastParent();
|
||||||
}
|
}
|
||||||
if (node.getContainingElement() instanceof UBinaryExpressionWithType) {
|
if (node.getUastParent() instanceof UBinaryExpressionWithType) {
|
||||||
UBinaryExpressionWithType cast = (UBinaryExpressionWithType) node.getContainingElement();
|
UBinaryExpressionWithType cast = (UBinaryExpressionWithType) node.getUastParent();
|
||||||
PsiType type = cast.getType();
|
PsiType type = cast.getType();
|
||||||
String castType = null;
|
String castType = null;
|
||||||
if (type instanceof PsiClassType) {
|
if (type instanceof PsiClassType) {
|
||||||
|
|||||||
+1
-1
@@ -261,7 +261,7 @@ public class IntellijLintUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
element = element.getContainingElement();
|
element = element.getUastParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import org.jetbrains.uast.*
|
|||||||
|
|
||||||
class KotlinUAnnotation(
|
class KotlinUAnnotation(
|
||||||
override val psi: KtAnnotationEntry,
|
override val psi: KtAnnotationEntry,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : UAnnotation {
|
) : UAnnotation {
|
||||||
private val resolvedAnnotation by lz { psi.analyze()[BindingContext.ANNOTATION, psi] }
|
private val resolvedAnnotation by lz { psi.analyze()[BindingContext.ANNOTATION, psi] }
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ class KotlinUAnnotation(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KotlinUNamedExpression(override val name: String, override val containingElement: UElement?) : UNamedExpression {
|
class KotlinUNamedExpression(override val name: String, override val uastParent: UElement?) : UNamedExpression {
|
||||||
override lateinit var expression: UExpression
|
override lateinit var expression: UExpression
|
||||||
|
|
||||||
override val annotations: List<UAnnotation>
|
override val annotations: List<UAnnotation>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import org.jetbrains.uast.kotlin.declarations.KotlinUMethod
|
|||||||
|
|
||||||
class KotlinUClass private constructor(
|
class KotlinUClass private constructor(
|
||||||
psi: KtLightClass,
|
psi: KtLightClass,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : AbstractJavaUClass(), PsiClass by psi {
|
) : AbstractJavaUClass(), PsiClass by psi {
|
||||||
|
|
||||||
val ktClass = psi.kotlinOrigin
|
val ktClass = psi.kotlinOrigin
|
||||||
@@ -49,17 +49,21 @@ class KotlinUClass private constructor(
|
|||||||
override val uastAnchor: UElement
|
override val uastAnchor: UElement
|
||||||
get() = UIdentifier(psi.nameIdentifier, this)
|
get() = UIdentifier(psi.nameIdentifier, this)
|
||||||
|
|
||||||
override val uastNestedClasses: List<UClass> by lz {
|
override fun getInnerClasses(): Array<UClass> {
|
||||||
// filter DefaultImpls to avoid processing same methods from original interface multiple times
|
// filter DefaultImpls to avoid processing same methods from original interface multiple times
|
||||||
// filter Enum entry classes to avoid duplication with PsiEnumConstant initializer class
|
// filter Enum entry classes to avoid duplication with PsiEnumConstant initializer class
|
||||||
psi.innerClasses.filter {
|
return psi.innerClasses.filter {
|
||||||
it.name != JvmAbi.DEFAULT_IMPLS_CLASS_NAME && !it.isEnumEntryLightClass()
|
it.name != JvmAbi.DEFAULT_IMPLS_CLASS_NAME && !it.isEnumEntryLightClass()
|
||||||
}.map {
|
}.map {
|
||||||
getLanguagePlugin().convert<UClass>(it, this)
|
getLanguagePlugin().convert<UClass>(it, this)
|
||||||
}
|
}.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
override val uastMethods: List<UMethod> by lz {
|
override fun getSuperClass(): UClass? = super.getSuperClass()
|
||||||
|
override fun getFields(): Array<UField> = super.getFields()
|
||||||
|
override fun getInitializers(): Array<UClassInitializer> = super.getInitializers()
|
||||||
|
|
||||||
|
override fun getMethods(): Array<UMethod> {
|
||||||
val primaryConstructor = ktClass?.getPrimaryConstructor()?.toLightMethods()?.firstOrNull()
|
val primaryConstructor = ktClass?.getPrimaryConstructor()?.toLightMethods()?.firstOrNull()
|
||||||
val initBlocks = ktClass?.getAnonymousInitializers() ?: emptyList()
|
val initBlocks = ktClass?.getAnonymousInitializers() ?: emptyList()
|
||||||
|
|
||||||
@@ -75,7 +79,7 @@ class KotlinUClass private constructor(
|
|||||||
override val psi: PsiElement?
|
override val psi: PsiElement?
|
||||||
get() = null
|
get() = null
|
||||||
|
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
get() = containingMethod
|
get() = containingMethod
|
||||||
|
|
||||||
override val annotations: List<UAnnotation>
|
override val annotations: List<UAnnotation>
|
||||||
@@ -96,10 +100,11 @@ class KotlinUClass private constructor(
|
|||||||
|
|
||||||
fun isDelegatedMethod(psiMethod: PsiMethod) = psiMethod is KtLightMethod && psiMethod.isDelegated
|
fun isDelegatedMethod(psiMethod: PsiMethod) = psiMethod is KtLightMethod && psiMethod.isDelegated
|
||||||
|
|
||||||
psi.methods.asSequence()
|
return psi.methods.asSequence()
|
||||||
.filterNot(::isDelegatedMethod)
|
.filterNot(::isDelegatedMethod)
|
||||||
.map(::createUMethod)
|
.map(::createUMethod)
|
||||||
.toList()
|
.toList()
|
||||||
|
.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun PsiClass.isEnumEntryLightClass() = (this as? KtLightClass)?.kotlinOrigin is KtEnumEntry
|
private fun PsiClass.isEnumEntryLightClass() = (this as? KtLightClass)?.kotlinOrigin is KtEnumEntry
|
||||||
@@ -116,7 +121,7 @@ class KotlinUClass private constructor(
|
|||||||
|
|
||||||
class KotlinUAnonymousClass(
|
class KotlinUAnonymousClass(
|
||||||
psi: PsiAnonymousClass,
|
psi: PsiAnonymousClass,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : AbstractJavaUClass(), UAnonymousClass, PsiAnonymousClass by psi {
|
) : AbstractJavaUClass(), UAnonymousClass, PsiAnonymousClass by psi {
|
||||||
|
|
||||||
override val psi: PsiAnonymousClass = unwrap<UAnonymousClass, PsiAnonymousClass>(psi)
|
override val psi: PsiAnonymousClass = unwrap<UAnonymousClass, PsiAnonymousClass>(psi)
|
||||||
@@ -125,6 +130,12 @@ class KotlinUAnonymousClass(
|
|||||||
return super<AbstractJavaUClass>.getOriginalElement()
|
return super<AbstractJavaUClass>.getOriginalElement()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getSuperClass(): UClass? = super<AbstractJavaUClass>.getSuperClass()
|
||||||
|
override fun getFields(): Array<UField> = super<AbstractJavaUClass>.getFields()
|
||||||
|
override fun getMethods(): Array<UMethod> = super<AbstractJavaUClass>.getMethods()
|
||||||
|
override fun getInitializers(): Array<UClassInitializer> = super<AbstractJavaUClass>.getInitializers()
|
||||||
|
override fun getInnerClasses(): Array<UClass> = super<AbstractJavaUClass>.getInnerClasses()
|
||||||
|
|
||||||
override val uastAnchor: UElement?
|
override val uastAnchor: UElement?
|
||||||
get() {
|
get() {
|
||||||
val ktClassOrObject = (psi.originalElement as? KtLightClass)?.kotlinOrigin as? KtObjectDeclaration ?: return null
|
val ktClassOrObject = (psi.originalElement as? KtLightClass)?.kotlinOrigin as? KtObjectDeclaration ?: return null
|
||||||
|
|||||||
+2
-2
@@ -28,7 +28,7 @@ import org.jetbrains.uast.USimpleNameReferenceExpression
|
|||||||
|
|
||||||
class KotlinUImportStatement(
|
class KotlinUImportStatement(
|
||||||
override val psi: KtImportDirective,
|
override val psi: KtImportDirective,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : UImportStatement {
|
) : UImportStatement {
|
||||||
override val isOnDemand: Boolean
|
override val isOnDemand: Boolean
|
||||||
get() = psi.isAllUnder
|
get() = psi.isAllUnder
|
||||||
@@ -47,7 +47,7 @@ class KotlinUImportStatement(
|
|||||||
private class ImportReference(
|
private class ImportReference(
|
||||||
override val psi: KtExpression,
|
override val psi: KtExpression,
|
||||||
override val identifier: String,
|
override val identifier: String,
|
||||||
override val containingElement: UElement?,
|
override val uastParent: UElement?,
|
||||||
private val importDirective: KtImportDirective
|
private val importDirective: KtImportDirective
|
||||||
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression {
|
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression {
|
||||||
override val resolvedName: String?
|
override val resolvedName: String?
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import org.jetbrains.uast.kotlin.*
|
|||||||
|
|
||||||
open class KotlinUMethod(
|
open class KotlinUMethod(
|
||||||
psi: KtLightMethod,
|
psi: KtLightMethod,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : UMethod, JavaUElementWithComments, PsiMethod by psi {
|
) : UMethod, JavaUElementWithComments, PsiMethod by psi {
|
||||||
override val psi: KtLightMethod = unwrap<UMethod, KtLightMethod>(psi)
|
override val psi: KtLightMethod = unwrap<UMethod, KtLightMethod>(psi)
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ abstract class AbstractKotlinUVariable : AbstractJavaUVariable() {
|
|||||||
|
|
||||||
class KotlinUVariable(
|
class KotlinUVariable(
|
||||||
psi: PsiVariable,
|
psi: PsiVariable,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : AbstractKotlinUVariable(), UVariable, PsiVariable by psi {
|
) : AbstractKotlinUVariable(), UVariable, PsiVariable by psi {
|
||||||
override val psi = unwrap<UVariable, PsiVariable>(psi)
|
override val psi = unwrap<UVariable, PsiVariable>(psi)
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ class KotlinUVariable(
|
|||||||
|
|
||||||
open class KotlinUParameter(
|
open class KotlinUParameter(
|
||||||
psi: PsiParameter,
|
psi: PsiParameter,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : AbstractKotlinUVariable(), UParameter, PsiParameter by psi {
|
) : AbstractKotlinUVariable(), UParameter, PsiParameter by psi {
|
||||||
|
|
||||||
override val psi = unwrap<UParameter, PsiParameter>(psi)
|
override val psi = unwrap<UParameter, PsiParameter>(psi)
|
||||||
@@ -97,7 +97,7 @@ open class KotlinUParameter(
|
|||||||
|
|
||||||
open class KotlinUField(
|
open class KotlinUField(
|
||||||
psi: PsiField,
|
psi: PsiField,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : AbstractKotlinUVariable(), UField, PsiField by psi {
|
) : AbstractKotlinUVariable(), UField, PsiField by psi {
|
||||||
|
|
||||||
override val psi = unwrap<UField, PsiField>(psi)
|
override val psi = unwrap<UField, PsiField>(psi)
|
||||||
@@ -113,7 +113,7 @@ open class KotlinUField(
|
|||||||
|
|
||||||
open class KotlinULocalVariable(
|
open class KotlinULocalVariable(
|
||||||
psi: PsiLocalVariable,
|
psi: PsiLocalVariable,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : AbstractKotlinUVariable(), ULocalVariable, PsiLocalVariable by psi {
|
) : AbstractKotlinUVariable(), ULocalVariable, PsiLocalVariable by psi {
|
||||||
|
|
||||||
override val psi = unwrap<ULocalVariable, PsiLocalVariable>(psi)
|
override val psi = unwrap<ULocalVariable, PsiLocalVariable>(psi)
|
||||||
@@ -130,7 +130,7 @@ open class KotlinULocalVariable(
|
|||||||
|
|
||||||
open class KotlinUEnumConstant(
|
open class KotlinUEnumConstant(
|
||||||
psi: PsiEnumConstant,
|
psi: PsiEnumConstant,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : AbstractKotlinUVariable(), UEnumConstant, PsiEnumConstant by psi {
|
) : AbstractKotlinUVariable(), UEnumConstant, PsiEnumConstant by psi {
|
||||||
override val initializingClass: UClass? by lz { getLanguagePlugin().convertOpt<UClass>(psi.initializingClass, this) }
|
override val initializingClass: UClass? by lz { getLanguagePlugin().convertOpt<UClass>(psi.initializingClass, this) }
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ open class KotlinUEnumConstant(
|
|||||||
|
|
||||||
private class KotlinEnumConstantClassReference(
|
private class KotlinEnumConstantClassReference(
|
||||||
override val psi: PsiEnumConstant,
|
override val psi: PsiEnumConstant,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : JavaAbstractUExpression(), USimpleNameReferenceExpression {
|
) : JavaAbstractUExpression(), USimpleNameReferenceExpression {
|
||||||
override fun resolve() = psi.containingClass
|
override fun resolve() = psi.containingClass
|
||||||
override val resolvedName: String?
|
override val resolvedName: String?
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ private fun createVariableReferenceExpression(variable: UVariable, containingEle
|
|||||||
object : USimpleNameReferenceExpression {
|
object : USimpleNameReferenceExpression {
|
||||||
override val psi: PsiElement? = null
|
override val psi: PsiElement? = null
|
||||||
override fun resolve(): PsiElement? = variable
|
override fun resolve(): PsiElement? = variable
|
||||||
override val containingElement: UElement? = containingElement
|
override val uastParent: UElement? = containingElement
|
||||||
override val resolvedName: String? = variable.name
|
override val resolvedName: String? = variable.name
|
||||||
override val annotations: List<UAnnotation> = emptyList()
|
override val annotations: List<UAnnotation> = emptyList()
|
||||||
override val identifier: String = variable.name.orAnonymous()
|
override val identifier: String = variable.name.orAnonymous()
|
||||||
@@ -23,7 +23,7 @@ private fun createVariableReferenceExpression(variable: UVariable, containingEle
|
|||||||
private fun createNullLiteralExpression(containingElement: UElement?) =
|
private fun createNullLiteralExpression(containingElement: UElement?) =
|
||||||
object : ULiteralExpression {
|
object : ULiteralExpression {
|
||||||
override val psi: PsiElement? = null
|
override val psi: PsiElement? = null
|
||||||
override val containingElement: UElement? = containingElement
|
override val uastParent: UElement? = containingElement
|
||||||
override val value: Any? = null
|
override val value: Any? = null
|
||||||
override val annotations: List<UAnnotation> = emptyList()
|
override val annotations: List<UAnnotation> = emptyList()
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ private fun createNullLiteralExpression(containingElement: UElement?) =
|
|||||||
private fun createNotEqWithNullExpression(variable: UVariable, containingElement: UElement?) =
|
private fun createNotEqWithNullExpression(variable: UVariable, containingElement: UElement?) =
|
||||||
object : UBinaryExpression {
|
object : UBinaryExpression {
|
||||||
override val psi: PsiElement? = null
|
override val psi: PsiElement? = null
|
||||||
override val containingElement: UElement? = containingElement
|
override val uastParent: UElement? = containingElement
|
||||||
override val leftOperand: UExpression by lz { createVariableReferenceExpression(variable, this) }
|
override val leftOperand: UExpression by lz { createVariableReferenceExpression(variable, this) }
|
||||||
override val rightOperand: UExpression by lz { createNullLiteralExpression(this) }
|
override val rightOperand: UExpression by lz { createNullLiteralExpression(this) }
|
||||||
override val operator: UastBinaryOperator = UastBinaryOperator.NOT_EQUALS
|
override val operator: UastBinaryOperator = UastBinaryOperator.NOT_EQUALS
|
||||||
@@ -53,7 +53,7 @@ private fun createElvisExpressions(
|
|||||||
|
|
||||||
val ifExpression = object : UIfExpression {
|
val ifExpression = object : UIfExpression {
|
||||||
override val psi: PsiElement? = null
|
override val psi: PsiElement? = null
|
||||||
override val containingElement: UElement? = containingElement
|
override val uastParent: UElement? = containingElement
|
||||||
override val condition: UExpression by lz { createNotEqWithNullExpression(tempVariable, this) }
|
override val condition: UExpression by lz { createNotEqWithNullExpression(tempVariable, this) }
|
||||||
override val thenExpression: UExpression? by lz { createVariableReferenceExpression(tempVariable, this) }
|
override val thenExpression: UExpression? by lz { createVariableReferenceExpression(tempVariable, this) }
|
||||||
override val elseExpression: UExpression? by lz { KotlinConverter.convertExpression(right, this) }
|
override val elseExpression: UExpression? by lz { KotlinConverter.convertExpression(right, this) }
|
||||||
@@ -73,7 +73,7 @@ fun createElvisExpression(elvisExpression: KtBinaryExpression, containingElement
|
|||||||
return object : UExpressionList, KotlinEvaluatableUElement, KotlinUElementWithType {
|
return object : UExpressionList, KotlinEvaluatableUElement, KotlinUElementWithType {
|
||||||
override val psi: PsiElement? = elvisExpression
|
override val psi: PsiElement? = elvisExpression
|
||||||
override val kind = KotlinSpecialExpressionKinds.ELVIS
|
override val kind = KotlinSpecialExpressionKinds.ELVIS
|
||||||
override val containingElement: UElement? = containingElement
|
override val uastParent: UElement? = containingElement
|
||||||
override val annotations: List<UAnnotation> = emptyList()
|
override val annotations: List<UAnnotation> = emptyList()
|
||||||
override val expressions: List<UExpression> by lz {
|
override val expressions: List<UExpression> by lz {
|
||||||
createElvisExpressions(left, right, this, elvisExpression.parent)
|
createElvisExpressions(left, right, this, elvisExpression.parent)
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.UastBinaryOperator
|
|||||||
|
|
||||||
class KotlinStringTemplateUPolyadicExpression(
|
class KotlinStringTemplateUPolyadicExpression(
|
||||||
override val psi: KtStringTemplateExpression,
|
override val psi: KtStringTemplateExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(),
|
) : KotlinAbstractUExpression(),
|
||||||
UPolyadicExpression,
|
UPolyadicExpression,
|
||||||
KotlinUElementWithType,
|
KotlinUElementWithType,
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UElement
|
|||||||
|
|
||||||
class KotlinUArrayAccessExpression(
|
class KotlinUArrayAccessExpression(
|
||||||
override val psi: KtArrayAccessExpression,
|
override val psi: KtArrayAccessExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UArrayAccessExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
) : KotlinAbstractUExpression(), UArrayAccessExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.arrayExpression, this) }
|
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.arrayExpression, this) }
|
||||||
override val indices by lz { psi.indexExpressions.map { KotlinConverter.convertOrEmpty(it, this) } }
|
override val indices by lz { psi.indexExpressions.map { KotlinConverter.convertOrEmpty(it, this) } }
|
||||||
|
|||||||
+2
-2
@@ -28,7 +28,7 @@ import org.jetbrains.uast.*
|
|||||||
|
|
||||||
class KotlinUBinaryExpression(
|
class KotlinUBinaryExpression(
|
||||||
override val psi: KtBinaryExpression,
|
override val psi: KtBinaryExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UBinaryExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
) : KotlinAbstractUExpression(), UBinaryExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
private companion object {
|
private companion object {
|
||||||
val BITWISE_OPERATORS = mapOf(
|
val BITWISE_OPERATORS = mapOf(
|
||||||
@@ -88,7 +88,7 @@ class KotlinUBinaryExpression(
|
|||||||
|
|
||||||
class KotlinCustomUBinaryExpression(
|
class KotlinCustomUBinaryExpression(
|
||||||
override val psi: PsiElement,
|
override val psi: PsiElement,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UBinaryExpression {
|
) : KotlinAbstractUExpression(), UBinaryExpression {
|
||||||
lateinit override var leftOperand: UExpression
|
lateinit override var leftOperand: UExpression
|
||||||
internal set
|
internal set
|
||||||
|
|||||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.uast.*
|
|||||||
|
|
||||||
class KotlinUBinaryExpressionWithType(
|
class KotlinUBinaryExpressionWithType(
|
||||||
override val psi: KtBinaryExpressionWithTypeRHS,
|
override val psi: KtBinaryExpressionWithTypeRHS,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UBinaryExpressionWithType,
|
) : KotlinAbstractUExpression(), UBinaryExpressionWithType,
|
||||||
KotlinUElementWithType, KotlinEvaluatableUElement {
|
KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ class KotlinUBinaryExpressionWithType(
|
|||||||
|
|
||||||
class KotlinCustomUBinaryExpressionWithType(
|
class KotlinCustomUBinaryExpressionWithType(
|
||||||
override val psi: PsiElement,
|
override val psi: PsiElement,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UBinaryExpressionWithType {
|
) : KotlinAbstractUExpression(), UBinaryExpressionWithType {
|
||||||
lateinit override var operand: UExpression
|
lateinit override var operand: UExpression
|
||||||
internal set
|
internal set
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UElement
|
|||||||
|
|
||||||
class KotlinUBlockExpression(
|
class KotlinUBlockExpression(
|
||||||
override val psi: KtBlockExpression,
|
override val psi: KtBlockExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UBlockExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), UBlockExpression, KotlinUElementWithType {
|
||||||
override val expressions by lz { psi.statements.map { KotlinConverter.convertOrEmpty(it, this) } }
|
override val expressions by lz { psi.statements.map { KotlinConverter.convertOrEmpty(it, this) } }
|
||||||
}
|
}
|
||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.kotlin.KotlinAbstractUExpression
|
|||||||
|
|
||||||
class KotlinUBreakExpression(
|
class KotlinUBreakExpression(
|
||||||
override val psi: KtBreakExpression,
|
override val psi: KtBreakExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UBreakExpression {
|
) : KotlinAbstractUExpression(), UBreakExpression {
|
||||||
override val label: String?
|
override val label: String?
|
||||||
get() = psi.getLabelName()
|
get() = psi.getLabelName()
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.uast.UExpression
|
|||||||
|
|
||||||
class KotlinUCallableReferenceExpression(
|
class KotlinUCallableReferenceExpression(
|
||||||
override val psi: KtCallableReferenceExpression,
|
override val psi: KtCallableReferenceExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UCallableReferenceExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), UCallableReferenceExpression, KotlinUElementWithType {
|
||||||
override val qualifierExpression: UExpression?
|
override val qualifierExpression: UExpression?
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter
|
|||||||
|
|
||||||
class KotlinUCatchClause(
|
class KotlinUCatchClause(
|
||||||
override val psi: KtCatchClause,
|
override val psi: KtCatchClause,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUElement(), UCatchClause {
|
) : KotlinAbstractUElement(), UCatchClause {
|
||||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.catchBody, this) }
|
override val body by lz { KotlinConverter.convertOrEmpty(psi.catchBody, this) }
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.UExpression
|
|||||||
|
|
||||||
class KotlinUClassLiteralExpression(
|
class KotlinUClassLiteralExpression(
|
||||||
override val psi: KtClassLiteralExpression,
|
override val psi: KtClassLiteralExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UClassLiteralExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), UClassLiteralExpression, KotlinUElementWithType {
|
||||||
override val type by lz {
|
override val type by lz {
|
||||||
val ktType = psi.analyze()[DOUBLE_COLON_LHS, psi.receiverExpression]?.type ?: return@lz null
|
val ktType = psi.analyze()[DOUBLE_COLON_LHS, psi.receiverExpression]?.type ?: return@lz null
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.kotlin.KotlinAbstractUExpression
|
|||||||
|
|
||||||
class KotlinUContinueExpression(
|
class KotlinUContinueExpression(
|
||||||
override val psi: KtContinueExpression,
|
override val psi: KtContinueExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UContinueExpression {
|
) : KotlinAbstractUExpression(), UContinueExpression {
|
||||||
override val label: String?
|
override val label: String?
|
||||||
get() = psi.getLabelName()
|
get() = psi.getLabelName()
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ import com.intellij.psi.PsiElement
|
|||||||
import org.jetbrains.uast.kotlin.KotlinAbstractUExpression
|
import org.jetbrains.uast.kotlin.KotlinAbstractUExpression
|
||||||
|
|
||||||
class KotlinUDeclarationsExpression(
|
class KotlinUDeclarationsExpression(
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UDeclarationsExpression {
|
) : KotlinAbstractUExpression(), UDeclarationsExpression {
|
||||||
override val psi: PsiElement?
|
override val psi: PsiElement?
|
||||||
get() = null
|
get() = null
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.UIdentifier
|
|||||||
|
|
||||||
class KotlinUDoWhileExpression(
|
class KotlinUDoWhileExpression(
|
||||||
override val psi: KtDoWhileExpression,
|
override val psi: KtDoWhileExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UDoWhileExpression {
|
) : KotlinAbstractUExpression(), UDoWhileExpression {
|
||||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ import org.jetbrains.uast.UastSpecialExpressionKind
|
|||||||
open class KotlinUExpressionList(
|
open class KotlinUExpressionList(
|
||||||
override val psi: PsiElement?,
|
override val psi: PsiElement?,
|
||||||
override val kind: UastSpecialExpressionKind, // original element
|
override val kind: UastSpecialExpressionKind, // original element
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UExpressionList, KotlinUElementWithType, KotlinEvaluatableUElement {
|
) : KotlinAbstractUExpression(), UExpressionList, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override lateinit var expressions: List<UExpression>
|
override lateinit var expressions: List<UExpression>
|
||||||
internal set
|
internal set
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.UastPsiParameterNotResolved
|
|||||||
|
|
||||||
class KotlinUForEachExpression(
|
class KotlinUForEachExpression(
|
||||||
override val psi: KtForExpression,
|
override val psi: KtForExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UForEachExpression {
|
) : KotlinAbstractUExpression(), UForEachExpression {
|
||||||
override val iteratedValue by lz { KotlinConverter.convertOrEmpty(psi.loopRange, this) }
|
override val iteratedValue by lz { KotlinConverter.convertOrEmpty(psi.loopRange, this) }
|
||||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||||
|
|||||||
+3
-3
@@ -34,7 +34,7 @@ import org.jetbrains.uast.visitor.UastVisitor
|
|||||||
|
|
||||||
class KotlinUFunctionCallExpression(
|
class KotlinUFunctionCallExpression(
|
||||||
override val psi: KtCallExpression,
|
override val psi: KtCallExpression,
|
||||||
override val containingElement: UElement?,
|
override val uastParent: UElement?,
|
||||||
private val _resolvedCall: ResolvedCall<*>? = null
|
private val _resolvedCall: ResolvedCall<*>? = null
|
||||||
) : KotlinAbstractUExpression(), UCallExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), UCallExpression, KotlinUElementWithType {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -96,8 +96,8 @@ class KotlinUFunctionCallExpression(
|
|||||||
|
|
||||||
override val receiver: UExpression?
|
override val receiver: UExpression?
|
||||||
get() {
|
get() {
|
||||||
return if (containingElement is UQualifiedReferenceExpression && containingElement.selector == this)
|
return if (uastParent is UQualifiedReferenceExpression && uastParent.selector == this)
|
||||||
containingElement.receiver
|
uastParent.receiver
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.UIfExpression
|
|||||||
|
|
||||||
class KotlinUIfExpression(
|
class KotlinUIfExpression(
|
||||||
override val psi: KtIfExpression,
|
override val psi: KtIfExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UIfExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
) : KotlinAbstractUExpression(), UIfExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||||
override val thenExpression by lz { KotlinConverter.convertOrNull(psi.then, this) }
|
override val thenExpression by lz { KotlinConverter.convertOrNull(psi.then, this) }
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.ULabeledExpression
|
|||||||
|
|
||||||
class KotlinULabeledExpression(
|
class KotlinULabeledExpression(
|
||||||
override val psi: KtLabeledExpression,
|
override val psi: KtLabeledExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), ULabeledExpression {
|
) : KotlinAbstractUExpression(), ULabeledExpression {
|
||||||
override val label: String
|
override val label: String
|
||||||
get() = psi.getLabelName().orAnonymous("label")
|
get() = psi.getLabelName().orAnonymous("label")
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.uast.withMargin
|
|||||||
|
|
||||||
class KotlinULambdaExpression(
|
class KotlinULambdaExpression(
|
||||||
override val psi: KtLambdaExpression,
|
override val psi: KtLambdaExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), ULambdaExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), ULambdaExpression, KotlinUElementWithType {
|
||||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.uast.ULiteralExpression
|
|||||||
|
|
||||||
class KotlinULiteralExpression(
|
class KotlinULiteralExpression(
|
||||||
override val psi: KtConstantExpression,
|
override val psi: KtConstantExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), ULiteralExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
) : KotlinAbstractUExpression(), ULiteralExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override val isNull: Boolean
|
override val isNull: Boolean
|
||||||
get() = psi.unwrapBlockOrParenthesis().node?.elementType == KtNodeTypes.NULL
|
get() = psi.unwrapBlockOrParenthesis().node?.elementType == KtNodeTypes.NULL
|
||||||
@@ -35,7 +35,7 @@ class KotlinULiteralExpression(
|
|||||||
|
|
||||||
class KotlinStringULiteralExpression(
|
class KotlinStringULiteralExpression(
|
||||||
override val psi: PsiElement,
|
override val psi: PsiElement,
|
||||||
override val containingElement: UElement?,
|
override val uastParent: UElement?,
|
||||||
val text: String? = null
|
val text: String? = null
|
||||||
) : KotlinAbstractUExpression(), ULiteralExpression, KotlinUElementWithType{
|
) : KotlinAbstractUExpression(), ULiteralExpression, KotlinUElementWithType{
|
||||||
override val value: String
|
override val value: String
|
||||||
|
|||||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.uast.*
|
|||||||
|
|
||||||
class KotlinUObjectLiteralExpression(
|
class KotlinUObjectLiteralExpression(
|
||||||
override val psi: KtObjectLiteralExpression,
|
override val psi: KtObjectLiteralExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UObjectLiteralExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), UObjectLiteralExpression, KotlinUElementWithType {
|
||||||
override val declaration by lz { getLanguagePlugin().convert<UClass>(psi.objectDeclaration.toLightClass()!!, this) }
|
override val declaration by lz { getLanguagePlugin().convert<UClass>(psi.objectDeclaration.toLightClass()!!, this) }
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ class KotlinUObjectLiteralExpression(
|
|||||||
|
|
||||||
private class ObjectLiteralClassReference(
|
private class ObjectLiteralClassReference(
|
||||||
override val psi: KtSuperTypeCallEntry,
|
override val psi: KtSuperTypeCallEntry,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUElement(), USimpleNameReferenceExpression {
|
) : KotlinAbstractUElement(), USimpleNameReferenceExpression {
|
||||||
override fun resolve() = (psi.resolveCallToDeclaration(this) as? PsiMethod)?.containingClass
|
override fun resolve() = (psi.resolveCallToDeclaration(this) as? PsiMethod)?.containingClass
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UParenthesizedExpression
|
|||||||
|
|
||||||
class KotlinUParenthesizedExpression(
|
class KotlinUParenthesizedExpression(
|
||||||
override val psi: KtParenthesizedExpression,
|
override val psi: KtParenthesizedExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UParenthesizedExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), UParenthesizedExpression, KotlinUElementWithType {
|
||||||
override val expression by lz { KotlinConverter.convertOrEmpty(psi.expression, this) }
|
override val expression by lz { KotlinConverter.convertOrEmpty(psi.expression, this) }
|
||||||
}
|
}
|
||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.*
|
|||||||
|
|
||||||
class KotlinUPostfixExpression(
|
class KotlinUPostfixExpression(
|
||||||
override val psi: KtPostfixExpression,
|
override val psi: KtPostfixExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UPostfixExpression, KotlinUElementWithType, KotlinEvaluatableUElement, UResolvable {
|
) : KotlinAbstractUExpression(), UPostfixExpression, KotlinUElementWithType, KotlinEvaluatableUElement, UResolvable {
|
||||||
override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.uast.UastPrefixOperator
|
|||||||
|
|
||||||
class KotlinUPrefixExpression(
|
class KotlinUPrefixExpression(
|
||||||
override val psi: KtPrefixExpression,
|
override val psi: KtPrefixExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UPrefixExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
) : KotlinAbstractUExpression(), UPrefixExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -28,7 +28,7 @@ import org.jetbrains.uast.UastQualifiedExpressionAccessType
|
|||||||
|
|
||||||
class KotlinUQualifiedReferenceExpression(
|
class KotlinUQualifiedReferenceExpression(
|
||||||
override val psi: KtDotQualifiedExpression,
|
override val psi: KtDotQualifiedExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UQualifiedReferenceExpression,
|
) : KotlinAbstractUExpression(), UQualifiedReferenceExpression,
|
||||||
KotlinUElementWithType, KotlinEvaluatableUElement {
|
KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) }
|
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) }
|
||||||
@@ -43,7 +43,7 @@ class KotlinUQualifiedReferenceExpression(
|
|||||||
|
|
||||||
class KotlinUComponentQualifiedReferenceExpression(
|
class KotlinUComponentQualifiedReferenceExpression(
|
||||||
override val psi: KtDestructuringDeclarationEntry,
|
override val psi: KtDestructuringDeclarationEntry,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UQualifiedReferenceExpression,
|
) : KotlinAbstractUExpression(), UQualifiedReferenceExpression,
|
||||||
KotlinUElementWithType, KotlinEvaluatableUElement {
|
KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override val accessType = UastQualifiedExpressionAccessType.SIMPLE
|
override val accessType = UastQualifiedExpressionAccessType.SIMPLE
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UReturnExpression
|
|||||||
|
|
||||||
class KotlinUReturnExpression(
|
class KotlinUReturnExpression(
|
||||||
override val psi: KtReturnExpression,
|
override val psi: KtReturnExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UReturnExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), UReturnExpression, KotlinUElementWithType {
|
||||||
override val returnExpression by lz { KotlinConverter.convertOrNull(psi.returnedExpression, this) }
|
override val returnExpression by lz { KotlinConverter.convertOrNull(psi.returnedExpression, this) }
|
||||||
}
|
}
|
||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.UQualifiedReferenceExpression
|
|||||||
|
|
||||||
class KotlinUSafeQualifiedExpression(
|
class KotlinUSafeQualifiedExpression(
|
||||||
override val psi: KtSafeQualifiedExpression,
|
override val psi: KtSafeQualifiedExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UQualifiedReferenceExpression,
|
) : KotlinAbstractUExpression(), UQualifiedReferenceExpression,
|
||||||
KotlinUElementWithType, KotlinEvaluatableUElement {
|
KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) }
|
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) }
|
||||||
|
|||||||
+6
-6
@@ -36,7 +36,7 @@ import org.jetbrains.uast.visitor.UastVisitor
|
|||||||
open class KotlinUSimpleReferenceExpression(
|
open class KotlinUSimpleReferenceExpression(
|
||||||
override val psi: KtSimpleNameExpression,
|
override val psi: KtSimpleNameExpression,
|
||||||
override val identifier: String,
|
override val identifier: String,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
private val resolvedDeclaration by lz { psi.resolveCallToDeclaration(this) }
|
private val resolvedDeclaration by lz { psi.resolveCallToDeclaration(this) }
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ open class KotlinUSimpleReferenceExpression(
|
|||||||
|
|
||||||
class KotlinAccessorCallExpression(
|
class KotlinAccessorCallExpression(
|
||||||
override val psi: KtElement,
|
override val psi: KtElement,
|
||||||
override val containingElement: KotlinUSimpleReferenceExpression,
|
override val uastParent: KotlinUSimpleReferenceExpression,
|
||||||
private val resolvedCall: ResolvedCall<*>,
|
private val resolvedCall: ResolvedCall<*>,
|
||||||
private val accessorDescriptor: DeclarationDescriptor,
|
private val accessorDescriptor: DeclarationDescriptor,
|
||||||
val setterValue: KtExpression?
|
val setterValue: KtExpression?
|
||||||
@@ -100,7 +100,7 @@ open class KotlinUSimpleReferenceExpression(
|
|||||||
|
|
||||||
override val receiver: UExpression?
|
override val receiver: UExpression?
|
||||||
get() {
|
get() {
|
||||||
val containingElement = containingElement.containingElement
|
val containingElement = uastParent.uastParent
|
||||||
return if (containingElement is UQualifiedReferenceExpression && containingElement.selector == this)
|
return if (containingElement is UQualifiedReferenceExpression && containingElement.selector == this)
|
||||||
containingElement.receiver
|
containingElement.receiver
|
||||||
else
|
else
|
||||||
@@ -116,7 +116,7 @@ open class KotlinUSimpleReferenceExpression(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val methodIdentifier: UIdentifier?
|
override val methodIdentifier: UIdentifier?
|
||||||
get() = UIdentifier(containingElement.psi, this)
|
get() = UIdentifier(uastParent.psi, this)
|
||||||
|
|
||||||
override val classReference: UReferenceExpression?
|
override val classReference: UReferenceExpression?
|
||||||
get() = null
|
get() = null
|
||||||
@@ -184,7 +184,7 @@ open class KotlinUSimpleReferenceExpression(
|
|||||||
class KotlinClassViaConstructorUSimpleReferenceExpression(
|
class KotlinClassViaConstructorUSimpleReferenceExpression(
|
||||||
override val psi: KtCallExpression,
|
override val psi: KtCallExpression,
|
||||||
override val identifier: String,
|
override val identifier: String,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression, KotlinUElementWithType {
|
||||||
override val resolvedName: String?
|
override val resolvedName: String?
|
||||||
get() = (psi.getResolvedCall(psi.analyze())?.resultingDescriptor as? ConstructorDescriptor)
|
get() = (psi.getResolvedCall(psi.analyze())?.resultingDescriptor as? ConstructorDescriptor)
|
||||||
@@ -200,7 +200,7 @@ class KotlinClassViaConstructorUSimpleReferenceExpression(
|
|||||||
|
|
||||||
class KotlinStringUSimpleReferenceExpression(
|
class KotlinStringUSimpleReferenceExpression(
|
||||||
override val identifier: String,
|
override val identifier: String,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression {
|
) : KotlinAbstractUExpression(), USimpleNameReferenceExpression {
|
||||||
override val psi: PsiElement?
|
override val psi: PsiElement?
|
||||||
get() = null
|
get() = null
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.USuperExpression
|
|||||||
|
|
||||||
class KotlinUSuperExpression(
|
class KotlinUSuperExpression(
|
||||||
override val psi: KtSuperExpression,
|
override val psi: KtSuperExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), USuperExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
) : KotlinAbstractUExpression(), USuperExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override val label: String?
|
override val label: String?
|
||||||
get() = psi.getLabelName()
|
get() = psi.getLabelName()
|
||||||
|
|||||||
+3
-4
@@ -23,7 +23,7 @@ import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds
|
|||||||
|
|
||||||
class KotlinUSwitchExpression(
|
class KotlinUSwitchExpression(
|
||||||
override val psi: KtWhenExpression,
|
override val psi: KtWhenExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), USwitchExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), USwitchExpression, KotlinUElementWithType {
|
||||||
override val expression by lz { KotlinConverter.convertOrNull(psi.subjectExpression, this) }
|
override val expression by lz { KotlinConverter.convertOrNull(psi.subjectExpression, this) }
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class KotlinUSwitchExpression(
|
|||||||
|
|
||||||
class KotlinUSwitchEntry(
|
class KotlinUSwitchEntry(
|
||||||
override val psi: KtWhenEntry,
|
override val psi: KtWhenEntry,
|
||||||
override val containingElement: UExpression
|
override val uastParent: UExpression
|
||||||
) : KotlinAbstractUExpression(), USwitchClauseExpressionWithBody {
|
) : KotlinAbstractUExpression(), USwitchClauseExpressionWithBody {
|
||||||
override val caseValues by lz {
|
override val caseValues by lz {
|
||||||
psi.conditions.map { when (it) {
|
psi.conditions.map { when (it) {
|
||||||
@@ -89,13 +89,12 @@ class KotlinUSwitchEntry(
|
|||||||
is KtBlockExpression -> exprPsi.statements.map { KotlinConverter.convertOrEmpty(it, this) }
|
is KtBlockExpression -> exprPsi.statements.map { KotlinConverter.convertOrEmpty(it, this) }
|
||||||
else -> listOf(KotlinConverter.convertOrEmpty(exprPsi, this))
|
else -> listOf(KotlinConverter.convertOrEmpty(exprPsi, this))
|
||||||
}
|
}
|
||||||
containingElement
|
|
||||||
expressions = userExpressions + object : UBreakExpression {
|
expressions = userExpressions + object : UBreakExpression {
|
||||||
override val psi: PsiElement?
|
override val psi: PsiElement?
|
||||||
get() = null
|
get() = null
|
||||||
override val label: String?
|
override val label: String?
|
||||||
get() = null
|
get() = null
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
get() = this@KotlinUSwitchEntry
|
get() = this@KotlinUSwitchEntry
|
||||||
override val annotations: List<UAnnotation>
|
override val annotations: List<UAnnotation>
|
||||||
get() = emptyList()
|
get() = emptyList()
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.UThisExpression
|
|||||||
|
|
||||||
class KotlinUThisExpression(
|
class KotlinUThisExpression(
|
||||||
override val psi: KtThisExpression,
|
override val psi: KtThisExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UThisExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
) : KotlinAbstractUExpression(), UThisExpression, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override val label: String?
|
override val label: String?
|
||||||
get() = psi.getLabelName()
|
get() = psi.getLabelName()
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UThrowExpression
|
|||||||
|
|
||||||
class KotlinUThrowExpression(
|
class KotlinUThrowExpression(
|
||||||
override val psi: KtThrowExpression,
|
override val psi: KtThrowExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UThrowExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), UThrowExpression, KotlinUElementWithType {
|
||||||
override val thrownExpression by lz { KotlinConverter.convertOrEmpty(psi.thrownExpression, this) }
|
override val thrownExpression by lz { KotlinConverter.convertOrEmpty(psi.thrownExpression, this) }
|
||||||
}
|
}
|
||||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.UVariable
|
|||||||
|
|
||||||
class KotlinUTryExpression(
|
class KotlinUTryExpression(
|
||||||
override val psi: KtTryExpression,
|
override val psi: KtTryExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UTryExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(), UTryExpression, KotlinUElementWithType {
|
||||||
override val tryClause by lz { KotlinConverter.convertOrEmpty(psi.tryBlock, this) }
|
override val tryClause by lz { KotlinConverter.convertOrEmpty(psi.tryBlock, this) }
|
||||||
override val catchClauses by lz { psi.catchClauses.map { KotlinUCatchClause(it, this) } }
|
override val catchClauses by lz { psi.catchClauses.map { KotlinUCatchClause(it, this) } }
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.UastBinaryExpressionWithTypeKind
|
|||||||
|
|
||||||
class KotlinUTypeCheckExpression(
|
class KotlinUTypeCheckExpression(
|
||||||
override val psi: KtIsExpression,
|
override val psi: KtIsExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UBinaryExpressionWithType, KotlinUElementWithType, KotlinEvaluatableUElement {
|
) : KotlinAbstractUExpression(), UBinaryExpressionWithType, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||||
override val operand by lz { KotlinConverter.convertOrEmpty(psi.leftHandSide, this) }
|
override val operand by lz { KotlinConverter.convertOrEmpty(psi.leftHandSide, this) }
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -8,13 +8,13 @@ import org.jetbrains.uast.UTypeReferenceExpression
|
|||||||
open class KotlinUTypeReferenceExpression(
|
open class KotlinUTypeReferenceExpression(
|
||||||
override val type: PsiType,
|
override val type: PsiType,
|
||||||
override val psi: PsiElement?,
|
override val psi: PsiElement?,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UTypeReferenceExpression, KotlinUElementWithType
|
) : KotlinAbstractUExpression(), UTypeReferenceExpression, KotlinUElementWithType
|
||||||
|
|
||||||
|
|
||||||
class LazyKotlinUTypeReferenceExpression(
|
class LazyKotlinUTypeReferenceExpression(
|
||||||
override val psi: PsiElement,
|
override val psi: PsiElement,
|
||||||
override val containingElement: UElement?,
|
override val uastParent: UElement?,
|
||||||
private val typeSupplier: () -> PsiType
|
private val typeSupplier: () -> PsiType
|
||||||
) : KotlinAbstractUExpression(), UTypeReferenceExpression {
|
) : KotlinAbstractUExpression(), UTypeReferenceExpression {
|
||||||
override val type: PsiType by lz { typeSupplier() }
|
override val type: PsiType by lz { typeSupplier() }
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.UWhileExpression
|
|||||||
|
|
||||||
class KotlinUWhileExpression(
|
class KotlinUWhileExpression(
|
||||||
override val psi: KtWhileExpression,
|
override val psi: KtWhileExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UWhileExpression {
|
) : KotlinAbstractUExpression(), UWhileExpression {
|
||||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable
|
|||||||
private class KotlinLocalFunctionUVariable(
|
private class KotlinLocalFunctionUVariable(
|
||||||
val function: KtFunction,
|
val function: KtFunction,
|
||||||
override val psi: PsiVariable,
|
override val psi: PsiVariable,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : UVariable, PsiVariable by psi {
|
) : UVariable, PsiVariable by psi {
|
||||||
override val uastInitializer: UExpression? by lz {
|
override val uastInitializer: UExpression? by lz {
|
||||||
createLocalFunctionLambdaExpression(function, this)
|
createLocalFunctionLambdaExpression(function, this)
|
||||||
@@ -27,7 +27,7 @@ private class KotlinLocalFunctionUVariable(
|
|||||||
|
|
||||||
private class KotlinLocalFunctionULambdaExpression(
|
private class KotlinLocalFunctionULambdaExpression(
|
||||||
override val psi: KtFunction,
|
override val psi: KtFunction,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
): KotlinAbstractUExpression(), ULambdaExpression {
|
): KotlinAbstractUExpression(), ULambdaExpression {
|
||||||
|
|
||||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.UExpression
|
|||||||
|
|
||||||
class UnknownKotlinExpression(
|
class UnknownKotlinExpression(
|
||||||
override val psi: KtExpression,
|
override val psi: KtExpression,
|
||||||
override val containingElement: UElement?
|
override val uastParent: UElement?
|
||||||
) : KotlinAbstractUExpression(), UExpression {
|
) : KotlinAbstractUExpression(), UExpression {
|
||||||
override fun asLogString() = "[!] UnknownKotlinExpression ($psi)"
|
override fun asLogString() = "[!] UnknownKotlinExpression ($psi)"
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
<os family="windows"/>
|
<os family="windows"/>
|
||||||
</condition>
|
</condition>
|
||||||
|
|
||||||
<property name="uast.version" value="1.0.11"/>
|
<property name="uast.version" value="1.0.12"/>
|
||||||
|
|
||||||
<property name="generators" value="${basedir}/generators"/>
|
<property name="generators" value="${basedir}/generators"/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user