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

(-)apichanges.xml (-1 / +15 lines)
Lines 82-88 Link Here
82
    <!-- ACTUAL CHANGES BEGIN HERE: -->
82
    <!-- ACTUAL CHANGES BEGIN HERE: -->
83
83
84
    <changes>
84
    <changes>
85
        
85
        <change id="JavaSource-Task">
86
            <api name="general"/>
87
            <summary>CancellableTask split into Task and CancellableTask.</summary>
88
            <version major="0" minor="17"/>
89
            <date day="13" month="6" year="2007"/>
90
            <author login="tzezula"/>
91
            <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="no" semantic="compatible" source="compatible"/>
92
            <description>
93
                The JavaSource.runModificationTask(), runWhenScanFinished() and runUserActionTask() never call the cancel method of the
94
                CancellableTask, the implementor of such a CancellableTask just writes an empty cancel method. The compatible API
95
                change splits the CancellableTask into Task with run method and CancellableTask which extends the Task by cancel method.
96
                The JavaSource methods mentioned above take Task rather than CancellableTask. The CancellableTask is used only for tasks
97
                registered by factories.
98
            </description>
99
        </change>
86
        <change id="CompilationInfo-getTopLevelElements">
100
        <change id="CompilationInfo-getTopLevelElements">
87
            <api name="general"/>
101
            <api name="general"/>
88
            <summary>Added a method to obtain top level elements defined in the source/class file.</summary>
102
            <summary>Added a method to obtain top level elements defined in the source/class file.</summary>
(-)nbproject/project.properties (-1 / +1 lines)
Lines 21-25 Link Here
21
javadoc.title=Java Source
21
javadoc.title=Java Source
22
javadoc.arch=${basedir}/arch.xml
22
javadoc.arch=${basedir}/arch.xml
23
javadoc.apichanges=${basedir}/apichanges.xml
23
javadoc.apichanges=${basedir}/apichanges.xml
24
spec.version.base=0.15.0
24
spec.version.base=0.17.0
25
test.unit.run.cp.extra=${core.dir}/core/core.jar:${core.dir}/lib/boot.jar:../../junit/external/insanelib.jar
25
test.unit.run.cp.extra=${core.dir}/core/core.jar:${core.dir}/lib/boot.jar:../../junit/external/insanelib.jar
(-)src/org/netbeans/api/java/source/CancellableTask.java (-9 / +2 lines)
Lines 23-39 Link Here
23
 *
23
 *
24
 * @author Petr Hrebejk
24
 * @author Petr Hrebejk
25
 */
25
 */
26
public interface CancellableTask<P> {
26
public interface CancellableTask<P> extends Task<P>{
27
27
28
    /** After this method is called the task if running should exit the run
28
    /** After this method is called the task if running should exit the run
29
     * method immediately.
29
     * method immediately.
30
     */
30
     */
31
    public void cancel();
31
    public void cancel();    
32
33
34
    /** Implement the functionality here.
35
     *@param parameter Parameter depending on the context or null.
36
     */
37
    public void run( P parameter ) throws Exception;
38
39
}
32
}
(-)src/org/netbeans/api/java/source/JavaSource.java (-8 / +8 lines)
Lines 477-483 Link Here
477
     * </p>
477
     * </p>
478
     * </div>
478
     * </div>
479
     */
479
     */
