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

(-)a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java (-4 / +3 lines)
Lines 181-190 Link Here
181
import org.netbeans.modules.parsing.api.Snapshot;
181
import org.netbeans.modules.parsing.api.Snapshot;
182
import org.netbeans.modules.parsing.api.Source;
182
import org.netbeans.modules.parsing.api.Source;
183
import org.netbeans.modules.parsing.api.UserTask;
183
import org.netbeans.modules.parsing.api.UserTask;
184
import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
184
import org.netbeans.modules.parsing.impl.indexing.*;
185
import org.netbeans.modules.parsing.impl.indexing.FileObjectIndexable;
186
import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
187
import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
188
import org.netbeans.modules.parsing.impl.indexing.lucene.LayeredDocumentIndex;
185
import org.netbeans.modules.parsing.impl.indexing.lucene.LayeredDocumentIndex;
189
import org.netbeans.modules.parsing.impl.indexing.lucene.LuceneIndexFactory;
186
import org.netbeans.modules.parsing.impl.indexing.lucene.LuceneIndexFactory;
190
import org.netbeans.modules.parsing.impl.indexing.lucene.TestIndexFactoryImpl;
187
import org.netbeans.modules.parsing.impl.indexing.lucene.TestIndexFactoryImpl;
Lines 1562-1567 Link Here
1562
                false,
1559
                false,
1563
                false,                
1560
                false,                
1564
                false,
1561
                false,
1562
                SuspendSupport.NOP,
1563
                null,
1565
                null
1564
                null
1566
        );
1565
        );
1567
1566
(-)a/java.source/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java (-2 / +15 lines)
Lines 108-113 Link Here
108
import org.netbeans.modules.java.source.parsing.FileObjects;
108
import org.netbeans.modules.java.source.parsing.FileObjects;
109
import org.netbeans.modules.java.source.usages.ClassIndexImpl.UsageType;
109
import org.netbeans.modules.java.source.usages.ClassIndexImpl.UsageType;
110
import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
110
import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
111
import org.netbeans.modules.parsing.impl.indexing.SuspendSupport;
111
import org.netbeans.modules.parsing.lucene.support.LowMemoryWatcher;
112
import org.netbeans.modules.parsing.lucene.support.LowMemoryWatcher;
112
import org.netbeans.modules.parsing.spi.indexing.Context;
113
import org.netbeans.modules.parsing.spi.indexing.Context;
113
import org.openide.filesystems.FileObject;
114
import org.openide.filesystems.FileObject;
Lines 200-207 Link Here
200
     */
201
     */
201
    @Deprecated
202
    @Deprecated
202
    public final Result start (final @NonNull URL url, final AtomicBoolean canceled, final AtomicBoolean shutdown) throws IOException, IllegalArgumentException  {
203
    public final Result start (final @NonNull URL url, final AtomicBoolean canceled, final AtomicBoolean shutdown) throws IOException, IllegalArgumentException  {
203
        return start (url, SPIAccessor.getInstance().createContext(FileUtil.createMemoryFileSystem().getRoot(), url,
204
        return start (
204
                JavaIndex.NAME, JavaIndex.VERSION, null, false, false, false, null));
205
                url,
206
                SPIAccessor.getInstance().createContext(
207
                    FileUtil.createMemoryFileSystem().getRoot(),
208
                    url,
209
                    JavaIndex.NAME,
210
                    JavaIndex.VERSION,
211
                    null,
212
                    false,
213
                    false,
214
                    false,
215
                    SuspendSupport.NOP,
216
                    null,
217
                    null));
205
    }
218
    }
206
219
207
    public Result resume () throws IOException {
220
    public Result resume () throws IOException {
(-)a/parsing.api/apichanges.xml (+19 lines)
Lines 110-115 Link Here
110
<!-- ACTUAL CHANGES BEGIN HERE: -->
110
<!-- ACTUAL CHANGES BEGIN HERE: -->
111
111
112
  <changes>
112
  <changes>
113
  <change id="SuspendStatus">
114
      <api name="ParsingAPI"/>
115
      <summary>Added <code>SuspendStatus</code> service which can be used by indexers to find out if
116
      indexing is suspended.</summary>
117
      <version major="1" minor="52"/>
118
      <date day="17" month="2" year="2012"/>
119
      <author login="tzezula"/>
120
      <compatibility source="compatible" binary="compatible" semantic="compatible" deletion="no" addition="yes" modification="no"/>
121
      <description>
122
          <p>
123
               The indexing is suspended by the infrastructure when high priority request like index query or execution
124
               of <code>UserTask</code>, <code>ParserResultTask</code> is in progress. The <code>SuspendStatus</code>
125
               allows indexers to find out that indexing is suspended or to park while it's suspended.
126
          </p>
127
      </description>
128
      <class package="org.netbeans.modules.parsing.spi.indexing" name="SuspendedStatus"/>
129
      <class package="org.netbeans.modules.parsing.spi.indexing" name="Context"/>
130
      <issue number="208378"/>
131
  </change>
113
  <change id="IndexingAwareParserResultTask">
132
  <change id="IndexingAwareParserResultTask">
114
      <api name="ParsingAPI"/>
133
      <api name="ParsingAPI"/>
115
      <summary>Added <code>IndexingAwareParserResultTask</code> which is a specialization of <code>ParserResultTask</code>
134
      <summary>Added <code>IndexingAwareParserResultTask</code> which is a specialization of <code>ParserResultTask</code>
(-)a/parsing.api/nbproject/project.properties (-1 / +1 lines)
Lines 3-6 Link Here
3
javac.source=1.6
3
javac.source=1.6
4
javadoc.apichanges=${basedir}/apichanges.xml
4
javadoc.apichanges=${basedir}/apichanges.xml
5
javadoc.arch=${basedir}/arch.xml
5
javadoc.arch=${basedir}/arch.xml
6
spec.version.base=1.51.0
6
spec.version.base=1.52.0
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/Crawler.java (+1 lines)
Lines 42-47 Link Here
42
42
43
package org.netbeans.modules.parsing.impl.indexing;
43
package org.netbeans.modules.parsing.impl.indexing;
44
44
45
import org.netbeans.modules.parsing.spi.indexing.SuspendStatus;
45
import java.io.IOException;
46
import java.io.IOException;
46
import java.net.URL;
47
import java.net.URL;
47
import java.util.ArrayList;
48
import java.util.ArrayList;
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/FileObjectCrawler.java (+1 lines)
Lines 42-47 Link Here
42
42
43
package org.netbeans.modules.parsing.impl.indexing;
43
package org.netbeans.modules.parsing.impl.indexing;
44
44
45
import org.netbeans.modules.parsing.spi.indexing.SuspendStatus;
45
import java.io.File;
46
import java.io.File;
46
import java.io.IOException;
47
import java.io.IOException;
47
import java.util.Collection;
48
import java.util.Collection;
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java (-46 / +120 lines)
Lines 110-124 Link Here
110
import org.netbeans.modules.parsing.lucene.support.IndexManager;
110
import org.netbeans.modules.parsing.lucene.support.IndexManager;
111
import org.netbeans.modules.parsing.spi.ParseException;
111
import org.netbeans.modules.parsing.spi.ParseException;
112
import org.netbeans.modules.parsing.spi.Parser;
112
import org.netbeans.modules.parsing.spi.Parser;
113
import org.netbeans.modules.parsing.spi.indexing.BinaryIndexer;
113
import org.netbeans.modules.parsing.spi.indexing.*;
114
import org.netbeans.modules.parsing.spi.indexing.BinaryIndexerFactory;
115
import org.netbeans.modules.parsing.spi.indexing.Context;
116
import org.netbeans.modules.parsing.spi.indexing.CustomIndexer;
117
import org.netbeans.modules.parsing.spi.indexing.CustomIndexerFactory;
118
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexer;
119
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
120
import org.netbeans.modules.parsing.spi.indexing.Indexable;
121
import org.netbeans.modules.parsing.spi.indexing.SourceIndexerFactory;
122
import org.openide.filesystems.FileChangeAdapter;
114
import org.openide.filesystems.FileChangeAdapter;
123
import org.openide.filesystems.FileChangeListener;
115
import org.openide.filesystems.FileChangeListener;
124
import org.openide.filesystems.FileEvent;
116
import org.openide.filesystems.FileEvent;
Lines 176-182 Link Here
176
                        scannedRoots2Peers,
168
                        scannedRoots2Peers,
177
                        sourcesForBinaryRoots,
169
                        sourcesForBinaryRoots,
178
                        false,
170
                        false,
179
                        suspendSupport,
171
                        suspendSupport.getSuspendStatus(),
180
                        LogContext.create(LogContext.EventType.PATH, null));
172
                        LogContext.create(LogContext.EventType.PATH, null));
