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

(-)a/java.api.common/manifest.mf (-1 / +1 lines)
Lines 1-4 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.java.api.common/0
2
OpenIDE-Module: org.netbeans.modules.java.api.common/0
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.34
4
OpenIDE-Module-Specification-Version: 1.35
(-)a/java.api.common/nbproject/project.xml (-1 / +1 lines)
Lines 99-105 Link Here
99
                    <compile-dependency/>
99
                    <compile-dependency/>
100
                    <run-dependency>
100
                    <run-dependency>
101
                        <release-version>1</release-version>
101
                        <release-version>1</release-version>
102
                        <specification-version>1.41</specification-version>
102
                        <specification-version>1.47</specification-version>
103
                    </run-dependency>
103
                    </run-dependency>
104
                </dependency>
104
                </dependency>
105
                <dependency>
105
                <dependency>
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/queries/QuerySupport.java (-9 / +24 lines)
Lines 42-53 Link Here
42
42
43
package org.netbeans.modules.java.api.common.queries;
43
package org.netbeans.modules.java.api.common.queries;
44
44
45
import java.io.File;
45
import javax.swing.Icon;
46
import javax.swing.Icon;
46
import org.netbeans.api.annotations.common.NonNull;
47
import org.netbeans.api.annotations.common.NonNull;
47
import org.netbeans.api.annotations.common.NullAllowed;
48
import org.netbeans.api.annotations.common.NullAllowed;
48
import org.netbeans.api.project.Sources;
49
import org.netbeans.api.project.Sources;
49
import org.netbeans.modules.java.api.common.SourceRoots;
50
import org.netbeans.modules.java.api.common.SourceRoots;
50
import org.netbeans.api.java.queries.AnnotationProcessingQuery.Result;
51
import org.netbeans.api.project.Project;
51
import org.netbeans.api.project.Project;
52
import org.netbeans.api.project.ProjectInformation;
52
import org.netbeans.api.project.ProjectInformation;
53
import org.netbeans.modules.java.api.common.Roots;
53
import org.netbeans.modules.java.api.common.Roots;
Lines 58-70 Link Here
58
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
58
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
59
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
59
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
60
import org.netbeans.spi.java.queries.SourceLevelQueryImplementation2;
60
import org.netbeans.spi.java.queries.SourceLevelQueryImplementation2;
61
import org.netbeans.spi.project.SourceGroupModifierImplementation;
62
import org.netbeans.spi.project.support.ant.AntProjectHelper;
61
import org.netbeans.spi.project.support.ant.AntProjectHelper;
63
import org.netbeans.spi.project.support.ant.AntProjectListener;
62
import org.netbeans.spi.project.support.ant.AntProjectListener;
64
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
63
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
65
import org.netbeans.spi.queries.FileBuiltQueryImplementation;
64
import org.netbeans.spi.queries.FileBuiltQueryImplementation;
66
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
65
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
67
import org.netbeans.spi.queries.SharabilityQueryImplementation;
66
import org.netbeans.spi.queries.SharabilityQueryImplementation;
67
import org.netbeans.spi.queries.SharabilityQueryImplementation2;
68
import org.openide.loaders.CreateFromTemplateAttributesProvider;
68
import org.openide.loaders.CreateFromTemplateAttributesProvider;
69
import org.openide.util.Parameters;
69
import org.openide.util.Parameters;
70
import org.openide.util.WeakListeners;
70
import org.openide.util.WeakListeners;
Lines 180-188 Link Here
180
     * @param testRoots a list of test roots to treat as sharable, may be null if the project does not support tests
180
     * @param testRoots a list of test roots to treat as sharable, may be null if the project does not support tests
181
     * @param additionalSourceRoots additional paths to treat as sharable (just pure property names, do not
181
     * @param additionalSourceRoots additional paths to treat as sharable (just pure property names, do not
182
     *          use <i>${</i> and <i>}</i> characters). Can be <code>null</code>.
182
     *          use <i>${</i> and <i>}</i> characters). Can be <code>null</code>.
183
     * @return a {@link SharabilityQueryImplementation} to provide information about files sharability.
183
     * @return a query to provide information about files sharability.
184
     * @since 1.35
184
     */
