KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > retouche > source > SourceAccessor


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.retouche.source;
21
22 import java.io.IOException JavaDoc;
23 import org.netbeans.api.retouche.source.ParserTaskImpl;
24 import org.netbeans.api.gsf.CancellableTask;
25 import org.netbeans.api.retouche.source.ClasspathInfo;
26 import org.netbeans.api.retouche.source.CompilationInfo;
27 import org.netbeans.api.retouche.source.Phase;
28 import org.netbeans.api.retouche.source.Source;
29 import org.netbeans.modules.gsf.Language;
30 import org.netbeans.modules.retouche.source.parsing.SourceFileObject;
31 import org.openide.ErrorManager;
32
33 /**
34  * This class is based on JavaSourceAccessor in Retouche
35  * This file is originally from Retouche, the Java Support
36  * infrastructure in NetBeans. I have modified the file as little
37  * as possible to make merging Retouche fixes back as simple as
38  * possible.
39  *
40  *
41  * @author tom
42  */

43 public abstract class SourceAccessor {
44
45     
46     static {
47         try {
48             Class.forName("org.netbeans.api.retouche.source.Source", true, SourceAccessor.class.getClassLoader()); //NOI18N
49
} catch (ClassNotFoundException JavaDoc e) {
50             ErrorManager.getDefault().notify (e);
51         }
52     }
53     
54     public static SourceAccessor INSTANCE;
55     
56     
57     public void runSpecialTask (final CancellableTask<CompilationInfo> task, final Source.Priority priority) {
58         INSTANCE.runSpecialTaskImpl (task, priority);
59     }
60     
61     protected abstract void runSpecialTaskImpl (CancellableTask<CompilationInfo> task, Source.Priority priority);
62         
63     public abstract ParserTaskImpl createParserTask(Language language, ClasspathInfo cpInfo,/* DiagnosticListener<? super SourceFileObject> diagnosticListener,*/ String JavaDoc sourceLevel);
64     
65     
66 // /**
67
// * Returns the JavacTaskImpl associated with given {@link CompilationInfo},
68
// * when it's not available it's created.
69
// * @param compilationInfo which {@link JavacTaskImpl} should be obtained.
70
// * @return {@link JavacTaskImpl} never returns null
71
// */
72
public abstract ParserTaskImpl getParserTask (CompilationInfo compilationInfo);
73     
74     /**
75      * Returns a cached compilation info when available or null
76      * @param js {@link JavaSource} which {@CompilationInfo} should be returned
77      * @param phase to which the compilation info should be moved
78      * Can be called only from the dispatch thread!
79      * @return {@link CompilationInfo} or null
80      */

81     public abstract CompilationInfo getCurrentCompilationInfo (Source js, Phase phase) throws IOException JavaDoc;
82     
83     public abstract void revalidate(Source js);
84     
85     
86     /**
87      * Returns true when the caller is a {@link JavaSource} worker thread
88      * @return boolean
89      */

90     public abstract boolean isDispatchThread ();
91     
92 }
93
Popular Tags