181
                }
173
                }
182
            }
174
            }
Lines 391-397 Link Here
391
                    forceRefresh,
383
                    forceRefresh,
392
                    sourcesForBinaryRoots.contains(rootUrl),
384
                    sourcesForBinaryRoots.contains(rootUrl),
393
                    steady,
385
                    steady,
394
                    suspendSupport,
386
                    suspendSupport.getSuspendStatus(),
395
                    logCtx);
387
                    logCtx);
396
            }
388
            }
397
        } else {
389
        } else {
Lines 402-408 Link Here
402
                checkEditor,
394
                checkEditor,
403
                forceRefresh,
395
                forceRefresh,
404
                sourcesForBinaryRoots.contains(rootUrl),
396
                sourcesForBinaryRoots.contains(rootUrl),
405
                suspendSupport,
397
                suspendSupport.getSuspendStatus(),
406
                logCtx);
398
                logCtx);
407
        }
399
        }
408
        return flw;
400
        return flw;
Lines 424-430 Link Here
424
        if (cifInfos == null) {
416
        if (cifInfos == null) {
425
            throw new InvalidParameterException("No CustomIndexerFactory with name: '" + indexerName + "'"); //NOI18N
417
            throw new InvalidParameterException("No CustomIndexerFactory with name: '" + indexerName + "'"); //NOI18N
426
        } else {
418
        } else {
427
            Work w = new RefreshCifIndices(cifInfos, scannedRoots2Dependencies, sourcesForBinaryRoots, suspendSupport, logCtx);
419
            Work w = new RefreshCifIndices(cifInfos, scannedRoots2Dependencies, sourcesForBinaryRoots, suspendSupport.getSuspendStatus(), logCtx);
428
            scheduleWork(w, false);
420
            scheduleWork(w, false);
429
        }
421
        }
430
    }
422
    }
Lines 453-459 Link Here
453
                logStatistics,
445
                logStatistics,
454
                filesOrFileObjects == null ? Collections.<Object>emptySet() : Arrays.asList(filesOrFileObjects),
446
                filesOrFileObjects == null ? Collections.<Object>emptySet() : Arrays.asList(filesOrFileObjects),
455
                fsRefreshInterceptor,
447
                fsRefreshInterceptor,
456
                suspendSupport,
448
                suspendSupport.getSuspendStatus(),
457
                logCtx),
449
                logCtx),
458
            wait);
450
            wait);
459
    }
451
    }
Lines 541-547 Link Here
541
                        scannedRoots2Peers,
533
                        scannedRoots2Peers,
542
                        sourcesForBinaryRoots,
534
                        sourcesForBinaryRoots,
543
                        !existingPathsChanged,
535
                        !existingPathsChanged,
544
                        suspendSupport,
536
                        suspendSupport.getSuspendStatus(),
545
                        logContext),
537
                        logContext),
546
                    false);
538
                    false);
547
        }
539
        }
Lines 554-560 Link Here
554
                    false,
546
                    false,
555
                    false,
547
                    false,
556
                    sourcesForBinaryRoots.contains(rootUrl),
548
                    sourcesForBinaryRoots.contains(rootUrl),
557
                    suspendSupport,
549
                    suspendSupport.getSuspendStatus(),
558
                    logContext),
550
                    logContext),
559
                false);
551
                false);
560
        }
552
        }
Lines 662-668 Link Here
662
                                    scannedRoots2Peers,
654
                                    scannedRoots2Peers,
663
                                    sourcesForBinaryRoots,
655
                                    sourcesForBinaryRoots,
664
                                    false,
656
                                    false,
665
                                    suspendSupport,
657
                                    suspendSupport.getSuspendStatus(),
666
                                    LogContext.create(LogContext.EventType.FILE, null));
658
                                    LogContext.create(LogContext.EventType.FILE, null));
667
                            } else {
659
                            } else {
668
                                //Already seen files work is enough
660
                                //Already seen files work is enough
Lines 677-683 Link Here
677
                                        true,
669
                                        true,
678
                                        sourcForBinaryRoot,
670
                                        sourcForBinaryRoot,
679
                                        true,
671
                                        true,
680
                                        suspendSupport,
672
                                        suspendSupport.getSuspendStatus(),
681
                                        LogContext.create(LogContext.EventType.FILE, null));
673
                                        LogContext.create(LogContext.EventType.FILE, null));
682
                                } else {
674
                                } else {
683
                                    //If no children nothing needs to be done - save some CPU time
675
                                    //If no children nothing needs to be done - save some CPU time
Lines 694-700 Link Here
694
                                true,
686
                                true,
695
                                sourcForBinaryRoot,
687
                                sourcForBinaryRoot,
696
                                true,
688
                                true,
697
                                suspendSupport,
689
                                suspendSupport.getSuspendStatus(),
698
                                LogContext.create(LogContext.EventType.FILE, null));
690
                                LogContext.create(LogContext.EventType.FILE, null));
699
                        }
691
                        }