185
     */
185
    public static SharabilityQueryImplementation createSharabilityQuery(
186
    public static SharabilityQueryImplementation2 createSharabilityQuery2(
186
            final @NonNull AntProjectHelper helper,
187
            final @NonNull AntProjectHelper helper,
187
            final @NonNull PropertyEvaluator evaluator,
188
            final @NonNull PropertyEvaluator evaluator,
188
            final @NonNull SourceRoots srcRoots,
189
            final @NonNull SourceRoots srcRoots,
Lines 194-206 Link Here
194
195
195
        return new SharabilityQueryImpl(helper, evaluator, srcRoots, testRoots, additionalSourceRoots);
196
        return new SharabilityQueryImpl(helper, evaluator, srcRoots, testRoots, additionalSourceRoots);
196
    }
197
    }
197
198
    /**
198
    /**
199
     * Create a new query to provide information about files sharability without any additional source roots. See
199
     * @deprecated since 1.35 use {@link #createSharabilityQuery2} instead
200
     * {@link #createSharabilityQuery(AntProjectHelper, PropertyEvaluator, SourceRoots, SourceRoots, String...)
201
     * createSharabilityQuery()}
202
     * for more information.
203
     */
200
     */
201
    @Deprecated
202
    public static SharabilityQueryImplementation createSharabilityQuery(
203
            final @NonNull AntProjectHelper helper,
204
            final @NonNull PropertyEvaluator evaluator,
205
            final @NonNull SourceRoots srcRoots,
206
            final @NullAllowed SourceRoots testRoots,
207
            final @NullAllowed String... additionalSourceRoots) {
208
        final SharabilityQueryImplementation2 sq2 = createSharabilityQuery2(helper, evaluator, srcRoots, testRoots, additionalSourceRoots);
209
        return new SharabilityQueryImplementation() {
210
            @Override public int getSharability(File file) {
211
                return sq2.getSharability(file.toURI()).ordinal();
212
            }
213
        };
214
    }
215
    /**
216
     * @deprecated since 1.35 use {@link #createSharabilityQuery2} instead
217
     */
218
    @Deprecated
