Skip to content

Commit 234ab2e

Browse files
committed
Update CoCo SourcePositions
1 parent 6599cd9 commit 234ab2e

File tree

9 files changed

+51
-47
lines changed

9 files changed

+51
-47
lines changed

src/main/java/de/monticore/scbasis/_cocos/AnteBlockOnlyWithInitialStateModifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class AnteBlockOnlyWithInitialStateModifier implements SCBasisASTSCStateC
2121
public void check(ASTSCState node) {
2222
if (node.isPresentSCSAnte() && !node.getSCModifier().isInitial()) {
2323
Log.error(ERROR_CODE + " " + String.format(MESSAGE, node.getName()),
24-
node.get_SourcePositionStart()
24+
node.get_SourcePositionStart(), node.get_SourcePositionEnd()
2525
);
2626
}
2727
}

src/main/java/de/monticore/scbasis/_cocos/AtLeastOneInitialState.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@
88
import de.se_rwth.commons.logging.Log;
99

1010
public class AtLeastOneInitialState implements SCBasisASTStatechartCoCo {
11-
11+
1212
protected SCBasisTraverser t;
13-
14-
public AtLeastOneInitialState (){
13+
14+
public AtLeastOneInitialState() {
1515
super();
16-
this.t = SCBasisMill.traverser();
16+
this.t = SCBasisMill.traverser();
1717
}
18-
19-
public AtLeastOneInitialState (SCBasisTraverser traverser){
18+
19+
public AtLeastOneInitialState(SCBasisTraverser traverser) {
2020
super();
2121
this.t = traverser;
2222
}
23-
23+
2424
public static final String ERROR_CODE = "0xCC102";
25-
25+
2626
@Override
2727
public void check(ASTStatechart node) {
2828
StateCollector collector = new StateCollector();
2929
t.add4SCBasis(collector);
3030
node.accept(t);
31-
if(collector.getStates(0).stream().noneMatch(x -> x.getSCModifier().isInitial())){
32-
Log.error(ERROR_CODE + " Statecharts need at least one initial state.",
33-
node.get_SourcePositionStart());
31+
if (collector.getStates(0).stream().noneMatch(x -> x.getSCModifier().isInitial())) {
32+
Log.error(ERROR_CODE + " Statecharts need at least one initial state.",
33+
node.get_SourcePositionStart(), node.get_SourcePositionEnd());
3434
}
3535
}
3636
}

src/main/java/de/monticore/scbasis/_cocos/CapitalStateNames.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
import de.se_rwth.commons.logging.Log;
66

77
public class CapitalStateNames implements SCBasisASTSCStateCoCo {
8-
8+
99
public static final String ERROR_CODE = "0xCC105";
10-
11-
@Override public void check(ASTSCState node) {
10+
11+
@Override
12+
public void check(ASTSCState node) {
1213
if (Character.isLowerCase(node.getName().charAt(0))) {
13-
Log.warn(ERROR_CODE + " State " + node.getName() + " should start with a capital letter." );
14+
Log.warn(ERROR_CODE + " State " + node.getName() + " should start with a capital letter.",
15+
node.get_SourcePositionStart(), node.get_SourcePositionEnd());
1416
}
1517
}
1618
}

src/main/java/de/monticore/scbasis/_cocos/PackageCorrespondsToFolders.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
public class PackageCorrespondsToFolders implements SCBasisASTSCArtifactCoCo {
1313

1414
public static final String ERROR_CODE = "0xCC107";
15-
16-
protected static final String MESSAGE =
17-
" Package name '%s' does not correspond to the file path '%s'.";
15+
16+
protected static final String MESSAGE =
17+
" Package name '%s' does not correspond to the file path '%s'.";
1818

1919
@Override
2020
public void check(ASTSCArtifact node) {
2121
if (node.isPresentPackage()) {
2222
String packageName = node.getPackage().getQName();
2323
if (node.getFilePath() != null && !node.getFilePath().getParent().endsWith(Names.getPathFromPackage(packageName))) {
24-
Log.error(String.format(ERROR_CODE + MESSAGE, packageName, node.getFilePath().toString()));
24+
Log.error(String.format(ERROR_CODE + MESSAGE, packageName, node.getFilePath().toString()),
25+
node.getPackage().get_SourcePositionStart(), node.getPackage().get_SourcePositionEnd());
2526
}
2627
}
2728
}

src/main/java/de/monticore/scbasis/_cocos/UniqueStates.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,34 @@
1616

1717
public class UniqueStates implements SCBasisASTStatechartCoCo {
1818

19+
public static final String ERROR_CODE = "0xCC100";
20+
21+
public static final String ERROR_MSG_FORMAT = " State names must be unique but %s was duplicated.";
22+
1923
protected SCBasisTraverser t;
2024

21-
public UniqueStates (){
25+
public UniqueStates() {
2226
super();
2327
this.t = SCBasisMill.traverser();
2428
}
2529

26-
public UniqueStates (SCBasisTraverser traverser){
30+
public UniqueStates(SCBasisTraverser traverser) {
2731
super();
2832
this.t = traverser;
2933
}
30-
31-
32-
public static final String ERROR_CODE = "0xCC100";
33-
34-
public static final String ERROR_MSG_FORMAT = " State names must be unique but %s was duplicated." ;
35-
34+
3635
@Override
3736
public void check(ASTStatechart node) {
3837
StateCollector collector = new StateCollector();
3938
t.add4SCBasis(collector);
4039
node.accept(t);
4140
Set<String> uniques = Sets.newHashSet();
4241
List<ASTSCState> duplicates = collector.getStates().stream()
43-
.filter(e -> !uniques.add(e.getName()))
44-
.collect(Collectors.toList());
45-
if(!duplicates.isEmpty()){
42+
.filter(e -> !uniques.add(e.getName()))
43+
.collect(Collectors.toList());
44+
if (!duplicates.isEmpty()) {
4645
Log.error(String.format(ERROR_CODE + ERROR_MSG_FORMAT, duplicates.get(0).getName()),
47-
duplicates.get(0).get_SourcePositionStart());
46+
duplicates.get(0).get_SourcePositionStart(), duplicates.get(0).get_SourcePositionEnd());
4847
}
4948
}
5049
}

src/main/java/de/monticore/scevents/_cocos/NonCapitalEventNames.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import de.se_rwth.commons.logging.Log;
66

77
public class NonCapitalEventNames implements SCEventsASTSCFuncEventDefCoCo {
8-
8+
99
public static final String ERROR_CODE = "0xCC110";
10-
11-
@Override public void check(ASTSCFuncEventDef node) {
12-
if(!Character.isLowerCase((node.getName().charAt(0)))){
13-
Log.warn(ERROR_CODE + " The event name " + node.getName() + " should start with a lower case letter."
14-
, node.get_SourcePositionStart());
10+
11+
@Override
12+
public void check(ASTSCFuncEventDef node) {
13+
if (!Character.isLowerCase((node.getName().charAt(0)))) {
14+
Log.warn(ERROR_CODE + " The event name " + node.getName() + " should start with a lower case letter.",
15+
node.get_SourcePositionStart(), node.get_SourcePositionEnd());
1516
}
1617
}
1718
}

src/main/java/de/monticore/scevents/_cocos/NonCapitalParamNames.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import de.se_rwth.commons.logging.Log;
66

77
public class NonCapitalParamNames implements SCEventsASTSCFuncEventParameterCoCo {
8-
8+
99
public static final String ERROR_CODE = "0xCC109";
10-
11-
@Override public void check(ASTSCFuncEventParameter node) {
12-
if(!Character.isLowerCase((node.getName().charAt(0)))){
13-
Log.warn(ERROR_CODE + " The parameter name " + node.getName() + " should start with a lower case letter."
14-
, node.get_SourcePositionStart());
10+
11+
@Override
12+
public void check(ASTSCFuncEventParameter node) {
13+
if (!Character.isLowerCase((node.getName().charAt(0)))) {
14+
Log.warn(ERROR_CODE + " The parameter name " + node.getName() + " should start with a lower case letter.",
15+
node.get_SourcePositionStart(), node.get_SourcePositionEnd());
1516
}
1617
}
1718
}

src/main/java/de/monticore/scstateinvariants/_cocos/InvariantValid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void check(ASTSCInvState node) {
1616
SymTypeExpression symType = TypeCheck3.typeOf(node.getExpression());
1717

1818
if (!symType.isObscureType() && !SymTypeRelations.isBoolean(symType)) {
19-
Log.error(ERROR_CODE + " Invariant of " + node.getName() + " not of type boolean", node.get_SourcePositionStart());
19+
Log.error(ERROR_CODE + " Invariant of " + node.getName() + " not of type boolean", node.get_SourcePositionStart(), node.get_SourcePositionEnd());
2020
}
2121
}
2222
}

src/main/java/de/monticore/sctransitions4code/_cocos/TransitionPreconditionsAreBoolean.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public void check(ASTTransitionBody node) {
5050
Log.debug(() -> String.format(
5151
"Coco '%s' skipped for transition guard at %s. The type is obscure, an error should already have been logged.",
5252
this.getClass().getSimpleName(),
53-
node.get_SourcePositionStart()),
53+
node.getPre().get_SourcePositionStart()),
5454
"Cocos"
5555
);
5656
} else if (!SymTypeRelations.isBoolean(preType)) {
5757
Log.error(
5858
String.format(ERROR_CODE + " " + GUARD_NOT_BOOLEAN_ERROR_MSG, BOOLEAN, preType.print()),
59-
node.get_SourcePositionStart(), node.get_SourcePositionEnd()
59+
node.getPre().get_SourcePositionStart(), node.getPre().get_SourcePositionEnd()
6060
);
6161
}
6262
}

0 commit comments

Comments
 (0)