public void run(CompilationController parameter) throws IOException { myInfo = parameter; parameter.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED); scan(parameter.getCompilationUnit(), null); }
@Override public void run(CompilationController parameter) throws IOException { this.info = parameter; parameter.toPhase(Phase.RESOLVED); this.scan(parameter.getCompilationUnit(), null); } }
public void run(CompilationController co) throws Exception { co.toPhase(JavaSource.Phase.RESOLVED); CompilationUnitTree cut = co.getCompilationUnit(); List<? extends Tree> typeDecls = cut.getTypeDecls(); if (!typeDecls.isEmpty()){ treePathHandles.add(TreePathHandle.create(TreePath.getPath(cut, typeDecls.get(0)), co)); } } }, false);
public FileObject getFileObject() { try { return URLMapper.findFileObject(getController().getCompilationUnit().getSourceFile().toUri().toURL()); } catch (MalformedURLException ex) { Exceptions.printStackTrace(ex); } return null; }
@Override Integer run(CompilationController controller, MethodTree methodTree, ExecutableElement methodElement) { return (int) controller.getTrees().getSourcePositions().getEndPosition( controller.getCompilationUnit(), methodTree); } }.execute();
@Override Integer run(CompilationController controller, MethodTree methodTree, ExecutableElement methodElement) { return (int) controller.getTrees().getSourcePositions().getEndPosition( controller.getCompilationUnit(), methodTree); } }.execute();
@Override Integer run(CompilationController controller, ClassTree classTree, TypeElement classElement) { return (int) controller.getTrees().getSourcePositions().getEndPosition( controller.getCompilationUnit(), classTree); } }.execute();
public void run(CompilationController co) throws Exception { co.toPhase(JavaSource.Phase.RESOLVED); CompilationUnitTree cut = co.getCompilationUnit(); if (cut.getTypeDecls().isEmpty()) { return; } result[0] = TreePathHandle.create(TreePath.getPath(cut, cut.getTypeDecls().get(0)), co); } }, true);
public void run(CompilationController co) throws Exception { co.toPhase(JavaSource.Phase.RESOLVED); CompilationUnitTree cut = co.getCompilationUnit(); if(!cut.getTypeDecls().isEmpty()){ treePathHandle = TreePathHandle.create(TreePath.getPath(cut, cut.getTypeDecls().get(0)), co); } } }, false);
public void run(CompilationController co) throws Exception { co.toPhase(JavaSource.Phase.RESOLVED); CompilationUnitTree cut = co.getCompilationUnit(); if (cut.getTypeDecls().isEmpty()){ return; } result[0] = TreePathHandle.create(TreePath.getPath(cut, cut.getTypeDecls().get(0)), co); }
@Override Integer run(CompilationController controller, MethodTree methodTree, ExecutableElement methodElement) { return (int) controller.getTrees().getSourcePositions().getStartPosition( controller.getCompilationUnit(), methodTree); } }.execute();
private void computeImports(CompilationController ci, List<String> imports) throws IOException { if (ci.toPhase(Phase.PARSED).compareTo(Phase.PARSED) < 0) { ErrorManager.getDefault().log(ErrorManager.WARNING, "Unable to resolve "+ci.getFileObject()+" to phase "+Phase.RESOLVED+", current phase = "+ci.getPhase()+ "\nDiagnostics = "+ci.getDiagnostics()+ "\nFree memory = "+Runtime.getRuntime().freeMemory()); return; } List importDecl = ci.getCompilationUnit().getImports(); int i = 0; for (Iterator it = importDecl.iterator(); it.hasNext(); i++) { ImportTree itree = (ImportTree) it.next(); String importStr = itree.getQualifiedIdentifier().toString(); imports.add(importStr); } }
static boolean isViewClass(ClassTree classT, CompilationController controller) { Trees trees = controller.getTrees(); TreePath classTPath = trees.getPath(controller.getCompilationUnit(), classT); TypeElement classEl = (TypeElement) trees.getElement(classTPath); TypeElement appEl = controller.getElements().getTypeElement("org.jdesktop.application.View"); // NOI18N Types types = controller.getTypes(); TypeMirror tm1 = types.erasure(classEl.asType()); TypeMirror tm2 = types.erasure(appEl.asType()); return types.isSubtype(tm1, tm2); }
/** * A convenience method for converting a <code>ClassTree</code> to the * corresponding <code>TypeElement</code>, if any. */ static TypeElement classTree2TypeElement(CompilationController controller, ClassTree classTree) { assert controller != null; assert classTree != null; TreePath classTreePath = controller.getTrees().getPath(controller.getCompilationUnit(), classTree); return (TypeElement)controller.getTrees().getElement(classTreePath); }
private static TypeElement getTypeElement(CompilationController ci, String binaryName, String[] classExcludeNames) { ClassScanner cs = new ClassScanner(ci.getTrees(), ci.getElements(), binaryName, classExcludeNames); TypeElement te = cs.scan(ci.getCompilationUnit(), null); if (te != null) { return te; } else { return null; } }
public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.ELEMENTS_RESOLVED); Trees trees = compilationController.getTrees(); CompilationUnitTree compilationUnitTree = compilationController.getCompilationUnit(); List<?extends Tree> typeDecls = compilationUnitTree.getTypeDecls(); for (Tree tree : typeDecls) { Element element = trees.getElement(trees.getPath(compilationUnitTree, tree)); if (element != null && element.getKind() == ElementKind.CLASS && element.getSimpleName().contentEquals(fo.getName())){ long pos = trees.getSourcePositions().getStartPosition(compilationUnitTree, tree); line[0] = compilationUnitTree.getLineMap().getLineNumber(pos); break; } } } }, true);
@Override public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.ELEMENTS_RESOLVED); Trees trees = compilationController.getTrees(); CompilationUnitTree compilationUnitTree = compilationController.getCompilationUnit(); List<? extends Tree> typeDecls = compilationUnitTree.getTypeDecls(); for (Tree tree : typeDecls) { Element element = trees.getElement(trees.getPath(compilationUnitTree, tree)); if (element != null && element.getKind() == ElementKind.CLASS && element.getSimpleName().contentEquals(fo.getName())) { long pos = trees.getSourcePositions().getStartPosition(compilationUnitTree, tree); line[0] = compilationUnitTree.getLineMap().getLineNumber(pos); break; } } } }, true);
@Override public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.ELEMENTS_RESOLVED); Trees trees = compilationController.getTrees(); CompilationUnitTree compilationUnitTree = compilationController.getCompilationUnit(); List<? extends Tree> typeDecls = compilationUnitTree.getTypeDecls(); for (Tree tree : typeDecls) { Element element = trees.getElement(trees.getPath(compilationUnitTree, tree)); if (element != null && element.getKind() == ElementKind.CLASS && element.getSimpleName().contentEquals(fo.getName())) { long pos = trees.getSourcePositions().getStartPosition(compilationUnitTree, tree); line[0] = compilationUnitTree.getLineMap().getLineNumber(pos); break; } } } }, true);
@Override public void run(CompilationController controller) throws Exception { controller.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED); Element element = handles[0].resolve(controller); Trees trees = controller.getTrees(); Tree tree = trees.getTree(element); SourcePositions sourcePositions = trees.getSourcePositions(); offset[0] = (int) sourcePositions.getStartPosition(controller.getCompilationUnit(), tree); } }, true);
@Override public void run(CompilationController controller) throws Exception { controller.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED); Element element = handles[0].resolve(controller); Trees trees = controller.getTrees(); Tree tree = trees.getTree(element); SourcePositions sourcePositions = trees.getSourcePositions(); offset[0] = (int) sourcePositions.getStartPosition(controller.getCompilationUnit(), tree); } }, true);