Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 184840
Collapse All | Expand All

(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java (-25 / +41 lines)
 Lines 411-417    Link Here 
411
    
411
    
412
    final FileEventLog eventQueue = new FileEventLog();
412
    final FileEventLog eventQueue = new FileEventLog();
413
413
414
    private void fileFolderCreatedImpl(FileEvent fe, boolean source) {
414
    private void fileFolderCreatedImpl(FileEvent fe, Boolean source) {
415
        FileObject fo = fe.getFile();
415
        FileObject fo = fe.getFile();
416
        if (isCacheFile(fo)) {
416
        if (isCacheFile(fo)) {
417
            return;
417
            return;
 Lines 428-434    Link Here 
428
        Pair<URL, FileObject> root = null;
428
        Pair<URL, FileObject> root = null;
429
        
429
        
430
        if (fo != null && fo.isValid() && VisibilityQuery.getDefault().isVisible(fo)) {
430
        if (fo != null && fo.isValid() && VisibilityQuery.getDefault().isVisible(fo)) {
431
            if (source) {
431
            if (source == null || source.booleanValue()) {
432
                root = getOwningSourceRoot(fo);
432
                root = getOwningSourceRoot(fo);
433
                if (root != null) {
433
                if (root != null) {
434
                    boolean sourcForBinaryRoot = sourcesForBinaryRoots.contains(root.first);
434
                    boolean sourcForBinaryRoot = sourcesForBinaryRoots.contains(root.first);
 Lines 439-445    Link Here 
439
                        processed = true;
439
                        processed = true;
440
                    }
440
                    }
441
                }
441
                }
442
            } else {
442
            }
443
444
            if (!processed && (source == null || !source.booleanValue())) {
443
                root = getOwningBinaryRoot(fo);
445
                root = getOwningBinaryRoot(fo);
444
                if (root != null) {
446
                if (root != null) {
445
                    final Work wrk = new BinaryWork(root.first);
447
                    final Work wrk = new BinaryWork(root.first);
 Lines 455-461    Link Here 
455
        }
457
        }
456
    }
458
    }
457
459
458
    private void fileChangedImpl (FileEvent fe, boolean source) {
460
    private void fileChangedImpl (FileEvent fe, Boolean source) {
459
        FileObject fo = fe.getFile();
461
        FileObject fo = fe.getFile();
460
        if (isCacheFile(fo)) {
462
        if (isCacheFile(fo)) {
461
            return;
463
            return;
 Lines 469-475    Link Here 
469
        Pair<URL, FileObject> root = null;
471
        Pair<URL, FileObject> root = null;
470
472
471
        if (fo != null && fo.isValid() && VisibilityQuery.getDefault().isVisible(fo)) {
473
        if (fo != null && fo.isValid() && VisibilityQuery.getDefault().isVisible(fo)) {
472
            if (source) {
474
            if (source == null || source.booleanValue()) {
473
                root = getOwningSourceRoot (fo);
475
                root = getOwningSourceRoot (fo);
474
                if (root != null) {
476
                if (root != null) {
475
                    boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root.first);
477
                    boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root.first);
 Lines 480-486    Link Here 
480
                        processed = true;
482
                        processed = true;
481
                    }
483
                    }
482
                }
484
                }
483
            } else {
485
            }
486
487
            if (!processed && (source == null || !source.booleanValue())) {
484
                root = getOwningBinaryRoot(fo);
488
                root = getOwningBinaryRoot(fo);
485
                if (root != null) {
489
                if (root != null) {
486
                    final Work wrk = new BinaryWork(root.first);
490
                    final Work wrk = new BinaryWork(root.first);
 Lines 496-502    Link Here 
496
        }
500
        }
497
    }
501
    }
498
502
499
    private void fileDeletedImpl(FileEvent fe, boolean source) {
503
    private void fileDeletedImpl(FileEvent fe, Boolean source) {
500
        FileObject fo = fe.getFile();
504
        FileObject fo = fe.getFile();
501
        if (isCacheFile(fo)) {
505
        if (isCacheFile(fo)) {
502
            return;
506
            return;
 Lines 510-516    Link Here 
510
        Pair<URL, FileObject> root = null;
514
        Pair<URL, FileObject> root = null;
511
515
512
        if (fo != null && VisibilityQuery.getDefault().isVisible(fo)) {
516
        if (fo != null && VisibilityQuery.getDefault().isVisible(fo)) {
513
            if (source) {
517
            if (source == null || source.booleanValue()) {
514
                root = getOwningSourceRoot (fo);
518
                root = getOwningSourceRoot (fo);
515
                if (root != null) {
519
                if (root != null) {
516
                    if (fo.isData() /*&& FileUtil.getMIMEType(fo, recognizers.getMimeTypes())!=null*/) {
520
                    if (fo.isData() /*&& FileUtil.getMIMEType(fo, recognizers.getMimeTypes())!=null*/) {
 Lines 521-527    Link Here 
521
                        processed = true;
525
                        processed = true;
522
                    }
526
                    }
523
                }
527
                }
524
            } else {
528
            }
529
530
            if (!processed && (source == null || !source.booleanValue())) {
525
                root = getOwningBinaryRoot(fo);
531
                root = getOwningBinaryRoot(fo);
526
                if (root != null) {
532
                if (root != null) {
527
                    final Work wrk = new BinaryWork(root.first);
533
                    final Work wrk = new BinaryWork(root.first);
 Lines 537-543    Link Here 
537
        }
543
        }
538
    }
544
    }
539
545
540
    private void fileRenamedImpl(FileRenameEvent fe, boolean  source) {
546
    private void fileRenamedImpl(FileRenameEvent fe, Boolean  source) {
541
        FileObject fo = fe.getFile();
547
        FileObject fo = fe.getFile();
542
        if (isCacheFile(fo)) {
548
        if (isCacheFile(fo)) {
543
            return;
549
            return;
 Lines 553-559    Link Here 
553
        boolean processed = false;
559
        boolean processed = false;
554
560
555
        if (newFile != null && newFile.isValid()) {
561
        if (newFile != null && newFile.isValid()) {
556
            if (source) {
562
            if (source == null || source.booleanValue()) {
557
                root = getOwningSourceRoot(newFile);
563
                root = getOwningSourceRoot(newFile);
558
                if (root != null) {
564
                if (root != null) {
559
                    FileObject rootFo = root.second;
565
                    FileObject rootFo = root.second;
 Lines 582-588    Link Here 
582
                    }
588
                    }
583
                    processed = true;
589
                    processed = true;
584
                }
590
                }
585
            } else {
591
            }
592
593
            if (!processed && (source == null || !source.booleanValue())) {
586
                root = getOwningBinaryRoot(newFile);
594
                root = getOwningBinaryRoot(newFile);
587
                if (root != null) {
595
                if (root != null) {
588
                    final File parentFile = FileUtil.toFile(newFile.getParent());
596
                    final File parentFile = FileUtil.toFile(newFile.getParent());
 Lines 794-800    Link Here 
794
    private static final Logger SFEC_LOGGER = Logger.getLogger("org.netbeans.ui.ScanForExternalChanges"); //NOI18N
802
    private static final Logger SFEC_LOGGER = Logger.getLogger("org.netbeans.ui.ScanForExternalChanges"); //NOI18N
795
    private static final boolean PERF_TEST = Boolean.getBoolean("perf.refactoring.test"); //NOI18N
803
    private static final boolean PERF_TEST = Boolean.getBoolean("perf.refactoring.test"); //NOI18N
796
    private static final boolean notInterruptible = Boolean.getBoolean("netbeans.indexing.notInterruptible"); //NOI18N
804
    private static final boolean notInterruptible = Boolean.getBoolean("netbeans.indexing.notInterruptible"); //NOI18N
797
    private static final boolean noRecursiveListener = Boolean.getBoolean("netbeans.indexing.notRecursiveListener");    //NOI18N
805
    private static final boolean useRecursiveListeners = Boolean.getBoolean("netbeans.indexing.recursiveListeners"); //NOI18N
798
    private static final int FILE_LOCKS_DELAY = org.openide.util.Utilities.isWindows() ? 2000 : 1000;
806
    private static final int FILE_LOCKS_DELAY = org.openide.util.Utilities.isWindows() ? 2000 : 1000;
799
    private static final String PROP_LAST_INDEXED_VERSION = RepositoryUpdater.class.getName() + "-last-indexed-document-version"; //NOI18N
807
    private static final String PROP_LAST_INDEXED_VERSION = RepositoryUpdater.class.getName() + "-last-indexed-document-version"; //NOI18N
800
    private static final String PROP_LAST_DIRTY_VERSION = RepositoryUpdater.class.getName() + "-last-dirty-document-version"; //NOI18N
808
    private static final String PROP_LAST_DIRTY_VERSION = RepositoryUpdater.class.getName() + "-last-dirty-document-version"; //NOI18N
 Lines 823-834    Link Here 
823
    private boolean ignoreIndexerCacheEvents = false;
831
    private boolean ignoreIndexerCacheEvents = false;
824
832
825
    /* test */ final RootsListeners rootsListeners = new RootsListeners();
833
    /* test */ final RootsListeners rootsListeners = new RootsListeners();
826
    private final FileChangeListener sourceRootsListener = new FCL(true);
834
    private final FileChangeListener sourceRootsListener = new FCL(useRecursiveListeners ? Boolean.TRUE : null);
827
    private final FileChangeListener binaryRootsListener = new FCL(false);
835
    private final FileChangeListener binaryRootsListener = new FCL(Boolean.FALSE);
828
    private final ThreadLocal<Boolean> inIndexer = new ThreadLocal<Boolean>();
836
    private final ThreadLocal<Boolean> inIndexer = new ThreadLocal<Boolean>();
829
837
830
    private RepositoryUpdater () {
838
    private RepositoryUpdater () {
831
        // no-op
839
        LOGGER.log(Level.INFO, "perf.refactoring.test={0}", PERF_TEST); //NOI18N
840
        LOGGER.log(Level.INFO, "netbeans.indexing.notInterruptible={0}", notInterruptible); //NOI18N
841
        LOGGER.log(Level.INFO, "netbeans.indexing.recursiveListeners={0}", useRecursiveListeners); //NOI18N
842
        LOGGER.log(Level.INFO, "FILE_LOCKS_DELAY={0}", FILE_LOCKS_DELAY); //NOI18N
832
    }
843
    }
833
844
834
    private void handleActiveDocumentChange(Document deactivated, Document activated) {
845
    private void handleActiveDocumentChange(Document deactivated, Document activated) {
 Lines 3901-3906    Link Here 
3901
        public void setListener(FileChangeListener sourcesListener, FileChangeListener binariesListener) {
3912
        public void setListener(FileChangeListener sourcesListener, FileChangeListener binariesListener) {
3902
            assert (sourcesListener != null && binariesListener != null) || (sourcesListener == null && binariesListener == null) :
3913
            assert (sourcesListener != null && binariesListener != null) || (sourcesListener == null && binariesListener == null) :
3903
                "Both sourcesListener and binariesListener must either be null or non-null"; //NOI18N
3914
                "Both sourcesListener and binariesListener must either be null or non-null"; //NOI18N
3915
3904
            //todo: remove removeRecursiveListener from synchronized block
3916
            //todo: remove removeRecursiveListener from synchronized block
3905
            synchronized (this) {
3917
            synchronized (this) {
3906
                if (sourcesListener != null) {
3918
                if (sourcesListener != null) {
 Lines 3908-3917    Link Here 
3908
                            + ", won't attach " + sourcesListener + " and " + binariesListener; //NOI18N
3920
                            + ", won't attach " + sourcesListener + " and " + binariesListener; //NOI18N
3909
                    assert sourceRoots.isEmpty() : "Expecting no source roots: " + sourceRoots; //NOI18N
3921
                    assert sourceRoots.isEmpty() : "Expecting no source roots: " + sourceRoots; //NOI18N
3910
                    assert binaryRoots.isEmpty() : "Expecting no binary roots: " + binaryRoots; //NOI18N
3922
                    assert binaryRoots.isEmpty() : "Expecting no binary roots: " + binaryRoots; //NOI18N
3923
3911
                    this.sourcesListener = sourcesListener;
3924
                    this.sourcesListener = sourcesListener;
3912
                    this.binariesListener = binariesListener;
3925
                    this.binariesListener = binariesListener;
3926
                    if (!useRecursiveListeners) {
3927
                        FileUtil.addFileChangeListener(sourcesListener);
3928
                    }
3913
                } else {
3929
                } else {
3914
                    assert this.sourcesListener != null : "RootsListeners are already dormant"; //NOI18N
3930
                    assert this.sourcesListener != null : "RootsListeners are already dormant"; //NOI18N
3931
3932
                    if (!useRecursiveListeners) {
3933
                        FileUtil.removeFileChangeListener(sourcesListener);
3934
                    }
3915
                    for(Map.Entry<URL, File> entry : sourceRoots.entrySet()) {
3935
                    for(Map.Entry<URL, File> entry : sourceRoots.entrySet()) {
3916
                        safeRemoveRecursiveListener(this.sourcesListener, entry.getValue());
3936
                        safeRemoveRecursiveListener(this.sourcesListener, entry.getValue());
3917
                    }
3937
                    }
 Lines 3995-4005    Link Here 
3995
        }
4015
        }
3996
4016
3997
        private void safeAddRecursiveListener(FileChangeListener listener, File path) {
4017
        private void safeAddRecursiveListener(FileChangeListener listener, File path) {
3998
            if (noRecursiveListener) {
4018
            if (useRecursiveListeners) {
3999
                if (!noRecursiveListenerLogged.getAndSet(true)) {
4000
                    LOGGER.info("Recursive listeners are disabled"); //NOI18N
4001
                }
4002
            } else {
4003
                try {
4019
                try {
4004
                    FileUtil.addRecursiveListener(listener, path, new Callable<Boolean>() {
4020
                    FileUtil.addRecursiveListener(listener, path, new Callable<Boolean>() {
4005
                        @Override
4021
                        @Override
 Lines 4017-4023    Link Here 
4017
        }
4033
        }
4018
4034
4019
        private void safeRemoveRecursiveListener(FileChangeListener listener, File path) {
4035
        private void safeRemoveRecursiveListener(FileChangeListener listener, File path) {
4020
            if (!noRecursiveListener) {
4036
            if (useRecursiveListeners) {
4021
                try {
4037
                try {
4022
                    FileUtil.removeRecursiveListener(listener, path);
4038
                    FileUtil.removeRecursiveListener(listener, path);
4023
                } catch (Exception e) {
4039
                } catch (Exception e) {
 Lines 4029-4037    Link Here 
4029
    } // End of RootsListeners class
4045
    } // End of RootsListeners class
4030
4046
4031
    private final class FCL extends FileChangeAdapter {
4047
    private final class FCL extends FileChangeAdapter {
4032
        private final boolean listeningOnSources;
4048
        private final Boolean listeningOnSources;
4033
4049
4034
        public FCL(boolean listeningOnSources) {
4050
        public FCL(Boolean listeningOnSources) {
4035
            this.listeningOnSources = listeningOnSources;
4051
            this.listeningOnSources = listeningOnSources;
4036
        }
4052
        }
4037
4053

Return to bug 184840
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo