本文整理汇总了Java中com.google.errorprone.BugPattern类的典型用法代码示例。如果您正苦于以下问题:Java BugPattern类的具体用法?Java BugPattern怎么用?Java BugPattern使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BugPattern类属于com.google.errorprone包,在下文中一共展示了BugPattern类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: assertErrorsOnLines
import com.google.errorprone.BugPattern; //导入依赖的package包/类
/**
* Asserts that the given diagnostics contain errors with a message containing "[CheckerName]"
* on the given lines of the given file. If there should be multiple errors on a line, the line
* number must appear multiple times. There may not be any errors in any other file.
*/
public void assertErrorsOnLines(String file,
List<Diagnostic<? extends JavaFileObject>> diagnostics, long... lines) {
ListMultimap<String, Long> actualErrors = ArrayListMultimap.create();
for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics) {
String message = diagnostic.getMessage(Locale.US);
// The source may be null, e.g. for diagnostics about command-line flags
assertNotNull(message, diagnostic.getSource());
String sourceName = diagnostic.getSource().getName();
assertEquals(
"unexpected error in source file " + sourceName + ": " + message,
file, sourceName);
actualErrors.put(diagnostic.getSource().getName(), diagnostic.getLineNumber());
// any errors from the compiler that are not related to this checker should fail
assertThat(message).contains("[" + checker.getAnnotation(BugPattern.class).name() + "]");
}
assertEquals(
ImmutableMultiset.copyOf(Longs.asList(lines)),
ImmutableMultiset.copyOf(actualErrors.get(file)));
}
开发者ID:google,项目名称:guava-beta-checker,代码行数:30,代码来源:TestCompiler.java
示例2: BugChecker
import com.google.errorprone.BugPattern; //导入依赖的package包/类
public BugChecker() {
pattern = this.getClass().getAnnotation(BugPattern.class);
try {
BugPatternValidator.validate(pattern);
} catch (ValidationException e) {
throw new IllegalStateException(e);
}
canonicalName = pattern.name();
allNames = new HashSet<String>();
allNames.add(canonicalName);
allNames.addAll(Arrays.asList(pattern.altNames()));
disableable = pattern.disableable();
suppressibility = pattern.suppressibility();
if (suppressibility == Suppressibility.CUSTOM_ANNOTATION) {
customSuppressionAnnotation = pattern.customSuppressionAnnotation();
} else {
customSuppressionAnnotation = null;
}
}
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:20,代码来源:BugChecker.java
示例3: Description
import com.google.errorprone.BugPattern; //导入依赖的package包/类
/** TODO(cushon): Remove this constructor and ensure that there's always a check name. */
@Deprecated
public Description(
Tree node, String message, Fix suggestedFix, BugPattern.SeverityLevel severity) {
this(node, UNDEFINED_CHECK_NAME, message, message, ImmutableList.of(suggestedFix), severity);
if (suggestedFix == null) {
throw new IllegalArgumentException("suggestedFix must not be null.");
}
}
开发者ID:google,项目名称:error-prone,代码行数:10,代码来源:Description.java
示例4: defaultSeverities
import com.google.errorprone.BugPattern; //导入依赖的package包/类
private static Map<String, BugPattern.SeverityLevel> defaultSeverities(
Iterable<BugChecker> checkers) {
ImmutableMap.Builder<String, BugPattern.SeverityLevel> builder = ImmutableMap.builder();
for (BugChecker check : checkers) {
builder.put(check.canonicalName(), check.defaultSeverity());
}
return builder.build();
}
开发者ID:google,项目名称:error-prone,代码行数:9,代码来源:ErrorProneScanner.java
示例5: Description
import com.google.errorprone.BugPattern; //导入依赖的package包/类
private Description(Tree node, String checkName, String message, String rawMessage,
Fix suggestedFix, BugPattern.SeverityLevel severity) {
this.checkName = checkName;
this.message = message;
this.rawMessage = rawMessage;
if (suggestedFix == null) {
throw new IllegalArgumentException("suggestedFix must not be null. Use "
+ "SuggestedFix.NO_FIX if there is no fix.");
}
this.suggestedFix = suggestedFix;
this.node = node;
this.severity = severity;
}
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:14,代码来源:Description.java
示例6: setUp
import com.google.errorprone.BugPattern; //导入依赖的package包/类
@Before
public void setUp() {
compiler = new ErrorProneTestCompiler.Builder()
.report(new ErrorProneScanner(new EnabledPredicate() {
@SuppressWarnings("unchecked")
@Override
public boolean isEnabled(Class<? extends BugChecker> check, BugPattern annotation) {
return asList(DeadException.class, EmptyIfStatement.class, SelfAssignment.class)
.contains(check);
}
}))
.build();
}
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:14,代码来源:SuppressWarningsTest.java
示例7: getSuppressibility
import com.google.errorprone.BugPattern; //导入依赖的package包/类
@Override
public BugPattern.Suppressibility getSuppressibility() {
return suppressibility;
}
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:5,代码来源:BugChecker.java
示例8: getSuppressibility
import com.google.errorprone.BugPattern; //导入依赖的package包/类
/**
* Returns how this checker can be suppressed (e.g., via {@code @SuppressWarnings} or a custom
* suppression annotation.
*/
BugPattern.Suppressibility getSuppressibility();
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:6,代码来源:Suppressible.java
注:本文中的com.google.errorprone.BugPattern类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论