amondel2 commented on code in PR #432:
URL: 
https://github.com/apache/grails-intellij-plugin/pull/432#discussion_r4191367720


##########
plugin/src/main/java/org/apache/grails/intellij/plugin/projectView/impl/Grails3NodeProvider.java:
##########
@@ -63,8 +78,21 @@ public class Grails3NodeProvider implements 
GrailsViewNodeProvider {
 
     PsiDirectory src = GrailsViewItems.findPsiDirectory(application, "src");
     if (src != null) {
-      PsiFileSystemItemFilter filter = item -> !specialDirs.contains(item) && 
GrailsViewItems.shouldShowItem(item);
+      List<PsiDirectory> testDirs = findTestSourceDirectories(src);
+      // Directories that get their own node, so src can refuse to claim them. 
PsiDirectoryNode.contains()
+      // only applies a node's filter to the file and its immediate parent, so 
hiding the directories from
+      // src is not enough: src would still claim their contents, and Reveal 
in Project View would expand
+      // src and dead-end. isAncestor(dir, dir, false) is true, so one check 
covers the directories too.
+      Set<VirtualFile> lifted = liftedDirectories(specialDirs, testDirs);
+      PsiFileSystemItemFilter filter = item -> !isUnder(lifted, 
item.getVirtualFile())
+        && GrailsViewItems.shouldShowItem(item);
       result.add(new GrailsPsiDirectoryNode(src, settings, 
NodeWeights.SRC_FOLDERS, filter));
+
+      for (PsiDirectory testDir : testDirs) {
+        Icon icon = "test".equals(testDir.getName()) ? 
PlatformIcons.TEST_SOURCE_FOLDER : GroovyMvcIcons.Grails_test;

Review Comment:
   Fixed in `e1ad4a0`, adopting your suggestion. `src/test` renders as 
**`Tests:unit`**, `src/integration-test` as **`Tests:integration`**, 
`src/functional-test` as **`Tests:functional`** — the Grails 2 phase labels 
`OldGrailsNodeProvider` produced from `"Tests:" + name`. Grails 3+ renamed the 
directories, so reproducing the labels needs a mapping keyed on directory name, 
declared in one place beside the discovery logic. Any other lifted root falls 
back to `"Tests:" + directoryName`, so a custom phase renders as 
`Tests:smoke-test` rather than losing its label. Since `Tests:unit` no longer 
contains the folder name, each node also carries a **location string** with its 
real path; that needed an optional location on `GrailsPsiDirectoryNode`, 
defaulting to `null` so `OtherGrailsAppSourcesNode` and its `"Other sources"` 
location are unaffected. Icons are unchanged.
   
   Worth flagging, because the test suite could not have caught it: the labels 
didn't render at all on the first attempt. `PsiDirectoryNode` builds the label 
from `PresentationData`'s **coloured fragments**, not `presentableText`, and 
fills them with the directory's qualified path — so setting `presentableText` 
changed nothing the renderer draws. `GrailsPsiDirectoryNode` now clears and 
re-adds the fragments in `postprocess`, the only hook that runs after the 
platform writes the label. Verified by installing the ZIP on a real Grails 7.2 
app, and recorded in AGENTS.md under "Project view gotchas".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to