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

(-)a/java.source/src/org/netbeans/modules/java/source/parsing/JavacParser.java (-11 / +18 lines)
Lines 180-187 Link Here
180
180
181
    //Listener support
181
    //Listener support
182
    private final ChangeSupport listeners = new ChangeSupport(this);
182
    private final ChangeSupport listeners = new ChangeSupport(this);
183
    //Cancelling of parser & index
183
    //Cancelling of parser
184
    private final AtomicBoolean canceled = new AtomicBoolean();
184
    private final AtomicBoolean parserCanceled = new AtomicBoolean();
185
    //Cancelling of index
186
    private final AtomicBoolean indexCanceled = new AtomicBoolean();
187
    
185
    //When true the parser is a private copy not used by the parsing API, see JavaSourceAccessor.createCompilationController
188
    //When true the parser is a private copy not used by the parsing API, see JavaSourceAccessor.createCompilationController
186
    private final boolean privateParser;
189
    private final boolean privateParser;
187
    //File processed by this javac
190
    //File processed by this javac
Lines 323-329 Link Here
323
        assert task != null;
326
        assert task != null;
324
        assert privateParser || Utilities.holdsParserLock();
327
        assert privateParser || Utilities.holdsParserLock();
325
        parseId++;
328
        parseId++;
326
        canceled.set(false);
329
        parserCanceled.set(false);
330
        indexCanceled.set(false);
327
        LOGGER.log(Level.FINE, "parse: task: {0}\n{1}", new Object[]{   //NOI18N
331
        LOGGER.log(Level.FINE, "parse: task: {0}\n{1}", new Object[]{   //NOI18N
328
            task.toString(),
332
            task.toString(),
329
            snapshot == null ? "null" : snapshot.getText()});      //NOI18N
333
            snapshot == null ? "null" : snapshot.getText()});      //NOI18N
Lines 437-443 Link Here
437
                }
441
                }
438
            }
442
            }
439
            if (reachedPhase.compareTo(requiredPhase)>=0) {
443
            if (reachedPhase.compareTo(requiredPhase)>=0) {
440
                Index.cancel.set(canceled);
444
                Index.cancel.set(indexCanceled);
441
                result = new JavacParserResult(JavaSourceAccessor.getINSTANCE().createCompilationInfo(ciImpl));
445
                result = new JavacParserResult(JavaSourceAccessor.getINSTANCE().createCompilationInfo(ciImpl));
442
            }
446
            }
443
        }
447
        }
Lines 466-473 Link Here
466
    }
470
    }
467
471
468
    @Override
472
    @Override
469
    public void cancel () {
473
    public void cancel (final @NonNull CancelReason reason, final @NonNull SourceModificationEvent event) {
470
        canceled.set(true);
474
        indexCanceled.set(true);
475
        if (reason == CancelReason.SOURCE_MODIFICATION_EVENT && event.sourceChanged()) {
476
            parserCanceled.set(true);
477
        }
471
    }
478
    }