700
                        if (wrk != null) {
692
                        if (wrk != null) {
Lines 710-716 Link Here
710
                if (root != null && isVisible(fo, root.second)) {
702
                if (root != null && isVisible(fo, root.second)) {
711
                    final Work wrk = new BinaryWork(
703
                    final Work wrk = new BinaryWork(
712
                        root.first,
704
                        root.first,
713
                        suspendSupport,
705
                        suspendSupport.getSuspendStatus(),
714
                        LogContext.create(LogContext.EventType.FILE, null));
706
                        LogContext.create(LogContext.EventType.FILE, null));
715
                    eventQueue.record(FileEventLog.FileOp.CREATE, root.first, null, fe, wrk);
707
                    eventQueue.record(FileEventLog.FileOp.CREATE, root.first, null, fe, wrk);
716
                    processed = true;
708
                    processed = true;
Lines 754-760 Link Here
754
                            true,
746
                            true,
755
                            sourceForBinaryRoot,
747
                            sourceForBinaryRoot,
756
                            true,
748
                            true,
757
                            suspendSupport,
749
                            suspendSupport.getSuspendStatus(),
758
                            LogContext.create(LogContext.EventType.FILE, null));
750
                            LogContext.create(LogContext.EventType.FILE, null));
759
                        eventQueue.record(FileEventLog.FileOp.CREATE, root.first, FileUtil.getRelativePath(root.second, fo), fe, wrk);
751
                        eventQueue.record(FileEventLog.FileOp.CREATE, root.first, FileUtil.getRelativePath(root.second, fo), fe, wrk);
760
                        processed = true;
752
                        processed = true;
Lines 767-773 Link Here
767
                if (root != null && isVisible(fo,root.second)) {
759
                if (root != null && isVisible(fo,root.second)) {
768
                    final Work wrk = new BinaryWork(
760
                    final Work wrk = new BinaryWork(
769
                        root.first,
761
                        root.first,
770
                        suspendSupport,
762
                        suspendSupport.getSuspendStatus(),
771
                        LogContext.create(LogContext.EventType.FILE, null));
763
                        LogContext.create(LogContext.EventType.FILE, null));
772
                    eventQueue.record(FileEventLog.FileOp.CREATE, root.first, null, fe, wrk);
764
                    eventQueue.record(FileEventLog.FileOp.CREATE, root.first, null, fe, wrk);
773
                    processed = true;
765
                    processed = true;
Lines 816-822 Link Here
816
                        final Work wrk = new DeleteWork(
808
                        final Work wrk = new DeleteWork(
817
                            root.first,
809
                            root.first,
818
                            Collections.singleton(relativePath),
810
                            Collections.singleton(relativePath),
819
                            suspendSupport,
811
                            suspendSupport.getSuspendStatus(),
820
                            LogContext.create(LogContext.EventType.FILE, null));
812
                            LogContext.create(LogContext.EventType.FILE, null));
821
                        eventQueue.record(FileEventLog.FileOp.DELETE, root.first, relativePath, fe, wrk);
813
                        eventQueue.record(FileEventLog.FileOp.DELETE, root.first, relativePath, fe, wrk);
822
                        processed = true;
814
                        processed = true;
Lines 833-839 Link Here
833
                if (root != null && isVisible(fo, root.second)) {
825
                if (root != null && isVisible(fo, root.second)) {
834
                    final Work wrk = new BinaryWork(
826
                    final Work wrk = new BinaryWork(
835
                        root.first,
827
                        root.first,
836
                        suspendSupport,
828
                        suspendSupport.getSuspendStatus(),
837
                        LogContext.create(LogContext.EventType.FILE, null));
829
                        LogContext.create(LogContext.EventType.FILE, null));
838
                    eventQueue.record(FileEventLog.FileOp.DELETE, root.first, null, fe, wrk);
830
                    eventQueue.record(FileEventLog.FileOp.DELETE, root.first, null, fe, wrk);
839
                    processed = true;
831
                    processed = true;
Lines 879-885 Link Here
879
                        final Work work = new DeleteWork(
871
                        final Work work = new DeleteWork(
880
                            root.first,
872
                            root.first,
881
                            Collections.singleton(oldFilePath),
873
                            Collections.singleton(oldFilePath),
882
                            suspendSupport,
874
                            suspendSupport.getSuspendStatus(),
883
                            LogContext.create(LogContext.EventType.FILE, null));
875
                            LogContext.create(LogContext.EventType.FILE, null));
884
                        eventQueue.record(FileEventLog.FileOp.DELETE, root.first, oldFilePath, fe, work);
876
                        eventQueue.record(FileEventLog.FileOp.DELETE, root.first, oldFilePath, fe, work);
885
                    } else {
877
                    } else {
Lines 889-895 Link Here
889
                            final Work work = new DeleteWork(
881
                            final Work work = new DeleteWork(
890
                                root.first,
882
                                root.first,
891
                                oldFilePaths,
883
                                oldFilePaths,
892
                                suspendSupport,
884
                                suspendSupport.getSuspendStatus(),
893
                                LogContext.create(LogContext.EventType.FILE, null));
885
                                LogContext.create(LogContext.EventType.FILE, null));
894
                            eventQueue.record(FileEventLog.FileOp.DELETE, root.first, path, fe, work);
886
                            eventQueue.record(FileEventLog.FileOp.DELETE, root.first, path, fe, work);
895
                        }
887
                        }
Lines 908-914 Link Here
908
                                true,
900
                                true,
909
                                sourceForBinaryRoot,
901
                                sourceForBinaryRoot,
910
                                true,
902
                                true,
911
                                suspendSupport,
903
                                suspendSupport.getSuspendStatus(),
912
                                LogContext.create(LogContext.EventType.FILE, null));
904
                                LogContext.create(LogContext.EventType.FILE, null));
913
                            eventQueue.record(FileEventLog.FileOp.CREATE, root.first, FileUtil.getRelativePath(rootFo, newFile), fe,flw);
905
                            eventQueue.record(FileEventLog.FileOp.CREATE, root.first, FileUtil.getRelativePath(rootFo, newFile), fe,flw);
914
                        }
906
                        }
Lines 930-936 Link Here
930
                                    null,
922
                                    null,
931
                                    fe,
923
                                    fe,
932
                                    new BinaryWork(oldBinaryRoot,
924
                                    new BinaryWork(oldBinaryRoot,
933
                                        suspendSupport,
925
                                        suspendSupport.getSuspendStatus(),
934
                                        LogContext.create(LogContext.EventType.FILE, null)));    //NOI18N
926
                                        LogContext.create(LogContext.EventType.FILE, null)));    //NOI18N
935
                        } catch (MalformedURLException mue) {
927
                        } catch (MalformedURLException mue) {
936
                            LOGGER.log(Level.WARNING, null, mue);
928
                            LOGGER.log(Level.WARNING, null, mue);
Lines 943-949 Link Here
943
                            null,
935
                            null,
944
                            fe,
936
                            fe,
945
                            new BinaryWork(root.first,
937
                            new BinaryWork(root.first,
946
                                suspendSupport,
938
                                suspendSupport.getSuspendStatus(),
947
                                LogContext.create(LogContext.EventType.FILE, null)));
939
                                LogContext.create(LogContext.EventType.FILE, null)));
948
                    processed = true;
940
                    processed = true;
949
                }
941
                }
Lines 977-983 Link Here
977
                        changedIndexers,
969
                        changedIndexers,
978
                        scannedRoots2Dependencies,
970
                        scannedRoots2Dependencies,
979
                        sourcesForBinaryRoots,
971
                        sourcesForBinaryRoots,
980
                        suspendSupport,
972
                        suspendSupport.getSuspendStatus(),
981
                        LogContext.create(LogContext.EventType.INDEXER,null)),
973
                        LogContext.create(LogContext.EventType.INDEXER,null)),
982
                        false);
974
                        false);
983
            }
975
            }
Lines 990-996 Link Here
990
                        changedIndexers,
982
                        changedIndexers,
991
                        scannedRoots2Dependencies,
983
                        scannedRoots2Dependencies,
992
                        sourcesForBinaryRoots,
984
                        sourcesForBinaryRoots,
993
                        suspendSupport,
985
                        suspendSupport.getSuspendStatus(),
994
                        LogContext.create(LogContext.EventType.INDEXER, null)),
986
                        LogContext.create(LogContext.EventType.INDEXER, null)),
995
                        false);
987
                        false);
996
            }
988
            }
Lines 1096-1102 Link Here
1096
                                    true,
1088
                                    true,
1097
                                    sourcesForBinaryRoots.contains(root.first),
1089
                                    sourcesForBinaryRoots.contains(root.first),
1098
                                    true,
1090
                                    true,
1099
                                    suspendSupport,
1091
                                    suspendSupport.getSuspendStatus(),
1100
                                    LogContext.create(LogContext.EventType.FILE, null));
1092
                                    LogContext.create(LogContext.EventType.FILE, null));
1101
                            jobs.put(root.first, job);
1093
                            jobs.put(root.first, job);
