Skip to content

Commit 918d393

Browse files
flatombeAxelRICHARD
authored andcommitted
[2011] Improve SysML validation to be more modular
Notes: * Had to tweak JDT formatter setting "org.eclipse.jdt.core.formatter.alignment_for_enum_constants" so we get a newline for each enum literal even if it does not have Javadoc. * Had to tweak JDT formatter setting "org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" to be in-line with the formatting expected by Checkstyle. Bug: #2011 Signed-off-by: Florent Latombe <florent.latombe@obeo.fr>
1 parent 60c23eb commit 918d393

19 files changed

Lines changed: 2756 additions & 615 deletions

CHANGELOG.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ The following methods have been added:
2323
- https://github.com/eclipse-syson/syson/issues/1988[#1988] [syson] Extract Elasticsearch container initialization in a dedicated abstract test class.
2424
The property `SysONTestsProperties#ELASTICSEARCH` has been removed, tests that require Elasticsearch should extend `AbstractIntegrationTestsWithElasticsearch`.
2525

26+
- [validation] The following classes have been renamed, and some of them reworked:
27+
28+
** `org.eclipse.syson.sysml.validation.SysMLv2ValidationRules`: turned into enumeration `org.eclipse.syson.sysml.validation.rules.SysMLValidationRule`.
29+
** `org.eclipse.syson.sysml.validation.SysMLv2ValidationService`: renamed into `org.eclipse.syson.sysml.validation.SysONSysMLValidationService`.
30+
** `org.eclipse.syson.sysml.validation.SysMLv2Validator`: renamed into `org.eclipse.syson.sysml.validation.SysMLValidator`.
31+
** `org.eclipse.syson.sysml.validation.ValidationRule`: renamed into `org.eclipse.syson.sysml.validation.rules.ValidationRule`, extracted its methods into interface `org.eclipse.syson.sysml.validation.rules.api.ISysMLValidationRule` and added `int getSeverity()` to represent the severity of the rule.
32+
** `org.eclipse.syson.sysml.validation.SysONQueryServices`: renamed into `org.eclipse.syson.sysml.validation.rules.SysMLValidationRuleQueryServices`.
33+
** `org.eclipse.syson.sysml.validation.SysMLv2ValidatorConfiguration`: renamed into `org.eclipse.syson.sysml.validation.SysMLValidatorRegistrationConfiguration` and now expects an injected `org.eclipse.syson.sysml.validation.rules.api.ISysMLValidationRulesProvider`, for which SysON provides default implementation `org.eclipse.syson.sysml.validation.rules.SysONValidationRulesProvider`.
34+
35+
2636
=== Dependency update
2737

2838
- [releng] Update to https://github.com/eclipse-sirius/sirius-web[Sirius Web 2026.1.3]
@@ -88,6 +98,16 @@ Instead SysON will now use the inherited elements without redefining them first,
8898
- https://github.com/eclipse-syson/syson/issues/1994[1994] [syson] Add support for excluding libraries in the _Search_ view.
8999
The _Search in libraries_ toggle in the _Search_ view allows to include elements from user and standard libraries in the search.
90100
This toggle is de-activated by default.
101+
- https://github.com/eclipse-syson/syson/issues/2011[#2011] [validation] Improve SysML validation to be more modular:
102+
Add interface `ISysMLValidationRulesProvider` in charge of providing the validation rules to execute on SysML models.
103+
The default implementation, `SysONValidationRulesProvider` always provides all validation rules from the SysML specification.
104+
Downstream applications can override this to choose (possibly dynamically) which rules get executed.
105+
Add interface `ISysMLValidationRule` for the validation rules supported by our validation service, so downstream applications can easily execute their custom rules without having to implement their own service.
106+
The SysML validation rules from the specification have been turned into literals of enumeration `SysMLValidationRule` that implements this interface.
107+
Add a few simple unit tests to help maintain this enumeration.
108+
Add possibility for validation rules to specify their severity ; the SysML rules from the specification remain as WARNINGs for now.
109+
Tweak the diagnostic messages to help users understand where the erroneous element is in their editing context.
110+
Make sure diagnostics are sorted according to their validated element and its containing document.
91111

92112
=== New features
93113

backend/application/syson-sysml-validation/.settings/org.eclipse.jdt.core.prefs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
145145
org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
146146
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
147147
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0
148-
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
148+
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=17
149149
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
150150
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
151151
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow=0
@@ -229,7 +229,7 @@ org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
229229
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
230230
org.eclipse.jdt.core.formatter.compact_else_if=true
231231
org.eclipse.jdt.core.formatter.continuation_indentation=2
232-
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
232+
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=1
233233
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
234234
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
235235
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false

backend/application/syson-sysml-validation/src/main/java/org/eclipse/syson/sysml/validation/SysMLv2ValidatorConfiguration.java renamed to backend/application/syson-sysml-validation/src/main/java/org/eclipse/syson/sysml/validation/SysMLValidatorRegistrationConfiguration.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2025 Obeo.
2+
* Copyright (c) 2025, 2026 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@
1616

1717
import org.eclipse.emf.ecore.EValidator.Registry;
1818
import org.eclipse.syson.sysml.SysmlPackage;
19+
import org.eclipse.syson.sysml.validation.rules.api.IValidationRulesProvider;
1920
import org.springframework.context.annotation.Configuration;
2021

2122
import jakarta.annotation.PostConstruct;
@@ -24,18 +25,22 @@
2425
* Configuration of the SysMLv2 Validator.
2526
*
2627
* @author arichard
28+
* @see SysONSysMLValidationService
2729
*/
2830
@Configuration
29-
public class SysMLv2ValidatorConfiguration {
31+
public class SysMLValidatorRegistrationConfiguration {
32+
33+
private final IValidationRulesProvider validationRulesProvider;
3034

3135
private final Registry eValidatorRegistry;
3236

33-
public SysMLv2ValidatorConfiguration(Registry eValidatorRegistry) {
37+
public SysMLValidatorRegistrationConfiguration(final IValidationRulesProvider validationRulesProvider, final Registry eValidatorRegistry) {
38+
this.validationRulesProvider = Objects.requireNonNull(validationRulesProvider);
3439
this.eValidatorRegistry = Objects.requireNonNull(eValidatorRegistry);
3540
}
3641

3742
@PostConstruct
3843
public void registerDomainValidator() {
39-
this.eValidatorRegistry.put(SysmlPackage.eINSTANCE, new SysMLv2Validator());
44+
this.eValidatorRegistry.put(SysmlPackage.eINSTANCE, new SysONSysMLValidator(this.validationRulesProvider));
4045
}
4146
}

0 commit comments

Comments
 (0)