204
    public static SharabilityQueryImplementation createSharabilityQuery(AntProjectHelper helper,
219
    public static SharabilityQueryImplementation createSharabilityQuery(AntProjectHelper helper,
205
            PropertyEvaluator evaluator, SourceRoots srcRoots, SourceRoots testRoots) {
220
            PropertyEvaluator evaluator, SourceRoots srcRoots, SourceRoots testRoots) {
206
221
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/queries/SharabilityQueryImpl.java (-10 / +10 lines)
Lines 45-76 Link Here
45
package org.netbeans.modules.java.api.common.queries;
45
package org.netbeans.modules.java.api.common.queries;
46
46
47
import org.netbeans.modules.java.api.common.SourceRoots;
47
import org.netbeans.modules.java.api.common.SourceRoots;
48
import java.io.File;
49
import java.beans.PropertyChangeEvent;
48
import java.beans.PropertyChangeEvent;
50
import java.beans.PropertyChangeListener;
49
import java.beans.PropertyChangeListener;
50
import java.net.URI;
51
import java.util.ArrayList;
51
import java.util.ArrayList;
52
import java.util.Arrays;
52
import java.util.Arrays;
53
import java.util.Collections;
53
import java.util.Collections;
54
import java.util.List;
54
import java.util.List;
55
import org.openide.util.Mutex;
55
import org.openide.util.Mutex;
56
import org.netbeans.api.project.ProjectManager;
56
import org.netbeans.api.project.ProjectManager;
57
import org.netbeans.api.queries.SharabilityQuery;
57
import org.netbeans.spi.queries.SharabilityQueryImplementation;
58
import org.netbeans.spi.queries.SharabilityQueryImplementation;
58
import org.netbeans.spi.project.support.ant.AntProjectHelper;
59
import org.netbeans.spi.project.support.ant.AntProjectHelper;
59
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
60
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
61
import org.netbeans.spi.queries.SharabilityQueryImplementation2;
60
62
61
/**
63
/**
62
 * Default implementation of {@link SharabilityQueryImplementation} which is capable to take more sources.
64
 * Default implementation of {@link SharabilityQueryImplementation} which is capable to take more sources.
63
 * It listens to the changes in particular property values.
65
 * It listens to the changes in particular property values.
64
 * @author Tomas Zezula, Tomas Mysik
66
 * @author Tomas Zezula, Tomas Mysik
65
 */
67
 */
66
class SharabilityQueryImpl implements SharabilityQueryImplementation, PropertyChangeListener {
68
class SharabilityQueryImpl implements SharabilityQueryImplementation2, PropertyChangeListener {
67
69
68
    private final AntProjectHelper helper;
70
    private final AntProjectHelper helper;
69
    private final PropertyEvaluator evaluator;
71
    private final PropertyEvaluator evaluator;
70
    private final SourceRoots srcRoots;
72
    private final SourceRoots srcRoots;
71
    private final SourceRoots testRoots;
73
    private final SourceRoots testRoots;
72
    private final List<String> additionalSourceRoots;
74
    private final List<String> additionalSourceRoots;
73
    private SharabilityQueryImplementation delegate;
75
    private SharabilityQueryImplementation2 delegate;
74
76
75
    @SuppressWarnings("LeakingThisInConstructor")
77
    @SuppressWarnings("LeakingThisInConstructor")
76
    public SharabilityQueryImpl(AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots srcRoots,
78
    public SharabilityQueryImpl(AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots srcRoots,
Lines 94-104 Link Here
94
        }
96
        }
95
    }
97
    }
96
98
97
    @Override
99
    @Override public SharabilityQuery.Sharability getSharability(final URI file) {
98
    public int getSharability(final File file) {
100
        return ProjectManager.mutex().readAccess(new Mutex.Action<SharabilityQuery.Sharability>() {
99
        return ProjectManager.mutex().readAccess(new Mutex.Action<Integer>() {
101
            @Override public SharabilityQuery.Sharability run() {
100
            @Override
101
            public Integer run() {
102
                synchronized (SharabilityQueryImpl.this) {
102
                synchronized (SharabilityQueryImpl.this) {
103
                    if (delegate == null) {
103
                    if (delegate == null) {
104
                        delegate = createDelegate();
104
                        delegate = createDelegate();
Lines 118-124 Link Here
118
        }
118
        }
119
    }
119
    }
120
120
121
    private SharabilityQueryImplementation createDelegate() {
121
    private SharabilityQueryImplementation2 createDelegate() {
122
        String[] srcProps = srcRoots.getRootProperties();
122
        String[] srcProps = srcRoots.getRootProperties();
123
        String[] testProps = testRoots == null ? new String[0] : testRoots.getRootProperties();
123
        String[] testProps = testRoots == null ? new String[0] : testRoots.getRootProperties();
124
        String[] buildDirectories = new String[] {"${dist.dir}", "${build.dir}"}; // NOI18N
124
        String[] buildDirectories = new String[] {"${dist.dir}", "${build.dir}"}; // NOI18N
Lines 136-141 Link Here
136
        }
136
        }
137
        props.addAll(additionalSourceRoots);
137
        props.addAll(additionalSourceRoots);
138
138
139
        return helper.createSharabilityQuery(evaluator, props.toArray(new String[props.size()]), buildDirectories);
139
        return helper.createSharabilityQuery2(evaluator, props.toArray(new String[props.size()]), buildDirectories);
140
    }
140
    }
141
}
141
}
(-)a/java.j2seproject/nbproject/project.xml (-2 / +2 lines)
Lines 141-148 Link Here
141
                    <build-prerequisite/>
141
                    <build-prerequisite/>
142
                    <compile-dependency/>
142
                    <compile-dependency/>
143
                    <run-dependency>
143
                    <run-dependency>
144
                        <release-version>0-1</release-version>
144
                        <release-version>1</release-version>
145
                        <specification-version>1.26</specification-version>
145
                        <specification-version>1.35</specification-version>
146
                    </run-dependency>
146
                    </run-dependency>
147
                </dependency>
147
                </dependency>
148
                <dependency>
148
                <dependency>
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java (-2 / +1 lines)
Lines 72-78 Link Here
72
import javax.xml.parsers.DocumentBuilder;
72
import javax.xml.parsers.DocumentBuilder;
73
import javax.xml.parsers.DocumentBuilderFactory;
73
import javax.xml.parsers.DocumentBuilderFactory;
74
import javax.xml.parsers.ParserConfigurationException;
74
import javax.xml.parsers.ParserConfigurationException;
75
import org.netbeans.api.annotations.common.NonNull;
76
import org.netbeans.api.java.classpath.ClassPath;
75
import org.netbeans.api.java.classpath.ClassPath;
77
import org.netbeans.api.java.classpath.GlobalPathRegistry;
76
import org.netbeans.api.java.classpath.GlobalPathRegistry;
78
import org.netbeans.api.java.project.JavaProjectConstants;
77
import org.netbeans.api.java.project.JavaProjectConstants;
Lines 373-379 Link Here
373
            QuerySupport.createUnitTestForSourceQuery(getSourceRoots(), getTestSourceRoots()),
372
            QuerySupport.createUnitTestForSourceQuery(getSourceRoots(), getTestSourceRoots()),
374
            QuerySupport.createSourceLevelQuery2(evaluator()),
373
            QuerySupport.createSourceLevelQuery2(evaluator()),
375
            QuerySupport.createSources(this, helper, evaluator(), getSourceRoots(), getTestSourceRoots(), Roots.nonSourceRoots(ProjectProperties.BUILD_DIR, J2SEProjectProperties.DIST_DIR)),
374
            QuerySupport.createSources(this, helper, evaluator(), getSourceRoots(), getTestSourceRoots(), Roots.nonSourceRoots(ProjectProperties.BUILD_DIR, J2SEProjectProperties.DIST_DIR)),
376
            QuerySupport.createSharabilityQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
375
            QuerySupport.createSharabilityQuery2(helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
377
            new CoSAwareFileBuiltQueryImpl(QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), this),
376
            new CoSAwareFileBuiltQueryImpl(QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), this),
378
            new RecommendedTemplatesImpl (this.updateHelper),
377
            new RecommendedTemplatesImpl (this.updateHelper),
379
            ProjectClassPathModifier.extenderForModifier(cpMod),
378
            ProjectClassPathModifier.extenderForModifier(cpMod),
(-)a/project.ant/apichanges.xml (+21 lines)
Lines 108-113 Link Here
108
108
109
    <changes>
109
    <changes>
110
110
111
        <change id="createSharabilityQuery2">
112
            <api name="general"/>
113
            <summary>Added <code>AntProjectHelper.createSharabilityQuery2</code></summary>
114
            <version major="1" minor="47"/>
115
            <date year="2012" month="1" day="20"/>
116
            <author login="jglick"/>
117
            <compatibility addition="yes" deprecation="yes">
118
                <p>
119
                    Project types using <code>AntProjectHelper.createSharabilityQuery</code> should switch to the new method.
120
                </p>
121
            </compatibility>
122
            <description>
123
                <p>
124
                   <code>AntProjectHelper.createSharabilityQuery2</code> was introduced
125
                   to avoid the deprecated <code>SharabilityQueryImplementation</code>.
126
                </p>
127
            </description>
128
            <class package="org.netbeans.spi.project.support.ant" name="AntProjectHelper"/>
129
            <issue number="207288"/>
130
        </change>
131
111
        <change id="ReferenceHelper-getLibraryChooserImportHandler-url">
132
        <change id="ReferenceHelper-getLibraryChooserImportHandler-url">
112
            <api name="general"/>
133
            <api name="general"/>
113
            <summary>Added <code>getLibraryChooserImportHandler</code> method into <code>ReferenceHelper</code> accepting <code>URL</code></summary>
134
            <summary>Added <code>getLibraryChooserImportHandler</code> method into <code>ReferenceHelper</code> accepting <code>URL</code></summary>
(-)a/project.ant/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.project.ant/1
2
OpenIDE-Module: org.netbeans.modules.project.ant/1
3
OpenIDE-Module-Specification-Version: 1.46
3
OpenIDE-Module-Specification-Version: 1.47
4
OpenIDE-Module-Layer: org/netbeans/modules/project/ant/resources/mf-layer.xml
4
OpenIDE-Module-Layer: org/netbeans/modules/project/ant/resources/mf-layer.xml
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bundle.properties
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bundle.properties
6
OpenIDE-Module-Install: org/netbeans/modules/project/ant/AntProjectModule.class
6
OpenIDE-Module-Install: org/netbeans/modules/project/ant/AntProjectModule.class
(-)a/project.ant/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java (-4 / +18 lines)
Lines 74-79 Link Here
74
import org.netbeans.spi.project.ProjectState;
74
import org.netbeans.spi.project.ProjectState;
75
import org.netbeans.spi.queries.FileBuiltQueryImplementation;
75
import org.netbeans.spi.queries.FileBuiltQueryImplementation;
76
import org.netbeans.spi.queries.SharabilityQueryImplementation;
76
import org.netbeans.spi.queries.SharabilityQueryImplementation;
77
import org.netbeans.spi.queries.SharabilityQueryImplementation2;
77
import org.openide.ErrorManager;
78
import org.openide.ErrorManager;
78
import org.openide.filesystems.FileAlreadyLockedException;
79
import org.openide.filesystems.FileAlreadyLockedException;
79
import org.openide.filesystems.FileAttributeEvent;
80
import org.openide.filesystems.FileAttributeEvent;
Lines 1153-1161 Link Here
1153
     * Typical usage would be:
1154
     * Typical usage would be:
1154
     * </p>
1155
     * </p>
1155
     * <pre>
1156
     * <pre>
1156
     * helper.createSharabilityQuery(helper.getStandardPropertyEvaluator(),
1157
     * helper.createSharabilityQuery2(helper.getStandardPropertyEvaluator(),
1157
     *                               new String[] {"${src.dir}", "${test.src.dir}"},
1158
     *                                new String[] {"${src.dir}", "${test.src.dir}"},
1158
     *                               new String[] {"${build.dir}", "${dist.dir}"})
1159
     *                                new String[] {"${build.dir}", "${dist.dir}"})
1159
     * </pre>
1160
     * </pre>
1160
     * <p>
1161
     * <p>
1161
     * A quick rule of thumb is that the include list should contain any
1162
     * A quick rule of thumb is that the include list should contain any
Lines 1180-1187 Link Here
1180
     * @param buildDirectories a list of paths to treat as not sharable
1181
     * @param buildDirectories a list of paths to treat as not sharable
1181
     * @return a sharability query implementation suitable for the project lookup
1182
     * @return a sharability query implementation suitable for the project lookup
1182
     * @see Project#getLookup
1183
     * @see Project#getLookup
1184
     * @since 1.47
1183
     */
1185
     */
1184
    public SharabilityQueryImplementation createSharabilityQuery(PropertyEvaluator eval, String[] sourceRoots, String[] buildDirectories) {
1186
    public SharabilityQueryImplementation2 createSharabilityQuery2(PropertyEvaluator eval, String[] sourceRoots, String[] buildDirectories) {
1185
        String[] includes = new String[sourceRoots.length + 1];
1187
        String[] includes = new String[sourceRoots.length + 1];
1186
        System.arraycopy(sourceRoots, 0, includes, 0, sourceRoots.length);
1188
        System.arraycopy(sourceRoots, 0, includes, 0, sourceRoots.length);
1187
        includes[sourceRoots.length] = ""; // NOI18N
1189
        includes[sourceRoots.length] = ""; // NOI18N
Lines 1190-1195 Link Here
1190
        excludes[buildDirectories.length] = "nbproject/private"; // NOI18N
1192
        excludes[buildDirectories.length] = "nbproject/private"; // NOI18N
1191
        return new SharabilityQueryImpl(this, eval, includes, excludes);
1193
        return new SharabilityQueryImpl(this, eval, includes, excludes);
1192
    }
1194
    }
1195
    /**
1196
     * @deprecated since 1.47 use {@link #createSharabilityQuery2} instead
1197
     */
1198
    @Deprecated
1199
    public SharabilityQueryImplementation createSharabilityQuery(PropertyEvaluator eval, String[] sourceRoots, String[] buildDirectories) {
1200
        final SharabilityQueryImplementation2 sq2 = createSharabilityQuery2(eval, sourceRoots, buildDirectories);
1201
        return new SharabilityQueryImplementation() {
1202
            @Override public int getSharability(File file) {
1203
                return sq2.getSharability(file.toURI()).ordinal();
1204
            }
1205
        };
1206
    }
1193
    
1207
    
1194
    /**
1208
    /**
1195
     * Get a property provider which defines <code>basedir</code> according to
1209
     * Get a property provider which defines <code>basedir</code> according to
(-)a/project.ant/src/org/netbeans/spi/project/support/ant/SharabilityQueryImpl.java (-9 / +11 lines)
Lines 47-64 Link Here
47
import java.beans.PropertyChangeEvent;
47
import java.beans.PropertyChangeEvent;
48
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyChangeListener;
49
import java.io.File;
49
import java.io.File;
50
import java.net.URI;
50
import java.util.ArrayList;
51
import java.util.ArrayList;
51
import java.util.List;
52
import java.util.List;
52
import org.netbeans.api.queries.SharabilityQuery;
53
import org.netbeans.api.queries.SharabilityQuery;
53
import org.netbeans.modules.project.ant.ProjectLibraryProvider;
54
import org.netbeans.modules.project.ant.ProjectLibraryProvider;
54
import org.netbeans.spi.queries.SharabilityQueryImplementation;
55
import org.netbeans.spi.queries.SharabilityQueryImplementation2;
55
import org.openide.util.WeakListeners;
56
import org.openide.util.WeakListeners;
56
57
57
/**
58
/**
58
 * Standard impl of {@link SharabilityQueryImplementation}.
59
 * Standard impl of {@link SharabilityQueryImplementation2}.
59
 * @author Jesse Glick
60
 * @author Jesse Glick
60
 */
61
 */
61
final class SharabilityQueryImpl implements SharabilityQueryImplementation, PropertyChangeListener, AntProjectListener {
62
final class SharabilityQueryImpl implements SharabilityQueryImplementation2, PropertyChangeListener, AntProjectListener {
62
63
63
    private final AntProjectHelper h;
64
    private final AntProjectHelper h;
64
    private final PropertyEvaluator eval;
65
    private final PropertyEvaluator eval;
Lines 105-119 Link Here
105
        // XXX should remove overlaps somehow
106
        // XXX should remove overlaps somehow
106
        return result.toArray(new String[result.size()]);
107
        return result.toArray(new String[result.size()]);
107
    }
108
    }
108
    
109
109
    public synchronized int getSharability(File file) {
110
    @Override public SharabilityQuery.Sharability getSharability(URI uri) {
110
        String path = file.getAbsolutePath();
111
        // XXX might be more efficient to precompute URIs for includePaths and excludePaths
112
        String path = new File(uri).getAbsolutePath();
111
        if (contains(path, excludePaths, false)) {
113
        if (contains(path, excludePaths, false)) {
112
            return SharabilityQuery.NOT_SHARABLE;
114
            return SharabilityQuery.Sharability.NOT_SHARABLE;
113
        }
115
        }
114
        return contains(path, includePaths, false) ?
116
        return contains(path, includePaths, false) ?
115
            (contains(path, excludePaths, true) ? SharabilityQuery.MIXED : SharabilityQuery.SHARABLE) :
117
            (contains(path, excludePaths, true) ? SharabilityQuery.Sharability.MIXED : SharabilityQuery.Sharability.SHARABLE) :
116
            SharabilityQuery.UNKNOWN;
118
            SharabilityQuery.Sharability.UNKNOWN;
117
    }
119
    }
118
    
120
    
119
    /**
121
    /**
(-)a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java (-1 / +1 lines)
Lines 189-195 Link Here
189
                genFilesHelper,
189
                genFilesHelper,
190
                aux,
190
                aux,
191
                helper.createCacheDirectoryProvider(),
191
                helper.createCacheDirectoryProvider(),
192
                helper.createSharabilityQuery(helper.getStandardPropertyEvaluator(), new String[0], new String[0]),
192
                helper.createSharabilityQuery2(helper.getStandardPropertyEvaluator(), new String[0], new String[0]),
193
                refHelper.createSubprojectProvider(),
193
                refHelper.createSubprojectProvider(),
194
                new TestAntArtifactProvider(),
194
                new TestAntArtifactProvider(),
195
                new ProjectXmlSavedHook() {
195
                new ProjectXmlSavedHook() {
(-)a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/SharabilityQueryImplTest.java (-39 / +40 lines)
Lines 45-55 Link Here
45
package org.netbeans.spi.project.support.ant;
45
package org.netbeans.spi.project.support.ant;
46
46
47
import java.io.File;
47
import java.io.File;
48
import java.net.URI;
48
import org.netbeans.api.project.ProjectManager;
49
import org.netbeans.api.project.ProjectManager;
49
import org.netbeans.api.project.TestUtil;
50
import org.netbeans.api.project.TestUtil;
50
import org.netbeans.api.queries.SharabilityQuery;
51
import org.netbeans.api.queries.SharabilityQuery;
51
import org.netbeans.junit.NbTestCase;
52
import org.netbeans.junit.NbTestCase;
52
import org.netbeans.spi.queries.SharabilityQueryImplementation;
53
import org.netbeans.spi.queries.SharabilityQueryImplementation2;
53
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileUtil;
55
import org.openide.filesystems.FileUtil;
55
import org.openide.util.test.MockLookup;
56
import org.openide.util.test.MockLookup;
Lines 67-73 Link Here
67
    /** Location of top of testing dir (contains projdir and external). */
68
    /** Location of top of testing dir (contains projdir and external). */
68
    private File scratchF;
69
    private File scratchF;
69
    /** Tested impl. */
70
    /** Tested impl. */
70
    private SharabilityQueryImplementation sqi;
71
    private SharabilityQueryImplementation2 sqi;
71
    
72
    
72
    protected void setUp() throws Exception {
73
    protected void setUp() throws Exception {
73
        super.setUp();
74
        super.setUp();
Lines 88-152 Link Here
88
        props.setProperty("build3.dir", new File(externalF, "build").getAbsolutePath());
89
        props.setProperty("build3.dir", new File(externalF, "build").getAbsolutePath());
89
        h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
90
        h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
90
        ProjectManager.getDefault().saveProject(ProjectManager.getDefault().findProject(projdir));
91
        ProjectManager.getDefault().saveProject(ProjectManager.getDefault().findProject(projdir));
91
        sqi = h.createSharabilityQuery(h.getStandardPropertyEvaluator(), new String[] {"${src.dir}", "${src2.dir}"},
92
        sqi = h.createSharabilityQuery2(h.getStandardPropertyEvaluator(), new String[] {"${src.dir}", "${src2.dir}"},
92
                                       new String[] {"${build.dir}", "${build2.dir}", "${build3.dir}", "${dist.dir}"});
93
                                       new String[] {"${build.dir}", "${build2.dir}", "${build3.dir}", "${dist.dir}"});
93
    }
94
    }
94
    
95
    
95
    private File file(String path) {
96
    private URI file(String path) {
96
        return new File(scratchF, path.replace('/', File.separatorChar));
97
        return new File(scratchF, path.replace('/', File.separatorChar)).toURI();
97
    }
98
    }
98
    
99
    
99
    public void testBasicIncludesExcludes() throws Exception {
100
    public void testBasicIncludesExcludes() throws Exception {
100
        assertEquals("project directory is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir")));
101
        assertEquals("project directory is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir")));
101
        assertEquals("build.xml is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/build.xml")));
102
        assertEquals("build.xml is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/build.xml")));
