Package org.netbeans.api.java.classpath

Examples of org.netbeans.api.java.classpath.ClassPath



    @Override
    public ClassPath getBootstrapLibraries() {
        synchronized (this) {
            ClassPath cp = (bootstrap == null ? null : bootstrap.get());
            if (cp != null)
                return cp;
            String pathSpec = getSystemProperties().get(SYSPROP_BOOT_CLASSPATH);
            String extPathSpec = Util.getExtensions((String)getSystemProperties().get(SYSPROP_JAVA_EXT_PATH));
            if (extPathSpec != null) {
View Full Code Here


     * @return  ClassPath that represents contents of system property java.class.path.
     */
    @Override
    public ClassPath getStandardLibraries() {
        synchronized (this) {
            ClassPath cp = (standardLibs == null ? null : standardLibs.get());
            if (cp != null)
                return cp;
            String pathSpec = getSystemProperties().get(SYSPROP_SCALA_CLASS_PATH);
            cp = Util.createClassPath (pathSpec);
            standardLibs = new WeakReference<ClassPath>(cp);
View Full Code Here

        public void readSettings(WizardDescriptor settings) {          
            this.wiz = settings;
            ScalaPlatform platform = this.iterator.getPlatform();
            String srcPath = null;
            String jdocPath = null;
            ClassPath src = platform.getSourceFolders();
            if (src.entries().size()>0) {
                URL folderRoot = src.entries().get(0).getURL();
                if ("jar".equals(folderRoot.getProtocol())) {   //NOI18N
                    folderRoot = FileUtil.getArchiveFile (folderRoot);
                }
                srcPath = new File(URI.create(folderRoot.toExternalForm())).getAbsolutePath();
            }
View Full Code Here

        }
        Collection installFolders = platform.getInstallFolders();
        if (installFolders.size()>0) {
            File scalaHome = FileUtil.toFile ((FileObject)installFolders.iterator().next());
            props.setProperty(homePropName, scalaHome.getAbsolutePath());
            ClassPath bootCP = platform.getBootstrapLibraries();
            StringBuffer sbootcp = new StringBuffer();
            for (ClassPath.Entry entry : bootCP.entries()) {
                URL url = entry.getURL();
                if ("jar".equals(url.getProtocol())) {              //NOI18N
                    url = FileUtil.getArchiveFile(url);
                }
                File root = new File (URI.create(url.toExternalForm()));
View Full Code Here

        else {
            ScalaPlatformManager manager = ScalaPlatformManager.getDefault();
            platforms = manager.getInstalledPlatforms();
        }
        for (int i=0; i<platforms.length; i++) {
            ClassPath bootClassPath = platforms[i].getBootstrapLibraries();
            ClassPath libraryPath = platforms[i].getStandardLibraries();
            ClassPath sourcePath = platforms[i].getSourceFolders();
            FileObject root = null;
            if (ClassPath.SOURCE.equals(type) && sourcePath != null &&
                (root = sourcePath.findOwnerRoot(fo))!=null) {
                this.setLastUsedPlatform (root,platforms[i]);
                return sourcePath;
            }
            else if (ClassPath.BOOT.equals(type) &&
                    ((bootClassPath != null && (root = bootClassPath.findOwnerRoot (fo))!=null) ||
                    (sourcePath != null && (root = sourcePath.findOwnerRoot(fo)) != null) ||
                    (libraryPath != null && (root = libraryPath.findOwnerRoot(fo))!=null))) {
                this.setLastUsedPlatform (root,platforms[i]);
                return bootClassPath;
            }
            else if (ClassPath.COMPILE.equals(type)) {
                if (libraryPath != null && (root = libraryPath.findOwnerRoot(fo))!=null) {
                    this.setLastUsedPlatform (root,platforms[i]);
                    return libraryPath;
                }
                else if ((bootClassPath != null && (root = bootClassPath.findOwnerRoot (fo))!=null) ||
                    (sourcePath != null && (root = sourcePath.findOwnerRoot(fo)) != null)) {
                    return this.getEmptyClassPath ();
                }
            }
        }
        return null;
View Full Code Here

                fPath = new java.io.File(fullPath);
            }
            FileObject fo = FileUtil.toFileObject(fPath);
            Object[] pcks = getClasspathForSource().toArray();
            for (int i = 0; i < pcks.length; i++) {
                ClassPath p = (ClassPath)pcks[i];
                if (p.contains(fo)) {
                    return p.getResourceName(fo);
                }
            }
        } catch (MalformedURLException ex) {
            Exceptions.printStackTrace(ex);
        } catch (URISyntaxException ex) {
View Full Code Here

        //    (null, Session.class);
        Map properties = contextProvider.lookupFirst(null, Map.class);
        //   sourcesHelper = contextProvider.lookupFirst(null, SourcesHelper.class);


        ClassPath cljClassPath = null;
        try {
            //??cljClassPath = (ClassPath) RT.var("org.enclojure.platform.pathutils", "get-classpath-for-clojure-files").invoke();
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }

        // 2) get default allSourceRoots of source roots used for stepping

        if (properties != null) {
            smartSteppingSourcePath = (ClassPath) properties.get("sourcepath");
            ClassPath jdkCP = (ClassPath) properties.get("jdksources");
            if ((jdkCP == null) && (JavaPlatform.getDefault() != null)) {
                jdkCP = JavaPlatform.getDefault().getSourceFolders();
            }
            originalSourcePath = jdkCP == null ? smartSteppingSourcePath : ClassPathSupport.createProxyClassPath(
                    new ClassPath[]{
                        jdkCP,
                        smartSteppingSourcePath
                    });
            projectSourceRoots = getSourceRoots(originalSourcePath);
            Set<FileObject> preferredRoots = new HashSet<FileObject>();
            preferredRoots.addAll(Arrays.asList(originalSourcePath.getRoots()));
            Set<FileObject> globalRoots = new TreeSet<FileObject>(new FileObjectComparator());
            globalRoots.addAll(GlobalPathRegistry.getDefault().getSourceRoots());
            globalRoots.removeAll(preferredRoots);
            ClassPath globalCP = ClassPathSupport.createClassPath(globalRoots.toArray(new FileObject[0]));
            originalSourcePath = ClassPathSupport.createProxyClassPath(
                    new ClassPath[]{
                        cljClassPath
                                , originalSourcePath
                                , globalCP
                    });
        } else {
            pathRegistryListener = new PathRegistryListener();
            GlobalPathRegistry.getDefault().addGlobalPathRegistryListener(
                    WeakListeners.create(GlobalPathRegistryListener.class,
                    pathRegistryListener,
                    GlobalPathRegistry.getDefault()));
            JavaPlatformManager.getDefault().addPropertyChangeListener(
                    WeakListeners.propertyChange(pathRegistryListener,
                    JavaPlatformManager.getDefault()));

            List<FileObject> allSourceRoots = new ArrayList<FileObject>();
            Set<FileObject> preferredRoots = new HashSet<FileObject>();
            Set<FileObject> addedBinaryRoots = new HashSet<FileObject>();
            Project mainProject = OpenProjects.getDefault().getMainProject();
            if (mainProject != null) {
                SourceGroup[] sgs = ProjectUtils.getSources(mainProject).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
                for (SourceGroup sg : sgs) {
                    ClassPath ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.SOURCE);
                    if (ecp == null) {
                        ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.EXECUTE);
                    }
                    if (ecp != null) {
                        FileObject[] binaryRoots = ecp.getRoots();
                        for (FileObject fo : binaryRoots) {
                            if (addedBinaryRoots.contains(fo)) {
                                continue;
                            }
                            addedBinaryRoots.add(fo);
View Full Code Here

                fo,
                directorySeparator,
                includeExtension);
        if (relativePath == null) {
            // fallback to FileObject's class path
            ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE);
            if (cp == null) {
                cp = ClassPath.getClassPath(fo, ClassPath.COMPILE);
            }
            if (cp == null) {
                //ET - If the url of the full path exists, return that...
                if(fo!=null && theUrl!=null)
                {                              
                    File f = new File(theUrl.getPath());
                    if(f.exists())
                        return f.getAbsolutePath();                  
                }
                return null;
            }
            relativePath = cp.getResourceName(
                    fo,
                    directorySeparator,
                    includeExtension);
        }
        if (relativePath == null) {
View Full Code Here

    public void setSourceRoots(String[] sourceRoots) {

        LOG.log(Level.FINE, "SourcePathProviderImpl.setSourceRoots(" + java.util.Arrays.asList(sourceRoots) + ")");

        Set<String> newRoots = new HashSet<String>(Arrays.asList(sourceRoots));
        ClassPath oldCP = null;
        ClassPath newCP = null;
        synchronized (this) {
            List<FileObject> sourcePath = new ArrayList<FileObject>(
                    Arrays.asList(smartSteppingSourcePath.getRoots()));
            List<FileObject> sourcePathOriginal = new ArrayList<FileObject>(
                    Arrays.asList(originalSourcePath.getRoots()));
View Full Code Here

        return roots;
    }

    private void verifyClasspath(Project prj, FileObject fo, String cpType, String... entries) {
        ClassPathProvider cpp = prj.getLookup().lookup(ClassPathProvider.class);
        ClassPath classpath = cpp.findClassPath(fo, cpType);
        assertNotNull("classpath " + cpType + " found", classpath);

        Set<String> cpRoots = getRootsOfClassPath(classpath);
        for (final String entry: entries) {
            assertTrue(
View Full Code Here

TOP

Related Classes of org.netbeans.api.java.classpath.ClassPath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.