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 246147
Collapse All | Expand All

(-)a/api.java.classpath/apichanges.xml (+16 lines)
Lines 76-81 Link Here
76
<!-- ACTUAL CHANGES BEGIN HERE: -->
76
<!-- ACTUAL CHANGES BEGIN HERE: -->
77
77
78
<changes>
78
<changes>
79
        <change id="ClassPath.getFlags">
80
            <api name="classpath"/>
81
            <summary>Added ClassPath flags</summary>
82
            <version major="1" minor="43"/>
83
            <date day="30" month="7" year="2014"/>
84
            <author login="tzezula"/>
85
            <compatibility addition="yes" modification="no" semantic="compatible" source="compatible" binary="compatible"/>
86
            <description>
87
                <p>
88
                    Added flags to <code>ClassPath</code>
89
                </p>
90
            </description>
91
            <class package="org.netbeans.api.java.classpath" name="ClassPath"/>
92
            <class package="org.netbeans.spi.java.classpath" name="FlaggedClassPathImplementation"/>
93
            <issue number="245155"/>
94
        </change>
79
        <change id="ClassPath.EMPTY">
95
        <change id="ClassPath.EMPTY">
80
            <api name="classpath"/>
96
            <api name="classpath"/>
81
            <summary>Added a constant representing an empty ClassPath</summary>
97
            <summary>Added a constant representing an empty ClassPath</summary>
(-)a/api.java.classpath/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.api.java.classpath/1
2
OpenIDE-Module: org.netbeans.api.java.classpath/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/java/classpath/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/java/classpath/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.42
4
OpenIDE-Module-Specification-Version: 1.43
5
5
(-)a/api.java.classpath/nbproject/project.xml (+2 lines)
Lines 81-86 Link Here
81
                    </test-dependency>
81
                    </test-dependency>
82
                    <test-dependency>
82
                    <test-dependency>
83
                        <code-name-base>org.openide.util</code-name-base>
83
                        <code-name-base>org.openide.util</code-name-base>
84
                        <compile-dependency/>
85
                        <test/>
84
                    </test-dependency>
86
                    </test-dependency>
85
                    <test-dependency>
87
                    <test-dependency>
86
                        <code-name-base>org.openide.util.lookup</code-name-base>
88
                        <code-name-base>org.openide.util.lookup</code-name-base>
(-)a/api.java.classpath/src/org/netbeans/api/java/classpath/ClassPath.java (-1 / +41 lines)
Lines 77-82 Link Here
77
import org.netbeans.spi.java.classpath.ClassPathImplementation;
77
import org.netbeans.spi.java.classpath.ClassPathImplementation;
78
import org.netbeans.spi.java.classpath.ClassPathProvider;
78
import org.netbeans.spi.java.classpath.ClassPathProvider;
79
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation;
79
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation;
80
import org.netbeans.spi.java.classpath.FlaggedClassPathImplementation;
80
import org.netbeans.spi.java.classpath.PathResourceImplementation;
81
import org.netbeans.spi.java.classpath.PathResourceImplementation;
81
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
82
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
82
import org.openide.filesystems.FileAttributeEvent;
83
import org.openide.filesystems.FileAttributeEvent;
Lines 206-212 Link Here
206
     * Name of the "entries" property
207
     * Name of the "entries" property
207
     */
208
     */
208
    public static final String PROP_ENTRIES = "entries";
209
    public static final String PROP_ENTRIES = "entries";
209
    
210
211
    /**
212
     * Name of the "flags" property
213
     * @since 1.43
214
     */
215
    public static final String PROP_FLAGS = "flags";
216
210
    /**
217
    /**
211
     * Property to be fired when include/exclude set changes.
218
     * Property to be fired when include/exclude set changes.
212
     * @see FilteringPathResourceImplementation
219
     * @see FilteringPathResourceImplementation
Lines 596-601 Link Here
596
    }
603
    }
597
604
598
    /**
605
    /**
606
     * Returns the {@link ClassPath}'s flags.
607
     * @return the {@link Flag}s
608
     * @since 1.43
609
     */
610
    @NonNull
611
    public Set<Flag> getFlags() {
612
        if (impl instanceof FlaggedClassPathImplementation) {
613
            final Set<Flag> res = ((FlaggedClassPathImplementation)impl).getFlags();
614
            assert res != null : String.format(
615
                "ClassPathImplementation %s : %s returned null flags.", //NOI18N
616
                impl,
617
                impl.getClass());
618
            return res;
619
        } else {
620
            return Collections.<Flag>emptySet();
621
        }
622
    }
623
624
    /**
599
     * Find the classpath of a given type, if any, defined for a given file.
625
     * Find the classpath of a given type, if any, defined for a given file.
600
     * <p>This method may return null, if:</p>
626
     * <p>This method may return null, if:</p>
601
     * <ul>
627
     * <ul>
Lines 676-681 Link Here
676
    }
702
    }
677
703
678
    /**
704
    /**
705
     * ClassPath's flags.
706
     * @since 1.43
707
     */
708
    public enum Flag {
709
        /**
710
         * The incomplete {@link ClassPath} is ignored by language features
711
         * unless it's resolved and the {@link INCOMPLETE} flag is removed.
712
         */
713
        INCOMPLETE
714
    }
715
716
    /**
679
     * Render this classpath in the conventional format used by the Java launcher.
717
     * Render this classpath in the conventional format used by the Java launcher.
680
     * @param conversionMode policy for converting unusual entries
718
     * @param conversionMode policy for converting unusual entries
681
     * @return a conventionally-formatted representation of the classpath
719
     * @return a conventionally-formatted representation of the classpath
Lines 1160-1165 Link Here
1160
                if (fire) {
1198
                if (fire) {
1161
                    firePropertyChange(PROP_INCLUDES, null, null, evt.getPropagationId());
1199
                    firePropertyChange(PROP_INCLUDES, null, null, evt.getPropagationId());
1162
                }
1200
                }
1201
            } else if (FlaggedClassPathImplementation.PROP_FLAGS.equals(prop)) {
1202
                firePropertyChange(PROP_FLAGS, null, null, null);
1163
            }
1203
            }
1164
            if (ClassPathImplementation.PROP_RESOURCES.equals(prop)) {
1204
            if (ClassPathImplementation.PROP_RESOURCES.equals(prop)) {
1165
                final List<? extends PathResourceImplementation> resources = impl.getResources();
1205
                final List<? extends PathResourceImplementation> resources = impl.getResources();
(-)a/api.java.classpath/src/org/netbeans/spi/java/classpath/FlaggedClassPathImplementation.java (+67 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2014 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.spi.java.classpath;
44
45
import java.util.Set;
46
import org.netbeans.api.annotations.common.NonNull;
47
import org.netbeans.api.java.classpath.ClassPath;
48
49
/**
50
 * The ClassPathImplementation with {@link ClassPath.Flag}s.
51
 * @author Tomas Zezula
52
 * @since 1.43
53
 */
