diff --git a/src/main/java/com/intellij/plugins/haxe/lang/psi/HaxeResolver.java b/src/main/java/com/intellij/plugins/haxe/lang/psi/HaxeResolver.java index fbe409665..92ace18ba 100644 --- a/src/main/java/com/intellij/plugins/haxe/lang/psi/HaxeResolver.java +++ b/src/main/java/com/intellij/plugins/haxe/lang/psi/HaxeResolver.java @@ -211,8 +211,10 @@ private List doResolveInner(@NotNull HaxeReference referen if (fileModel != null) { List matchesInImport = HaxeResolveUtil.searchInImports(fileModel, referenceText); // Remove enumValues if we are resolving typeTag as typeTags should not be EnumValues + // We also have to remove resolved fields as abstract enums is a thing if (isType) { matchesInImport = matchesInImport.stream().filter(element -> !(element instanceof HaxeEnumValueDeclaration)).toList(); + matchesInImport = matchesInImport.stream().filter(element -> !(element instanceof HaxeFieldDeclaration)).toList(); } if (!matchesInImport.isEmpty()) { // one file may contain multiple enums and have enumValues with the same name; trying to match any argument list diff --git a/src/main/java/com/intellij/plugins/haxe/util/HaxeResolveUtil.java b/src/main/java/com/intellij/plugins/haxe/util/HaxeResolveUtil.java index 5678c87c3..5fb50aa65 100644 --- a/src/main/java/com/intellij/plugins/haxe/util/HaxeResolveUtil.java +++ b/src/main/java/com/intellij/plugins/haxe/util/HaxeResolveUtil.java @@ -313,7 +313,7 @@ private static void addNotNullComponents(@NotNull List colle * * @param unique - whether multiple components sharing a name are included. If true, *which* of the components * sharing a name is returned is indeterminate. - * @param resolver - map of generic type names to real types. + * @param parentResolver - map of generic type names to real types. * @param rootHaxeClasses - which class(es) to gather components from. * @return a list of named components defined in the rootHaxeClasses and their supertypes. */ @@ -364,7 +364,8 @@ public static List findNamedSubComponents(boolean unique, @N List baseTypes = new ArrayList<>(); baseTypes.addAll(haxeClass.getHaxeExtendsList()); baseTypes.addAll(haxeClass.getHaxeImplementsList()); - List baseClasses = tryResolveClassesByQName(baseTypes); + + List baseClasses = tryResolveClasses(baseTypes); if (haxeClass.isEnum() && !haxeClass.isAbstractType() && haxeClass.getContext() != null) { //Enums should provide the same methods as EnumValue baseClasses.add(HaxeEnumValueUtil.getEnumValueClass(haxeClass.getContext()).getHaxeClass()); @@ -1043,6 +1044,22 @@ private static HaxeResolveResult tryResolveFunctionType(@Nullable HaxeFunctionTy return tryResolveClassByTypeTag(returnType.getTypeOrAnonymous().getType(), specialization); } + @NotNull + public static List tryResolveClasses(@NotNull List types) { + final List result = new ArrayList(); + for (HaxeType haxeType : types) { + PsiElement resolve = haxeType.getReferenceExpression().resolve(); + if (resolve instanceof HaxeClass type) { + result.add(type); + }else { + final HaxeClass haxeClass = tryResolveClassByQName(haxeType); + if (haxeClass != null) { + result.add(haxeClass); + } + } + } + return result; + } @NotNull public static List tryResolveClassesByQName(@NotNull List types) { final List result = new ArrayList();