public static ClassPath findProjectIncludePath(FileObject file) { PROJECT_INCLUDES_LOCK.readLock().lock(); try { for (ClassPath classPath : PROJECT_INCLUDES) { if (classPath.contains(file)) { return classPath; } } } finally { PROJECT_INCLUDES_LOCK.readLock().unlock(); } return null; }
@Override public ClassPath findClassPath(FileObject file, String type) { if (MakeProjectPaths.SOURCES.equals(type)) { PROJECT_LOCK.readLock().lock(); try { for (ClassPath spc : PROJECT_CPS) { boolean accept = false; if (spc.contains(file)) { Project owner = FileOwnerQuery.getOwner(file); if (owner instanceof MakeProject) { accept = true; } } if (accept) { LOG.log(Level.FINE, "findClassPath({0}, {1}) -> {2} from {3}", new Object[] {file, type, spc, MakeProjectClassPathProvider.class}); return spc; } } } finally { PROJECT_LOCK.readLock().unlock(); } } LOG.log(Level.FINE, "findClassPath({0}, {1}) -> null", new Object[] {file, type}); return null; }
private static FileType getFileTypeFromIncludeClassPath(FileObject file) { // now, check include path of opened projects ClassPath classPath = IncludePathClassPathProvider.findProjectIncludePath(file); if (classPath != null && classPath.contains(file)) { // internal? if (org.netbeans.modules.php.project.util.PhpProjectUtils.isInternalFile(file)) { return FileType.INTERNAL; } // include return FileType.INCLUDE; } return null; }
private static void addRecursivelly(FileObject top, List<FileObject> into, Set<String> sourceIds, ClassPath sourceCP, SourceGroup sg, AtomicBoolean cancel) { List<FileObject> todo = new LinkedList<FileObject>(); Iterator<String> sIDIter = sourceIds.iterator(); while (sourceCP == null && sIDIter.hasNext()) { if (cancel.get()) return; sourceCP = ClassPath.getClassPath(top, sIDIter.next()); } todo.add(top); while (!todo.isEmpty()) { if (cancel.get()) return; FileObject current = todo.remove(0); if (!VisibilityQuery.getDefault().isVisible(current)) continue; if (sourceCP != null && !sourceCP.contains(current)) continue; if (sg != null && !sg.contains(current)) continue; if (current.isData()) { into.add(current); } todo.addAll(Arrays.asList(current.getChildren())); } }
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); } } } }
/** * Check if a project has an root reference to the named root qualified by the type parameter. * @param project Target project * @param rootFile file object of the root * @param type Determines whether the root is to be referenced from the design-time classpath or deploy * time classpath * @return Returns true if the root is already referenced by the project, false otherwise */ public static boolean hasRootReference(Project project, URL rootFile, String type) { FileObject obj = URLMapper.findFileObject(rootFile); if (obj == null) { return false; } // XXX NetBeans API not finished yet type = ClassPath.COMPILE; ClassPath cp = ClassPath.getClassPath(getSourceRoot(project), type); return cp.contains(obj); }
/** * Check if a project has a library reference to the named library qualified by the type parameter. * @param project Target project * @param library Library object * @param type Determines whether the library is to be referenced from the design-time classpath or deploy * time classpath * @return Returns true if the library is already referenced by the project, false otherwise */ public static boolean hasLibraryReference(Project project, Library library, String type) { List lst = library.getContent("classpath"); if (lst.isEmpty()) { return false; } URL url = (URL) lst.get(0); FileObject obj = URLMapper.findFileObject(url); if (obj == null) { return false; } // XXX NetBeans API not finished yet type = ClassPath.COMPILE; ClassPath cp = ClassPath.getClassPath(getSourceRoot(project), type); if (cp == null) { return false; } return cp.contains(obj); }
public String getSourceLevel(org.openide.filesystems.FileObject javaFile) { try { } catch (Exception e) {} ScalaPlatform[] platforms = ScalaPlatformManager.getDefault().getInstalledPlatforms (); for (int i=0; i< platforms.length; i++) { if (J2SEPlatformImpl.PLATFORM_J2SE.equalsIgnoreCase(platforms[i].getSpecification().getName()) && platforms[i].getSourceFolders().contains(javaFile)) { //NOI18N return platforms[i].getSpecification().getVersion().toString(); } } return null; }
public String getSourceLevel(org.openide.filesystems.FileObject javaFile) { try { } catch (Exception e) {} JavaPlatform[] platforms = JavaPlatformManager.getDefault().getInstalledPlatforms (); for (JavaPlatform platform : platforms ) { if (CDCPlatform.PLATFORM_CDC.equalsIgnoreCase(platform.getSpecification().getName()) && platform.getSourceFolders().contains(javaFile)) { //NOI18N return platform.getSpecification().getVersion().toString(); } } return null; }
private void packageRename(FileObject originalPkgFile) { FormEditorSupport fes = getFormEditorSupport(); if (fes.isOpened()) { fes.closeFormEditor(); } String oldName = refInfo.getOldName(originalPkgFile); String newName = refInfo.getNewName(); if (refInfo.getChangeType() == RefactoringInfo.ChangeType.FOLDER_RENAME) { // determine full package name for renamed folder ClassPath cp = ClassPath.getClassPath(originalPkgFile, ClassPath.SOURCE); FileObject parent = originalPkgFile.getParent(); if (cp != null && cp.contains(parent)) { String parentPkgName = cp.getResourceName(parent, '.', false); if (parentPkgName != null && parentPkgName.length() > 0) { oldName = parentPkgName + "." + oldName; // NOI18N newName = parentPkgName + "." + newName; // NOI18N } } } if (replaceClassOrPkgName(new String[] { oldName }, new String[] { newName }, true) && !isGuardedCodeChanging()) { // some package references in resource were changed in the form file // (not class names since no change in guarded code came from java // refactoring) and because no component has changed we can load the // form and regenerate to get the new resource names into code updateForm(true); } }
if (js != null) { final ClassPath scp = js.getClasspathInfo().getClassPath(PathKind.SOURCE); if (scp != null && scp.contains(file)) { js.runUserActionTask(new Task<CompilationController>() { @Override
listener = WeakListeners.create(FileChangeListener.class, MainClassUpdater.this, current); if (current != null && sourcePath.contains(current)) { current.addFileChangeListener(listener);