Class ValidationUtils
java.lang.Object
net.ssehub.easy.dslCore.validation.ValidationUtils
Some validation helper methods.
- Author:
- Holger Eichelberger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDefines a validation callback to provide the information required for validation.static enumDefines common xText error types.static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static ValidationUtils.ValidationModeprivate static booleanPerform Xtext validation or emulate problem markers on editor save (partial parsing problem). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds afile, usually a model location, as information/prefix which files to validate/process as resources.static <R extends org.eclipse.emf.ecore.EObject,T>
voidcheckModel(R unit, ValidationUtils.IModelValidationCallback<R, T> callback, boolean debug) Checks the model on top-level element layer on-save through editor hook, if enabled.static <R extends org.eclipse.emf.ecore.EObject,T>
voidcheckModelFromValidation(R unit, ValidationUtils.IModelValidationCallback<R, T> callback, boolean debug) Checks the model on top-level element layer, called through builder validation.private static org.eclipse.emf.common.util.DiagnosticcreateDiagnostic(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.private static <R extends org.eclipse.emf.ecore.EObject,T>
voiddoCheckModel(R unit, ValidationUtils.IModelValidationCallback<R, T> callback, boolean debug) Checks the model on top-level element layer.static booleanenableOnSave(boolean enable) Enables/disables validation on save, e.g., to handle xText conflicts.static booleanexcludeBinTarget(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.private static final net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLoggerReturns the responsible logger.Returns the validation mode.static booleanisInPath(org.eclipse.emf.common.util.URI uri) Returns whether the given EMF resource URI is in a path specified byaddPath(File).static booleanstatic org.eclipse.emf.common.util.DiagnosticprocessMessage(Message message) Processes amessage.static voidprocessMessages(TranslationResult<?> result, org.eclipse.emf.common.util.BasicDiagnostic diagnostic) Processes messages.static voidremovePath(File file) Removes afile, usually a model location, as information/prefix which files to validate/process as resources.private static inttoDiagnosticSeverity(org.eclipse.xtext.diagnostics.Severity severity) Converts an xText severity into a diagnostic severity.private static StringTurns a file into a matchable URI prefix.
-
Field Details
-
performValidationOnSave
private static boolean performValidationOnSavePerform Xtext validation or emulate problem markers on editor save (partial parsing problem). -
pathPrefixes
-
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
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 fromdiagnostic- the diagnostic instance to add messages to
-
processMessage
Processes amessage.- 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 diagnosticmessage- the messageobject- the causing EMF element in the parse treefeature- the causing grammar featureindex- 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:
truefor exclusion or null,falseelse
-
toPrefix
Turns a file into a matchable URI prefix.- Parameters:
file- the file- Returns:
- the prefix
-
addPath
Adds afile, 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
Removes afile, 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 byaddPath(File).- Parameters:
uri- the URI to look for- Returns:
truefor in path,falseelse
-
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 typeT- the transformation result type- Parameters:
unit- the variability unit to start tests withcallback- the callback providing relevant model informationdebug- 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 typeT- the transformation result type- Parameters:
unit- the variability unit to start tests withcallback- the callback providing relevant model informationdebug- 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 typeT- the transformation result type- Parameters:
unit- the variability unit to start tests withcallback- the callback providing relevant model informationdebug- shall debug information be emitted
-