Search in sources :

Example 1 with ValidationMessageAcceptor

use of org.eclipse.xtext.validation.ValidationMessageAcceptor in project ow by vtst.

the class ValidatorPageHelper method resetValidatorCache.

private void resetValidatorCache() {
    ValidationMessageAcceptor messageAcceptor = getValidator().getMessageAcceptor();
    if (!(messageAcceptor instanceof ConfigurableValidationMessageAcceptor))
        return;
    ConfigurableValidationMessageAcceptor configurableMessageAcceptor = (ConfigurableValidationMessageAcceptor) messageAcceptor;
    configurableMessageAcceptor.resetCache(this.project);
}
Also used : ConfigurableValidationMessageAcceptor(net.vtst.eclipse.easyxtext.validation.config.ConfigurableValidationMessageAcceptor) ValidationMessageAcceptor(org.eclipse.xtext.validation.ValidationMessageAcceptor) ConfigurableValidationMessageAcceptor(net.vtst.eclipse.easyxtext.validation.config.ConfigurableValidationMessageAcceptor)

Example 2 with ValidationMessageAcceptor

use of org.eclipse.xtext.validation.ValidationMessageAcceptor in project xtext-core by eclipse.

the class XtextValidator method checkGeneratedPackage.

public void checkGeneratedPackage(GeneratedMetamodel metamodel, Diagnostician diagnostician, Map<?, ?> params) {
    EPackage pack = metamodel.getEPackage();
    if (pack != null) {
        Diagnostic packageValidationResult = diagnostician.validate(pack, params);
        ValidationMessageAcceptor filter = new AbstractValidationMessageAcceptor() {

            Set<Triple<EObject, EStructuralFeature, String>> accepted = Sets.newHashSet();

            @Override
            public void acceptInfo(String message, EObject object, EStructuralFeature feature, int index, String code, String... issueData) {
                if (accepted.add(Tuples.create(object, feature, message))) {
                    XtextValidator.this.getMessageAcceptor().acceptInfo(message, object, feature, index, code, issueData);
                }
            }

            @Override
            public void acceptWarning(String message, EObject object, EStructuralFeature feature, int index, String code, String... issueData) {
                if (accepted.add(Tuples.create(object, feature, message))) {
                    XtextValidator.this.getMessageAcceptor().acceptWarning(message, object, feature, index, code, issueData);
                }
            }

            @Override
            public void acceptError(String message, EObject object, EStructuralFeature feature, int index, String code, String... issueData) {
                if (accepted.add(Tuples.create(object, feature, message))) {
                    XtextValidator.this.getMessageAcceptor().acceptError(message, object, feature, index, code, issueData);
                }
            }
        };
        propageValidationResult(packageValidationResult, metamodel, filter);
    }
}
Also used : AbstractValidationMessageAcceptor(org.eclipse.xtext.validation.AbstractValidationMessageAcceptor) Set(java.util.Set) TreeSet(java.util.TreeSet) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) HashSet(java.util.HashSet) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) ValidationMessageAcceptor(org.eclipse.xtext.validation.ValidationMessageAcceptor) AbstractValidationMessageAcceptor(org.eclipse.xtext.validation.AbstractValidationMessageAcceptor) EObject(org.eclipse.emf.ecore.EObject) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) Diagnostic(org.eclipse.emf.common.util.Diagnostic) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

ValidationMessageAcceptor (org.eclipse.xtext.validation.ValidationMessageAcceptor)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 ConfigurableValidationMessageAcceptor (net.vtst.eclipse.easyxtext.validation.config.ConfigurableValidationMessageAcceptor)1 Diagnostic (org.eclipse.emf.common.util.Diagnostic)1 EObject (org.eclipse.emf.ecore.EObject)1 EPackage (org.eclipse.emf.ecore.EPackage)1 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1 AbstractValidationMessageAcceptor (org.eclipse.xtext.validation.AbstractValidationMessageAcceptor)1