use of org.eclipse.emf.common.util.BasicDiagnostic in project iobserve-analysis by research-iobserve.
the class cloudprofileEditor method analyzeResourceProblems.
/**
* Returns a diagnostic describing the errors and warnings listed in the resource
* and the specified exception (if any).
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
boolean hasErrors = !resource.getErrors().isEmpty();
if (hasErrors || !resource.getWarnings().isEmpty()) {
BasicDiagnostic basicDiagnostic = new BasicDiagnostic(hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.iobserve.planning.cloudprofile.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception == null ? (Object) resource : exception });
basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
return basicDiagnostic;
} else if (exception != null) {
return new BasicDiagnostic(Diagnostic.ERROR, "org.iobserve.planning.cloudprofile.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception });
} else {
return Diagnostic.OK_INSTANCE;
}
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project iobserve-analysis by research-iobserve.
the class systemadaptationEditor method analyzeResourceProblems.
/**
* Returns a diagnostic describing the errors and warnings listed in the resource
* and the specified exception (if any).
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
boolean hasErrors = !resource.getErrors().isEmpty();
if (hasErrors || !resource.getWarnings().isEmpty()) {
BasicDiagnostic basicDiagnostic = new BasicDiagnostic(hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "planning.systemadaptation.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception == null ? (Object) resource : exception });
basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
return basicDiagnostic;
} else if (exception != null) {
return new BasicDiagnostic(Diagnostic.ERROR, "planning.systemadaptation.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception });
} else {
return Diagnostic.OK_INSTANCE;
}
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project n4js by eclipse.
the class AutomaticCancelationTest method testCancelIndicatorGetsInvokedAutomatically.
@Test
public void testCancelIndicatorGetsInvokedAutomatically() throws Exception {
String program = " class X { \n\t a: any; \n\t a: any; } } ";
Script s;
try {
s = ph.parse(program);
N4ClassDeclaration clazz = (N4ClassDeclaration) s.getScriptElements().get(0);
Map<Object, Object> context = new HashMap<>();
context.put(CancelableDiagnostician.CANCEL_INDICATOR, new TraceLeavingCancelIndicator());
// the cancel indicator in use sets a flag in case its isCanceled() was queried
assertTrue(!(wasChecked.get()));
DiagnosticChain chain = new BasicDiagnostic();
try {
v.validate(clazz, chain, context);
fail("expected OperationCanceledException or OperationCanceledError was not thrown");
} catch (Throwable th) {
assertTrue("wrong kind of throwable; expected: OperationCanceledException or OperationCanceledError, actual: " + th.getClass().getSimpleName(), operationCanceledManager.isOperationCanceledException(th));
}
assertTrue(wasChecked.get());
// now validate with a cancel indicator that never cancels,
// upon which validation methods run and errors are recorded.
context.put(CancelableDiagnostician.CANCEL_INDICATOR, CancelIndicator.NullImpl);
final boolean isValid02 = v.validate(clazz, chain, context);
assertTrue(!isValid02);
// validate again (this time with the default cancel indicator, which never cancels),
// check expected errors one by one.
String[] expectedErrorMsgs = { "The field a (line 2) duplicates field a (line 3).", "The field a (line 3) duplicates field a (line 2)." };
for (String expectedErrorMsg : expectedErrorMsgs) {
vth.assertError(s, N4JSPackage.Literals.N4_MEMBER_DECLARATION, IssueCodes.CLF_DUP_MEMBER, expectedErrorMsg);
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project dsl-devkit by dsldevkit.
the class CheckExtensionGenerator method catalogValidates.
/**
* Catalog validates.
*
* @param catalog
* the catalog
* @return true, if successful
*/
private boolean catalogValidates(final CheckCatalog catalog) {
EValidator.Registry eValidatorRegistry = EValidator.Registry.INSTANCE;
EValidator eValidator = eValidatorRegistry.getEValidator(catalog.eClass().getEPackage());
BasicDiagnostic diag = new BasicDiagnostic();
eValidator.validate(catalog, diag, Maps.newHashMap());
Iterable<Diagnostic> children = diag.getChildren();
Iterable<Diagnostic> errors = Iterables.filter(children, new Predicate<Diagnostic>() {
@Override
public boolean apply(final Diagnostic input) {
return input.getSeverity() == Diagnostic.ERROR;
}
});
return Iterables.isEmpty(errors);
}
use of org.eclipse.emf.common.util.BasicDiagnostic in project metalib by softlang.
the class FsmlEditor method analyzeResourceProblems.
/**
* Returns a diagnostic describing the errors and warnings listed in the resource
* and the specified exception (if any).
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
boolean hasErrors = !resource.getErrors().isEmpty();
if (hasErrors || !resource.getWarnings().isEmpty()) {
BasicDiagnostic basicDiagnostic = new BasicDiagnostic(hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING, "org.softlang.metalib.sirius.fsml.model.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception == null ? (Object) resource : exception });
basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
return basicDiagnostic;
} else if (exception != null) {
return new BasicDiagnostic(Diagnostic.ERROR, "org.softlang.metalib.sirius.fsml.model.editor", 0, getString("_UI_CreateModelError_message", resource.getURI()), new Object[] { exception });
} else {
return Diagnostic.OK_INSTANCE;
}
}
Aggregations