102
        assertEquals("src/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src")));
103
        assertEquals("src/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src")));
103
        assertEquals("src/org/foo/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/org/foo")));
104
        assertEquals("src/org/foo/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/org/foo")));
104
        assertEquals("src/org/foo/Foo.java is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/Foo.java")));
105
        assertEquals("src/org/foo/Foo.java is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/Foo.java")));
105
        assertEquals("nbproject/ is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir/nbproject")));
106
        assertEquals("nbproject/ is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir/nbproject")));
106
        assertEquals("nbproject/project.xml is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/nbproject/project.xml")));
107
        assertEquals("nbproject/project.xml is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/nbproject/project.xml")));
107
        assertEquals("nbproject/private/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private")));
108
        assertEquals("nbproject/private/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private")));
108
        assertEquals("nbproject/private/private.properties is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/private.properties")));
109
        assertEquals("nbproject/private/private.properties is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/private.properties")));
109
        assertEquals("build/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build")));
110
        assertEquals("build/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build")));
110
        assertEquals("build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/classes/org/foo/Foo.class")));
111
        assertEquals("build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/classes/org/foo/Foo.class")));
111
        assertEquals("dist/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/dist")));
112
        assertEquals("dist/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/dist")));
112
    }
113
    }
113
    
114
    
