@Override public void run( CompilationController controller ) throws Exception { controller.toPhase(JavaSource.Phase.RESOLVED); String typeName = controller.getFileObject().getName(); List<? extends TypeElement> topLevelElements = controller.getTopLevelElements(); for (TypeElement typeElement : topLevelElements) { if ( kind == typeElement.getKind() && typeName.contentEquals( typeElement.getSimpleName())) { result.add(ElementHandle.create( typeElement)); return; } } } },true);
public boolean isInjectionTarget(CompilationController controller, TypeElement typeElement) { if (controller == null || typeElement==null) { throw new NullPointerException("Passed null to WebInjectionTargetQueryImplementation.isInjectionTarget(CompilationController, TypeElement)"); // NOI18N } boolean ret = false; WebModule webModule = WebModule.getWebModule(controller.getFileObject()); if (webModule != null && !Profile.J2EE_13.equals(webModule.getJ2eeProfile()) && // NOI18N !Profile.J2EE_14.equals(webModule.getJ2eeProfile())) { // NOI18N ret = SourceUtils.isSubtype(controller, typeElement, "javax.servlet.Servlet"); // NOI18N } return ret; }
public boolean isInjectionTarget(CompilationController controller, TypeElement typeElement) { Car apiCar = Car.getCar(controller.getFileObject()); if (apiCar != null && !Profile.J2EE_13.equals(apiCar.getJ2eeProfile()) && !Profile.J2EE_14.equals(apiCar.getJ2eeProfile())) { return SourceUtils.isMainClass(typeElement.getQualifiedName().toString(), controller.getClasspathInfo()); } return false; }
@Override public boolean isInjectionTarget(CompilationController controller, TypeElement typeElement) { if (controller == null || typeElement==null) { throw new NullPointerException("Passed null to EEInjectiontargetQueryImplementation.isInjectionTarget(CompilationController, TypeElement)"); // NOI18N } FileObject fo = controller.getFileObject(); Project project = FileOwnerQuery.getOwner(fo); J2eeProjectCapabilities j2eeProjectCapabilities = J2eeProjectCapabilities.forProject(project); if (j2eeProjectCapabilities == null) { return false; } boolean ejb31 = j2eeProjectCapabilities.isEjb31Supported() || j2eeProjectCapabilities.isEjb31LiteSupported();//it's foe ee6 only or common annotations 1.1 if (ejb31 && !(ElementKind.INTERFACE==typeElement.getKind())) { List<? extends AnnotationMirror> annotations = typeElement.getAnnotationMirrors(); boolean found = false; for (AnnotationMirror m : annotations) { Name qualifiedName = ((TypeElement)m.getAnnotationType().asElement()).getQualifiedName(); if (qualifiedName.contentEquals("javax.annotation.ManagedBean")) { //NOI18N found = true; break; } } if (found) return true; } return false; }
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); } }
public void run(CompilationController controller) throws Exception { controller.toPhase(Phase.RESOLVED); fo = controller.getFileObject(); TypeElement typeElement = null; List<? extends TypeElement> topLevelElements = controller.getTopLevelElements();
Parameters.notNull("controller", controller); // NOI18N FileObject mainFileObject = controller.getFileObject(); if (mainFileObject == null) { throw new IllegalStateException();
@Override public void run(CompilationController controller) throws Exception { controller.toPhase(Phase.RESOLVED); fileObject = controller.getFileObject(); TypeElement typeElement = null; List<? extends TypeElement> topLevelElements = controller.getTopLevelElements();
public void run(CompilationController controller) throws Exception { controller.toPhase(Phase.RESOLVED); fileObject = controller.getFileObject(); TypeElement typeElement = null; List<? extends TypeElement> topLevelElements = controller.getTopLevelElements();
private StyledDocument getDocument(CompilationController ci) { // Do NOT use ci.getDocument(), since it returns null when the document is not loaded yet! FileObject file = ci.getFileObject(); if (file == null || !file.isValid()) { return null; } try { DataObject od = DataObject.find(file); EditorCookie ec = od.getLookup().lookup(EditorCookie.class); if (ec != null) { return ec.openDocument(); } else { return null; } } catch (DataObjectNotFoundException e) { return null; } catch (IOException ioex) { return null; } }
public static ClassTree getTopLevelClassTree(CompilationController controller) { String className = controller.getFileObject().getName(); CompilationUnitTree cu = controller.getCompilationUnit(); if (cu != null) { List<? extends Tree> decls = cu.getTypeDecls(); for (Tree decl : decls) { if (!TreeUtilities.CLASS_TREE_KINDS.contains(decl.getKind())) { continue; } ClassTree classTree = (ClassTree) decl; if (classTree.getSimpleName().contentEquals(className) && classTree.getModifiers().getFlags().contains(Modifier.PUBLIC)) { return classTree; } } } return null; }
public void run(CompilationController cc) throws Exception { if (cancel.get()) return; HintsSettings.setPreferencesOverride(preferencesOverlay); DataObject d = DataObject.find(cc.getFileObject()); EditorCookie ec = d.getLookup().lookup(EditorCookie.class); Document doc = ec.openDocument(); try { handle.progress(FileUtil.getFileDisplayName(cc.getFileObject())); if (cc.toPhase(JavaSource.Phase.RESOLVED).compareTo(JavaSource.Phase.RESOLVED) < 0) { return; } handle.progress(f.incrementAndGet()); eds.addAll(new HintsTask().computeHints(cc)); } finally { HintsSettings.setPreferencesOverride(null); } } }, true);
result.add( new InterceptorGenerator( contextElement.getSimpleName().toString(), controller.getFileObject()) );
Parameters.notNull("typeElement", typeElement); Project project = FileOwnerQuery.getOwner( controller.getFileObject() ); if ( project == null ){ return false;
if (ci.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {//TODO: ELEMENTS_RESOLVED may be sufficient 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());
"Unable to resolve "+ci.getFileObject()+" to phase "+Phase.RESOLVED+", current phase = "+ci.getPhase()+ "\nDiagnostics = "+ci.getDiagnostics()+ "\nFree memory = "+Runtime.getRuntime().freeMemory()); } else { ErrorManager.getDefault().log(ErrorManager.WARNING, "No enclosing class for "+ci.getFileObject()+", offset = "+offset);
if (ci.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {//TODO: ELEMENTS_RESOLVED may be sufficient 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());
"Unable to resolve "+ci.getFileObject()+" to phase "+Phase.RESOLVED+", current phase = "+ci.getPhase()+ "\nDiagnostics = "+ci.getDiagnostics()+ "\nFree memory = "+Runtime.getRuntime().freeMemory());
private MethodArgument[] computeMethodArguments(CompilationController ci, int methodLineNumber, int offset) throws IOException { MethodArgument args[]; if (ci.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 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 null; } Scope scope = ci.getTreeUtilities().scopeFor(offset); Element clazz = scope.getEnclosingClass(); if (clazz == null) { return null; } Tree methodTree = ci.getTrees().getTree(clazz); CompilationUnitTree cu = ci.getCompilationUnit(); MethodArgumentsScanner scanner = new MethodArgumentsScanner(methodLineNumber, cu, ci.getTrees().getSourcePositions(), false, new OperationCreationDelegateImpl()); args = methodTree.accept(scanner, null); args = scanner.getArguments(); return args; }
private MethodArgument[] computeMethodArguments(CompilationController ci, Operation operation) throws IOException { MethodArgument args[]; if (ci.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 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 null; } int offset = operation.getMethodEndPosition().getOffset(); Scope scope = ci.getTreeUtilities().scopeFor(offset); Element method = scope.getEnclosingMethod(); if (method == null) { return null; } Tree methodTree = ci.getTrees().getTree(method); CompilationUnitTree cu = ci.getCompilationUnit(); MethodArgumentsScanner scanner = new MethodArgumentsScanner(offset, cu, ci.getTrees().getSourcePositions(), true, new OperationCreationDelegateImpl()); args = methodTree.accept(scanner, null); args = scanner.getArguments(); return args; }