com.android.tools.lint.detector.api
Enum Scope

java.lang.Object
  extended by java.lang.Enum<Scope>
      extended by com.android.tools.lint.detector.api.Scope
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Scope>

@Beta
public enum Scope
extends java.lang.Enum<Scope>

The scope of a detector is the set of files a detector must consider when performing its analysis. This can be used to determine when issues are potentially obsolete, whether a detector should re-run on a file save, etc.

NOTE: This is not a public or final API; if you rely on this be prepared to adjust your code for the next tools release.


Enum Constant Summary
ALL_CLASS_FILES
          The analysis considers all the Java class files together.
ALL_JAVA_FILES
          The analysis considers all the Java source files together.
ALL_RESOURCE_FILES
          The analysis considers all the resource file.
CLASS_FILE
          The analysis only considers a single Java class file at a time.
GRADLE_FILE
          The analysis considers a Gradle build file
JAVA_FILE
          The analysis only considers a single Java source file at a time.
JAVA_LIBRARIES
          The analysis considers classes in the libraries for this project.
MANIFEST
          The analysis considers the manifest file
OTHER
          Scope for other files.
PROGUARD_FILE
          The analysis considers the Proguard configuration file
RESOURCE_FILE
          The analysis only considers a single XML resource file at a time.
 
Field Summary
static java.util.EnumSet<Scope> ALL
          All scopes: running lint on a project will check these scopes
static java.util.EnumSet<Scope> ALL_CLASSES_AND_LIBRARIES
          Scope-set used for analyzing all class files, including those in libraries
static java.util.EnumSet<Scope> ALL_RESOURCES_SCOPE
          Scope-set used for detectors which scan all resources
static java.util.EnumSet<Scope> CLASS_AND_ALL_RESOURCE_FILES
          Scope-set used for analyzing individual class files and all resource files
static java.util.EnumSet<Scope> CLASS_FILE_SCOPE
          Scope-set used for detectors which are affected by a single Java class file
static java.util.EnumSet<Scope> GRADLE_SCOPE
          Scope-set used for detectors which are affected by a single Gradle build file
static java.util.EnumSet<Scope> JAVA_AND_RESOURCE_FILES
          Scope-set used for detectors which are affected by single XML and Java source files
static java.util.EnumSet<Scope> JAVA_FILE_SCOPE
          Scope-set used for detectors which are affected by a single Java source file
static java.util.EnumSet<Scope> JAVA_LIBRARY_SCOPE
          Scope-set used for detectors which are affected by Java libraries
static java.util.EnumSet<Scope> MANIFEST_SCOPE
          Scope-set used for detectors which are affected by the manifest only
static java.util.EnumSet<Scope> OTHER_SCOPE
          Scope-set used for detectors which correspond to some other context
static java.util.EnumSet<Scope> PROGUARD_SCOPE
          Scope-set used for detectors which are affected by a single ProGuard class file
static java.util.EnumSet<Scope> RESOURCE_FILE_SCOPE
          Scope-set used for detectors which are affected by a single resource file
 
Method Summary
static boolean checkSingleFile(java.util.EnumSet<Scope> scopes)
          Returns true if the given scope set corresponds to scanning a single file rather than a whole project
static java.util.EnumSet<Scope> infer(java.util.Collection<Project> projects)
          Infers a suitable scope to use from the given projects to be analyzed
static java.util.EnumSet<Scope> intersect(java.util.EnumSet<Scope> scope1, java.util.EnumSet<Scope> scope2)
          Returns the intersection of two scope sets
