@Override
 public void linkModel(EObject model, IDiagnosticConsumer diagnosticsConsumer) {
   StoppedTask task = Stopwatches.forTask("installing proxies (AbstractCleaningLinker.linkModel)");
   task.start();
   boolean debug = log.isDebugEnabled();
   long time = System.currentTimeMillis();
   beforeModelLinked(model, diagnosticsConsumer);
   if (debug) {
     long now = System.currentTimeMillis();
     log.debug("beforeModelLinked took: " + (now - time) + "ms");
     time = now;
   }
   doLinkModel(model, diagnosticsConsumer);
   if (debug) {
     long now = System.currentTimeMillis();
     log.debug("doLinkModel took: " + (now - time) + "ms");
     time = now;
   }
   afterModelLinked(model, diagnosticsConsumer);
   if (debug) {
     long now = System.currentTimeMillis();
     log.debug("afterModelLinked took: " + (now - time) + "ms");
     time = now;
   }
   task.stop();
 }
Beispiel #2
0
  @Override
  public void build(final IBuildContext context, IProgressMonitor monitor) throws CoreException {
    if (!isEnabled(context)) {
      return;
    }

    final List<IResourceDescription.Delta> deltas = getRelevantDeltas(context);
    if (deltas.isEmpty()) {
      return;
    }

    StoppedTask task =
        Stopwatches.forTask(
            "org.eclipse.xtext.builder.BuilderParticipant.build(IBuildContext, IProgressMonitor)");
    try {
      task.start();

      // monitor handling
      if (monitor.isCanceled()) throw new OperationCanceledException();
      SubMonitor subMonitor =
          SubMonitor.convert(monitor, context.getBuildType() == BuildType.RECOVERY ? 5 : 3);

      EclipseResourceFileSystemAccess2 access = fileSystemAccessProvider.get();
      IProject builtProject = context.getBuiltProject();
      access.setProject(builtProject);
      Map<String, OutputConfiguration> outputConfigurations = getOutputConfigurations(context);
      refreshOutputFolders(context, outputConfigurations, subMonitor.newChild(1));
      if (subMonitor.isCanceled()) {
        throw new OperationCanceledException();
      }
      access.setOutputConfigurations(outputConfigurations);
      if (context.getBuildType() == BuildType.CLEAN
          || context.getBuildType() == BuildType.RECOVERY) {
        SubMonitor cleanMonitor =
            SubMonitor.convert(subMonitor.newChild(2), outputConfigurations.size());
        for (OutputConfiguration config : outputConfigurations.values()) {
          cleanOutput(context, config, access, cleanMonitor.newChild(1));
        }
        if (context.getBuildType() == BuildType.CLEAN) return;
      }
      Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers =
          getGeneratorMarkers(builtProject, outputConfigurations.values());
      if (subMonitor.isCanceled()) {
        throw new OperationCanceledException();
      }
      doBuild(
          deltas, outputConfigurations, generatorMarkers, context, access, subMonitor.newChild(2));

    } finally {
      task.stop();
    }
  }
Beispiel #3
0
  @SuppressWarnings("rawtypes")
  @Override
  protected IProject[] build(final int kind, Map args, IProgressMonitor monitor)
      throws CoreException {
    if (IBuildFlag.FORGET_BUILD_STATE_ONLY.isSet(args)) {
      forgetLastBuiltState();
      return getProject().getReferencedProjects();
    }
    Job.getJobManager().addJobChangeListener(MAKE_EGIT_JOB_SYSTEM);
    long startTime = System.currentTimeMillis();
    StoppedTask task =
        Stopwatches.forTask(String.format("XtextBuilder.build[%s]", getKindAsString(kind)));
    try {
      queuedBuildData.createCheckpoint();
      if (shouldCancelBuild(kind)) {
        throw new OperationCanceledException("Build has been interrupted");
      }
      task.start();
      if (monitor != null) {
        final String taskName =
            Messages.XtextBuilder_Building + getProject().getName() + ": "; // $NON-NLS-1$
        monitor =
            new ProgressMonitorWrapper(monitor) {
              @Override
              public void subTask(String name) {
                super.subTask(taskName + name);
              }

              @Override
              public boolean isCanceled() {
                boolean shouldCancelBuild = shouldCancelBuild(kind);
                if (shouldCancelBuild) buildLogger.log("interrupted");
                return shouldCancelBuild || super.isCanceled();
              }
            };
      }
      SubMonitor progress = SubMonitor.convert(monitor, 1);
      if (kind == FULL_BUILD) {
        fullBuild(progress.newChild(1), IBuildFlag.RECOVERY_BUILD.isSet(args));
      } else {
        IResourceDelta delta = getDelta(getProject());
        if (delta == null || isOpened(delta)) {
          fullBuild(progress.newChild(1), IBuildFlag.RECOVERY_BUILD.isSet(args));
        } else {
          incrementalBuild(delta, progress.newChild(1));
        }
      }
    } catch (CoreException e) {
      log.error(e.getMessage(), e);
      throw e;
    } catch (OperationCanceledException e) {
      handleCanceled(e);
    } catch (OperationCanceledError err) {
      handleCanceled(err);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      buildLogger.log(
          e.getClass().getSimpleName()
              + " while building "
              + getProject().getName()
              + ": "
              + e.getMessage()
              + " (see logs for details)");
      forgetLastBuiltState();
    } finally {
      queuedBuildData.discardCheckpoint();
      if (monitor != null) monitor.done();
      String message =
          "Build "
              + getProject().getName()
              + " in "
              + (System.currentTimeMillis() - startTime)
              + " ms";
      log.info(message);
      buildLogger.log(message);
      task.stop();
      Job.getJobManager().removeJobChangeListener(MAKE_EGIT_JOB_SYSTEM);
    }
    return getProject().getReferencedProjects();
  }