@Beta public class DefaultConfiguration extends Configuration
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.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CONFIG_FILE_NAME
Default name of the configuration file
|
protected java.util.Map<java.lang.String,com.android.tools.lint.detector.api.Severity> |
severity
Map from id to custom
Severity override |
static java.lang.String |
TAG_LINT
The root tag in a configuration file
|
static java.lang.String |
VALUE_ALL |
| Modifier | Constructor and Description |
|---|---|
protected |
DefaultConfiguration(com.android.tools.lint.client.api.LintClient client,
Project project,
Configuration parent) |
protected |
DefaultConfiguration(com.android.tools.lint.client.api.LintClient client,
Project project,
Configuration parent,
java.io.File configFile) |
| Modifier and Type | Method and Description |
|---|---|
static DefaultConfiguration |
create(com.android.tools.lint.client.api.LintClient client,
java.io.File lintFile)
Creates a new
DefaultConfiguration for the given lint config
file, not affiliated with a project. |
static DefaultConfiguration |
create(com.android.tools.lint.client.api.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.
|
java.io.File |
getBaselineFile()
Returns the baseline file to use, if any.
|
protected com.android.tools.lint.detector.api.Severity |
getDefaultSeverity(Issue issue) |
com.android.tools.lint.detector.api.Severity |
getSeverity(Issue issue)
Returns the severity for a given issue.
|
static java.lang.String |
globToRegexp(java.lang.String glob) |
void |
ignore(com.android.tools.lint.detector.api.Context context,
Issue issue,
com.android.tools.lint.detector.api.Location location,
java.lang.String message)
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(com.android.tools.lint.detector.api.Context context,
Issue issue,
com.android.tools.lint.detector.api.Location location,
java.lang.String message)
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 |
setBaselineFile(java.io.File baselineFile)
Sets the baseline file, if any.
|
void |
setSeverity(Issue issue,
com.android.tools.lint.detector.api.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). |
isEnabledpublic static final java.lang.String CONFIG_FILE_NAME
public static final java.lang.String TAG_LINT
public static final java.lang.String VALUE_ALL
protected java.util.Map<java.lang.String,com.android.tools.lint.detector.api.Severity> severity
Severity overrideprotected DefaultConfiguration(@NonNull
com.android.tools.lint.client.api.LintClient client,
@Nullable
Project project,
@Nullable
Configuration parent,
@NonNull
java.io.File configFile)
protected DefaultConfiguration(@NonNull
com.android.tools.lint.client.api.LintClient client,
@NonNull
Project project,
@Nullable
Configuration parent)
@NonNull public static DefaultConfiguration create(@NonNull com.android.tools.lint.client.api.LintClient client, @NonNull Project project, @Nullable Configuration parent)
DefaultConfigurationclient - the client to report errors to etcproject - the associated projectparent - the parent/fallback configuration or null@NonNull public static DefaultConfiguration create(@NonNull com.android.tools.lint.client.api.LintClient client, @NonNull java.io.File lintFile)
DefaultConfiguration for the given lint config
file, not affiliated with a project. This is used for global
configurations.client - the client to report errors to etclintFile - the lint file containing the configurationpublic boolean isIgnored(@NonNull
com.android.tools.lint.detector.api.Context context,
@NonNull
Issue issue,
@Nullable
com.android.tools.lint.detector.api.Location location,
@NonNull
java.lang.String message)
ConfigurationConfiguration.isEnabled(Issue).isIgnored in class Configurationcontext - the context used by the detector when the issue was foundissue - the issue that was foundlocation - the location of the issuemessage - the associated user message@NonNull
protected com.android.tools.lint.detector.api.Severity getDefaultSeverity(@NonNull
Issue issue)
@NonNull
public com.android.tools.lint.detector.api.Severity getSeverity(@NonNull
Issue issue)
ConfigurationIssue.getDefaultSeverity() unless the user has selected a custom
severity (which is tool context dependent).getSeverity in class Configurationissue - the issue to look up the severity from@NonNull
public static java.lang.String globToRegexp(@NonNull
java.lang.String glob)
public void ignore(@NonNull
com.android.tools.lint.detector.api.Context context,
@NonNull
Issue issue,
@Nullable
com.android.tools.lint.detector.api.Location location,
@NonNull
java.lang.String message)
Configurationignore in class Configurationcontext - The scanning contextissue - the issue to be ignoredlocation - The location to ignore the warning at, if anymessage - The message for the warningpublic void ignore(@NonNull
Issue issue,
@NonNull
java.io.File file)
Configurationignore in class Configurationissue - the issue to be ignored in the given filefile - the file to ignore the issue inpublic void setSeverity(@NonNull
Issue issue,
@Nullable
com.android.tools.lint.detector.api.Severity severity)
ConfigurationsetSeverity in class Configurationissue - the issue to set the severity forseverity - the severity to associate with this issue, or null to
reset the severity to the defaultpublic void startBulkEditing()
ConfigurationConfiguration.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). 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.startBulkEditing in class Configurationpublic void finishBulkEditing()
ConfigurationConfiguration.startBulkEditing() for
details.finishBulkEditing in class Configuration@Nullable public java.io.File getBaselineFile()
ConfigurationIf you have a project with a large number of existing warnings, this lets you set a baseline and only see newly introduced warnings until you get a chance to go back and address the "technical debt" of the earlier warnings.
getBaselineFile in class Configurationpublic void setBaselineFile(@Nullable
java.io.File baselineFile)
ConfigurationsetBaselineFile in class ConfigurationConfiguration.getBaselineFile()