Java Code Examples for com.sun.source.util.TaskEvent#getCompilationUnit()
The following examples show how to use
com.sun.source.util.TaskEvent#getCompilationUnit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavacPlugin.java From manifold with Apache License 2.0 | 6 votes |
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() ) ); } } } }
Example 2
Source File: ValidatingTaskListener.java From buck with Apache License 2.0 | 6 votes |
@Override public void finished(TaskEvent e) { TaskEvent.Kind kind = e.getKind(); if (kind == TaskEvent.Kind.PARSE) { 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; } }
Example 3
Source File: ShowTypePlugin.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void finished(TaskEvent taskEvent) { if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) { CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit(); visitor.scan(compilationUnit, null); } }
Example 4
Source File: ShowTypePlugin.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void finished(TaskEvent taskEvent) { if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) { CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit(); visitor.scan(compilationUnit, null); } }
Example 5
Source File: ShowTypePlugin.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void finished(TaskEvent taskEvent) { if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) { CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit(); visitor.scan(compilationUnit, null); } }
Example 6
Source File: JavacFlowListener.java From netbeans with Apache License 2.0 | 5 votes |
@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()); } } }
Example 7
Source File: ShowTypePlugin.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public void finished(TaskEvent taskEvent) { if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) { CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit(); visitor.scan(compilationUnit, null); } }
Example 8
Source File: ShowTypePlugin.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void finished(TaskEvent taskEvent) { if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) { CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit(); visitor.scan(compilationUnit, null); } }
Example 9
Source File: CompiledTypeProcessor.java From manifold with Apache License 2.0 | 5 votes |
@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 ); } } }
Example 10
Source File: ShowTypePlugin.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public void finished(TaskEvent taskEvent) { if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) { CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit(); visitor.scan(compilationUnit, null); } }
Example 11
Source File: ShowTypePlugin.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public void finished(TaskEvent taskEvent) { if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) { CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit(); visitor.scan(compilationUnit, null); } }
Example 12
Source File: ShowTypePlugin.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public void finished(TaskEvent taskEvent) { if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) { CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit(); visitor.scan(compilationUnit, null); } }
Example 13
Source File: CompiledTypeProcessor.java From manifold with Apache License 2.0 | 4 votes |
@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 ); }
Example 14
Source File: JavacPlugin.java From manifold with Apache License 2.0 | 4 votes |
private void tailorJavaCompiler( TaskEvent te ) { CompilationUnitTree compilationUnit = te.getCompilationUnit(); if( !(compilationUnit instanceof JCTree.JCCompilationUnit) ) { return; } // For type processing (##todo is this still necessary?) JavaCompiler compiler = JavaCompiler.instance( getContext() ); compiler.shouldStopPolicyIfNoError = CompileStates.CompileState.max( compiler.shouldStopPolicyIfNoError, CompileStates.CompileState.FLOW ); // // Both Java 8 and Java 9 alterations // // Override javac's Log for error suppression (@Jailbreak too, but that's only if extensions are enabled, see below) ReflectUtil.method( "manifold.internal.javac.ManLog_" + (IS_JAVA_8 ? 8 : 9), "instance", Context.class ).invokeStatic( getContext() ); // Override javac's ClassWriter ManClassWriter.instance( getContext() ); // Override javac's Check ManCheck.instance( getContext() ); if( !isExtensionsEnabled() ) { // No need to hook up all the extension stuff if it's not enabled return; } // Override javac's Attr Attr manAttr = (Attr)ReflectUtil.method( "manifold.internal.javac.ManAttr_" + (IS_JAVA_8 ? 8 : 9), "instance", Context.class ).invokeStatic( getContext() ); // Override javac's Resolve ManResolve.instance( _ctx ); // Override javac's TransTypes ManTransTypes.instance( _ctx ); // Override javac's Types ManTypes.instance( _ctx ); ((Log)ReflectUtil.field( manAttr, "log" ).get()).setDiagnosticFormatter( RichDiagnosticFormatter.instance( _ctx ) ); if( IS_JAVA_8 ) { return; } // // Java 9 specific alterations // Symbol module = (Symbol)ReflectUtil.field( compilationUnit, "modle" ).get(); if( module == null ) { return; } Set<Symbol> modules = _seenModules.computeIfAbsent( getContext(), k -> new LinkedHashSet<>() ); if( modules.contains( module ) ) { return; } modules.add( module ); NecessaryEvilUtil.openModule( getContext(), "jdk.compiler" ); // Override javac's ClassFinder //noinspection ConstantConditions ReflectUtil.method( ReflectUtil.type( "manifold.internal.javac.ManClassFinder_9" ), "instance", Context.class ).invokeStatic( getContext() ); }