Skip to content

Commit baee151

Browse files
committed
Add RepeatStatementNode helpers
1 parent e0c184d commit baee151

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- **API:** `RepeatStatementNode::getGuardExpression` method.
13+
- **API:** `RepeatStatementNode::getStatements` method.
14+
1015
### Fixed
1116

1217
- Parsing errors where adjacent `>` and `=` tokens were wrongly interpreted as the `>=` operator.

delphi-frontend/src/main/java/au/com/integradev/delphi/antlr/ast/node/RepeatStatementNodeImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,25 @@
2020

2121
import au.com.integradev.delphi.antlr.ast.visitors.DelphiParserVisitor;
2222
import org.antlr.runtime.Token;
23+
import org.sonar.plugins.communitydelphi.api.ast.ExpressionNode;
2324
import org.sonar.plugins.communitydelphi.api.ast.RepeatStatementNode;
25+
import org.sonar.plugins.communitydelphi.api.ast.StatementListNode;
2426

2527
public final class RepeatStatementNodeImpl extends DelphiNodeImpl implements RepeatStatementNode {
2628
public RepeatStatementNodeImpl(Token token) {
2729
super(token);
2830
}
2931

32+
@Override
33+
public ExpressionNode getGuardExpression() {
34+
return (ExpressionNode) getChild(2);
35+
}
36+
37+
@Override
38+
public StatementListNode getStatementList() {
39+
return (StatementListNode) getChild(0);
40+
}
41+
3042
@Override
3143
public <T> T accept(DelphiParserVisitor<T> visitor, T data) {
3244
return visitor.visit(this, data);

delphi-frontend/src/main/java/org/sonar/plugins/communitydelphi/api/ast/RepeatStatementNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@
1818
*/
1919
package org.sonar.plugins.communitydelphi.api.ast;
2020

21-
public interface RepeatStatementNode extends StatementNode {}
21+
public interface RepeatStatementNode extends StatementNode {
22+
ExpressionNode getGuardExpression();
23+
24+
StatementListNode getStatementList();
25+
}

0 commit comments

Comments
 (0)