1102
                        } else {
1094
                        } else {
Lines 1315-1322 Link Here
1315
                    for(IndexerCache.IndexerInfo<CustomIndexerFactory> info : cifInfos) {
1307
                    for(IndexerCache.IndexerInfo<CustomIndexerFactory> info : cifInfos) {
1316
                        try {
1308
                        try {
1317
                            CustomIndexerFactory factory = info.getIndexerFactory();
1309
                            CustomIndexerFactory factory = info.getIndexerFactory();
1318
                            Context ctx = SPIAccessor.getInstance().createContext(CacheFolder.getDataFolder(root.first), root.first,
1310
                            Context ctx = SPIAccessor.getInstance().createContext(
1319
                                    factory.getIndexerName(), factory.getIndexVersion(), null, false, true, false, null);
1311
                                    CacheFolder.getDataFolder(root.first),
1312
                                    root.first,
1313
                                    factory.getIndexerName(),
1314
                                    factory.getIndexVersion(),
1315
                                    null,
1316
                                    false,
1317
                                    true,
1318
                                    false,
1319
                                    SuspendSupport.NOP,
1320
                                    null,
1321
                                    null);
1320
                            factory.filesDirty(dirty, ctx);
1322
                            factory.filesDirty(dirty, ctx);
1321
                        } catch (IOException ex) {
1323
                        } catch (IOException ex) {
1322
                            LOGGER.log(Level.WARNING, null, ex);
1324
                            LOGGER.log(Level.WARNING, null, ex);
Lines 1327-1334 Link Here
1327
                    for(IndexerCache.IndexerInfo<EmbeddingIndexerFactory> info : eifInfos) {
1329
                    for(IndexerCache.IndexerInfo<EmbeddingIndexerFactory> info : eifInfos) {
1328
                        try {
1330
                        try {
1329
                            EmbeddingIndexerFactory factory = info.getIndexerFactory();
1331
                            EmbeddingIndexerFactory factory = info.getIndexerFactory();
1330
                            Context ctx = SPIAccessor.getInstance().createContext(CacheFolder.getDataFolder(root.first), root.first,
1332
                            Context ctx = SPIAccessor.getInstance().createContext(
1331
                                    factory.getIndexerName(), factory.getIndexVersion(), null, false, true, false, null);
1333
                                    CacheFolder.getDataFolder(root.first),
1334
                                    root.first,
1335
                                    factory.getIndexerName(),
1336
                                    factory.getIndexVersion(),
1337
                                    null,
1338
                                    false,
1339
                                    true,
1340
                                    false,
1341
                                    SuspendSupport.NOP,
1342
                                    null,
1343
                                    null);
1332
                            factory.filesDirty(dirty, ctx);
1344
                            factory.filesDirty(dirty, ctx);
1333
                        } catch (IOException ex) {
1345
                        } catch (IOException ex) {
1334
                            LOGGER.log(Level.WARNING, null, ex);
1346
                            LOGGER.log(Level.WARNING, null, ex);
Lines 1391-1397 Link Here
1391
                scannedRoots2Peers,
1403
                scannedRoots2Peers,
1392
                sourcesForBinaryRoots,
1404
                sourcesForBinaryRoots,
1393
                true,
1405
                true,
1394
                suspendSupport,
1406
                suspendSupport.getSuspendStatus(),
1395
                work == null ?
1407
                work == null ?
1396
                    LogContext.create(LogContext.EventType.PATH, null)
1408
                    LogContext.create(LogContext.EventType.PATH, null)
1397
                    : work.getLogContext()), false);
1409
                    : work.getLogContext()), false);
Lines 2095-2102 Link Here
2095
                final Pair<String,Integer> key = Pair.of(factory.getIndexerName(),factory.getIndexVersion());
2107
                final Pair<String,Integer> key = Pair.of(factory.getIndexerName(),factory.getIndexVersion());
2096
                Pair<SourceIndexerFactory,Context> value = ctxToFinish.get(key);
2108
                Pair<SourceIndexerFactory,Context> value = ctxToFinish.get(key);
2097
                if (value == null) {
2109
                if (value == null) {
2098
                    final Context ctx = SPIAccessor.getInstance().createContext(cacheRoot, root, factory.getIndexerName(), factory.getIndexVersion(), null,
2110
                    final Context ctx = SPIAccessor.getInstance().createContext(
2099
                        followUpJob, checkEditor, sourceForBinaryRoot, getShuttdownRequest());
2111
                            cacheRoot,
2112
                            root,
2113
                            factory.getIndexerName(),
2114
                            factory.getIndexVersion(),
2115
                            null,
2116
                            followUpJob,
2117
                            checkEditor,
2118
                            sourceForBinaryRoot,
2119
                            getSuspendStatus(),
2120
                            getShuttdownRequest(),
2121
                            null);
2100
                    value = Pair.<SourceIndexerFactory,Context>of(factory,ctx);
2122
                    value = Pair.<SourceIndexerFactory,Context>of(factory,ctx);
2101
                    ctxToFinish.put(key,value);
2123
                    ctxToFinish.put(key,value);
2102
                }
2124
                }
Lines 2124-2131 Link Here
2124
                    final Pair<String,Integer> key = Pair.of(eif.getIndexerName(), eif.getIndexVersion());
2146
                    final Pair<String,Integer> key = Pair.of(eif.getIndexerName(), eif.getIndexVersion());
2125
                    Pair<SourceIndexerFactory,Context> value = ctxToFinish.get(key);
2147
                    Pair<SourceIndexerFactory,Context> value = ctxToFinish.get(key);
2126
                    if (value == null) {
2148
                    if (value == null) {
2127
                        final Context context = SPIAccessor.getInstance().createContext(cacheRoot, root, eif.getIndexerName(), eif.getIndexVersion(), null,
2149
                        final Context context = SPIAccessor.getInstance().createContext(
2128
                                followUpJob, checkEditor, sourceForBinaryRoot, null);
2150
                                cacheRoot,
2151
                                root,
2152
                                eif.getIndexerName(),
2153
                                eif.getIndexVersion(),
2154
                                null,
2155
                                followUpJob,
2156
                                checkEditor,
2157
                                sourceForBinaryRoot,
2158
                                getSuspendStatus(),
2159
                                getShuttdownRequest(),
2160
                                null);
2129
                        value = Pair.<SourceIndexerFactory,Context>of(eif,context);
2161
                        value = Pair.<SourceIndexerFactory,Context>of(eif,context);
2130
                        ctxToFinish.put(key, value);
2162
                        ctxToFinish.put(key, value);
2131
                    }
2163
                    }
Lines 2284-2290 Link Here
2284
                        final Pair<String,Integer> key = Pair.of(factory.getIndexerName(),factory.getIndexVersion());
2316
                        final Pair<String,Integer> key = Pair.of(factory.getIndexerName(),factory.getIndexVersion());
2285
                        Pair<SourceIndexerFactory,Context> value = contexts.get(key);
2317
                        Pair<SourceIndexerFactory,Context> value = contexts.get(key);
2286
                        if (value == null) {
2318
                        if (value == null) {
2287
                            final Context ctx = SPIAccessor.getInstance().createContext(cacheRoot, root, factory.getIndexerName(), factory.getIndexVersion(), null, followUpJob, checkEditor, sourceForBinaryRoot, getShuttdownRequest());
2319
                            final Context ctx = SPIAccessor.getInstance().createContext(
2320
                                    cacheRoot,
2321
                                    root,
2322
                                    factory.getIndexerName(),
2323
                                    factory.getIndexVersion(),
2324
                                    null,
2325
                                    followUpJob,
2326
                                    checkEditor,
2327
                                    sourceForBinaryRoot,
2328
                                    getSuspendStatus(),
2329
                                    getShuttdownRequest(),
2330
                                    null);
2288
                            value = Pair.<SourceIndexerFactory,Context>of(factory,ctx);
2331
                            value = Pair.<SourceIndexerFactory,Context>of(factory,ctx);
2289
                            contexts.put(key,value);
2332
                            contexts.put(key,value);
2290
                        }
2333
                        }
Lines 2383-2389 Link Here
2383
                                    final Pair<String,Integer> key = Pair.of(factory.getIndexerName(),factory.getIndexVersion());
2426
                                    final Pair<String,Integer> key = Pair.of(factory.getIndexerName(),factory.getIndexVersion());
2384
                                    Pair<SourceIndexerFactory,Context> value = contexts.get(key);
2427
                                    Pair<SourceIndexerFactory,Context> value = contexts.get(key);
2385
                                    if (value == null) {
2428
                                    if (value == null) {
2386
                                        final Context ctx = SPIAccessor.getInstance().createContext(cacheRoot, root, factory.getIndexerName(), factory.getIndexVersion(), null, followUpJob, checkEditor, sourceForBinaryRoot, getShuttdownRequest());
2429
                                        final Context ctx = SPIAccessor.getInstance().createContext(
2430
                                                cacheRoot,
2431
                                                root,
2432
                                                factory.getIndexerName(),
2433
                                                factory.getIndexVersion(),
2434
                                                null,
2435
                                                followUpJob,
2436
                                                checkEditor,
2437
                                                sourceForBinaryRoot,
2438
                                                getSuspendStatus(),
2439
                                                getShuttdownRequest(),
2440
                                                null);
2387
                                        value = Pair.<SourceIndexerFactory,Context>of(factory,ctx);
2441
                                        value = Pair.<SourceIndexerFactory,Context>of(factory,ctx);
2388
                                        contexts.put(key,value);
2442
                                        contexts.put(key,value);
2389
                                    }
2443
                                    }
Lines 2482-2489 Link Here
2482
            final FileObject cacheRoot = CacheFolder.getDataFolder(root);
2536
            final FileObject cacheRoot = CacheFolder.getDataFolder(root);
2483
            for(BinaryIndexerFactory bif : indexers.bifs) {
2537
            for(BinaryIndexerFactory bif : indexers.bifs) {
2484
                final Context ctx = SPIAccessor.getInstance().createContext(
2538
                final Context ctx = SPIAccessor.getInstance().createContext(
2485
                    cacheRoot, root, bif.getIndexerName(), bif.getIndexVersion(), null, false, false,
2539
                    cacheRoot,
2486
                    false, getShuttdownRequest());
2540
                    root,
2541
                    bif.getIndexerName(),
2542
                    bif.getIndexVersion(),
2543
                    null,
2544
                    false,
2545
                    false,
2546
                    false,
2547
                    getSuspendStatus(),
2548
                    getShuttdownRequest(),
2549
                    null);
2487
                contexts.put(bif, ctx);
2550
                contexts.put(bif, ctx);
2488
            }
2551
            }
2489
        }
2552
        }
Lines 2630-2636 Link Here
2630
                                            final Pair<String,Integer> key = Pair.of(indexerName,indexerVersion);
2693
                                            final Pair<String,Integer> key = Pair.of(indexerName,indexerVersion);
2631
                                            Pair<SourceIndexerFactory,Context> value = transactionContexts.get(key);
2694
                                            Pair<SourceIndexerFactory,Context> value = transactionContexts.get(key);
2632
                                            if (value == null) {
2695
                                            if (value == null) {
2633
                                                final Context context = SPIAccessor.getInstance().createContext(cache, rootURL, indexerName, indexerVersion, null, followUpJob, checkEditor, sourceForBinaryRoot, null);
2696
                                                final Context context = SPIAccessor.getInstance().createContext(
2697
                                                        cache,
2698
                                                        rootURL,
2699
                                                        indexerName,
2700
                                                        indexerVersion,
2701
                                                        null,
2702
                                                        followUpJob,
2703
                                                        checkEditor,
2704
                                                        sourceForBinaryRoot,
2705
                                                        getSuspendStatus(),
2706
                                                        getShuttdownRequest(),
2707
                                                        null);
2634
                                                value = Pair.<SourceIndexerFactory,Context>of(indexerFactory,context);
2708
                                                value = Pair.<SourceIndexerFactory,Context>of(indexerFactory,context);
2635
                                                transactionContexts.put(key,value);
2709
                                                transactionContexts.put(key,value);
2636
                                            }
2710
                                            }
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/SPIAccessor.java (-19 / +5 lines)
Lines 89-114 Link Here
89
            boolean followUpJob,
89
            boolean followUpJob,
90
            boolean checkForEditorModifications,
90
            boolean checkForEditorModifications,
91
            boolean sourceForBinaryRoot,
91
            boolean sourceForBinaryRoot,
92
            CancelRequest cancelRequest,
92
            @NonNull final SuspendStatus suspendedStatus,
93
            @NullAllowed final CancelRequest cancelRequest,
93
            @NullAllowed final LogContext logContext) throws IOException;
94
            @NullAllowed final LogContext logContext) throws IOException;
94
95
    
95
    public final Context createContext (
96
    @NonNull
96
            final FileObject indexFolder, final URL rootURL,
97
    public abstract SuspendStatus createSuspendStatus(@NonNull SuspendSupport.SuspendStatusImpl impl);
97
            String indexerName, int indexerVersion, IndexFactoryImpl factory,
98
            boolean followUpJob, boolean checkForEditorModifications,
99
            boolean sourceForBinaryRoot, CancelRequest cancelRequest) throws IOException {
100
        return createContext(
101
            indexFolder,
102
            rootURL,
103
            indexerName,
104
            indexerVersion,
105
            factory,
106
            followUpJob,
107
            checkForEditorModifications,
108
            sourceForBinaryRoot,
109
            cancelRequest,
110
            null);
111
    }
112
98
113
    public abstract void context_attachIndexingSupport(Context context, IndexingSupport support);
99
    public abstract void context_attachIndexingSupport(Context context, IndexingSupport support);
114
100
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/SuspendSupport.java (-34 / +55 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.modules.parsing.impl.indexing;
42
package org.netbeans.modules.parsing.impl.indexing;
43
43
44
import org.netbeans.modules.parsing.spi.indexing.SuspendStatus;
44
import java.util.Arrays;
45
import java.util.Arrays;
45
import java.util.logging.Level;
46
import java.util.logging.Level;
46
import java.util.logging.Logger;
47
import java.util.logging.Logger;
Lines 53-59 Link Here
53
 *
54
 *
54
 * @author Tomas Zezula
55
 * @author Tomas Zezula
55
 */
56
 */
56
final class SuspendSupport implements SuspendStatus {
57
public final class SuspendSupport {
57
58
58
    private static final Logger LOG = Logger.getLogger(SuspendSupport.class.getName());
59
    private static final Logger LOG = Logger.getLogger(SuspendSupport.class.getName());
59
    private static final boolean NO_SUSPEND = Boolean.getBoolean("SuspendSupport.disabled");    //NOI18N
60
    private static final boolean NO_SUSPEND = Boolean.getBoolean("SuspendSupport.disabled");    //NOI18N
Lines 61-75 Link Here
61
    private final RequestProcessor worker;
62
    private final RequestProcessor worker;
62
    private final Object lock = new Object();
63
    private final Object lock = new Object();
63
    private final ThreadLocal<Boolean> ignoreSuspend = new ThreadLocal<Boolean>();
64
    private final ThreadLocal<Boolean> ignoreSuspend = new ThreadLocal<Boolean>();
65
    private final SuspendStatus suspendStatus = SPIAccessor.getInstance().createSuspendStatus(new DefaultImpl());
64
    //@GuardedBy("lock")
66
    //@GuardedBy("lock")
65
    private int suspedDepth;
67
    private int suspedDepth;
68
    
69
    public static final SuspendStatus NOP = SPIAccessor.getInstance().createSuspendStatus(new NopImpl());
66
70
71
    
72
    @NonNull
73
    public SuspendStatus getSuspendStatus() {
74
        return suspendStatus;
75
    }
76
    
77
    public static interface SuspendStatusImpl {
78
        public boolean isSuspended();
79
        public void parkWhileSuspended() throws InterruptedException;
80
    }
81
    
82
    
83
    
84
//-- Package private --
85
    
67
    SuspendSupport(@NonNull final RequestProcessor rp) {
86
    SuspendSupport(@NonNull final RequestProcessor rp) {
68
        Parameters.notNull("rp", rp);   //NOI18N
87
        Parameters.notNull("rp", rp);   //NOI18N
69
        this.worker = rp;
88
        this.worker = rp;
70
    }
89
    }
71
90
72
    public void suspend() {
91
    void suspend() {
73
        if (NO_SUSPEND) {
92
        if (NO_SUSPEND) {
74
            return;
93
            return;
75
        }
94
        }
Lines 87-93 Link Here
87
        }
106
        }
88
    }
107
    }
89
108
90
    public void resume() {
109
    void resume() {
91
        if (NO_SUSPEND) {
110
        if (NO_SUSPEND) {
92
            return;
111
            return;
93
        }
112
        }
Lines 104-110 Link Here
104
        }
123
        }
105
    }
124
    }
