Skip to content

Commit

Permalink
fix missing optional check on anonymousTypeFields (issue #1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rkeulv committed Aug 8, 2024
1 parent 872e051 commit 01f1cc7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/intellij/plugins/haxe/lang/parser/haxe.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ private enumConstructorParameters ::= parenthesizedParameterList

fieldDeclaration ::= fieldModifier* mutabilityModifier componentName propertyDeclaration? typeTag? varInit? <<semicolonUnlessPrecededByStatement>>
{pin=3 mixin="com.intellij.plugins.haxe.lang.psi.impl.HaxePsiFieldImpl" implements="com.intellij.plugins.haxe.lang.psi.HaxePsiField"}
optionalFieldDeclaration ::= fieldModifier* mutabilityModifier '?' componentName propertyDeclaration? typeTag? varInit? <<semicolonUnlessPrecededByStatement>>
optionalFieldDeclaration ::= fieldModifier* mutabilityModifier optionalMark componentName propertyDeclaration? typeTag? varInit? <<semicolonUnlessPrecededByStatement>>
{pin=3 implements=fieldDeclaration mixin="com.intellij.plugins.haxe.lang.psi.impl.HaxePsiFieldImpl" implements="com.intellij.plugins.haxe.lang.psi.HaxePsiField"}
//NOTE: static local variable is a haxe 4.3+ feature
localVarDeclarationList ::='static'? mutabilityModifier localVarDeclaration (',' localVarDeclaration)* <<semicolonUnlessPrecededByStatement>>{pin=3}
Expand Down Expand Up @@ -969,7 +969,7 @@ typeExtendsList ::= '>' type (',' '>' type)* {pin=1}

anonymousTypeFieldList ::= anonymousTypeField (',' anonymousTypeField)* ','? {recoverWhile="object_literal_part_recover" pin=1}
private sep ::= ',' | ';'
anonymousTypeField ::= "?"? componentName typeTag
anonymousTypeField ::= optionalMark? componentName typeTag
{pin=3 mixin="com.intellij.plugins.haxe.lang.psi.impl.HaxePsiFieldImpl" implements="com.intellij.plugins.haxe.lang.psi.HaxePsiField"}

// Do NOT genericize objectLiteral by making objectLiteralElementList optional. Doing so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ public HaxeExpression getInitializerExpression() {

public boolean isOptional() {
if(getBasePsi() instanceof HaxeOptionalFieldDeclaration) return true;
if(getBasePsi() instanceof HaxeAnonymousTypeField anonymous) {
if (anonymous.getOptionalMark() != null)return true;
}
return hasOptionalMeta();
}
}

0 comments on commit 01f1cc7

Please sign in to comment.