@@ -63,21 +63,54 @@ class RelatedFileListCellRenderer(val project: Project) : ListCellRenderer<FileP
63
63
64
64
/* *
65
65
* Constructs a display name for the given file presentation based on the associated virtual file.
66
+ *
67
+ * For file-system routing frameworks where files have conventional names but directories carry semantic meaning:
68
+ * - Next.js: app/dashboard/page.tsx -> dashboard/page.tsx
69
+ * - Django: myapp/views.py -> myapp/views.py
70
+ * - Nuxt: pages/about/index.vue -> about/index.vue
71
+ *
72
+ * Shows directory context for conventional filenames that appear frequently across projects.
66
73
*/
67
74
private fun buildDisplayName (value : FilePresentation ): @NlsSafe String {
68
75
val filename = value.virtualFile.name
69
- if (filename.startsWith(" index." )) {
76
+ val filenameWithoutExtension = filename.substringBeforeLast(' .' )
77
+
78
+ // File-system routing and framework convention patterns
79
+ val routingConventionFiles = setOf (
80
+ // Next.js App Router
81
+ " page" , " layout" , " loading" , " error" , " not-found" , " route" , " template" , " default" ,
82
+ // Traditional index files
83
+ " index" ,
84
+ // Django patterns
85
+ " views" , " models" , " urls" , " forms" , " admin" , " serializers" , " tests" ,
86
+ // Flask/FastAPI patterns
87
+ " app" , " main" , " routes" , " models" , " schemas" ,
88
+ // Vue/Nuxt patterns
89
+ " middleware" , " plugins" , " store" ,
90
+ // React/Vue component patterns
91
+ " component" , " components" , " hook" , " hooks" , " context" , " provider" ,
92
+ // General patterns
93
+ " config" , " settings" , " constants" , " types" , " utils" , " helpers"
94
+ )
95
+
96
+ if (filenameWithoutExtension in routingConventionFiles) {
70
97
val parent = value.virtualFile.parent?.name
71
98
if (parent != null ) {
72
- val grandParent = value.virtualFile.parent?.parent?.name
73
- return if (grandParent != null ) {
74
- " $grandParent /$parent /$filename "
99
+ // For index files, show more context as they're especially common
100
+ if (filenameWithoutExtension == " index" ) {
101
+ val grandParent = value.virtualFile.parent?.parent?.name
102
+ return if (grandParent != null ) {
103
+ " $grandParent /$parent /$filename "
104
+ } else {
105
+ " $parent /$filename "
106
+ }
75
107
} else {
76
- " $parent /$filename "
108
+ // For other conventional files, show parent directory context
109
+ return " $parent /$filename "
77
110
}
78
111
}
79
112
}
80
113
81
114
return filename
82
115
}
83
- }
116
+ }
0 commit comments