use of org.eclipse.xtext.diagnostics.Severity in project xtext-core by eclipse.
the class XtextValidator method checkOppositeReferenceUsed.
@Check
public void checkOppositeReferenceUsed(Assignment assignment) {
Severity severity = getIssueSeverities(getContext(), getCurrentObject()).getSeverity(BIDIRECTIONAL_REFERENCE);
if (severity == null || severity == Severity.IGNORE) {
// Don't perform any check if the result is ignored
return;
}
EClassifier classifier = GrammarUtil.findCurrentType(assignment);
if (classifier instanceof EClass) {
EStructuralFeature feature = ((EClass) classifier).getEStructuralFeature(assignment.getFeature());
if (feature instanceof EReference) {
EReference reference = (EReference) feature;
if (reference.getEOpposite() != null && !(reference.isContainment() || reference.isContainer())) {
addIssue("The feature '" + assignment.getFeature() + "' is a bidirectional reference." + " This may cause problems in the linking process.", assignment, XtextPackage.eINSTANCE.getAssignment_Feature(), BIDIRECTIONAL_REFERENCE);
}
}
}
}
use of org.eclipse.xtext.diagnostics.Severity in project xtext-eclipse by eclipse.
the class DerivedResourceMarkerCopier method getMaxSeverity.
private int getMaxSeverity(IFile srcFile) {
URI resourceURI = URI.createPlatformResourceURI(srcFile.getFullPath().toString(), true);
IResourceServiceProvider serviceProvider = serviceProviderRegistry.getResourceServiceProvider(resourceURI);
if (serviceProvider == null)
return Integer.MAX_VALUE;
IssueSeveritiesProvider severitiesProvider = serviceProvider.get(IssueSeveritiesProvider.class);
Severity severity = severitiesProvider.getIssueSeverities(new ResourceImpl(resourceURI)).getSeverity(COPY_JAVA_PROBLEMS_ISSUECODE);
switch(severity) {
case WARNING:
return IMarker.SEVERITY_WARNING;
case ERROR:
return IMarker.SEVERITY_ERROR;
case INFO:
case IGNORE:
return Integer.MAX_VALUE;
default:
break;
}
return Integer.MAX_VALUE;
}
use of org.eclipse.xtext.diagnostics.Severity in project statecharts by Yakindu.
the class DefaultValidationIssueStore method processIssues.
@Override
public synchronized void processIssues(List<Issue> issues, IProgressMonitor monitor) {
final Multimap<String, SCTIssue> newVisibleIssues = ArrayListMultimap.create();
for (Issue issue : issues) {
if (issue instanceof SCTIssue) {
String semanticURI = ((SCTIssue) issue).getSemanticURI();
newVisibleIssues.put(semanticURI, (SCTIssue) issue);
}
}
final Multimap<String, SCTIssue> oldVisibleIssues = ArrayListMultimap.create();
synchronized (visibleIssues) {
oldVisibleIssues.putAll(visibleIssues);
// normal and expensive checks will not be executed by the live
// validation, so persistent markers have to be copied
Iterable<SCTIssue> persistentIssues = Iterables.filter(visibleIssues.values(), new Predicate<SCTIssue>() {
public boolean apply(SCTIssue input) {
CheckType type = input.getType();
Severity severity = input.getSeverity();
return CheckType.NORMAL == type || CheckType.EXPENSIVE == type || Severity.INFO == severity;
}
});
for (SCTIssue sctIssue : persistentIssues) {
newVisibleIssues.put(sctIssue.getSemanticURI(), sctIssue);
}
visibleIssues.clear();
visibleIssues.putAll(newVisibleIssues);
}
SetView<String> changes = Sets.symmetricDifference(oldVisibleIssues.keySet(), newVisibleIssues.keySet());
for (String string : changes) {
notifyListeners(string);
}
SetView<String> intersection = Sets.intersection(oldVisibleIssues.keySet(), newVisibleIssues.keySet());
for (String string : intersection) {
if (changedSeverity(string, oldVisibleIssues, newVisibleIssues) || changedErrorCount(string, oldVisibleIssues, newVisibleIssues)) {
notifyListeners(string);
}
}
}
use of org.eclipse.xtext.diagnostics.Severity in project statecharts by Yakindu.
the class DefaultValidationIssueStore method changedSeverity.
protected boolean changedSeverity(String semanticElementID, Multimap<String, SCTIssue> oldVisibleIssues, Multimap<String, SCTIssue> newVisibleIssues) {
Severity minOldSeverity = getMinSeverity(oldVisibleIssues.get(semanticElementID));
Severity minNewSeverity = getMinSeverity(newVisibleIssues.get(semanticElementID));
return minNewSeverity.ordinal() != minOldSeverity.ordinal();
}
use of org.eclipse.xtext.diagnostics.Severity in project xtext-xtend by eclipse.
the class SmokeTest method checkNoErrorsInValidator.
protected void checkNoErrorsInValidator(final String model, LazyLinkingResource resource) {
ResourceValidatorImpl validator = resourceValidatorProvider.get();
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);
}
Aggregations