@Override @SuppressWarnings("rawtypes") protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { try { if (kind == FULL_BUILD || !DCLPersistence.existsDCLFolder(this.getProject())) { fullBuild(monitor); } else { IResourceDelta delta = getDelta(this.getProject()); if (delta == null) { fullBuild(monitor); } else { /* If the architecture has not been initialized yet */ if (!ArchitectureUtils.hasArchitectureInitialized(getProject())) { fullLoad(monitor); } incrementalBuild(delta, monitor); } } MarkerUtils.deleteErrorMarker(this.getProject()); } catch (ParseException e) { this.clean(monitor); final IFile dcFile = this.getProject().getFile(DCLUtil.DC_FILENAME); MarkerUtils.addErrorMarker( dcFile, "Syntax error on token \"" + e.getBody() + "\"", e.getLineNumber()); } catch (Throwable e) { this.clean(monitor); final String logFileName = DCLUtil.logError(this.getProject(), e); MarkerUtils.addErrorMarker( this.getProject(), "The dclcheck conformance tool has crashed. (see " + logFileName + ")"); } return null; }
protected void fullBuild(final IProgressMonitor monitor) throws CoreException, IOException, ParseException { monitor.setTaskName("Checking architecture"); monitor.subTask("loading dependencies"); final Architecture architecture = ArchitectureUtils.initializeArchitecture(getProject()); monitor.beginTask("Checking architecture", architecture.getProjectClasses().size()); getProject().accept(new FullBuildVisitor(architecture, monitor, true)); }
@Override protected void clean(IProgressMonitor monitor) throws CoreException { super.clean(monitor); DCLPersistence.clean(this.getProject()); MarkerUtils.deleteMarkers(this.getProject()); MarkerUtils.deleteErrorMarker(this.getProject()); ArchitectureUtils.cleanArchitecture(getProject()); }
protected void fullLoad(final IProgressMonitor monitor) throws CoreException, IOException, ClassNotFoundException, ParseException { monitor.setTaskName("Checking architecture"); monitor.subTask("loading dependencies"); final Architecture architecture = ArchitectureUtils.getOrInitializeArchitecture(this.getProject()); monitor.beginTask("Checking architecture", architecture.getProjectClasses().size()); for (String className : architecture.getProjectClasses()) { monitor.subTask(className); Collection<Dependency> dependencies = DCLPersistence.load(this.getProject(), className); if (dependencies == null) { throw new CoreException(null); } architecture.updateDependencies(className, dependencies); monitor.worked(1); } }
protected void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) throws CoreException, IOException, ParseException { final Architecture architecture = ArchitectureUtils.getOrInitializeArchitecture(getProject()); final boolean updateDC = (delta.findMember(new Path(DCLUtil.DC_FILENAME)) != null); if (updateDC) { architecture.updateDependencyConstraints(this.getProject()); } monitor.beginTask( "Checking architecture", delta.getAffectedChildren( IResourceDelta.ADDED | IResourceDelta.CHANGED | IResourceDelta.REMOVED, IResource.FILE) .length); delta.accept(new IncrementalDeltaVisitor(architecture, monitor)); /* For now, any change in the DCL File requires full build */ if (updateDC) { getProject().accept(new FullBuildVisitor(architecture, monitor, false)); } }