Changeset 3784
- Timestamp:
- May 25, 2008, 12:30:18 AM (13 years ago)
- Location:
- devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core/RfpAbstractBuilder.java
r3783 r3784 53 53 } 54 54 55 pr ivatevoid compileModules (final SortedSet<String> modulesToRecompile, IProgressMonitor monitor)55 protected void compileModules (final SortedSet<String> modulesToRecompile, IProgressMonitor monitor) 56 56 throws CoreException { 57 57 IWorkspace workspace = ResourcesPlugin.getWorkspace(); -
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/core/RfpBuilder.java
r3783 r3784 7 7 import java.util.Arrays; 8 8 import java.util.HashMap; 9 import java.util.Map;10 9 import java.util.Set; 11 10 import java.util.SortedMap; … … 23 22 import org.eclipse.core.resources.IResourceDeltaVisitor; 24 23 import org.eclipse.core.resources.IResourceVisitor; 25 import org.eclipse.core.resources.IWorkspace;26 import org.eclipse.core.resources.IWorkspaceRunnable;27 import org.eclipse.core.resources.IncrementalProjectBuilder;28 import org.eclipse.core.resources.ResourcesPlugin;29 24 import org.eclipse.core.runtime.CoreException; 30 25 import org.eclipse.core.runtime.IPath; 31 26 import org.eclipse.core.runtime.IProgressMonitor; 32 import org.eclipse.core.runtime.OperationCanceledException;33 27 import org.eclipse.core.runtime.QualifiedName; 34 28 import org.eclipse.jdt.core.IClasspathContainer; … … 51 45 import org.refal.rfpdt.compiler.SrcPosition; 52 46 53 public class RfpBuilder extends IncrementalProjectBuilder { 54 private RfpProject getRfpProject () { 55 return RfpCore.getRfpProject(getProject()); 56 } 57 47 public class RfpBuilder extends RfpAbstractBuilder { 58 48 private void deleteClassFiles (IFile file) { 59 49 RfpProject rfpProject = getRfpProject(); … … 265 255 } 266 256 267 /* 268 * (non-Javadoc) 269 * 270 * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, 271 * org.eclipse.core.runtime.IProgressMonitor) 272 */ 273 @SuppressWarnings("unchecked") 257 private static void deleteMarkers (IFile file) { 258 try { 259 file.deleteMarkers(RfpCore.MARKER_ID, false, IResource.DEPTH_ZERO); 260 } catch (CoreException e) { 261 RfpCore.log(e); 262 } 263 } 264 274 265 @Override 275 protected IProject[] build (int kind, Map args, IProgressMonitor monitor) throws CoreException { 276 if (kind == FULL_BUILD) 277 fullBuild(monitor); 278 else { 279 RfpProject rfpProject = getRfpProject(); 280 IResourceDelta delta = getDelta(rfpProject.getProject()); 281 if (delta == null || delta.findMember(rfpProject.getFile(".classpath").getProjectRelativePath()) != null) 282 fullBuild(monitor); 283 else 284 incrementalBuild(delta, monitor); 285 } 286 return null; 287 } 288 289 @SuppressWarnings("unchecked") 290 private void checkAndCompileModuleImplem (IResource resource) { 291 if (!RfpProject.isRfFile(resource)) 266 protected void checkAndCompileModuleImplem (String moduleName) { 267 IFile file = getRfpProject().getSource(moduleName, "rf"); 268 if (!RfpProject.isRfFile(file)) 292 269 return; 293 IFile file = (IFile) resource;294 270 deleteMarkers(file); 295 271 CompilerEnvironment environment = new IdeCompilerEnvironment(getRfpProject(), file); … … 324 300 } 325 301 326 private boolean checkCancel (IProgressMonitor monitor) { 327 if (monitor.isCanceled()) 328 // Discard build state if necessary 329 throw new OperationCanceledException(); 330 331 // if (isInterrupted()) { // FIXME: should cancel current job 332 // and rescedule auto-builds. 333 // return true; 334 // } 335 return false; 302 private SortedSet<String> getNamesOfImportedModules (IFile file) { 303 SortedSet<String> moduleNameSet = new TreeSet<String>(); 304 try { 305 String asString = file.getPersistentProperty(IMPORTED_MODULES_PROPKEY); 306 if (asString == null) 307 return moduleNameSet; 308 moduleNameSet.addAll(Arrays.asList(asString.split(","))); 309 } catch (CoreException e) {} 310 return moduleNameSet; 336 311 } 337 312 … … 363 338 } 364 339 365 private void compileEachModule (SortedSet<String> modulesToRecompile, IProgressMonitor monitor) { 366 monitor.beginTask("Recompile modules", modulesToRecompile.size()); 367 for (String moduleName : modulesToRecompile) { 368 if (checkCancel(monitor)) 369 return; 370 monitor.subTask("Compiling the module " + moduleName); 371 checkAndCompileModuleImplem(getRfpProject().getSource(moduleName, "rf")); 372 // try { 373 // Thread.sleep(1000); 374 // } catch (InterruptedException e) { 375 // } 376 monitor.worked(1); 377 } 378 monitor.done(); 379 } 380 381 private void compileModules (final SortedSet<String> modulesToRecompile, IProgressMonitor monitor) 382 throws CoreException { 383 // workspace.run(action, workspace.getRoot(), IWorkspace.AVOID_UPDATE, monitor); 384 IWorkspace workspace = ResourcesPlugin.getWorkspace(); 385 workspace.run(new IWorkspaceRunnable() { 386 public void run (IProgressMonitor monitor) throws CoreException { 387 compileEachModule(modulesToRecompile, monitor); 388 } 389 }, workspace.getRoot(), 0, monitor); 390 } 391 392 private static void deleteMarkers (IFile file) { 393 try { 394 file.deleteMarkers(RfpCore.MARKER_ID, false, IResource.DEPTH_ZERO); 395 } catch (CoreException e) { 396 RfpCore.log(e); 397 } 398 } 399 400 private void fullBuild (final IProgressMonitor monitor) throws CoreException { 401 final SortedSet<String> modulesToRecompile = new TreeSet<String>(); 402 final RfpProject rfpProject = getRfpProject(); 403 try { 404 getProject().accept(new IResourceVisitor() { 405 public boolean visit (IResource resource) throws CoreException { 406 if (RfpProject.isRfFile(resource)) { 407 String moduleName = rfpProject.getModuleName((IFile) resource); 408 if (moduleName != null) 409 modulesToRecompile.add(moduleName); 410 } 411 return true; 412 } 413 }); 414 compileModules(modulesToRecompile, monitor); 415 } catch (CoreException e) { 416 RfpCore.log(e); 417 } 418 } 419 420 private SortedSet<String> getNamesOfImportedModules (IFile file) { 421 SortedSet<String> moduleNameSet = new TreeSet<String>(); 422 try { 423 String asString = file.getPersistentProperty(IMPORTED_MODULES_PROPKEY); 424 if (asString == null) 425 return moduleNameSet; 426 moduleNameSet.addAll(Arrays.asList(asString.split(","))); 427 } catch (CoreException e) {} 428 return moduleNameSet; 429 } 430 431 private void incrementalBuild (IResourceDelta delta, IProgressMonitor monitor) throws CoreException { 340 @Override 341 protected void incrementalBuild (IResourceDelta delta, IProgressMonitor monitor) throws CoreException { 432 342 final SortedSet<String> modulesToRecompile = new TreeSet<String>(); 433 343 final SortedMap<String, SortedSet<String>> dependencies = collectDependencies(); … … 457 367 } 458 368 }); 459 } catch (CoreException e) {} 369 } catch (CoreException e) { 370 RfpCore.log(e); 371 } 460 372 compileModules(modulesToRecompile, monitor); 461 373 }
Note: See TracChangeset
for help on using the changeset viewer.