1 19 20 package org.netbeans.api.retouche.source; 21 22 import java.util.Map ; 23 import org.netbeans.api.gsf.OffsetRange; 24 import org.netbeans.api.gsf.Parser; 25 import org.netbeans.api.gsf.ParserResult; 26 import org.netbeans.api.gsf.ColoringAttributes; 27 import org.netbeans.api.retouche.source.CompilationUnitTree; 28 import org.netbeans.api.retouche.source.ParserTaskImpl; 29 import java.io.IOException ; 30 import java.util.List ; 31 import javax.swing.text.Document ; 32 import org.netbeans.api.gsf.Error; 33 import org.netbeans.api.gsf.Index; 34 import org.netbeans.api.gsf.PositionManager; 35 import org.netbeans.api.retouche.source.Phase; 36 import org.netbeans.modules.gsf.Language; 37 import org.openide.filesystems.FileObject; 38 import static org.netbeans.api.retouche.source.Phase.*; 39 40 54 public class CompilationController extends CompilationInfo { 55 56 final CompilationInfo delegate; 58 59 CompilationController(final CompilationInfo delegate) throws IOException { 60 super(); 61 assert delegate != null; 62 this.delegate = delegate; 63 } 64 65 67 82 public Phase toPhase(Phase phase ) throws IOException { 83 if (phase == MODIFIED) { 84 throw new IllegalArgumentException ( "Wrong phase" + phase ); 85 } 86 if (delegate.jfo == null) { 87 Phase currentPhase = delegate.getPhase(); 88 if (currentPhase.compareTo(phase)<0) { 89 delegate.setPhase(phase); 90 } 91 return delegate.getPhase(); 92 } 93 else { 94 Phase currentPhase = Source.moveToPhase(phase, this.delegate,false); 95 return currentPhase.compareTo (phase) < 0 ? currentPhase : phase; 96 } 97 } 98 99 105 @Override 106 public Phase getPhase() { 107 return this.delegate.getPhase(); 108 } 109 110 116 @Override 117 public CompilationUnitTree getCompilationUnit() { 118 return this.delegate.getCompilationUnit(); 119 } 120 121 @Override 122 public ParserResult getParserResult() { 123 return this.delegate.getParserResult(); 124 } 125 131 @Override 132 public String getText() { 133 return this.delegate.getText(); 134 } 135 136 137 142 148 @Override 149 public List <Error > getDiagnostics() { 150 return this.delegate.getDiagnostics(); 151 } 152 153 168 @Override 169 public Source getSource() { 170 return this.delegate.getSource(); 171 } 172 173 @Override 174 public ClasspathInfo getClasspathInfo() { 175 return this.delegate.getClasspathInfo(); 176 } 177 178 @Override 179 public FileObject getFileObject() { 180 return this.delegate.getFileObject(); 181 } 182 183 @Override 184 public PositionManager getPositionManager() { 185 return this.delegate.getPositionManager(); 186 } 187 188 @Override 189 public Parser getParser() { 190 return this.delegate.getParser(); 191 } 192 193 @Override 194 public Document getDocument() throws IOException { 195 return this.delegate.getDocument(); 196 } 197 198 200 @Override 201 void setPhase(final Phase phase) { 202 throw new UnsupportedOperationException ("CompilationController supports only read interface"); } 204 205 @Override 206 void setCompilationUnit(final CompilationUnitTree compilationUnit) { 207 throw new UnsupportedOperationException ("CompilationController supports only read interface"); } 209 210 @Override 211 public void setParserResult(final ParserResult parserResult) { 212 throw new UnsupportedOperationException ("CompilationController supports only read interface"); } 214 215 @Override 216 public void setPositionManager(final PositionManager positions) { 217 throw new UnsupportedOperationException ("CompilationController supports only read interface"); } 219 220 @Override 221 public void setParser(final Parser parser) { 222 throw new UnsupportedOperationException ("CompilationController supports only read interface"); } 224 225 @Override 226 public void setLanguage(final Language language) { 227 throw new UnsupportedOperationException ("CompilationController supports only read interface"); } 229 230 @Override 231 public Language getLanguage() { 232 return this.delegate.getLanguage(); 233 } 234 235 @Override 236 ParserTaskImpl getParserTask() { 237 return this.delegate.getParserTask(); 238 } 239 240 @Override 241 public Index getIndex() { 242 return this.delegate.getIndex(); 243 } 244 } 245 | Popular Tags |