-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
intellij-plugin
: privot approach (#2353)
* feat: create own PsiFile * feat: support renaming of modules * feat: remove unnecessary RenameHandler * feat: remove unused rename handler * feat: movement * fix: null exception on project switch * feat: debug * feat: radically simplify the plugin * chore: remove old stuff * Update apps/intellij-plugin/src/main/kotlin/ai/hash/rustextra/projectView/ModuleDirectoryNode.kt Co-authored-by: Tim Diekmann <[email protected]> * Update apps/intellij-plugin/src/main/resources/META-INF/plugin.xml * Update apps/intellij-plugin/build.gradle.kts * Update ModuleDirectoryNode.kt * chore: run `ktlint` --------- Co-authored-by: Tim Diekmann <[email protected]>
- Loading branch information
1 parent
720c4dc
commit 9420a82
Showing
6 changed files
with
41 additions
and
101 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
apps/intellij-plugin/src/main/kotlin/ai/hash/rustextra/projectView/ModuleDirectoryNode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ai.hash.rustextra.projectView | ||
|
||
import com.intellij.ide.projectView.NodeSortOrder | ||
import com.intellij.ide.projectView.NodeSortSettings | ||
import com.intellij.ide.projectView.ViewSettings | ||
import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.PsiDirectory | ||
|
||
class ModuleDirectoryNode(project: Project?, value: PsiDirectory, viewSettings: ViewSettings?) : PsiDirectoryNode(project, value, viewSettings) { | ||
// This is needed, as otherwise the `GroupByTypeComparator` won't fall back to the `AlphaComparator` | ||
override fun getTypeSortWeight(sortByType: Boolean): Int = 0 | ||
|
||
// This value is taken from `PsiFileNode`, which assigns a static value of `20` | ||
// we need to directly use the magic value of 20, as we're unable to invoke the method on `PsiFileNode` | ||
// directly. | ||
// This allows us to bypass the `AlphaComparator` and use the `FileNameComparator` for sorting. | ||
override fun getWeight(): Int = 20 | ||
|
||
// this is the default `SortKey` of `RsFile`, using the same allows us to group those together | ||
override fun getSortKey(): Int = 0 | ||
|
||
// taken from ProjectView, overwrites the directory sort order | ||
@Suppress("UnstableApiUsage") | ||
override fun getSortOrder(settings: NodeSortSettings): NodeSortOrder = | ||
if (settings.isManualOrder) NodeSortOrder.MANUAL else NodeSortOrder.UNSPECIFIED | ||
|
||
// a bit of a hack, if the `SortKey` is the same the `GroupByTypeComparator` redirects to the `AlphaComparator`, | ||
// if the weights of both files are the same, the `AlphaComparator` uses the `FileNameComparator` with the `toString` | ||
// representation of a node. For the node to be able to be displayed above the directory we "emulate" the name of | ||
// the file (and add `.mod` to ensure that we're always last). | ||
// AFAIK `toString()` is not used anywhere else. | ||
override fun toString(): String { | ||
val name = super.toString() | ||
|
||
return "$name.rs.mod" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
apps/intellij-plugin/src/main/kotlin/ai/hash/rustextra/projectView/ModuleNode.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...llij-plugin/src/main/kotlin/ai/hash/rustextra/projectView/ModuleNodeToolWindowListener.kt
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...j-plugin/src/main/kotlin/ai/hash/rustextra/projectView/ModuleNodeTreeExpansionListener.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters