public String[] getSourceRoots () { String[] fs1 = cp1.getSourceRoots (); String[] fs2 = cp2.getSourceRoots (); String[] fs = new String [fs1.length + fs2.length]; System.arraycopy (fs1, 0, fs, 0, fs1.length); System.arraycopy (fs2, 0, fs, fs1.length, fs2.length); return fs; }
public void addPropertyChangeListener (PropertyChangeListener l) { cp1.addPropertyChangeListener (l); cp2.addPropertyChangeListener (l); }
private void initSourcePaths () { Properties properties = Properties.getDefault (). getProperties ("debugger").getProperties ("sources"); Set originalSourceRoots = new HashSet (Arrays.asList ( sourcePathProvider.getOriginalSourceRoots () )); Set sourceRoots = new HashSet (Arrays.asList ( sourcePathProvider.getSourceRoots () )); Iterator enabledSourceRoots = properties.getProperties ("source_roots"). getCollection ("enabled", Collections.EMPTY_SET).iterator (); while (enabledSourceRoots.hasNext ()) { String root = (String) enabledSourceRoots.next (); if (originalSourceRoots.contains (root)) sourceRoots.add (root); } Iterator disabledSourceRoots = properties.getProperties ("source_roots"). getCollection ("disabled", Collections.EMPTY_SET).iterator (); while (disabledSourceRoots.hasNext ()) { String root = (String) disabledSourceRoots.next (); sourceRoots.remove (root); } String[] ss = new String [sourceRoots.size ()]; sourcePathProvider.setSourceRoots ((String[]) sourceRoots.toArray (ss)); }
public String[] getOriginalSourceRoots () { String[] fs1 = cp1.getOriginalSourceRoots (); String[] fs2 = cp2.getOriginalSourceRoots (); String[] fs = new String [fs1.length + fs2.length]; System.arraycopy (fs1, 0, fs, 0, fs1.length); System.arraycopy (fs2, 0, fs, fs1.length, fs2.length); return fs; }
public void removePropertyChangeListener (PropertyChangeListener l) { cp1.removePropertyChangeListener (l); cp2.removePropertyChangeListener (l); } }
public String getRelativePath ( String url, char directorySeparator, boolean includeExtension ) { String p1 = cp1.getRelativePath ( url, directorySeparator, includeExtension ); if (p1 != null) return p1; return cp2.getRelativePath ( url, directorySeparator, includeExtension ); }
/** * Returns set of original source roots. * * @return set of original source roots */ public String[] getOriginalSourceRoots () { return getContext ().getOriginalSourceRoots (); }
/** * Removes property change listener. * * @param l removed listener. */ public void removePropertyChangeListener ( PropertyChangeListener l ) { getContext ().removePropertyChangeListener (l); }
/** * Returns relative path for given url. * * @param url a url of resource file * @param directorySeparator a directory separator character * @param includeExtension whether the file extension should be included * in the result * * @return relative path */ public String getRelativePath ( String url, char directorySeparator, boolean includeExtension ) { return getContext ().getRelativePath (url, directorySeparator, includeExtension); }
path = path.substring(1); return provider.getURL(path, global);
/** * Returns array of source roots. */ public String[] getSourceRoots () { return getContext ().getSourceRoots (); }
private JavaSource getJavaSource(SourcePathProvider sp) { String[] roots = sp.getOriginalSourceRoots(); List<FileObject> sourcePathFiles = new ArrayList<FileObject>(); for (String root : roots) { FileObject fo = FileUtil.toFileObject (new java.io.File(root)); if (fo != null && FileUtil.isArchiveFile (fo)) { fo = FileUtil.getArchiveRoot (fo); } sourcePathFiles.add(fo); } ClassPath bootPath = ClassPathSupport.createClassPath(new FileObject[] {}); ClassPath classPath = ClassPathSupport.createClassPath(new FileObject[] {}); ClassPath sourcePath = ClassPathSupport.createClassPath(sourcePathFiles.toArray(new FileObject[] {})); return JavaSource.create(ClasspathInfo.create(bootPath, classPath, sourcePath), new FileObject[] {}); }
/** * Adds property change listener. * * @param l new listener. */ public void addPropertyChangeListener (PropertyChangeListener l) { getContext ().addPropertyChangeListener (l); }
private static FileObject getFileObject(String classRelPath) { DebuggerEngine engine = DebuggerManager.getDebuggerManager ().getCurrentEngine(); if (engine != null) { SourcePathProvider sp = engine.lookupFirst(null, SourcePathProvider.class); if (sp != null) { String url = sp.getURL(classRelPath, false); if (url == null) { url = sp.getURL(classRelPath, true); } if (url != null) { try { FileObject fo = URLMapper.findFileObject(new URL(url)); if (fo != null) { return fo; } } catch (MalformedURLException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } } } } classRelPath = SourcePathProviderImpl.normalize(classRelPath); FileObject fo = GlobalPathRegistry.getDefault().findResource(classRelPath); return fo; }
private Set<FileObject> computeModuleRoots() { Set<FileObject> projectDirectories = new LinkedHashSet<>(); String[] sourceRoots = sourcePath.getSourceRoots(); for (String src : sourceRoots) { FileObject fo = getFileObject(src); if (fo == null) { continue; } Project p = getProject(fo); if (p == null) { continue; } projectDirectories.add(p.getProjectDirectory()); } return projectDirectories; }
@Override public String getURL(String relativePath, boolean global) { if (relativePath.startsWith(pathPrefix)) { relativePath = relativePath.substring(pathPrefix.length()); synchronized (rootDirsLock) { if (rootDirs == null) { sourcePath = getSourcePathProvider(); sourcePath.addPropertyChangeListener(new SourcePathListener()); rootDirs = computeModuleRoots(); } for (FileObject root : rootDirs) { FileObject fo = root.getFileObject(relativePath); if (fo != null) { return fo.toURL().toExternalForm(); } } } } return null; }
private static FileObject getFileObject(String classRelPath) { DebuggerEngine engine = DebuggerManager.getDebuggerManager ().getCurrentEngine(); if (engine != null) { SourcePathProvider sp = engine.lookupFirst(null, SourcePathProvider.class); if (sp != null) { String url = sp.getURL(classRelPath, false); if (url == null) { url = sp.getURL(classRelPath, true); } if (url != null) { try { FileObject fo = URLMapper.findFileObject(new URL(url)); if (fo != null) { return fo; } } catch (MalformedURLException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } } } } classRelPath = SourcePathProviderImpl.normalize(classRelPath); FileObject fo = GlobalPathRegistry.getDefault().findResource(classRelPath); return fo; }
private Set<FileObject> getSourceRootsFO(SourcePathProvider sp) { if (sp instanceof SourcePathProviderImpl) { return ((SourcePathProviderImpl) sp).getSourceRootsFO(); } else { String[] sourceRoots = sp.getSourceRoots(); Set<FileObject> fos = new HashSet<FileObject>(); for (String root : sourceRoots) { FileObject fo; int jarIndex = root.indexOf("!/"); if (jarIndex > 0) { fo = FileUtil.toFileObject(new java.io.File(root.substring(0, jarIndex))); fo = fo.getFileObject(root.substring(jarIndex + 2)); } else { fo = FileUtil.toFileObject(new java.io.File(root)); } if (fo != null) { fos.add(fo); } } return fos; } }
private static FileObject getFileObject(String classRelPath) { DebuggerEngine engine = DebuggerManager.getDebuggerManager ().getCurrentEngine(); if (engine != null) { SourcePathProvider sp = engine.lookupFirst(null, SourcePathProvider.class); if (sp != null) { String url = sp.getURL(classRelPath, false); if (url == null) { url = sp.getURL(classRelPath, true); } if (url != null) { try { FileObject fo = URLMapper.findFileObject(new URL(url)); if (fo != null) { return fo; } } catch (MalformedURLException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } } } } classRelPath = SourcePathProviderImpl.normalize(classRelPath); FileObject fo = GlobalPathRegistry.getDefault().findResource(classRelPath); return fo; }