Lines 126-131
Link Here
|
126 |
import org.openide.util.Lookup; |
126 |
import org.openide.util.Lookup; |
127 |
import org.openide.util.Mutex.ExceptionAction; |
127 |
import org.openide.util.Mutex.ExceptionAction; |
128 |
import org.openide.util.NbBundle; |
128 |
import org.openide.util.NbBundle; |
|
|
129 |
import org.openide.util.Pair; |
129 |
import org.openide.util.Parameters; |
130 |
import org.openide.util.Parameters; |
130 |
import org.openide.util.RequestProcessor; |
131 |
import org.openide.util.RequestProcessor; |
131 |
import org.openide.util.TopologicalSortException; |
132 |
import org.openide.util.TopologicalSortException; |
Lines 626-645
Link Here
|
626 |
if (fo != null && fo.isValid()) { |
627 |
if (fo != null && fo.isValid()) { |
627 |
if (source == null || source.booleanValue()) { |
628 |
if (source == null || source.booleanValue()) { |
628 |
root = getOwningSourceRoot(fo); |
629 |
root = getOwningSourceRoot(fo); |
629 |
if (root != null && visibilitySupport.isVisible(fo, root.second)) { |
630 |
if (root != null && visibilitySupport.isVisible(fo, root.second())) { |
630 |
if (root.second == null) { |
631 |
if (root.second() == null) { |
631 |
LOGGER.log( |
632 |
LOGGER.log( |
632 |
Level.INFO, |
633 |
Level.INFO, |
633 |
"Ignoring event from non existing FileObject {0}", //NOI18N |
634 |
"Ignoring event from non existing FileObject {0}", //NOI18N |
634 |
root.first); |
635 |
root.first()); |
635 |
return; |
636 |
return; |
636 |
} |
637 |
} |
637 |
boolean sourcForBinaryRoot = sourcesForBinaryRoots.contains(root.first); |
638 |
boolean sourcForBinaryRoot = sourcesForBinaryRoots.contains(root.first()); |
638 |
ClassPath.Entry entry = sourcForBinaryRoot ? null : getClassPathEntry(root.second); |
639 |
ClassPath.Entry entry = sourcForBinaryRoot ? null : getClassPathEntry(root.second()); |
639 |
if (entry == null || entry.includes(fo)) { |
640 |
if (entry == null || entry.includes(fo)) { |
640 |
Work wrk; |
641 |
Work wrk; |
641 |
if (fo.equals(root.second)) { |
642 |
if (fo.equals(root.second())) { |
642 |
if (scannedRoots2Dependencies.get(root.first) == EMPTY_DEPS) { |
643 |
if (scannedRoots2Dependencies.get(root.first()) == EMPTY_DEPS) { |
643 |
//For first time seeing valid root do roots work to recalculate dependencies |
644 |
//For first time seeing valid root do roots work to recalculate dependencies |
644 |
wrk = new RootsWork( |
645 |
wrk = new RootsWork( |
645 |
scannedRoots2Dependencies, |
646 |
scannedRoots2Dependencies, |
Lines 649-655
Link Here
|
649 |
false, |
650 |
false, |
650 |
scannedRoots2DependenciesLamport, |
651 |
scannedRoots2DependenciesLamport, |
651 |
suspendSupport.getSuspendStatus(), |
652 |
suspendSupport.getSuspendStatus(), |
652 |
LogContext.create(LogContext.EventType.FILE, null).addRoots(Collections.singleton(root.first))); |
653 |
LogContext.create(LogContext.EventType.FILE, null).addRoots(Collections.singleton(root.first()))); |
653 |
} else { |
654 |
} else { |
654 |
//Already seen files work is enough |
655 |
//Already seen files work is enough |
655 |
final FileObject[] children = fo.getChildren(); |
656 |
final FileObject[] children = fo.getChildren(); |
Lines 657-663
Link Here
|
657 |
if (children.length > 0) { |
658 |
if (children.length > 0) { |
658 |
wrk = new FileListWork( |
659 |
wrk = new FileListWork( |
659 |
scannedRoots2Dependencies, |
660 |
scannedRoots2Dependencies, |
660 |
root.first, |
661 |
root.first(), |
661 |
c, |
662 |
c, |
662 |
false, |
663 |
false, |
663 |
false, |
664 |
false, |
Lines 666-672
Link Here
|
666 |
true, |
667 |
true, |
667 |
suspendSupport.getSuspendStatus(), |
668 |
suspendSupport.getSuspendStatus(), |
668 |
LogContext.create(LogContext.EventType.FILE, null). |
669 |
LogContext.create(LogContext.EventType.FILE, null). |
669 |
withRoot(root.first). |
670 |
withRoot(root.first()). |
670 |
addFileObjects(c)); |
671 |
addFileObjects(c)); |
671 |
} else { |
672 |
} else { |
672 |
//If no children nothing needs to be done - save some CPU time |
673 |
//If no children nothing needs to be done - save some CPU time |
Lines 677-683
Link Here
|
677 |
Collection<FileObject> c = Collections.singleton(fo); |
678 |
Collection<FileObject> c = Collections.singleton(fo); |
678 |
wrk = new FileListWork( |
679 |
wrk = new FileListWork( |
679 |
scannedRoots2Dependencies, |
680 |
scannedRoots2Dependencies, |
680 |
root.first, |
681 |
root.first(), |
681 |
c, |
682 |
c, |
682 |
false, |
683 |
false, |
683 |
false, |
684 |
false, |
Lines 686-696
Link Here
|
686 |
true, |
687 |
true, |
687 |
suspendSupport.getSuspendStatus(), |
688 |
suspendSupport.getSuspendStatus(), |
688 |
LogContext.create(LogContext.EventType.FILE, null). |
689 |
LogContext.create(LogContext.EventType.FILE, null). |
689 |
withRoot(root.first). |
690 |
withRoot(root.first()). |
690 |
addFileObjects(c)); |
691 |
addFileObjects(c)); |
691 |
} |
692 |
} |
692 |
if (wrk != null) { |
693 |
if (wrk != null) { |
693 |
eventQueue.record(FileEventLog.FileOp.CREATE, root.first, FileUtil.getRelativePath(root.second, fo), fe, wrk); |
694 |
eventQueue.record(FileEventLog.FileOp.CREATE, root.first(), FileUtil.getRelativePath(root.second(), fo), fe, wrk); |
694 |
} |
695 |
} |
695 |
processed = true; |
696 |
processed = true; |
696 |
} |
697 |
} |
Lines 699-712
Link Here
|
699 |
|
700 |
|
700 |
if (!processed && (source == null || !source.booleanValue())) { |
701 |
if (!processed && (source == null || !source.booleanValue())) { |
701 |
root = getOwningBinaryRoot(fo); |
702 |
root = getOwningBinaryRoot(fo); |
702 |
if (root != null && visibilitySupport.isVisible(fo, root.second)) { |
703 |
if (root != null && visibilitySupport.isVisible(fo, root.second())) { |
703 |
final Work wrk = new BinaryWork( |
704 |
final Work wrk = new BinaryWork( |
704 |
root.first, |
705 |
root.first(), |
705 |
suspendSupport.getSuspendStatus(), |
706 |
suspendSupport.getSuspendStatus(), |
706 |
LogContext.create(LogContext.EventType.FILE, null). |
707 |
LogContext.create(LogContext.EventType.FILE, null). |
707 |
withRoot(root.first). |
708 |
withRoot(root.first()). |
708 |
addFileObjects(Collections.singleton(fo))); |
709 |
addFileObjects(Collections.singleton(fo))); |
709 |
eventQueue.record(FileEventLog.FileOp.CREATE, root.first, null, fe, wrk); |
710 |
eventQueue.record(FileEventLog.FileOp.CREATE, root.first(), null, fe, wrk); |
710 |
processed = true; |
711 |
processed = true; |
711 |
} |
712 |
} |
712 |
} |
713 |
} |
Lines 734-753
Link Here
|
734 |
if (fo != null && fo.isValid()) { |
735 |
if (fo != null && fo.isValid()) { |
735 |
if (source == null || source.booleanValue()) { |
736 |
if (source == null || source.booleanValue()) { |
736 |
root = getOwningSourceRoot (fo); |
737 |
root = getOwningSourceRoot (fo); |
737 |
if (root != null && visibilitySupport.isVisible(fo,root.second)) { |
738 |
if (root != null && visibilitySupport.isVisible(fo,root.second())) { |
738 |
if (root.second == null) { |
739 |
if (root.second() == null) { |
739 |
LOGGER.log( |
740 |
LOGGER.log( |
740 |
Level.INFO, |
741 |
Level.INFO, |
741 |
"Ignoring event from non existing FileObject {0}", //NOI18N |
742 |
"Ignoring event from non existing FileObject {0}", //NOI18N |
742 |
root.first); |
743 |
root.first()); |
743 |
return; |
744 |
return; |
744 |
} |
745 |
} |
745 |
boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root.first); |
746 |
boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root.first()); |
746 |
ClassPath.Entry entry = sourceForBinaryRoot ? null : getClassPathEntry(root.second); |
747 |
ClassPath.Entry entry = sourceForBinaryRoot ? null : getClassPathEntry(root.second()); |
747 |
if (entry == null || entry.includes(fo)) { |
748 |
if (entry == null || entry.includes(fo)) { |
748 |
final Work wrk = new FileListWork( |
749 |
final Work wrk = new FileListWork( |
749 |
scannedRoots2Dependencies, |
750 |
scannedRoots2Dependencies, |
750 |
root.first, |
751 |
root.first(), |
751 |
Collections.singleton(fo), |
752 |
Collections.singleton(fo), |
752 |
false, |
753 |
false, |
753 |
false, |
754 |
false, |
Lines 756-764
Link Here
|
756 |
true, |
757 |
true, |
757 |
suspendSupport.getSuspendStatus(), |
758 |
suspendSupport.getSuspendStatus(), |
758 |
LogContext.create(LogContext.EventType.FILE, null). |
759 |
LogContext.create(LogContext.EventType.FILE, null). |
759 |
withRoot(root.first). |
760 |
withRoot(root.first()). |
760 |
addFiles(Collections.singleton(fo.toURL()))); |
761 |
addFiles(Collections.singleton(fo.toURL()))); |
761 |
eventQueue.record(FileEventLog.FileOp.CREATE, root.first, FileUtil.getRelativePath(root.second, fo), fe, wrk); |
762 |
eventQueue.record(FileEventLog.FileOp.CREATE, root.first(), FileUtil.getRelativePath(root.second(), fo), fe, wrk); |
762 |
processed = true; |
763 |
processed = true; |
763 |
} |
764 |
} |
764 |
} |
765 |
} |
Lines 766-779
Link Here
|
766 |
|
767 |
|
767 |
if (!processed && (source == null || !source.booleanValue())) { |
768 |
if (!processed && (source == null || !source.booleanValue())) { |
768 |
root = getOwningBinaryRoot(fo); |
769 |
root = getOwningBinaryRoot(fo); |
769 |
if (root != null && visibilitySupport.isVisible(fo,root.second)) { |
770 |
if (root != null && visibilitySupport.isVisible(fo,root.second())) { |
770 |
final Work wrk = new BinaryWork( |
771 |
final Work wrk = new BinaryWork( |
771 |
root.first, |
772 |
root.first(), |
772 |
suspendSupport.getSuspendStatus(), |
773 |
suspendSupport.getSuspendStatus(), |
773 |
LogContext.create(LogContext.EventType.FILE, null). |
774 |
LogContext.create(LogContext.EventType.FILE, null). |
774 |
withRoot(root.first). |
775 |
withRoot(root.first()). |
775 |
addFiles(Collections.singleton(fo.toURL()))); |
776 |
addFiles(Collections.singleton(fo.toURL()))); |
776 |
eventQueue.record(FileEventLog.FileOp.CREATE, root.first, null, fe, wrk); |
777 |
eventQueue.record(FileEventLog.FileOp.CREATE, root.first(), null, fe, wrk); |
777 |
processed = true; |
778 |
processed = true; |
778 |
} |
779 |
} |
779 |
} |
780 |
} |
Lines 807-830
Link Here
|
807 |
if (fo != null) { |
808 |
if (fo != null) { |
808 |
if (source == null || source.booleanValue()) { |
809 |
if (source == null || source.booleanValue()) { |
809 |
root = getOwningSourceRoot (fo); |
810 |
root = getOwningSourceRoot (fo); |
810 |
if (root != null && fo.isData() && visibilitySupport.isVisible(fo, root.second)) { |
811 |
if (root != null && fo.isData() && visibilitySupport.isVisible(fo, root.second())) { |
811 |
String relativePath = null; |
812 |
String relativePath = null; |
812 |
try { |
813 |
try { |
813 |
//Root may be deleted -> no root.second available |
814 |
//Root may be deleted -> no root.second available |
814 |
if (root.second != null) { |
815 |
if (root.second() != null) { |
815 |
relativePath = FileUtil.getRelativePath(root.second, fo); |
816 |
relativePath = FileUtil.getRelativePath(root.second(), fo); |
816 |
} else { |
817 |
} else { |
817 |
relativePath = root.first.toURI().relativize(fo.getURL().toURI()).getPath(); |
818 |
relativePath = root.first().toURI().relativize(fo.getURL().toURI()).getPath(); |
818 |
} |
819 |
} |
819 |
assert relativePath != null : "FileObject not under root: f=" + fo + ", root=" + root; //NOI18N |
820 |
assert relativePath != null : "FileObject not under root: f=" + fo + ", root=" + root; //NOI18N |
820 |
final Work wrk = new DeleteWork( |
821 |
final Work wrk = new DeleteWork( |
821 |
root.first, |
822 |
root.first(), |
822 |
Collections.singleton(relativePath), |
823 |
Collections.singleton(relativePath), |
823 |
suspendSupport.getSuspendStatus(), |
824 |
suspendSupport.getSuspendStatus(), |
824 |
LogContext.create(LogContext.EventType.FILE, null). |
825 |
LogContext.create(LogContext.EventType.FILE, null). |
825 |
withRoot(root.first). |
826 |
withRoot(root.first()). |
826 |
addFiles(Collections.singleton(fo.toURL()))); |
827 |
addFiles(Collections.singleton(fo.toURL()))); |
827 |
eventQueue.record(FileEventLog.FileOp.DELETE, root.first, relativePath, fe, wrk); |
828 |
eventQueue.record(FileEventLog.FileOp.DELETE, root.first(), relativePath, fe, wrk); |
828 |
processed = true; |
829 |
processed = true; |
829 |
} catch (FileStateInvalidException fse) { |
830 |
} catch (FileStateInvalidException fse) { |
830 |
Exceptions.printStackTrace(fse); |
831 |
Exceptions.printStackTrace(fse); |
Lines 836-849
Link Here
|
836 |
|
837 |
|
837 |
if (!processed && (source == null || !source.booleanValue())) { |
838 |
if (!processed && (source == null || !source.booleanValue())) { |
838 |
root = getOwningBinaryRoot(fo); |
839 |
root = getOwningBinaryRoot(fo); |
839 |
if (root != null && visibilitySupport.isVisible(fo, root.second)) { |
840 |
if (root != null && visibilitySupport.isVisible(fo, root.second())) { |
840 |
final Work wrk = new BinaryWork( |
841 |
final Work wrk = new BinaryWork( |
841 |
root.first, |
842 |
root.first(), |
842 |
suspendSupport.getSuspendStatus(), |
843 |
suspendSupport.getSuspendStatus(), |
843 |
LogContext.create(LogContext.EventType.FILE, null). |
844 |
LogContext.create(LogContext.EventType.FILE, null). |
844 |
withRoot(root.first). |
845 |
withRoot(root.first()). |
845 |
addFiles(Collections.singleton(fo.toURL()))); |
846 |
addFiles(Collections.singleton(fo.toURL()))); |
846 |
eventQueue.record(FileEventLog.FileOp.DELETE, root.first, null, fe, wrk); |
847 |
eventQueue.record(FileEventLog.FileOp.DELETE, root.first(), null, fe, wrk); |
847 |
processed = true; |
848 |
processed = true; |
848 |
} |
849 |
} |
849 |
} |
850 |
} |
Lines 879-892
Link Here
|
879 |
if (source == null || source.booleanValue()) { |
880 |
if (source == null || source.booleanValue()) { |
880 |
root = getOwningSourceRoot(newFile); |
881 |
root = getOwningSourceRoot(newFile); |
881 |
if (root != null) { |
882 |
if (root != null) { |
882 |
if (root.second == null) { |
883 |
if (root.second() == null) { |
883 |
LOGGER.log( |
884 |
LOGGER.log( |
884 |
Level.INFO, |
885 |
Level.INFO, |
885 |
"Ignoring event from non existing FileObject {0}", //NOI18N |
886 |
"Ignoring event from non existing FileObject {0}", //NOI18N |
886 |
root.first); |
887 |
root.first()); |
887 |
return; |
888 |
return; |
888 |
} |
889 |
} |
889 |
FileObject rootFo = root.second; |
890 |
FileObject rootFo = root.second(); |
890 |
if (rootFo.equals(newFile)) { |
891 |
if (rootFo.equals(newFile)) { |
891 |
//Root renamed do nothing, will be fired as ClassPath change. |
892 |
//Root renamed do nothing, will be fired as ClassPath change. |
892 |
return; |
893 |
return; |
Lines 895-929
Link Here
|
895 |
String oldFilePath = ownerPath.length() == 0 ? oldNameExt : ownerPath + "/" + oldNameExt; //NOI18N |
896 |
String oldFilePath = ownerPath.length() == 0 ? oldNameExt : ownerPath + "/" + oldNameExt; //NOI18N |
896 |
if (newFile.isData()) { |
897 |
if (newFile.isData()) { |
897 |
final Work work = new DeleteWork( |
898 |
final Work work = new DeleteWork( |
898 |
root.first, |
899 |
root.first(), |
899 |
Collections.singleton(oldFilePath), |
900 |
Collections.singleton(oldFilePath), |
900 |
suspendSupport.getSuspendStatus(), |
901 |
suspendSupport.getSuspendStatus(), |
901 |
LogContext.create(LogContext.EventType.FILE, null). |
902 |
LogContext.create(LogContext.EventType.FILE, null). |
902 |
withRoot(root.first). |
903 |
withRoot(root.first()). |
903 |
addFilePaths(Collections.singleton(oldFilePath))); |
904 |
addFilePaths(Collections.singleton(oldFilePath))); |
904 |
eventQueue.record(FileEventLog.FileOp.DELETE, root.first, oldFilePath, fe, work); |
905 |
eventQueue.record(FileEventLog.FileOp.DELETE, root.first(), oldFilePath, fe, work); |
905 |
} else { |
906 |
} else { |
906 |
Set<String> oldFilePaths = new HashSet<String>(); |
907 |
Set<String> oldFilePaths = new HashSet<String>(); |
907 |
collectFilePaths(newFile, oldFilePath, oldFilePaths); |
908 |
collectFilePaths(newFile, oldFilePath, oldFilePaths); |
908 |
for (String path : oldFilePaths) { |
909 |
for (String path : oldFilePaths) { |
909 |
final Work work = new DeleteWork( |
910 |
final Work work = new DeleteWork( |
910 |
root.first, |
911 |
root.first(), |
911 |
oldFilePaths, |
912 |
oldFilePaths, |
912 |
suspendSupport.getSuspendStatus(), |
913 |
suspendSupport.getSuspendStatus(), |
913 |
LogContext.create(LogContext.EventType.FILE, null). |
914 |
LogContext.create(LogContext.EventType.FILE, null). |
914 |
withRoot(root.first). |
915 |
withRoot(root.first()). |
915 |
addFilePaths(oldFilePaths)); |
916 |
addFilePaths(oldFilePaths)); |
916 |
eventQueue.record(FileEventLog.FileOp.DELETE, root.first, path, fe, work); |
917 |
eventQueue.record(FileEventLog.FileOp.DELETE, root.first(), path, fe, work); |
917 |
} |
918 |
} |
918 |
} |
919 |
} |
919 |
|
920 |
|
920 |
if (visibilitySupport.isVisible(newFile,root.second)) { |
921 |
if (visibilitySupport.isVisible(newFile,root.second())) { |
921 |
final boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root.first); |
922 |
final boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root.first()); |
922 |
ClassPath.Entry entry = sourceForBinaryRoot ? null : getClassPathEntry(rootFo); |
923 |
ClassPath.Entry entry = sourceForBinaryRoot ? null : getClassPathEntry(rootFo); |
923 |
if (entry == null || entry.includes(newFile)) { |
924 |
if (entry == null || entry.includes(newFile)) { |
924 |
final FileListWork flw = new FileListWork( |
925 |
final FileListWork flw = new FileListWork( |
925 |
scannedRoots2Dependencies, |
926 |
scannedRoots2Dependencies, |
926 |
root.first, |
927 |
root.first(), |
927 |
Collections.singleton(newFile), |
928 |
Collections.singleton(newFile), |
928 |
false, |
929 |
false, |
929 |
false, |
930 |
false, |
Lines 932-940
Link Here
|
932 |
true, |
933 |
true, |
933 |
suspendSupport.getSuspendStatus(), |
934 |
suspendSupport.getSuspendStatus(), |
934 |
LogContext.create(LogContext.EventType.FILE, null). |
935 |
LogContext.create(LogContext.EventType.FILE, null). |
935 |
withRoot(root.first). |
936 |
withRoot(root.first()). |
936 |
addFileObjects(Collections.singleton(newFile))); |
937 |
addFileObjects(Collections.singleton(newFile))); |
937 |
eventQueue.record(FileEventLog.FileOp.CREATE, root.first, FileUtil.getRelativePath(rootFo, newFile), fe,flw); |
938 |
eventQueue.record(FileEventLog.FileOp.CREATE, root.first(), FileUtil.getRelativePath(rootFo, newFile), fe,flw); |
938 |
} |
939 |
} |
939 |
} |
940 |
} |
940 |
processed = true; |
941 |
processed = true; |
Lines 964-977
Link Here
|
964 |
|
965 |
|
965 |
eventQueue.record( |
966 |
eventQueue.record( |
966 |
FileEventLog.FileOp.CREATE, |
967 |
FileEventLog.FileOp.CREATE, |
967 |
root.first, |
968 |
root.first(), |
968 |
null, |
969 |
null, |
969 |
fe, |
970 |
fe, |
970 |
new BinaryWork(root.first, |
971 |
new BinaryWork(root.first(), |
971 |
suspendSupport.getSuspendStatus(), |
972 |
suspendSupport.getSuspendStatus(), |
972 |
LogContext.create(LogContext.EventType.FILE, null). |
973 |
LogContext.create(LogContext.EventType.FILE, null). |
973 |
withRoot(root.first). |
974 |
withRoot(root.first()). |
974 |
addRoots(Collections.singleton(root.first)))); |
975 |
addRoots(Collections.singleton(root.first())))); |
975 |
processed = true; |
976 |
processed = true; |
976 |
} |
977 |
} |
977 |
} |
978 |
} |
Lines 1076-1084
Link Here
|
1076 |
Document doc = jtc.getDocument(); |
1077 |
Document doc = jtc.getDocument(); |
1077 |
Pair<URL, FileObject> root = getOwningSourceRoot(doc); |
1078 |
Pair<URL, FileObject> root = getOwningSourceRoot(doc); |
1078 |
if (root != null) { |
1079 |
if (root != null) { |
1079 |
if (root.second == null) { |
1080 |
if (root.second() == null) { |
1080 |
final FileObject file = Util.getFileObject(doc); |
1081 |
final FileObject file = Util.getFileObject(doc); |
1081 |
assert file == null || !file.isValid() : "Expecting both owningSourceRootUrl=" + root.first + " and owningSourceRoot=" + root.second; //NOI18N |
1082 |
assert file == null || !file.isValid() : "Expecting both owningSourceRootUrl=" + root.first() + " and owningSourceRoot=" + root.second(); //NOI18N |
1082 |
return; |
1083 |
return; |
1083 |
} |
1084 |
} |
1084 |
long version = DocumentUtilities.getDocumentVersion(doc); |
1085 |
long version = DocumentUtilities.getDocumentVersion(doc); |
Lines 1109-1134
Link Here
|
1109 |
if (reindex) { |
1110 |
if (reindex) { |
1110 |
// we have already seen the document and it's been modified since the last time |
1111 |
// we have already seen the document and it's been modified since the last time |
1111 |
if (LOGGER.isLoggable(Level.FINE)) { |
1112 |
if (LOGGER.isLoggable(Level.FINE)) { |
1112 |
LOGGER.fine("Document modified (reindexing): " + FileUtil.getFileDisplayName(docFile) + " Owner: " + root.first); //NOI18N |
1113 |
LOGGER.fine("Document modified (reindexing): " + FileUtil.getFileDisplayName(docFile) + " Owner: " + root.first()); //NOI18N |
1113 |
} |
1114 |
} |
1114 |
|
1115 |
|
1115 |
FileListWork job = jobs.get(root.first); |
1116 |
FileListWork job = jobs.get(root.first()); |
1116 |
if (job == null) { |
1117 |
if (job == null) { |
1117 |
Collection<FileObject> c = Collections.singleton(docFile); |
1118 |
Collection<FileObject> c = Collections.singleton(docFile); |
1118 |
job = new FileListWork( |
1119 |
job = new FileListWork( |
1119 |
scannedRoots2Dependencies, |
1120 |
scannedRoots2Dependencies, |
1120 |
root.first, |
1121 |
root.first(), |
1121 |
c, |
1122 |
c, |
1122 |
false, |
1123 |
false, |
1123 |
openedInEditor, |
1124 |
openedInEditor, |
1124 |
true, |
1125 |
true, |
1125 |
sourcesForBinaryRoots.contains(root.first), |
1126 |
sourcesForBinaryRoots.contains(root.first()), |
1126 |
true, |
1127 |
true, |
1127 |
suspendSupport.getSuspendStatus(), |
1128 |
suspendSupport.getSuspendStatus(), |
1128 |
LogContext.create(LogContext.EventType.FILE, null). |
1129 |
LogContext.create(LogContext.EventType.FILE, null). |
1129 |
withRoot(root.first). |
1130 |
withRoot(root.first()). |
1130 |
addFileObjects(c)); |
1131 |
addFileObjects(c)); |
1131 |
jobs.put(root.first, job); |
1132 |
jobs.put(root.first(), job); |
1132 |
} else { |
1133 |
} else { |
1133 |
// XXX: strictly speaking we should set 'checkEditor' for each file separately |
1134 |
// XXX: strictly speaking we should set 'checkEditor' for each file separately |
1134 |
// and not for each job; in reality we normally do not end up here |
1135 |
// and not for each job; in reality we normally do not end up here |
Lines 1301-1311
Link Here
|
1301 |
|
1302 |
|
1302 |
final Pair<URL, FileObject> root = getOwningSourceRoot(document); |
1303 |
final Pair<URL, FileObject> root = getOwningSourceRoot(document); |
1303 |
if (root != null) { |
1304 |
if (root != null) { |
1304 |
if (root.second == null) { |
1305 |
if (root.second() == null) { |
1305 |
LOGGER.log( |
1306 |
LOGGER.log( |
1306 |
Level.INFO, |
1307 |
Level.INFO, |
1307 |
"Ignoring event from non existing FileObject {0}", //NOI18N |
1308 |
"Ignoring event from non existing FileObject {0}", //NOI18N |
1308 |
root.first); |
1309 |
root.first()); |
1309 |
return; |
1310 |
return; |
1310 |
} |
1311 |
} |
1311 |
if (activeDocument == document) { |
1312 |
if (activeDocument == document) { |
Lines 1326-1335
Link Here
|
1326 |
// An active document was modified, we've indexed that document berfore, |
1327 |
// An active document was modified, we've indexed that document berfore, |
1327 |
// so mark it dirty |
1328 |
// so mark it dirty |
1328 |
if (LOGGER.isLoggable(Level.FINE)) { |
1329 |
if (LOGGER.isLoggable(Level.FINE)) { |
1329 |
LOGGER.fine("Active document modified (marking dirty): " + FileUtil.getFileDisplayName(docFile) + " Owner: " + root.first); //NOI18N |
1330 |
LOGGER.fine("Active document modified (marking dirty): " + FileUtil.getFileDisplayName(docFile) + " Owner: " + root.first()); //NOI18N |
1330 |
} |
1331 |
} |
1331 |
|
1332 |
|
1332 |
Collection<? extends Indexable> dirty = Collections.singleton(SPIAccessor.getInstance().create(new FileObjectIndexable(root.second, docFile))); |
1333 |
Collection<? extends Indexable> dirty = Collections.singleton(SPIAccessor.getInstance().create(new FileObjectIndexable(root.second(), docFile))); |
1333 |
String mimeType = DocumentUtilities.getMimeType(document); |
1334 |
String mimeType = DocumentUtilities.getMimeType(document); |
1334 |
|
1335 |
|
1335 |
TransientUpdateSupport.setTransientUpdate(true); |
1336 |
TransientUpdateSupport.setTransientUpdate(true); |
Lines 1340-1346
Link Here
|
1340 |
@Override |
1341 |
@Override |
1341 |
public FileObject call() throws Exception { |
1342 |
public FileObject call() throws Exception { |
1342 |
if (cache == null) { |
1343 |
if (cache == null) { |
1343 |
cache = CacheFolder.getDataFolder(root.first); |
1344 |
cache = CacheFolder.getDataFolder(root.first()); |
1344 |
} |
1345 |
} |
1345 |
return cache; |
1346 |
return cache; |
1346 |
} |
1347 |
} |
Lines 1351-1357
Link Here
|
1351 |
final CustomIndexerFactory factory = info.getIndexerFactory(); |
1352 |
final CustomIndexerFactory factory = info.getIndexerFactory(); |
1352 |
final Context ctx = SPIAccessor.getInstance().createContext( |
1353 |
final Context ctx = SPIAccessor.getInstance().createContext( |
1353 |
indexFolderFactory, |
1354 |
indexFolderFactory, |
1354 |
root.first, |
1355 |
root.first(), |
1355 |
factory.getIndexerName(), |
1356 |
factory.getIndexerName(), |
1356 |
factory.getIndexVersion(), |
1357 |
factory.getIndexVersion(), |
1357 |
null, |
1358 |
null, |
Lines 1373-1379
Link Here
|
1373 |
final EmbeddingIndexerFactory factory = info.getIndexerFactory(); |
1374 |
final EmbeddingIndexerFactory factory = info.getIndexerFactory(); |
1374 |
final Context ctx = SPIAccessor.getInstance().createContext( |
1375 |
final Context ctx = SPIAccessor.getInstance().createContext( |
1375 |
indexFolderFactory, |
1376 |
indexFolderFactory, |
1376 |
root.first, |
1377 |
root.first(), |
1377 |
factory.getIndexerName(), |
1378 |
factory.getIndexerName(), |
1378 |
factory.getIndexVersion(), |
1379 |
factory.getIndexVersion(), |
1379 |
null, |
1380 |
null, |
Lines 1398-1404
Link Here
|
1398 |
FileObject f = Util.getFileObject(document); |
1399 |
FileObject f = Util.getFileObject(document); |
1399 |
Collection<URL> c = Collections.singleton(f.getURL()); |
1400 |
Collection<URL> c = Collections.singleton(f.getURL()); |
1400 |
addIndexingJob( |
1401 |
addIndexingJob( |
1401 |
root.first, |
1402 |
root.first(), |
1402 |
c, |
1403 |
c, |
1403 |
false, |
1404 |
false, |
1404 |
true, |
1405 |
true, |
Lines 1406-1412
Link Here
|
1406 |
true, |
1407 |
true, |
1407 |
true, |
1408 |
true, |
1408 |
LogContext.create(LogContext.EventType.FILE, null). |
1409 |
LogContext.create(LogContext.EventType.FILE, null). |
1409 |
withRoot(root.first). |
1410 |
withRoot(root.first()). |
1410 |
addFiles(c)); |
1411 |
addFiles(c)); |
1411 |
} catch (FileStateInvalidException ex) { |
1412 |
} catch (FileStateInvalidException ex) { |
1412 |
LOGGER.log(Level.WARNING, null, ex); |
1413 |
LOGGER.log(Level.WARNING, null, ex); |
Lines 2200-2206
Link Here
|
2200 |
} |
2201 |
} |
2201 |
logStartIndexer(factory.getIndexerName()); |
2202 |
logStartIndexer(factory.getIndexerName()); |
2202 |
try { |
2203 |
try { |
2203 |
boolean vote = factory.scanStarted(value.second); |
2204 |
boolean vote = factory.scanStarted(value.second()); |
2204 |
votes.put(factory,vote); |
2205 |
votes.put(factory,vote); |
2205 |
} catch (Throwable t) { |
2206 |
} catch (Throwable t) { |
2206 |
if (t instanceof ThreadDeath) { |
2207 |
if (t instanceof ThreadDeath) { |
Lines 2246-2252
Link Here
|
2246 |
} |
2247 |
} |
2247 |
logStartIndexer(eif.getIndexerName()); |
2248 |
logStartIndexer(eif.getIndexerName()); |
2248 |
try { |
2249 |
try { |
2249 |
boolean vote = eif.scanStarted(value.second); |
2250 |
boolean vote = eif.scanStarted(value.second()); |
2250 |
votes.put(eif, vote); |
2251 |
votes.put(eif, vote); |
2251 |
} catch (Throwable t) { |
2252 |
} catch (Throwable t) { |
2252 |
if (t instanceof ThreadDeath) { |
2253 |
if (t instanceof ThreadDeath) { |
Lines 2270-2283
Link Here
|
2270 |
parkWhileSuspended(); |
2271 |
parkWhileSuspended(); |
2271 |
if (TEST_LOGGER.isLoggable(Level.FINEST)) { |
2272 |
if (TEST_LOGGER.isLoggable(Level.FINEST)) { |
2272 |
TEST_LOGGER.log(Level.FINEST, "scanFinishing:{0}:{1}", |
2273 |
TEST_LOGGER.log(Level.FINEST, "scanFinishing:{0}:{1}", |
2273 |
new Object[] { entry.first.getIndexerName(), entry.second.getRootURI().toExternalForm() }); |
2274 |
new Object[] { entry.first().getIndexerName(), entry.second().getRootURI().toExternalForm() }); |
2274 |
} |
2275 |
} |
2275 |
logStartIndexer(entry.first.getIndexerName()); |
2276 |
logStartIndexer(entry.first().getIndexerName()); |
2276 |
SPIAccessor.getInstance().putProperty(entry.second, ClusteredIndexables.DELETE, null); |
2277 |
SPIAccessor.getInstance().putProperty(entry.second(), ClusteredIndexables.DELETE, null); |
2277 |
SPIAccessor.getInstance().putProperty(entry.second, ClusteredIndexables.INDEX, null); |
2278 |
SPIAccessor.getInstance().putProperty(entry.second(), ClusteredIndexables.INDEX, null); |
2278 |
cancelRequest.setResult(finished); |
2279 |
cancelRequest.setResult(finished); |
2279 |
try { |
2280 |
try { |
2280 |
entry.first.scanFinished(entry.second); |
2281 |
entry.first().scanFinished(entry.second()); |
2281 |
} catch (Throwable t) { |
2282 |
} catch (Throwable t) { |
2282 |
if (t instanceof ThreadDeath) { |
2283 |
if (t instanceof ThreadDeath) { |
2283 |
throw (ThreadDeath) t; |
2284 |
throw (ThreadDeath) t; |
Lines 2287-2296
Link Here
|
2287 |
} finally { |
2288 |
} finally { |
2288 |
cancelRequest.setResult(null); |
2289 |
cancelRequest.setResult(null); |
2289 |
} |
2290 |
} |
2290 |
logFinishIndexer(entry.first.getIndexerName()); |
2291 |
logFinishIndexer(entry.first().getIndexerName()); |
2291 |
if (TEST_LOGGER.isLoggable(Level.FINEST)) { |
2292 |
if (TEST_LOGGER.isLoggable(Level.FINEST)) { |
2292 |
TEST_LOGGER.log(Level.FINEST, "scanFinished:{0}:{1}", |
2293 |
TEST_LOGGER.log(Level.FINEST, "scanFinished:{0}:{1}", |
2293 |
new Object[] { entry.first.getIndexerName(), entry.second.getRootURI().toExternalForm() }); |
2294 |
new Object[] { entry.first().getIndexerName(), entry.second().getRootURI().toExternalForm() }); |
2294 |
} |
2295 |
} |
2295 |
} |
2296 |
} |
2296 |
} finally { |
2297 |
} finally { |
Lines 2298-2311
Link Here
|
2298 |
boolean indexOk = true; |
2299 |
boolean indexOk = true; |
2299 |
for(Pair<SourceIndexerFactory,Context> entry : ctxToFinish) { |
2300 |
for(Pair<SourceIndexerFactory,Context> entry : ctxToFinish) { |
2300 |
indexOk &= storeChanges( |
2301 |
indexOk &= storeChanges( |
2301 |
entry.first.getIndexerName(), |
2302 |
entry.first().getIndexerName(), |
2302 |
entry.second, |
2303 |
entry.second(), |
2303 |
isSteady(), |
2304 |
isSteady(), |
2304 |
usedIterables.get(), |
2305 |
usedIterables.get(), |
2305 |
finished); |
2306 |
finished); |
2306 |
} |
2307 |
} |
2307 |
if (!indexOk) { |
2308 |
if (!indexOk) { |
2308 |
final Context ctx = ctxToFinish.iterator().next().second; |
2309 |
final Context ctx = ctxToFinish.iterator().next().second(); |
2309 |
RepositoryUpdater.getDefault().addIndexingJob( |
2310 |
RepositoryUpdater.getDefault().addIndexingJob( |
2310 |
ctx.getRootURI(), |
2311 |
ctx.getRootURI(), |
2311 |
null, |
2312 |
null, |
Lines 2336-2347
Link Here
|
2336 |
try { |
2337 |
try { |
2337 |
for (Pair<SourceIndexerFactory,Context> pair : contexts.values()) { |
2338 |
for (Pair<SourceIndexerFactory,Context> pair : contexts.values()) { |
2338 |
parkWhileSuspended(); |
2339 |
parkWhileSuspended(); |
2339 |
SPIAccessor.getInstance().putProperty(pair.second, ClusteredIndexables.DELETE, ci); |
2340 |
SPIAccessor.getInstance().putProperty(pair.second(), ClusteredIndexables.DELETE, ci); |
2340 |
pair.first.filesDeleted(ci.getIndexablesFor(null), pair.second); |
2341 |
pair.first().filesDeleted(ci.getIndexablesFor(null), pair.second()); |
2341 |
} |
2342 |
} |
2342 |
} finally { |
2343 |
} finally { |
2343 |
for(Pair<SourceIndexerFactory,Context> pair : contexts.values()) { |
2344 |
for(Pair<SourceIndexerFactory,Context> pair : contexts.values()) { |
2344 |
DocumentIndex index = SPIAccessor.getInstance().getIndexFactory(pair.second).getIndex(pair.second.getIndexFolder()); |
2345 |
DocumentIndex index = SPIAccessor.getInstance().getIndexFactory(pair.second()).getIndex(pair.second().getIndexFolder()); |
2345 |
if (index != null) { |
2346 |
if (index != null) { |
2346 |
usedIterables.offer(ci.getIndexablesFor(null)); |
2347 |
usedIterables.offer(ci.getIndexablesFor(null)); |
2347 |
} |
2348 |
} |
Lines 2435-2441
Link Here
|
2435 |
factory |
2436 |
factory |
2436 |
}); |
2437 |
}); |
2437 |
} |
2438 |
} |
2438 |
SPIAccessor.getInstance().setAllFilesJob(value.second, allFiles); |
2439 |
SPIAccessor.getInstance().setAllFilesJob(value.second(), allFiles); |
2439 |
List<Iterable<Indexable>> indexerIndexablesList = new LinkedList<Iterable<Indexable>>(); |
2440 |
List<Iterable<Indexable>> indexerIndexablesList = new LinkedList<Iterable<Indexable>>(); |
2440 |
ClusteredIndexables usedCi = null; |
2441 |
ClusteredIndexables usedCi = null; |
2441 |
for(String mimeType : cifInfo.getMimeTypes()) { |
2442 |
for(String mimeType : cifInfo.getMimeTypes()) { |
Lines 2466-2475
Link Here
|
2466 |
final CustomIndexer indexer = factory.createIndexer(); |
2467 |
final CustomIndexer indexer = factory.createIndexer(); |
2467 |
long tm1 = -1, tm2 = -1; |
2468 |
long tm1 = -1, tm2 = -1; |
2468 |
logStartIndexer(factory.getIndexerName()); |
2469 |
logStartIndexer(factory.getIndexerName()); |
2469 |
SPIAccessor.getInstance().putProperty(value.second, ClusteredIndexables.INDEX, usedCi); |
2470 |
SPIAccessor.getInstance().putProperty(value.second(), ClusteredIndexables.INDEX, usedCi); |
2470 |
try { |
2471 |
try { |
2471 |
tm1 = System.currentTimeMillis(); |
2472 |
tm1 = System.currentTimeMillis(); |
2472 |
SPIAccessor.getInstance().index(indexer, indexables, value.second); |
2473 |
SPIAccessor.getInstance().index(indexer, indexables, value.second()); |
2473 |
} catch (ThreadDeath td) { |
2474 |
} catch (ThreadDeath td) { |
2474 |
throw td; |
2475 |
throw td; |
2475 |
} catch (Throwable t) { |
2476 |
} catch (Throwable t) { |
Lines 2551-2557
Link Here
|
2551 |
value = Pair.<SourceIndexerFactory,Context>of(factory,ctx); |
2552 |
value = Pair.<SourceIndexerFactory,Context>of(factory,ctx); |
2552 |
contexts.put(key,value); |
2553 |
contexts.put(key,value); |
2553 |
} |
2554 |
} |
2554 |
SPIAccessor.getInstance().setAllFilesJob(value.second, allFiles); |
2555 |
SPIAccessor.getInstance().setAllFilesJob(value.second(), allFiles); |
2555 |
} |
2556 |
} |
2556 |
} |
2557 |
} |
2557 |
} |
2558 |
} |
Lines 2705-2719
Link Here
|
2705 |
protected final boolean checkBinaryIndexers( |
2706 |
protected final boolean checkBinaryIndexers( |
2706 |
@NullAllowed Pair<Long,Map<Pair<String,Integer>,Integer>> lastState, |
2707 |
@NullAllowed Pair<Long,Map<Pair<String,Integer>,Integer>> lastState, |
2707 |
@NonNull Map<BinaryIndexerFactory, Context> contexts) throws IOException { |
2708 |
@NonNull Map<BinaryIndexerFactory, Context> contexts) throws IOException { |
2708 |
if (lastState == null || lastState.first == 0L) { |
2709 |
if (lastState == null || lastState.first() == 0L) { |
2709 |
//Nothing known about the last state |
2710 |
//Nothing known about the last state |
2710 |
return false; |
2711 |
return false; |
2711 |
} |
2712 |
} |
2712 |
if (contexts.size() != lastState.second.size()) { |
2713 |
if (contexts.size() != lastState.second().size()) { |
2713 |
//Factories changed |
2714 |
//Factories changed |
2714 |
return false; |
2715 |
return false; |
2715 |
} |
2716 |
} |
2716 |
final Map<Pair<String,Integer>,Integer> copy = new HashMap<Pair<String,Integer>,Integer>(lastState.second); |
2717 |
final Map<Pair<String,Integer>,Integer> copy = new HashMap<Pair<String,Integer>,Integer>(lastState.second()); |
2717 |
for (Map.Entry<BinaryIndexerFactory,Context> e : contexts.entrySet()) { |
2718 |
for (Map.Entry<BinaryIndexerFactory,Context> e : contexts.entrySet()) { |
2718 |
final BinaryIndexerFactory bif = e.getKey(); |
2719 |
final BinaryIndexerFactory bif = e.getKey(); |
2719 |
final Integer state = copy.remove(Pair.<String,Integer>of(bif.getIndexerName(),bif.getIndexVersion())); |
2720 |
final Integer state = copy.remove(Pair.<String,Integer>of(bif.getIndexerName(),bif.getIndexVersion())); |
Lines 2866-2876
Link Here
|
2866 |
|
2867 |
|
2867 |
final EmbeddingIndexer indexer = indexerFactory.createIndexer(dirty, pr.getSnapshot()); |
2868 |
final EmbeddingIndexer indexer = indexerFactory.createIndexer(dirty, pr.getSnapshot()); |
2868 |
if (indexer != null) { |
2869 |
if (indexer != null) { |
2869 |
SPIAccessor.getInstance().putProperty(value.second, ClusteredIndexables.INDEX, usedCi); |
2870 |
SPIAccessor.getInstance().putProperty(value.second(), ClusteredIndexables.INDEX, usedCi); |
2870 |
long st = System.currentTimeMillis(); |
2871 |
long st = System.currentTimeMillis(); |
2871 |
logStartIndexer(indexerName); |
2872 |
logStartIndexer(indexerName); |
2872 |
try { |
2873 |
try { |
2873 |
SPIAccessor.getInstance().index(indexer, dirty, pr, value.second); |
2874 |
SPIAccessor.getInstance().index(indexer, dirty, pr, value.second()); |
2874 |
} catch (ThreadDeath td) { |
2875 |
} catch (ThreadDeath td) { |
2875 |
throw td; |
2876 |
throw td; |
2876 |
} catch (Throwable t) { |
2877 |
} catch (Throwable t) { |
Lines 3672-3678
Link Here
|
3672 |
final Pair<String,Integer> indexerKey = Pair.<String,Integer>of(factory.getIndexerName(),factory.getIndexVersion()); |
3673 |
final Pair<String,Integer> indexerKey = Pair.<String,Integer>of(factory.getIndexerName(),factory.getIndexVersion()); |
3673 |
final Pair<SourceIndexerFactory, Context> ctx = transactionContexts.get(indexerKey); |
3674 |
final Pair<SourceIndexerFactory, Context> ctx = transactionContexts.get(indexerKey); |
3674 |
if (ctx != null) { |
3675 |
if (ctx != null) { |
3675 |
SPIAccessor.getInstance().setAllFilesJob(ctx.second, true); |
3676 |
SPIAccessor.getInstance().setAllFilesJob(ctx.second(), true); |
3676 |
final CustomIndexer indexer = factory.createIndexer(); |
3677 |
final CustomIndexer indexer = factory.createIndexer(); |
3677 |
if (LOGGER.isLoggable(Level.FINE)) { |
3678 |
if (LOGGER.isLoggable(Level.FINE)) { |
3678 |
StringBuilder sb = printMimeTypes(cifInfo.getMimeTypes(), new StringBuilder()); |
3679 |
StringBuilder sb = printMimeTypes(cifInfo.getMimeTypes(), new StringBuilder()); |
Lines 3685-3695
Link Here
|
3685 |
sb |
3686 |
sb |
3686 |
}); |
3687 |
}); |
3687 |
} |
3688 |
} |
3688 |
SPIAccessor.getInstance().putProperty(ctx.second, ClusteredIndexables.INDEX, ci); |
3689 |
SPIAccessor.getInstance().putProperty(ctx.second(), ClusteredIndexables.INDEX, ci); |
3689 |
long st = System.currentTimeMillis(); |
3690 |
long st = System.currentTimeMillis(); |
3690 |
logStartIndexer(factory.getIndexerName()); |
3691 |
logStartIndexer(factory.getIndexerName()); |
3691 |
try { |
3692 |
try { |
3692 |
SPIAccessor.getInstance().index(indexer, indexables, ctx.second); |
3693 |
SPIAccessor.getInstance().index(indexer, indexables, ctx.second()); |
3693 |
} catch (ThreadDeath td) { |
3694 |
} catch (ThreadDeath td) { |
3694 |
throw td; |
3695 |
throw td; |
3695 |
} catch (Throwable t) { |
3696 |
} catch (Throwable t) { |
Lines 3969-3981
Link Here
|
3969 |
for(Pair<Object, Boolean> fileOrFileObject : suspectFilesOrFileObjects) { |
3970 |
for(Pair<Object, Boolean> fileOrFileObject : suspectFilesOrFileObjects) { |
3970 |
Pair<FileObject, Boolean> fileObject = null; |
3971 |
Pair<FileObject, Boolean> fileObject = null; |
3971 |
|
3972 |
|
3972 |
if (fileOrFileObject.first instanceof File) { |
3973 |
if (fileOrFileObject.first() instanceof File) { |
3973 |
FileObject f = FileUtil.toFileObject((File) fileOrFileObject.first); |
3974 |
FileObject f = FileUtil.toFileObject((File) fileOrFileObject.first()); |
3974 |
if (f != null) { |
3975 |
if (f != null) { |
3975 |
fileObject = Pair.<FileObject, Boolean>of(f, fileOrFileObject.second); |
3976 |
fileObject = Pair.<FileObject, Boolean>of(f, fileOrFileObject.second()); |
3976 |
} |
3977 |
} |
3977 |
} else if (fileOrFileObject.first instanceof FileObject) { |
3978 |
} else if (fileOrFileObject.first() instanceof FileObject) { |
3978 |
fileObject = Pair.<FileObject, Boolean>of((FileObject) fileOrFileObject.first, fileOrFileObject.second); |
3979 |
fileObject = Pair.<FileObject, Boolean>of((FileObject) fileOrFileObject.first(), fileOrFileObject.second()); |
3979 |
} else { |
3980 |
} else { |
3980 |
LOGGER.fine("Not File or FileObject, ignoring: " + fileOrFileObject); //NOI18N |
3981 |
LOGGER.fine("Not File or FileObject, ignoring: " + fileOrFileObject); //NOI18N |
3981 |
} |
3982 |
} |
Lines 3993-3999
Link Here
|
3993 |
if (rootFile != null) { |
3994 |
if (rootFile != null) { |
3994 |
FileObject rootFo = FileUtil.toFileObject(rootFile); |
3995 |
FileObject rootFo = FileUtil.toFileObject(rootFile); |
3995 |
if (rootFo != null) { |
3996 |
if (rootFo != null) { |
3996 |
if (f.first == rootFo || FileUtil.isParentOf(f.first, rootFo)) { |
3997 |
if (f.first() == rootFo || FileUtil.isParentOf(f.first(), rootFo)) { |
3997 |
depCtx.newBinariesToScan.add(root); |
3998 |
depCtx.newBinariesToScan.add(root); |
3998 |
break; |
3999 |
break; |
3999 |
} |
4000 |
} |
Lines 4003-4009
Link Here
|
4003 |
// check roots that own a suspect |
4004 |
// check roots that own a suspect |
4004 |
FileObject rootFo = URLCache.getInstance().findFileObject(root, true); |
4005 |
FileObject rootFo = URLCache.getInstance().findFileObject(root, true); |
4005 |
if (rootFo != null) { |
4006 |
if (rootFo != null) { |
4006 |
if (f.first == rootFo || FileUtil.isParentOf(rootFo, f.first)) { |
4007 |
if (f.first() == rootFo || FileUtil.isParentOf(rootFo, f.first())) { |
4007 |
depCtx.newBinariesToScan.add(root); |
4008 |
depCtx.newBinariesToScan.add(root); |
4008 |
break; |
4009 |
break; |
4009 |
} |
4010 |
} |
Lines 4020-4031
Link Here
|
4020 |
FileObject rootFo = URLCache.getInstance().findFileObject(root, true); |
4021 |
FileObject rootFo = URLCache.getInstance().findFileObject(root, true); |
4021 |
if (rootFo != null) { |
4022 |
if (rootFo != null) { |
4022 |
for(Pair<FileObject, Boolean> f : suspects) { |
4023 |
for(Pair<FileObject, Boolean> f : suspects) { |
4023 |
if (f.first == rootFo || FileUtil.isParentOf(f.first, rootFo)) { |
4024 |
if (f.first() == rootFo || FileUtil.isParentOf(f.first(), rootFo)) { |
4024 |
Pair<FileObject, Boolean> pair = sourceRootsToScan.get(root); |
4025 |
Pair<FileObject, Boolean> pair = sourceRootsToScan.get(root); |
4025 |
if (pair == null) { |
4026 |
if (pair == null) { |
4026 |
pair = Pair.<FileObject, Boolean>of(rootFo, f.second); |
4027 |
pair = Pair.<FileObject, Boolean>of(rootFo, f.second()); |
4027 |
} else { |
4028 |
} else { |
4028 |
pair = Pair.<FileObject, Boolean>of(rootFo, pair.second || f.second); |
4029 |
pair = Pair.<FileObject, Boolean>of(rootFo, pair.second() || f.second()); |
4029 |
} |
4030 |
} |
4030 |
sourceRootsToScan.put(root, pair); |
4031 |
sourceRootsToScan.put(root, pair); |
4031 |
containers.add(f); |
4032 |
containers.add(f); |
Lines 4039-4045
Link Here
|
4039 |
for(Iterator<Pair<FileObject, Boolean>> it = suspects.iterator(); it.hasNext(); ) { |
4040 |
for(Iterator<Pair<FileObject, Boolean>> it = suspects.iterator(); it.hasNext(); ) { |
4040 |
Pair<FileObject, Boolean> f = it.next(); |
4041 |
Pair<FileObject, Boolean> f = it.next(); |
4041 |
Pair<FileObject, Boolean> root = entry.getValue(); |
4042 |
Pair<FileObject, Boolean> root = entry.getValue(); |
4042 |
if (FileUtil.isParentOf(root.first, f.first) && (root.second || !f.second)) { // second means fullRescan |
4043 |
if (FileUtil.isParentOf(root.first(), f.first()) && (root.second() || !f.second())) { // second means fullRescan |
4043 |
it.remove(); |
4044 |
it.remove(); |
4044 |
} |
4045 |
} |
4045 |
} |
4046 |
} |
Lines 4047-4053
Link Here
|
4047 |
|
4048 |
|
4048 |
for(Map.Entry<URL, Pair<FileObject, Boolean>> entry : sourceRootsToScan.entrySet()) { |
4049 |
for(Map.Entry<URL, Pair<FileObject, Boolean>> entry : sourceRootsToScan.entrySet()) { |
4049 |
depCtx.newRootsToScan.add(entry.getKey()); |
4050 |
depCtx.newRootsToScan.add(entry.getKey()); |
4050 |
if (entry.getValue().second) { |
4051 |
if (entry.getValue().second()) { |
4051 |
depCtx.fullRescanSourceRoots.add(entry.getKey()); |
4052 |
depCtx.fullRescanSourceRoots.add(entry.getKey()); |
4052 |
} |
4053 |
} |
4053 |
} |
4054 |
} |
Lines 4060-4073
Link Here
|
4060 |
for(Pair<FileObject, Boolean> f : suspects) { |
4061 |
for(Pair<FileObject, Boolean> f : suspects) { |
4061 |
for(URL root : scannedRoots2Dependencies.keySet()) { |
4062 |
for(URL root : scannedRoots2Dependencies.keySet()) { |
4062 |
FileObject rootFo = URLCache.getInstance().findFileObject(root, true); |
4063 |
FileObject rootFo = URLCache.getInstance().findFileObject(root, true); |
4063 |
if (rootFo != null && (f.first == rootFo || FileUtil.isParentOf(rootFo, f.first))) { |
4064 |
if (rootFo != null && (f.first() == rootFo || FileUtil.isParentOf(rootFo, f.first()))) { |
4064 |
Map<URL, Set<FileObject>> map = f.second ? fullRescanFiles : checkTimestampFiles; |
4065 |
Map<URL, Set<FileObject>> map = f.second() ? fullRescanFiles : checkTimestampFiles; |
4065 |
Set<FileObject> files = map.get(root); |
4066 |
Set<FileObject> files = map.get(root); |
4066 |
if (files == null) { |
4067 |
if (files == null) { |
4067 |
files = new HashSet<FileObject>(); |
4068 |
files = new HashSet<FileObject>(); |
4068 |
map.put(root, files); |
4069 |
map.put(root, files); |
4069 |
} |
4070 |
} |
4070 |
files.add(f.first); |
4071 |
files.add(f.first()); |
4071 |
break; |
4072 |
break; |
4072 |
} |
4073 |
} |
4073 |
} |
4074 |
} |
Lines 4631-4637
Link Here
|
4631 |
final long binaryScanStart = System.currentTimeMillis(); |
4632 |
final long binaryScanStart = System.currentTimeMillis(); |
4632 |
final Pair<Boolean,Collection<? extends URL>> res = pool.execute(); |
4633 |
final Pair<Boolean,Collection<? extends URL>> res = pool.execute(); |
4633 |
final long binaryScanEnd = System.currentTimeMillis(); |
4634 |
final long binaryScanEnd = System.currentTimeMillis(); |
4634 |
ctx.scannedBinaries.addAll(res.second); |
4635 |
ctx.scannedBinaries.addAll(res.second()); |
4635 |
if (LOGGER.isLoggable(Level.INFO)) { |
4636 |
if (LOGGER.isLoggable(Level.INFO)) { |
4636 |
LOGGER.log( |
4637 |
LOGGER.log( |
4637 |
Level.INFO, |
4638 |
Level.INFO, |
Lines 4642-4648
Link Here
|
4642 |
}); |
4643 |
}); |
4643 |
} |
4644 |
} |
4644 |
TEST_LOGGER.log(Level.FINEST, "scanBinary", ctx.newBinariesToScan); //NOI18N |
4645 |
TEST_LOGGER.log(Level.FINEST, "scanBinary", ctx.newBinariesToScan); //NOI18N |
4645 |
return res.first; |
4646 |
return res.first(); |
4646 |
} |
4647 |
} |
4647 |
|
4648 |
|
4648 |
protected final boolean scanBinary(URL root, BinaryIndexers binaryIndexers, AtomicInteger scannedRootsCnt) { |
4649 |
protected final boolean scanBinary(URL root, BinaryIndexers binaryIndexers, AtomicInteger scannedRootsCnt) { |
Lines 4664-4670
Link Here
|
4664 |
final Pair<Long,Map<Pair<String,Integer>,Integer>> lastState = ArchiveTimeStamps.getLastModified(file.getURL()); |
4665 |
final Pair<Long,Map<Pair<String,Integer>,Integer>> lastState = ArchiveTimeStamps.getLastModified(file.getURL()); |
4665 |
final boolean indexersUpToDate = checkBinaryIndexers(lastState, contexts); |
4666 |
final boolean indexersUpToDate = checkBinaryIndexers(lastState, contexts); |
4666 |
currentLastModified = file.lastModified().getTime(); |
4667 |
currentLastModified = file.lastModified().getTime(); |
4667 |
upToDate = indexersUpToDate && lastState.first == currentLastModified; |
4668 |
upToDate = indexersUpToDate && lastState.first() == currentLastModified; |
4668 |
} else { |
4669 |
} else { |
4669 |
currentLastModified = -1L; |
4670 |
currentLastModified = -1L; |
4670 |
upToDate = false; |
4671 |
upToDate = false; |
Lines 4926-4932
Link Here
|
4926 |
final Pair<String,Integer> indexerKey = Pair.<String,Integer>of(factory.getIndexerName(),factory.getIndexVersion()); |
4927 |
final Pair<String,Integer> indexerKey = Pair.<String,Integer>of(factory.getIndexerName(),factory.getIndexVersion()); |
4927 |
final Pair<SourceIndexerFactory,Context> ctx = transactionContexts.get(indexerKey); |
4928 |
final Pair<SourceIndexerFactory,Context> ctx = transactionContexts.get(indexerKey); |
4928 |
if (ctx != null) { |
4929 |
if (ctx != null) { |
4929 |
SPIAccessor.getInstance().index(indexer, Collections.<Indexable>emptySet(), ctx.second); |
4930 |
SPIAccessor.getInstance().index(indexer, Collections.<Indexable>emptySet(), ctx.second()); |
4930 |
} else { |
4931 |
} else { |
4931 |
LOGGER.log( |
4932 |
LOGGER.log( |
4932 |
Level.WARNING, "RefreshCifIndices ignored recently added factory: {0}", //NOI18N |
4933 |
Level.WARNING, "RefreshCifIndices ignored recently added factory: {0}", //NOI18N |
Lines 5870-5879
Link Here
|
5870 |
} |
5871 |
} |
5871 |
sourceRoots.clear(); |
5872 |
sourceRoots.clear(); |
5872 |
for(Map.Entry<URL, Pair<File, Boolean>> entry : binaryRoots.entrySet()) { |
5873 |
for(Map.Entry<URL, Pair<File, Boolean>> entry : binaryRoots.entrySet()) { |
5873 |
if (entry.getValue().second) { |
5874 |
if (entry.getValue().second()) { |
5874 |
safeRemoveFileChangeListener(this.binariesListener, entry.getValue().first); |
5875 |
safeRemoveFileChangeListener(this.binariesListener, entry.getValue().first()); |
5875 |
} else { |
5876 |
} else { |
5876 |
safeRemoveRecursiveListener(this.binariesListener, entry.getValue().first); |
5877 |
safeRemoveRecursiveListener(this.binariesListener, entry.getValue().first()); |
5877 |
} |
5878 |
} |
5878 |
} |
5879 |
} |
5879 |
binaryRoots.clear(); |
5880 |
binaryRoots.clear(); |
Lines 5949-5958
Link Here
|
5949 |
if (binariesListener != null) { |
5950 |
if (binariesListener != null) { |
5950 |
Pair<File, Boolean> pair = binaryRoots.remove(root); |
5951 |
Pair<File, Boolean> pair = binaryRoots.remove(root); |
5951 |
if (pair != null) { |
5952 |
if (pair != null) { |
5952 |
if (pair.second) { |
5953 |
if (pair.second()) { |
5953 |
safeRemoveFileChangeListener(binariesListener, pair.first); |
5954 |
safeRemoveFileChangeListener(binariesListener, pair.first()); |
5954 |
} else { |
5955 |
} else { |
5955 |
safeRemoveRecursiveListener(binariesListener, pair.first); |
5956 |
safeRemoveRecursiveListener(binariesListener, pair.first()); |
5956 |
} |
5957 |
} |
5957 |
} |
5958 |
} |
5958 |
} |
5959 |
} |