本文整理汇总了Java中com.sun.source.util.TaskEvent.getCompilationUnit方法的典型用法代码示例。如果您正苦于以下问题:Java TaskEvent.getCompilationUnit方法的具体用法?Java TaskEvent.getCompilationUnit怎么用?Java TaskEvent.getCompilationUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.source.util.TaskEvent
的用法示例。
在下文中一共展示了TaskEvent.getCompilationUnit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: started
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void started( TaskEvent te )
{
if( JreUtil.isJava8() )
{
return;
}
CompilationUnitTree compilationUnit = te.getCompilationUnit();
if( !(compilationUnit instanceof JCTree.JCCompilationUnit) )
{
return;
}
if( _done )
{
return;
}
_done = true;
openModule( _ctx, "jdk.compiler" );
}
示例2: addInputFile
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
private void addInputFile( TaskEvent e )
{
if( !_initialized )
{
CompilationUnitTree compilationUnit = e.getCompilationUnit();
ExpressionTree pkg = compilationUnit.getPackageName();
String packageQualifier = pkg == null ? "" : (pkg.toString() + '.');
for( Tree classDecl : compilationUnit.getTypeDecls() )
{
if( classDecl instanceof JCTree.JCClassDecl )
{
_javaInputFiles.add( new Pair<>( packageQualifier + ((JCTree.JCClassDecl)classDecl).getSimpleName(), compilationUnit.getSourceFile() ) );
}
}
}
}
示例3: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void finished(TaskEvent e) {
final TaskEvent.Kind kind = e.getKind();
if (kind == TaskEvent.Kind.PARSE) {
final CompilationUnitTree compilationUnit = e.getCompilationUnit();
compilationUnits.add(compilationUnit);
} else if (kind == TaskEvent.Kind.ENTER) {
enterDepth -= 1;
// We wait until we've received all enter events so that the validation time shows up
// separately from compiler enter time in the traces. We wait until after annotation
// processing so we catch all the types.
if (!annotationProcessing && enterDepth == 0 && !errorsExist.get()) {
getValidator().validate(compilationUnits);
}
} else if (kind == TaskEvent.Kind.ANNOTATION_PROCESSING) {
annotationProcessing = false;
}
}
示例4: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的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());
}
}
}
示例5: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
/**
* Kicks off the scan if we've just finished the analyze phase
* @param e event
*/
@Override
public void finished(TaskEvent e) {
TaskEvent.Kind kind = e.getKind();
if (kind == TaskEvent.Kind.ANALYZE) {
// visit all of the classes to see if their method params are explicitly or effectively final
CompilationUnitTree compilationUnit = e.getCompilationUnit();
visitor.scan(compilationUnit, null);
}
}
示例6: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void finished(TaskEvent taskEvent) {
if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) {
CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit();
visitor.scan(compilationUnit, null);
}
}
示例7: started
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void started( TaskEvent e )
{
if( e.getKind() != TaskEvent.Kind.GENERATE )
{
return;
}
//
// Process trees that were generated and therefore not available during ANALYZE
// For instance, we must process bridge methods
//
TypeElement elem = e.getTypeElement();
if( elem instanceof Symbol.ClassSymbol )
{
if( _typesToProcess.containsKey( elem.getQualifiedName().toString() ) )
{
_tree = findTopLevel( (Symbol.ClassSymbol)elem, e.getCompilationUnit().getTypeDecls() );
}
else
{
_tree = _innerClassForGeneration.get( ((Symbol.ClassSymbol)elem).flatName().toString() );
}
if( _tree != null )
{
_compilationUnit = e.getCompilationUnit();
_generate = true;
process( elem, _issueReporter );
}
}
}
示例8: hijackJavacCompilerForJava9
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
private void hijackJavacCompilerForJava9( TaskEvent te )
{
if( IS_JAVA_8 )
{
return;
}
CompilationUnitTree compilationUnit = te.getCompilationUnit();
if( !(compilationUnit instanceof JCTree.JCCompilationUnit) )
{
return;
}
Symbol module = (Symbol)ReflectUtil.field( compilationUnit, "modle" ).get();
if( module == null || _seenModules.contains( module ) )
{
return;
}
_seenModules.add( module );
BootstrapPlugin.openModule( _ctx, "jdk.compiler" );
// Override javac's Resolve (lol)
ReflectUtil.method( ReflectUtil.type( "manifold.internal.javac.ManResolve" ), "instance", Context.class ).invokeStatic( _ctx );
// Override javac's ClassFinder
ReflectUtil.method( ReflectUtil.type( "manifold.internal.javac.ManClassFinder" ), "instance", Context.class ).invokeStatic( _ctx );
}
示例9: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void finished(TaskEvent e) {
if (e.getKind() != TaskEvent.Kind.ANALYZE)
return;
if (!hasInvokedTypeProcessingStart) {
typeProcessingStart();
hasInvokedTypeProcessingStart = true;
}
Log log = Log.instance(((JavacProcessingEnvironment) processingEnv).getContext());
if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) {
typeProcessingOver();
hasInvokedTypeProcessingOver = true;
}
if (e.getTypeElement() == null)
throw new AssertionError("event task without a type element");
if (e.getCompilationUnit() == null)
throw new AssertionError("event task without compilation unit");
if (!elements.remove(e.getTypeElement().getQualifiedName()))
return;
TypeElement elem = e.getTypeElement();
TreePath p = Trees.instance(processingEnv).getPath(elem);
typeProcess(elem, p);
if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) {
typeProcessingOver();
hasInvokedTypeProcessingOver = true;
}
}
示例10: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void finished(TaskEvent e) {
if (e.getKind() != TaskEvent.Kind.ANALYZE) {
return;
}
if (!hasInvokedTypeProcessingStart) {
typeProcessingStart();
hasInvokedTypeProcessingStart = true;
}
Log log = Log.instance(((JavacProcessingEnvironment) processingEnv).getContext());
if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) {
typeProcessingOver();
hasInvokedTypeProcessingOver = true;
}
if (e.getTypeElement() == null) {
throw new AssertionError("event task without a type element");
}
if (e.getCompilationUnit() == null) {
throw new AssertionError("event task without compilation unit");
}
if (!elements.remove(e.getTypeElement().getQualifiedName())) {
return;
}
TypeElement elem = e.getTypeElement();
TreePath p = Trees.instance(processingEnv).getPath(elem);
typeProcess(elem, p);
if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) {
typeProcessingOver();
hasInvokedTypeProcessingOver = true;
}
}
示例11: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void finished(TaskEvent arg0) {
if (arg0.getKind().toString().equals("ANALYZE")) {
CompilationUnitTree u = arg0.getCompilationUnit();
GraphDatabaseService graphDb = graphDbBuilder.newGraphDatabase();
new WiggleVisitor(task, graphDb, cuProps).scan(u, null);
graphDb.shutdown();
}
}
示例12: started
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void started(TaskEvent taskEvent) {
if (taskEvent.getKind().equals(TaskEvent.Kind.ENTER)) {
CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit();
visitor.scan(compilationUnit, null);
}
}
示例13: started
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void started(TaskEvent taskEvent) {
JCCompilationUnit jcc = (JCCompilationUnit)taskEvent.getCompilationUnit();
// if (taskEvent.getKind().equals(TaskEvent.Kind.GENERATE)) {
// out.println("########## START ENTER\n\n\n"+jcc.toString());
// savingModdedSources(taskEvent);
// }
}
示例14: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void finished(TaskEvent taskEvent) {
JCCompilationUnit jcc = (JCCompilationUnit)taskEvent.getCompilationUnit();
if (taskEvent.getKind().equals(TaskEvent.Kind.ENTER)) {
persistentify(jcc);
// out.println("########## FINISH ENTER\n\n\n"+jcc.toString());
}
}
示例15: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void finished( TaskEvent e )
{
if( e.getKind() != TaskEvent.Kind.ANALYZE )
{
return;
}
//
// Process fully analyzed trees (full type information is in the trees)
//
_generate = false;
String fqn = e.getTypeElement().getQualifiedName().toString();
Boolean visited = _typesToProcess.get( fqn );
if( visited == Boolean.TRUE )
{
// already processed
return;
}
// if( visited == null && !isNested( e.getTypeElement().getEnclosingElement() ) && !isOuter( fqn ) )
// {
// // also process inner types of types to process and (outer type if processing inner type first)
// return;
// }
if( fqn.isEmpty() )
{
return;
}
// mark processed
_typesToProcess.put( fqn, true );
_compilationUnit = e.getCompilationUnit();
TypeElement elem = e.getTypeElement();
_tree = (JCTree.JCClassDecl)getTreeUtil().getTree( elem );
preserveInnerClassesForGeneration( _tree );
process( elem, _issueReporter );
}