Skip to content

Commit

Permalink
Fixing minor formatting bug & issue with type completion when using H…
Browse files Browse the repository at this point in the history
…axe 3.1 extensions annotations in typedefs
  • Loading branch information
m0rkeulv committed Aug 19, 2024
1 parent ea35327 commit 3c531b8
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ private static boolean needIndent(@Nullable IElementType type, IElementType elem
result = result || type == CLASS_BODY;
result = result || type == ABSTRACT_BODY;
result = result || (type == ARRAY_LITERAL && elementType != PLBRACK && elementType != PRBRACK);
result = result || type == ANONYMOUS_TYPE_FIELD_LIST || type == TYPE_EXTENDS_LIST;
result = result || type == OBJECT_LITERAL;
result = result || type == MAP_INITIALIZER_EXPRESSION;
result = result || type == MAP_LOOP_INITIALIZER_EXPRESSION;
Expand Down
5 changes: 3 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 @@ -982,10 +982,11 @@ anonymousTypeBody ::= anonymousTypeWithEmptyBody | regularAnonymousTypeBody
private anonymousTypeWithEmptyBody ::= '{' '}' {pin=2}
private regularAnonymousTypeBody ::= '{' anonymousTypeBodyContents '}' {pin=2}
private anonymousTypeBodyContents ::= extendedAnonymousTypeBody | simpleAnonymousTypeBody | anonymousInterfaceBodyList
private extendedAnonymousTypeBody ::= typeExtendsList ',' (anonymousTypeFieldList)? (anonymousInterfaceBodyList)?
private extendedAnonymousTypeBody ::= typeExtendsList ',' (anonymousTypeFieldList)? (anonymousInterfaceBodyList)? {pin=1}
private anonymousInterfaceBodyList ::= (optionalFieldDeclaration | interfaceBodyPart )+ {recoverWhile="interface_body_part_recover"}
private simpleAnonymousTypeBody ::= anonymousTypeFieldList (sep anonymousInterfaceBodyList)?
typeExtendsList ::= '>' type (',' '>' type)* {pin=1}
typeExtendsList ::= '>' type (',' '>' type)* {pin=1 recoverWhile=type_extends_list_recover}
private type_extends_list_recover ::= !(',' | '}' | '>')

anonymousTypeFieldList ::= anonymousTypeField (',' anonymousTypeField)* ','? {recoverWhile="object_literal_part_recover" pin=1}
private sep ::= ',' | ';'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public String getQualifiedName() {
}

PsiFile file = getContainingFile();
if (file == null) return name;
if (file == null) return name == null ? "" : name;

final String fileName = FileUtil.getNameWithoutExtension(file.getName());
String packageName = HaxeResolveUtil.getPackageName(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ public void testSpaceOthers() throws Exception {
myTestStyleSettings.SPACE_AFTER_SEMICOLON = false;
doTest();
}
@Test
public void testIndentTypedef() throws Exception {
doTest();
}

@Test
public void testWrappingMeth() throws Exception {
Expand Down
21 changes: 21 additions & 0 deletions src/test/resources/testData/formatter/IndentTypedef.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
typedef Point2D = { x:Int, y:Int }
typedef Point3D = {
> Point2D,
z:Int
}
typedef FormattingTest = {
var x = 0 ;
var y = 0 ;
var z = 0 ;

function dummy(point:Point3D) {
x= point.x;
y= point.y;
z = point.z;
}
}

class MyClass<T:{x:Int, y:Int}>
{
var point:T = {x:1,y:2};
}
20 changes: 20 additions & 0 deletions src/test/resources/testData/formatter/IndentTypedef.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
typedef Point2D = {x:Int, y:Int}
typedef Point3D = {
> Point2D,
z:Int
}
typedef FormattingTest = {
var x = 0 ;
var y = 0 ;
var z = 0 ;

function dummy(point:Point3D) {
x = point.x;
y = point.y;
z = point.z;
}
}

class MyClass<T:{x:Int, y:Int}> {
var point:T = {x:1, y:2} ;
}

0 comments on commit 3c531b8

Please sign in to comment.