TrailingCommaInspection: don't report Missing line break for when entry that has no trailing comma
#KT-38568 Fixed
This commit is contained in:
committed by
Yan Zhulanow
parent
3272b8fc2c
commit
25787eb869
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.idea.util.isComma
|
|||||||
import org.jetbrains.kotlin.idea.util.isLineBreak
|
import org.jetbrains.kotlin.idea.util.isLineBreak
|
||||||
import org.jetbrains.kotlin.idea.util.leafIgnoringWhitespaceAndComments
|
import org.jetbrains.kotlin.idea.util.leafIgnoringWhitespaceAndComments
|
||||||
import org.jetbrains.kotlin.psi.KtElement
|
import org.jetbrains.kotlin.psi.KtElement
|
||||||
|
import org.jetbrains.kotlin.psi.KtWhenEntry
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||||
import javax.swing.JComponent
|
import javax.swing.JComponent
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
@@ -62,7 +63,9 @@ class TrailingCommaInspection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val last = TrailingCommaHelper.elementAfterLastElement(commaOwner)
|
val last = TrailingCommaHelper.elementAfterLastElement(commaOwner)
|
||||||
if (last?.prevLeaf(true)?.isLineBreak() == false) {
|
val whenEntryWithoutTrailingComma =
|
||||||
|
commaOwner is KtWhenEntry && TrailingCommaHelper.trailingCommaOrLastElement(commaOwner)?.isComma != true
|
||||||
|
if (last?.prevLeaf(true)?.isLineBreak() == false && !whenEntryWithoutTrailingComma) {
|
||||||
registerProblemForLineBreak(
|
registerProblemForLineBreak(
|
||||||
commaOwner,
|
commaOwner,
|
||||||
last,
|
last,
|
||||||
|
|||||||
@@ -5507,18 +5507,6 @@
|
|||||||
<offset>8</offset>
|
<offset>8</offset>
|
||||||
<length>1</length>
|
<length>1</length>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
|
||||||
<file>WhenEntry.kt</file>
|
|
||||||
<line>15</line>
|
|
||||||
<module>testProject</module>
|
|
||||||
<package>light_idea_test_case</package>
|
|
||||||
<entry_point TYPE="file" FQNAME="WhenEntry.kt" />
|
|
||||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">Trailing comma recommendations</problem_class>
|
|
||||||
<description>Missing line break</description>
|
|
||||||
<highlighted_element>-</highlighted_element>
|
|
||||||
<offset>44</offset>
|
|
||||||
<length>1</length>
|
|
||||||
</problem>
|
|
||||||
<problem>
|
<problem>
|
||||||
<file>WhenEntry.kt</file>
|
<file>WhenEntry.kt</file>
|
||||||
<line>21</line>
|
<line>21</line>
|
||||||
@@ -5555,28 +5543,4 @@
|
|||||||
<offset>9</offset>
|
<offset>9</offset>
|
||||||
<length>1</length>
|
<length>1</length>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
|
||||||
<file>WhenEntry.kt</file>
|
|
||||||
<line>54</line>
|
|
||||||
<module>testProject</module>
|
|
||||||
<package>light_idea_test_case</package>
|
|
||||||
<entry_point TYPE="file" FQNAME="WhenEntry.kt" />
|
|
||||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">Trailing comma recommendations</problem_class>
|
|
||||||
<description>Missing line break</description>
|
|
||||||
<highlighted_element>-</highlighted_element>
|
|
||||||
<offset>15</offset>
|
|
||||||
<length>1</length>
|
|
||||||
</problem>
|
|
||||||
<problem>
|
|
||||||
<file>WhenEntry.kt</file>
|
|
||||||
<line>62</line>
|
|
||||||
<module>testProject</module>
|
|
||||||
<package>light_idea_test_case</package>
|
|
||||||
<entry_point TYPE="file" FQNAME="WhenEntry.kt" />
|
|
||||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">Trailing comma recommendations</problem_class>
|
|
||||||
<description>Missing line break</description>
|
|
||||||
<highlighted_element>-</highlighted_element>
|
|
||||||
<offset>15</offset>
|
|
||||||
<length>1</length>
|
|
||||||
</problem>
|
|
||||||
</problems>
|
</problems>
|
||||||
@@ -1907,18 +1907,6 @@
|
|||||||
<offset>44</offset>
|
<offset>44</offset>
|
||||||
<length>1</length>
|
<length>1</length>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
|
||||||
<file>WhenEntry.kt</file>
|
|
||||||
<line>15</line>
|
|
||||||
<module>testProject</module>
|
|
||||||
<package>light_idea_test_case</package>
|
|
||||||
<entry_point TYPE="file" FQNAME="WhenEntry.kt" />
|
|
||||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">Trailing comma recommendations</problem_class>
|
|
||||||
<description>Missing line break</description>
|
|
||||||
<highlighted_element>-</highlighted_element>
|
|
||||||
<offset>44</offset>
|
|
||||||
<length>1</length>
|
|
||||||
</problem>
|
|
||||||
<problem>
|
<problem>
|
||||||
<file>WhenEntry.kt</file>
|
<file>WhenEntry.kt</file>
|
||||||
<line>15</line>
|
<line>15</line>
|
||||||
@@ -1979,18 +1967,6 @@
|
|||||||
<offset>8</offset>
|
<offset>8</offset>
|
||||||
<length>1</length>
|
<length>1</length>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
|
||||||
<file>WhenEntry.kt</file>
|
|
||||||
<line>54</line>
|
|
||||||
<module>testProject</module>
|
|
||||||
<package>light_idea_test_case</package>
|
|
||||||
<entry_point TYPE="file" FQNAME="WhenEntry.kt" />
|
|
||||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">Trailing comma recommendations</problem_class>
|
|
||||||
<description>Missing line break</description>
|
|
||||||
<highlighted_element>-</highlighted_element>
|
|
||||||
<offset>15</offset>
|
|
||||||
<length>1</length>
|
|
||||||
</problem>
|
|
||||||
<problem>
|
<problem>
|
||||||
<file>WhenEntry.kt</file>
|
<file>WhenEntry.kt</file>
|
||||||
<line>54</line>
|
<line>54</line>
|
||||||
@@ -2003,18 +1979,6 @@
|
|||||||
<offset>8</offset>
|
<offset>8</offset>
|
||||||
<length>1</length>
|
<length>1</length>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
|
||||||
<file>WhenEntry.kt</file>
|
|
||||||
<line>62</line>
|
|
||||||
<module>testProject</module>
|
|
||||||
<package>light_idea_test_case</package>
|
|
||||||
<entry_point TYPE="file" FQNAME="WhenEntry.kt" />
|
|
||||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">Trailing comma recommendations</problem_class>
|
|
||||||
<description>Missing line break</description>
|
|
||||||
<highlighted_element>-</highlighted_element>
|
|
||||||
<offset>15</offset>
|
|
||||||
<length>1</length>
|
|
||||||
</problem>
|
|
||||||
<problem>
|
<problem>
|
||||||
<file>WhenEntry.kt</file>
|
<file>WhenEntry.kt</file>
|
||||||
<line>62</line>
|
<line>62</line>
|
||||||
|
|||||||
Reference in New Issue
Block a user