This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 121640
Collapse All | Expand All

(-)projects/src/org/netbeans/modules/ruby/rubyproject/BootClassPathProvider.java (-37 / +18 lines)
Lines 71-118 Link Here
71
    
71
    
72
    public ClassPath findClassPath(FileObject file, String type) {
72
    public ClassPath findClassPath(FileObject file, String type) {
73
        // See if the file is under the Ruby libraries
73
        // See if the file is under the Ruby libraries
74
        if (RubyInstallation.getInstance().isSystemFile(file)) {
74
        FileObject systemRoot = RubyInstallation.getInstance().getSystemRoot(file);
75
            return getRubyClassPaths(file, type);
75
        if (systemRoot != null) {
76
            return getRubyClassPaths(file, type, systemRoot);
76
        }
77
        }
77
        
78
        
78
        return null;
79
        return null;
79
    }
80
    }
80
    
81
    
81
    private ClassPath getRubyClassPaths(FileObject file, String type) {
82
    private ClassPath getRubyClassPaths(FileObject file, String type, FileObject systemRoot) {
82
            // Default provider - do this for things like Ruby library files
83
        // Default provider - do this for things like Ruby library files
83
               synchronized (this) {
84
        synchronized (this) {
84
                    ClassPath cp = null;
85
            ClassPath cp = null;
85
                    if (file.isFolder()) {
86
            if (!file.isFolder()) {
86
                        Reference ref = (Reference) this.sourceClassPathsCache.get (file);
87
                file = systemRoot;
87
                        if (ref == null || (cp = (ClassPath)ref.get()) == null ) {
88
            }
88
                            cp = ClassPathSupport.createClassPath(new FileObject[] {file});
89
            if (file.isFolder()) {
89
                            this.sourceClassPathsCache.put(file, new WeakReference<ClassPath>(cp));
90
                Reference ref = (Reference) this.sourceClassPathsCache.get (file);
90
                        }
91
                if (ref == null || (cp = (ClassPath)ref.get()) == null ) {
91
                    }
92
                    cp = ClassPathSupport.createClassPath(new FileObject[] {file});
92
                    else {
93
                    this.sourceClassPathsCache.put(file, new WeakReference<ClassPath>(cp));
93
                        //Reference ref = (Reference) this.sourceRootsCache.get (file);
94
                        //FileObject sourceRoot = null;
95
                        //if (ref == null || (sourceRoot = (FileObject)ref.get()) == null ) {
96
                        //    sourceRoot = getRootForFile (file, TYPE_JAVA);
97
                        //    if (sourceRoot == null) {
98
                        //        return null;
99
                        //    }
100
                        //    this.sourceRootsCache.put (file, new WeakReference(sourceRoot));
101
                        //}
102
                        //if (!sourceRoot.isValid()) {
103
                        //    this.sourceClasPathsCache.remove(sourceRoot);
104
                        //}
105
                        //else {
106
                        //    ref = (Reference) this.sourceClasPathsCache.get(sourceRoot);
107
                        //    if (ref == null || (cp = (ClassPath)ref.get()) == null ) {
108
                        //        cp = ClassPathSupport.createClassPath(new FileObject[] {sourceRoot});
109
                        //        this.sourceClasPathsCache.put (sourceRoot, new WeakReference(cp));
110
                        //    }
111
                        //}
112
                        return null;
113
                    }
114
                    return cp;                                        
115
                }
94
                }
95
            }
96
            return cp;                                        
97
        }
116
    }
98
    }
117
    
118
}
99
}
(-)platform/src/org/netbeans/api/ruby/platform/RubyInstallation.java (-5 / +6 lines)
Lines 773-783 Link Here
773
        return null;
773
        return null;
774
    }
774
    }
775
    
775
    
776
    /** Return true iff the given file is a "system" file - e.g. it's part
776
    /** Return non-null iff the given file is a "system" file - e.g. it's part
777
     * of the Ruby 1.8 libraries, or the Java support libraries, or the user's rubygems,
777
     * of the Ruby 1.8 libraries, or the Java support libraries, or the user's rubygems,
778
     * or something under $GEM_HOME...
778
     * or something under $GEM_HOME...
779
     * @return The actual root the in the system the file is under.
779
     */
780
     */
780
    public boolean isSystemFile(FileObject file) {
781
    public FileObject getSystemRoot(FileObject file) {
781
        // See if the file is under the Ruby libraries
782
        // See if the file is under the Ruby libraries
782
        FileObject rubyLibFo = getRubyLibFo();
783
        FileObject rubyLibFo = getRubyLibFo();
783
        FileObject rubyStubs = getRubyStubs();
784
        FileObject rubyStubs = getRubyStubs();
Lines 790-804 Link Here
790
791
791
        while (file != null) {
792
        while (file != null) {
792
            if (file == rubyLibFo || file == rubyStubs || file == gemHome) {
793
            if (file == rubyLibFo || file == rubyStubs || file == gemHome) {
793
                return true;
794
                return file;
794
            }
795
            }
795
            
796
            
796
            file = file.getParent();
797
            file = file.getParent();
797
        }
798
        }
798
799
799
        return false;
800
        return null;
800
    }
801
    }
801
802
    
802
    public String getRake() {
803
    public String getRake() {
803
        if (rake == null) {
804
        if (rake == null) {
804
            rake = findGemExecutable("rake"); // NOI18N
805
            rake = findGemExecutable("rake"); // NOI18N

Return to bug 121640