Search in sources :

Example 16 with CancelIndicator

use of org.eclipse.xtext.util.CancelIndicator in project xtext-core by eclipse.

the class IncrementalBuilder method build.

public IncrementalBuilder.Result build(final BuildRequest request, final Function1<? super URI, ? extends IResourceServiceProvider> languages, final IResourceClusteringPolicy clusteringPolicy) {
    try {
        final XtextResourceSet resourceSet = request.getResourceSet();
        ResourceDescriptionsData _copy = request.getState().getResourceDescriptions().copy();
        Source2GeneratedMapping _copy_1 = request.getState().getFileMappings().copy();
        final IndexState oldState = new IndexState(_copy, _copy_1);
        CancelIndicator _cancelIndicator = request.getCancelIndicator();
        final BuildContext context = new BuildContext(languages, resourceSet, oldState, clusteringPolicy, _cancelIndicator);
        final IncrementalBuilder.InternalStatefulIncrementalBuilder builder = this.provider.get();
        builder.context = context;
        builder.request = request;
        try {
            return builder.launch();
        } catch (final Throwable _t) {
            if (_t instanceof Throwable) {
                final Throwable t = (Throwable) _t;
                this._operationCanceledManager.propagateIfCancelException(t);
                throw t;
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) BuildContext(org.eclipse.xtext.build.BuildContext) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Source2GeneratedMapping(org.eclipse.xtext.build.Source2GeneratedMapping) CancelIndicator(org.eclipse.xtext.util.CancelIndicator) IndexState(org.eclipse.xtext.build.IndexState)

Example 17 with CancelIndicator

use of org.eclipse.xtext.util.CancelIndicator in project xtext-core by eclipse.

the class OutdatedStateManager method newCancelIndicator.

/**
 * Created a fresh CancelIndicator
 */
public CancelIndicator newCancelIndicator(final ResourceSet rs) {
    CancelIndicator _xifexpression = null;
    if ((rs instanceof XtextResourceSet)) {
        final boolean cancelationAllowed = (this.cancelationAllowed.get()).booleanValue();
        final int current = ((XtextResourceSet) rs).getModificationStamp();
        final CancelIndicator _function = () -> {
            return (cancelationAllowed && (((XtextResourceSet) rs).isOutdated() || (current != ((XtextResourceSet) rs).getModificationStamp())));
        };
        return _function;
    } else {
        _xifexpression = CancelIndicator.NullImpl;
    }
    return _xifexpression;
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) CancelIndicator(org.eclipse.xtext.util.CancelIndicator)

Example 18 with CancelIndicator

use of org.eclipse.xtext.util.CancelIndicator in project xtext-core by eclipse.

the class NamesAreUniqueValidator method checkUniqueNamesInResourceOf.

@Check
public void checkUniqueNamesInResourceOf(EObject eObject) {
    Map<Object, Object> context = getContext();
    Resource resource = eObject.eResource();
    if (resource == null)
        return;
    CancelIndicator cancelIndicator = null;
    if (context != null) {
        if (context.containsKey(resource))
            // resource was already validated
            return;
        context.put(resource, this);
        cancelIndicator = (CancelIndicator) context.get(CancelableDiagnostician.CANCEL_INDICATOR);
    }
    doCheckUniqueNames(resource, cancelIndicator);
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) EObject(org.eclipse.emf.ecore.EObject) CancelIndicator(org.eclipse.xtext.util.CancelIndicator)

Aggregations

CancelIndicator (org.eclipse.xtext.util.CancelIndicator)18 URI (org.eclipse.emf.common.util.URI)5 List (java.util.List)4 EObject (org.eclipse.emf.ecore.EObject)4 XtextResource (org.eclipse.xtext.resource.XtextResource)4 BuildManager (org.eclipse.xtext.ide.server.BuildManager)3 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)3 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 IFile (org.eclipse.core.resources.IFile)2 CompletionList (org.eclipse.lsp4j.CompletionList)2 ICodeLensResolver (org.eclipse.xtext.ide.server.codelens.ICodeLensResolver)2 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)2 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)2 Function2 (org.eclipse.xtext.xbase.lib.Functions.Function2)2 Binder (com.google.inject.Binder)1 AnnotatedBindingBuilder (com.google.inject.binder.AnnotatedBindingBuilder)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1