visibility argument can be used to specific what the original
+ * visibility should have been if it had not been made public or package-private for testing.
+ * The default is to consider the element private.
+ */
+@Retention(RetentionPolicy.SOURCE)
+public @interface VisibleForTesting {
+ /**
+ * Intended visibility if the element had not been made public or package-private for
+ * testing.
+ */
+ enum Visibility {
+ /** The element should be considered protected. */
+ PROTECTED,
+ /** The element should be considered package-private. */
+ PACKAGE,
+ /** The element should be considered private. */
+ PRIVATE
+ }
+
+ /**
+ * Intended visibility if the element had not been made public or package-private for testing.
+ * If not specified, one should assume the element originally intended to be private.
+ */
+ Visibility visibility() default Visibility.PRIVATE;
+}
diff --git a/plugins/lint/android-annotations/src/com/android/annotations/concurrency/GuardedBy.java b/plugins/lint/android-annotations/src/com/android/annotations/concurrency/GuardedBy.java
new file mode 100644
index 00000000000..5a151acc8b8
--- /dev/null
+++ b/plugins/lint/android-annotations/src/com/android/annotations/concurrency/GuardedBy.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.annotations.concurrency;
+
+import java.lang.annotation.*;
+
+/**
+ * Indicates that the target field or method should only be accessed
+ * with the specified lock being held.
+ */
+@Documented
+@Retention(RetentionPolicy.CLASS)
+@Target({ElementType.METHOD, ElementType.FIELD})
+public @interface GuardedBy {
+ String value();
+}
diff --git a/plugins/lint/android-annotations/src/com/android/annotations/concurrency/Immutable.java b/plugins/lint/android-annotations/src/com/android/annotations/concurrency/Immutable.java
new file mode 100644
index 00000000000..c83f9f0ffc9
--- /dev/null
+++ b/plugins/lint/android-annotations/src/com/android/annotations/concurrency/Immutable.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.annotations.concurrency;
+
+import java.lang.annotation.*;
+
+/**
+ * Indicates that the target class to which this annotation is applied
+ * is immutable.
+ */
+@Documented
+@Retention(RetentionPolicy.CLASS)
+@Target(ElementType.TYPE)
+public @interface Immutable {
+}
diff --git a/plugins/lint/lint-api/lint-api.iml b/plugins/lint/lint-api/lint-api.iml
new file mode 100644
index 00000000000..9158eb89551
--- /dev/null
+++ b/plugins/lint/lint-api/lint-api.iml
@@ -0,0 +1,18 @@
+
+
diff --git a/plugins/lint/lint-api/src/com/android/tools/klint/client/api/IssueRegistry.java b/plugins/lint/lint-api/src/com/android/tools/klint/client/api/IssueRegistry.java
index 09e70dc7e6b..552ea3e2cea 100644
--- a/plugins/lint/lint-api/src/com/android/tools/klint/client/api/IssueRegistry.java
+++ b/plugins/lint/lint-api/src/com/android/tools/klint/client/api/IssueRegistry.java
@@ -14,28 +14,21 @@
* limitations under the License.
*/
-package com.android.tools.lint.client.api;
+package com.android.tools.klint.client.api;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.annotations.VisibleForTesting;
-import com.android.tools.lint.detector.api.Category;
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Implementation;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Scope;
-import com.android.tools.lint.detector.api.Severity;
+import com.android.tools.klint.detector.api.Category;
+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.Scope;
+import com.android.tools.klint.detector.api.Severity;
import com.google.common.annotations.Beta;
import com.google.common.collect.Maps;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* Registry which provides a list of checks to be performed on an Android project
diff --git a/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JarFileIssueRegistry.java b/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JarFileIssueRegistry.java
index 0262691fc7e..bcafb754a1c 100644
--- a/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JarFileIssueRegistry.java
+++ b/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JarFileIssueRegistry.java
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.tools.lint.client.api;
+package com.android.tools.klint.client.api;
import com.android.annotations.NonNull;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Severity;
+import com.android.tools.klint.detector.api.Issue;
+import com.android.tools.klint.detector.api.Severity;
import com.android.utils.SdkUtils;
import com.google.common.collect.Lists;
diff --git a/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JavaLintLanguageExtension.java b/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JavaLintLanguageExtension.java
new file mode 100644
index 00000000000..06ccbf6c619
--- /dev/null
+++ b/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JavaLintLanguageExtension.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2010-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tools.klint.client.api;
+
+import org.jetbrains.uast.UastConverter;
+import org.jetbrains.uast.java.JavaConverter;
+
+public class JavaLintLanguageExtension extends LintLanguageExtension {
+ @Override
+ public UastConverter getConverter() {
+ return JavaConverter.INSTANCE;
+ }
+}
diff --git a/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JavaParser.java b/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JavaParser.java
index 3aa55d42868..4fd83c82036 100644
--- a/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JavaParser.java
+++ b/plugins/lint/lint-api/src/com/android/tools/klint/client/api/JavaParser.java
@@ -14,26 +14,12 @@
* limitations under the License.
*/
-package com.android.tools.lint.client.api;
-
-import static com.android.SdkConstants.ATTR_VALUE;
+package com.android.tools.klint.client.api;
import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.tools.lint.detector.api.Context;
-import com.android.tools.lint.detector.api.JavaContext;
-import com.android.tools.lint.detector.api.Location;
+import com.android.tools.klint.detector.api.JavaContext;
import com.google.common.annotations.Beta;
-import com.google.common.base.Splitter;
-
-import java.util.Collections;
-import java.util.List;
-
-import lombok.ast.Identifier;
-import lombok.ast.Node;
-import lombok.ast.StrictListAccessor;
-import lombok.ast.TypeReference;
-import lombok.ast.TypeReferencePart;
+import org.jetbrains.uast.UFile;
/**
* A wrapper for a Java parser. This allows tools integrating lint to map directly
@@ -56,475 +42,11 @@ public abstract class JavaParser {
public static final String TYPE_BYTE = "byte"; //$NON-NLS-1$
public static final String TYPE_NULL = "null"; //$NON-NLS-1$
- /**
- * Prepare to parse the given contexts. This method will be called before
- * a series of {@link #parseJava(JavaContext)} calls, which allows some
- * parsers to do up front global computation in case they want to more
- * efficiently process multiple files at the same time. This allows a single
- * type-attribution pass for example, which is a lot more efficient than
- * performing global type analysis over and over again for each individual
- * file
- *
- * @param contexts a list of contexts to be parsed
- */
- public abstract void prepareJavaParse(@NonNull List
- * If you return specific AST node types from
- * {@link #getApplicableNodeTypes()}, then the visitor will only
- * be called for the specific requested node types. This is more
- * efficient, since it allows many detectors that apply to only a small
- * part of the AST (such as method call nodes) to share iteration of the
- * majority of the parse tree.
- *
- * If you return null from {@link #getApplicableNodeTypes()}, then your
- * visitor will be called from the top and all node types visited.
- *
- * Note that a new visitor is created for each separate compilation
- * unit, so you can store per file state in the visitor.
- *
- * @param context the {@link Context} for the file being analyzed
- * @return a visitor, or null.
- */
- @Nullable
- AstVisitor createJavaVisitor(@NonNull JavaContext context);
-
- /**
- * Return the types of AST nodes that the visitor returned from
- * {@link #createJavaVisitor(JavaContext)} should visit. See the
- * documentation for {@link #createJavaVisitor(JavaContext)} for details
- * on how the shared visitor is used.
- *
- * If you return null from this method, then the visitor will process
- * the full tree instead.
- *
- * Note that for the shared visitor, the return codes from the visit
- * methods are ignored: returning true will not prune iteration
- * of the subtree, since there may be other node types interested in the
- * children. If you need to ensure that your visitor only processes a
- * part of the tree, use a full visitor instead. See the
- * OverdrawDetector implementation for an example of this.
- *
- * @return the list of applicable node types (AST node classes), or null
- */
- @Nullable
- List
- * This makes it easy to write detectors that focus on some fixed calls.
- * For example, the StringFormatDetector uses this mechanism to look for
- * "format" calls, and when found it looks around (using the AST's
- * {@link Node#getParent()} method) to see if it's called on
- * a String class instance, and if so do its normal processing. Note
- * that since it doesn't need to do any other AST processing, that
- * detector does not actually supply a visitor.
- *
- * @return a set of applicable method names, or null.
- */
- @Nullable
- List
- * This makes it easy to write detectors that focus on some fixed constructors.
- *
- * @return a set of applicable fully qualified types, or null.
- */
- @Nullable
- List
- * This flag is mutually exclusive with {@link #JAVA_FILE}.
+ * This flag is mutually exclusive with {@link #SOURCE_FILE}.
*/
- ALL_JAVA_FILES,
+ ALL_SOURCE_FILES,
/**
* The analysis only considers a single Java class file at a time.
@@ -143,10 +135,10 @@ public enum Scope {
if (size == 2) {
// When single checking a Java source file, we check both its Java source
// and the associated class files
- return scopes.contains(JAVA_FILE) && scopes.contains(CLASS_FILE);
+ return scopes.contains(SOURCE_FILE) && scopes.contains(CLASS_FILE);
} else {
return size == 1 &&
- (scopes.contains(JAVA_FILE)
+ (scopes.contains(SOURCE_FILE)
|| scopes.contains(CLASS_FILE)
|| scopes.contains(RESOURCE_FILE)
|| scopes.contains(PROGUARD_FILE)
@@ -192,7 +184,7 @@ public enum Scope {
} else if (name.endsWith(DOT_XML)) {
scope.add(RESOURCE_FILE);
} else if (name.endsWith(DOT_JAVA)) {
- scope.add(JAVA_FILE);
+ scope.add(SOURCE_FILE);
} else if (name.endsWith(DOT_CLASS)) {
scope.add(CLASS_FILE);
} else if (name.endsWith(DOT_GRADLE)) {
@@ -210,6 +202,9 @@ public enum Scope {
scope.add(RESOURCE_FILE);
scope.add(BINARY_RESOURCE_FILE);
scope.add(RESOURCE_FOLDER);
+ } else if (UastConverterUtils.isFileSupported(
+ project.getClient().getConverters(), name)) {
+ scope.add(SOURCE_FILE);
}
}
} else {
@@ -231,7 +226,7 @@ public enum Scope {
/** Scope-set used for detectors which scan all resources */
public static final EnumSet