Skip to content

Commit 094c5af

Browse files
sergejskovtunsFylmTM
authored andcommitted
Variable together with single star in variable length pattern now is recognized as list. (#75)
- Tests added
1 parent c91cab3 commit 094c5af

File tree

7 files changed

+24
-49
lines changed

7 files changed

+24
-49
lines changed

language/cypher/src/main/gen/com/neueda/jetbrains/plugin/graphdb/language/cypher/CypherParser.java

Lines changed: 15 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

language/cypher/src/main/java/com/neueda/jetbrains/plugin/graphdb/language/cypher/lexer/Cypher.bnf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ PatternElementChain ::= RelationshipPattern NodePattern {pin=1}
336336

337337
RelationshipPattern ::= LeftArrowHead? Dash RelationshipDetail? Dash RightArrowHead? {pin=2}
338338

339-
RelationshipDetail ::= "[" Variable? "?"? RelationshipTypes? MaybeVariableLength Properties? "]" {pin=1}
339+
RelationshipDetail ::= "[" Variable? "?"? RelationshipTypes? MaybeVariableLength? Properties? "]" {pin=1}
340340
RelationshipTypes ::= ":" RelTypeName ("|" ":"? RelTypeName)* {pin=1}
341-
MaybeVariableLength ::= ("*" RangeLiteral?)?
341+
MaybeVariableLength ::= ("*" RangeLiteral?)
342342

343343
NodePattern ::= "(" Variable? NodeLabels? Properties? ")" {pin=1}
344344

language/cypher/src/main/java/com/neueda/jetbrains/plugin/graphdb/language/cypher/references/CypherVariableElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ default CypherType getType() {
4747

4848
default CypherType resolveRelationshipType(CypherRelationshipDetail relationshipDetail) {
4949
CypherMaybeVariableLength maybeVariableLength = relationshipDetail.getMaybeVariableLength();
50-
return nonNull(maybeVariableLength.getRangeLiteral()) ? CypherList.of(RELATIONSHIP) : RELATIONSHIP;
50+
return nonNull(maybeVariableLength) ? CypherList.of(RELATIONSHIP) : RELATIONSHIP;
5151
}
5252
}

testing/integration-neo4j/src/test/java/com/neueda/jetbrains/plugin/graphdb/test/integration/neo4j/tests/cypher/inspection/CypherFunctionCallInspectionTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,8 @@ public void testRelationshipSizeWithVariableLength() {
209209
addDataSourceFileAndCheck("MATCH (a)-[c*1..1]->(b) WITH size(c) as derp RETURN derp");
210210
}
211211

212+
public void testRelationshipSizeWithStar() {
213+
addDataSourceFileAndCheck("MATCH (a)-[c*]->(b) WITH size(c) as derp RETURN derp");
214+
}
215+
212216
}

testing/integration-neo4j/src/test/resources/parsing/expressions/Expressions.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,6 @@ Cypher file: FILE(0,923)
531531
PsiElement(-)('-')(743,744)
532532
CypherRelationshipDetailImpl(RELATIONSHIP_DETAIL)(744,746)
533533
PsiElement([)('[')(744,745)
534-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(745,745)
535-
<empty list>
536534
PsiElement(])(']')(745,746)
537535
CypherDashImpl(DASH)(746,747)
538536
PsiElement(-)('-')(746,747)
@@ -662,4 +660,4 @@ Cypher file: FILE(0,923)
662660
PsiElement(string)('"str \n"')(902,910)
663661
PsiElement(AND)('AND')(911,914)
664662
CypherStringLiteralImpl(STRING_LITERAL)(915,923)
665-
PsiElement(string)('"str \""')(915,923)
663+
PsiElement(string)('"str \""')(915,923)

testing/integration-neo4j/src/test/resources/parsing/expressions/PatternComprehension.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ Cypher file: FILE(0,86)
2929
PsiElement(-)('-')(11,12)
3030
CypherRelationshipDetailImpl(RELATIONSHIP_DETAIL)(12,14)
3131
PsiElement([)('[')(12,13)
32-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(13,13)
33-
<empty list>
3432
PsiElement(])(']')(13,14)
3533
CypherDashImpl(DASH)(14,15)
3634
PsiElement(-)('-')(14,15)
@@ -81,8 +79,6 @@ Cypher file: FILE(0,86)
8179
PsiElement(-)('-')(44,45)
8280
CypherRelationshipDetailImpl(RELATIONSHIP_DETAIL)(45,47)
8381
PsiElement([)('[')(45,46)
84-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(46,46)
85-
<empty list>
8682
PsiElement(])(']')(46,47)
8783
CypherDashImpl(DASH)(47,48)
8884
PsiElement(-)('-')(47,48)

