use of org.eclipse.xtext.util.CancelIndicator in project xtext-xtend by eclipse.
the class DirtyStateEditorValidationTest method testAddedInterfaceMethod.
@Test
public void testAddedInterfaceMethod() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("interface Foo {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String interface_ = _builder.toString();
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("interface Foo {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def void bar(String b)");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
final String interfaceChanged = _builder_1.toString();
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("class Bar implements Foo {");
_builder_2.newLine();
_builder_2.append("}");
_builder_2.newLine();
final String class_ = _builder_2.toString();
final IFile interfaceFile = this.helper.createFile("Foo.xtend", interface_);
final IFile classFile = this.helper.createFile("Bar.xtend", class_);
this._syncUtil.waitForBuild(null);
Assert.assertEquals(0, classFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE).length);
final XtextEditor interfaceEditor = this.helper.openEditor(interfaceFile);
final XtextEditor classEditor = this.helper.openEditor(classFile);
this.assertNumberOfErrorAnnotations(classEditor, 0);
interfaceEditor.getDocument().set(interfaceChanged);
this._syncUtil.waitForReconciler(interfaceEditor);
this._syncUtil.waitForReconciler(classEditor);
final IUnitOfWork<Object, XtextResource> _function = (XtextResource it) -> {
final CancelIndicator _function_1 = () -> {
return false;
};
final List<Issue> issues = this.validator.validate(it, CheckMode.NORMAL_AND_FAST, _function_1);
Assert.assertEquals(issues.toString(), 1, issues.size());
return null;
};
classEditor.getDocument().<Object>readOnly(_function);
interfaceEditor.getDocument().set(interface_);
this._syncUtil.waitForReconciler(interfaceEditor);
this._syncUtil.waitForReconciler(classEditor);
final IUnitOfWork<Object, XtextResource> _function_1 = (XtextResource it) -> {
final CancelIndicator _function_2 = () -> {
return false;
};
final List<Issue> issues = this.validator.validate(it, CheckMode.NORMAL_AND_FAST, _function_2);
Assert.assertTrue(issues.toString(), issues.isEmpty());
return null;
};
classEditor.getDocument().<Object>readOnly(_function_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.util.CancelIndicator in project xtext-core by eclipse.
the class LanguageServerImpl method rename.
@Override
public CompletableFuture<WorkspaceEdit> rename(final RenameParams params) {
final Function1<CancelIndicator, WorkspaceEdit> _function = (CancelIndicator cancelIndicator) -> {
WorkspaceEdit _xblockexpression = null;
{
final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
IRenameService _get = null;
if (resourceServiceProvider != null) {
_get = resourceServiceProvider.<IRenameService>get(IRenameService.class);
}
final IRenameService renameService = _get;
if ((renameService == null)) {
return new WorkspaceEdit();
}
_xblockexpression = renameService.rename(this.workspaceManager, params, cancelIndicator);
}
return _xblockexpression;
};
return this.requestManager.<WorkspaceEdit>runRead(_function);
}
use of org.eclipse.xtext.util.CancelIndicator in project xtext-core by eclipse.
the class WorkspaceManager method didChange.
public BuildManager.Buildable didChange(final URI uri, final int version, final Iterable<TextEdit> changes) {
boolean _containsKey = this.openDocuments.containsKey(uri);
boolean _not = (!_containsKey);
if (_not) {
WorkspaceManager.LOG.error((("The document " + uri) + " has not been opened."));
final BuildManager.Buildable _function = (CancelIndicator it) -> {
return null;
};
return _function;
}
final Document contents = this.openDocuments.get(uri);
this.openDocuments.put(uri, contents.applyChanges(changes));
return this.didChangeFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(uri)), CollectionLiterals.<URI>newArrayList());
}
use of org.eclipse.xtext.util.CancelIndicator in project xtext-core by eclipse.
the class ResourceValidatorImpl method validate.
@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();
}
}
use of org.eclipse.xtext.util.CancelIndicator in project xtext-core by eclipse.
the class LazyLinkingResource method resolveLazyCrossReferences.
/**
* resolves any lazy cross references in this resource, adding Issues for unresolvable elements to this resource.
* This resource might still contain resolvable proxies after this method has been called.
*
* @param mon a {@link CancelIndicator} can be used to stop the resolution.
*/
public void resolveLazyCrossReferences(final CancelIndicator mon) {
final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon;
TreeIterator<Object> iterator = EcoreUtil.getAllContents(this, true);
while (iterator.hasNext()) {
operationCanceledManager.checkCanceled(monitor);
InternalEObject source = (InternalEObject) iterator.next();
EStructuralFeature[] eStructuralFeatures = ((EClassImpl.FeatureSubsetSupplier) source.eClass().getEAllStructuralFeatures()).crossReferences();
if (eStructuralFeatures != null) {
for (EStructuralFeature crossRef : eStructuralFeatures) {
operationCanceledManager.checkCanceled(monitor);
resolveLazyCrossReference(source, crossRef);
}
}
}
}
Aggregations