コード例 #1
0
ファイル: DCLBuilder.java プロジェクト: joyeliz/DCL
 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));
 }
コード例 #2
0
ファイル: DCLBuilder.java プロジェクト: joyeliz/DCL
  private void check(IResource resource, Architecture architecture, boolean reextractDependencies)
      throws CoreException {
    if (resource instanceof IFile && resource.getName().endsWith(".java")) {
      final IFile file = (IFile) resource;
      MarkerUtils.deleteMarkers(file);

      final ICompilationUnit unit = ((ICompilationUnit) JavaCore.create((IFile) resource));

      /* We only consider the units linked to source-folders */
      if (!unit.isOpen()) {
        return;
      }

      final String className = DCLUtil.getClassName(unit);

      /* We only consider the units without compilation errors*/
      if (file.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)
          == IMarker.SEVERITY_ERROR) {
        // MarkerUtils.addErrorMarker(this.getProject(), "DCLcheck has not verified class " +
        // className + " because it contains compilation errors.");
        return;
      }

      try {
        final Collection<Dependency> dependencies;
        if (reextractDependencies) {
          dependencies = DCLUtil.getDependenciesUsingAST(unit);
          architecture.updateDependencies(className, dependencies);
          DCLPersistence.persist(this.getProject(), className, dependencies);
        } else {
          dependencies = architecture.getDependencies(className);
        }

        for (DependencyConstraint dc : architecture.getDependencyConstraints()) {
          Collection<ArchitecturalDrift> result =
              dc.validate(
                  className,
                  architecture.getModules(),
                  architecture.getProjectClasses(),
                  dependencies,
                  this.getProject());
          if (result != null && !result.isEmpty()) {
            for (ArchitecturalDrift ad : result) {
              MarkerUtils.addMarker(file, ad);
            }
          }
        }
      } catch (Exception e) {
        MarkerUtils.addErrorMarker(
            this.getProject(), "There was a problem in extracting dependencies from " + className);
        CoreException ce = new CoreException(Status.CANCEL_STATUS);
        ce.setStackTrace(e.getStackTrace());
        throw ce;
      }
    }
  }
コード例 #3
0
ファイル: DCLBuilder.java プロジェクト: joyeliz/DCL
  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);
    }
  }
コード例 #4
0
ファイル: DCLBuilder.java プロジェクト: joyeliz/DCL
  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));
    }
  }