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


##########
plugin/src/main/java/org/apache/grails/intellij/plugin/projectView/nodes/GrailsCustomFolderNode.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.grails.intellij.plugin.projectView.nodes;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.ide.projectView.PresentationData;
+import com.intellij.ide.projectView.ViewSettings;
+import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode;
+import com.intellij.ide.util.treeView.AbstractTreeNode;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VfsUtilCore;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiDirectory;
+import com.intellij.psi.PsiManager;
+import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.ui.tree.LeafState;
+import org.apache.grails.intellij.plugin.config.FolderPaths;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * A configured custom folder shown as a top-level node in the Grails project 
view pane. The folder
+ * may not exist on disk, in which case the node is a placeholder: it renders 
with the folder name
+ * and the configured path as tooltip, but has no children and contains 
nothing.
+ */
+public final class GrailsCustomFolderNode extends AbstractTreeNode<String> {

Review Comment:
   Adopted your suggested shape verbatim.
   
   A folder that resolves on disk is now a `GrailsPsiDirectoryNode` subclass 
built with the seven-argument
   constructor you named — `(dir, settings, AllIcons.Nodes.Folder, 
NodeWeights.CUSTOM_FOLDER, label, null, configuredPath)` —
   so its value is the `PsiDirectory` and it inherits `contains`, the data 
context, the comparator weight
   and the title handling in `postprocess`. A folder that does not resolve 
keeps a separate lightweight
   `GrailsMissingCustomFolderNode` placeholder, and that is the only 
`AbstractTreeNode<String>` left in
   the feature.
   
   Both kinds implement one `GrailsCustomFolder` interface 
(`getConfiguredPath()`, `getNodeWeight()`),
   so `GrailsNodeComparator.weight()` is a single `instanceof` branch covering 
the directory node and the
   placeholder.
   
   On your probe: `testVisitorRevealsFileInsideCustomFolder` drives
   `AbstractProjectViewPane.createVisitor(file).visit(...)` for 
`docs/readme.md` and asserts `CONTINUE`.
   It runs on a pooled thread under a read action, because 
`AbstractTreeNodeVisitor.visit` asserts a
   background thread. The value assertion is 
`testExistingFolderNodeCarriesTheDirectoryAsValue`, which
   is what puts `PSI_ELEMENT`/`VIRTUAL_FILE` into the data context.
   
   The location string is the configured path exactly as typed, so `docs` and 
`app/docs` stay
   distinguishable — 
`testExistingFolderNodeCarriesTheConfiguredPathAsLocationAndTooltip` pins both 
it
   and the tooltip, using `./docs/` so the assertion notices if the label and 
the spelling get conflated.
   
   The old `contains` override is gone, so the `contains` in play for an 
existing folder is the
   platform's own `ProjectViewNode.contains` on the directory node; a 
placeholder contributes the
   visitor's `SKIP_CHILDREN` and nothing else.



-- 
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