From c9bd15e14e900722f68d176b65499f5262ac559a Mon Sep 17 00:00:00 2001 From: m0rkeulv Date: Sun, 19 May 2024 19:12:59 +0200 Subject: [PATCH] Fixing type hierarchy / inheritance index not indexing types with generics correctly --- CHANGELOG.md | 3 ++- .../plugins/haxe/ide/index/HaxeInheritanceIndex.java | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2ba4a9c3..c36be4d71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ * Bugfix: import would be displayed as unused if last reference in a file was a fully qualified reference. * Bugfix: Fixing problem with resolving setter method reference from property. * Bugfix: Imports would not be added automatically when package statement was missing. -* Bugfix: Constraints and defaults could not be used together in type generics +* Fixed: Constraints and defaults could not be used together in type generics +* Fixed: Type-hierarchy would not include types that contained generics * Improvement: major rework of completion suggestions - Added completion for constructors - Added public static members to completion suggestions diff --git a/src/main/java/com/intellij/plugins/haxe/ide/index/HaxeInheritanceIndex.java b/src/main/java/com/intellij/plugins/haxe/ide/index/HaxeInheritanceIndex.java index 4f4fb0c35..263812f98 100644 --- a/src/main/java/com/intellij/plugins/haxe/ide/index/HaxeInheritanceIndex.java +++ b/src/main/java/com/intellij/plugins/haxe/ide/index/HaxeInheritanceIndex.java @@ -116,7 +116,7 @@ public HaxeClass fun(PsiElement element) { final HaxeClassInfo value = new HaxeClassInfo(classString, packageString, HaxeComponentType.typeOf(haxeClass)); for (HaxeType haxeType : haxeClass.getHaxeExtendsList()) { if (haxeType == null) continue; - final String classNameCandidate = haxeType.getText(); + final String classNameCandidate = getClassNameCandidate(haxeType); final String key = classNameCandidate.indexOf('.') != -1 ? classNameCandidate : getQNameAndCache(qNameCache, psiFile, classNameCandidate); @@ -124,7 +124,7 @@ public HaxeClass fun(PsiElement element) { } for (HaxeType haxeType : haxeClass.getHaxeImplementsList()) { if (haxeType == null) continue; - final String classNameCandidate = haxeType.getText(); + final String classNameCandidate = getClassNameCandidate(haxeType); final String key = classNameCandidate.indexOf('.') != -1 ? classNameCandidate : getQNameAndCache(qNameCache, psiFile, classNameCandidate); @@ -134,6 +134,11 @@ public HaxeClass fun(PsiElement element) { return result; } + private static String getClassNameCandidate(HaxeType haxeType) { + // we are not using "haxeType.getText();" here because that would include type parameters/ generics + return haxeType.getReferenceExpression().getText(); + } + private static String getQNameAndCache(Map qNameCache, PsiFile psiFile, String classNameCandidate) { String result = qNameCache.get(classNameCandidate); if (result == null) {