com.android.tools.lint.client.api
Class DefaultConfiguration

java.lang.Object
  extended by com.android.tools.lint.client.api.Configuration
      extended by com.android.tools.lint.client.api.DefaultConfiguration

@Beta
public class DefaultConfiguration
extends Configuration

Default implementation of a Configuration which reads and writes configuration data into lint.xml in the project directory.

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.


Field Summary
static java.lang.String CONFIG_FILE_NAME
          Default name of the configuration file
 
Constructor Summary
protected DefaultConfiguration(LintClient client, Project project, Configuration parent)
           
protected DefaultConfiguration(LintClient client, Project project, Configuration parent, java.io.File configFile)
           
 
Method Summary
static DefaultConfiguration create(LintClient client, java.io.File lintFile)
          Creates a new DefaultConfiguration for the given lint config file, not affiliated with a project.
static DefaultConfiguration create(LintClient client, Project project, Configuration parent)
          Creates a new DefaultConfiguration
 void finishBulkEditing()
          Marks the end of a "bulk" editing operation, where values should be committed to persistent storage.
protected  Severity getDefaultSeverity(Issue issue)
           
 Severity getSeverity(Issue issue)
          Returns the severity for a given issue.
 void ignore(Context context, Issue issue, Location location, java.lang.String message, java.lang.Object data)
          Marks the given warning as "ignored".
 void ignore(Issue issue, java.io.File file)
          Marks the given issue and file combination as being ignored.
 boolean isIgnored(Context context, Issue issue, Location location, java.lang.String message, java.lang.Object data)
          Checks whether this issue should be ignored because the user has already suppressed the error? Note that this refers to individual issues being suppressed/ignored, not a whole detector being disabled via something like Configuration.isEnabled(Issue).
 void setSeverity(Issue issue, Severity severity)
          Sets the severity to be used for this issue.
 void startBulkEditing()
          Marks the beginning of a "bulk" editing operation with repeated calls to Configuration.setSeverity(com.android.tools.lint.detector.api.Issue, com.android.tools.lint.detector.api.Severity) or Configuration.ignore(com.android.tools.lint.detector.api.Context, com.android.tools.lint.detector.api.Issue, com.android.tools.lint.detector.api.Location, java.lang.String, java.lang.Object).
 
Methods inherited from class com.android.tools.lint.client.api.Configuration
isEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_FILE_NAME

public static final java.lang.String CONFIG_FILE_NAME
Default name of the configuration file

See Also:
Constant Field Values
Constructor Detail

DefaultConfiguration

protected DefaultConfiguration(@NonNull
                               LintClient client,
                               @Nullable
                               Project project,
                               @Nullable
                               Configuration parent,
                               @NonNull
                               java.io.File configFile)

DefaultConfiguration

protected DefaultConfiguration(@NonNull
                               LintClient client,
                               @NonNull
                               Project project,
                               @Nullable
                               Configuration parent)
Method Detail

create

@NonNull
public static DefaultConfiguration create(@NonNull
                                                  LintClient client,
                                                  @NonNull
                                                  Project project,
                                                  @Nullable
                                                  Configuration parent)
Creates a new DefaultConfiguration

Parameters:
client - the client to report errors to etc
project - the associated project
parent - the parent/fallback configuration or null
Returns:
a new configuration

create

@NonNull
public static DefaultConfiguration create(@NonNull
                                                  LintClient client,
                                                  @NonNull
                                                  java.io.File lintFile)
Creates a new DefaultConfiguration for the given lint config file, not affiliated with a project. This is used for global configurations.

Parameters:
client - the client to report errors to etc
lintFile - the lint file containing the configuration
Returns:
a new configuration

isIgnored

public boolean isIgnored(@NonNull
                         Context context,
                         @NonNull
                         Issue issue,
                         @Nullable
                         Location location,
                         @NonNull
                         java.lang.String message,
                         @Nullable
                         java.lang.Object data)
Description copied from class: Configuration
Checks whether this issue should be ignored because the user has already suppressed the error? Note that this refers to individual issues being suppressed/ignored, not a whole detector being disabled via something like Configuration.isEnabled(Issue).

Overrides:
isIgnored in class Configuration
Parameters:
context - the context used by the detector when the issue was found
issue - the issue that was found
location - the location of the issue
message - the associated user message
data - additional information about an issue (see LintClient.report(Context, Issue, Severity, Location, String, Object) for more information
Returns:
true if this issue should be suppressed

getDefaultSeverity

@NonNull
protected Severity getDefaultSeverity(@NonNull
                                              Issue issue)

getSeverity

@NonNull
public Severity getSeverity(@NonNull
                                    Issue issue)
Description copied from class: Configuration
Returns the severity for a given issue. This is the same as the Issue.getDefaultSeverity() unless the user has selected a custom severity (which is tool context dependent).

Overrides:
getSeverity in class Configuration
Parameters:
issue - the issue to look up the severity from
Returns:
the severity use for issues for the given detector

ignore

public void ignore(@NonNull
                   Context context,
                   @NonNull
                   Issue issue,
                   @Nullable
                   Location location,
                   @NonNull
                   java.lang.String message,
                   @Nullable
                   java.lang.Object data)
Description copied from class: Configuration
Marks the given warning as "ignored".

Specified by:
ignore in class Configuration
Parameters:
context - The scanning context
issue - the issue to be ignored
location - The location to ignore the warning at, if any
message - The message for the warning
data - The corresponding data, or null

ignore

public void ignore(@NonNull
                   Issue issue,
                   @NonNull
                   java.io.File file)
Marks the given issue and file combination as being ignored.

Parameters:
issue - the issue to be ignored in the given file
file - the file to ignore the issue in

setSeverity

public void setSeverity(@NonNull
                        Issue issue,
                        @Nullable
                        Severity severity)
Description copied from class: Configuration
Sets the severity to be used for this issue.

Specified by:
setSeverity in class Configuration
Parameters:
issue - the issue to set the severity for
severity - the severity to associate with this issue, or null to reset the severity to the default

startBulkEditing

public void startBulkEditing()
Description copied from class: Configuration
Marks the beginning of a "bulk" editing operation with repeated calls to Configuration.setSeverity(com.android.tools.lint.detector.api.Issue, com.android.tools.lint.detector.api.Severity) or Configuration.ignore(com.android.tools.lint.detector.api.Context, com.android.tools.lint.detector.api.Issue, com.android.tools.lint.detector.api.Location, java.lang.String, java.lang.Object). After all the values have been set, the client must call Configuration.finishBulkEditing(). This allows configurations to avoid doing expensive I/O (such as writing out a config XML file) for each and every editing operation when they are applied in bulk, such as from a configuration dialog's "Apply" action.

Overrides:
startBulkEditing in class Configuration

finishBulkEditing

public void finishBulkEditing()
Description copied from class: Configuration
Marks the end of a "bulk" editing operation, where values should be committed to persistent storage. See Configuration.startBulkEditing() for details.

Overrides:
finishBulkEditing in class Configuration