Class ValidationUtils


  • public class ValidationUtils
    extends java.lang.Object
    Some validation helper methods.
    Author:
    Holger Eichelberger
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean PERFORM_XTEXT_VALIDATION
      Perform Xtext validation or emulate problem markers on editor save (partial parsing problem).
    • Constructor Summary

      Constructors 
      Constructor Description
      ValidationUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <R extends org.eclipse.emf.ecore.EObject,​T>
      void
      checkModel​(R unit, ValidationUtils.IModelValidationCallback<R,​T> callback, boolean debug)
      Checks the model on top-level element layer.
      private static org.eclipse.emf.common.util.Diagnostic createDiagnostic​(org.eclipse.xtext.diagnostics.Severity severity, java.lang.String message, org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature feature, int index, java.lang.String code, java.lang.String... issueData)
      Creates an EMF Eclipse diagnostic instance.
      private static EASyLoggerFactory.EASyLogger getLogger()
      Returns the responsible logger.
      static org.eclipse.emf.common.util.Diagnostic processMessage​(Message message)
      Processes a message.
      static void processMessages​(TranslationResult<?> result, org.eclipse.emf.common.util.BasicDiagnostic diagnostic)
      Processes messages.
      private static int toDiagnosticSeverity​(org.eclipse.xtext.diagnostics.Severity severity)
      Converts an xText severity into a diagnostic severity.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PERFORM_XTEXT_VALIDATION

        public static final boolean PERFORM_XTEXT_VALIDATION
        Perform Xtext validation or emulate problem markers on editor save (partial parsing problem).
        See Also:
        Constant Field Values
    • Constructor Detail

      • ValidationUtils

        public ValidationUtils()
    • Method Detail

      • processMessages

        public static void processMessages​(TranslationResult<?> result,
                                           org.eclipse.emf.common.util.BasicDiagnostic diagnostic)
        Processes messages.
        Parameters:
        result - the translation result to take the messages from
        diagnostic - the diagnostic instance to add messages to
      • processMessage

        public static org.eclipse.emf.common.util.Diagnostic processMessage​(Message message)
        Processes a message.
        Parameters:
        message - the message to be processed
        Returns:
        the related Eclipse diagnosic instance
      • createDiagnostic

        private static org.eclipse.emf.common.util.Diagnostic createDiagnostic​(org.eclipse.xtext.diagnostics.Severity severity,
                                                                               java.lang.String message,
                                                                               org.eclipse.emf.ecore.EObject object,
                                                                               org.eclipse.emf.ecore.EStructuralFeature feature,
                                                                               int index,
                                                                               java.lang.String code,
                                                                               java.lang.String... issueData)
        Creates an EMF Eclipse diagnostic instance.
        Parameters:
        severity - the severity of the diagnostic
        message - the message
        object - the causing EMF element in the parse tree
        feature - the causing grammar feature
        index - an optional index value (aka code)
        code - a textual description of the code (may be null)
        issueData - optional user specific data
        Returns:
        the created diagnostic element
      • toDiagnosticSeverity

        private static int toDiagnosticSeverity​(org.eclipse.xtext.diagnostics.Severity severity)
        Converts an xText severity into a diagnostic severity.
        Parameters:
        severity - the xText severity
        Returns:
        the diagnostic severity
      • checkModel

        public static <R extends org.eclipse.emf.ecore.EObject,​T> void checkModel​(R unit,
                                                                                        ValidationUtils.IModelValidationCallback<R,​T> callback,
                                                                                        boolean debug)
        Checks the model on top-level element layer.
        Type Parameters:
        R - the model root type
        T - the transformation result type
        Parameters:
        unit - the variability unit to start tests with
        callback - the callback providing relevant model information
        debug - shall debug information be emitted