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

(-)a/java.debug/nbproject/project.xml (+9 lines)
Lines 92-97 Link Here
92
                    </run-dependency>
92
                    </run-dependency>
93
                </dependency>
93
                </dependency>
94
                <dependency>
94
                <dependency>
95
                    <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
96
                    <build-prerequisite/>
97
                    <compile-dependency/>
98
                    <run-dependency>
99
                        <release-version>1</release-version>
100
                        <specification-version>1.51</specification-version>
101
                    </run-dependency>
102
                </dependency>
103
                <dependency>
95
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
104
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
96
                    <build-prerequisite/>
105
                    <build-prerequisite/>
97
                    <compile-dependency/>
106
                    <compile-dependency/>
(-)a/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorJavaSourceFactory.java (-1 / +2 lines)
Lines 52-57 Link Here
52
import org.netbeans.api.java.source.JavaSourceTaskFactory;
52
import org.netbeans.api.java.source.JavaSourceTaskFactory;
53
import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
53
import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
54
import org.netbeans.api.java.source.support.LookupBasedJavaSourceTaskFactory;
54
import org.netbeans.api.java.source.support.LookupBasedJavaSourceTaskFactory;
55
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
55
import org.openide.filesystems.FileObject;
56
import org.openide.filesystems.FileObject;
56
import org.openide.util.Lookup;
57
import org.openide.util.Lookup;
57
import org.openide.util.lookup.ServiceProvider;
58
import org.openide.util.lookup.ServiceProvider;
Lines 75-81 Link Here
75
    }
76
    }
76
    
77
    
77
    public TreeNavigatorJavaSourceFactory() {
78
    public TreeNavigatorJavaSourceFactory() {
78
        super(Phase.UP_TO_DATE, Priority.NORMAL);
79
        super(Phase.UP_TO_DATE, Priority.NORMAL, TaskIndexingMode.ALLOWED_DURING_SCAN);
79
    }
80
    }
