Skip to content

Commit 485171c

Browse files
committed
Fix Multiple Dots Check
1 parent cb0ea0e commit 485171c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

liquidjava-verifier/src/main/java/liquidjava/rj_language/visitors/CreateASTVisitor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,18 @@ private Expression functionCallCreate(FunctionCallContext rc) throws LJError {
188188
}
189189

190190
/**
191-
* Handles both cases of dot calls: this.func(args) and targetFunc(this).func(args)
192-
* Converts them to func(this, args) and func(targetFunc(this), args) respectively
191+
* Handles both cases of dot calls: this.func(args) and targetFunc(this).func(args) Converts them to func(this,
192+
* args) and func(targetFunc(this), args) respectively
193193
*/
194194
private Expression dotCallCreate(DotCallContext rc) throws LJError {
195195
if (rc.OBJECT_TYPE() != null) {
196+
String text = rc.OBJECT_TYPE().getText();
196197

197198
// check if there are multiple fields (e.g. this.a.b)
198-
if (rc.ID().size() > 1)
199-
throw new SyntaxError("Multiple dot notation is not allowed", rc.getText());
199+
if (text.chars().filter(ch -> ch == '.').count() > 1)
200+
throw new SyntaxError("Multiple dot notation is not allowed", text);
200201

201202
// this.func(args) => func(this, args)
202-
String text = rc.OBJECT_TYPE().getText();
203203
int dot = text.indexOf('.');
204204
String target = text.substring(0, dot);
205205
String simpleName = text.substring(dot + 1);

0 commit comments

Comments
 (0)