@Override public void run(CompilationController controller) throws Exception { controller.toPhase( Phase.ELEMENTS_RESOLVED ); for( String servletClass : servletClasses){ TypeElement typeElem = controller.getElements(). getTypeElement( servletClass); if ( typeElem == null ){ continue; } ElementHandle<TypeElement> handle = ElementHandle.create( typeElem ); FileObject fileObject = SourceUtils.getFile( handle, controller.getClasspathInfo()); if ( fileObject != null && !Boolean.TRUE.equals( fileObject.getAttribute(IS_SERVLET_FILE))) { fileObject.setAttribute(IS_SERVLET_FILE, Boolean.TRUE); } } } }, true);
/** Creates new form JFXApplicationClassChooser */ public JFXApplicationClassChooser(final @NonNull Project p, final @NonNull PropertyEvaluator pe) { this.evaluator = pe; this.project = p; this.isFXinSwing = JFXProjectUtils.isFXinSwingProject(p); initComponents(); if(!SourceUtils.isScanInProgress()) labelScanning.setVisible(false); listAppClasses.setCellRenderer(new AppClassRenderer()); initClassesView(); initClassesModel(); }
/** * Returns the dependent source path roots for given source root. * It returns all the open project source roots which have either * direct or transitive dependency on the given source root. * @param root to find the dependent roots for * @return {@link Set} of {@link URL}s containing at least the * incoming root, never returns null. * @since 0.10 */ @NonNull @org.netbeans.api.annotations.common.SuppressWarnings(value = {"DMI_COLLECTION_OF_URLS"}, justification="URLs have never host part") public static Set<URL> getDependentRoots (@NonNull final URL root) { return getDependentRoots(root, true); }
public FileObject getFileObject() { FileObject file = SourceUtils.getFile(el, cpInfo); if (fo.getNameExt().endsWith(FileObjects.SIG)) { StringTokenizer tk = new StringTokenizer(pkgName, "/"); //NOI18N for (int i = 0; fo != null && i <= tk.countTokens(); i++) { fo = fo.getParent(); URL url = fo.getURL();
FileObject file = SourceUtils.getFile(ElementHandle.create(typeElement), ClasspathInfo.create(getModel().getModelUnit().getBootPath() , ClassPath.EMPTY, getModel().getModelUnit().getSourcePath())); String ext = archiveFile.getExt(); if ( "war".equalsIgnoreCase( ext)){ // NOI18N return root.getFileObject("WEB-INF/beans.xml") == null; // NOI18N
FileObject file = SourceUtils.getFile(handle, js.getClasspathInfo()); if (file != null) { return file; } else { String qualifiedName = handle.getQualifiedName(); String relPath = qualifiedName.replace('.', '/') + ".class"; //NOI18N ClassPath classPath = js.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE); for (ClassPath.Entry entry : classPath.entries()) { FileObject[] roots; file = root.getFileObject(relPath); if (file != null) { return file;
@Override @CheckForNull protected URL map(@NonNull final FileObject fo) { final String relative = FileObjects.convertFolder2Package( FileObjects.stripExtension(FileObjects.getRelativePath(cacheRoot, FileUtil.toFile(fo))), File.separatorChar); final FileObject sourceFile = SourceUtils.getFile( ElementHandleAccessor.getInstance().create(ElementKind.CLASS, relative), resolveCps); return sourceFile == null ? null : sourceFile.toURL(); } }
/** * Returns set of names of main classes in the given project * * @param project * @return set of class names */ public static Set<String> getMainClassNames(@NonNull Project project) { final Set<String> mainClassNames = new HashSet<String>(); FileObject sourceRoots[] = getSourceRoots(project).toArray(new FileObject[0]); for (ElementHandle<TypeElement> elemHandle : SourceUtils.getMainClasses(sourceRoots)) { mainClassNames.add(elemHandle.getQualifiedName()); } return mainClassNames; }
private Boolean performSync(@NonNull final Context ctx) throws IOException { final URL sourceRoot = ctx.getSourceRoot(); final File targetFolder = ctx.getTarget(); SourceUtils.waitScanFinished(); } catch (InterruptedException e) { final FileObject sr = sources[0][i]; if (!cosActive) { URL srURL = sr.toURL(); File index = JavaIndex.getClassFolder(srURL, true);
private Boolean performClean(@NonNull final Context ctx) throws IOException { final File targetFolder = ctx.getTarget(); if (targetFolder == null) { return null; } File tagFile = new File(targetFolder, TAG_FILE_NAME); if (!tagFile.exists()) { return null; } try { SourceUtils.waitScanFinished(); } catch (InterruptedException e) { //Not Important LOG.log(Level.FINE, null, e); return false; } delete(targetFolder, false); delete(tagFile, true); return null; }
public static DeclarationLocation getDeclarationLocation(final ClasspathInfo cpInfo, final Element el) { ElementHandle<Element> handle = ElementHandle.create(el); FileObject fo = SourceUtils.getFile(handle, cpInfo); if (fo != null) { return getDeclarationLocation(fo, handle); } return DeclarationLocation.NONE; }
public void run(CompilationController c) throws Exception { TypeElement te = c.getElements().getTypeElement(mainClassName); if (te != null) { synchronized (MainClassUpdater.this) { current = SourceUtils.getFile(te, cpInfo); listener = WeakListeners.create(FileChangeListener.class, MainClassUpdater.this, current); if (current != null && sourcePath.contains(current)) { current.addFileChangeListener(listener); } } } }
private static FileObject getFileObjectFromClassName(Project p, String qualifiedClassName) throws IOException { FileObject root = MiscUtilities.findSourceRoot(p); ClasspathInfo cpInfo = ClasspathInfo.create(root); ClassIndex ci = cpInfo.getClassIndex(); int beginIndex = qualifiedClassName.lastIndexOf('.')+1; String simple = qualifiedClassName.substring(beginIndex); Set<ElementHandle<TypeElement>> handles = ci.getDeclaredTypes( simple, ClassIndex.NameKind.SIMPLE_NAME, Collections.singleton(ClassIndex.SearchScope.SOURCE)); if ( handles == null ){ return null; } for (ElementHandle<TypeElement> handle : handles) { if (qualifiedClassName.equals(handle.getQualifiedName())) { return SourceUtils.getFile(handle, cpInfo); } } return null; }
private List<Fix> createQualifierFix( CompilationInfo compilationInfo, Element annotation, Element classElement ) { PackageElement packageElement = compilationInfo.getElements() .getPackageOf(classElement); FileObject targetFile = SourceUtils.getFile( ElementHandle.create(classElement), compilationInfo.getClasspathInfo()); return Collections.<Fix> singletonList(new CreateQualifierFix( compilationInfo, annotation.getSimpleName().toString(), packageElement.getQualifiedName().toString(), targetFile)); }
if (element != null) { elementFound.set(true); ElementHandle el = ElementHandle.create(element); FileObject fo = SourceUtils.getFile(el, cpi); if (fo == null) { StatusDisplayer.getDefault().setStatusText(Bundle.lbl_managed_bean_not_found(fqn)); Toolkit.getDefaultToolkit().beep(); } else if (!SourceUtils.isScanInProgress()) { StatusDisplayer.getDefault().setStatusText(Bundle.lbl_managed_bean_not_found(fqn)); Toolkit.getDefaultToolkit().beep();
public static Doc findJavadoc(CompilationInfo javac, Document doc, int offset) { TokenSequence<JavaTokenId> ts = SourceUtils.getJavaTokenSequence(javac.getTokenHierarchy(), offset); if (ts == null || !movedToJavadocToken(ts, offset)) { return null; TreePath tp = javac.getTreeUtilities().pathFor(offsetBehindJavadoc); Tree leaf = tp.getLeaf(); Kind kind = leaf.getKind(); SourcePositions positions = javac.getTrees().getSourcePositions();
if (e == null || javac.getElementUtilities().isSynthetic(e)) return null; tree = javac.getTrees().getTree(e); if (tree == null) return null; int elementStartOffset = (int) javac.getTrees().getSourcePositions().getStartPosition(javac.getCompilationUnit(), tree); TokenSequence<JavaTokenId> s = SourceUtils.getJavaTokenSequence(javac.getTokenHierarchy(), elementStartOffset); if (s == null) { return null;
@NbBundle.Messages("title.go.to.class.action=Searching Managed Bean") private void findJavaClass(final String fqn, javax.swing.text.Document doc) { FileObject fo = NbEditorUtilities.getFileObject(doc); if (fo != null) { WebModule wm = WebModule.getWebModule(fo); if (wm != null) { ClasspathInfo cpi = ClasspathInfo.create(wm.getDocumentBase()); ClassSeekerTask classSeekerTask = new ClassSeekerTask(cpi, fqn); runClassSeekerUserTask(classSeekerTask); if (!classSeekerTask.wasElementFound() && SourceUtils.isScanInProgress()) { ScanDialog.runWhenScanFinished(classSeekerTask, Bundle.title_go_to_class_action()); } } } }
@Override public void contentsChanged(ListDataEvent e) { setScanningLabelVisible(SourceUtils.isScanInProgress()); } });