472
479
473
    public void resultFinished (boolean isCancelable) {
480
    public void resultFinished (boolean isCancelable) {
Lines 514-520 Link Here
514
        Phase currentPhase = currentInfo.getPhase();
521
        Phase currentPhase = currentInfo.getPhase();
515
        try {
522
        try {
516
            if (currentPhase.compareTo(Phase.PARSED)<0 && phase.compareTo(Phase.PARSED)>=0 && phase.compareTo(parserError)<=0) {
523
            if (currentPhase.compareTo(Phase.PARSED)<0 && phase.compareTo(Phase.PARSED)>=0 && phase.compareTo(parserError)<=0) {
517
                if (cancellable && canceled.get()) {
524
                if (cancellable && parserCanceled.get()) {
518
                    //Keep the currentPhase unchanged, it may happen that an userActionTask
525
                    //Keep the currentPhase unchanged, it may happen that an userActionTask
519
                    //runnig after the phace completion task may still use it.
526
                    //runnig after the phace completion task may still use it.
520
                    return Phase.MODIFIED;
527
                    return Phase.MODIFIED;
Lines 536-542 Link Here
536
                assert !it.hasNext();
543
                assert !it.hasNext();
537
                final Document doc = listener == null ? null : listener.document;
544
                final Document doc = listener == null ? null : listener.document;
538
                if (doc != null && supportsReparse) {
545
                if (doc != null && supportsReparse) {
539
                    FindMethodRegionsVisitor v = new FindMethodRegionsVisitor(doc,Trees.instance(currentInfo.getJavacTask()).getSourcePositions(),this.canceled);
546
                    FindMethodRegionsVisitor v = new FindMethodRegionsVisitor(doc,Trees.instance(currentInfo.getJavacTask()).getSourcePositions(),this.parserCanceled);
540
                    v.visit(unit, null);
547
                    v.visit(unit, null);
541
                    synchronized (positions) {
548
                    synchronized (positions) {
542
                        positions.clear();
549
                        positions.clear();
Lines 552-558 Link Here
552
                logTime (currentFile,currentPhase,(end-start));
559
                logTime (currentFile,currentPhase,(end-start));
553
            }
560
            }
554
            if (currentPhase == Phase.PARSED && phase.compareTo(Phase.ELEMENTS_RESOLVED)>=0 && phase.compareTo(parserError)<=0) {
561
            if (currentPhase == Phase.PARSED && phase.compareTo(Phase.ELEMENTS_RESOLVED)>=0 && phase.compareTo(parserError)<=0) {
555
                if (cancellable && canceled.get()) {
562
                if (cancellable && parserCanceled.get()) {
556
                    return Phase.MODIFIED;
563
                    return Phase.MODIFIED;
557
                }
564
                }
558
                long start = System.currentTimeMillis();
565
                long start = System.currentTimeMillis();
Lines 562-568 Link Here
562
                logTime(currentInfo.getFileObject(),currentPhase,(end-start));
569
                logTime(currentInfo.getFileObject(),currentPhase,(end-start));
563
           }
570
           }
564
           if (currentPhase == Phase.ELEMENTS_RESOLVED && phase.compareTo(Phase.RESOLVED)>=0 && phase.compareTo(parserError)<=0) {
571
           if (currentPhase == Phase.ELEMENTS_RESOLVED && phase.compareTo(Phase.RESOLVED)>=0 && phase.compareTo(parserError)<=0) {
565
                if (cancellable && canceled.get()) {
572
                if (cancellable && parserCanceled.get()) {
566
                    return Phase.MODIFIED;
573
                    return Phase.MODIFIED;
567
                }
574
                }
568
                long start = System.currentTimeMillis ();
575
                long start = System.currentTimeMillis ();
Lines 1030-1036 Link Here
1030
1037
1031
        @Override
1038
        @Override
1032
        public boolean isCanceled() {
1039
        public boolean isCanceled() {
1033
            return mayCancel.get() && parser.canceled.get();
1040
            return mayCancel.get() && parser.parserCanceled.get();
1034
        }
1041
        }
1035
    }
1042
    }
1036
1043
(-)a/java.source/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java (-1 / +1 lines)
Lines 216-222 Link Here
216
        suite.addTest(new JavaSourceTest("testRunWhenScanFinished"));
216
        suite.addTest(new JavaSourceTest("testRunWhenScanFinished"));
217
        suite.addTest(new JavaSourceTest("testNested2"));
217
        suite.addTest(new JavaSourceTest("testNested2"));
218
        suite.addTest(new JavaSourceTest("testIndexCancel"));
218
        suite.addTest(new JavaSourceTest("testIndexCancel"));
219
//        suite.addTest(new JavaSourceTest("testIndexCancel2"));
219
        suite.addTest(new JavaSourceTest("testIndexCancel2"));
220
        suite.addTest(new JavaSourceTest("testRegisterSameTask"));
220
        suite.addTest(new JavaSourceTest("testRegisterSameTask"));
221
        suite.addTest(new JavaSourceTest("testIncrementalReparse"));
221
        suite.addTest(new JavaSourceTest("testIncrementalReparse"));
222
        suite.addTest(new JavaSourceTest("testCreateTaggedController"));
222
        suite.addTest(new JavaSourceTest("testCreateTaggedController"));
(-)a/parsing.api/apichanges.xml (+17 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="parser-cancelling">
114
      <api name="ParsingAPI"/>
115
      <summary>Adding Parser.cancel method with parameters describing the reason of cancel</summary>
116
      <version major="1" minor="36"/>
117
      <date day="15" month="10" year="2010"/>
118
      <author login="tzezula"/>
119
      <compatibility source="compatible" binary="compatible" semantic="compatible" deletion="no" addition="yes" modification="no"/>
120
      <description>
121
          <p>
122
              Adding Parser.cancel method with parameters describing the reason of cancel. This information can be used by the
123
              parser to optimize the cancel behavior.
124
          </p>
125
      </description>
126
      <class package="org.netbeans.modules.parsing.spi" name="SourceModificationEvent"/>
127
      <class package="org.netbeans.modules.parsing.spi" name="Parser"/>
128
      <issue number="190933"/>
129
  </change>
113
  <change id="adding-PathRecognizerRegistration-annotation">
130
  <change id="adding-PathRecognizerRegistration-annotation">
114
      <api name="ParsingAPI"/>
131
      <api name="ParsingAPI"/>
115
      <summary>Adding PathRecognizerRegistration annotation</summary>
132
      <summary>Adding PathRecognizerRegistration annotation</summary>
(-)a/parsing.api/nbproject/project.properties (-1 / +1 lines)
Lines 2-5 Link Here
2
javac.source=1.6
2
javac.source=1.6
3
javadoc.apichanges=${basedir}/apichanges.xml
3
javadoc.apichanges=${basedir}/apichanges.xml
4
javadoc.arch=${basedir}/arch.xml
4
javadoc.arch=${basedir}/arch.xml
5
spec.version.base=1.35.0
5
spec.version.base=1.36.0
(-)a/parsing.api/src/org/netbeans/modules/parsing/api/Source.java (-10 / +16 lines)
Lines 57-62 Link Here
57
import java.util.Map;
57
import java.util.Map;
58
import java.util.Set;
58
import java.util.Set;
59
import java.util.WeakHashMap;
59
import java.util.WeakHashMap;
60
import java.util.concurrent.atomic.AtomicReference;
60
import java.util.logging.Level;
61
import java.util.logging.Level;
61
import java.util.logging.Logger;
62
import java.util.logging.Logger;
62
import javax.swing.text.BadLocationException;
63
import javax.swing.text.BadLocationException;
Lines 450-457 Link Here
450
    
451
    
451
    private int taskCount;
452
    private int taskCount;
452
    private volatile Parser cachedParser;
453
    private volatile Parser cachedParser;
453
    private volatile ASourceModificationEvent  sourceModificationEvent;
454
    private final AtomicReference<ASourceModificationEvent> sourceModificationEvent = new AtomicReference<ASourceModificationEvent>();
454
    private final ASourceModificationEvent unspecifiedSourceModificationEvent = new ASourceModificationEvent (this, -1, -1);
455
    private final ASourceModificationEvent unspecifiedSourceModificationEvent = new ASourceModificationEvent (this, true, -1, -1);
455
    private Map<Class<? extends Scheduler>,? extends SchedulerEvent> schedulerEvents;
456
    private Map<Class<? extends Scheduler>,? extends SchedulerEvent> schedulerEvents;
456
    //GuardedBy(this)
457
    //GuardedBy(this)
457
    private SourceCache     cache;
458
    private SourceCache     cache;
Lines 618-639 Link Here
618
        }
619
        }
619
620
620
        @Override
621
        @Override
621
        public void setSourceModification (Source source, int startOffset, int endOffset) {
622
        public void setSourceModification (Source source, boolean sourceChanged, int startOffset, int endOffset) {
622
            assert source != null;
623
            assert source != null;
623
            source.sourceModificationEvent = new ASourceModificationEvent (source, startOffset, endOffset);
624
            ASourceModificationEvent oldSourceModificationEvent;
625
            ASourceModificationEvent newSourceModificationEvent;
626
            do {
627
                oldSourceModificationEvent = source.sourceModificationEvent.get();
628
                boolean mergedChange = sourceChanged | (oldSourceModificationEvent == null ? false : oldSourceModificationEvent.sourceChanged());
629
                newSourceModificationEvent = new ASourceModificationEvent (source, mergedChange, startOffset, endOffset);                
630
            } while (!source.sourceModificationEvent.compareAndSet(oldSourceModificationEvent, newSourceModificationEvent));
624
        }
631
        }
625
632
626
        @Override
633
        @Override
627
        public void parsed (Source source) {
634
        public void parsed (Source source) {
628
            synchronized (TaskProcessor.INTERNAL_LOCK) {
635
            source.sourceModificationEvent.set(null);
629
                source.sourceModificationEvent = null;
630
            }
631
        }
636
        }
632
637
633
        @Override
638
        @Override
634
        public SourceModificationEvent getSourceModificationEvent (Source source) {
639
        public SourceModificationEvent getSourceModificationEvent (Source source) {
635
            assert source != null;
640
            assert source != null;
636
            SourceModificationEvent event = source.sourceModificationEvent;
641
            SourceModificationEvent event = source.sourceModificationEvent.get();
637
            if (event == null) {
642
            if (event == null) {
638
                event = source.unspecifiedSourceModificationEvent;
643
                event = source.unspecifiedSourceModificationEvent;
639
            }
644
            }
Lines 743-752 Link Here
743
748
744
        ASourceModificationEvent (
749
        ASourceModificationEvent (
745
            Object          source,
750
            Object          source,
751
            boolean         sourceChanged,
746
            int             _startOffset,
752
            int             _startOffset,
747
            int             _endOffset
753
            int             _endOffset
748
        ) {
754
        ) {
749
            super (source);
755
            super (source, sourceChanged);
750
            startOffset = _startOffset;
756
            startOffset = _startOffset;
751
            endOffset = _endOffset;
757
            endOffset = _endOffset;
752
        }
758
        }
Lines 761-767 Link Here
761
767
762
        @Override
768
        @Override
763
        public String toString () {
769
        public String toString () {
764
            return "SourceModificationEvent " + startOffset + ":" + endOffset;
770
            return "SourceModificationEvent ("+ sourceChanged() +") "+ startOffset + ":" + endOffset;
765
        }
771
        }
766
    }
772
    }
767
}
773
}
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/SourceAccessor.java (-1 / +1 lines)
Lines 130-136 Link Here
130
130
131
    public abstract SourceModificationEvent getSourceModificationEvent (Source source);
131
    public abstract SourceModificationEvent getSourceModificationEvent (Source source);
132
132
133
    public abstract void setSourceModification (Source source, int startOffset, int endOffset);
133
    public abstract void setSourceModification (Source source, boolean sourceChanged, int startOffset, int endOffset);
134
134
135
    public abstract void parsed (Source source);
135
    public abstract void parsed (Source source);
136
136
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/TaskProcessor.java (-6 / +38 lines)
Lines 931-936 Link Here
931
        
931
        
932
        Request getTaskToCancel (final int priority) {
932
        Request getTaskToCancel (final int priority) {
933
            Request request = null;
933
            Request request = null;
934
            Parser parser = null;
934
            if (!factory.isDispatchThread(Thread.currentThread())) {
935
            if (!factory.isDispatchThread(Thread.currentThread())) {
935
                synchronized (CRR_LOCK) {
936
                synchronized (CRR_LOCK) {
936
                    if (this.reference != null && priority<this.reference.task.getPriority()) {
937
                    if (this.reference != null && priority<this.reference.task.getPriority()) {
Lines 939-947 Link Here
939
                        this.canceledReference = request;
940
                        this.canceledReference = request;
940
                        this.reference = null;
941
                        this.reference = null;
941
                        this.canceled = true;
942
                        this.canceled = true;
942
                        this.cancelTime = System.currentTimeMillis();                        
943
                        this.cancelTime = System.currentTimeMillis();
944
                        parser = activeParser;
943
                    }
945
                    }
944
                }
946
                }
947
                if (parser != null) {
948
                    parser.cancel(Parser.CancelReason.PARSER_RESULT_TASK, null);
949
                }
945
            }
950
            }
946
            return request;
951
            return request;
947
        }
952
        }
Lines 950-956 Link Here
950
        Request getTaskToCancel (final Collection<? extends SchedulerTask> tasks) {
955
        Request getTaskToCancel (final Collection<? extends SchedulerTask> tasks) {
951
            assert tasks != null;
956
            assert tasks != null;
952
            Request request = null;
957
            Request request = null;
953
            if (!factory.isDispatchThread(Thread.currentThread())) {
958
            Parser parser = null;
959
            if (!factory.isDispatchThread(Thread.currentThread())) {                
954
                synchronized (CRR_LOCK) {
960
                synchronized (CRR_LOCK) {
955
                    if (this.reference != null && tasks.contains(this.reference.task)) {
961
                    if (this.reference != null && tasks.contains(this.reference.task)) {
956
                        assert this.canceledReference == null;
962
                        assert this.canceledReference == null;
Lines 958-971 Link Here
958
                        this.canceledReference = request;
964
                        this.canceledReference = request;
959
                        this.reference = null;
965
                        this.reference = null;
960
                        this.canceled = true;
966
                        this.canceled = true;
967
                        parser = activeParser;
961
                    }
968
                    }
962
                }
969
                }
970
                if (parser != null) {
971
                    parser.cancel(Parser.CancelReason.PARSER_RESULT_TASK, null);
972
                }
963
            }
973
            }
964
            return request;
974
            return request;
965
        }
975
        }
966
        
976
        
967
        Request getTaskToCancel () {
977
        Request getTaskToCancel () {
968
            Request request = null;
978
            Request request = null;
979
            Parser parser = null;
969
            if (!factory.isDispatchThread(Thread.currentThread())) {                
980
            if (!factory.isDispatchThread(Thread.currentThread())) {                
970
                synchronized (CRR_LOCK) {
981
                synchronized (CRR_LOCK) {
971
                     request = this.reference;
982
                     request = this.reference;
Lines 975-990 Link Here
975
                        this.reference = null;
986
                        this.reference = null;
976
                        this.canceled = true;
987
                        this.canceled = true;
977
                        this.cancelTime = System.currentTimeMillis();
988
                        this.cancelTime = System.currentTimeMillis();
989
                        parser = activeParser;
978
                    }
990
                    }
979
                }
991
                }
992
                if (parser != null) {
993
                    parser.cancel(Parser.CancelReason.USER_TASK, null);
994
                }
980
            }
995
            }
981
            return request;
996
            return request;
982
        }
997
        }
983
        
998
        
984
        Request getTaskToCancel (final boolean mayCancelParser) {
999
        Request getTaskToCancel (final boolean mayCancelParser) {
985
            Request request = null;
1000
            Request request = null;
986
            if (!factory.isDispatchThread(Thread.currentThread())) {
1001
            if (!factory.isDispatchThread(Thread.currentThread())) {    
987
                Parser parser;
1002
                Parser parser = null;
988
                synchronized (CRR_LOCK) {
1003
                synchronized (CRR_LOCK) {
989
                    if (this.reference != null) {
1004
                    if (this.reference != null) {
990
                        assert this.canceledReference == null;
1005
                        assert this.canceledReference == null;
Lines 1003-1010 Link Here
1003
                    }
1018
                    }
1004
                    parser = activeParser;
1019
                    parser = activeParser;
1005
                }
1020
                }
1006
                if (parser != null && mayCancelParser) {
1021
                if (parser != null) {
1007
                    parser.cancel();
1022
                    Source src = null;
1023
                    SourceCache sc;
1024
                    if (request != null && (sc = request.cache)!= null) {
1025
                        src = sc.getSnapshot().getSource();
1026
                    }
1027
                    if (src != null) {
1028
                        if (mayCancelParser) {
1029
                            parser.cancel();
1030
                        }
1031
                        parser.cancel(
1032
                            Parser.CancelReason.SOURCE_MODIFICATION_EVENT,
1033
                            SourceAccessor.getINSTANCE().getSourceModificationEvent(src));
1034
                    }
1008
                }
1035
                }
1009
            }
1036
            }
1010
            return request;
1037
            return request;
Lines 1014-1019 Link Here
1014
            assert request != null;
1041
            assert request != null;
1015
            assert request.length == 1;
1042
            assert request.length == 1;
1016
            boolean result = false;
1043
            boolean result = false;
1044
            Parser parser = null;
1017
            if (!factory.isDispatchThread(Thread.currentThread())) {
1045
            if (!factory.isDispatchThread(Thread.currentThread())) {
1018
                synchronized (CRR_LOCK) {
1046
                synchronized (CRR_LOCK) {
1019
                     request[0] = this.reference;
1047
                     request[0] = this.reference;
Lines 1026-1033 Link Here
1026
                        }
1054
                        }
1027
                        this.canceled = result;
1055
                        this.canceled = result;
1028
                        this.cancelTime = System.currentTimeMillis();
1056
                        this.cancelTime = System.currentTimeMillis();
1057
                        parser = activeParser;
1029
                    }
1058
                    }
1030
                }
1059
                }
1060
                if (parser != null) {
1061
                    parser.cancel(Parser.CancelReason.USER_TASK, null);
1062
                }
1031
            }
1063
            }
1032
            return result;
1064
            return result;
1033
        }
1065
        }
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/event/EventSupport.java (-1 / +1 lines)
Lines 153-160 Link Here
153
        if (invalidate) {
153
        if (invalidate) {
154
            flags.add(SourceFlags.INVALID);
154
            flags.add(SourceFlags.INVALID);
155
            flags.add(SourceFlags.RESCHEDULE_FINISHED_TASKS);
155
            flags.add(SourceFlags.RESCHEDULE_FINISHED_TASKS);
156
            SourceAccessor.getINSTANCE().setSourceModification (source, startOffset, endOffset);
157
        }
156
        }
157
        SourceAccessor.getINSTANCE().setSourceModification (source, invalidate, startOffset, endOffset);
158
        SourceAccessor.getINSTANCE().setFlags(this.source, flags);
158
        SourceAccessor.getINSTANCE().setFlags(this.source, flags);
159
        TaskProcessor.resetState (this.source,invalidate,true);
159
        TaskProcessor.resetState (this.source,invalidate,true);
160
160
(-)a/parsing.api/src/org/netbeans/modules/parsing/spi/Parser.java (-1 / +43 lines)
Lines 42-48 Link Here
42
42
43
package org.netbeans.modules.parsing.spi;
43
package org.netbeans.modules.parsing.spi;
44
44
45
import com.sun.istack.internal.NotNull;
45
import javax.swing.event.ChangeListener;
46
import javax.swing.event.ChangeListener;
47
import org.netbeans.api.annotations.common.NullAllowed;
48
import org.netbeans.modules.parsing.api.ParserManager;
46
49
47
import org.netbeans.modules.parsing.api.Snapshot;
50
import org.netbeans.modules.parsing.api.Snapshot;
48
import org.netbeans.modules.parsing.api.Task;
51
import org.netbeans.modules.parsing.api.Task;
Lines 96-103 Link Here
96
    
99
    
97
    /**
100
    /**
98
     * Called by the infrastructure to stop the parser operation.
101
     * Called by the infrastructure to stop the parser operation.
102
     * @deprecated use {@link Parser#cancel(CancelReason, org.netbeans.modules.parsing.spi.SourceModificationEvent)}
99
     */
103
     */
100
    public abstract void cancel ();
104
    @Deprecated
105
    public void cancel () {};
106
    
107
    /**
108
     * Called by the infrastructure to stop the parser operation.
109
     * @param reason of the cancel, see {@link Parser#CancelReason}
110
     * @param event an additional info if the reason is SOURCE_MODIFICATION_EVENT, otherwise null
111
     * @since 
112
     */
113
    public void cancel (@NotNull CancelReason reason, @NullAllowed SourceModificationEvent event) {}
101
    
114
    
102
    /**
115
    /**
103
     * Registers new listener.
116
     * Registers new listener.
Lines 155-160 Link Here
155
        
168
        
156
    }
169
    }
157
    
170
    
171
    /**
172
     * The {@link CancelReason} is passed to {@link Parser#cancel(org.netbeans.modules.parsing.spi.Parser.CancelReason, org.netbeans.modules.parsing.spi.SourceModificationEvent)}
173
     * as a hint. The parser may use this information to optimize the canceling.
174
     * @since 1.36
175
     */
176
    public enum CancelReason {
177
        /**
178
         * The cancel is called due to source modification.
179
         * Any information calculated by the parser is based on obsolete data,
180
         * the parser should stop and throw all the cached data.
181
         */
182
        SOURCE_MODIFICATION_EVENT,
183
        
184
        /**
185
         * The cancel is called because {@link ParserManager}'s parse method
186
         * was called.
187
         * The source used by the parser is still valid, the parser can use
188
         * these data during the next request.
189
         */
190
        USER_TASK,
191
        
192
        /**
193
         * The cancel is called because a higher priority task was added.
194
         * The source used by the parser is still valid, the parser can use
195
         * these data during next request.
196
         */
197
        PARSER_RESULT_TASK;
198
    }
199
    
158
    
200
    
159
    private static class MyAccessor extends ParserAccessor {
201
    private static class MyAccessor extends ParserAccessor {
160
202
(-)a/parsing.api/src/org/netbeans/modules/parsing/spi/SourceModificationEvent.java (-1 / +14 lines)
Lines 50-65 Link Here
50
 * @author hanz
50
 * @author hanz
51
 */
51
 */
52
public class SourceModificationEvent extends EventObject {
52
public class SourceModificationEvent extends EventObject {
53
    
54
    private final boolean sourceChanged;
53
55
54
    protected SourceModificationEvent (
56
    protected SourceModificationEvent (
55
        Object              source
57
        Object              source,
58
        boolean             sourceChanged
56
    ) {
59
    ) {
57
        super (source);
60
        super (source);
61
        this.sourceChanged = sourceChanged;
58
    }
62
    }
59
63
60
    public Source getModifiedSource () {
64
    public Source getModifiedSource () {
61
        return (Source) getSource ();
65
        return (Source) getSource ();
62
    }
66
    }
67
    
68
    /**
69
     * Returns true when the change causing this event affected the source.
70
     * @return true if the source was changed
71
     * @since 1.36
72
     */
73
    public boolean sourceChanged() {
74
        return sourceChanged;
75
    }
63
76
64
    @Override
77
    @Override
65
    public String toString () {
78
    public String toString () {

Return to bug 190934