Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ assertj_version = 3.21.0
junit_version = 5.8.2

# Version of published artifacts
version = 7.8.73
version = 7.8.75
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.monticore.lang.sysmlv2._lsp.commands;

import de.monticore.lang.sysmlbasis._ast.ASTModifierBuilder;

import de.monticore.lang.sysmlparts._ast.ASTEnumDefBuilder;
import de.monticore.lang.sysmlparts._ast.ASTPartDef;
import de.monticore.lang.sysmlparts._ast.ASTPartDefBuilder;
Expand Down Expand Up @@ -58,13 +58,13 @@ public Boolean execute(String[] args) {
.addPortUsage("port1", booleanType)
.addEmptyStateUsage(modelName);
if (args.length == 4) {
automatonBuilder.addRefinement(new ASTPartDefBuilder().setName(args[3]).setModifier(new ASTModifierBuilder().build()).build());
automatonBuilder.addRefinement(new ASTPartDefBuilder().setName(args[3]).setModifier(SysMLv2Mill.modifierBuilder().build()).build());
}
partDef = automatonBuilder.build();
model.addSysMLElement(new ASTPartDefBuilder(partDef).build());

} else if (modelType.equalsIgnoreCase("Port Definition")) {
var portDef = new ASTPortDefBuilder().setName(modelName).setModifier(new ASTModifierBuilder().build()).build();
var portDef = new ASTPortDefBuilder().setName(modelName).setModifier(SysMLv2Mill.modifierBuilder().build()).build();
model.addSysMLElement(portDef);

} else if (modelType.equalsIgnoreCase("Enum Definition")) {
Expand Down
72 changes: 0 additions & 72 deletions language/src/main/grammars/de/monticore/lang/SysMLBasis.mc4
Original file line number Diff line number Diff line change
Expand Up @@ -173,78 +173,6 @@ component grammar SysMLBasis

SysMLIdentifier = "<" Name ">" ;

/**
* P.27 of 2a-OMG_Systems_Modeling_Language.PDF (though only in relation to *packages*):
* "The visibility of the membership can be specified by placing one of the keywords public,
* protected or private before the public element declaration. If the membership is public (the default), then it is
* visible outside of the namespace. If it is private, then it is not visible."
* P.29 of 2a-OMG_Systems_Modeling_Language.PDF (now relating to *imports*):
* "The visibility of an import can be specified by placing the keyword public or private before the import
* declaration. If the import is public (the default), then all the imported memberships become public for the
* importing namespace. If import is private, then the imported memberships become private relative to the
* importing namespace"
* Nowhere is the use of visibility keywords such as public, private, protected explicitly documented for any other
* elements. There exists however examples of showing its use on attributes and calculations. We therefore assume
* these modifiers to be applicable to all elements of the SysML.
* P.43 of 2a-OMG_Systems_Modeling_Language.PDF:
* "There are a number of additional properties of a usage that can be flagged by adding specific keywords to its
* declaration. If present these are always specified in the following order, before the kind keyword in the usage
* declaration.
* 1. in, out, inout
* 2. abstract
* 3. readonly
* 4. derived
* 5. end
* 6. ref"
* It is unclear if an how these modifiers relate to the visibility modifiers above. Their order differs from the
* specification in at least two official examples (ItemTest.sysml and PartTest.sysml). We therefore implement all
* these modifiers as one group and do not enforce any ordering.
* P.119 of 2a-OMG_Systems_Modeling_Language.PDF (relating to *calculations*):
* "A calculation definition or usage is declared as an action definition or usage (see 7.16.2), but using the keyword
* calc instead of action. As for an action definition or usage, directed usages declared in the body of a calculation
* definition or usage are consider to be parameters. In addition, the result parameter for a calculation definition or
* usage can be declared as an out parameter using the keyword return instead of out"
* Examples show further use of "return" in analysis cases, verification cases, and functions. Seeing as it is an
* alternative keyword to "out", we decided to implement it as a modifier.
* P.56&57 of 2a-OMG_Systems_Modeling_Language.PDF (once relating to timeslice/snapshot, once relating to individual):
* "An occurrence usage (of any kind) can be declared as a <X> using the keyword <X>, placed immediately before the
* kind keyword of the declaration (after any of the other usage property keywords described in 7.6.3)."
* Section 7.6.3 describes on P.43 (see above) more Modifiers. We therefore chose to implement all three keywords as
* Modifiers.
* P.57 of 2a-OMG_Systems_Modeling_Language.PDF:
* "An event occurrence usage is declared like an occurrence usage, as described in 7.9.2, 7.9.3, and 7.9.4, but using the
* kind keyword event occurrence instead of just occurrence."
* While it seemingly only applies to "real occurences", re-implementing it for anonymous references seems tedious
* compared to simply declaring it as Modifier.
* P.48 of 2a-OMG_Systems_Modeling_Language.PDF:
* "A definition or usage is specified as a variation by placing the keyword variation before its kind keyword. A
* variation is always abstract, so the abstract keyword is not used on a variation."
* Since "abstract" is already mentioned, we chose to implement this as a Modifier
* Lastly, we add all remaining modifiers previously known from the UML: final, local, static.
*/
@Override
Modifier =
Stereotype?
( ["public"] | [public:"+"]
| ["private"] | [private:"-"]
| ["protected"] | [protected:"#"]
| ["abstract"]
| ["constant"]
| ["local"]
| ["derived"] | [derived:"/"]
| ["readonly"] | [readonly:"?"]
| ["static"]
| ["in"] | ["out"] | ["inout"] // default direction is "in"
| ["end"]
| ["ref"]
| ["return"] // only in calculation, analysis, verification, function
| ["timeslice"] // only in occurrences
| ["snapshot"] // only in occurrences
| ["individual"] // only in occurrences
| ["event"] // only in occurrences
| ["variation"]
| ["variant"]
)*;

UserDefinedKeyword =
{noSpace(2);} "#" MCQualifiedName ;
Expand Down
73 changes: 73 additions & 0 deletions language/src/main/grammars/de/monticore/lang/SysMLv2.mc4
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,79 @@ grammar SysMLv2 extends SysMLExpressions,
FractalLiteral implements NumericLiteral =
{ noSpace(2) }? "." post:Digits;

/**
* P.27 of 2a-OMG_Systems_Modeling_Language.PDF (though only in relation to *packages*):
* "The visibility of the membership can be specified by placing one of the keywords public,
* protected or private before the public element declaration. If the membership is public (the default), then it is
* visible outside of the namespace. If it is private, then it is not visible."
* P.29 of 2a-OMG_Systems_Modeling_Language.PDF (now relating to *imports*):
* "The visibility of an import can be specified by placing the keyword public or private before the import
* declaration. If the import is public (the default), then all the imported memberships become public for the
* importing namespace. If import is private, then the imported memberships become private relative to the
* importing namespace"
* Nowhere is the use of visibility keywords such as public, private, protected explicitly documented for any other
* elements. There exists however examples of showing its use on attributes and calculations. We therefore assume
* these modifiers to be applicable to all elements of the SysML.
* P.43 of 2a-OMG_Systems_Modeling_Language.PDF:
* "There are a number of additional properties of a usage that can be flagged by adding specific keywords to its
* declaration. If present these are always specified in the following order, before the kind keyword in the usage
* declaration.
* 1. in, out, inout
* 2. abstract
* 3. readonly
* 4. derived
* 5. end
* 6. ref"
* It is unclear if an how these modifiers relate to the visibility modifiers above. Their order differs from the
* specification in at least two official examples (ItemTest.sysml and PartTest.sysml). We therefore implement all
* these modifiers as one group and do not enforce any ordering.
* P.119 of 2a-OMG_Systems_Modeling_Language.PDF (relating to *calculations*):
* "A calculation definition or usage is declared as an action definition or usage (see 7.16.2), but using the keyword
* calc instead of action. As for an action definition or usage, directed usages declared in the body of a calculation
* definition or usage are consider to be parameters. In addition, the result parameter for a calculation definition or
* usage can be declared as an out parameter using the keyword return instead of out"
* Examples show further use of "return" in analysis cases, verification cases, and functions. Seeing as it is an
* alternative keyword to "out", we decided to implement it as a modifier.
* P.56&57 of 2a-OMG_Systems_Modeling_Language.PDF (once relating to timeslice/snapshot, once relating to individual):
* "An occurrence usage (of any kind) can be declared as a <X> using the keyword <X>, placed immediately before the
* kind keyword of the declaration (after any of the other usage property keywords described in 7.6.3)."
* Section 7.6.3 describes on P.43 (see above) more Modifiers. We therefore chose to implement all three keywords as
* Modifiers.
* P.57 of 2a-OMG_Systems_Modeling_Language.PDF:
* "An event occurrence usage is declared like an occurrence usage, as described in 7.9.2, 7.9.3, and 7.9.4, but using the
* kind keyword event occurrence instead of just occurrence."
* While it seemingly only applies to "real occurences", re-implementing it for anonymous references seems tedious
* compared to simply declaring it as Modifier.
* P.48 of 2a-OMG_Systems_Modeling_Language.PDF:
* "A definition or usage is specified as a variation by placing the keyword variation before its kind keyword. A
* variation is always abstract, so the abstract keyword is not used on a variation."
* Since "abstract" is already mentioned, we chose to implement this as a Modifier
* Lastly, we add all remaining modifiers previously known from the UML: final, local, static.
*/
@Override
Modifier =
Stereotype?
( ["public"] | [public:"+"]
| ["private"] | [private:"-"]
| ["protected"] | [protected:"#"]
| ["abstract"]
| ["constant"]
| ["local"]
| ["derived"] | [derived:"/"]
| ["readonly"] | [readonly:"?"]
| ["static"]
| ["in"] | ["out"] | ["inout"] // default direction is "in"
| ["end"]
| ["ref"]
| ["return"] // only in calculation, analysis, verification, function
| ["timeslice"] // only in occurrences
| ["snapshot"] // only in occurrences
| ["individual"] // only in occurrences
| ["event"] // only in occurrences
| ["variation"]
| ["variant"]
)*;

/**
* A user-defined keyword for semantic metadata may also be used to declare a
* definition or usage without using any language-defined keyword.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import de.monticore.ast.Comment;
import de.monticore.expressions.expressionsbasis._ast.ASTLiteralExpressionBuilder;
import de.monticore.lang.sysmlbasis._ast.ASTDefaultValueBuilder;
import de.monticore.lang.sysmlbasis._ast.ASTModifierBuilder;
import de.monticore.lang.sysmlv2._ast.ASTModifierBuilder;
import de.monticore.lang.sysmlconstraints._ast.ASTConstraintUsage;
import de.monticore.lang.sysmlconstraints._ast.ASTConstraintUsageBuilder;
import de.monticore.lang.sysmlparts._symboltable.PartDefSymbol;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public void check(ASTCalcDef node) {
traverser.add4SysMLBasis(new SysMLBasisVisitor2() {
@Override
public void visit(ASTAnonymousUsage retNode) {
if (retNode.getModifier().isReturn() && retNode.getEnclosingScope() == node.getSpannedScope()) {
var modifier = retNode.getModifier();
if (modifier instanceof de.monticore.lang.sysmlv2._ast.ASTModifier
&& ((de.monticore.lang.sysmlv2._ast.ASTModifier) modifier).isReturn()
&& retNode.getEnclosingScope() == node.getSpannedScope()) {
returnCount[0]++;
}
}
Expand All @@ -31,7 +34,10 @@ public void visit(ASTAnonymousUsage retNode) {
traverser.add4SysMLParts(new SysMLPartsVisitor2() {
@Override
public void visit(ASTAttributeUsage retNode) {
if (retNode.getModifier().isReturn() && retNode.getEnclosingScope() == node.getSpannedScope()) {
var modifier = retNode.getModifier();
if (modifier instanceof de.monticore.lang.sysmlv2._ast.ASTModifier
&& ((de.monticore.lang.sysmlv2._ast.ASTModifier) modifier).isReturn()
&& retNode.getEnclosingScope() == node.getSpannedScope()) {
returnCount[0]++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public void check(ASTCalcUsage node) {
traverser.add4SysMLBasis(new SysMLBasisVisitor2() {
@Override
public void visit(ASTAnonymousUsage retNode) {
if (retNode.getModifier().isReturn() && retNode.getEnclosingScope() == node.getSpannedScope()) {
var modifier = retNode.getModifier();
if (modifier instanceof de.monticore.lang.sysmlv2._ast.ASTModifier
&& ((de.monticore.lang.sysmlv2._ast.ASTModifier) modifier).isReturn()
&& retNode.getEnclosingScope() == node.getSpannedScope()) {
returnCount[0]++;
}
}
Expand All @@ -31,7 +34,10 @@ public void visit(ASTAnonymousUsage retNode) {
traverser.add4SysMLParts(new SysMLPartsVisitor2() {
@Override
public void visit(ASTAttributeUsage retNode) {
if (retNode.getModifier().isReturn() && retNode.getEnclosingScope() == node.getSpannedScope()) {
var modifier = retNode.getModifier();
if (modifier instanceof de.monticore.lang.sysmlv2._ast.ASTModifier
&& ((de.monticore.lang.sysmlv2._ast.ASTModifier) modifier).isReturn()
&& retNode.getEnclosingScope() == node.getSpannedScope()) {
returnCount[0]++;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.sysmlv2.cocos;

import de.monticore.lang.sysmlbasis._ast.ASTModifier;
import de.monticore.lang.sysmlbasis._ast.ASTEndpoint;
import de.monticore.lang.sysmlbasis._ast.ASTSysMLTyping;
import de.monticore.lang.sysmlparts._ast.ASTAttributeUsage;
import de.monticore.lang.sysmlparts._ast.ASTConnectionUsage;
import de.monticore.lang.sysmlparts._cocos.SysMLPartsASTConnectionUsageCoCo;
import de.monticore.lang.sysmlparts._symboltable.*;
import de.monticore.symboltable.modifiers.AccessModifier;
import de.monticore.umlmodifier._ast.ASTModifier;
import de.se_rwth.commons.logging.Log;

import java.util.List;
Expand Down Expand Up @@ -180,21 +180,30 @@ protected ASTModifier getModifiersFromPortUsageSymbol(PortUsageSymbol symbol) {

protected boolean portIsInput(PortUsageSymbol symbol) {
ASTModifier mods = getModifiersFromPortUsageSymbol(symbol);
boolean portIsInAndNotConjugated = mods.isIn() && !portIsConjugated(symbol);
boolean portIsOutAndConjugated = mods.isOut() && portIsConjugated(symbol);
return (portIsInAndNotConjugated || portIsOutAndConjugated);
if (mods instanceof de.monticore.lang.sysmlv2._ast.ASTModifier) {
var sysMLModifier = (de.monticore.lang.sysmlv2._ast.ASTModifier) mods;
boolean portIsInAndNotConjugated = sysMLModifier.isIn() && !portIsConjugated(symbol);
boolean portIsOutAndConjugated = sysMLModifier.isOut() && portIsConjugated(symbol);
return (portIsInAndNotConjugated || portIsOutAndConjugated);
}
return false;
}

protected boolean portIsOutput(PortUsageSymbol symbol) {
ASTModifier mods = getModifiersFromPortUsageSymbol(symbol);
boolean portIsOutAndNotConjugated = mods.isOut() && !portIsConjugated(symbol);
boolean portIsInAndConjugated = mods.isIn() && portIsConjugated(symbol);
return (portIsOutAndNotConjugated || portIsInAndConjugated);
if (mods instanceof de.monticore.lang.sysmlv2._ast.ASTModifier) {
var sysMLModifier = (de.monticore.lang.sysmlv2._ast.ASTModifier) mods;
boolean portIsOutAndNotConjugated = sysMLModifier.isOut() && !portIsConjugated(symbol);
boolean portIsInAndConjugated = sysMLModifier.isIn() && portIsConjugated(symbol);
return (portIsOutAndNotConjugated || portIsInAndConjugated);
}
return false;
}

protected boolean portIsInOutput(PortUsageSymbol symbol) {
ASTModifier mods = getModifiersFromPortUsageSymbol(symbol);
return mods.isInout();
return mods instanceof de.monticore.lang.sysmlv2._ast.ASTModifier
&& ((de.monticore.lang.sysmlv2._ast.ASTModifier) mods).isInout();
}

protected boolean portIsConjugated(PortUsageSymbol symbol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import de.monticore.lang.sysmlbasis._ast.ASTAnonymousReference;
import de.monticore.lang.sysmlbasis._ast.ASTAnonymousUsage;
import de.monticore.lang.sysmlbasis._ast.ASTModifier;
import de.monticore.lang.sysmlbasis._visitor.SysMLBasisVisitor2;
import de.monticore.lang.sysmlparts._ast.ASTAttributeUsage;
import de.monticore.lang.sysmlparts._visitor.SysMLPartsVisitor2;
import de.monticore.umlmodifier._ast.ASTModifier;

/**
* Sets the isIn / isOut properties of symbols based on Modifiers parsed to the AST.
Expand All @@ -17,15 +17,23 @@ public class DirectionCompleter implements SysMLBasisVisitor2, SysMLPartsVisitor
* yields true.
*/
protected boolean isIn(ASTModifier modifier) {
return modifier.isIn() || !modifier.isOut() && !modifier.isReturn();
if (modifier instanceof de.monticore.lang.sysmlv2._ast.ASTModifier) {
var sysMLModifier = (de.monticore.lang.sysmlv2._ast.ASTModifier) modifier;
return sysMLModifier.isIn() || !sysMLModifier.isOut() && !sysMLModifier.isReturn();
}
return true;
}

/**
* Returns whether this is an input. Defaults to {@code false} if no direction was explicitly set. The keyword "inout"
* yields true. The keyword "return" is treated as output.
*/
protected boolean isOut(ASTModifier modifier) {
return modifier.isOut() || modifier.isInout() || modifier.isReturn();
if (modifier instanceof de.monticore.lang.sysmlv2._ast.ASTModifier) {
var sysMLModifier = (de.monticore.lang.sysmlv2._ast.ASTModifier) modifier;
return sysMLModifier.isOut() || sysMLModifier.isInout() || sysMLModifier.isReturn();
}
return false;
}

@Override
Expand Down
Loading
Loading