Skip to content

Commit

Permalink
chore: isWhiteSpaceOrNewLine
Browse files Browse the repository at this point in the history
  • Loading branch information
BFergerson committed Apr 1, 2024
1 parent 75a2154 commit 81d97c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package spp.jetbrains.artifact.service
import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiWhiteSpace
import spp.jetbrains.artifact.model.FunctionArtifact
import spp.jetbrains.artifact.service.define.AbstractSourceMarkerService
import spp.jetbrains.artifact.service.define.IArtifactTypeService
Expand Down Expand Up @@ -51,6 +52,14 @@ object ArtifactTypeService : AbstractSourceMarkerService<IArtifactTypeService>()
return getService(element.language).isComment(element)
}

override fun isWhiteSpaceOrNewLine(element: PsiElement): Boolean {
//language-agnostic check
if (element is PsiWhiteSpace) return true

//language-specific check
return getService(element.language).isWhiteSpaceOrNewLine(element)
}

override fun getType(element: PsiElement): ArtifactType? {
if (!isSupported(element)) return null
//language-agnostic check
Expand Down Expand Up @@ -123,6 +132,10 @@ fun PsiElement.isComment(): Boolean {
return ArtifactTypeService.isComment(this)
}

fun PsiElement.isWhiteSpaceOrNewLine(): Boolean {
return ArtifactTypeService.isWhiteSpaceOrNewLine(this)
}

fun PsiElement.getType(): ArtifactType? {
return ArtifactTypeService.getType(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface IArtifactTypeService : ISourceMarkerService {
fun getAnnotationOwnerIfAnnotation(element: PsiElement): PsiElement?
fun getAnnotationOwnerIfAnnotation(element: PsiElement, line: Int): PsiElement?
fun isComment(element: PsiElement): Boolean
fun isWhiteSpaceOrNewLine(element: PsiElement): Boolean = false
fun getType(element: PsiElement): ArtifactType?

fun isLiteral(element: PsiElement): Boolean {
Expand Down

0 comments on commit 81d97c6

Please sign in to comment.