Java Code Examples for org.eclipse.xtext.util.CancelIndicator#NullImpl

The following examples show how to use org.eclipse.xtext.util.CancelIndicator#NullImpl . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CancelIndicatorUtil.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns a cancel indicator that will report a cancellation, i.e. will return true from
 * {@link CancelIndicator#isCanceled()}, iff at least one of the given indicators reports a cancellation. Might
 * return one of the given indicators.
 */
public static CancelIndicator combine(List<CancelIndicator> cancelIndicators) {
	List<CancelIndicator> actualIndicators = cancelIndicators.stream()
			.filter(ci -> ci != null && ci != CancelIndicator.NullImpl)
			.collect(Collectors.toList());
	if (actualIndicators.isEmpty()) {
		return CancelIndicator.NullImpl;
	} else if (actualIndicators.size() == 1) {
		return actualIndicators.get(0);
	} else {
		return new CombinedCancelIndicator(actualIndicators);
	}
}
 
Example 2
Source File: JavaProjectBasedBuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void handleChangedContents(Delta delta, IBuildContext context, IFileSystemAccess fileSystemAccess) {
	if (!resourceServiceProvider.canHandle(delta.getUri()))
		return;
	Resource resource = context.getResourceSet().getResource(delta.getUri(), true);
	if (shouldGenerate(resource, context)) {
		CancelIndicator cancelIndicator = CancelIndicator.NullImpl;
		if (fileSystemAccess instanceof EclipseResourceFileSystemAccess2) {
			cancelIndicator = new MonitorBasedCancelIndicator(((EclipseResourceFileSystemAccess2) fileSystemAccess).getMonitor());
		}
		GeneratorContext generatorContext = new GeneratorContext();
		generatorContext.setCancelIndicator(cancelIndicator);
		generator.generate(resource, (IFileSystemAccess2) fileSystemAccess, generatorContext);
		context.needRebuild();
	}
}
 
Example 3
Source File: OutdatedStateManager.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Created a fresh CancelIndicator
 */
public CancelIndicator newCancelIndicator(ResourceSet rs) {
	if (rs instanceof XtextResourceSet) {
		boolean isCancelationAllowed = cancelationAllowed.get().booleanValue();
		XtextResourceSet xtextRs = (XtextResourceSet) rs;
		int current = xtextRs.getModificationStamp();
		return () -> isCancelationAllowed && (xtextRs.isOutdated() || current != xtextRs.getModificationStamp());
	} else {
		return CancelIndicator.NullImpl;
	}
}
 
Example 4
Source File: ResourceValidatorImpl.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<Issue> validate(Resource resource, final CheckMode mode, CancelIndicator mon) throws OperationCanceledError {
	StoppedTask task = Stopwatches.forTask("ResourceValidatorImpl.validation");
	try {
		task.start();
		final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon;
		resolveProxies(resource, monitor);
		operationCanceledManager.checkCanceled(monitor);

		final List<Issue> result = Lists.newArrayListWithExpectedSize(resource.getErrors().size()
				+ resource.getWarnings().size());
		try {
			IAcceptor<Issue> acceptor = createAcceptor(result);

			if (mode.shouldCheck(CheckType.FAST)) {
				collectResourceDiagnostics(resource, monitor, acceptor);
			}

			operationCanceledManager.checkCanceled(monitor);
			boolean syntaxDiagFail = !result.isEmpty();
			logCheckStatus(resource, syntaxDiagFail, "Syntax");

			validate(resource, mode, monitor, acceptor);
			operationCanceledManager.checkCanceled(monitor);
		} catch (RuntimeException e) {
			operationCanceledManager.propagateAsErrorIfCancelException(e);
			log.error(e.getMessage(), e);
		}
		return result;
	} finally {
		task.stop();
	}
}
 
Example 5
Source File: BackgroundOutlineTreeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.7
 */
@Override
public IOutlineNode createRoot(IXtextDocument document, CancelIndicator cancelIndicator) {
	try {
		this.cancelIndicator = cancelIndicator;
		return factory.createRoot(document, getImageDescriptor(document), getText(document), this);
	} finally {
		this.cancelIndicator = CancelIndicator.NullImpl;
	}
}
 
Example 6
Source File: DefaultOutlineTreeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.7
 */
@Override
public IOutlineNode createRoot(IXtextDocument document, CancelIndicator cancelIndicator) {
	try {
		this.cancelIndicator = cancelIndicator;
		return createRoot(document);
	} finally {
		this.cancelIndicator = CancelIndicator.NullImpl;
	}
}
 
Example 7
Source File: XbaseHighlightingCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @deprecated Use org.eclipse.xtext.ide.editor.syntaxcoloring.DefaultSemanticHighlightingCalculator instead.
 */
@Deprecated
protected void highlightElementRecursively(EObject element, IHighlightedPositionAcceptor acceptor) {
	super.highlightElementRecursively(element, upcast(acceptor), CancelIndicator.NullImpl);
}
 
Example 8
Source File: XbaseHighlightingCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @deprecated Use org.eclipse.xtext.ide.editor.syntaxcoloring.DefaultSemanticHighlightingCalculator instead.
 */
@Deprecated
protected boolean highlightElement(EObject object, IHighlightedPositionAcceptor acceptor) {
	return super.highlightElement(object, upcast(acceptor), CancelIndicator.NullImpl);
}
 
Example 9
Source File: XbaseHighlightingCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @deprecated Use org.eclipse.xtext.ide.editor.syntaxcoloring.DefaultSemanticHighlightingCalculator instead.
 */
@Deprecated
protected void searchAndHighlightElements(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
	super.searchAndHighlightElements(resource, upcast(acceptor), CancelIndicator.NullImpl);
}
 
Example 10
Source File: XbaseHighlightingCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @deprecated Use org.eclipse.xtext.ide.editor.syntaxcoloring.DefaultSemanticHighlightingCalculator instead.
 */
@Deprecated
protected void doProvideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
	super.doProvideHighlightingFor(resource, upcast(acceptor), CancelIndicator.NullImpl);
}
 