114
    public void testOverlaps() throws Exception {
115
    public void testOverlaps() throws Exception {
115
        assertEquals("build/2/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2")));
116
        assertEquals("build/2/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2")));
116
        assertEquals("build/2/whatever is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/whatever")));
117
        assertEquals("build/2/whatever is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/whatever")));
117
        // overlaps in includePaths tested in basicIncludesExcludes: src is inside projdir
118
        // overlaps in includePaths tested in basicIncludesExcludes: src is inside projdir
118
    }
119
    }
119
    
120
    
120
    public void testExternalFiles() throws Exception {
121
    public void testExternalFiles() throws Exception {
121
        assertEquals("external/src is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("external/src")));
122
        assertEquals("external/src is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("external/src")));
122
        assertEquals("external/src/org/foo/Foo.java is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("external/src/org/foo/Foo.java")));
123
        assertEquals("external/src/org/foo/Foo.java is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("external/src/org/foo/Foo.java")));
123
        assertEquals("external/build is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("external/build")));
124
        assertEquals("external/build is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("external/build")));
124
        assertEquals("external/build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("external/build/classes/org/foo/Foo.class")));
125
        assertEquals("external/build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("external/build/classes/org/foo/Foo.class")));
125
    }
126
    }
126
    
127
    
127
    public void testUnknownFiles() throws Exception {
128
    public void testUnknownFiles() throws Exception {
128
        assertEquals("some other dir is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("something")));
129
        assertEquals("some other dir is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("something")));
129
        assertEquals("some other file is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("something/else")));
130
        assertEquals("some other file is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("something/else")));
130
        assertEquals("external itself is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("external")));
131
        assertEquals("external itself is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("external")));
131
    }
132
    }
132
    
133
    
133
    public void testDirNamesEndingInSlash() throws Exception {
134
    public void testDirNamesEndingInSlash() throws Exception {
134
        assertEquals("project directory is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir/")));
135
        assertEquals("project directory is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir/")));
135
        assertEquals("src/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/")));
136
        assertEquals("src/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/")));
136
        assertEquals("src/org/foo/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/")));
137
        assertEquals("src/org/foo/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/")));
137
        assertEquals("nbproject/ is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir/nbproject/")));
138
        assertEquals("nbproject/ is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir/nbproject/")));