106
    
125
    
107
    public void runWithNoSuspend(final Runnable work) {
126
    void runWithNoSuspend(final Runnable work) {
108
        ignoreSuspend.set(Boolean.TRUE);
127
        ignoreSuspend.set(Boolean.TRUE);
109
        try {
128
        try {
110
            work.run();
129
            work.run();
Lines 112-147 Link Here
112
            ignoreSuspend.remove();
131
            ignoreSuspend.remove();
113
        }
132
        }
114
    }
133
    }
115
116
    @Override
117
    public boolean isSuspended() {
118
        if (ignoreSuspend.get() == Boolean.TRUE) {
119
            return false;
120
        }
121
        synchronized(lock) {
122
            return suspedDepth > 0;
123
        }
124
    }
125
126
    @Override
127
    public void parkWhileSuspended() throws InterruptedException {
128
        if (ignoreSuspend.get() == Boolean.TRUE) {
129
            return;
130
        }
131
        synchronized(lock) {
132
            boolean parked = false;
133
            while (suspedDepth > 0) {
134
                LOG.fine("PARK");   //NOI18N
135
                lock.wait();
136
                parked = true;
137
            }
138
            if (LOG.isLoggable(Level.FINE) && parked) {
139
                LOG.fine("UNPARK");   //NOI18N
140
            }
141
        }
142
    }
143
    
134
    
