1 19 20 package org.netbeans.api.java.source; 21 22 import com.sun.source.tree.CompilationUnitTree; 23 import com.sun.source.util.Trees; 24 import com.sun.tools.javac.api.JavacTaskImpl; 25 import java.io.IOException ; 26 import java.util.List ; 27 import javax.lang.model.util.Elements; 28 import javax.lang.model.util.Types; 29 import javax.swing.text.Document ; 30 import javax.tools.Diagnostic; 31 import org.netbeans.api.lexer.TokenHierarchy; 32 import static org.netbeans.api.java.source.JavaSource.Phase.*; 33 import org.openide.filesystems.FileObject; 34 35 43 public class CompilationController extends CompilationInfo { 44 45 final CompilationInfo delegate; 47 48 CompilationController(final CompilationInfo delegate) throws IOException { 49 super(); 50 assert delegate != null; 51 this.delegate = delegate; 52 } 53 54 56 69 public JavaSource.Phase toPhase(JavaSource.Phase phase ) throws IOException { 70 if (phase == MODIFIED) { 71 throw new IllegalArgumentException ( "Wrong phase" + phase ); 72 } 73 if (delegate.jfo == null) { 74 JavaSource.Phase currentPhase = delegate.getPhase(); 75 if (currentPhase.compareTo(phase)<0) { 76 delegate.setPhase(phase); 77 } 78 return delegate.getPhase(); 79 } 80 else { 81 JavaSource.Phase currentPhase = JavaSource.moveToPhase(phase, this.delegate,false); 82 return currentPhase.compareTo (phase) < 0 ? currentPhase : phase; 83 } 84 } 85 86 91 @Override 92 public JavaSource.Phase getPhase() { 93 return this.delegate.getPhase(); 94 } 95 96 104 @Override 105 public CompilationUnitTree getCompilationUnit() { 106 return this.delegate.getCompilationUnit(); 107 } 108 109 114 @Override 115 public String getText() { 116 return this.delegate.getText(); 117 } 118 119 120 @Override 121 public TokenHierarchy getTokenHierarchy() { 122 return this.delegate.getTokenHierarchy(); 123 } 124 125 130 @Override 131 public List <Diagnostic> getDiagnostics() { 132 return this.delegate.getDiagnostics(); 133 } 134 135 @Override 136 public Trees getTrees() { 137 return this.delegate.getTrees(); 138 } 139 140 @Override 141 public Types getTypes() { 142 return this.delegate.getTypes(); 143 } 144 145 @Override 146 public Elements getElements() { 147 return this.delegate.getElements(); 148 } 149 150 @Override 151 public JavaSource getJavaSource() { 152 return this.delegate.getJavaSource(); 153 } 154 155 @Override 156 public ClasspathInfo getClasspathInfo() { 157 return this.delegate.getClasspathInfo(); 158 } 159 160 @Override 161 public FileObject getFileObject() { 162 return this.delegate.getFileObject(); 163 } 164 165 @Override 166 public Document getDocument() throws IOException { 167 return this.delegate.getDocument(); 168 } 169 170 @Override 171 public synchronized TreeUtilities getTreeUtilities() { 172 return this.delegate.getTreeUtilities(); 173 } 174 175 @Override 176 public synchronized ElementUtilities getElementUtilities() { 177 return this.delegate.getElementUtilities(); 178 } 179 180 @Override 181 public synchronized CommentUtilities getCommentUtilities() { 182 return this.delegate.getCommentUtilities(); 183 } 184 185 187 @Override 188 void setPhase(final JavaSource.Phase phase) { 189 throw new UnsupportedOperationException ("CompilationController supports only read interface"); } 191 192 @Override 193 void setCompilationUnit(final CompilationUnitTree compilationUnit) { 194 throw new UnsupportedOperationException ("CompilationController supports only read interface"); } 196 197 @Override 198 JavacTaskImpl getJavacTask() { 199 return this.delegate.getJavacTask(); 200 } 201 } 202 | Popular Tags |