138
        assertEquals("nbproject/private/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/")));
139
        assertEquals("nbproject/private/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/")));
139
        assertEquals("build/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/")));
140
        assertEquals("build/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/")));
140
        assertEquals("dist/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/dist/")));
141
        assertEquals("dist/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/dist/")));
141
        assertEquals("build/2/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/")));
142
        assertEquals("build/2/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/")));
142
        assertEquals("some other dir is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("something/")));
143
        assertEquals("some other dir is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("something/")));
143
        assertEquals("external itself is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("external/")));
144
        assertEquals("external itself is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("external/")));
144
        assertEquals("external/src is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("external/src/")));
145
        assertEquals("external/src is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("external/src/")));
145
        assertEquals("external/build is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("external/build/")));
146
        assertEquals("external/build is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("external/build/")));
146
    }
147
    }
147
    
148
    
148
    public void testSubprojectFiles() throws Exception {
149
    public void testSubprojectFiles() throws Exception {
149
        assertEquals("nbproject/private from a subproject is sharable as far as this impl is concerned", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/subproj/nbproject/private")));
150
        assertEquals("nbproject/private from a subproject is sharable as far as this impl is concerned", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/subproj/nbproject/private")));
150
    }
151
    }
151
    
152
    
152
    // XXX testChangedProperties
153
    // XXX testChangedProperties

Return to bug 207288