80
81
81
    public synchronized CancellableTask<CompilationInfo> createTask(FileObject file) {
82
    public synchronized CancellableTask<CompilationInfo> createTask(FileObject file) {
(-)a/java.editor/nbproject/project.xml (-2 / +2 lines)
Lines 236-242 Link Here
236
                    <build-prerequisite/>
236
                    <build-prerequisite/>
237
                    <compile-dependency/>
237
                    <compile-dependency/>
238
                    <run-dependency>
238
                    <run-dependency>
239
                        <specification-version>0.86</specification-version>
239
                        <specification-version>0.94</specification-version>
240
                    </run-dependency>
240
                    </run-dependency>
241
                </dependency>
241
                </dependency>
242
                <dependency>
242
                <dependency>
Lines 281-287 Link Here
281
                    <compile-dependency/>
281
                    <compile-dependency/>
282
                    <run-dependency>
282
                    <run-dependency>
283
                        <release-version>1</release-version>
283
                        <release-version>1</release-version>
284
                        <specification-version>1.26</specification-version>
284
                        <specification-version>1.51</specification-version>
285
                    </run-dependency>
285
                    </run-dependency>
286
                </dependency>
286
                </dependency>
287
                <dependency>
287
                <dependency>
(-)a/java.editor/src/org/netbeans/modules/java/editor/fold/JavaElementFoldManagerTaskFactory.java (-1 / +2 lines)
Lines 49-54 Link Here
49
import org.netbeans.api.java.source.JavaSource.Priority;
49
import org.netbeans.api.java.source.JavaSource.Priority;
50
import org.netbeans.api.java.source.JavaSourceTaskFactory;
50
import org.netbeans.api.java.source.JavaSourceTaskFactory;
51
import org.netbeans.api.java.source.support.EditorAwareJavaSourceTaskFactory;
51
import org.netbeans.api.java.source.support.EditorAwareJavaSourceTaskFactory;
52
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
52
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileObject;
53
import org.openide.util.Lookup;
54
import org.openide.util.Lookup;
54
55
Lines 60-66 Link Here
60
public class JavaElementFoldManagerTaskFactory extends EditorAwareJavaSourceTaskFactory {
61
public class JavaElementFoldManagerTaskFactory extends EditorAwareJavaSourceTaskFactory {
61
62
62
    public JavaElementFoldManagerTaskFactory() {
63
    public JavaElementFoldManagerTaskFactory() {
63
        super(Phase.PARSED, Priority.NORMAL);
64
        super(Phase.PARSED, Priority.NORMAL, TaskIndexingMode.ALLOWED_DURING_SCAN);
64
    }
65
    }
65
66
66
    public CancellableTask<CompilationInfo> createTask(FileObject file) {
67
    public CancellableTask<CompilationInfo> createTask(FileObject file) {
(-)a/java.editor/src/org/netbeans/modules/java/editor/overridden/ComputeAnnotations.java (-5 / +2 lines)
Lines 61-71 Link Here
61
import org.netbeans.api.java.source.JavaParserResultTask;
61
import org.netbeans.api.java.source.JavaParserResultTask;
62
import org.netbeans.api.java.source.JavaSource.Phase;
62
import org.netbeans.api.java.source.JavaSource.Phase;
63
import org.netbeans.modules.parsing.api.Snapshot;
63
import org.netbeans.modules.parsing.api.Snapshot;
64
import org.netbeans.modules.parsing.spi.*;
64
import org.netbeans.modules.parsing.spi.Parser.Result;
65
import org.netbeans.modules.parsing.spi.Parser.Result;
65
import org.netbeans.modules.parsing.spi.Scheduler;
66
import org.netbeans.modules.parsing.spi.SchedulerEvent;
67
import org.netbeans.modules.parsing.spi.SchedulerTask;
68
import org.netbeans.modules.parsing.spi.TaskFactory;
69
import org.openide.text.NbDocument;
66
import org.openide.text.NbDocument;
70
import org.openide.util.NbBundle;
67
import org.openide.util.NbBundle;
71
68
Lines 78-84 Link Here
78
    private final AtomicBoolean cancel = new AtomicBoolean();
75
    private final AtomicBoolean cancel = new AtomicBoolean();
79
    
76
    
80
    public ComputeAnnotations() {
77
    public ComputeAnnotations() {
81
        super(Phase.RESOLVED);
78
        super(Phase.RESOLVED, TaskIndexingMode.ALLOWED_DURING_SCAN);
82
    }
79
    }
83
80
84
    @Override
81
    @Override
(-)a/java.editor/src/org/netbeans/modules/java/editor/semantic/MarkOccurrencesHighlighter.java (-1 / +2 lines)
Lines 104-109 Link Here
104
import org.netbeans.modules.parsing.spi.Parser.Result;
104
import org.netbeans.modules.parsing.spi.Parser.Result;
105
import org.netbeans.modules.parsing.spi.Scheduler;
105
import org.netbeans.modules.parsing.spi.Scheduler;
106
import org.netbeans.modules.parsing.spi.SchedulerEvent;
106
import org.netbeans.modules.parsing.spi.SchedulerEvent;
107
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
107
import org.netbeans.spi.editor.highlighting.support.OffsetsBag;
108
import org.netbeans.spi.editor.highlighting.support.OffsetsBag;
108
import org.openide.filesystems.FileObject;
109
import org.openide.filesystems.FileObject;
109
import org.openide.loaders.DataObject;
110
import org.openide.loaders.DataObject;
Lines 120-126 Link Here
120
121
121
    /** Creates a new instance of SemanticHighlighter */
122
    /** Creates a new instance of SemanticHighlighter */
122
    MarkOccurrencesHighlighter(FileObject file) {
123
    MarkOccurrencesHighlighter(FileObject file) {
123
        super(Phase.RESOLVED);
124
        super(Phase.RESOLVED, TaskIndexingMode.ALLOWED_DURING_SCAN);
124
        this.file = file;
125
        this.file = file;
125
    }
126
    }
126
127
(-)a/java.editor/src/org/netbeans/modules/java/editor/semantic/SemanticHighlighter.java (-1 / +2 lines)
Lines 121-126 Link Here
121
import org.netbeans.modules.parsing.spi.Parser.Result;
121
import org.netbeans.modules.parsing.spi.Parser.Result;
122
import org.netbeans.modules.parsing.spi.Scheduler;
122
import org.netbeans.modules.parsing.spi.Scheduler;
123
import org.netbeans.modules.parsing.spi.SchedulerEvent;
123
import org.netbeans.modules.parsing.spi.SchedulerEvent;
124
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
124
import org.netbeans.spi.editor.highlighting.support.OffsetsBag;
125
import org.netbeans.spi.editor.highlighting.support.OffsetsBag;
125
import org.netbeans.spi.editor.hints.ErrorDescription;
126
import org.netbeans.spi.editor.hints.ErrorDescription;
126
import org.openide.filesystems.FileObject;
127
import org.openide.filesystems.FileObject;
Lines 165-171 Link Here
165
//    }
166
//    }
166
//    
167
//    
167
    SemanticHighlighter(FileObject file/*, SemanticHighlighterFactory fact*/) {
168
    SemanticHighlighter(FileObject file/*, SemanticHighlighterFactory fact*/) {
168
        super(Phase.RESOLVED);
169
        super(Phase.RESOLVED, TaskIndexingMode.ALLOWED_DURING_SCAN);
169
        this.file = file;
170
        this.file = file;
170
//        this.fact = fact;
171
//        this.fact = fact;
171
    }
172
    }
(-)a/java.hints.declarative/nbproject/project.xml (-2 / +2 lines)
Lines 113-119 Link Here
113
                    <build-prerequisite/>
113
                    <build-prerequisite/>
114
                    <compile-dependency/>
114
                    <compile-dependency/>
115
                    <run-dependency>
115
                    <run-dependency>
116
                        <specification-version>0.43.0.7.7.1</specification-version>
116
                        <specification-version>0.94</specification-version>
117
                    </run-dependency>
117
                    </run-dependency>
118
                </dependency>
118
                </dependency>
119
                <dependency>
119
                <dependency>
Lines 131-137 Link Here
131
                    <compile-dependency/>
131
                    <compile-dependency/>
132
                    <run-dependency>
132
                    <run-dependency>
133
                        <release-version>1</release-version>
133
                        <release-version>1</release-version>
134
                        <specification-version>1.12.1</specification-version>
134
                        <specification-version>1.51</specification-version>
135
                    </run-dependency>
135
                    </run-dependency>
136
                </dependency>
136
                </dependency>
137
                <dependency>
137
                <dependency>
(-)a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/debugging/EvaluationSpanTask.java (-6 / +2 lines)
Lines 76-87 Link Here
76
import org.netbeans.modules.java.hints.declarative.test.TestTokenId;
76
import org.netbeans.modules.java.hints.declarative.test.TestTokenId;
77
import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
77
import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
78
import org.netbeans.modules.parsing.api.Snapshot;
78
import org.netbeans.modules.parsing.api.Snapshot;
79
import org.netbeans.modules.parsing.spi.CursorMovedSchedulerEvent;
79
import org.netbeans.modules.parsing.spi.*;
80
import org.netbeans.modules.parsing.spi.Parser.Result;
80
import org.netbeans.modules.parsing.spi.Parser.Result;
81
import org.netbeans.modules.parsing.spi.Scheduler;
82
import org.netbeans.modules.parsing.spi.SchedulerEvent;
83
import org.netbeans.modules.parsing.spi.SchedulerTask;
84
import org.netbeans.modules.parsing.spi.TaskFactory;
85
import org.netbeans.spi.editor.highlighting.support.OffsetsBag;
81
import org.netbeans.spi.editor.highlighting.support.OffsetsBag;
86
import org.openide.filesystems.FileObject;
82
import org.openide.filesystems.FileObject;
87
import org.openide.filesystems.FileUtil;
83
import org.openide.filesystems.FileUtil;
Lines 94-100 Link Here
94
public class EvaluationSpanTask extends JavaParserResultTask<Result> {
90
public class EvaluationSpanTask extends JavaParserResultTask<Result> {
95
91
96
    public EvaluationSpanTask() {
92
    public EvaluationSpanTask() {
97
        super(Phase.RESOLVED);
93
        super(Phase.RESOLVED, TaskIndexingMode.ALLOWED_DURING_SCAN);
98
    }
94
    }
99
95
100
    @Override
96
    @Override
(-)a/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceHintFactory.java (-1 / +2 lines)
Lines 48-53 Link Here
48
import org.netbeans.api.java.source.JavaSource.Phase;
48
import org.netbeans.api.java.source.JavaSource.Phase;
49
import org.netbeans.api.java.source.JavaSource.Priority;
49
import org.netbeans.api.java.source.JavaSource.Priority;
50
import org.netbeans.api.java.source.support.SelectionAwareJavaSourceTaskFactory;
50
import org.netbeans.api.java.source.support.SelectionAwareJavaSourceTaskFactory;
51
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
51
import org.openide.filesystems.FileObject;
52
import org.openide.filesystems.FileObject;
52
53
53
/**
54
/**
Lines 58-64 Link Here
58
public class IntroduceHintFactory extends SelectionAwareJavaSourceTaskFactory {
59
public class IntroduceHintFactory extends SelectionAwareJavaSourceTaskFactory {
59
60
60
    public IntroduceHintFactory() {
61
    public IntroduceHintFactory() {
61
        super(Phase.RESOLVED, Priority.BELOW_NORMAL);
62
        super(Phase.RESOLVED, Priority.BELOW_NORMAL, TaskIndexingMode.ALLOWED_DURING_SCAN);
62
    }
63
    }
63
    
64
    
64
    protected CancellableTask<CompilationInfo> createTask(FileObject file) {
65
    protected CancellableTask<CompilationInfo> createTask(FileObject file) {
(-)a/java.hints/src/org/netbeans/modules/java/hints/jackpot/impl/hints/HintsTask.java (-1 / +2 lines)
Lines 65-70 Link Here
65
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
65
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
66
import org.netbeans.modules.java.hints.infrastructure.JavaHintsPositionRefresher;
66
import org.netbeans.modules.java.hints.infrastructure.JavaHintsPositionRefresher;
67
import org.netbeans.modules.java.hints.options.HintsSettings;
67
import org.netbeans.modules.java.hints.options.HintsSettings;
68
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
68
import org.netbeans.spi.editor.hints.ErrorDescription;
69
import org.netbeans.spi.editor.hints.ErrorDescription;
69
import org.netbeans.spi.editor.hints.Severity;
70
import org.netbeans.spi.editor.hints.Severity;
70
import org.openide.util.WeakListeners;
71
import org.openide.util.WeakListeners;
Lines 138-144 Link Here
138
    public static final class FactoryImpl extends EditorAwareJavaSourceTaskFactory implements ChangeListener {
139
    public static final class FactoryImpl extends EditorAwareJavaSourceTaskFactory implements ChangeListener {
139
140
140
        public FactoryImpl() {
141
        public FactoryImpl() {
141
            super(Phase.RESOLVED, Priority.LOW);
142
            super(Phase.RESOLVED, Priority.LOW, TaskIndexingMode.ALLOWED_DURING_SCAN);
142
	    HintsSettings.addChangeListener(WeakListeners.change(this, HintsSettings.class));
143
	    HintsSettings.addChangeListener(WeakListeners.change(this, HintsSettings.class));
143
        }
144
        }
144
145
(-)a/java.navigation/nbproject/project.xml (-1 / +10 lines)
Lines 152-158 Link Here
152
                    <build-prerequisite/>
152
                    <build-prerequisite/>
153
                    <compile-dependency/>
153
                    <compile-dependency/>
154
                    <run-dependency>
154
                    <run-dependency>
155
                        <specification-version>0.84</specification-version>
155
                        <specification-version>0.94</specification-version>
156
                    </run-dependency>
156
                    </run-dependency>
157
                </dependency>
157
                </dependency>
158
                <dependency>
158
                <dependency>
Lines 174-179 Link Here
174
                    </run-dependency>
174
                    </run-dependency>
175
                </dependency>
175
                </dependency>
176
                <dependency>
176
                <dependency>
177
                    <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
178
                    <build-prerequisite/>
179
                    <compile-dependency/>
180
                    <run-dependency>
181
                        <release-version>1</release-version>
182
                        <specification-version>1.51</specification-version>
183
                    </run-dependency>
184
                </dependency>
185
                <dependency>
177
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
186
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
178
                    <build-prerequisite/>
187
                    <build-prerequisite/>
179
                    <compile-dependency/>
188
                    <compile-dependency/>
(-)a/java.navigation/src/org/netbeans/modules/java/navigation/CaretListeningFactory.java (-1 / +2 lines)
Lines 50-55 Link Here
50
import org.netbeans.api.java.source.JavaSource.Phase;
50
import org.netbeans.api.java.source.JavaSource.Phase;
51
import org.netbeans.api.java.source.JavaSource.Priority;
51
import org.netbeans.api.java.source.JavaSource.Priority;
52
import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
52
import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
53
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
53
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileObject;
54
55
55
/**
56
/**
Lines 63-69 Link Here
63
    private static CaretListeningFactory INSTANCE;
64
    private static CaretListeningFactory INSTANCE;
64
    
65
    
65
    public CaretListeningFactory() {
66
    public CaretListeningFactory() {
66
        super(Phase.RESOLVED, Priority.LOW);
67
        super(Phase.RESOLVED, Priority.LOW, TaskIndexingMode.ALLOWED_DURING_SCAN);
67
        INSTANCE = this;
68
        INSTANCE = this;
68
    }
69
    }
69
70
(-)a/java.navigation/src/org/netbeans/modules/java/navigation/ClassMemberNavigatorJavaSourceFactory.java (-1 / +7 lines)
Lines 51-56 Link Here
51
import org.netbeans.api.java.source.JavaSource.Priority;
51
import org.netbeans.api.java.source.JavaSource.Priority;
52
import org.netbeans.api.java.source.JavaSourceTaskFactory;
52
import org.netbeans.api.java.source.JavaSourceTaskFactory;
53
import org.netbeans.api.java.source.support.LookupBasedJavaSourceTaskFactory;
53
import org.netbeans.api.java.source.support.LookupBasedJavaSourceTaskFactory;
54
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
54
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileObject;
55
import org.openide.util.Lookup;
56
import org.openide.util.Lookup;
56
57
Lines 79-85 Link Here
79
    }
80
    }
80
    
81
    
81
    public ClassMemberNavigatorJavaSourceFactory() {        
82
    public ClassMemberNavigatorJavaSourceFactory() {        
82
        super(Phase.ELEMENTS_RESOLVED, Priority.NORMAL, "text/x-java", "application/x-class-file");
83
        super(
84
            Phase.ELEMENTS_RESOLVED,
85
            Priority.NORMAL,
86
            TaskIndexingMode.ALLOWED_DURING_SCAN,
87
            "text/x-java",
88
            "application/x-class-file");
83
    }
89
    }
84
90
85
    public synchronized CancellableTask<CompilationInfo> createTask(FileObject file) {
91
    public synchronized CancellableTask<CompilationInfo> createTask(FileObject file) {
(-)a/java.source/apichanges.xml (+19 lines)
Lines 108-113 Link Here
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
109
109
110
    <changes>
110
    <changes>
111
        <change id="Indexing-aware-JavaSourceTaskFactories">
112
             <api name="general"/>
113
             <summary>Added <code>TaskIndexingMode</code> into <code>JavaSourceTaskFactory</code>s</summary>
114
             <version major="0" minor="94"/>
115
             <date day="31" month="1" year="2012"/>
116
             <author login="tzezula"/>
117
            <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="no" semantic="compatible" source="compatible"/>
118
             <description>
119
                 The <code>CancellableTask</code>s created by the <code>JavaSourceTaskFactory</code>s are not executed during the scan to keep the semantic backward compatibility.
120
                 Constructors with the <code>TaskIndexingMode</code> were added into these factories to allow tasks to run during the scan.
121
             </description>
122
             <class package="org.netbeans.api.java.source" name="JavaParserResultTask"/>
123
             <class package="org.netbeans.api.java.source" name="JavaSourceTaskFactory"/>
124
             <class package="org.netbeans.api.java.source.support" name="SelectionAwareJavaSourceTaskFactory"/>
125
             <class package="org.netbeans.api.java.source.support" name="LookupBasedJavaSourceTaskFactory"/>
126
             <class package="org.netbeans.api.java.source.support" name="EditorAwareJavaSourceTaskFactory"/>
127
             <class package="org.netbeans.api.java.source.support" name="CaretAwareJavaSourceTaskFactory"/>
128
             <issue number="207459"/>
129
        </change>
111
        <change id="TreePathHandle-getElementHandle">
130
        <change id="TreePathHandle-getElementHandle">
112
             <api name="general"/>
131
             <api name="general"/>
113
             <summary>Added <code>TreePathHandle.getElementHandle</code>.</summary>
132
             <summary>Added <code>TreePathHandle.getElementHandle</code>.</summary>
(-)a/java.source/nbproject/project.properties (-1 / +1 lines)
Lines 46-52 Link Here
46
javadoc.title=Java Source
46
javadoc.title=Java Source
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
49
spec.version.base=0.93.0
49
spec.version.base=0.94.0
50
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/javac-api-nb-7.0-b07.jar
50
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/javac-api-nb-7.0-b07.jar
51
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
51
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
52
    ${o.n.core.dir}/lib/boot.jar:\
52
    ${o.n.core.dir}/lib/boot.jar:\
(-)a/java.source/src/org/netbeans/api/java/source/JavaParserResultTask.java (-5 / +21 lines)
Lines 43-60 Link Here
43
package org.netbeans.api.java.source;
43
package org.netbeans.api.java.source;
44
44
45
import org.netbeans.api.annotations.common.NonNull;
45
import org.netbeans.api.annotations.common.NonNull;
46
import org.netbeans.modules.parsing.spi.IndexingAwareParserResultTask;
46
import org.netbeans.modules.parsing.spi.Parser;
47
import org.netbeans.modules.parsing.spi.Parser;
47
import org.netbeans.modules.parsing.spi.ParserResultTask;
48
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
48
import org.openide.util.Parameters;
49
import org.openide.util.Parameters;
49
50
50
/**
51
/**
51
 * Java specific version of the {@link ParserResultTask}. In addition to the
52
 * Java specific version of the {@link IndexingAwareParserResultTask}. In addition to the
52
 * {@link ParserResultTask} it adds a support for javac phases.
53
 * {@link IndexingAwareParserResultTask} it adds a support for javac phases.
53
 * @see JavaSource
54
 * @see JavaSource
54
 * @since 0.42
55
 * @since 0.42
55
 * @author Tomas Zezula
56
 * @author Tomas Zezula
56
 */
57
 */
57
public abstract class JavaParserResultTask<T extends Parser.Result> extends ParserResultTask<T> {
58
public abstract class JavaParserResultTask<T extends Parser.Result> extends IndexingAwareParserResultTask<T> {
58
59
59
    private final JavaSource.Phase phase;
60
    private final JavaSource.Phase phase;
60
61
Lines 63-69 Link Here
63
     * @param phase needed by the task.
64
     * @param phase needed by the task.
64
     */
65
     */
65
    protected JavaParserResultTask (final @NonNull JavaSource.Phase phase) {
66
    protected JavaParserResultTask (final @NonNull JavaSource.Phase phase) {
66
        Parameters.notNull("phase", phase);
67
        this (phase, TaskIndexingMode.DISALLOWED_DURING_SCAN);
68
    }
69
    
70
    /**
71
     * Creates a new JavaParserResultTask
72
     * @param phase needed by the task.
73
     * @param taskIndexingMode the awareness of indexing. For tasks which can run
74
     * during indexing use {@link TaskIndexingMode#ALLOWED_DURING_SCAN} for tasks
75
     * which cannot run during indexing use {@link TaskIndexingMode#DISALLOWED_DURING_SCAN}.
76
     * @since 0.94
77
     */
78
    protected JavaParserResultTask (
79
        @NonNull final JavaSource.Phase phase,
80
        @NonNull final TaskIndexingMode taskIndexingMode) {
81
        super(taskIndexingMode);
82
        Parameters.notNull("phase", phase); //NOI18
67
        this.phase = phase;
83
        this.phase = phase;
68
    }
84
    }
69
85
(-)a/java.source/src/org/netbeans/api/java/source/JavaSourceTaskFactory.java (-4 / +32 lines)
Lines 62-67 Link Here
62
import org.netbeans.api.java.source.support.LookupBasedJavaSourceTaskFactory;
62
import org.netbeans.api.java.source.support.LookupBasedJavaSourceTaskFactory;
63
import org.netbeans.modules.java.source.JavaSourceAccessor;
63
import org.netbeans.modules.java.source.JavaSourceAccessor;
64
import org.netbeans.modules.java.source.JavaSourceTaskFactoryManager;
64
import org.netbeans.modules.java.source.JavaSourceTaskFactoryManager;
65
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
66
import org.openide.util.Parameters;
65
import org.openide.util.RequestProcessor;
67
import org.openide.util.RequestProcessor;
66
68
67
/**
69
/**
Lines 86-91 Link Here
86
            
88
            
87
    private final Phase phase;
89
    private final Phase phase;
88
    private final Priority priority;
90
    private final Priority priority;
91
    private final TaskIndexingMode taskIndexingMode;
89
92
90
    /**Construct the JavaSourceTaskFactory with given {@link Phase} and {@link Priority}.
93
    /**Construct the JavaSourceTaskFactory with given {@link Phase} and {@link Priority}.
91
     *
94
     *
Lines 95-100 Link Here
95
    protected JavaSourceTaskFactory(@NonNull Phase phase, @NonNull Priority priority) {
98
    protected JavaSourceTaskFactory(@NonNull Phase phase, @NonNull Priority priority) {
96
        this.phase = phase;
99
        this.phase = phase;
97
        this.priority = priority;
100
        this.priority = priority;
101
        this.taskIndexingMode = TaskIndexingMode.DISALLOWED_DURING_SCAN;
102
        this.file2Task = new HashMap<FileObject, CancellableTask<CompilationInfo>>();
103
        this.file2JS = new HashMap<FileObject, JavaSource>();
104
    }
105
    
106
    /**Construct the JavaSourceTaskFactory with given {@link Phase}, {@link Priority}
107
     * and {@link TaskIndexingMode}.
108
     *
109
     * @param phase phase to use for tasks created by {@link #createTask}
110
     * @param priority priority to use for tasks created by {@link #createTask}
111
     * @param taskIndexingMode the awareness of indexing. For tasks which can run
112
     * during indexing use {@link TaskIndexingMode#ALLOWED_DURING_SCAN} for tasks
113
     * which cannot run during indexing use {@link TaskIndexingMode#DISALLOWED_DURING_SCAN}.
114
     * @since 0.94
115
     */
116
    protected JavaSourceTaskFactory(
117
            @NonNull final Phase phase,
118
            @NonNull final Priority priority,
119
            @NonNull final TaskIndexingMode taskIndexingMode) {
120
        Parameters.notNull("phase", phase); //NOI18N
121
        Parameters.notNull("priority", priority);   //NOI18N
122
        Parameters.notNull("taskIndexingMode", taskIndexingMode);   //NOI18N
123
        this.phase = phase;
124
        this.priority = priority;
125
        this.taskIndexingMode = taskIndexingMode;
98
        this.file2Task = new HashMap<FileObject, CancellableTask<CompilationInfo>>();
126
        this.file2Task = new HashMap<FileObject, CancellableTask<CompilationInfo>>();
99
        this.file2JS = new HashMap<FileObject, JavaSource>();
127
        this.file2JS = new HashMap<FileObject, JavaSource>();
100
    }
128
    }
Lines 184-190 Link Here
184
                    if (task == null) {
212
                    if (task == null) {
185
                        throw new IllegalStateException("createTask(FileObject) returned null for factory: " + getClass().getName());
213
                        throw new IllegalStateException("createTask(FileObject) returned null for factory: " + getClass().getName());
186
                    }                    
214
                    }                    
187
                    ACCESSOR2.addPhaseCompletionTask(js, task, phase, priority);                    
215
                    ACCESSOR2.addPhaseCompletionTask(js, task, phase, priority, taskIndexingMode);                    
188
                    file2Task.put(a, task);
216
                    file2Task.put(a, task);
189
                    file2JS.put(a, js);
217
                    file2JS.put(a, js);
190
                }
218
                }
Lines 230-237 Link Here
230
            }
258
            }
231
        };
259
        };
232
        ACCESSOR2 = new Accessor2() {
260
        ACCESSOR2 = new Accessor2() {
233
            public void addPhaseCompletionTask(JavaSource js, CancellableTask<CompilationInfo> task, Phase phase, Priority priority) {
261
            public void addPhaseCompletionTask(JavaSource js, CancellableTask<CompilationInfo> task, Phase phase, Priority priority, TaskIndexingMode taskIndexingMode) {
234
                JavaSourceAccessor.getINSTANCE().addPhaseCompletionTask (js, task, phase, priority);                
262
                JavaSourceAccessor.getINSTANCE().addPhaseCompletionTask (js, task, phase, priority, taskIndexingMode);
235
            }
263
            }
236
264
237
            public void removePhaseCompletionTask(JavaSource js, CancellableTask<CompilationInfo> task) {
265
            public void removePhaseCompletionTask(JavaSource js, CancellableTask<CompilationInfo> task) {
Lines 245-251 Link Here
245
    }
273
    }
246
274
247
    static interface Accessor2 {
275
    static interface Accessor2 {
248
        public abstract void addPhaseCompletionTask(JavaSource js, CancellableTask<CompilationInfo> task, Phase phase, Priority priority );
276
        public abstract void addPhaseCompletionTask(JavaSource js, CancellableTask<CompilationInfo> task, Phase phase, Priority priority, TaskIndexingMode taskIndexingMode );
249
        public abstract void removePhaseCompletionTask(JavaSource js, CancellableTask<CompilationInfo> task );
277
        public abstract void removePhaseCompletionTask(JavaSource js, CancellableTask<CompilationInfo> task );
250
        public abstract void rescheduleTask(JavaSource js, CancellableTask<CompilationInfo> task);
278
        public abstract void rescheduleTask(JavaSource js, CancellableTask<CompilationInfo> task);
251
    }
279
    }
(-)a/java.source/src/org/netbeans/api/java/source/support/CaretAwareJavaSourceTaskFactory.java (-4 / +29 lines)
Lines 46-53 Link Here
46
import java.lang.ref.Reference;
46
import java.lang.ref.Reference;
47
import java.lang.ref.WeakReference;
47
import java.lang.ref.WeakReference;
48
import java.util.ArrayList;
48
import java.util.ArrayList;
49
import java.util.Arrays;
50
import java.util.HashMap;
51
import java.util.List;
49
import java.util.List;
52
import java.util.Map;
50
import java.util.Map;
53
import java.util.WeakHashMap;
51
import java.util.WeakHashMap;
Lines 56-66 Link Here
56
import javax.swing.event.ChangeEvent;
54
import javax.swing.event.ChangeEvent;
57
import javax.swing.event.ChangeListener;
55
import javax.swing.event.ChangeListener;
58
import javax.swing.text.JTextComponent;
56
import javax.swing.text.JTextComponent;
57
import org.netbeans.api.annotations.common.NonNull;
59
import org.netbeans.api.java.source.JavaSource.Phase;
58
import org.netbeans.api.java.source.JavaSource.Phase;
60
import org.netbeans.api.java.source.JavaSource.Priority;
59
import org.netbeans.api.java.source.JavaSource.Priority;
61
import org.netbeans.api.java.source.JavaSourceTaskFactory;
60
import org.netbeans.api.java.source.JavaSourceTaskFactory;
62
import org.netbeans.api.java.source.SourceUtils;
61
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
63
import org.openide.filesystems.FileObject;
62
import org.openide.filesystems.FileObject;
63
import org.openide.util.Parameters;
64
import org.openide.util.RequestProcessor;
64
import org.openide.util.RequestProcessor;
65
65
66
/**A {@link JavaSourceTaskFactorySupport} that registers tasks to all files that are
66
/**A {@link JavaSourceTaskFactorySupport} that registers tasks to all files that are
Lines 96-108 Link Here
96
     * @since 0.21
96
     * @since 0.21
97
     */
97
     */
98
    public CaretAwareJavaSourceTaskFactory(Phase phase, Priority priority, String... supportedMimeTypes) {
98
    public CaretAwareJavaSourceTaskFactory(Phase phase, Priority priority, String... supportedMimeTypes) {
99
        super(phase, priority);
99
        super(phase, priority, TaskIndexingMode.DISALLOWED_DURING_SCAN);
100
        //XXX: weak, or something like this:
100
        //XXX: weak, or something like this:
101
        OpenedEditors.getDefault().addChangeListener(new ChangeListenerImpl());
101
        OpenedEditors.getDefault().addChangeListener(new ChangeListenerImpl());
102
        this.timeout = DEFAULT_RESCHEDULE_TIMEOUT;
102
        this.timeout = DEFAULT_RESCHEDULE_TIMEOUT;
103
        this.supportedMimeTypes = supportedMimeTypes != null ? supportedMimeTypes.clone() : null;
103
        this.supportedMimeTypes = supportedMimeTypes != null ? supportedMimeTypes.clone() : null;
104
    }
104
    }
105
    
105
    
106
    /**Construct the CaretAwareJavaSourceTaskFactory.
107
     *
108
     * @param phase phase to use for tasks created by {@link #createTask}
109
     * @param priority priority to use for tasks created by {@link #createTask}
110
     * @param taskIndexingMode the awareness of indexing. For tasks which can run
111
     * during indexing use {@link TaskIndexingMode#ALLOWED_DURING_SCAN} for tasks
112
     * which cannot run during indexing use {@link TaskIndexingMode#DISALLOWED_DURING_SCAN}.
113
     * @param supportedMimeTypes a list of mime types on which the tasks created by this factory should be run,
114
     * empty array falls back to default text/x-java.
115
     * 
116
     * @since 0.94
117
     */
118
    public CaretAwareJavaSourceTaskFactory(
119
            @NonNull Phase phase,
120
            @NonNull Priority priority,
121
            @NonNull TaskIndexingMode taskIndexingMode,
122
            @NonNull String... supportedMimeTypes) {
123
        super(phase, priority, taskIndexingMode);
124
        Parameters.notNull("supportedMimeTypes", supportedMimeTypes);   //NOI18N
125
        //XXX: weak, or something like this:
126
        OpenedEditors.getDefault().addChangeListener(new ChangeListenerImpl());
127
        this.timeout = DEFAULT_RESCHEDULE_TIMEOUT;
128
        this.supportedMimeTypes = supportedMimeTypes.length > 0 ? supportedMimeTypes.clone() : null;
129
    }
130
    
106
    /**@inheritDoc*/
131
    /**@inheritDoc*/
107
    public List<FileObject> getFileObjects() {
132
    public List<FileObject> getFileObjects() {
108
        List<FileObject> files = OpenedEditors.filterSupportedMIMETypes(OpenedEditors.getDefault().getVisibleEditorsFiles(), supportedMimeTypes);
133
        List<FileObject> files = OpenedEditors.filterSupportedMIMETypes(OpenedEditors.getDefault().getVisibleEditorsFiles(), supportedMimeTypes);
(-)a/java.source/src/org/netbeans/api/java/source/support/EditorAwareJavaSourceTaskFactory.java (-2 / +27 lines)
Lines 46-56 Link Here
46
import java.util.List;
46
import java.util.List;
47
import javax.swing.event.ChangeEvent;
47
import javax.swing.event.ChangeEvent;
48
import javax.swing.event.ChangeListener;
48
import javax.swing.event.ChangeListener;
49
import org.netbeans.api.annotations.common.NonNull;
49
import org.netbeans.api.java.source.JavaSource.Phase;
50
import org.netbeans.api.java.source.JavaSource.Phase;
50
import org.netbeans.api.java.source.JavaSource.Priority;
51
import org.netbeans.api.java.source.JavaSource.Priority;
51
import org.netbeans.api.java.source.JavaSourceTaskFactory;
52
import org.netbeans.api.java.source.JavaSourceTaskFactory;
52
import org.netbeans.api.java.source.SourceUtils;
53
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
53
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileObject;
55
import org.openide.util.Parameters;
54
56
55
/**A {@link JavaSourceTaskFactorySupport} that registers tasks to all files that are
57
/**A {@link JavaSourceTaskFactorySupport} that registers tasks to all files that are
56
 * opened in the editor and are visible.
58
 * opened in the editor and are visible.
Lines 78-89 Link Here
78
     * @since 0.21
80
     * @since 0.21
79
     */
81
     */
80
    protected EditorAwareJavaSourceTaskFactory(Phase phase, Priority priority, String... supportedMimeTypes) {
82
    protected EditorAwareJavaSourceTaskFactory(Phase phase, Priority priority, String... supportedMimeTypes) {
81
        super(phase, priority);
83
        super(phase, priority, TaskIndexingMode.DISALLOWED_DURING_SCAN);
82
        //XXX: weak, or something like this:
84
        //XXX: weak, or something like this:
83
        OpenedEditors.getDefault().addChangeListener(new ChangeListenerImpl());
85
        OpenedEditors.getDefault().addChangeListener(new ChangeListenerImpl());
84
        this.supportedMimeTypes = supportedMimeTypes != null ? supportedMimeTypes.clone() : null;
86
        this.supportedMimeTypes = supportedMimeTypes != null ? supportedMimeTypes.clone() : null;
85
    }
87
    }
86
    
88
    
89
    /**Construct the EditorAwareJavaSourceTaskFactory.
90
     *
91
     * @param phase phase to use for tasks created by {@link #createTask}
92
     * @param priority priority to use for tasks created by {@link #createTask}
93
     * @param taskIndexingMode the awareness of indexing. For tasks which can run
94
     * during indexing use {@link TaskIndexingMode#ALLOWED_DURING_SCAN} for tasks
95
     * which cannot run during indexing use {@link TaskIndexingMode#DISALLOWED_DURING_SCAN}.
96
     * @param supportedMimeTypes a list of mime types on which the tasks created by this factory should be run,
97
     * empty array falls back to default text/x-java.
98
     * @since 0.94
99
     */
100
    protected EditorAwareJavaSourceTaskFactory(
101
            @NonNull final Phase phase,
102
            @NonNull final Priority priority,
103
            @NonNull final TaskIndexingMode taskIndexingMode,
104
            @NonNull final String... supportedMimeTypes) {
105
        super(phase, priority, taskIndexingMode);
106
        Parameters.notNull("supportedMimeTypes", supportedMimeTypes);   //NOI18N
107
        //XXX: weak, or something like this:
108
        OpenedEditors.getDefault().addChangeListener(new ChangeListenerImpl());
109
        this.supportedMimeTypes = supportedMimeTypes.length > 0 ? supportedMimeTypes.clone() : null;
110
    }
111
    
87
    /**@inheritDoc*/
112
    /**@inheritDoc*/
88
    public List<FileObject> getFileObjects() {
113
    public List<FileObject> getFileObjects() {
89
        List<FileObject> files = OpenedEditors.filterSupportedMIMETypes(OpenedEditors.getDefault().getVisibleEditorsFiles(), supportedMimeTypes);
114
        List<FileObject> files = OpenedEditors.filterSupportedMIMETypes(OpenedEditors.getDefault().getVisibleEditorsFiles(), supportedMimeTypes);
(-)a/java.source/src/org/netbeans/api/java/source/support/LookupBasedJavaSourceTaskFactory.java (-4 / +27 lines)
Lines 43-59 Link Here
43
 */
43
 */
44
package org.netbeans.api.java.source.support;
44
package org.netbeans.api.java.source.support;
45
45
46
import java.util.ArrayList;
47
import java.util.Collections;
46
import java.util.Collections;
48
import java.util.HashSet;
47
import java.util.HashSet;
49
import java.util.LinkedList;
48
import java.util.LinkedList;
50
import java.util.List;
49
import java.util.List;
51
import java.util.Set;
50
import java.util.Set;
52
import javax.swing.event.ChangeEvent;
51
import org.netbeans.api.annotations.common.NonNull;
53
import org.netbeans.api.java.source.JavaSource.Phase;
52
import org.netbeans.api.java.source.JavaSource.Phase;
54
import org.netbeans.api.java.source.JavaSource.Priority;
53
import org.netbeans.api.java.source.JavaSource.Priority;
55
import org.netbeans.api.java.source.JavaSourceTaskFactory;
54
import org.netbeans.api.java.source.JavaSourceTaskFactory;
56
import org.netbeans.api.java.source.SourceUtils;
55
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
57
import org.openide.filesystems.FileObject;
56
import org.openide.filesystems.FileObject;
58
import org.openide.loaders.DataObject;
57
import org.openide.loaders.DataObject;
59
import org.openide.nodes.Node;
58
import org.openide.nodes.Node;
Lines 61-66 Link Here
61
import org.openide.util.Lookup.Result;
60
import org.openide.util.Lookup.Result;
62
import org.openide.util.LookupEvent;
61
import org.openide.util.LookupEvent;
63
import org.openide.util.LookupListener;
62
import org.openide.util.LookupListener;
63
import org.openide.util.Parameters;
64
64
65
/**A {@link JavaSourceTaskFactorySupport} that registers tasks to all files that are
65
/**A {@link JavaSourceTaskFactorySupport} that registers tasks to all files that are
66
 * found in the given {@link Lookup}.
66
 * found in the given {@link Lookup}.
Lines 98-108 Link Here
98
     * @since 0.21
98
     * @since 0.21
99
     */
99
     */
100
    public LookupBasedJavaSourceTaskFactory(Phase phase, Priority priority, String... supportedMimeTypes) {
100
    public LookupBasedJavaSourceTaskFactory(Phase phase, Priority priority, String... supportedMimeTypes) {
101
        super(phase, priority);
101
        super(phase, priority, TaskIndexingMode.DISALLOWED_DURING_SCAN);
102
        currentFiles = Collections.emptyList();
102
        currentFiles = Collections.emptyList();
103
        listener = new LookupListenerImpl();
103
        listener = new LookupListenerImpl();
104
        this.supportedMimeTypes = supportedMimeTypes != null ? supportedMimeTypes.clone() : null;
104
        this.supportedMimeTypes = supportedMimeTypes != null ? supportedMimeTypes.clone() : null;
105
    }
105
    }
106
    
107
    /**Construct the LookupBasedJavaSourceTaskFactory with given {@link Phase} and {@link Priority}.
108
     *
109
     * @param phase phase to use for tasks created by {@link #createTask}
110
     * @param priority priority to use for tasks created by {@link #createTask}
111
     * @param taskIndexingMode the awareness of indexing. For tasks which can run
112
     * during indexing use {@link TaskIndexingMode#ALLOWED_DURING_SCAN} for tasks
113
     * which cannot run during indexing use {@link TaskIndexingMode#DISALLOWED_DURING_SCAN}.
114
     * @param supportedMimeTypes a list of mime types on which the tasks created by this factory should be run,
115
     * empty array falls back to default text/x-java.
116
     * @since 0.94
117
     */
118
    public LookupBasedJavaSourceTaskFactory(
119
            @NonNull final Phase phase,
120
            @NonNull final Priority priority,
121
            @NonNull final TaskIndexingMode taskIndexingMode,
122
            @NonNull final String... supportedMimeTypes) {
123
        super(phase, priority, taskIndexingMode);
124
        Parameters.notNull("supportedMimeTypes", supportedMimeTypes);   //NOI18N
125
        currentFiles = Collections.emptyList();
126
        listener = new LookupListenerImpl();
127
        this.supportedMimeTypes = supportedMimeTypes.length > 0 ? supportedMimeTypes.clone() : null;
128
    }
106
129
107
    /**Sets a new {@link Lookup} to search.
130
    /**Sets a new {@link Lookup} to search.
108
     *
131
     *
(-)a/java.source/src/org/netbeans/api/java/source/support/SelectionAwareJavaSourceTaskFactory.java (-2 / +28 lines)
Lines 46-52 Link Here
46
import java.lang.ref.Reference;
46
import java.lang.ref.Reference;
47
import java.lang.ref.WeakReference;
47
import java.lang.ref.WeakReference;
48
import java.util.ArrayList;
48
import java.util.ArrayList;
49
import java.util.HashMap;
50
import java.util.List;
49
import java.util.List;
51
import java.util.Map;
50
import java.util.Map;
52
import java.util.WeakHashMap;
51
import java.util.WeakHashMap;
Lines 55-64 Link Here
55
import javax.swing.event.ChangeEvent;
54
import javax.swing.event.ChangeEvent;
56
import javax.swing.event.ChangeListener;
55
import javax.swing.event.ChangeListener;
57
import javax.swing.text.JTextComponent;
56
import javax.swing.text.JTextComponent;
57
import org.netbeans.api.annotations.common.NonNull;
58
import org.netbeans.api.java.source.JavaSource.Phase;
58
import org.netbeans.api.java.source.JavaSource.Phase;
59
import org.netbeans.api.java.source.JavaSource.Priority;
59
import org.netbeans.api.java.source.JavaSource.Priority;
60
import org.netbeans.api.java.source.JavaSourceTaskFactory;
60
import org.netbeans.api.java.source.JavaSourceTaskFactory;
61
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
61
import org.openide.filesystems.FileObject;
62
import org.openide.filesystems.FileObject;
63
import org.openide.util.Parameters;
62
import org.openide.util.RequestProcessor;
64
import org.openide.util.RequestProcessor;
63
65
64
/**A {@link JavaSourceTaskFactorySupport} that registers tasks to all files that are
66
/**A {@link JavaSourceTaskFactorySupport} that registers tasks to all files that are
Lines 96-108 Link Here
96
     * @since 0.22
98
     * @since 0.22
97
     */
99
     */
98
    public SelectionAwareJavaSourceTaskFactory(Phase phase, Priority priority, String... supportedMimeTypes) {
100
    public SelectionAwareJavaSourceTaskFactory(Phase phase, Priority priority, String... supportedMimeTypes) {
99
        super(phase, priority);
101
        super(phase, priority, TaskIndexingMode.DISALLOWED_DURING_SCAN);
100
        //XXX: weak, or something like this:
102
        //XXX: weak, or something like this:
101
        OpenedEditors.getDefault().addChangeListener(new ChangeListenerImpl());
103
        OpenedEditors.getDefault().addChangeListener(new ChangeListenerImpl());
102
        this.timeout = DEFAULT_RESCHEDULE_TIMEOUT;
104
        this.timeout = DEFAULT_RESCHEDULE_TIMEOUT;
103
        this.supportedMimeTypes = supportedMimeTypes != null ? supportedMimeTypes.clone() : null;
105
        this.supportedMimeTypes = supportedMimeTypes != null ? supportedMimeTypes.clone() : null;
104
    }
106
    }
105
    
107
    
108
    /**Construct the SelectionAwareJavaSourceTaskFactory with given {@link Phase} and {@link Priority}.
109
     *
110
     * @param phase phase to use for tasks created by {@link #createTask}
111
     * @param priority priority to use for tasks created by {@link #createTask}
112
     * @param taskIndexingMode the awareness of indexing. For tasks which can run
113
     * during indexing use {@link TaskIndexingMode#ALLOWED_DURING_SCAN} for tasks
114
     * which cannot run during indexing use {@link TaskIndexingMode#DISALLOWED_DURING_SCAN}.
115
     * @param supportedMimeTypes a list of mime types on which the tasks created by this factory should be run,
116
     * empty array falls back to default text/x-java.
117
     * @since 0.94
118
     */
119
    public SelectionAwareJavaSourceTaskFactory(
120
            @NonNull final Phase phase,
121
            @NonNull final Priority priority,
122
            @NonNull final TaskIndexingMode taskIndexingMode,
123
            @NonNull String... supportedMimeTypes) {
124
        super(phase, priority, taskIndexingMode);
125
        Parameters.notNull("supportedMimeTypes", supportedMimeTypes);   //NOI18N
126
        //XXX: weak, or something like this:
127
        OpenedEditors.getDefault().addChangeListener(new ChangeListenerImpl());
128
        this.timeout = DEFAULT_RESCHEDULE_TIMEOUT;
129
        this.supportedMimeTypes = supportedMimeTypes.length > 0 ? supportedMimeTypes.clone() : null;
130
    }
131
    
106
    /**@inheritDoc*/
132
    /**@inheritDoc*/
107
    public List<FileObject> getFileObjects() {
133
    public List<FileObject> getFileObjects() {
108
        List<FileObject> files = OpenedEditors.filterSupportedMIMETypes(OpenedEditors.getDefault().getVisibleEditorsFiles(), supportedMimeTypes);
134
        List<FileObject> files = OpenedEditors.filterSupportedMIMETypes(OpenedEditors.getDefault().getVisibleEditorsFiles(), supportedMimeTypes);
(-)a/java.source/src/org/netbeans/modules/java/source/JavaSourceAccessor.java (-7 / +11 lines)
Lines 76-85 Link Here
76
import org.netbeans.modules.parsing.spi.ParserResultTask;
76
import org.netbeans.modules.parsing.spi.ParserResultTask;
77
import org.netbeans.modules.parsing.spi.Scheduler;
77
import org.netbeans.modules.parsing.spi.Scheduler;
78
import org.netbeans.modules.parsing.spi.SchedulerEvent;
78
import org.netbeans.modules.parsing.spi.SchedulerEvent;
79
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
79
import org.openide.filesystems.FileObject;
80
import org.openide.filesystems.FileObject;
80
import org.openide.text.PositionRef;
81
import org.openide.text.PositionRef;
81
import org.openide.util.Exceptions;
82
import org.openide.util.Exceptions;
82
import org.openide.util.Mutex;
83
import org.openide.util.Parameters;
83
import org.openide.util.Parameters;
84
84
85
/**
85
/**
Lines 147-153 Link Here
147
    public void addPhaseCompletionTask (final JavaSource js,
147
    public void addPhaseCompletionTask (final JavaSource js,
148
            final CancellableTask<CompilationInfo> task,
148
            final CancellableTask<CompilationInfo> task,
149
            final JavaSource.Phase phase,
149
            final JavaSource.Phase phase,
150
            final JavaSource.Priority priority) {
150
            final JavaSource.Priority priority,
151
            final TaskIndexingMode taskIndexingMode) {
151
        
152
        
152
        final Collection<Source> sources = getSources(js);
153
        final Collection<Source> sources = getSources(js);
153
        assert sources.size() == 1;
154
        assert sources.size() == 1;
Lines 155-161 Link Here
155
        if (tasks.keySet().contains(task)) {
156
        if (tasks.keySet().contains(task)) {
156
            throw new IllegalArgumentException(String.format("Task: %s is already scheduled", task.toString()));   //NOI18N
157
            throw new IllegalArgumentException(String.format("Task: %s is already scheduled", task.toString()));   //NOI18N
157
        }
158
        }
158
        final ParserResultTask<?> hanz = new CancelableTaskWrapper(task, pp, phase, js);
159
        final ParserResultTask<?> hanz = new CancelableTaskWrapper(task, pp, phase, js, taskIndexingMode);
159
        tasks.put(task, hanz);
160
        tasks.put(task, hanz);
160
        Utilities.addParserResultTask(hanz, sources.iterator().next());
161
        Utilities.addParserResultTask(hanz, sources.iterator().next());
161
    }
162
    }
Lines 254-263 Link Here
254
        private final int priority;
255
        private final int priority;
255
        private final CancellableTask<CompilationInfo> task;
256
        private final CancellableTask<CompilationInfo> task;
256
        
257
        
257
        public CancelableTaskWrapper (final CancellableTask<CompilationInfo> task,
258
        public CancelableTaskWrapper (
258
                final int priority, final Phase phase,
259
                @NonNull final CancellableTask<CompilationInfo> task,
259
                final JavaSource javaSource) {
260
                final int priority,
260
            super (phase);
261
                @NonNull final Phase phase,
262
                @NonNull final JavaSource javaSource,
263
                @NonNull final TaskIndexingMode taskIndexingMode) {
264
            super (phase, taskIndexingMode);
261
            assert phase != null;
265
            assert phase != null;
262
            assert javaSource != null;
266
            assert javaSource != null;
263
            this.task = task;
267
            this.task = task;
(-)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="IndexingAwareParserResultTask">
114
      <api name="ParsingAPI"/>
115
      <summary>Added <code>IndexingAwareParserResultTask</code> which is a specialization of <code>ParserResultTask</code>
116
      which can be executed during scan.</summary>
117
      <version major="1" minor="52"/>
118
      <date day="31" month="1" 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 <code>ParserResultTask</code>s are not executed during the scan to keep the semantic backward compatibility.
124
              A specialization of the <code>ParserResultTask</code> the <code>IndexingAwareParserResultTask</code> was added.
125
              The <code>IndexingAwareParserResultTask</code> can be executed during the scan.
126
          </p>
127
      </description>
128
      <class package="org.netbeans.modules.parsing.spi" name="IndexingAwareParserResultTask"/>
129
      <class package="org.netbeans.modules.parsing.spi" name="TaskIndexingMode"/>
130
      <issue number="207459"/>
131
  </change>
113
  <change id="ConstrainedBinaryIndexer-namePattern">
132
  <change id="ConstrainedBinaryIndexer-namePattern">
114
      <api name="ParsingAPI"/>
133
      <api name="ParsingAPI"/>
115
      <summary>Added <code>ConstrainedBinaryIndexer.Registration.namePattern</code> to allow indexers to use name pattern rather than expensive
134
      <summary>Added <code>ConstrainedBinaryIndexer.Registration.namePattern</code> to allow indexers to use name pattern rather than expensive
(-)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.50.0
6
spec.version.base=1.51.0
(-)a/parsing.api/src/org/netbeans/modules/parsing/impl/TaskProcessor.java (-9 / +7 lines)
Lines 78-94 Link Here
78
import org.netbeans.modules.parsing.api.Source;
78
import org.netbeans.modules.parsing.api.Source;
79
import org.netbeans.modules.parsing.api.Task;
79
import org.netbeans.modules.parsing.api.Task;
80
import org.netbeans.modules.parsing.api.UserTask;
80
import org.netbeans.modules.parsing.api.UserTask;
81
import org.netbeans.modules.parsing.api.indexing.IndexingManager;
81
import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
82
import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
82
import org.netbeans.modules.parsing.impl.indexing.Util;
83
import org.netbeans.modules.parsing.impl.indexing.Util;
83
import org.netbeans.modules.parsing.spi.EmbeddingProvider;
84
import org.netbeans.modules.parsing.spi.*;
84
import org.netbeans.modules.parsing.spi.ParseException;
85
import org.netbeans.modules.parsing.spi.Parser;
86
import org.netbeans.modules.parsing.spi.Parser.Result;
85
import org.netbeans.modules.parsing.spi.Parser.Result;
87
import org.netbeans.modules.parsing.spi.ParserResultTask;
88
import org.netbeans.modules.parsing.spi.SchedulerEvent;
89
import org.netbeans.modules.parsing.spi.SchedulerTask;
90
import org.netbeans.modules.parsing.spi.Scheduler;
91
import org.netbeans.modules.parsing.spi.SourceModificationEvent;
92
import org.openide.util.Exceptions;
86
import org.openide.util.Exceptions;
93
import org.openide.util.Mutex;
87
import org.openide.util.Mutex;
94
import org.openide.util.Parameters;
88
import org.openide.util.Parameters;
Lines 718-724 Link Here
718
                                                            final Parser.Result currentResult = sourceCache.getResult (r.task);
712
                                                            final Parser.Result currentResult = sourceCache.getResult (r.task);
719
                                                            if (currentResult != null) {
713
                                                            if (currentResult != null) {
720
                                                                try {
714
                                                                try {
721
                                                                    boolean shouldCall = !SourceAccessor.getINSTANCE().testFlag(source, SourceFlags.INVALID);
715
                                                                    final boolean sourceInvalid = SourceAccessor.getINSTANCE().testFlag(source, SourceFlags.INVALID);
716
                                                                    final boolean scanInProgress = IndexingManager.getDefault().isIndexing();
717
                                                                    final boolean canRunDuringScan = (r.task instanceof IndexingAwareParserResultTask) &&
718
                                                                            ((IndexingAwareParserResultTask)r.task).getIndexingMode() == TaskIndexingMode.ALLOWED_DURING_SCAN;
719
                                                                    final boolean shouldCall = !sourceInvalid && (!scanInProgress || canRunDuringScan);
722
                                                                    if (shouldCall) {
720
                                                                    if (shouldCall) {
723
                                                                        try {
721
                                                                        try {
724
                                                                            final long startTime = System.currentTimeMillis();
722
                                                                            final long startTime = System.currentTimeMillis();
(-)a/parsing.api/src/org/netbeans/modules/parsing/spi/IndexingAwareParserResultTask.java (+63 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.parsing.spi;
43
44
import org.netbeans.api.annotations.common.NonNull;
45
import org.openide.util.Parameters;
46
47
/**
48
 *
49
 * @author Tomas Zezula
50
 * @since 1.51
51
 */
52
public abstract class IndexingAwareParserResultTask<T extends Parser.Result>  extends ParserResultTask<T> {
53
    private final TaskIndexingMode scanMode;
54
    
55
    protected IndexingAwareParserResultTask(@NonNull final TaskIndexingMode scanMode) {
56
        Parameters.notNull("scanMode", scanMode);   //NOI18N
57
        this.scanMode = scanMode;
58
    }
59
    
60
    public final TaskIndexingMode getIndexingMode() {
61
        return scanMode;
62
    }
63
}
(-)a/parsing.api/src/org/netbeans/modules/parsing/spi/TaskIndexingMode.java (+52 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.parsing.spi;
43
44
/**
45
 *
46
 * @author Tomas Zezula
47
 * @since 1.51
48
 */
49
public enum TaskIndexingMode {
50
    ALLOWED_DURING_SCAN, 
51
    DISALLOWED_DURING_SCAN
52
}
(-)a/spellchecker.bindings.java/nbproject/project.xml (-1 / +10 lines)
Lines 54-60 Link Here
54
                    <build-prerequisite/>
54
                    <build-prerequisite/>
55
                    <compile-dependency/>
55
                    <compile-dependency/>
56
                    <run-dependency>
56
                    <run-dependency>
57
                        <specification-version>0.26</specification-version>
57
                        <specification-version>0.94</specification-version>
58
                    </run-dependency>
58
                    </run-dependency>
59
                </dependency>
59
                </dependency>
60
                <dependency>
60
                <dependency>
Lines 67-72 Link Here
67
                    </run-dependency>
67
                    </run-dependency>
68
                </dependency>
68
                </dependency>
69
                <dependency>
69
                <dependency>
70
                    <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
71
                    <build-prerequisite/>
72
                    <compile-dependency/>
73
                    <run-dependency>
74
                        <release-version>1</release-version>
75
                        <specification-version>1.51</specification-version>
76
                    </run-dependency>
77
                </dependency>
78
                <dependency>
70
                    <code-name-base>org.netbeans.modules.spellchecker.apimodule</code-name-base>
79
                    <code-name-base>org.netbeans.modules.spellchecker.apimodule</code-name-base>
71
                    <build-prerequisite/>
80
                    <build-prerequisite/>
72
                    <compile-dependency/>
81
                    <compile-dependency/>
(-)a/spellchecker.bindings.java/src/org/netbeans/modules/spellchecker/bindings/java/JavaSemanticTokenList.java (-1 / +2 lines)
Lines 60-65 Link Here
60
import org.netbeans.api.java.source.JavaSource.Phase;
60
import org.netbeans.api.java.source.JavaSource.Phase;
61
import org.netbeans.api.java.source.JavaSource.Priority;
61
import org.netbeans.api.java.source.JavaSource.Priority;
62
import org.netbeans.api.java.source.support.EditorAwareJavaSourceTaskFactory;
62
import org.netbeans.api.java.source.support.EditorAwareJavaSourceTaskFactory;
63
import org.netbeans.modules.parsing.spi.TaskIndexingMode;
63
import org.netbeans.modules.spellchecker.spi.language.TokenList;
64
import org.netbeans.modules.spellchecker.spi.language.TokenList;
64
import org.openide.filesystems.FileObject;
65
import org.openide.filesystems.FileObject;
65
import org.openide.util.ChangeSupport;
66
import org.openide.util.ChangeSupport;
Lines 273-279 Link Here
273
    public static final class FactoryImpl extends EditorAwareJavaSourceTaskFactory {
274
    public static final class FactoryImpl extends EditorAwareJavaSourceTaskFactory {
274
275
275
        public FactoryImpl() {
276
        public FactoryImpl() {
276
            super(Phase.PARSED, Priority.LOW);
277
            super(Phase.PARSED, Priority.LOW, TaskIndexingMode.ALLOWED_DURING_SCAN);
277
        }
278
        }
278
279
279
        @Override
280
        @Override

Return to bug 207459