480
    public void runUserActionTask( final CancellableTask<CompilationController> task, final boolean shared) throws IOException {
480
    public void runUserActionTask( final Task<CompilationController> task, final boolean shared) throws IOException {
481
        if (task == null) {
481
        if (task == null) {
482
            throw new IllegalArgumentException ("Task cannot be null");     //NOI18N
482
            throw new IllegalArgumentException ("Task cannot be null");     //NOI18N
483
        }
483
        }
Lines 632-638 Link Here
632
     * @throws IOException encapsulating the exception thrown by {@link CancellableTasks#run}
632
     * @throws IOException encapsulating the exception thrown by {@link CancellableTasks#run}
633
     * @since 0.12
633
     * @since 0.12
634
     */
634
     */
635
    public Future<Void> runWhenScanFinished (final CancellableTask<CompilationController> task, final boolean shared) throws IOException {
635
    public Future<Void> runWhenScanFinished (final Task<CompilationController> task, final boolean shared) throws IOException {
636
        assert task != null;
636
        assert task != null;
637
        final ScanSync sync = new ScanSync (task);
637
        final ScanSync sync = new ScanSync (task);
638
        final DeferredTask r = new DeferredTask (this,task,shared,sync);
638
        final DeferredTask r = new DeferredTask (this,task,shared,sync);
Lines 697-706 Link Here
697
    /** Runs a task which permits for modifying the sources.
697
    /** Runs a task which permits for modifying the sources.
698
     * Call to this method will cancel processig of all the phase completion tasks until
698
     * Call to this method will cancel processig of all the phase completion tasks until
699
     * this task does not finish.<BR>
699
     * this task does not finish.<BR>
700
     * @see CancellableTask for information about implementation requirements
700
     * @see Task for information about implementation requirements
701
     * @param task The task which.
701
     * @param task The task which.
702
     */    
702
     */    
703
    public ModificationResult runModificationTask(CancellableTask<WorkingCopy> task) throws IOException {        
703
    public ModificationResult runModificationTask(Task<WorkingCopy> task) throws IOException {        
704
        if (task == null) {
704
        if (task == null) {
705
            throw new IllegalArgumentException ("Task cannot be null");     //NOI18N
705
            throw new IllegalArgumentException ("Task cannot be null");     //NOI18N
706
        }
706
        }
Lines 1984-1994 Link Here
1984
    
1984
    
1985
    static final class ScanSync implements Future<Void> {
1985
    static final class ScanSync implements Future<Void> {
1986
        
1986
        
1987
        private CancellableTask<CompilationController> task;
1987
        private Task<CompilationController> task;
1988
        private final CountDownLatch sync;
1988
        private final CountDownLatch sync;
1989
        private final AtomicBoolean canceled;
1989
        private final AtomicBoolean canceled;
1990
        
1990
        
1991
        public ScanSync (final CancellableTask<CompilationController> task) {
1991
        public ScanSync (final Task<CompilationController> task) {
1992
            assert task != null;
1992
            assert task != null;
1993
            this.task = task;
1993
            this.task = task;
1994
            this.sync = new CountDownLatch (1);
1994
            this.sync = new CountDownLatch (1);
Lines 2039-2049 Link Here
2039
    
2039
    
2040
    static final class DeferredTask {
2040
    static final class DeferredTask {
2041
        final JavaSource js;
2041
        final JavaSource js;
2042
        final CancellableTask<CompilationController> task;
2042
        final Task<CompilationController> task;
2043
        final boolean shared;
2043
        final boolean shared;
2044
        final ScanSync sync;
2044
        final ScanSync sync;
2045
        
2045
        
2046
        public DeferredTask (final JavaSource js, final CancellableTask<CompilationController> task, final boolean shared, final ScanSync sync) {
2046
        public DeferredTask (final JavaSource js, final Task<CompilationController> task, final boolean shared, final ScanSync sync) {
2047
            assert js != null;
2047
            assert js != null;
2048
            assert task != null;
2048
            assert task != null;
2049
            assert sync != null;
2049
            assert sync != null;
(-)src/org/netbeans/api/java/source/Task.java (+33 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
package org.netbeans.api.java.source;
20
21
/**
22
 * Runnable which takes parameter of a given type.
23
 * @author Petr Hrebejk, Tomas Zezula
24
 * @since 0.17
25
 */
26
public interface Task<P> {
27
28
    /** Implement the functionality here.
29
     *@param parameter Parameter depending on the context or null.
30
     */
31
    public void run( P parameter ) throws Exception;
32
33
}

Return to bug 106549