mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-148254 Suppress sentence-starting and -ending punctuation errors in multi-sentence literals
GitOrigin-RevId: 79647bfb4c5901a3267e39da86a2ab95e3c32d1a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
47e6960faf
commit
934ecd177b
@@ -1,14 +1,8 @@
|
||||
package com.intellij.grazie.text
|
||||
|
||||
import com.intellij.grazie.utils.Text
|
||||
|
||||
/** Enable this filter for your language to filter [RuleGroup.LITERALS] in its string literals */
|
||||
class LiteralProblemFilter : ProblemFilter() {
|
||||
private val ignoredRules = RuleGroup.LITERALS
|
||||
|
||||
override fun shouldIgnore(problem: TextProblem): Boolean {
|
||||
return problem.text.domain == TextContent.TextDomain.LITERALS &&
|
||||
Text.isSingleSentence(problem.text) &&
|
||||
problem.fitsGroup(ignoredRules)
|
||||
return problem.text.domain == TextContent.TextDomain.LITERALS && problem.fitsGroup(RuleGroup.LITERALS)
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ class Main {
|
||||
System.out.println("The path is ../data/test.avi");
|
||||
}
|
||||
|
||||
String messagePart = "; fragment of one sentence. This is another sentence,";
|
||||
|
||||
String gitCherryPickPattern = "(cherry picked from "; // hard-coding the string git outputs
|
||||
String nonGitCherryPick = "I'd like to <GRAMMAR_ERROR descr="EN_COMPOUNDS_CHERRY_PICK">cherry pick</GRAMMAR_ERROR> this";
|
||||
}
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
<extensions defaultExtensionNs="com.intellij.grazie">
|
||||
<textExtractor language="kotlin" implementationClass="org.jetbrains.kotlin.idea.grazie.KotlinTextExtractor"/>
|
||||
<problemFilter language="kotlin" implementationClass="org.jetbrains.kotlin.idea.grazie.KotlinProblemFilter"/>
|
||||
<problemFilter language="kotlin" implementationClass="com.intellij.grazie.text.LiteralProblemFilter"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -2,9 +2,7 @@
|
||||
package org.jetbrains.kotlin.idea.grazie
|
||||
|
||||
import com.intellij.grazie.text.ProblemFilter
|
||||
import com.intellij.grazie.text.RuleGroup
|
||||
import com.intellij.grazie.text.TextContent.TextDomain.DOCUMENTATION
|
||||
import com.intellij.grazie.text.TextContent.TextDomain.LITERALS
|
||||
import com.intellij.grazie.text.TextProblem
|
||||
import com.intellij.grazie.utils.ProblemFilterUtil
|
||||
import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag
|
||||
@@ -12,9 +10,6 @@ import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag
|
||||
class KotlinProblemFilter : ProblemFilter() {
|
||||
override fun shouldIgnore(problem: TextProblem): Boolean {
|
||||
val domain = problem.text.domain
|
||||
if (domain == LITERALS) {
|
||||
return problem.fitsGroup(RuleGroup.LITERALS)
|
||||
}
|
||||
if (domain == DOCUMENTATION && problem.text.commonParent::class == KDocTag::class &&
|
||||
(ProblemFilterUtil.isUndecoratedSingleSentenceIssue(problem) || ProblemFilterUtil.isInitialCasingIssue(problem))) {
|
||||
return true
|
||||
|
||||
@@ -9,15 +9,9 @@ import com.intellij.grazie.utils.ProblemFilterUtil
|
||||
class PythonProblemFilter : ProblemFilter() {
|
||||
override fun shouldIgnore(problem: TextProblem): Boolean {
|
||||
val domain = problem.text.domain
|
||||
if (domain == TextContent.TextDomain.LITERALS) {
|
||||
return problem.fitsGroup(RuleGroup.LITERALS)
|
||||
}
|
||||
if (domain == TextContent.TextDomain.DOCUMENTATION &&
|
||||
(ProblemFilterUtil.isUndecoratedSingleSentenceIssue(problem) ||
|
||||
ProblemFilterUtil.isInitialCasingIssue(problem) ||
|
||||
problem.fitsGroup(RuleGroup(RuleGroup.UNDECORATED_SENTENCE_SEPARATION)))) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return domain == TextContent.TextDomain.DOCUMENTATION &&
|
||||
(ProblemFilterUtil.isUndecoratedSingleSentenceIssue(problem) ||
|
||||
ProblemFilterUtil.isInitialCasingIssue(problem) ||
|
||||
problem.fitsGroup(RuleGroup(RuleGroup.UNDECORATED_SENTENCE_SEPARATION)))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user