Skip to content

Commit c8cf487

Browse files
committed
Fix regular expressions not being allowed in hook transmits list
1 parent 2412088 commit c8cf487

File tree

7 files changed

+12
-42
lines changed

7 files changed

+12
-42
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# intellij-runescript Changelog
22

33
## [Unreleased]
4+
### Fixed
5+
- Fix regular expressions not being allowed in hook transmits list.
6+
47
### Changed
58
- Inspections that require symbols will no longer run on files outside the project.
69
- Update the file extension for commands from ".op" to ".cs2".

src/main/gen/io/runescript/plugin/lang/parser/RsParser.java

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ public static boolean HookRoot(PsiBuilder b, int l) {
706706
}
707707

708708
/* ********************************************************** */
709-
// LBRACE (DynamicExpression (',' DynamicExpression)*)? RBRACE
709+
// LBRACE ExpressionList? RBRACE
710710
public static boolean HookTransmitList(PsiBuilder b, int l) {
711711
if (!recursion_guard_(b, l, "HookTransmitList")) return false;
712712
if (!nextTokenIs(b, LBRACE)) return false;
@@ -719,46 +719,13 @@ public static boolean HookTransmitList(PsiBuilder b, int l) {
719719
return r;
720720
}
721721

722-
// (DynamicExpression (',' DynamicExpression)*)?
722+
// ExpressionList?
723723
private static boolean HookTransmitList_1(PsiBuilder b, int l) {
724724
if (!recursion_guard_(b, l, "HookTransmitList_1")) return false;
725-
HookTransmitList_1_0(b, l + 1);
726-
return true;
727-
}
728-
729-
// DynamicExpression (',' DynamicExpression)*
730-
private static boolean HookTransmitList_1_0(PsiBuilder b, int l) {
731-
if (!recursion_guard_(b, l, "HookTransmitList_1_0")) return false;
732-
boolean r;
733-
Marker m = enter_section_(b);
734-
r = DynamicExpression(b, l + 1);
735-
r = r && HookTransmitList_1_0_1(b, l + 1);
736-
exit_section_(b, m, null, r);
737-
return r;
738-
}
739-
740-
// (',' DynamicExpression)*
741-
private static boolean HookTransmitList_1_0_1(PsiBuilder b, int l) {
742-
if (!recursion_guard_(b, l, "HookTransmitList_1_0_1")) return false;
743-
while (true) {
744-
int c = current_position_(b);
745-
if (!HookTransmitList_1_0_1_0(b, l + 1)) break;
746-
if (!empty_element_parsed_guard_(b, "HookTransmitList_1_0_1", c)) break;
747-
}
725+
ExpressionList(b, l + 1);
748726
return true;
749727
}
750728

751-
// ',' DynamicExpression
752-
private static boolean HookTransmitList_1_0_1_0(PsiBuilder b, int l) {
753-
if (!recursion_guard_(b, l, "HookTransmitList_1_0_1_0")) return false;
754-
boolean r;
755-
Marker m = enter_section_(b);
756-
r = consumeToken(b, COMMA);
757-
r = r && DynamicExpression(b, l + 1);
758-
exit_section_(b, m, null, r);
759-
return r;
760-
}
761-
762729
/* ********************************************************** */
763730
// IF '(' LogicalOrWrapper ')' Statement (ELSE Statement)?
764731
public static boolean IfStatement(PsiBuilder b, int l) {

src/main/gen/io/runescript/plugin/lang/psi/RsHookTransmitList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public interface RsHookTransmitList extends PsiElement {
99

1010
@NotNull
11-
List<RsDynamicExpression> getDynamicExpressionList();
11+
List<RsExpression> getExpressionList();
1212

1313
@NotNull
1414
PsiElement getLbrace();

src/main/gen/io/runescript/plugin/lang/psi/impl/RsHookTransmitListImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public void accept(@NotNull PsiElementVisitor visitor) {
2929

3030
@Override
3131
@NotNull
32-
public List<RsDynamicExpression> getDynamicExpressionList() {
33-
return PsiTreeUtil.getChildrenOfTypeAsList(this, RsDynamicExpression.class);
32+
public List<RsExpression> getExpressionList() {
33+
return PsiTreeUtil.getChildrenOfTypeAsList(this, RsExpression.class);
3434
}
3535

3636
@Override

src/main/grammars/RuneScript.bnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,4 @@ HookFragment ::= NameLiteral (ArgumentList HookTransmitList?)? {
278278
mixin="io.runescript.plugin.lang.psi.mixin.RsHookFragmentMixin"
279279
implements="io.runescript.plugin.lang.psi.RsNamedElement"
280280
}
281-
HookTransmitList ::= LBRACE (DynamicExpression (',' DynamicExpression)*)? RBRACE
281+
HookTransmitList ::= LBRACE ExpressionList? RBRACE

src/main/kotlin/io/runescript/plugin/ide/codeInsight/controlFlow/RsControlFlowBuilder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class RsControlFlowBuilder : ControlFlowBuilder() {
9797
}
9898

9999
override fun visitHookTransmitList(o: RsHookTransmitList) {
100-
o.dynamicExpressionList.forEach { it.accept(this) }
100+
o.expressionList.forEach { it.accept(this) }
101101
}
102102

103103
override fun visitCommandExpression(o: RsCommandExpression) {

src/main/kotlin/io/runescript/plugin/lang/psi/type/inference/RsTypeInferenceVisitor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class RsTypeInferenceVisitor(private val myInferenceData: RsTypeInference) : RsV
214214
if (expectedType == null) {
215215
hookTransmitList.error("${reference.name} does not allow transmit list.")
216216
}
217-
hookTransmitList.dynamicExpressionList.forEach {
217+
hookTransmitList.expressionList.forEach {
218218
it.typeHint = expectedType ?: RsErrorType
219219
it.accept(this)
220220
}

0 commit comments

Comments
 (0)