Class ValidationUtils

java.lang.Object
net.ssehub.easy.dslCore.validation.ValidationUtils

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

    • performValidationOnSave

      private static boolean performValidationOnSave
      Perform Xtext validation or emulate problem markers on editor save (partial parsing problem).
    • pathPrefixes

      private static List<String> pathPrefixes
    • mode

      private static ValidationUtils.ValidationMode mode
  • Constructor Details

    • ValidationUtils

      public ValidationUtils()
  • Method Details

    • enableOnSave

      public static boolean enableOnSave(boolean enable)
      Enables/disables validation on save, e.g., to handle xText conflicts.
      Parameters:
      enable - enable or disable
      Returns:
      the previous state
    • isOnSaveEnabled

      public static boolean isOnSaveEnabled()
    • getValidationMode

      public static ValidationUtils.ValidationMode getValidationMode()
      Returns the validation mode.
      Returns:
      the mode
    • 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, String message, org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature feature, int index, String code, 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
    • getLogger

      private static final net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger getLogger()
      Returns the responsible logger.
      Returns:
      the responsible logger
    • excludeBinTarget

      public static boolean excludeBinTarget(org.eclipse.emf.common.util.URI uri)
      Returns whether a (model) URI is excluded as it is located in "bin" or "target" to speed up building/validation.
      Parameters:
      uri - the URI to check, may be null
      Returns:
      true for exclusion or null, false else
    • toPrefix

      private static String toPrefix(File file)
      Turns a file into a matchable URI prefix.
      Parameters:
      file - the file
      Returns:
      the prefix
    • addPath

      public static void addPath(File file)
      Adds a file, usually a model location, as information/prefix which files to validate/process as resources. Shall be called from Eclipse plugin code only.
      Parameters:
      file - the file to add
    • removePath

      public static void removePath(File file)
      Removes a file, usually a model location, as information/prefix which files to validate/process as resources. Shall be called from Eclipse plugin code only.
      Parameters:
      file - the file to add
    • isInPath

      public static boolean isInPath(org.eclipse.emf.common.util.URI uri)
      Returns whether the given EMF resource URI is in a path specified by addPath(File).
      Parameters:
      uri - the URI to look for
      Returns:
      true for in path, false else
    • doCheckModel

      private static <R extends org.eclipse.emf.ecore.EObject, T> void doCheckModel(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
    • 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 on-save through editor hook, if enabled.
      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
    • checkModelFromValidation

      public static <R extends org.eclipse.emf.ecore.EObject, T> void checkModelFromValidation(R unit, ValidationUtils.IModelValidationCallback<R,T> callback, boolean debug)
      Checks the model on top-level element layer, called through builder validation.
      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