144
    static final SuspendStatus NOP = new SuspendStatus () {
135
    private static final class NopImpl implements SuspendStatusImpl {
145
        @Override
136
        @Override
146
        public boolean isSuspended() {
137
        public boolean isSuspended() {
147
            return false;
138
            return false;
Lines 149-154 Link Here
149
        @Override
140
        @Override
150
        public void parkWhileSuspended() throws InterruptedException {
141
        public void parkWhileSuspended() throws InterruptedException {
151
        }
142
        }
152
    };
143
    }
144
    
145
    private final class DefaultImpl implements SuspendStatusImpl {
146
        @Override
147
        public boolean isSuspended() {
148
            if (ignoreSuspend.get() == Boolean.TRUE) {
149
                return false;
150
            }
151
            synchronized(lock) {
152
                return suspedDepth > 0;
153
            }
154
        }
155
156
        @Override
157
        public void parkWhileSuspended() throws InterruptedException {
158
            if (ignoreSuspend.get() == Boolean.TRUE) {
159
                return;
160
            }
161
            synchronized(lock) {
162
                boolean parked = false;
163
                while (suspedDepth > 0) {
164
                    LOG.fine("PARK");   //NOI18N
165
                    lock.wait();
166
                    parked = true;
167
                }
168
                if (LOG.isLoggable(Level.FINE) && parked) {
169
                    LOG.fine("UNPARK");   //NOI18N
170
                }
171
            }
172
        }
173
    }
153
174
154
}
175
}
(-)a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/Context.java (-1 / +15 lines)
Lines 79-84 Link Here
79
    private final boolean checkForEditorModifications;
79
    private final boolean checkForEditorModifications;
80
    private final boolean sourceForBinaryRoot;
80
    private final boolean sourceForBinaryRoot;
81
    private final CancelRequest cancelRequest;
81
    private final CancelRequest cancelRequest;
82
    private final SuspendStatus suspendedStatus;
82
    private final LogContext logContext;
83
    private final LogContext logContext;
83
    private final Map<String,Object> props;
84
    private final Map<String,Object> props;
84
    private FileObject indexFolder;
85
    private FileObject indexFolder;
Lines 94-100 Link Here
94
             final IndexFactoryImpl factory, boolean followUpJob,
95
             final IndexFactoryImpl factory, boolean followUpJob,
95
             final boolean checkForEditorModifications,
96
             final boolean checkForEditorModifications,
96
             final boolean sourceForBinaryRoot,
97
             final boolean sourceForBinaryRoot,
97
             final CancelRequest cancelRequest,
98
             @NonNull final SuspendStatus suspendedStatus,
99
             @NullAllowed final CancelRequest cancelRequest,
98
             @NullAllowed final LogContext logContext
100
             @NullAllowed final LogContext logContext
99
    ) throws IOException {
101
    ) throws IOException {
100
        assert indexBaseFolder != null;
102
        assert indexBaseFolder != null;
Lines 109-114 Link Here
109
        this.checkForEditorModifications = checkForEditorModifications;
111
        this.checkForEditorModifications = checkForEditorModifications;
110
        this.sourceForBinaryRoot = sourceForBinaryRoot;
112
        this.sourceForBinaryRoot = sourceForBinaryRoot;
111
        this.cancelRequest = cancelRequest;
113
        this.cancelRequest = cancelRequest;
114
        this.suspendedStatus = suspendedStatus;
112
        this.logContext = logContext;
115
        this.logContext = logContext;
113
        this.props = new HashMap<String, Object>();
116
        this.props = new HashMap<String, Object>();
114
    }
117
    }
Lines 256-261 Link Here
256
    public boolean isCancelled() {
259
    public boolean isCancelled() {
257
        return cancelRequest == null ? false : cancelRequest.isRaised();
260
        return cancelRequest == null ? false : cancelRequest.isRaised();
258
    }
261
    }
262
    
263
    /**
264
     * Returns {@link SuspendStatus} providing information
265
     * about indexing suspension.
266
     * @return the {@link SuspendStatus}
267
     * @since 1.52
268
     */
269
    @NonNull
270
    public SuspendStatus getSuspendStatus() {
271
        return suspendedStatus;
272
    }
259
273
260
    // -----------------------------------------------------------------------
274
    // -----------------------------------------------------------------------
261
    // Package private implementation
275
    // Package private implementation
(-)a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/Indexable.java (-1 / +10 lines)
Lines 54-59 Link Here
54
import org.netbeans.modules.parsing.impl.indexing.LogContext;
54
import org.netbeans.modules.parsing.impl.indexing.LogContext;
55
import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
55
import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
56
import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
56
import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
57
import org.netbeans.modules.parsing.impl.indexing.SuspendSupport.SuspendStatusImpl;
57
import org.netbeans.modules.parsing.spi.Parser.Result;
58
import org.netbeans.modules.parsing.spi.Parser.Result;
58
import org.netbeans.modules.parsing.spi.indexing.support.IndexingSupport;
59
import org.netbeans.modules.parsing.spi.indexing.support.IndexingSupport;
59
import org.openide.filesystems.FileObject;
60
import org.openide.filesystems.FileObject;
Lines 169-175 Link Here
169
                boolean followUpJob,
170
                boolean followUpJob,
170
                boolean checkForEditorModifications,
171
                boolean checkForEditorModifications,
171
                boolean sourceForBinaryRoot,
172
                boolean sourceForBinaryRoot,
172
                CancelRequest cancelRequest,
173
                @NonNull SuspendStatus suspendedStatus,
174
                @NullAllowed CancelRequest cancelRequest,
173
                @NullAllowed final LogContext logContext) throws IOException {
175
                @NullAllowed final LogContext logContext) throws IOException {
174
            return new Context(
176
            return new Context(
175
                    indexFolder,
177
                    indexFolder,
Lines 180-189 Link Here
180
                    followUpJob,
182
                    followUpJob,
181
                    checkForEditorModifications,
183
                    checkForEditorModifications,
182
                    sourceForBinaryRoot,
184
                    sourceForBinaryRoot,
185
                    suspendedStatus,
183
                    cancelRequest,
186
                    cancelRequest,
184
                    logContext);
187
                    logContext);
185
        }
188
        }
186
189
190
        @NonNull
191
        @Override
192
        public SuspendStatus createSuspendStatus(@NonNull final SuspendStatusImpl impl) {
193
            return new SuspendStatus(impl);
194
        }
195
187
        @Override
196
        @Override