54
public interface FlaggedClassPathImplementation extends ClassPathImplementation {
55
56
    /**
57
     * Name of the "flags" property.
58
     */
59
    public static final String PROP_FLAGS = "flags";    //NOI18N
60
61
    /**
62
     * Returns the {@link ClassPath}'s flags.
63
     * @return the {@link Flag}s
64
     */
65
    @NonNull
66
    Set<ClassPath.Flag> getFlags();
67
}
(-)a/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/ClassPathTest.java (-1 / +34 lines)
Lines 56-61 Link Here
56
import java.util.ArrayList;
56
import java.util.ArrayList;
57
import java.util.Arrays;
57
import java.util.Arrays;
58
import java.util.Collections;
58
import java.util.Collections;
59
import java.util.EnumSet;
59
import java.util.Enumeration;
60
import java.util.Enumeration;
60
import java.util.HashSet;
61
import java.util.HashSet;
61
import java.util.Iterator;
62
import java.util.Iterator;
Lines 77-82 Link Here
77
import org.openide.filesystems.FileObject;
78
import org.openide.filesystems.FileObject;
78
import org.openide.filesystems.FileUtil;
79
import org.openide.filesystems.FileUtil;
79
import org.openide.util.Utilities;
80
import org.openide.util.Utilities;
81
import org.openide.util.test.MockPropertyChangeListener;
80
82
81
public class ClassPathTest extends NbTestCase {
83
public class ClassPathTest extends NbTestCase {
82
84
Lines 312-318 Link Here
312
        f.delete();
314
        f.delete();
313
        assertEquals("again empty", null, cp.findResource("f"));
315
        assertEquals("again empty", null, cp.findResource("f"));
314
    }
316
    }
315
    
317
318
    public void testFlags() {
319
        final FlaggedClassPathImpl fcpImpl = new FlaggedClassPathImpl();
320
        final ClassPath cp = ClassPathFactory.createClassPath(fcpImpl);
321
        Set<ClassPath.Flag> flags = cp.getFlags();
322
        assertNotNull(flags);
323
        assertTrue(flags.isEmpty());
324
        fcpImpl.setFlags(EnumSet.of(ClassPath.Flag.INCOMPLETE));
325
        flags = cp.getFlags();
326
        assertNotNull(flags);
327
        assertEquals(1, flags.size());
328
        assertEquals(ClassPath.Flag.INCOMPLETE, flags.iterator().next());
329
        fcpImpl.setFlags(EnumSet.noneOf(ClassPath.Flag.class));
330
        flags = cp.getFlags();
331
        assertNotNull(flags);
332
        assertTrue(flags.isEmpty());
333
    }
334
335
    public void testFlagsFiring() {
336
        final FlaggedClassPathImpl fcpImpl = new FlaggedClassPathImpl();
337
        final ClassPath cp = ClassPathFactory.createClassPath(fcpImpl);
338
        Set<ClassPath.Flag> flags = cp.getFlags();
339
        assertNotNull(flags);
340
        assertTrue(flags.isEmpty());
341
        final MockPropertyChangeListener pl = new MockPropertyChangeListener(ClassPath.PROP_FLAGS);
342
        cp.addPropertyChangeListener(pl);
343
        fcpImpl.setFlags(EnumSet.of(ClassPath.Flag.INCOMPLETE));
344
        pl.assertEventCount(1);
345
        fcpImpl.setFlags(EnumSet.noneOf(ClassPath.Flag.class));
346
        pl.assertEventCount(1);
347
    }
