return; TreePath path = JavacTrees.instance(context).getPath(taskEvent.getTypeElement()); if (path == null) { path = new TreePath(taskEvent.getCompilationUnit());
public TreePath getPath(Element e) { return getPath(e, null, null); }
public TreePath getPath(Element e, AnnotationMirror a) { return getPath(e, a, null); }
public TreePath getPath(Element e, AnnotationMirror a) { return getPath(e, a, null); }
public TreePath getPath(Element e) { return getPath(e, null, null); }
public TreePath getPath(Element e) { return getPath(e, null, null); }
public TreePath getPath(Element e, AnnotationMirror a) { return getPath(e, a, null); }
public TreePath getPath(Element e) { return getPath(e, null, null); }
public TreePath getPath(Element e, AnnotationMirror a) { return getPath(e, a, null); }
private Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> getClassSymbolForProducedClass( String fqn, BasicJavacTask[] task ) { StringWriter errors = new StringWriter(); // need javac with ManifoldJavaFileManager because the produced class must come from manifold task[0] = getJavacTask_ManFileMgr(); Symbol.ClassSymbol e = IDynamicJdk.instance().getTypeElement( task[0].getContext(), null, fqn ); if( e != null && e.getSimpleName().contentEquals( ManClassUtil.getShortClassName( fqn ) ) ) { JavacTrees trees = JavacTrees.instance( task[0].getContext() ); TreePath path = trees.getPath( e ); if( path != null ) { return new Pair<>( e, (JCTree.JCCompilationUnit)path.getCompilationUnit() ); } else { // TreePath is only applicable to a source file; // if fqn is not a source file, there is no compilation unit available return new Pair<>( e, null ); } } StringBuffer errorText = errors.getBuffer(); if( errorText.length() > 0 ) { throw new RuntimeException( "Compile errors:\n" + errorText ); } return null; }
private Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> getClassSymbol( Context ctx, Object moduleCtx, String fqn ) { Symbol.ClassSymbol typeElement = IDynamicJdk.instance().getTypeElement( ctx, moduleCtx, fqn ); if( typeElement == null ) { // For the case where the class is generated from a type manifold esp. from a IExtensionClassProducer return getClassSymbolForProducedClass( fqn, new BasicJavacTask[1] ); //## want this instead, but the typeElement is not complete in this case, investigate this // if( JavacPlugin.instance() != null ) // { // typeElement = IDynamicJdk.instance().getTypeElement( JavacPlugin.instance().getContext(), moduleCtx, fqn ); // typeElement.complete(); // } } JavacTrees trees = JavacTrees.instance( ctx ); TreePath path = trees.getPath( typeElement ); if( path != null ) { return new Pair<>( typeElement, (JCTree.JCCompilationUnit)path.getCompilationUnit() ); } else { // TreePath is only applicable to a source file; // if fqn is not a source file, there is no compilation unit available return new Pair<>( typeElement, null ); } }
return; TreePath path = JavacTrees.instance(context).getPath(taskEvent.getTypeElement()); if (path == null) { path = new TreePath(taskEvent.getCompilationUnit());