Search in sources :

Example 6 with ClosableMeasurement

use of org.eclipse.n4js.smith.ClosableMeasurement in project n4js by eclipse.

the class N4JSGenerateImmediatelyBuilderState method doUpdate.

/**
 * {@inheritDoc}
 *
 * Initializes an adapter which is attached to the builder's resource set. This adapter will be used later on to
 * process each delta after the corresponding resource was validated.
 *
 * @param buildData
 *            the data that should be considered for the update
 * @param newData
 *            the new resource descriptions as they are to be persisted (the new index after the build). Initially
 *            contains the old resource descriptions.
 * @param monitor
 *            The progress monitor
 * @return A list of deltas describing all changes made by the build.
 */
@Override
protected Collection<Delta> doUpdate(BuildData buildData, ResourceDescriptionsData newData, IProgressMonitor monitor) {
    builderStateLogger.log("N4JSGenerateImmediatelyBuilderState.doUpdate() >>>");
    logBuildData(buildData, " of before #doUpdate");
    IProject project = getProject(buildData);
    try (ClosableMeasurement m = dcBuild.getClosableMeasurement("build " + Instant.now())) {
        BuildType buildType = N4JSBuildTypeTracker.getBuildType(project);
        IBuildParticipantInstruction instruction;
        if (buildType == null) {
            instruction = IBuildParticipantInstruction.NOOP;
        } else {
            instruction = findJSBuilderParticipant().prepareBuild(project, buildType);
        }
        // removed after the build automatically;
        // the resource set is discarded afterwards, anyway
        buildData.getResourceSet().eAdapters().add(instruction);
    } catch (CoreException e) {
        handleCoreException(e);
    }
    Collection<Delta> modifiedDeltas = super.doUpdate(buildData, newData, monitor);
    logBuildData(buildData, " of after #doUpdate");
    builderStateLogger.log("Modified deltas: " + modifiedDeltas);
    builderStateLogger.log("N4JSGenerateImmediatelyBuilderState.doUpdate() <<<");
    return modifiedDeltas;
}
Also used : ClosableMeasurement(org.eclipse.n4js.smith.ClosableMeasurement) IBuildParticipantInstruction(org.eclipse.n4js.ui.building.instructions.IBuildParticipantInstruction) CoreException(org.eclipse.core.runtime.CoreException) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) DefaultResourceDescriptionDelta(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionDelta) BuildType(org.eclipse.xtext.builder.IXtextBuilderParticipant.BuildType) IProject(org.eclipse.core.resources.IProject)

Example 7 with ClosableMeasurement

use of org.eclipse.n4js.smith.ClosableMeasurement in project n4js by eclipse.

the class ManifestAwareResourceValidator method validate.

@Override
public List<Issue> validate(Resource resource, CheckMode mode, CancelIndicator cancelIndicator) {
    try (ClosableMeasurement m = collector.getClosableMeasurement(resource.getURI().toString())) {
        operationCanceledManager.checkCanceled(cancelIndicator);
        if (!isInSourceFolder(resource)) {
            return Collections.emptyList();
        }
        List<Issue> res = super.validate(resource, mode, cancelIndicator);
        return res;
    }
}
Also used : ClosableMeasurement(org.eclipse.n4js.smith.ClosableMeasurement) Issue(org.eclipse.xtext.validation.Issue)

Aggregations

ClosableMeasurement (org.eclipse.n4js.smith.ClosableMeasurement)7 File (java.io.File)1 URI (java.net.URI)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 TreeIterator (org.eclipse.emf.common.util.TreeIterator)1 EObject (org.eclipse.emf.ecore.EObject)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 BadEscapementException (org.eclipse.n4js.conversion.AbstractN4JSStringValueConverter.BadEscapementException)1 N4JSValueConverterException (org.eclipse.n4js.conversion.N4JSValueConverterException)1 N4JSValueConverterWithValueException (org.eclipse.n4js.conversion.N4JSValueConverterWithValueException)1 FlowAnalyser (org.eclipse.n4js.flowgraphs.FlowAnalyser)1 N4JSFlowAnalyser (org.eclipse.n4js.flowgraphs.N4JSFlowAnalyser)1 DirectPathAnalyses (org.eclipse.n4js.flowgraphs.analysis.DirectPathAnalyses)1 GraphVisitorAnalysis (org.eclipse.n4js.flowgraphs.analysis.GraphVisitorAnalysis)1