本文整理汇总了Java中com.sun.source.util.TaskEvent.Kind类的典型用法代码示例。如果您正苦于以下问题:Java Kind类的具体用法?Java Kind怎么用?Java Kind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Kind类属于com.sun.source.util.TaskEvent包,在下文中一共展示了Kind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
void test(Iterable<String> options, Iterable<JavaFileObject> files) throws IOException {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
TestListener listener = new TestListener();
JavacTask task = tool.getTask(pw, fm, null, options, null, files);
task.setTaskListener(listener);
task.call();
for (Entry<Kind, Integer> e : listener.kind2Count.entrySet()) {
if (e.getValue() != null && e.getValue() != 0) {
throw new IllegalStateException("Not balanced event: " + e.getKey());
}
}
}
示例2: finished
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
@Override
public void finished(TaskEvent e) {
if (e.getKind() == Kind.ANALYZE) {
e.getCompilationUnit().accept(new Scanner(), null);
} else if (e.getKind() == Kind.GENERATE) {
try {
FileObject file =
processingEnv
.getFiler()
.createResource(
StandardLocation.CLASS_OUTPUT, "", "output.txt", e.getTypeElement());
try (OutputStream os = file.openOutputStream()) {
os.write(values.toString().getBytes(UTF_8));
}
} catch (IOException exception) {
throw new IOError(exception);
}
}
}
示例3: finished
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
@Override
public void finished(TaskEvent e) {
if (e.getKind() == Kind.ANALYZE) {
JCCompilationUnit toplevel = (JCCompilationUnit) e.getCompilationUnit();
if (toplevel != null && toplevel.sourcefile != null) {
flowCompleted.add(toplevel.sourcefile.toUri());
}
}
}
示例4: isSimpleStringArg
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
boolean isSimpleStringArg(JCExpression e) {
switch (e.getTag()) {
case LAMBDA:
JCLambda lambda = (JCLambda)e;
return (lambda.getBodyKind() == BodyKind.EXPRESSION) &&
isSimpleStringArg((JCExpression)lambda.body);
default:
Symbol argSym = TreeInfo.symbolFor(e);
return (e.type.constValue() != null ||
(argSym != null && argSym.kind == Kinds.Kind.VAR));
}
}
示例5: checkLegacyLogMethod
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
void checkLegacyLogMethod(JCMethodInvocation tree) {
Symbol method = TreeInfo.symbolFor(tree);
if (method == null ||
method.kind != Kinds.Kind.MTH ||
!typeToCheck(method.owner.type) ||
!LEGACY_METHOD_NAMES.contains(method.name.toString()) ||
!((MethodSymbol) method).isVarArgs() ||
method.type.getParameterTypes().size() < 2) {
return ;
}
JCExpression key = tree.args.get(method.type.getParameterTypes().size() - 2);
if (key.hasTag(Tag.LITERAL)) {
messages.error(tree, "crules.use.of.legacy.log.method", tree);
}
}
示例6: visitBlock
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
@Override
public Void visitBlock(BlockTree node, Void p) {
if (getCurrentPath().getParentPath().getLeaf().getKind() != Tree.Kind.CLASS) {
return super.visitBlock(node, p);
}
Element prevOwner = currentOwner;
try {
currentOwner = null;
return super.visitBlock(node, p);
} finally {
currentOwner = prevOwner;
}
}
示例7: test
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
void test(List<String> options, List<JavaFileObject> files) throws IOException {
System.err.println("testing: " + options + ", " + files);
TestListener listener = new TestListener();
JavacTask task = tool.getTask(null, fm, null, options, null, files);
task.setTaskListener(listener);
task.call();
for (Entry<Kind, Integer> e : listener.kind2Count.entrySet()) {
if (e.getValue() != null && e.getValue() != 0) {
throw new IllegalStateException("Not balanced event: " + e.getKey());
}
}
}
示例8: get
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
int get(Kind k) {
Integer count = kind2Count.get(k);
if (count == null)
kind2Count.put(k, count = 0);
return count;
}
示例9: visitClass
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
@Override
public Void visitClass(ClassTree node, Symtab syms) {
Symbol sym = ((JCClassDecl)node).sym;
if (sym != null) {
syms.removeClass(sym.packge().modle, sym.flatName());
Type sup = supertype(sym);
if (isCoreClass(sym) ||
(sup != null && isCoreClass(sup.tsym) && sup.tsym.kind != Kinds.Kind.TYP)) {
polluted = true;
}
}
return super.visitClass(node, syms);
}
示例10: report
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
List<Diagnostic<? extends JavaFileObject>> diags =
diagsByKeys.getOrDefault(diagnostic.getCode(), List.nil());
diagsByKeys.put(diagnostic.getCode(), diags.prepend(diagnostic));
Diagnostic.Kind kind = diagnostic.getKind();
diags = diagsByKind.getOrDefault(kind, List.nil());
diagsByKind.put(kind, diags.prepend(diagnostic));
}
示例11: postFlow
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
/** Run Error Prone analysis after performing dataflow checks. */
@Override
public void postFlow(Env<AttrContext> env) {
try {
errorProneAnalyzer.finished(new TaskEvent(Kind.ANALYZE, env.toplevel, env.enclClass.sym));
} catch (ErrorProneError e) {
e.logFatalError(log);
// let the exception propagate to javac's main, where it will cause the compilation to
// terminate with Result.ABNORMAL
throw e;
}
}
示例12: getEntries
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
private Map<String, Deps.Dependency.Kind> getEntries(Deps.Dependencies deps) {
Map<String, Deps.Dependency.Kind> result = new LinkedHashMap<>();
for (Dependency dep : deps.getDependencyList()) {
result.put(dep.getPath(), dep.getKind());
}
return result;
}
示例13: MutableFieldsAnalyzer
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
public MutableFieldsAnalyzer(JavacTask task) {
super(task);
treeVisitor = new MutableFieldsVisitor();
eventKind = Kind.ANALYZE;
}
示例14: AssertCheckAnalyzer
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
public AssertCheckAnalyzer(JavacTask task) {
super(task);
treeVisitor = new AssertCheckVisitor();
eventKind = Kind.ANALYZE;
}
示例15: LegacyLogMethodAnalyzer
import com.sun.source.util.TaskEvent.Kind; //导入依赖的package包/类
public LegacyLogMethodAnalyzer(JavacTask task) {
super(task);
treeVisitor = new LegacyLogMethodVisitor();
eventKind = Kind.ANALYZE;
}