Example 11
Source File: DefaultSemanticHighlightingCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @deprecated Use org.eclipse.xtext.ide.editor.syntaxcoloring.DefaultSemanticHighlightingCalculator instead.
 */
@Deprecated
protected boolean highlightElement(EObject object, IHighlightedPositionAcceptor acceptor) {
	return super.highlightElement(object, upcast(acceptor), CancelIndicator.NullImpl);
}
 
Example 12
Source File: DefaultSemanticHighlightingCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @deprecated Use org.eclipse.xtext.ide.editor.syntaxcoloring.DefaultSemanticHighlightingCalculator instead.
 */
@Deprecated
protected void highlightElementRecursively(EObject element, IHighlightedPositionAcceptor acceptor) {
	super.highlightElementRecursively(element, upcast(acceptor), CancelIndicator.NullImpl);
}
 
Example 13
Source File: XbaseHighlightingCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @deprecated Use org.eclipse.xtext.xbase.ide.highlighting.XbaseHighlightingCalculator instead.
 */
@Deprecated
protected void computeReferencedJvmTypeHighlighting(
		IHighlightedPositionAcceptor acceptor, EObject referencer) {
	super.computeReferencedJvmTypeHighlighting(upcast(acceptor), referencer, CancelIndicator.NullImpl);
}
 
Example 14
Source File: PublicResolvedTypes.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public PublicResolvedTypes(final DefaultReentrantTypeResolver resolver) {
  super(resolver, CancelIndicator.NullImpl);
}
 
Example 15
Source File: DefaultSemanticHighlightingCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.9
 */
@Override
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
	super.provideHighlightingFor(resource, upcast(acceptor), CancelIndicator.NullImpl);
}
 
Example 16
Source File: PublicResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public PublicResolvedTypes(DefaultReentrantTypeResolver resolver) {
	super(resolver, CancelIndicator.NullImpl);
}
 
Example 17
Source File: RecomputingReentrantTypeResolver.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public RootResolvedTypes createResolvedTypes(final CancelIndicator monitor) {
  return new RecordingRootResolvedTypes(this, CancelIndicator.NullImpl);
}
 
Example 18
Source File: CompoundReentrantTypeResolver.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected CancelIndicator getMonitor() {
	return monitor != null ? monitor : CancelIndicator.NullImpl;
}
 
Example 19
Source File: PublicResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public PublicResolvedTypes(DefaultReentrantTypeResolver resolver) {
	super(resolver, CancelIndicator.NullImpl);
}
 
Example 20
Source File: CancelIndicatorBaseExtractor.java    From n4js with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * We can't hardcode a dependency on EclipseResourceFileSystemAccess2 because IDE-1739, ie the headless compiler
 * would get a dependency on org.eclipse.xtext.builder.
 * <p>
 * This is a stop-gap measure until a real cancel indicator is made available to an IGenerator (or IGenerator2 as
 * proposed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=477068) in a more straightforward manner.
 * <p>
 * In the meantime the cancel indicator is extracted from IFileSystemAccess (in the IDE scenario only; in the
 * headless compiler scenario a CancelIndicator.NullImpl is used instead).
 * <p>
 * This method implements the default behavior, which is also the expected behavior for use in the headless
 * compiler.
 *
 */
public CancelIndicator extractCancelIndicator(@SuppressWarnings("unused") Object fsa) {
	return CancelIndicator.NullImpl;
}