Java Code Examples for org.eclipse.xtext.util.CancelIndicator#isCanceled()
The following examples show how to use
org.eclipse.xtext.util.CancelIndicator#isCanceled() .
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: AbstractSCTResource.java From statecharts with Eclipse Public License 1.0 | 6 votes |
public void resolveLazyCrossReferences(CancelIndicator monitor) { TreeIterator<Object> iterator = EcoreUtil.getAllContents(this, true); while (iterator.hasNext()) { InternalEObject source = (InternalEObject) iterator.next(); EStructuralFeature[] eStructuralFeatures = ((EClassImpl.FeatureSubsetSupplier) source.eClass() .getEAllStructuralFeatures()).crossReferences(); if (eStructuralFeatures != null) { for (EStructuralFeature crossRef : eStructuralFeatures) { if (monitor.isCanceled()) { return; } resolveLazyCrossReference(source, crossRef, monitor); } } } }
Example 2
Source File: XbaseInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected Object _doEvaluate(XListLiteral literal, IEvaluationContext context, CancelIndicator indicator) { IResolvedTypes resolveTypes = typeResolver.resolveTypes(literal); LightweightTypeReference type = resolveTypes.getActualType(literal); List<Object> list = newArrayList(); for(XExpression element: literal.getElements()) { if (indicator.isCanceled()) throw new InterpreterCanceledException(); list.add(internalEvaluate(element, context, indicator)); } if(type != null && type.isArray()) { try { LightweightTypeReference componentType = type.getComponentType(); return Conversions.unwrapArray(list, getJavaType(componentType.getType())); } catch (ClassNotFoundException e) { } } return Collections.unmodifiableList(list); }
Example 3
Source File: AbstractXtextCodeMiningProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Creates code minings for a document * @param document The document * @param resource The resource for that document * @param indicator Cancelation indicator * @return Computed minings * @throws BadLocationException when line number doesn't exists */ protected List<ICodeMining> createCodeMinings(IDocument document, XtextResource resource, CancelIndicator cancelIndicator) throws BadLocationException { List<ICodeMining> codeMiningList = new ArrayList<>(); IAcceptor<ICodeMining> acceptor = new IAcceptor<ICodeMining>() { @Override public void accept(ICodeMining codeMiningObject) { if (cancelIndicator.isCanceled()) { // do not accept mining and abort processing when operation was canceled throw new CancellationException(); } codeMiningList.add(codeMiningObject); } }; createCodeMinings(document, resource, cancelIndicator, acceptor); return codeMiningList; }
Example 4
Source File: CancelIndicatorUtil.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public boolean isCanceled() { for (CancelIndicator ci : delegates) { if (ci.isCanceled()) { return true; } } return false; }
Example 5
Source File: SCTResourceValidatorImpl.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void validate(Resource resource, final CheckMode mode, final CancelIndicator monitor, IAcceptor<Issue> acceptor) { for (EObject ele : resource.getContents()) { if (!(ele instanceof Statechart)) { continue; } if (!monitor.isCanceled()) { validate(null, ele, mode, monitor, acceptor); } } }
Example 6
Source File: FixedHighlightingReconciler.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * @since 2.8 */ @Override protected void checkCanceled(final CancelIndicator cancelIndicator) { if (cancelIndicator.isCanceled()) { throw new OperationCanceledException(); } }
Example 7
Source File: LazyLinkingResource2.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public void resolveLazyCrossReferences(final CancelIndicator mon) { // We must set that flag only if the xtext proxy resolution was not canceled. If it was, we must re-do the proxy resolution (the // super implementation takes care to only resolve xtext proxies, so this will not fully resolve even if run several times). If // we unconditionally set the flag, a canceled linking run may leave behind xtext proxies, and because the flag will be set, // subsequent invocations will be no-ops. As a result, we'll have xtext proxies during validation. // // Furthermore, it's probably nonsense to have two threads execute this simultaneously on the same resource, so we'll serialize // this. // // Unfortunately, we have no set() on IResourceScopeCache. We'll have to get that ourselves using an indirection... final LazyResolutionFlag lazyLinking = getCache().get(LAZY_CROSS_REFERENCES_RESOLVED, this, new Provider<LazyResolutionFlag>() { @Override public LazyResolutionFlag get() { return new LazyResolutionFlag(); // Initially false } }); synchronized (lazyLinking) { if (!lazyLinking.isDone()) { super.resolveLazyCrossReferences(mon); if (mon == null || !mon.isCanceled()) { lazyLinking.setDone(); // And make sure that the flag is in the cache!! getCache().get(LAZY_CROSS_REFERENCES_RESOLVED, this, new Provider<LazyResolutionFlag>() { @Override public LazyResolutionFlag get() { return lazyLinking; } }); } } } }
Example 8
Source File: EcoreUtil2.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private static void resolveCrossReferences(EObject eObject, CancelIndicator monitor) { for (Iterator<EObject> i = eObject.eCrossReferences().iterator(); i.hasNext(); i .next()) { if (monitor.isCanceled()) { throw new OperationCanceledException(); } // The loop resolves the cross references by visiting them. } }
Example 9
Source File: EcoreUtil2.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.emf.ecore.util.EcoreUtil#resolveAll(EObject) */ public static void resolveAll(EObject eObject, CancelIndicator monitor) { resolveCrossReferences(eObject, monitor); for (Iterator<EObject> i = eObject.eAllContents(); i.hasNext();) { if (monitor.isCanceled()) throw new OperationCanceledException(); EObject childEObject = i.next(); resolveCrossReferences(childEObject, monitor); } }
Example 10
Source File: EcoreUtil2.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public static void resolveAll(Resource resource, CancelIndicator monitor) { for (Iterator<EObject> i = resource.getAllContents(); i.hasNext();) { if (monitor.isCanceled()) throw new OperationCanceledException(); EObject eObject = i.next(); resolveCrossReferences(eObject, monitor); } }
Example 11
Source File: AnnotationProcessor.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public Future<?> monitorUntil(final ActiveAnnotationContext ctx, final CancelIndicator cancelIndicator, final Function0<? extends Boolean> isFinished) { Future<?> _xblockexpression = null; { final Runnable _function = () -> { try { while ((!(isFinished.apply()).booleanValue())) { { boolean _isCanceled = cancelIndicator.isCanceled(); if (_isCanceled) { CompilationUnitImpl _compilationUnit = ctx.getCompilationUnit(); _compilationUnit.setCanceled(true); return; } Thread.sleep(100); } } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }; final Runnable r = _function; Future<?> _xtrycatchfinallyexpression = null; try { _xtrycatchfinallyexpression = this.pool.submit(r); } catch (final Throwable _t) { if (_t instanceof RejectedExecutionException) { final RejectedExecutionException e = (RejectedExecutionException)_t; AnnotationProcessor.CancellationObserver.log.debug(e.getMessage(), e); new Thread(r).start(); } else { throw Exceptions.sneakyThrow(_t); } } _xblockexpression = _xtrycatchfinallyexpression; } return _xblockexpression; }
Example 12
Source File: OverrideIndicatorModelListener.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected Map<Annotation, Position> createOverrideIndicatorAnnotationMap(XtextResource xtextResource, CancelIndicator cancelIndicator) { List<EObject> contents = xtextResource.getContents(); if (contents.isEmpty()) return Maps.newHashMap(); EObject eObject = contents.get(0); if (!(eObject instanceof XtendFile)) { return Maps.newHashMap(); } XtendFile xtendFile = (XtendFile) eObject; Map<Annotation, Position> annotationToPosition = Maps.newHashMap(); for (XtendFunction xtendFunction : getXtendFunctions(xtendFile)) { if(cancelIndicator.isCanceled()) throw new OperationCanceledException(); if (xtendFunction.isOverride()) { typeResolver.resolveTypes(xtendFunction); INode node = NodeModelUtils.getNode(xtendFunction); JvmOperation inferredOperation = associations.getDirectlyInferredOperation(xtendFunction); if (inferredOperation != null) { JvmOperation jvmOperation = overrideHelper.findOverriddenOperation(inferredOperation); if (node != null && jvmOperation != null) { boolean overwriteIndicator = isOverwriteIndicator(jvmOperation); String text = (overwriteIndicator ? "overrides " : "implements ") + jvmOperation.getQualifiedName(); //$NON-NLS-1$ //$NON-NLS-2$ node = getFirst(findNodesForFeature(xtendFunction, XtendPackage.eINSTANCE.getXtendFunction_Name()), node); annotationToPosition.put( new OverrideIndicatorAnnotation(overwriteIndicator, text, xtextResource .getURIFragment(xtendFunction)), new Position(node.getOffset())); } } } } return annotationToPosition; }
Example 13
Source File: OutlineRefreshJob.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.7 */ protected void restoreChildrenSelectionAndExpansion(IOutlineNode parent, Resource resource, OutlineTreeState formerState, OutlineTreeState newState, CancelIndicator cancelIndicator) { List<IOutlineNode> children = parent.getChildren(); for(IOutlineNode child: children) { if(cancelIndicator.isCanceled()) throw new OperationCanceledException(); if(containsUsingComparer(formerState.getExpandedNodes(), child)) { restoreChildrenSelectionAndExpansion(child, resource, formerState, newState, cancelIndicator); newState.addExpandedNode(child); } if(containsUsingComparer(formerState.getSelectedNodes(), child)) { newState.addSelectedNode(child); } } }
Example 14
Source File: XbaseInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected Object internalEvaluate(XExpression expression, IEvaluationContext context, CancelIndicator indicator) throws EvaluationException { if (indicator.isCanceled()) throw new InterpreterCanceledException(); Object result = doEvaluate(expression, context, indicator); final LightweightTypeReference expectedType = typeResolver.resolveTypes(expression).getExpectedType(expression); if(expectedType != null) result = wrapOrUnwrapArray(result, expectedType); return result; }
Example 15
Source File: OperationCanceledManager.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public void checkCanceled(final CancelIndicator indicator) { if (indicator != null && indicator.isCanceled()) { throwOperationCanceledException(); } }
Example 16
Source File: CancelableDiagnostician.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * <p> * Use {@link #checkCanceled} instead to throw a platform specific cancellation exception. * </p> */ @Deprecated protected boolean isCanceled(Map<Object, Object> context) { CancelIndicator indicator = getCancelIndicator(context); return indicator != null && indicator.isCanceled(); }
Example 17
Source File: HighlightingReconciler.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.8 */ protected void checkCanceled(CancelIndicator cancelIndicator) { if (cancelIndicator.isCanceled()) throw new OperationCanceledException(); }
Example 18
Source File: BslValidator.java From ru.capralow.dt.bslls.validator with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void validateModule(EObject object, CustomValidationMessageAcceptor messageAcceptor, CancelIndicator monitor) { if (monitor.isCanceled()) return; IV8Project v8Project = projectManager.getProject(object); if (v8Project == null) return; ProjectContext projectContext = projectsContext.get(v8Project.getProject()); if (projectContext == null) return; long startTime = System.currentTimeMillis(); BslValidatorPlugin.log( BslValidatorPlugin.createInfoStatus(BSL_LS_PREFIX.concat("Начало передачи текста модуля"))); //$NON-NLS-1$ Module module = (Module)object; IFile moduleFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(EcoreUtil.getURI(module).toPlatformString(true))); ICompositeNode node = NodeModelUtils.findActualNodeFor(module); String objectText = node.getText(); Document doc = new Document(objectText); DocumentContext documentContext = projectContext.bslServerContext.addDocument(moduleFile.getLocationURI(), objectText); long computeStartTime = System.currentTimeMillis(); List<Diagnostic> diagnostics = projectContext.diagnosticProvider.computeDiagnostics(documentContext); long computeDifference = System.currentTimeMillis() - computeStartTime; int findNodeAmount = diagnostics.size(); for (Diagnostic diagnostic : diagnostics) { if (monitor.isCanceled()) break; registerIssue(object, messageAcceptor, diagnostic, documentContext, doc, projectContext); } projectContext.diagnosticProvider.clearComputedDiagnostics(documentContext); documentContext.clearSecondaryData(); long difference = System.currentTimeMillis() - startTime; if (difference > 10000) BslValidatorPlugin.log(BslValidatorPlugin.createInfoStatus( BSL_LS_PREFIX.concat("URI модуля длительной проверки: ").concat(moduleFile.getLocation().toString()))); //$NON-NLS-1$ String differenceText = MessageFormat.format("(всего:{0}сек,анализ:{1}сек/{2}проб)", //$NON-NLS-1$ Long.toString(difference / 1000), Long.toString(computeDifference / 1000), String.valueOf(findNodeAmount)); BslValidatorPlugin.log(BslValidatorPlugin.createInfoStatus( BSL_LS_PREFIX.concat("Окончание передачи текста модуля ").concat(differenceText))); //$NON-NLS-1$ }