Java Code Examples for org.eclipse.emf.common.util.Diagnostic#getCode()

The following examples show how to use org.eclipse.emf.common.util.Diagnostic#getCode() . 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: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void diagnose(Diagnostic diagnostic, URI[] expectedUnresolvedProxies) {
	if (diagnostic.getChildren().isEmpty()) {
		if (diagnostic.getSeverity() != Diagnostic.OK) {
			if (diagnostic.getCode() == EObjectValidator.EOBJECT__EVERY_PROXY_RESOLVES) {
				EObject proxy = (EObject) diagnostic.getData().get(2); // magic number ...
				if (org.eclipse.xtext.util.Arrays.contains(expectedUnresolvedProxies, EcoreUtil.getURI(proxy))) {
					return;
				}
			}
			assertEquals(String.valueOf(diagnostic), diagnostic.getSeverity() == Diagnostic.OK);
		}
	} else {
		for (Diagnostic child : diagnostic.getChildren()) {
			diagnose(child, expectedUnresolvedProxies);
		}
	}
}
 
Example 2
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void diagnose(Diagnostic diagnostic, URI[] expectedUnresolvedProxies) {
	if (diagnostic.getChildren().isEmpty()) {
		if (diagnostic.getSeverity() != Diagnostic.OK) {
			if (diagnostic.getCode() == EObjectValidator.EOBJECT__EVERY_PROXY_RESOLVES) {
				EObject proxy = (EObject) diagnostic.getData().get(2); // magic number ...
				if (org.eclipse.xtext.util.Arrays.contains(expectedUnresolvedProxies, EcoreUtil.getURI(proxy))) {
					return;
				}
			}
			assertEquals(String.valueOf(diagnostic), diagnostic.getSeverity() == Diagnostic.OK);
		}
	} else {
		for (Diagnostic child : diagnostic.getChildren()) {
			diagnose(child, expectedUnresolvedProxies);
		}
	}
}
 
Example 3
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void diagnose(Diagnostic diagnostic, URI[] expectedUnresolvedProxies) {
	if (diagnostic.getChildren().isEmpty()) {
		if (diagnostic.getSeverity() != Diagnostic.OK) {
			if (diagnostic.getCode() == EObjectValidator.EOBJECT__EVERY_PROXY_RESOLVES) {
				EObject proxy = (EObject) diagnostic.getData().get(2); // magic number ...
				if (org.eclipse.xtext.util.Arrays.contains(expectedUnresolvedProxies, EcoreUtil.getURI(proxy))) {
					return;
				}
			}
			assertEquals(String.valueOf(diagnostic), diagnostic.getSeverity() == Diagnostic.OK);
		}
	} else {
		for (Diagnostic child : diagnostic.getChildren()) {
			diagnose(child, expectedUnresolvedProxies);
		}
	}
}
 
Example 4
Source File: XtextValidator.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private void propageValidationResult(Diagnostic diagnostic, GeneratedMetamodel metamodel, ValidationMessageAcceptor acceptor) {
	if (diagnostic.getSeverity() != Diagnostic.OK) {
		if (diagnostic.getCode() != 0) {
			List<?> data = diagnostic.getData();
			if (!data.isEmpty() && data.get(0) instanceof EObject) {
				doPropagateValidationResult(diagnostic, metamodel, acceptor);
			}
		}
		for(Diagnostic child: diagnostic.getChildren())
			propageValidationResult(child, metamodel, acceptor);
	}
}
 
Example 5
Source File: XtextValidator.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public boolean createMessageForSource(Diagnostic diagnostic, EObject object, ValidationMessageAcceptor acceptor) {
	String code = XtextValidator.class.getName() + ".PackageValidation." + diagnostic.getCode();
	int severity = diagnostic.getSeverity();
	if (diagnostic.getCode() == EcoreValidator.UNIQUE_CLASSIFIER_NAMES || diagnostic.getCode() == EcoreValidator.UNIQUE_FEATURE_NAMES)
		severity = Diagnostic.ERROR;
	String message = diagnostic.getMessage();
	return createMessageForSource(message, code, severity, object, acceptor);
}
 
Example 6
Source File: XtextValidator.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public void doCreateMessage(Diagnostic diagnostic, EObject object, EStructuralFeature feature, ValidationMessageAcceptor acceptor) {
	String code = XtextValidator.class.getName() + ".PackageValidation." + diagnostic.getCode();
	int severity = diagnostic.getSeverity();
	if (diagnostic.getCode() == EcoreValidator.UNIQUE_CLASSIFIER_NAMES || diagnostic.getCode() == EcoreValidator.UNIQUE_FEATURE_NAMES)
		severity = Diagnostic.ERROR;
	String message = diagnostic.getMessage();
	doCreateMessage(message, code, severity, object, feature, acceptor);
}