diff --git a/gen/com/intellij/plugins/haxe/lang/parser/HaxeParser.java b/gen/com/intellij/plugins/haxe/lang/parser/HaxeParser.java index cd49e22ec..560543901 100644 --- a/gen/com/intellij/plugins/haxe/lang/parser/HaxeParser.java +++ b/gen/com/intellij/plugins/haxe/lang/parser/HaxeParser.java @@ -2620,7 +2620,7 @@ private static boolean functionPrototypeDeclarationWithAttributes_8(PsiBuilder b } /* ********************************************************** */ - // '->' '?'? typeOrAnonymous + // '->' '?'? functionTypeOrWrapper public static boolean functionType(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "functionType")) return false; if (!nextTokenIs(b, OARROW)) return false; @@ -2628,7 +2628,7 @@ public static boolean functionType(PsiBuilder b, int l) { Marker m = enter_section_(b, l, _LEFT_, null); r = consumeToken(b, OARROW); r = r && functionType_1(b, l + 1); - r = r && typeOrAnonymous(b, l + 1); + r = r && functionTypeOrWrapper(b, l + 1); exit_section_(b, l, m, FUNCTION_TYPE, r, false, null); return r; } diff --git a/gen/com/intellij/plugins/haxe/lang/psi/HaxeFunctionType.java b/gen/com/intellij/plugins/haxe/lang/psi/HaxeFunctionType.java index c61b25ddc..5eb7b1306 100644 --- a/gen/com/intellij/plugins/haxe/lang/psi/HaxeFunctionType.java +++ b/gen/com/intellij/plugins/haxe/lang/psi/HaxeFunctionType.java @@ -25,8 +25,8 @@ public interface HaxeFunctionType extends HaxePsiCompositeElement { - @Nullable - HaxeFunctionType getFunctionType(); + @NotNull + List getFunctionTypeList(); @NotNull List getTypeOrAnonymousList(); diff --git a/gen/com/intellij/plugins/haxe/lang/psi/impl/HaxeFunctionTypeImpl.java b/gen/com/intellij/plugins/haxe/lang/psi/impl/HaxeFunctionTypeImpl.java index 0997c3aed..aaa55b902 100644 --- a/gen/com/intellij/plugins/haxe/lang/psi/impl/HaxeFunctionTypeImpl.java +++ b/gen/com/intellij/plugins/haxe/lang/psi/impl/HaxeFunctionTypeImpl.java @@ -40,9 +40,9 @@ public void accept(@NotNull PsiElementVisitor visitor) { } @Override - @Nullable - public HaxeFunctionType getFunctionType() { - return findChildByClass(HaxeFunctionType.class); + @NotNull + public List getFunctionTypeList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, HaxeFunctionType.class); } @Override diff --git a/grammar/haxe.bnf b/grammar/haxe.bnf index 2455a9401..47bbf5a24 100644 --- a/grammar/haxe.bnf +++ b/grammar/haxe.bnf @@ -363,7 +363,7 @@ arrayLiteral ::= '[' (expressionList ','?)? ']' private functionTypeWrapper ::= functionTypeOrWrapper functionType* private functionTypeOrWrapper ::= typeOrAnonymous | '(' functionTypeWrapper ')' -left functionType ::= '->' '?'? typeOrAnonymous +left functionType ::= '->' '?'? functionTypeOrWrapper /* * Haxe and Java have this backward from each other. diff --git a/src/14.1/com/intellij/plugins/haxe/ide/structure/HaxeStructureViewModel.java b/src/14.1/com/intellij/plugins/haxe/ide/structure/HaxeStructureViewModel.java index 66a5f8238..382b4ce81 100644 --- a/src/14.1/com/intellij/plugins/haxe/ide/structure/HaxeStructureViewModel.java +++ b/src/14.1/com/intellij/plugins/haxe/ide/structure/HaxeStructureViewModel.java @@ -74,11 +74,7 @@ public boolean isVisible(TreeElement treeNode) { if (!(treeNode instanceof HaxeStructureViewElement)) return true; final PsiElement element = ((HaxeStructureViewElement)treeNode).getRealElement(); - if (HaxeComponentType.typeOf(element) == HaxeComponentType.FIELD) { - return false; - } - - return true; + return HaxeComponentType.typeOf(element) != HaxeComponentType.FIELD; } public boolean isReverted() { diff --git a/src/common/com/intellij/plugins/haxe/util/HaxePresentableUtil.java b/src/common/com/intellij/plugins/haxe/util/HaxePresentableUtil.java index 1c39637a7..c31d71c79 100644 --- a/src/common/com/intellij/plugins/haxe/util/HaxePresentableUtil.java +++ b/src/common/com/intellij/plugins/haxe/util/HaxePresentableUtil.java @@ -107,8 +107,16 @@ public static String buildTypeText(HaxeNamedComponent element, HaxeTypeTag typeT public static String buildTypeText(HaxeNamedComponent element, HaxeTypeTag typeTag, HaxeGenericSpecialization specialization) { if (typeTag != null) { - final HaxeFunctionType haxeFunctionType = (typeTag.getFunctionType() == null) ? null : - typeTag.getFunctionType().getFunctionType(); + List list; + HaxeFunctionType functionType = typeTag.getFunctionType(); + list = functionType != null ? functionType.getFunctionTypeList() : null; + HaxeFunctionType type = null; + if (list != null) { + type = list.size() > 0 ? list.get(0) : null; + } + + final HaxeFunctionType haxeFunctionType = (functionType == null) ? null : + type; if (haxeFunctionType != null) { return buildTypeText(element, haxeFunctionType, specialization); } @@ -142,7 +150,9 @@ private static String buildTypeText(HaxeNamedComponent element, "->" + buildTypeText(element, typeOrAnonymousList.get(1).getType(), specialization); } - return buildTypeText(element, functionType.getFunctionType(), specialization) + + List list = functionType.getFunctionTypeList(); + HaxeFunctionType type = list.size() > 0 ? list.get(0) : null; + return buildTypeText(element, type, specialization) + "->" + buildTypeText(element, typeOrAnonymousList.get(0).getType(), specialization); } diff --git a/src/common/com/intellij/plugins/haxe/util/HaxeResolveUtil.java b/src/common/com/intellij/plugins/haxe/util/HaxeResolveUtil.java index dba56622e..62c2fb472 100644 --- a/src/common/com/intellij/plugins/haxe/util/HaxeResolveUtil.java +++ b/src/common/com/intellij/plugins/haxe/util/HaxeResolveUtil.java @@ -519,7 +519,8 @@ private static HaxeClassResolveResult tryResolveFunctionType(@Nullable HaxeFunct final HaxeTypeOrAnonymous returnTypeOrAnonymous = functionType.getTypeOrAnonymousList().get(functionType.getTypeOrAnonymousList().size() - 1); final HaxeClassResolveResult result = tryResolveClassByTypeTag(returnTypeOrAnonymous.getType(), specialization); - functionType = functionType.getFunctionType(); + List list = functionType.getFunctionTypeList(); + functionType = list.size() > 0 ? list.get(0) : null; while (functionType != null) { // todo: anonymous types :( final List typeList = functionType.getTypeOrAnonymousList(); @@ -527,7 +528,8 @@ private static HaxeClassResolveResult tryResolveFunctionType(@Nullable HaxeFunct for (HaxeTypeOrAnonymous typeOrAnonymous : typeList) { result.getFunctionTypes().add(tryResolveClassByTypeTag(typeOrAnonymous.getType(), specialization)); } - functionType = functionType.getFunctionType(); + List list2 = functionType.getFunctionTypeList(); + functionType = list2.size() > 0 ? list2.get(0) : null; } Collections.reverse(result.getFunctionTypes()); return result; diff --git a/testData/parsing/haxe/declarations/typedef/FunctionTypedef.hx b/testData/parsing/haxe/declarations/typedef/FunctionTypedef.hx new file mode 100644 index 000000000..87740eec1 --- /dev/null +++ b/testData/parsing/haxe/declarations/typedef/FunctionTypedef.hx @@ -0,0 +1,3 @@ +package test; + +typedef MyFnPtr = String->Int->Void; diff --git a/testData/parsing/haxe/declarations/typedef/FunctionTypedef.txt b/testData/parsing/haxe/declarations/typedef/FunctionTypedef.txt new file mode 100644 index 000000000..5ecb7ea17 --- /dev/null +++ b/testData/parsing/haxe/declarations/typedef/FunctionTypedef.txt @@ -0,0 +1 @@ +// No satisfactory golden file has been generated yet. \ No newline at end of file diff --git a/testData/parsing/haxe/declarations/typedef/FunctionTypedefWithFunctionParameter.hx b/testData/parsing/haxe/declarations/typedef/FunctionTypedefWithFunctionParameter.hx new file mode 100644 index 000000000..e5c7295e3 --- /dev/null +++ b/testData/parsing/haxe/declarations/typedef/FunctionTypedefWithFunctionParameter.hx @@ -0,0 +1,3 @@ +package test; + +typedef MyFnPtr = String->(Int->Int->Void)->Void; diff --git a/testData/parsing/haxe/declarations/typedef/FunctionTypedefWithFunctionParameter.txt b/testData/parsing/haxe/declarations/typedef/FunctionTypedefWithFunctionParameter.txt new file mode 100644 index 000000000..37e4d7141 --- /dev/null +++ b/testData/parsing/haxe/declarations/typedef/FunctionTypedefWithFunctionParameter.txt @@ -0,0 +1 @@ +// No satisfactory golden master has been generated yet. \ No newline at end of file diff --git a/testSrc/com/intellij/plugins/haxe/lang/parser/declarations/TypedefDeclarationTest.java b/testSrc/com/intellij/plugins/haxe/lang/parser/declarations/TypedefDeclarationTest.java index bd3ab6cf0..e013c2a27 100644 --- a/testSrc/com/intellij/plugins/haxe/lang/parser/declarations/TypedefDeclarationTest.java +++ b/testSrc/com/intellij/plugins/haxe/lang/parser/declarations/TypedefDeclarationTest.java @@ -32,4 +32,12 @@ public void testSimple() throws Throwable { public void testPoints() throws Throwable { doTest(true); } + + public void testFunctionTypedef() throws Throwable { + doTest(true); + } + + public void testFunctionTypedefWithFunctionParameter() throws Throwable { + doTest(true); + } }