188
        public String getIndexerName(Context ctx) {
197
        public String getIndexerName(Context ctx) {
189
            assert ctx != null;
198
            assert ctx != null;
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/SuspendStatus.java (-5 / +44 lines)
Lines 39-51 Link Here
39
 *
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
41
 */
42
package org.netbeans.modules.parsing.impl.indexing;
42
package org.netbeans.modules.parsing.spi.indexing;
43
44
import org.netbeans.api.annotations.common.NonNull;
45
import org.netbeans.modules.parsing.api.UserTask;
46
import org.netbeans.modules.parsing.impl.indexing.SuspendSupport;
47
import org.netbeans.modules.parsing.spi.ParserResultTask;
48
import org.openide.util.Parameters;
43
49
44
/**
50
/**
45
 *
51
 * A service for indexers to check if an indexing is suspended or
52
 * to park while indexing is suspended.
53
 * The indexing is suspended by the infrastructure when high priority request
54
 * like index query or execution of {@link UserTask}, {@link ParserResultTask}
55
 * is in progress.
56
 * The instance of the {@link SuspendStatus} can be obtained from
57
 * {@link Context#getSuspendStatus()}. The infrastructure suspends indexing
58
 * automatically. The {@link EmbeddingIndexer}s are suspended with a file granularity.
59
 * The {@link CustomIndexer}s are suspended with a source root granularity.
60
 * This service can be used for more fine granularity suspending especially for
61
 * {@link CustomIndexer}s.
46
 * @author Tomas Zezula
62
 * @author Tomas Zezula
63
 * @since 1.52
47
 */
64
 */
48
interface SuspendStatus {
65
public final class SuspendStatus {
49
    boolean isSuspended();
66
    
50
    void parkWhileSuspended() throws InterruptedException;
67
    private final SuspendSupport.SuspendStatusImpl impl;
68
    
69
    SuspendStatus(@NonNull final SuspendSupport.SuspendStatusImpl impl) {
70
        Parameters.notNull("impl", impl);   //NOI18N
71
        this.impl = impl;
72
    }
73
74
    /**
75
     * Checks if an indexing is suspended.
76
     * @return true if an indexing is suspended.
77
     */
78
    public boolean isSuspended() {
79
        return impl.isSuspended();
80
    }
81
    
82
    /**
83
     * Parks a current (caller) thread while an indexing is suspended.
84
     * Threading: The caller should not hold any locks when calling this method.
85
     * @throws InterruptedException if the caller is interrupted.
86
     */
87
    public void parkWhileSuspended() throws InterruptedException {
88
        impl.parkWhileSuspended();
89
    }
51
}
90
}
(-)a/parsing.api/test/unit/src/org/netbeans/modules/parsing/spi/indexing/support/IndexingSupportTest.java (-9 / +50 lines)
Lines 59-69 Link Here
59
import org.netbeans.modules.parsing.impl.indexing.lucene.LuceneIndexFactory;
59
import org.netbeans.modules.parsing.impl.indexing.lucene.LuceneIndexFactory;
60
import org.netbeans.modules.parsing.lucene.support.DocumentIndex;
60
import org.netbeans.modules.parsing.lucene.support.DocumentIndex;
61
import org.netbeans.modules.parsing.lucene.support.Queries;
61
import org.netbeans.modules.parsing.lucene.support.Queries;
62
import org.netbeans.modules.parsing.spi.indexing.Context;
62
import org.netbeans.modules.parsing.spi.indexing.*;
63
import org.netbeans.modules.parsing.spi.indexing.CustomIndexer;
64
import org.netbeans.modules.parsing.spi.indexing.CustomIndexerFactory;
65
import org.netbeans.modules.parsing.spi.indexing.Indexable;
66
import org.netbeans.modules.parsing.spi.indexing.PathRecognizer;
67
import org.netbeans.spi.java.classpath.ClassPathProvider;
63
import org.netbeans.spi.java.classpath.ClassPathProvider;
68
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
64
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
69
import org.openide.filesystems.FileObject;
65
import org.openide.filesystems.FileObject;
Lines 107-115 Link Here
107
    }
103
    }
108
104
109
    public void testIndexingSupportInstances () throws Exception {
105
    public void testIndexingSupportInstances () throws Exception {
110
        final Context ctx1 = SPIAccessor.getInstance().createContext(CacheFolder.getDataFolder(root.getURL()), root.getURL(), "fooIndexer", 1, null, false, false, false, null);
106
        final Context ctx1 = SPIAccessor.getInstance().createContext(
107
                CacheFolder.getDataFolder(
108
                root.toURL()),
109
                root.toURL(),
110
                "fooIndexer",
111
                1,
112
                null,
113
                false,
114
                false,
115
                false,
116
                SuspendSupport.NOP,
117
                null,
118
                null);
111
        assertNotNull(ctx1);
119
        assertNotNull(ctx1);
112
        final Context ctx2 = SPIAccessor.getInstance().createContext(CacheFolder.getDataFolder(root.getURL()), root.getURL(), "embIndexer", 1, null, false, false, false, null);
120
        final Context ctx2 = SPIAccessor.getInstance().createContext(
121
                CacheFolder.getDataFolder(root.toURL()),
122
                root.toURL(),
123
                "embIndexer",
124
                1,
125
                null,
126
                false,
127
                false,
128
                false,
129
                SuspendSupport.NOP,
130
                null,
131
                null);
113
        assertNotNull(ctx2);
132
        assertNotNull(ctx2);
114
133
115
        final IndexingSupport is1 = IndexingSupport.getInstance(ctx1);
134
        final IndexingSupport is1 = IndexingSupport.getInstance(ctx1);
Lines 123-129 Link Here
123
142
124
    public void testIndexingQuerySupport () throws Exception {
143
    public void testIndexingQuerySupport () throws Exception {
125
        // index
144
        // index
126
        final Context ctx = SPIAccessor.getInstance().createContext(CacheFolder.getDataFolder(root.getURL()), root.getURL(), "fooIndexer", 1, null, false, false, false, null);
145
        final Context ctx = SPIAccessor.getInstance().createContext(
146
                CacheFolder.getDataFolder(root.toURL()),
147
                root.toURL(),
148
                "fooIndexer",
149
                1,
150
                null,
151
                false,
152
                false,
153
                false,
154
                SuspendSupport.NOP,
155
                null,
156
                null);
127
        assertNotNull(ctx);
157
        assertNotNull(ctx);
128
        final Indexable i1 = SPIAccessor.getInstance().create(new FileObjectIndexable(root, f1));
158
        final Indexable i1 = SPIAccessor.getInstance().create(new FileObjectIndexable(root, f1));
129
        final IndexingSupport is = IndexingSupport.getInstance(ctx);
159
        final IndexingSupport is = IndexingSupport.getInstance(ctx);
Lines 195-201 Link Here
195
225
196
    public void testQuerySupportCaching() throws Exception {
226
    public void testQuerySupportCaching() throws Exception {
197
        // index
227
        // index
198
        final Context ctx = SPIAccessor.getInstance().createContext(CacheFolder.getDataFolder(root.getURL()), root.getURL(), "fooIndexer", 1, null, false, false, false, null);
228
        final Context ctx = SPIAccessor.getInstance().createContext(
229
                CacheFolder.getDataFolder(root.toURL()),
230
                root.toURL(),
231
                "fooIndexer",
232
                1,
233
                null,
234
                false,
235
                false,
236
                false,
237
                SuspendSupport.NOP,
238
                null,
239
                null);
199
        assertNotNull(ctx);
240
        assertNotNull(ctx);
200
        final Indexable i1 = SPIAccessor.getInstance().create(new FileObjectIndexable(root, f1));
241
        final Indexable i1 = SPIAccessor.getInstance().create(new FileObjectIndexable(root, f1));
201
        final IndexingSupport is = IndexingSupport.getInstance(ctx);
242
        final IndexingSupport is = IndexingSupport.getInstance(ctx);

Return to bug 208378