static Scope valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static Scope[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

RESOURCE_FILE

public static final Scope RESOURCE_FILE
The analysis only considers a single XML resource file at a time.

Issues which are only affected by a single resource file can be checked for incrementally when a file is edited.


ALL_RESOURCE_FILES

public static final Scope ALL_RESOURCE_FILES
The analysis considers all the resource file. This scope must not be used in conjunction with RESOURCE_FILE; an issue scope is either considering just a single resource file or all the resources, not both.


JAVA_FILE

public static final Scope JAVA_FILE
The analysis only considers a single Java source file at a time.

Issues which are only affected by a single Java source file can be checked for incrementally when a Java source file is edited.


ALL_JAVA_FILES

public static final Scope ALL_JAVA_FILES
The analysis considers all the Java source files together.

This flag is mutually exclusive with JAVA_FILE.


CLASS_FILE

public static final Scope CLASS_FILE
The analysis only considers a single Java class file at a time.

Issues which are only affected by a single Java class file can be checked for incrementally when a Java source file is edited and then recompiled.


ALL_CLASS_FILES

public static final Scope ALL_CLASS_FILES
The analysis considers all the Java class files together.

This flag is mutually exclusive with CLASS_FILE.


MANIFEST

public static final Scope MANIFEST
The analysis considers the manifest file


PROGUARD_FILE

public static final Scope PROGUARD_FILE
The analysis considers the Proguard configuration file


JAVA_LIBRARIES

public static final Scope JAVA_LIBRARIES
The analysis considers classes in the libraries for this project. These will be analyzed before the classes themselves.


GRADLE_FILE

public static final Scope GRADLE_FILE
The analysis considers a Gradle build file


OTHER

public static final Scope OTHER
Scope for other files. Issues that specify a custom scope will be called unconditionally. This will call Detector.run(Context)} on the detectors unconditionally.

Field Detail

ALL

public static final java.util.EnumSet<Scope> ALL
All scopes: running lint on a project will check these scopes


RESOURCE_FILE_SCOPE

public static final java.util.EnumSet<Scope> RESOURCE_FILE_SCOPE
Scope-set used for detectors which are affected by a single resource file


ALL_RESOURCES_SCOPE

public static final java.util.EnumSet<Scope> ALL_RESOURCES_SCOPE
Scope-set used for detectors which scan all resources


JAVA_FILE_SCOPE

public static final java.util.EnumSet<Scope> JAVA_FILE_SCOPE
Scope-set used for detectors which are affected by a single Java source file


CLASS_FILE_SCOPE

public static final java.util.EnumSet<Scope> CLASS_FILE_SCOPE
Scope-set used for detectors which are affected by a single Java class file


GRADLE_SCOPE

public static final java.util.EnumSet<Scope> GRADLE_SCOPE
Scope-set used for detectors which are affected by a single Gradle build file


MANIFEST_SCOPE

public static final java.util.EnumSet<Scope> MANIFEST_SCOPE
Scope-set used for detectors which are affected by the manifest only


OTHER_SCOPE

public static final java.util.EnumSet<Scope> OTHER_SCOPE
Scope-set used for detectors which correspond to some other context


PROGUARD_SCOPE

public static final java.util.EnumSet<Scope> PROGUARD_SCOPE
Scope-set used for detectors which are affected by a single ProGuard class file


JAVA_AND_RESOURCE_FILES

public static final java.util.EnumSet<Scope> JAVA_AND_RESOURCE_FILES
Scope-set used for detectors which are affected by single XML and Java source files


CLASS_AND_ALL_RESOURCE_FILES

public static final java.util.EnumSet<Scope> CLASS_AND_ALL_RESOURCE_FILES
Scope-set used for analyzing individual class files and all resource files


ALL_CLASSES_AND_LIBRARIES

public static final java.util.EnumSet<Scope> ALL_CLASSES_AND_LIBRARIES
Scope-set used for analyzing all class files, including those in libraries


JAVA_LIBRARY_SCOPE

public static final java.util.EnumSet<Scope> JAVA_LIBRARY_SCOPE
Scope-set used for detectors which are affected by Java libraries

Method Detail

values

public static Scope[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (Scope c : Scope.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Scope valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

checkSingleFile

public static boolean checkSingleFile(@NonNull
                                      java.util.EnumSet<Scope> scopes)
Returns true if the given scope set corresponds to scanning a single file rather than a whole project

Parameters:
scopes - the scope set to check
Returns:
true if the scope set references a single file

intersect

@NonNull
public static java.util.EnumSet<Scope> intersect(@NonNull
                                                         java.util.EnumSet<Scope> scope1,
                                                         @NonNull
                                                         java.util.EnumSet<Scope> scope2)
Returns the intersection of two scope sets

Parameters:
scope1 - the first set to intersect
scope2 - the second set to intersect
Returns:
the intersection of the two sets

infer

@NonNull
public static java.util.EnumSet<Scope> infer(@NonNull
                                                     java.util.Collection<Project> projects)
Infers a suitable scope to use from the given projects to be analyzed

Parameters:
projects - the projects to find a suitable scope for
Returns:
the scope to use