use of org.eclipse.xtext.validation.Issue in project xtext-eclipse by eclipse.
the class DerivedResourceMarkerCopier method determinateMarkerTypeByURI.
private String determinateMarkerTypeByURI(SourceRelativeURI resourceURI) {
IResourceServiceProvider serviceProvider = serviceProviderRegistry.getResourceServiceProvider(resourceURI.getURI());
if (serviceProvider == null)
return null;
MarkerTypeProvider typeProvider = serviceProvider.get(MarkerTypeProvider.class);
Issue.IssueImpl issue = new Issue.IssueImpl();
issue.setType(CheckType.NORMAL);
return typeProvider.getMarkerType(issue);
}
use of org.eclipse.xtext.validation.Issue in project xtext-eclipse by eclipse.
the class NoJRESmokeTester method checkNoErrorsInValidator.
protected void checkNoErrorsInValidator(final String model, XtextResource resource) {
ResourceValidatorImpl validator = resourceValidatorProvider.get();
Assert.assertNotSame(validator, resource.getResourceServiceProvider().getResourceValidator());
validator.setDiagnosticConverter(new IDiagnosticConverter() {
@Override
public void convertValidatorDiagnostic(org.eclipse.emf.common.util.Diagnostic diagnostic, IAcceptor<Issue> acceptor) {
if (diagnostic instanceof BasicDiagnostic) {
List<?> data = diagnostic.getData();
if (!data.isEmpty() && data.get(0) instanceof Throwable) {
Throwable t = (Throwable) data.get(0);
throwError(t);
}
if (EObjectValidator.DIAGNOSTIC_SOURCE.equals(diagnostic.getSource()) && diagnostic.getCode() == EObjectValidator.EOBJECT__EVERY_REFERENCE_IS_CONTAINED) {
throwError(new RuntimeException("Dangling reference found."));
}
}
}
private void throwError(Throwable e) {
ComparisonFailure result = new ComparisonFailure(e.getMessage(), model, "");
result.setStackTrace(e.getStackTrace());
throw result;
}
@Override
public void convertResourceDiagnostic(Diagnostic diagnostic, Severity severity, IAcceptor<Issue> acceptor) {
if (diagnostic instanceof ExceptionDiagnostic) {
Exception e = ((ExceptionDiagnostic) diagnostic).getException();
throwError(e);
}
}
});
validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);
}
use of org.eclipse.xtext.validation.Issue in project xtext-eclipse by eclipse.
the class DeclarativeQuickfixProviderTest method testHasResolutions.
@Test
public void testHasResolutions() throws Exception {
abstract class __DeclarativeQuickfixProviderTest_1 extends AbstractDeclarativeQuickfixProvider {
public abstract void signature(final Issue i, final IssueResolutionAcceptor acceptor);
}
AbstractDeclarativeQuickfixProvider provider = new __DeclarativeQuickfixProviderTest_1() {
@Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE)
public void signature(final Issue i, final IssueResolutionAcceptor acceptor) {
}
};
Assert.assertFalse(provider.hasResolutionFor((DeclarativeQuickfixProviderTest.DUMMY_CODE + Integer.valueOf(1))));
Assert.assertTrue(provider.hasResolutionFor(DeclarativeQuickfixProviderTest.DUMMY_CODE));
}
use of org.eclipse.xtext.validation.Issue in project xtext-eclipse by eclipse.
the class DeclarativeQuickfixProviderTest method testHasResolutions2.
@Test
public void testHasResolutions2() throws Exception {
abstract class __DeclarativeQuickfixProviderTest_2 extends AbstractDeclarativeQuickfixProvider {
public abstract void signature(final Issue i, final IssueResolutionAcceptor acceptor);
}
AbstractDeclarativeQuickfixProvider provider = new __DeclarativeQuickfixProviderTest_2() {
@Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE)
@Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE2)
public void signature(final Issue i, final IssueResolutionAcceptor acceptor) {
}
};
Assert.assertFalse(provider.hasResolutionFor((DeclarativeQuickfixProviderTest.DUMMY_CODE + Integer.valueOf(1))));
Assert.assertTrue(provider.hasResolutionFor(DeclarativeQuickfixProviderTest.DUMMY_CODE));
Assert.assertTrue(provider.hasResolutionFor(DeclarativeQuickfixProviderTest.DUMMY_CODE2));
}
use of org.eclipse.xtext.validation.Issue in project xtext-eclipse by eclipse.
the class DeclarativeQuickfixProviderTest method testHasResolutions3.
@Test
public void testHasResolutions3() throws Exception {
abstract class __DeclarativeQuickfixProviderTest_3 extends AbstractDeclarativeQuickfixProvider {
public abstract void signature(final Issue i, final IssueResolutionAcceptor acceptor);
}
AbstractDeclarativeQuickfixProvider provider = new __DeclarativeQuickfixProviderTest_3() {
@Fixes({ @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE), @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE2) })
public void signature(final Issue i, final IssueResolutionAcceptor acceptor) {
}
};
Assert.assertFalse(provider.hasResolutionFor((DeclarativeQuickfixProviderTest.DUMMY_CODE + Integer.valueOf(1))));
Assert.assertTrue(provider.hasResolutionFor(DeclarativeQuickfixProviderTest.DUMMY_CODE));
Assert.assertTrue(provider.hasResolutionFor(DeclarativeQuickfixProviderTest.DUMMY_CODE2));
}
Aggregations