Skip to content

Commit

Permalink
refactor: handle structural tabbing for the breaking change symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
lppedd committed Mar 22, 2023
1 parent 4e5ae66 commit c15795c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ internal class CommitTabAction : TabAction() {
val elementAtCaret = psiFile?.findElementAt(editor.getCaretOffset())

if (elementAtCaret is ConventionalCommitScopeOpenParenPsiElement ||
elementAtCaret is ConventionalCommitScopeCloseParenPsiElement) {
elementAtCaret is ConventionalCommitScopeCloseParenPsiElement ||
elementAtCaret is ConventionalCommitBreakingChangePsiElement) {
editor.putUserData(moveCaretKey, 1)
return true
} else if (elementAtCaret is ConventionalCommitSeparatorPsiElement) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.lppedd.cc.language.parser

import com.github.lppedd.cc.language.lexer.ConventionalCommitTokenType.Companion.BODY
import com.github.lppedd.cc.language.lexer.ConventionalCommitTokenType.Companion.BREAKING_CHANGE
import com.github.lppedd.cc.language.lexer.ConventionalCommitTokenType.Companion.FOOTER_TYPE
import com.github.lppedd.cc.language.lexer.ConventionalCommitTokenType.Companion.FOOTER_TYPE_BREAKING_CHANGE
import com.github.lppedd.cc.language.lexer.ConventionalCommitTokenType.Companion.FOOTER_VALUE
Expand All @@ -27,6 +28,7 @@ internal class ConventionalCommitASTFactory : ASTFactory() {
tokensMap[SCOPE_OPEN_PAREN] = ::ConventionalCommitScopeOpenParenPsiElement
tokensMap[SCOPE] = ::ConventionalCommitScopeValuePsiElement
tokensMap[SCOPE_CLOSE_PAREN] = ::ConventionalCommitScopeCloseParenPsiElement
tokensMap[BREAKING_CHANGE] = ::ConventionalCommitBreakingChangePsiElement
tokensMap[SEPARATOR] = ::ConventionalCommitSeparatorPsiElement
tokensMap[SUBJECT] = ::ConventionalCommitSubjectPsiElement
tokensMap[BODY] = ::ConventionalCommitBodyPsiElement
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.lppedd.cc.language.psi

import com.intellij.psi.impl.source.tree.LeafPsiElement
import com.intellij.psi.tree.IElementType

/**
* @author Edoardo Luppi
*/
class ConventionalCommitBreakingChangePsiElement(
type: IElementType,
text: CharSequence,
) : LeafPsiElement(type, text) {
override fun toString(): String =
"ConventionalCommitBreakingChangePsiElement"
}

0 comments on commit c15795c

Please sign in to comment.