testing/integration-neo4j/src/test/resources/parsing/patterns/Patterns.txt

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,6 @@ Cypher file: FILE(0,751)
462462
PsiElement(-)('-')(296,297)
463463
CypherRelationshipDetailImpl(RELATIONSHIP_DETAIL)(297,299)
464464
PsiElement([)('[')(297,298)
465-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(298,298)
466-
<empty list>
467465
PsiElement(])(']')(298,299)
468466
CypherDashImpl(DASH)(299,300)
469467
PsiElement(-)('-')(299,300)
@@ -506,8 +504,6 @@ Cypher file: FILE(0,751)
506504
CypherSymbolicNameStringImpl(SYMBOLIC_NAME_STRING)(316,319)
507505
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(316,319)
508506
PsiElement(identifier)('var')(316,319)
509-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(319,319)
510-
<empty list>
511507
PsiElement(])(']')(319,320)
512508
CypherDashImpl(DASH)(320,321)
513509
PsiElement(-)('-')(320,321)
@@ -556,8 +552,6 @@ Cypher file: FILE(0,751)
556552
CypherSymbolicNameStringImpl(SYMBOLIC_NAME_STRING)(341,345)
557553
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(341,345)
558554
PsiElement(identifier)('Type')(341,345)
559-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(345,345)
560-
<empty list>
561555
PsiElement(])(']')(345,346)
562556
CypherDashImpl(DASH)(346,347)
563557
PsiElement(-)('-')(346,347)
@@ -606,8 +600,6 @@ Cypher file: FILE(0,751)
606600
CypherSymbolicNameStringImpl(SYMBOLIC_NAME_STRING)(367,371)
607601
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(367,371)
608602
PsiElement(identifier)('Type')(367,371)
609-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(371,371)
610-
<empty list>
611603
PsiElement(])(']')(371,372)
612604
CypherDashImpl(DASH)(372,373)
613605
PsiElement(-)('-')(372,373)
@@ -651,8 +643,6 @@ Cypher file: FILE(0,751)
651643
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(389,392)
652644
PsiElement(identifier)('var')(389,392)
653645
PsiElement(?)('?')(392,393)
654-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(393,393)
655-
<empty list>
656646
PsiElement(])(']')(393,394)
657647
CypherDashImpl(DASH)(394,395)
658648
PsiElement(-)('-')(394,395)
@@ -702,8 +692,6 @@ Cypher file: FILE(0,751)
702692
CypherSymbolicNameStringImpl(SYMBOLIC_NAME_STRING)(416,420)
703693
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(416,420)
704694
PsiElement(identifier)('Type')(416,420)
705-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(420,420)
706-
<empty list>
707695
PsiElement(])(']')(420,421)
708696
CypherDashImpl(DASH)(421,422)
709697
PsiElement(-)('-')(421,422)
@@ -758,8 +746,6 @@ Cypher file: FILE(0,751)
758746
CypherSymbolicNameStringImpl(SYMBOLIC_NAME_STRING)(448,452)
759747
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(448,452)
760748
PsiElement(identifier)('Type')(448,452)
761-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(452,452)
762-
<empty list>
763749
PsiElement(])(']')(452,453)
764750
CypherDashImpl(DASH)(453,454)
765751
PsiElement(-)('-')(453,454)
@@ -813,8 +799,6 @@ Cypher file: FILE(0,751)
813799
CypherSymbolicNameStringImpl(SYMBOLIC_NAME_STRING)(479,483)
814800
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(479,483)
815801
PsiElement(identifier)('Type')(479,483)
816-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(483,483)
817-
<empty list>
818802
PsiElement(])(']')(483,484)
819803
CypherDashImpl(DASH)(484,485)
820804
PsiElement(-)('-')(484,485)
@@ -1127,8 +1111,6 @@ Cypher file: FILE(0,751)
11271111
CypherSymbolicNameStringImpl(SYMBOLIC_NAME_STRING)(648,651)
11281112
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(648,651)
11291113
PsiElement(identifier)('var')(648,651)
1130-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(652,652)
1131-
<empty list>
11321114
CypherPropertiesImpl(PROPERTIES)(652,659)
11331115
CypherParameterImpl(PARAMETER)(652,659)
11341116
CypherOldParameterImpl(OLD_PARAMETER)(652,659)
@@ -1179,8 +1161,6 @@ Cypher file: FILE(0,751)
11791161
CypherSymbolicNameStringImpl(SYMBOLIC_NAME_STRING)(677,680)
11801162
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(677,680)
11811163
PsiElement(identifier)('var')(677,680)
1182-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(681,681)
1183-
<empty list>
11841164
CypherPropertiesImpl(PROPERTIES)(681,695)
11851165
CypherMapLiteralImpl(MAP_LITERAL)(681,695)
11861166
PsiElement({)('{')(681,682)
@@ -1235,8 +1215,6 @@ Cypher file: FILE(0,751)
12351215
CypherSymbolicNameStringImpl(SYMBOLIC_NAME_STRING)(713,716)
12361216
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(713,716)
12371217
PsiElement(identifier)('var')(713,716)
1238-
CypherMaybeVariableLengthImpl(MAYBE_VARIABLE_LENGTH)(717,717)
1239-
<empty list>
12401218
CypherPropertiesImpl(PROPERTIES)(717,745)
12411219
CypherMapLiteralImpl(MAP_LITERAL)(717,745)
12421220
PsiElement({)('{')(717,718)
@@ -1268,4 +1246,4 @@ Cypher file: FILE(0,751)
12681246
CypherUnescapedSymbolicNameStringImpl(UNESCAPED_SYMBOLIC_NAME_STRING)(748,749)
12691247
PsiElement(identifier)('n')(748,749)
12701248
PsiElement())(')')(749,750)
1271-
PsiElement(;)(';')(750,751)
1249+
PsiElement(;)(';')(750,751)

0 commit comments

Comments
 (0)