Repository navigation
Conversation
Bug: eclipse-syson#2675 Signed-off-by: Yvan Lussaud <yvan.lussaud@obeo.fr>
| /** | ||
| * The {@link Diagnostic} {@link List}. | ||
| */ | ||
| private List<Diagnostic> diagnostics; |
There was a problem hiding this comment.
what is the difference between diagnostics and internalDiagnostics?
why diagnostics was useless until now?
| <ownedRelationship xsi:type="sysml:OwningMembership"> | ||
| <ownedRelatedElement xsi:type="sysml:AttributeUsage" declaredName="x"> | ||
| <ownedRelationship xsi:type="sysml:FeatureValue"> | ||
| <ownedRelatedElement xsi:type="sysml:LiteralInteger"/> |
There was a problem hiding this comment.
Omit the overflowing initializer
Import package P { attribute x = 9223372036854775807; attribute y = 7; }. The importer warns about the overflow, then gives x a value of 0. y keeps its value of 7.
- Cause — Recovery leaves a
LiteralIntegerinside the initializer. Its unset primitivevaluereads as0, and this fixture expects that literal to be retained. - Fix — Omit the failed initializer while keeping the attribute and its siblings. Assert in the regression test that
xhas no initializer andystill has value7. - If skipped — The imported model contains a numeric value the author never supplied. Downstream consumers can use or export it as an ordinary zero.
| literalReal: | ||
| {start(_localctx, literalRational__());} ( | ||
| (realValue {set(literalRational_Value(), fromString(eDouble(), currentContextText(_localctx)));}) | ||
| (realValue {setFromContext(literalRational_Value(), _localctx);}) |
There was a problem hiding this comment.
Exclude hidden notes from real-number conversion
Import package P { attribute x = 1 //* note */ .2; }. The grammar accepts the hidden note between the numeric tokens, but the importer warns and gives x a value of 0.0. Removing the note gives 1.2.
- Cause — The source interval already included hidden tokens before this PR. The new recovery path sends the note text to the converter and then imports the default value when conversion fails.
- Fix — Build the conversion string from the numeric rule's default-channel tokens and add this case to the parser fixtures with an expected value of
1.2. - If skipped — A note can change an otherwise representable number in the imported model.
| } catch (Exception e) { | ||
| String message = ctx.getStart().getLine() + ":" + ctx.getStart().getCharPositionInLine() + " Unable to set " + attribute.getEContainingClass().getName() + "." + attribute.getName() | ||
| + " to " + text; | ||
| this.diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR, null, 0, message, null)); |
There was a problem hiding this comment.
Report conversion failures through the configured error listeners
Run the generated parser directly, with the same internal diagnostic setup used by SerializerRoundTripTestSupport:
var parser = new SysMLParser(new CommonTokenStream(
new SysMLLexer(CharStreams.fromString("2147483648"))));
parser.setInternalDiagnostics(new ArrayList<>());
parser.literalInteger();The conversion error is caught, then reporting it throws a NullPointerException. Through SysMLModelParser, the diagnostic is returned, but its getData() is empty even though the line and column are known.
- Cause — The catch block writes to a separate list that only the wrapper initializes, and puts the location in the message string.
- Fix — Dispatch the diagnostic through the existing error listeners with the literal's start token, line, and column. Dispatch directly so conversion failures do not trigger syntax recovery.
- If skipped — Direct parser callers still abort on overflow, and callers that read structured diagnostic locations have to parse the message to locate the literal.
Bug: #2675
PLEASE READ ALL ITEMS AND CHECK ONLY RELEVANT CHECKBOXES BELOW
Auto review
Project management
queue:andreview-window:labels been added to the pull request? (In case of doubt, start with the labelsqueue: triageandreview-window: unscheduled)package:,type:)Changelog and release notes
CHANGELOG.adoc+doc/content/modules/user-manual/pages/release-notes/YYYY.MM.0.adocbeen updated to reference the relevant issues?CHANGELOG.adoc?CHANGELOG.adoc?doc/content/modules/user-manual/pages/release-notes/YYYY.MM.0.adoc?Key highlightssection indoc/content/modules/user-manual/pages/release-notes/YYYY.MM.0.adoc?Documentation
Tests