[grazie+python] analyze adjacent comment texts together

GitOrigin-RevId: 63f0a7e72d36c3d040247e00795775f47c9d7274
This commit is contained in:
Peter Gromov
2021-07-01 09:57:25 +00:00
committed by intellij-monorepo-bot
parent 33884c70e3
commit d3dfcb4ace
3 changed files with 11 additions and 1 deletions

View File

@@ -4,9 +4,11 @@ package com.intellij.grazie.ide.language.python
import com.intellij.grazie.text.TextContent
import com.intellij.grazie.text.TextContentBuilder
import com.intellij.grazie.text.TextExtractor
import com.intellij.grazie.utils.getNotSoDistantSimilarSiblings
import com.intellij.psi.PsiElement
import com.intellij.psi.impl.source.tree.LeafPsiElement
import com.intellij.psi.impl.source.tree.PsiCommentImpl
import com.intellij.psi.tree.TokenSet
import com.intellij.psi.util.elementType
import com.jetbrains.python.PyTokenTypes
import com.jetbrains.python.PyTokenTypes.FSTRING_TEXT
@@ -21,7 +23,8 @@ internal class PythonTextExtractor : TextExtractor() {
}
if (root is PsiCommentImpl) {
return TextContentBuilder.FromPsi.removingIndents(" \t#").build(root, TextContent.TextDomain.COMMENTS)
val siblings = getNotSoDistantSimilarSiblings(root) { it is PsiCommentImpl }
return TextContent.joinWithWhitespace(siblings.mapNotNull { TextContent.builder().build(it, TextContent.TextDomain.COMMENTS) })
}
return null