generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
- Support invoke dynamic stmt | ||
- Support monitor stmts | ||
- Fold method body | ||
|
||
## [0.1.2] - 2023-10-16 | ||
|
||
|
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/pascal/taie/intellij/tir/editing/TirFoldingBuilder.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,29 @@ | ||
package pascal.taie.intellij.tir.editing | ||
|
||
import com.intellij.lang.ASTNode | ||
import com.intellij.lang.folding.FoldingBuilderEx | ||
import com.intellij.lang.folding.FoldingDescriptor | ||
import com.intellij.openapi.editor.Document | ||
import com.intellij.openapi.project.DumbAware | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.SyntaxTraverser | ||
import pascal.taie.intellij.tir.syntax.psi.TirMethodBody | ||
|
||
class TirFoldingBuilder : FoldingBuilderEx(), DumbAware { | ||
override fun buildFoldRegions( | ||
root: PsiElement, document: Document, quick: Boolean | ||
) = SyntaxTraverser | ||
.psiTraverser(root) | ||
.filter { it is TirMethodBody } | ||
.map { TirFoldingDescriptor(it, "{…}") } | ||
.toList().toTypedArray() | ||
|
||
override fun getPlaceholderText(node: ASTNode) = "…" | ||
|
||
override fun isCollapsedByDefault(node: ASTNode) = false | ||
|
||
class TirFoldingDescriptor(element: PsiElement, private val holder: String) : | ||
FoldingDescriptor(element.node, element.textRange) { | ||
override fun getPlaceholderText() = holder | ||
} | ||
} |
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