本文整理汇总了Java中com.sun.source.util.TaskEvent.getTypeElement方法的典型用法代码示例。如果您正苦于以下问题:Java TaskEvent.getTypeElement方法的具体用法?Java TaskEvent.getTypeElement怎么用?Java TaskEvent.getTypeElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.source.util.TaskEvent
的用法示例。
在下文中一共展示了TaskEvent.getTypeElement方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public void finished(TaskEvent taskEvent) {
List<AbstractCodingRulesAnalyzer> currentAnalyzers = this.analyzers.get(taskEvent.getKind());
if (currentAnalyzers != null) {
TypeElement typeElem = taskEvent.getTypeElement();
Tree tree = trees.getTree(typeElem);
if (tree != null) {
JavaFileObject prevSource = log.currentSourceFile();
try {
log.useSource(taskEvent.getCompilationUnit().getSourceFile());
for (AbstractCodingRulesAnalyzer analyzer : currentAnalyzers) {
analyzer.treeVisitor.scan((JCTree)tree);
}
} finally {
log.useSource(prevSource);
}
}
}
}
示例2: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void finished(TaskEvent taskEvent) {
if (taskEvent.getKind().equals(eventKind)) {
TypeElement typeElem = taskEvent.getTypeElement();
Tree tree = trees.getTree(typeElem);
if (tree != null) {
JavaFileObject prevSource = log.currentSourceFile();
try {
log.useSource(taskEvent.getCompilationUnit().getSourceFile());
treeVisitor.scan((JCTree)tree);
} finally {
log.useSource(prevSource);
}
}
}
}
示例3: finished
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
@Override
public void finished(TaskEvent e) {
if (e.getKind() != TaskEvent.Kind.ANALYZE) return;
TypeElement elem = e.getTypeElement();
for(Tree t : e.getCompilationUnit().getTypeDecls()) {
if (t.getKind() == Tree.Kind.CLASS) {
if (((JCClassDecl)t).sym.equals(elem)) {
currentClass = (ClassTree)t;
break;
}
}
}
if (currentClass != null) {
verify(currentClass, elem);
}
}
示例4: 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 );
}
}
}
示例5: 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;
}
}
示例6: 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;
}
}
示例7: mirrorTaskEvent
import com.sun.source.util.TaskEvent; //导入方法依赖的package包/类
private TaskEventMirror mirrorTaskEvent(TaskEvent e) {
return new TaskEventMirror(
e,
mirrorKind(e.getKind()),
e.getSourceFile(),
proxyCompilationUnit(e.getCompilationUnit()),
e.getTypeElement());
}
示例8: 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 );
}