Lines 100-106
Link Here
|
100 |
} |
100 |
} |
101 |
return project.resolveFile(val); |
101 |
return project.resolveFile(val); |
102 |
} |
102 |
} |
103 |
public Collection<FileObject> getIncludeRoots() { |
103 |
public Collection<FileObject> getIncludeRoots(boolean minimalSubfolders) { |
104 |
File loc = getActualLocation(); |
104 |
File loc = getActualLocation(); |
105 |
if (loc != null) { |
105 |
if (loc != null) { |
106 |
FileObject fo = FileUtil.toFileObject(loc); |
106 |
FileObject fo = FileUtil.toFileObject(loc); |
Lines 258-266
Link Here
|
258 |
|
258 |
|
259 |
|
259 |
|
260 |
@Override |
260 |
@Override |
261 |
public Collection<FileObject> getIncludeRoots() { |
261 |
public Collection<FileObject> getIncludeRoots(boolean minimalSubfolders) { |
262 |
Collection<FileObject> supe = super.getIncludeRoots(); |
262 |
Collection<FileObject> supe = super.getIncludeRoots(minimalSubfolders); |
263 |
if (supe.size() == 1) { |
263 |
if (!minimalSubfolders) { |
|
|
264 |
return supe; |
265 |
} |
266 |
else if (supe.size() == 1) { |
264 |
Set<FileObject> roots = new HashSet<FileObject>(); |
267 |
Set<FileObject> roots = new HashSet<FileObject>(); |
265 |
computeIncludeExcludePatterns(); |
268 |
computeIncludeExcludePatterns(); |
266 |
for (File r : matcher.findIncludedRoots()) { |
269 |
for (File r : matcher.findIncludedRoots()) { |
Lines 296-301
Link Here
|
296 |
private final List<Root> ownedFiles = new ArrayList<Root>(); |
299 |
private final List<Root> ownedFiles = new ArrayList<Root>(); |
297 |
private final List<TypedSourceRoot> typedSourceRoots = new ArrayList<TypedSourceRoot>(); |
300 |
private final List<TypedSourceRoot> typedSourceRoots = new ArrayList<TypedSourceRoot>(); |
298 |
private int registeredRootAlgorithm; |
301 |
private int registeredRootAlgorithm; |
|
|
302 |
private boolean minimalSubfolders; |
299 |
/** |
303 |
/** |
300 |
* If not null, external roots that we registered the last time. |
304 |
* If not null, external roots that we registered the last time. |
301 |
* Used when a property change is encountered, to see if the set of external |
305 |
* Used when a property change is encountered, to see if the set of external |
Lines 513-522
Link Here
|
513 |
* given <code>SourcesHelper</code> object |
517 |
* given <code>SourcesHelper</code> object |
514 |
*/ |
518 |
*/ |
515 |
public void registerExternalRoots(int algorithm) throws IllegalArgumentException, IllegalStateException { |
519 |
public void registerExternalRoots(int algorithm) throws IllegalArgumentException, IllegalStateException { |
|
|
520 |
registerExternalRoots(algorithm, true); |
521 |
} |
522 |
|
523 |
/** |
524 |
* Register all external source or non-source roots using {@link FileOwnerQuery#markExternalOwner}. |
525 |
* <p> |
526 |
* Only roots added by {@link #addPrincipalSourceRoot} and {@link #addNonSourceRoot} |
527 |
* are considered. They are registered if (and only if) they in fact fall |
528 |
* outside of the project directory, and of course only if the folders really |
529 |
* exist on disk. Currently it is not defined when this file existence check |
530 |
* is done (e.g. when this method is first called, or periodically) or whether |
531 |
* folders which are created subsequently will be registered, so project type |
532 |
* providers are encouraged to create all desired external roots before calling |
533 |
* this method. |
534 |
* </p> |
535 |
* <p> |
536 |
* If the actual value of the location changes (due to changes being |
537 |
* fired from the property evaluator), roots which were previously internal |
538 |
* and are now external will be registered, and roots which were previously |
539 |
* external and are now internal will be unregistered. The (un-)registration |
540 |
* will be done using the same algorithm as was used initially. |
541 |
* </p> |
542 |
* <p> |
543 |
* If a minimalSubfolders is true and an explicit include list is configured |
544 |
* for a principal source root, only those subfolders which are included |
545 |
* (or folders directly containing included files) |
546 |
* will be registered, otherwise the whole source root is registered. |
547 |
* Note that the source root, or an included subfolder, will |
548 |
* be registered even if it contains excluded files or folders beneath it. |
549 |
* </p> |
550 |
* <p> |
551 |
* Calling this method causes the helper object to hold strong references to the |
552 |
* current external roots, which helps a project satisfy the requirements of |
553 |
* {@link FileOwnerQuery#EXTERNAL_ALGORITHM_TRANSIENT}. |
554 |
* </p> |
555 |
* <p> |
556 |
* You may <em>not</em> call this method inside the project's constructor, as |
557 |
* it requires the actual project to exist and be registered in {@link ProjectManager}. |
558 |
* Typically you would use {@link org.openide.util.Mutex#postWriteRequest} to run it |
559 |
* later, if you were creating the helper in your constructor, since the project construction |
560 |
* normally occurs in read access. |
561 |
* </p> |
562 |
* @param algorithm an external root registration algorithm as per |
563 |
* {@link FileOwnerQuery#markExternalOwner} |
564 |
* @param minimalSubfolders controls how the roots having an explicit include list |
565 |
* are registered. When true only those subfolders which are included |
566 |
* (or folders directly containing included files) will be registered, |
567 |
* otherwise the whole source root is registered. |
568 |
* @throws IllegalArgumentException if the algorithm is unrecognized |
569 |
* @throws IllegalStateException if this method is called more than once on a |
570 |
* given <code>SourcesHelper</code> object |
571 |
* @since 1.26 |
572 |
*/ |
573 |
public void registerExternalRoots (int algorithm, boolean minimalSubfolders) throws IllegalArgumentException, IllegalStateException { |
516 |
if (lastRegisteredRoots != null) { |
574 |
if (lastRegisteredRoots != null) { |
517 |
throw new IllegalStateException("registerExternalRoots was already called before"); // NOI18N |
575 |
throw new IllegalStateException("registerExternalRoots was already called before"); // NOI18N |
518 |
} |
576 |
} |
519 |
registeredRootAlgorithm = algorithm; |
577 |
registeredRootAlgorithm = algorithm; |
|
|
578 |
this.minimalSubfolders = minimalSubfolders; |
520 |
remarkExternalRoots(); |
579 |
remarkExternalRoots(); |
521 |
} |
580 |
} |
522 |
|
581 |
|
Lines 539-545
Link Here
|
539 |
// that was last computed, and just check if that has changed... otherwise we wind |
598 |
// that was last computed, and just check if that has changed... otherwise we wind |
540 |
// up calling APH.resolveFileObject repeatedly (for each property change) |
599 |
// up calling APH.resolveFileObject repeatedly (for each property change) |
541 |
for (Root r : allRoots) { |
600 |
for (Root r : allRoots) { |
542 |
for (FileObject loc : r.getIncludeRoots()) { |
601 |
for (FileObject loc : r.getIncludeRoots(minimalSubfolders)) { |
543 |
if (FileUtil.getRelativePath(pdir, loc) != null) { |
602 |
if (FileUtil.getRelativePath(pdir, loc) != null) { |
544 |
// Inside projdir already. Skip it. |
603 |
// Inside projdir already. Skip it. |
545 |
continue; |
604 |
continue; |