348
316
    static final class TestClassPathImplementation implements ClassPathImplementation, PropertyChangeListener {
349
    static final class TestClassPathImplementation implements ClassPathImplementation, PropertyChangeListener {
317
350
318
        private final PropertyChangeSupport support = new PropertyChangeSupport (this);
351
        private final PropertyChangeSupport support = new PropertyChangeSupport (this);
(-)a/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/FlaggedClassPathImpl.java (+111 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2014 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.api.java.classpath;
44
45
import java.beans.PropertyChangeListener;
46
import java.beans.PropertyChangeSupport;
47
import java.util.Collections;
48
import java.util.EnumSet;
49
import java.util.List;
50
import java.util.Set;
51
import org.netbeans.api.annotations.common.NonNull;
52
import org.netbeans.spi.java.classpath.FlaggedClassPathImplementation;
53
import org.netbeans.spi.java.classpath.PathResourceImplementation;
54
import org.openide.util.Parameters;
55
56
/**
57
 *
58
 * @author Tomas Zezula
59
 */
60
class FlaggedClassPathImpl implements FlaggedClassPathImplementation {
61
62
    private final PropertyChangeSupport support;
63
    //@GuardedBy("this")
64
    private Set<ClassPath.Flag> flags;
65
    //@GuardedBy("this")
66
    private List<PathResourceImplementation> resources;
67
68
    FlaggedClassPathImpl() {
69
        this.support = new PropertyChangeSupport(this);
70
        this.flags = EnumSet.noneOf(ClassPath.Flag.class);
71
        this.resources = Collections.emptyList();
72
    }
73
74
    @Override
75
    public synchronized Set<ClassPath.Flag> getFlags() {
76
        return flags;
77
    }
78
79
    @Override
80
    public synchronized List<? extends PathResourceImplementation> getResources() {
81
        return resources;
82
    }
83
84
    @Override
85
    public void addPropertyChangeListener(PropertyChangeListener listener) {
86
        Parameters.notNull("listener", listener);   //NOI18N
87
        this.support.addPropertyChangeListener(listener);
88
    }
89
90
    @Override
91
    public void removePropertyChangeListener(PropertyChangeListener listener) {
92
        Parameters.notNull("listener", listener);   //NOI18N
93
        this.support.removePropertyChangeListener(listener);
94
    }
95
96
    void setResources(@NonNull final List<PathResourceImplementation> resources) {
97
        Parameters.notNull("resources", resources); //NOI18N
98
        synchronized (this) {
99
            this.resources = resources;
100
        }
101
        support.firePropertyChange(PROP_RESOURCES, null, null);
102
    }
103
104
    void setFlags(@NonNull final Set<ClassPath.Flag> flags) {
105
        Parameters.notNull("flags", flags); //NOI18N
106
        synchronized (this) {
107
            this.flags = flags;
108
        }
109
        support.firePropertyChange(PROP_FLAGS, null, null);
110
    }
111
}
(-)a/java.source/nbproject/project.xml (-1 / +1 lines)
Lines 73-79 Link Here
73
                    <compile-dependency/>
73
                    <compile-dependency/>
74
                    <run-dependency>
74
                    <run-dependency>
75
                        <release-version>1</release-version>
75
                        <release-version>1</release-version>
76
                        <specification-version>1.0</specification-version>
76
                        <specification-version>1.43</specification-version>
77
                    </run-dependency>
77
                    </run-dependency>
78
                </dependency>
78
                </dependency>
79
                <dependency>
79
                <dependency>
(-)a/java.source/src/org/netbeans/modules/java/source/classpath/SourcePathCheck.java (-17 / +30 lines)
Lines 85-110 Link Here
85
        final CompilationInfo info = CompilationInfo.get(result);
85
        final CompilationInfo info = CompilationInfo.get(result);
86
        final ClasspathInfo cpInfo = info.getClasspathInfo();
86
        final ClasspathInfo cpInfo = info.getClasspathInfo();
87
        if (cpInfo != null) {
87
        if (cpInfo != null) {
88
            final ClassPath cachedSrc = ClasspathInfoAccessor.getINSTANCE().getCachedClassPath(cpInfo, PathKind.SOURCE);
89
            final ClassPath src = cpInfo.getClassPath(PathKind.SOURCE);
88
            final ClassPath src = cpInfo.getClassPath(PathKind.SOURCE);
90
            try {
89
            final ClassPath boot = cpInfo.getClassPath(PathKind.BOOT);
91
                final Set<URL> unknown = new HashSet<URL>();
90
            final ClassPath compile = cpInfo.getClassPath(PathKind.COMPILE);
92
                if (cachedSrc.entries().isEmpty() && !src.entries().isEmpty()) {
91
            if (!isIncomplete(src, boot, compile)) {
93
                    for (ClassPath.Entry entry : src.entries()) {
92
                final ClassPath cachedSrc = ClasspathInfoAccessor.getINSTANCE().getCachedClassPath(cpInfo, PathKind.SOURCE);
94
                        final URL url = entry.getURL();
93
                try {
95
                        if (!this.factory.firedFor.contains(url) &&
94
                    final Set<URL> unknown = new HashSet<URL>();
96
                                !JavaIndex.hasSourceCache(url,false) &&
95
                    if (cachedSrc.entries().isEmpty() && !src.entries().isEmpty()) {
97
                                FileOwnerQuery.getOwner(url.toURI()) != null) {
96
                        for (ClassPath.Entry entry : src.entries()) {
98
                            unknown.add(url);
97
                            final URL url = entry.getURL();
99
                            this.factory.firedFor.add(url);
98
                            if (!this.factory.firedFor.contains(url) &&
99
                                    !JavaIndex.hasSourceCache(url,false) &&
100
                                    FileOwnerQuery.getOwner(url.toURI()) != null) {
101
                                unknown.add(url);
102
                                this.factory.firedFor.add(url);
103
                            }
100
                        }
104
                        }
101
                    }                
105
                    }
106
                    if (!unknown.isEmpty()) {
107
                        PathRegistry.getDefault().registerUnknownSourceRoots(src, unknown);
108
                    }
109
                } catch (URISyntaxException e) {
110
                    Exceptions.printStackTrace(e);
102
                }
111
                }
103
                if (!unknown.isEmpty()) {
104
                    PathRegistry.getDefault().registerUnknownSourceRoots(src, unknown);
105
                }
106
            } catch (URISyntaxException e) {
107
                Exceptions.printStackTrace(e);
108
            }
112
            }
109
        }
113
        }
110
    }
114
    }
Lines 123-128 Link Here
123
    public void cancel() {        
127
    public void cancel() {        
124
    }
128
    }
125
129
130
    private static boolean isIncomplete(ClassPath... cps) {
131
        for (ClassPath cp : cps) {
132
            if (cp.getFlags().contains(ClassPath.Flag.INCOMPLETE)) {
133
                return true;
134
            }
135
        }
136
        return false;
137
    }
138
126
    public static final class Factory extends TaskFactory {
139
    public static final class Factory extends TaskFactory {
127
140
128
        @org.netbeans.api.annotations.common.SuppressWarnings(value={"DMI_COLLECTION_OF_URLS"}, justification="URLs have never host part")    //NOI18N
141
        @org.netbeans.api.annotations.common.SuppressWarnings(value={"DMI_COLLECTION_OF_URLS"}, justification="URLs have never host part")    //NOI18N
(-)a/java.source/src/org/netbeans/modules/java/source/parsing/Bundle.properties (+1 lines)
Lines 42-44 Link Here
42
# made subject to such option by the copyright holder.
42
# made subject to such option by the copyright holder.
43
#
43
#
44
FMT_InvalidFile=Invalid or deleted file: {0}
44
FMT_InvalidFile=Invalid or deleted file: {0}
45
ERR_IncompleteClassPath=Missing mandatory Classpath entries. Resolve Project Problems.
(-)a/java.source/src/org/netbeans/modules/java/source/parsing/CompilationInfoImpl.java (-8 / +103 lines)
Lines 53-58 Link Here
53
import java.util.ArrayList;
53
import java.util.ArrayList;
54
import java.util.Arrays;
54
import java.util.Arrays;
55
import java.util.Collection;
55
import java.util.Collection;
56
import java.util.Collections;
56
import java.util.EnumMap;
57
import java.util.EnumMap;
57
import java.util.HashMap;
58
import java.util.HashMap;
58
import java.util.Iterator;
59
import java.util.Iterator;
Lines 68-85 Link Here
68
import javax.tools.Diagnostic.Kind;
69
import javax.tools.Diagnostic.Kind;
69
import javax.tools.DiagnosticListener;
70
import javax.tools.DiagnosticListener;
70
import javax.tools.JavaFileObject;
71
import javax.tools.JavaFileObject;
72
import org.netbeans.api.annotations.common.NonNull;
73
import org.netbeans.api.annotations.common.NullAllowed;
74
import org.netbeans.api.java.classpath.ClassPath;
71
import org.netbeans.api.java.source.ClasspathInfo;
75
import org.netbeans.api.java.source.ClasspathInfo;
72
import org.netbeans.api.java.source.CompilationInfo;
76
import org.netbeans.api.java.source.CompilationInfo;
73
import org.netbeans.api.java.source.CompilationInfo.CacheClearPolicy;
77
import org.netbeans.api.java.source.CompilationInfo.CacheClearPolicy;
74
import org.netbeans.api.java.source.JavaSource;
78
import org.netbeans.api.java.source.JavaSource;
75
import org.netbeans.api.lexer.TokenHierarchy;
79
import org.netbeans.api.lexer.TokenHierarchy;
76
import org.netbeans.modules.java.source.JavaFileFilterQuery;
80
import org.netbeans.modules.java.source.JavaFileFilterQuery;
81
import org.netbeans.modules.java.source.indexing.JavaIndex;
77
import org.netbeans.modules.parsing.api.Snapshot;
82
import org.netbeans.modules.parsing.api.Snapshot;
78
import org.openide.cookies.EditorCookie;
83
import org.openide.cookies.EditorCookie;
79
import org.openide.filesystems.FileObject;
84
import org.openide.filesystems.FileObject;
80
import org.openide.loaders.DataObject;
85
import org.openide.loaders.DataObject;
81
import org.openide.loaders.DataObjectNotFoundException;
86
import org.openide.loaders.DataObjectNotFoundException;
82
import org.openide.util.Exceptions;
87
import org.openide.util.Exceptions;
88
import org.openide.util.NbBundle;
83
import org.openide.util.Pair;
89
import org.openide.util.Pair;
84
90
85
/**
91
/**
Lines 397-403 Link Here
397
     */
403
     */
398
    public synchronized JavacTaskImpl getJavacTask() {
404
    public synchronized JavacTaskImpl getJavacTask() {
399
        if (javacTask == null) {
405
        if (javacTask == null) {
400
            diagnosticListener = new DiagnosticListenerImpl(this.jfo);
406
            diagnosticListener = new DiagnosticListenerImpl(this.root, this.jfo, this.cpInfo);
401
            javacTask = JavacParser.createJavacTask(this.file, this.root, this.cpInfo,
407
            javacTask = JavacParser.createJavacTask(this.file, this.root, this.cpInfo,
402
                    this.parser, diagnosticListener, null, isDetached);
408
                    this.parser, diagnosticListener, null, isDetached);
403
        }
409
        }
Lines 482-488 Link Here
482
    static class DiagnosticListenerImpl implements DiagnosticListener<JavaFileObject> {
488
    static class DiagnosticListenerImpl implements DiagnosticListener<JavaFileObject> {
483
        
489
        
484
        private final Map<JavaFileObject, TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>>> source2Errors;
490
        private final Map<JavaFileObject, TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>>> source2Errors;
491
        private final FileObject root;
485
        private final JavaFileObject jfo;
492
        private final JavaFileObject jfo;
493
        private final ClasspathInfo cpInfo;
486
        private volatile List<Diagnostic<? extends JavaFileObject>> partialReparseErrors;
494
        private volatile List<Diagnostic<? extends JavaFileObject>> partialReparseErrors;
487
        /**
495
        /**
488
         * true if the partialReparseErrors contain some non-warning
496
         * true if the partialReparseErrors contain some non-warning
Lines 491-498 Link Here
491
        private volatile List<Diagnostic<? extends JavaFileObject>> affectedErrors;
499
        private volatile List<Diagnostic<? extends JavaFileObject>> affectedErrors;
492
        private volatile int currentDelta;
500
        private volatile int currentDelta;
493
        
501
        
494
        public DiagnosticListenerImpl(final JavaFileObject jfo) {
502
        public DiagnosticListenerImpl(
503
                @NullAllowed final FileObject root,
504
                @NullAllowed final JavaFileObject jfo,
505
                @NonNull final ClasspathInfo cpInfo) {
506
            this.root = root;
495
            this.jfo = jfo;
507
            this.jfo = jfo;
508
            this.cpInfo = cpInfo;
496
            this.source2Errors = new HashMap<JavaFileObject, TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>>>();
509
            this.source2Errors = new HashMap<JavaFileObject, TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>>>();
497
        }
510
        }
498
        
511
        
Lines 518-530 Link Here
518
        }
531
        }
519
532
520
        private TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>> getErrors(JavaFileObject file) {
533
        private TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>> getErrors(JavaFileObject file) {
521
                TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>> errors = source2Errors.get(file);
534
            TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>> errors;
522
535
            if (isIncompleteClassPath()) {
536
                if (root != null && JavaIndex.hasSourceCache(root.toURL(), false)) {
537
                    errors = source2Errors.get(file);
538
                    if (errors == null) {
539
                        source2Errors.put(file, errors = new TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>>());
540
                        if (this.jfo != null && this.jfo == file) {
541
                            errors.put(
542
                                -1,
543
                                Collections.<Diagnostic<? extends JavaFileObject>>singleton(new IncompleteClassPath(this.jfo)));
544
                        }
545
                    }
546
                } else {
547
                    errors = new TreeMap<>();
548
                    if (this.jfo != null && this.jfo == file) {
549
                        errors.put(
550
                            -1,
551
                            Collections.<Diagnostic<? extends JavaFileObject>>singleton(new IncompleteClassPath(this.jfo)));
552
                    }
553
                }
554
            } else {
555
                errors = source2Errors.get(file);
523
                if (errors == null) {
556
                if (errors == null) {
524
                    source2Errors.put(file, errors = new TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>>());
557
                    source2Errors.put(file, errors = new TreeMap<Integer, Collection<Diagnostic<? extends JavaFileObject>>>());
525
                }
558
                }
526
559
            }
527
                return errors;
560
            return errors;
528
        }
561
        }
529
        
562
        
530
        final boolean hasPartialReparseErrors () {
563
        final boolean hasPartialReparseErrors () {
Lines 567-574 Link Here
567
                result.put(entry.getKey(), Arrays.asList(entry.getValue()));
600
                result.put(entry.getKey(), Arrays.asList(entry.getValue()));
568
            }
601
            }
569
            return result;
602
            return result;
570
        } 
603
        }
571
        
604
605
        private boolean isIncompleteClassPath() {
606
            return cpInfo.getClassPath(ClasspathInfo.PathKind.BOOT).getFlags().contains(ClassPath.Flag.INCOMPLETE) ||
607
            cpInfo.getClassPath(ClasspathInfo.PathKind.COMPILE).getFlags().contains(ClassPath.Flag.INCOMPLETE) ||
608
            cpInfo.getClassPath(ClasspathInfo.PathKind.SOURCE).getFlags().contains(ClassPath.Flag.INCOMPLETE);
609
        }
610
572
        private final class D implements Diagnostic {
611
        private final class D implements Diagnostic {
573
            
612
            
574
            private final JCDiagnostic delegate;
613
            private final JCDiagnostic delegate;
Lines 636-641 Link Here
636
            }
675
            }
637
            
676
            
638
        }
677
        }
678
679
        private static final class IncompleteClassPath implements Diagnostic<JavaFileObject> {
680
681
            private final JavaFileObject file;
682
683
            IncompleteClassPath(final JavaFileObject file) {
684
                this.file = file;
685
            }
686
687
            @Override
688
            public Kind getKind() {
689
                return Kind.ERROR;
690
            }
691
692
            @Override
693
            public JavaFileObject getSource() {
694
                return file;
695
            }
696
697
            @Override
698
            public long getPosition() {
699
                return -1;
700
            }
701
702
            @Override
703
            public long getStartPosition() {
704
                return getPosition();
705
            }
706
707
            @Override
708
            public long getEndPosition() {
709
                return getPosition();
710
            }
711
712
            @Override
713
            public long getLineNumber() {
714
                return getPosition();
715
            }
716
717
            @Override
718
            public long getColumnNumber() {
719
                return getPosition();
720
            }
721
722
            @Override
723
            public String getCode() {
724
                return "nb.classpath.incomplete";   //NOI18N
725
            }
726
727
            @Override
728
            public String getMessage(Locale locale) {
729
                return NbBundle.getMessage(
730
                    CompilationInfoImpl.class,
731
                    "ERR_IncompleteClassPath");
732
            }
733
        }
639
    }
734
    }
640
735
641
    static final class RichDiagnostic implements Diagnostic {
736
    static final class RichDiagnostic implements Diagnostic {
(-)a/maven/nbproject/project.xml (-1 / +1 lines)
Lines 104-110 Link Here
104
                    <compile-dependency/>
104
                    <compile-dependency/>
105
                    <run-dependency>
105
                    <run-dependency>
106
                        <release-version>1</release-version>
106
                        <release-version>1</release-version>
107
                        <specification-version>1.18</specification-version>
107
                        <specification-version>1.43</specification-version>
108
                    </run-dependency>
108
                    </run-dependency>
109
                </dependency>
109
                </dependency>
110
                <dependency>
110
                <dependency>
(-)a/maven/src/org/netbeans/modules/maven/classpath/AbstractProjectClassPathImpl.java (+4 lines)
Lines 141-146 Link Here
141
    protected final NbMavenProjectImpl getMavenProject() {
141
    protected final NbMavenProjectImpl getMavenProject() {
142
        return project;
142
        return project;
143
    }
143
    }
144
145
    protected final void firePropertyChange(String propName, Object oldValue, Object newValue) {
146
        support.firePropertyChange(propName, oldValue, newValue);
147
    }
144
    
148
    
145
    @Override
149
    @Override
146
    public synchronized List<PathResourceImplementation> getResources() {
150
    public synchronized List<PathResourceImplementation> getResources() {
(-)a/maven/src/org/netbeans/modules/maven/classpath/CompileClassPathImpl.java (-3 / +23 lines)
Lines 44-60 Link Here
44
44
45
import java.net.URI;
45
import java.net.URI;
46
import java.util.ArrayList;
46
import java.util.ArrayList;
47
import java.util.Collections;
48
import java.util.EnumSet;
47
import java.util.List;
49
import java.util.List;
50
import java.util.Set;
48
import org.apache.maven.artifact.Artifact;
51
import org.apache.maven.artifact.Artifact;
52
import org.netbeans.api.java.classpath.ClassPath;
49
import org.netbeans.modules.maven.NbMavenProjectImpl;
53
import org.netbeans.modules.maven.NbMavenProjectImpl;
54
import org.netbeans.spi.java.classpath.FlaggedClassPathImplementation;
50
import org.openide.util.Utilities;
55
import org.openide.util.Utilities;
51
56
52
/**
57
/**
53
 *
58
 *
54
 * @author  Milos Kleint
59
 * @author  Milos Kleint
55
 */
60
 */
56
class CompileClassPathImpl extends AbstractProjectClassPathImpl {
61
class CompileClassPathImpl extends AbstractProjectClassPathImpl implements FlaggedClassPathImplementation {
57
    
62
63
    private volatile boolean incomplete;
64
58
    /** Creates a new instance of SrcClassPathImpl */
65
    /** Creates a new instance of SrcClassPathImpl */
59
    public CompileClassPathImpl(NbMavenProjectImpl proj) {
66
    public CompileClassPathImpl(NbMavenProjectImpl proj) {
60
        super(proj);
67
        super(proj);
Lines 67-82 Link Here
67
        //except for the fact that multiproject references are not redirected to their respective
74
        //except for the fact that multiproject references are not redirected to their respective
68
        // output folders.. we lways retrieve stuff from local repo..
75
        // output folders.. we lways retrieve stuff from local repo..
69
        List<Artifact> arts = getMavenProject().getOriginalMavenProject().getCompileArtifacts();
76
        List<Artifact> arts = getMavenProject().getOriginalMavenProject().getCompileArtifacts();
77
        boolean broken = false;
70
        for (Artifact art : arts) {
78
        for (Artifact art : arts) {
71
            if (art.getFile() != null) {
79
            if (art.getFile() != null) {
72
                lst.add(Utilities.toURI(art.getFile()));
80
                lst.add(Utilities.toURI(art.getFile()));
81
                broken |= !art.getFile().exists();
73
            } else {
82
            } else {
74
              //NOPMD   //null means dependencies were not resolved..
83
              //NOPMD   //null means dependencies were not resolved..
84
                broken = true;
75
            } 
85
            } 
76
        }
86
        }
87
        if (incomplete != broken) {
88
            incomplete = broken;
89
            firePropertyChange(PROP_FLAGS, null, null);
90
        }
77
        URI[] uris = new URI[lst.size()];
91
        URI[] uris = new URI[lst.size()];
78
        uris = lst.toArray(uris);
92
        uris = lst.toArray(uris);
79
        return uris;
93
        return uris;
80
    }
94
    }
81
    
95
96
    @Override
97
    public Set<ClassPath.Flag> getFlags() {
98
        return incomplete ?
99
            EnumSet.of(ClassPath.Flag.INCOMPLETE) :
100
            Collections.<ClassPath.Flag>emptySet();
101
    }
82
}
102
}
(-)a/maven/src/org/netbeans/modules/maven/classpath/TestCompileClassPathImpl.java (-4 / +24 lines)
Lines 44-60 Link Here
44
44
45
import java.net.URI;
45
import java.net.URI;
46
import java.util.ArrayList;
46
import java.util.ArrayList;
47
import java.util.Collections;
48
import java.util.EnumSet;
47
import java.util.List;
49
import java.util.List;
50
import java.util.Set;
48
import org.apache.maven.artifact.Artifact;
51
import org.apache.maven.artifact.Artifact;
52
import org.netbeans.api.java.classpath.ClassPath;
49
import org.netbeans.modules.maven.NbMavenProjectImpl;
53
import org.netbeans.modules.maven.NbMavenProjectImpl;
54
import org.netbeans.spi.java.classpath.FlaggedClassPathImplementation;
50
import org.openide.util.Utilities;
55
import org.openide.util.Utilities;
51
56
52
/**
57
/**
53
 *
58
 *
54
 * @author  Milos Kleint 
59
 * @author  Milos Kleint 
55
 */
60
 */
56
class TestCompileClassPathImpl extends AbstractProjectClassPathImpl {
61
class TestCompileClassPathImpl extends AbstractProjectClassPathImpl implements FlaggedClassPathImplementation {
57
    
62
63
    private volatile boolean incomplete;
64
58
    /** Creates a new instance of SrcClassPathImpl */
65
    /** Creates a new instance of SrcClassPathImpl */
59
    public TestCompileClassPathImpl(NbMavenProjectImpl proj) {
66
    public TestCompileClassPathImpl(NbMavenProjectImpl proj) {
60
        super(proj);
67
        super(proj);
Lines 69-85 Link Here
69
        //except for the fact that multiproject references are not redirected to their respective
76
        //except for the fact that multiproject references are not redirected to their respective
70
        // output folders.. we lways retrieve stuff from local repo..
77
        // output folders.. we lways retrieve stuff from local repo..
71
        List<Artifact> arts = getMavenProject().getOriginalMavenProject().getTestArtifacts();
78
        List<Artifact> arts = getMavenProject().getOriginalMavenProject().getTestArtifacts();
79
        boolean broken = false;
72
        for (Artifact art : arts) {
80
        for (Artifact art : arts) {
73
            if (art.getFile() != null) {
81
            if (art.getFile() != null) {
74
                lst.add(Utilities.toURI(art.getFile()));
82
                lst.add(Utilities.toURI(art.getFile()));
83
                broken |= !art.getFile().exists();
75
            } else { //NOPMD
84
            } else { //NOPMD
76
                //null means dependencies were not resolved..
85
                //null means dependencies were not resolved..
77
            } 
86
                broken = true;
87
            }
88
        }
89
        if (incomplete != broken) {
90
            incomplete = broken;
91
            firePropertyChange(PROP_FLAGS, null, null);
78
        }
92
        }
79
        lst.add(0, Utilities.toURI(getMavenProject().getProjectWatcher().getOutputDirectory(false)));
93
        lst.add(0, Utilities.toURI(getMavenProject().getProjectWatcher().getOutputDirectory(false)));
80
        URI[] uris = new URI[lst.size()];
94
        URI[] uris = new URI[lst.size()];
81
        uris = lst.toArray(uris);
95
        uris = lst.toArray(uris);
82
        return uris;
96
        return uris;
83
    }    
97
    }    
84
    
98
99
    @Override
100
    public Set<ClassPath.Flag> getFlags() {
101
        return incomplete ?
102
            EnumSet.of(ClassPath.Flag.INCOMPLETE) :
103
            Collections.<ClassPath.Flag>emptySet();
104
    }
85
}
105
}
(-)a/parsing.api/nbproject/project.xml (-1 / +1 lines)
Lines 20-26 Link Here
20
                    <compile-dependency/>
20
                    <compile-dependency/>
21
                    <run-dependency>
21
                    <run-dependency>
22
                        <release-version>1</release-version>
22
                        <release-version>1</release-version>
23
                        <specification-version>1.18</specification-version>
23
                        <specification-version>1.43</specification-version>
24
                    </run-dependency>
24
                    </run-dependency>
25
                </dependency>
25
                </dependency>
26
                <dependency>
26
                <dependency>
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/PathRegistry.java (-26 / +88 lines)
Lines 77-82 Link Here
77
import org.openide.filesystems.FileObject;
77
import org.openide.filesystems.FileObject;
78
import org.openide.filesystems.FileStateInvalidException;
78
import org.openide.filesystems.FileStateInvalidException;
79
import org.openide.filesystems.FileUtil;
79
import org.openide.filesystems.FileUtil;
80
import org.openide.filesystems.URLMapper;
80
import org.openide.util.Exceptions;
81
import org.openide.util.Exceptions;
81
import org.openide.util.Parameters;
82
import org.openide.util.Parameters;
82
import org.openide.util.RequestProcessor;
83
import org.openide.util.RequestProcessor;
Lines 541-546 Link Here
541
                url.getProtocol());
542
                url.getProtocol());
542
    }
543
    }
543
544
545
    static boolean isIncompleteClassPath(@NonNull final ClassPath cp) {
546
        return cp.getFlags().contains(ClassPath.Flag.INCOMPLETE);
547
    }
548
549
    boolean isIncompleteRoot(@NonNull final FileObject root) {
550
        Set<String> sourceIds;
551
        Set<String> libIds;
552
        Set<String> binLibIds;
553
554
        if ((sourceIds = getSourceIdsFor(root.toURL())) != null && !sourceIds.isEmpty()) {
555
            libIds = new HashSet<>();
556
            binLibIds = new HashSet<>();
557
            for(String id : sourceIds) {
558
                libIds.addAll(PathRecognizerRegistry.getDefault().getLibraryIdsForSourceId(id));
559
                binLibIds.addAll(PathRecognizerRegistry.getDefault().getBinaryLibraryIdsForSourceId(id));
560
            }
561
        } else if ((libIds = getLibraryIdsFor(root.toURL())) != null && !libIds.isEmpty()) {
562
            sourceIds = Collections.emptySet();
563
            binLibIds = new HashSet<>();
564
            for(String id : libIds) {
565
                binLibIds.addAll(PathRecognizerRegistry.getDefault().getBinaryLibraryIdsForLibraryId(id));
566
            }
567
        } else {
568
            sourceIds = PathRecognizerRegistry.getDefault().getSourceIds();
569
            libIds = new HashSet<>();
570
            binLibIds = new HashSet<>();
571
            for(String id : sourceIds) {
572
                libIds.addAll(PathRecognizerRegistry.getDefault().getLibraryIdsForSourceId(id));
573
                binLibIds.addAll(PathRecognizerRegistry.getDefault().getBinaryLibraryIdsForSourceId(id));
574
            }
575
        }
576
        assert sourceIds != null;
577
        assert libIds != null;
578
        assert binLibIds != null;
579
        return isIncompleteClassPath(root, binLibIds) ||
580
           isIncompleteClassPath(root, libIds) ||
581
           isIncompleteClassPath(root, sourceIds);
582
    }
583
584
    boolean isIncompleteRoot(@NonNull final URL root) {
585
        final FileObject rootFo = URLMapper.findFileObject(root);
586
        return rootFo == null ?
587
            false :
588
            isIncompleteRoot(rootFo);
589
    }
590
544
    @org.netbeans.api.annotations.common.SuppressWarnings(
591
    @org.netbeans.api.annotations.common.SuppressWarnings(
545
        value="DMI_COLLECTION_OF_URLS",
592
        value="DMI_COLLECTION_OF_URLS",
546
        justification="URLs have never host part")
593
        justification="URLs have never host part")
Lines 643-656 Link Here
643
        if (oldHash == null) {
690
        if (oldHash == null) {
644
            return true;
691
            return true;
645
        }
692
        }
646
        final StringBuilder newRoots = new StringBuilder();
647
        for (ClassPath.Entry e : cp.entries()) {
648
            newRoots.append(e.getURL().toExternalForm()).
649
                append(File.pathSeparatorChar);
650
        }
651
        return !Arrays.equals(
693
        return !Arrays.equals(
652
            oldHash,
694
            oldHash,
653
            toDigest(createDigest(),newRoots));
695
            toDigest(cp, createDigest()));
654
    }
696
    }
655
697
656
    @org.netbeans.api.annotations.common.SuppressWarnings(
698
    @org.netbeans.api.annotations.common.SuppressWarnings(
Lines 672-687 Link Here
672
        for (TaggedClassPath tcp : request.sourceCps) {
714
        for (TaggedClassPath tcp : request.sourceCps) {
673
            ClassPath cp = tcp.getClasspath();
715
            ClassPath cp = tcp.getClasspath();
674
            boolean isNew = request.oldCps.remove(cp) == null;
716
            boolean isNew = request.oldCps.remove(cp) == null;
675
            final StringBuilder sb = new StringBuilder();
676
            for (ClassPath.Entry entry : cp.entries()) {
717
            for (ClassPath.Entry entry : cp.entries()) {
677
                URL root = entry.getURL();
718
                URL root = entry.getURL();
678
                assert noHostPart(root) : root;
719
                assert noHostPart(root) : root;
679
                sb.append(root.toExternalForm()).
680
                   append(File.pathSeparatorChar);
681
                sourceResult.add(root);
682
                updatePathIds(root, tcp, pathIdsResult, pathIdToRootsResult);
720
                updatePathIds(root, tcp, pathIdsResult, pathIdToRootsResult);
721
                if (!isIncompleteClassPath(cp)) {
722
                    sourceResult.add(root);
723
                }
683
            }
724
            }
684
            boolean notContained = newCps.put (cp, toDigest(digest, sb)) == null;
725
            boolean notContained = newCps.put (cp, toDigest(cp,digest)) == null;
685
            if (isNew && notContained) {
726
            if (isNew && notContained) {
686
               cp.addPropertyChangeListener(request.propertyListener);
727
               cp.addPropertyChangeListener(request.propertyListener);
687
            }
728
            }
Lines 690-705 Link Here
690
        for (TaggedClassPath tcp : request.libraryCps) {
731
        for (TaggedClassPath tcp : request.libraryCps) {
691
            ClassPath cp = tcp.getClasspath();
732
            ClassPath cp = tcp.getClasspath();
692
            boolean isNew = request.oldCps.remove(cp) == null;
733
            boolean isNew = request.oldCps.remove(cp) == null;
693
            final StringBuilder sb = new StringBuilder();
694
            for (ClassPath.Entry entry : cp.entries()) {
734
            for (ClassPath.Entry entry : cp.entries()) {
695
                URL root = entry.getURL();
735
                URL root = entry.getURL();
696
                assert noHostPart(root) : root;
736
                assert noHostPart(root) : root;
697
                sb.append(root.toExternalForm()).
698
                   append(File.pathSeparatorChar);
699
                libraryResult.add(root);
700
                updatePathIds(root, tcp, pathIdsResult, pathIdToRootsResult);
737
                updatePathIds(root, tcp, pathIdsResult, pathIdToRootsResult);
738
                if (!isIncompleteClassPath(cp)) {
739
                    libraryResult.add(root);
740
                }
701
            }
741
            }
702
            boolean notContained = newCps.put (cp, toDigest(digest, sb)) == null;
742
            boolean notContained = newCps.put (cp, toDigest(cp, digest)) == null;
703
            if (isNew && notContained) {
743
            if (isNew && notContained) {
704
               cp.addPropertyChangeListener(request.propertyListener);
744
               cp.addPropertyChangeListener(request.propertyListener);
705
            }
745
            }
Lines 708-722 Link Here
708
        for (TaggedClassPath tcp : request.binaryLibraryCps) {
748
        for (TaggedClassPath tcp : request.binaryLibraryCps) {
709
            ClassPath cp = tcp.getClasspath();
749
            ClassPath cp = tcp.getClasspath();
710
            boolean isNew = request.oldCps.remove(cp) == null;
750
            boolean isNew = request.oldCps.remove(cp) == null;
711
            final StringBuilder sb = new StringBuilder();
712
            for (ClassPath.Entry entry : cp.entries()) {
751
            for (ClassPath.Entry entry : cp.entries()) {
713
                URL binRoot = entry.getURL();
752
                URL binRoot = entry.getURL();
714
                assert noHostPart(binRoot) : binRoot;
753
                assert noHostPart(binRoot) : binRoot;
715
                sb.append(binRoot.toExternalForm()).
716
                   append(File.pathSeparatorChar);
717
                if (!translatedRoots.containsKey(binRoot)) {
754
                if (!translatedRoots.containsKey(binRoot)) {
718
                    updatePathIds(binRoot, tcp, pathIdsResult, pathIdToRootsResult);
755
                    updatePathIds(binRoot, tcp, pathIdsResult, pathIdToRootsResult);
719
                    
756
720
                    SourceForBinaryQuery.Result2 sr = request.oldSR.remove (binRoot);
757
                    SourceForBinaryQuery.Result2 sr = request.oldSR.remove (binRoot);
721
                    boolean isNewSR;
758
                    boolean isNewSR;
722
                    if (sr == null) {
759
                    if (sr == null) {
Lines 732-740 Link Here
732
                    final Set<URL> cacheURLs = new LinkedHashSet<URL> (); //LinkedSet to protect against wrong SFBQ but keep ordering
769
                    final Set<URL> cacheURLs = new LinkedHashSet<URL> (); //LinkedSet to protect against wrong SFBQ but keep ordering
733
                    final Collection<? extends URL> srcRoots = getSources(sr, cacheURLs, request.unknownRoots);
770
                    final Collection<? extends URL> srcRoots = getSources(sr, cacheURLs, request.unknownRoots);
734
                    if (srcRoots.isEmpty()) {
771
                    if (srcRoots.isEmpty()) {
735
                        binaryLibraryResult.add(binRoot);
772
                        if (!isIncompleteClassPath(cp)) {
773
                            binaryLibraryResult.add(binRoot);
774
                        }
736
                    } else {
775
                    } else {
737
                        libraryResult.addAll(srcRoots);
776
                        if (!isIncompleteClassPath(cp)) {
777
                            libraryResult.addAll(srcRoots);
778
                        }
738
                        updateTranslatedPathIds(srcRoots, tcp, pathIdsResult, pathIdToRootsResult);
779
                        updateTranslatedPathIds(srcRoots, tcp, pathIdsResult, pathIdToRootsResult);
739
                    }
780
                    }
740
                    translatedRoots.put(binRoot, cacheURLs.toArray(new URL[cacheURLs.size()]));
781
                    translatedRoots.put(binRoot, cacheURLs.toArray(new URL[cacheURLs.size()]));
Lines 747-753 Link Here
747
                    }
788
                    }
748
                }
789
                }
749
            }
790
            }
750
            boolean notContained = newCps.put (cp, toDigest(digest, sb)) == null;
791
            boolean notContained = newCps.put (cp, toDigest(cp, digest)) == null;
751
            if (isNew && notContained) {
792
            if (isNew && notContained) {
752
                cp.addPropertyChangeListener(request.propertyListener);
793
                cp.addPropertyChangeListener(request.propertyListener);
753
            }
794
            }
Lines 861-868 Link Here
861
902
862
    @NonNull
903
    @NonNull
863
    private static byte[] toDigest(
904
    private static byte[] toDigest(
864
        @NonNull final MessageDigest md,
905
        @NonNull final ClassPath cp,
865
        @NonNull final StringBuilder sb) {
906
        @NonNull final MessageDigest md) {
907
        final StringBuilder sb = new StringBuilder();
908
        for (ClassPath.Flag flag : cp.getFlags()) {
909
            sb.append(flag.name()).
910
                append(File.pathSeparatorChar);
911
        }
912
        for (ClassPath.Entry e : cp.entries()) {
913
            sb.append(e.getURL().toExternalForm()).
914
                append(File.pathSeparatorChar);
915
        }
866
        try {
916
        try {
867
            return md.digest(sb.toString().getBytes());
917
            return md.digest(sb.toString().getBytes());
868
        } finally {
918
        } finally {
Lines 870-875 Link Here
870
        }
920
        }
871
    }
921
    }
872
922
923
    private static boolean isIncompleteClassPath(
924
        @NonNull final FileObject root,
925
        @NonNull final Set<String> classPathTypes) {
926
        for (String classPathType : classPathTypes) {
927
            final ClassPath cp = ClassPath.getClassPath(root, classPathType);
928
            if (cp != null && isIncompleteClassPath(cp)) {
929
                return true;
930
            }
931
        }
932
        return false;
933
    }
934
873
    @NonNull
935
    @NonNull
874
    private static MessageDigest createDigest() {
936
    private static MessageDigest createDigest() {
875
        try {
937
        try {
Lines 1188-1194 Link Here
1188
                }
1250
                }
1189
1251
1190
                String propName = evt.getPropertyName();
1252
                String propName = evt.getPropertyName();
1191
                if (ClassPath.PROP_ENTRIES.equals(propName)) {
1253
                if (ClassPath.PROP_ENTRIES.equals(propName) || ClassPath.PROP_FLAGS.equals(propName)) {
1192
                    final Object source = evt.getSource();
1254
                    final Object source = evt.getSource();
1193
                    if ((source instanceof ClassPath) &&
1255
                    if ((source instanceof ClassPath) &&
1194
                        classPathChanged((ClassPath)source)) {
1256
                        classPathChanged((ClassPath)source)) {
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java (-24 / +32 lines)
Lines 1759-1764 Link Here
1759
1759
1760
        final List<URL> deps = new LinkedList<URL>();
1760
        final List<URL> deps = new LinkedList<URL>();
1761
        final List<URL> peers = new LinkedList<URL>();
1761
        final List<URL> peers = new LinkedList<URL>();
1762
        boolean incomplete = false;
1762
        ctx.cycleDetector.push(rootURL);
1763
        ctx.cycleDetector.push(rootURL);
1763
        try {
1764
        try {
1764
            if (sourceIds == null || libraryIds == null || binaryLibraryIds == null) {
1765
            if (sourceIds == null || libraryIds == null || binaryLibraryIds == null) {
Lines 1815-1820 Link Here
1815
                    }
1816
                    }
1816
                    final ClassPath cp = ClassPath.getClassPath(rootFo, id);
1817
                    final ClassPath cp = ClassPath.getClassPath(rootFo, id);
1817
                    if (cp != null) {
1818
                    if (cp != null) {
1819
                        incomplete |= PathRegistry.isIncompleteClassPath(cp);
1818
                        for (ClassPath.Entry entry : cp.entries()) {
1820
                        for (ClassPath.Entry entry : cp.entries()) {
1819
                            if (cancelRequest.isRaised()) {
1821
                            if (cancelRequest.isRaised()) {
1820
                                return false;
1822
                                return false;
Lines 1837-1842 Link Here
1837
1839
1838
                        ClassPath cp = ClassPath.getClassPath(rootFo, id);
1840
                        ClassPath cp = ClassPath.getClassPath(rootFo, id);
1839
                        if (cp != null) {
1841
                        if (cp != null) {
1842
                            incomplete |= PathRegistry.isIncompleteClassPath(cp);
1840
                            for (ClassPath.Entry entry : cp.entries()) {
1843
                            for (ClassPath.Entry entry : cp.entries()) {
1841
                                if (cancelRequest.isRaised()) {
1844
                                if (cancelRequest.isRaised()) {
1842
                                    return false;
1845
                                    return false;
Lines 1875-1880 Link Here
1875
1878
1876
                    ClassPath cp = ClassPath.getClassPath(rootFo, id);
1879
                    ClassPath cp = ClassPath.getClassPath(rootFo, id);
1877
                    if (cp != null) {
1880
                    if (cp != null) {
1881
                        incomplete |= PathRegistry.isIncompleteClassPath(cp);
1878
                        for (ClassPath.Entry entry : cp.entries()) {
1882
                        for (ClassPath.Entry entry : cp.entries()) {
1879
                            if (cancelRequest.isRaised()) {
1883
                            if (cancelRequest.isRaised()) {
1880
                                return false;
1884
                                return false;
Lines 1958-1966 Link Here
1958
        } finally {
1962
        } finally {
1959
            ctx.cycleDetector.pop();
1963
            ctx.cycleDetector.pop();
1960
        }
1964
        }
1961
1965
        if (!incomplete) {
1962
        ctx.newRoots2Deps.put(rootURL, deps);
1966
            ctx.newRoots2Deps.put(rootURL, deps);
1963
        ctx.newRoots2Peers.put(rootURL,peers);
1967
            ctx.newRoots2Peers.put(rootURL,peers);
1968
        }
1964
        return true;
1969
        return true;
1965
    }
1970
    }
1966
1971
Lines 3610-3638 Link Here
3610
        }
3615
        }
3611
3616
3612
        protected @Override boolean getDone() {
3617
        protected @Override boolean getDone() {
3613
            updateProgress(root, false);
3618
            if (scannedRoots2Depencencies.keySet().contains(root) ||
3614
            if (scanFiles(root, files, forceRefresh, sourceForBinaryRoot)) {
3619
                !PathRegistry.getDefault().isIncompleteRoot(root)) {
3615
                // if we are refreshing a specific set of files, try to update
3620
                updateProgress(root, false);
3616
                // their document versions
3621
                if (scanFiles(root, files, forceRefresh, sourceForBinaryRoot)) {
3617
                if (!files.isEmpty()) {
3622
                    // if we are refreshing a specific set of files, try to update
3618
                    Map<FileObject, Document> f2d = getEditorFiles();
3623
                    // their document versions
3619
                    for(FileObject f : files) {
3624
                    if (!files.isEmpty()) {
3620
                        Document d = f2d.get(f);
3625
                        Map<FileObject, Document> f2d = getEditorFiles();
3621
                        if (d != null) {
3626
                        for(FileObject f : files) {
3622
                            long version = DocumentUtilities.getDocumentVersion(d);
3627
                            Document d = f2d.get(f);
3623
                            d.putProperty(PROP_LAST_INDEXED_VERSION, version);
3628
                            if (d != null) {
3624
                            d.putProperty(PROP_LAST_DIRTY_VERSION, null);
3629
                                long version = DocumentUtilities.getDocumentVersion(d);
3630
                                d.putProperty(PROP_LAST_INDEXED_VERSION, version);
3631
                                d.putProperty(PROP_LAST_DIRTY_VERSION, null);
3632
                            }
3625
                        }
3633
                        }
3626
                    }
3634
                    }
3627
                }
3635
3628
3636
                    //If the root is unknown add it into scannedRoots2Depencencies to allow listening on changes under this root
3629
                //If the root is unknown add it into scannedRoots2Depencencies to allow listening on changes under this root
3637
                    if (!scannedRoots2Depencencies.containsKey(root)) {
3630
                if (!scannedRoots2Depencencies.containsKey(root)) {
3638
                        scannedRoots2Depencencies.put(root, UNKNOWN_ROOT);
3631
                    scannedRoots2Depencencies.put(root, UNKNOWN_ROOT);
3639
                    }
3632
                }
3640
                }
3633
            }
3641
                TEST_LOGGER.log(Level.FINEST, "filelist"); //NOI18N
3634
            TEST_LOGGER.log(Level.FINEST, "filelist"); //NOI18N
3642
                refreshActiveDocument();
3635
            refreshActiveDocument();
3643
            }
3636
            return true;
3644
            return true;
3637
        }
3645
        }
3638
3646

Return to bug 246147