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)) { |