本文整理汇总了Java中com.android.tools.lint.detector.api.Severity类的典型用法代码示例。如果您正苦于以下问题:Java Severity类的具体用法?Java Severity怎么用?Java Severity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Severity类属于com.android.tools.lint.detector.api包,在下文中一共展示了Severity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSeverityOverrides
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
/**
* An optional map of severity overrides. The map maps from issue id's to the corresponding
* severity to use, which must be "fatal", "error", "warning", or "ignore".
*
* @return a map of severity overrides, or null. The severities are one of the constants
* {@link #SEVERITY_FATAL}, {@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING},
* {@link #SEVERITY_INFORMATIONAL}, {@link #SEVERITY_IGNORE}
*/
@Override
@Nullable
public Map<String, Integer> getSeverityOverrides() {
if (severities == null || severities.isEmpty()) {
return null;
}
Map<String, Integer> map =
Maps.newHashMapWithExpectedSize(severities.size());
for (Map.Entry<String,Severity> entry : severities.entrySet()) {
map.put(entry.getKey(), convert(entry.getValue()));
}
return map;
}
示例2: getSeverity
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
@Override
@NonNull
public Severity getSeverity(@NonNull Issue issue) {
ensureInitialized();
Severity severity = mSeverity.get(issue.getId());
if (severity == null) {
severity = mSeverity.get(VALUE_ALL);
}
if (severity != null) {
return severity;
}
if (mParent != null) {
return mParent.getSeverity(issue);
}
return getDefaultSeverity(issue);
}
示例3: log
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
@Override
public void log(
@NonNull Severity severity,
@Nullable Throwable exception,
@Nullable String format,
@Nullable Object... args) {
System.out.flush();
if (!mFlags.isQuiet()) {
// Place the error message on a line of its own since we're printing '.' etc
// with newlines during analysis
System.err.println();
}
if (format != null) {
System.err.println(String.format(format, args));
}
if (exception != null) {
exception.printStackTrace();
}
}
示例4: getSeverity
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
@NonNull
@Override
public Severity getSeverity(@NonNull Issue issue) {
Severity severity = computeSeverity(issue);
if (mFatalOnly && severity != Severity.FATAL) {
return Severity.IGNORE;
}
if (mFlags.isWarningsAsErrors() && severity == Severity.WARNING) {
severity = Severity.ERROR;
}
if (mFlags.isIgnoreWarnings() && severity == Severity.WARNING) {
severity = Severity.IGNORE;
}
return severity;
}
示例5: getConfiguration
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
/** Returns the configuration used by this client */
Configuration getConfiguration() {
if (mConfiguration == null) {
File configFile = mFlags.getDefaultConfiguration();
if (configFile != null) {
if (!configFile.exists()) {
if (sAlreadyWarned == null || !sAlreadyWarned.contains(configFile)) {
log(Severity.ERROR, null,
"Warning: Configuration file %1$s does not exist", configFile);
}
if (sAlreadyWarned == null) {
sAlreadyWarned = Sets.newHashSet();
}
sAlreadyWarned.add(configFile);
}
mConfiguration = createConfigurationFromFile(configFile);
}
}
return mConfiguration;
}
示例6: log
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
@Override
public void log(
@NonNull Severity severity,
@Nullable Throwable exception,
@Nullable String format,
@Nullable Object... args) {
if (format != null) {
mLogBuffer.append(String.format(format, args));
mLogBuffer.append('\n');
}
if (exception != null) {
StringWriter writer = new StringWriter();
exception.printStackTrace(new PrintWriter(writer));
mLogBuffer.append(writer.toString());
mLogBuffer.append('\n');
}
}
示例7: test
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
public void test() throws Exception {
DefaultConfiguration configuration = getConfiguration(""
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<lint>\n"
+ " <issue id=\"ObsoleteLayoutParam\">\n"
+ " <ignore path=\"res/layout-xlarge/activation.xml\" />\n"
+ " </issue>\n"
+ " <issue id=\"FloatMath\" severity=\"ignore\" />\n"
+ " <issue id=\"FieldGetter\" severity=\"error\" />\n"
+ " <issue id=\"SdCardPath,ContentDescription\" severity=\"ignore\" />"
+ " <issue id=\"NewApi\">\n"
+ " <ignore path=\"res/layout-xlarge\" />\n"
+ " </issue>\n"
+ "</lint>");
assertTrue(configuration.isEnabled(ObsoleteLayoutParamsDetector.ISSUE));
assertFalse(configuration.isEnabled(SdCardDetector.ISSUE));
assertFalse(configuration.isEnabled(MathDetector.ISSUE));
assertFalse(configuration.isEnabled(AccessibilityDetector.ISSUE));
assertEquals(Severity.IGNORE, configuration.getSeverity(AccessibilityDetector.ISSUE));
assertEquals(Severity.WARNING, AccessibilityDetector.ISSUE.getDefaultSeverity());
assertEquals(Severity.WARNING, FieldGetterDetector.ISSUE.getDefaultSeverity());
assertEquals(Severity.ERROR, configuration.getSeverity(FieldGetterDetector.ISSUE));
assertEquals(Severity.IGNORE, configuration.getSeverity(MathDetector.ISSUE));
}
示例8: convert
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
private static int convert(Severity s) {
switch (s) {
case FATAL:
return com.android.builder.model.LintOptions.SEVERITY_FATAL;
case ERROR:
return com.android.builder.model.LintOptions.SEVERITY_ERROR;
case WARNING:
return com.android.builder.model.LintOptions.SEVERITY_WARNING;
case INFORMATIONAL:
return com.android.builder.model.LintOptions.SEVERITY_INFORMATIONAL;
case IGNORE:
default:
return com.android.builder.model.LintOptions.SEVERITY_IGNORE;
}
}
示例9: report
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
@Override
public void report(
@NonNull Context context,
@NonNull Issue issue,
@NonNull Severity severity,
@Nullable Location location,
@NonNull String message,
@NonNull TextFormat format) {
assert mCurrentProject != null;
if (!mCurrentProject.getReportIssues()) {
return;
}
Configuration configuration = context.getConfiguration();
if (!configuration.isEnabled(issue)) {
if (issue != IssueRegistry.PARSER_ERROR && issue != IssueRegistry.LINT_ERROR) {
mDelegate.log(null, "Incorrect detector reported disabled issue %1$s",
issue.toString());
}
return;
}
if (configuration.isIgnored(context, issue, location, message)) {
return;
}
if (severity == Severity.IGNORE) {
return;
}
mDelegate.report(context, issue, severity, location, message, format);
}
示例10: JarFileIssueRegistry
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
private JarFileIssueRegistry(@NonNull LintClient client, @NonNull File file)
throws IOException, ClassNotFoundException, IllegalAccessException,
InstantiationException {
myIssues = Lists.newArrayList();
JarFile jarFile = null;
try {
jarFile = new JarFile(file);
Manifest manifest = jarFile.getManifest();
Attributes attrs = manifest.getMainAttributes();
Object object = attrs.get(new Attributes.Name(MF_LINT_REGISTRY));
if (object instanceof String) {
String className = (String) object;
// Make a class loader for this jar
URL url = SdkUtils.fileToUrl(file);
URLClassLoader loader = new URLClassLoader(new URL[]{url},
JarFileIssueRegistry.class.getClassLoader());
Class<?> registryClass = Class.forName(className, true, loader);
IssueRegistry registry = (IssueRegistry) registryClass.newInstance();
myIssues.addAll(registry.getIssues());
} else {
client.log(Severity.ERROR, null,
"Custom lint rule jar %1$s does not contain a valid registry manifest key " +
"(%2$s).\n" +
"Either the custom jar is invalid, or it uses an outdated API not supported " +
"this lint client", file.getPath(), MF_LINT_REGISTRY);
}
} finally {
if (jarFile != null) {
jarFile.close();
}
}
}
示例11: getDefaultSeverity
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
@NonNull
protected Severity getDefaultSeverity(@NonNull Issue issue) {
if (!issue.isEnabledByDefault()) {
return Severity.IGNORE;
}
return issue.getDefaultSeverity();
}
示例12: setSeverity
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
@Override
public void setSeverity(@NonNull Issue issue, @Nullable Severity severity) {
ensureInitialized();
String id = issue.getId();
if (severity == null) {
mSeverity.remove(id);
} else {
mSeverity.put(id, severity);
}
if (!mBulkEditing) {
writeConfig();
}
}
示例13: checkReportedError
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
protected void checkReportedError(
@NonNull Context context,
@NonNull Issue issue,
@NonNull Severity severity,
@Nullable Location location,
@NonNull String message) {
}
示例14: getDefaultSeverity
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
@Override
@NonNull
protected Severity getDefaultSeverity(@NonNull Issue issue) {
// In unit tests, include issues that are ignored by default
Severity severity = super.getDefaultSeverity(issue);
if (severity == Severity.IGNORE) {
if (issue.getDefaultSeverity() != Severity.IGNORE) {
return issue.getDefaultSeverity();
}
return Severity.WARNING;
}
return severity;
}
示例15: getDefaultSeverity
import com.android.tools.lint.detector.api.Severity; //导入依赖的package包/类
@NonNull
@Override
protected Severity getDefaultSeverity(@NonNull Issue issue) {
if (mFlags.isCheckAllWarnings()) {
return issue.getDefaultSeverity();
}
return super.getDefaultSeverity(issue);
}