Package org.netbeans.api.java.classpath

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


    public void setSourceRoots (String[] sourceRoots) {
        if (logger.isLoggable(Level.FINE)) {
            logger.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


       
        JavaPlatform jp = findActivePlatform ();
        final List<PathResourceImplementation> result = new ArrayList<PathResourceImplementation>();
        if (jp != null) {
            //TODO: May also listen on CP, but from Platform it should be fixed.           
            final ClassPath cp = jp.getBootstrapLibraries();
            assert cp != null : jp;
            for (ClassPath.Entry entry : cp.entries()) {
                result.add(ClassPathSupport.createResource(entry.getURL()));
            }
        }
       
        ScalaPlatform sp = findActiveScalaPlatform();
        if (sp != null) {
            final ClassPath cp = sp.getBootstrapLibraries();
            assert cp != null : cp;
            for (ClassPath.Entry entry : cp.entries()) {
                result.add(ClassPathSupport.createResource(entry.getURL()));
            }
        }
       
        synchronized (this) {
View Full Code Here

            assert lookup != null;
            this.lookup = lookup;
        }               

        public ClassPath findClassPath(FileObject file, String type) {
            ClassPath result = defaultProvider.findClassPath(file, type);
            if (result != null) {
                return result;
            }
            for (ClassPathProvider cpProvider : lookup.lookupAll(ClassPathProvider.class)) {
                result = cpProvider.findClassPath(file, type);
View Full Code Here

        }
    }
    private ClassPath[] findClassPathOrNull(FileObject file, String type, Library lib) {
        if (lib.getType().equals(J2SELibraryTypeProvider.LIBRARY_TYPE)) {
            List<URL> resources = lib.getContent(J2SELibraryTypeProvider.VOLUME_TYPE_SRC);
            ClassPath sourcePath = ClassPathSupport.createClassPath(resources.toArray(new URL[resources.size()]));
            FileObject root = sourcePath.findOwnerRoot(file);
            if (root != null) {
                setLastUsedLibrary(root, lib);
                if (ClassPath.SOURCE.equals(type)) {
                    return new ClassPath[] {sourcePath};
                } else if (ClassPath.COMPILE.equals(type)) {
View Full Code Here

                }
                List<URL> sourceRoots = lib.getContent(J2SELibraryTypeProvider.VOLUME_TYPE_SRC);
                if (sourceRoots.isEmpty()) {
                    continue;
                }
                ClassPath cp = ClassPathSupport.createClassPath(sourceRoots.toArray(new URL[sourceRoots.size()]));
                FileObject root = cp.findOwnerRoot(javaFile);
                if (root != null) {
                    setLastUsedRoot(root, lib);
                    return getSourceLevel(lib);
                }
            }
View Full Code Here

        if (mainClass == null || mainClass.length() == 0) {
            return MainClassStatus.UNSET;
        }
        if (sourcesRoots.length > 0) {
            ClassPath bootPath = ClassPath.getClassPath(sourcesRoots[0], ClassPath.BOOT);        //Single compilation unit
            ClassPath compilePath = ClassPath.getClassPath(sourcesRoots[0], ClassPath.EXECUTE);
            ClassPath sourcePath = ClassPath.getClassPath(sourcesRoots[0], ClassPath.SOURCE);
            if (J2SEProjectUtil.isMainClass(mainClass, bootPath, compilePath, sourcePath)) {
                return MainClassStatus.SET_AND_VALID;
            }
        } else {
            ClassPathProviderImpl cpProvider = project.getClassPathProvider();
            if (cpProvider != null) {
                ClassPath bootPath = cpProvider.getProjectSourcesClassPath(ClassPath.BOOT);
                ClassPath compilePath = cpProvider.getProjectSourcesClassPath(ClassPath.EXECUTE);
                ClassPath sourcePath = cpProvider.getProjectSourcesClassPath(ClassPath.SOURCE);   //Empty ClassPath
                if (J2SEProjectUtil.isMainClass(mainClass, bootPath, compilePath, sourcePath)) {
                    return MainClassStatus.SET_AND_VALID;
                }
            }
        }
View Full Code Here

    }

    @Override
    public ClassPath getBootstrapLibraries() {
        synchronized (this) {
            ClassPath cp = (bootstrap == null ? null : bootstrap.get());
            if (cp != null) {
                return cp;
            }
            File scalaHome = getScalaHome();
            String pathSpec = ""//NOI18N
            if (scalaHome != null && scalaHome.exists() && scalaHome.canRead()) {
                File scalaLib = new File(scalaHome, "lib")//NOI18N
                if (scalaLib.exists() && scalaLib.canRead()) {
                    pathSpec = makeClassPath(new String[]{"scala-library.jar", "scala-reflect.jar", "scala-compiler.jar"}, scalaLib);
                }
            }

            cp = Util.createClassPath(pathSpec);

            /**
             * @todo how to deal with project's custom java platform ?
             */
            JavaPlatform javaPlatform = JavaPlatformManager.getDefault().getDefaultPlatform();
            if (javaPlatform != null) {
                ClassPath javaBootstrap = javaPlatform.getBootstrapLibraries();
                List<ClassPath.Entry> entries = javaBootstrap.entries();
                URL[] urls = new URL[entries.size() + 1];
                for (int i = 0; i < entries.size(); i++) {
                    urls[i] = entries.get(i).getURL();
                }
                if (!cp.entries().isEmpty()) {
View Full Code Here

        return cp.toString();
    }

    @Override
    public ClassPath getStandardLibraries() {
        ClassPath cp = standardLibs.get();
        if (cp != null) {
            return cp;
        }
        String s = getScalaClassPath();
        System.setProperty(J2SEPlatformImpl.SYSPROP_SCALA_CLASS_PATH, s);
View Full Code Here

                    return defaultPlatform.getBootstrapLibraries();
                }
            }
            else if (ClassPath.COMPILE.equals(type)) {
                synchronized (this) {
                    ClassPath cp = null;
                    if (this.compiledClassPath == null || (cp = this.compiledClassPath.get()) == null) {
                        cp = ClassPathFactory.createClassPath(new CompileClassPathImpl ());
                        this.compiledClassPath = new WeakReference<ClassPath> (cp);
                    }
                    return cp;
                }
            }
            else if (ClassPath.SOURCE.equals(type)) {
//                synchronized (this) {
//                    ClassPath cp = null;
//                    if (file.isFolder()) {
//                        Reference ref = (Reference) this.sourceClasPathsCache.get (file);
//                        if (ref == null || (cp = (ClassPath)ref.get()) == null ) {
//                            cp = ClassPathSupport.createClassPath(new FileObject[] {file});
//                            this.sourceClasPathsCache.put (file, new WeakReference(cp));
//                        }
//                    }
//                    else {
//                        Reference ref = (Reference) this.sourceRootsCache.get (file);
//                        FileObject sourceRoot = null;
//                        if (ref == null || (sourceRoot = (FileObject)ref.get()) == null ) {
//                            sourceRoot = getRootForFile (file, TYPE_JAVA);
//                            if (sourceRoot == null) {
//                                return null;
//                            }
//                            this.sourceRootsCache.put (file, new WeakReference(sourceRoot));
//                        }
//                        if (!sourceRoot.isValid()) {
//                            this.sourceClasPathsCache.remove(sourceRoot);
//                        }
//                        else {
//                            ref = (Reference) this.sourceClasPathsCache.get(sourceRoot);
//                            if (ref == null || (cp = (ClassPath)ref.get()) == null ) {
//                                cp = ClassPathSupport.createClassPath(new FileObject[] {sourceRoot});
//                                this.sourceClasPathsCache.put (sourceRoot, new WeakReference(cp));
//                            }
//                        }
//                    }
//                    return cp;                                       
//                }        
                //XXX: Needed by refactoring of the javaws generated files,
                //anyway it's better to return no source path for files with no project.
                //It has to be ignored by java model anyway otherwise a single java
                //file inside home folder may cause a scan of the whole home folder.
                //see issue #75410
                return null;
            }
        }
        else if (CLASS_EXT.equals(file.getExt())) {
            if (ClassPath.BOOT.equals (type)) {
                ScalaPlatform defaultPlatform = ScalaPlatformManager.getDefault().getDefaultPlatform();
                if (defaultPlatform != null) {
                    return defaultPlatform.getBootstrapLibraries();
                }
            }
            else if (ClassPath.EXECUTE.equals(type)) {
                ClassPath cp = null;
                Reference<FileObject> foRef = this.sourceRootsCache.get (file);
                FileObject execRoot = null;
                if (foRef == null || (execRoot = foRef.get()) == null ) {
                    execRoot = getRootForFile (file, TYPE_CLASS);
                    if (execRoot == null) {
View Full Code Here

                    regs.addGlobalPathRegistryListener(this);
                    Set<URL> roots = new HashSet<URL> ();
                    //Add compile classpath
                    Set<ClassPath> paths = regs.getPaths (ClassPath.COMPILE);
                    for (Iterator<ClassPath> it = paths.iterator(); it.hasNext();) {
                        ClassPath cp =  it.next();
                        try {
                            for (ClassPath.Entry entry : cp.entries()) {
                                roots.add (entry.getURL());
                            }                   
                        } catch (RecursionException e) {/*Recover from recursion*/}
                    }
                    //Add entries from Exec CP which has sources on Sources CP and are not on the Compile CP
                    Set<ClassPath> sources = regs.getPaths(ClassPath.SOURCE);
                    Set<URL> sroots = new HashSet<URL> ();
                    for (Iterator<ClassPath> it = sources.iterator(); it.hasNext();) {
                        ClassPath cp = it.next();
                        try {
                            for (Iterator<ClassPath.Entry> eit = cp.entries().iterator(); eit.hasNext();) {
                                ClassPath.Entry entry = eit.next();
                                sroots.add (entry.getURL());
                            }                   
                        } catch (RecursionException e) {/*Recover from recursion*/}
                    }               
                    Set<ClassPath> exec = regs.getPaths(ClassPath.EXECUTE);
                    for (Iterator<ClassPath> it = exec.iterator(); it.hasNext();) {
                        ClassPath cp = it.next ();
                        try {
                            for (Iterator<ClassPath.Entry> eit = cp.entries().iterator(); eit.hasNext();) {
                                ClassPath.Entry entry = eit.next ();
                                FileObject[] fos = SourceForBinaryQuery.findSourceRoots(entry.getURL()).getRoots();
                                for (int i=0; i< fos.length; i++) {
                                    try {
                                        if (sroots.contains(fos[i].getURL())) {
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.