本文整理汇总了Java中com.sun.mirror.apt.AnnotationProcessorFactory类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationProcessorFactory类的具体用法?Java AnnotationProcessorFactory怎么用?Java AnnotationProcessorFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationProcessorFactory类属于com.sun.mirror.apt包,在下文中一共展示了AnnotationProcessorFactory类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processing
import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
private static int processing(AnnotationProcessorFactory factory,
PrintWriter out,
String... args) {
if (out == null)
out = new PrintWriter(System.err, true);
com.sun.tools.apt.main.Main compiler =
new com.sun.tools.apt.main.Main("apt", out);
return compiler.compile(args, factory);
}
示例2: main
import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
public static int main(String[] args, File episode) throws Exception {
ClassLoader cl = Runner.class.getClassLoader();
Class apt = cl.loadClass("com.sun.tools.apt.Main");
Method processMethod = apt.getMethod("process",AnnotationProcessorFactory.class, String[].class);
com.sun.tools.internal.jxc.apt.SchemaGenerator r = new com.sun.tools.internal.jxc.apt.SchemaGenerator();
if(episode!=null)
r.setEpisodeFile(episode);
return (Integer) processMethod.invoke(null, r, args);
}
示例3: compile
import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
/** Main method: compile a list of files, return all compiled classes
* @param filenames The names of all files to be compiled.
*/
public List<ClassSymbol> compile(List<String> filenames,
Map<String, String> origOptions,
ClassLoader aptCL,
AnnotationProcessorFactory providedFactory,
java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
java.util.Set<java.io.File> aggregateGenFiles)
throws Throwable {
// as a JavaCompiler can only be used once, throw an exception if
// it has been used before.
assert !hasBeenUsed : "attempt to reuse JavaCompiler";
hasBeenUsed = true;
this.aggregateGenFiles = aggregateGenFiles;
long msec = System.currentTimeMillis();
ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
try {
//parse all files
ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
if (classesAsDecls) {
if (! l.head.endsWith(".java") ) { // process as class file
ClassSymbol cs = reader.enterClass(names.fromString(l.head));
try {
cs.complete();
} catch(Symbol.CompletionFailure cf) {
bark.aptError("CantFindClass", l);
continue;
}
classes.append(cs); // add to list of classes
continue;
}
}
trees.append(parse(l.head));
}
//enter symbols for all files
List<JCCompilationUnit> roots = trees.toList();
if (errorCount() == 0) {
boolean prev = bark.setDiagnosticsIgnored(true);
try {
enter.main(roots);
}
finally {
bark.setDiagnosticsIgnored(prev);
}
}
if (errorCount() == 0) {
apt.main(roots,
classes,
origOptions, aptCL,
providedFactory,
productiveFactories);
genSourceFileNames.addAll(apt.getSourceFileNames());
genClassFileNames.addAll(apt.getClassFileNames());
}
} catch (Abort ex) {
}
if (verbose)
printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
chk.reportDeferredDiagnostics();
printCount("error", errorCount());
printCount("warn", warningCount());
return classes.toList();
}
示例4: main
import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
public static void main(String argv[]) {
AnnotationProcessorFactory factory = new StaticApf();
System.exit(com.sun.tools.apt.Main.process(factory, argv));
}
示例5: compile
import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
/** Main method: compile a list of files, return all compiled classes
* @param filenames The names of all files to be compiled.
*/
public List<ClassSymbol> compile(List<String> filenames,
Map<String, String> origOptions,
ClassLoader aptCL,
AnnotationProcessorFactory providedFactory,
java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
java.util.Set<java.io.File> aggregateGenFiles)
throws Throwable {
// as a JavaCompiler can only be used once, throw an exception if
// it has been used before.
assert !hasBeenUsed : "attempt to reuse JavaCompiler";
hasBeenUsed = true;
this.aggregateGenFiles = aggregateGenFiles;
long msec = System.currentTimeMillis();
ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
try {
JavacFileManager fm = (JavacFileManager)fileManager;
//parse all files
ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
if (classesAsDecls) {
if (! l.head.endsWith(".java") ) { // process as class file
ClassSymbol cs = reader.enterClass(names.fromString(l.head));
try {
cs.complete();
} catch(Symbol.CompletionFailure cf) {
bark.aptError("CantFindClass", l);
continue;
}
classes.append(cs); // add to list of classes
continue;
}
}
JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
trees.append(parse(fo));
}
//enter symbols for all files
List<JCCompilationUnit> roots = trees.toList();
if (errorCount() == 0) {
boolean prev = bark.setDiagnosticsIgnored(true);
try {
enter.main(roots);
}
finally {
bark.setDiagnosticsIgnored(prev);
}
}
if (errorCount() == 0) {
apt.main(roots,
classes,
origOptions, aptCL,
providedFactory,
productiveFactories);
genSourceFileNames.addAll(apt.getSourceFileNames());
genClassFileNames.addAll(apt.getClassFileNames());
}
} catch (Abort ex) {
}
if (verbose)
log.printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
chk.reportDeferredDiagnostics();
printCount("error", errorCount());
printCount("warn", warningCount());
return classes.toList();
}
示例6: compile
import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
/** Main method: compile a list of files, return all compiled classes
* @param filenames The names of all files to be compiled.
*/
public List<ClassSymbol> compile(List<String> filenames,
Map<String, String> origOptions,
ClassLoader aptCL,
AnnotationProcessorFactory providedFactory,
java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
java.util.Set<java.io.File> aggregateGenFiles)
throws Throwable {
// as a JavaCompiler can only be used once, throw an exception if
// it has been used before.
assert !hasBeenUsed : "attempt to reuse JavaCompiler";
hasBeenUsed = true;
this.aggregateGenFiles = aggregateGenFiles;
long msec = System.currentTimeMillis();
ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
try {
JavacFileManager fm = (JavacFileManager)fileManager;
//parse all files
ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
if (classesAsDecls) {
if (! l.head.endsWith(".java") ) { // process as class file
ClassSymbol cs = reader.enterClass(names.fromString(l.head));
try {
cs.complete();
} catch(Symbol.CompletionFailure cf) {
bark.aptError("CantFindClass", l);
continue;
}
classes.append(cs); // add to list of classes
continue;
}
}
JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
trees.append(parse(fo));
}
//enter symbols for all files
List<JCCompilationUnit> roots = trees.toList();
if (errorCount() == 0) {
boolean prev = bark.setDiagnosticsIgnored(true);
try {
enter.main(roots);
}
finally {
bark.setDiagnosticsIgnored(prev);
}
}
if (errorCount() == 0) {
apt.main(roots,
classes,
origOptions, aptCL,
providedFactory,
productiveFactories);
genSourceFileNames.addAll(apt.getSourceFileNames());
genClassFileNames.addAll(apt.getClassFileNames());
}
} catch (Abort ex) {
}
if (verbose)
printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
chk.reportDeferredDiagnostics();
printCount("error", errorCount());
printCount("warn", warningCount());
return classes.toList();
}
示例7: process
import com.sun.mirror.apt.AnnotationProcessorFactory; //导入依赖的package包/类
/** Programmatic interface. If any argument
* is <tt>null</tt>, a <tt>NullPointerException</tt> is thrown.
* The "<tt>-factory</tt>" and "<tt>-factorypath</tt>"
* command line parameters are ignored by this entry point.
*
* @param factory The annotation processor factory to use
* @param args The command line parameters.
* @param out Where the tool's output is directed.
*/
public static int process(AnnotationProcessorFactory factory, PrintWriter out,
String... args) {
if (out == null)
throw new NullPointerException("Parameter out cannot be null.");
if (factory == null)
throw new NullPointerException("Parameter factory cannot be null");
return processing(factory, out, args);
}