Mute false positive duplicate warnings in highlighting in 191
This commit is contained in:
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
||||||
|
|
||||||
<info descr="null" textAttributesKey="KOTLIN_ANNOTATION">@Target</info>(<info descr="null" textAttributesKey="KOTLIN_CLASS">AnnotationTarget</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">CLASS</info>, <info descr="null" textAttributesKey="KOTLIN_CLASS">AnnotationTarget</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">EXPRESSION</info>)
|
<info descr="null" textAttributesKey="KOTLIN_ANNOTATION">@Target</info>(<info descr="null" textAttributesKey="KOTLIN_CLASS">AnnotationTarget</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">CLASS</info>, <info descr="null" textAttributesKey="KOTLIN_CLASS">AnnotationTarget</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">EXPRESSION</info>)
|
||||||
<info descr="null" textAttributesKey="KOTLIN_ANNOTATION">@Retention</info>(<info descr="null" textAttributesKey="KOTLIN_CLASS">AnnotationRetention</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">SOURCE</info>)
|
<info descr="null" textAttributesKey="KOTLIN_ANNOTATION">@Retention</info>(<info descr="null" textAttributesKey="KOTLIN_CLASS">AnnotationRetention</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">SOURCE</info>)
|
||||||
<info descr="null">annotation</info> class <info descr="null">Ann</info>
|
<info descr="null">annotation</info> class <info descr="null">Ann</info>
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
||||||
|
|
||||||
<info descr="null">data</info> class <info descr="null">Box</info>(val <info descr="null">v</info>: <info descr="null">Int</info>)
|
<info descr="null">data</info> class <info descr="null">Box</info>(val <info descr="null">v</info>: <info descr="null">Int</info>)
|
||||||
fun <info descr="null">consume</info>(<warning descr="[UNUSED_PARAMETER] Parameter 'x' is never used"><info descr="null">x</info></warning>: <info descr="null">Int</info>) {}
|
fun <info descr="null">consume</info>(<warning descr="[UNUSED_PARAMETER] Parameter 'x' is never used"><info descr="null">x</info></warning>: <info descr="null">Int</info>) {}
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
@@ -1,3 +1,6 @@
|
|||||||
|
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
||||||
|
// FALSE_POSITIVE
|
||||||
|
|
||||||
var <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">my</info></info> = 0
|
var <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">my</info></info> = 0
|
||||||
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() = <info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">field</info></info>
|
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() = <info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">field</info></info>
|
||||||
<info textAttributesKey="KOTLIN_KEYWORD">set</info>(<info textAttributesKey="KOTLIN_PARAMETER">arg</info>) {
|
<info textAttributesKey="KOTLIN_KEYWORD">set</info>(<info textAttributesKey="KOTLIN_PARAMETER">arg</info>) {
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
||||||
|
|
||||||
fun <info descr="null">bar</info>(<info descr="null">block</info>: () -> <info descr="null">Int</info>) = <info descr="null"><info descr="null">block</info></info>()
|
fun <info descr="null">bar</info>(<info descr="null">block</info>: () -> <info descr="null">Int</info>) = <info descr="null"><info descr="null">block</info></info>()
|
||||||
|
|
||||||
fun <info descr="null">foo</info>(): <info descr="null">Int</info> {
|
fun <info descr="null">foo</info>(): <info descr="null">Int</info> {
|
||||||
|
|||||||
+2
@@ -1,2 +1,4 @@
|
|||||||
|
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
||||||
|
|
||||||
typealias <info textAttributesKey="KOTLIN_TYPE_ALIAS">Predicate</info><<info textAttributesKey="KOTLIN_TYPE_PARAMETER">T</info>> = (<info textAttributesKey="KOTLIN_TYPE_PARAMETER">T</info>) -> <info textAttributesKey="KOTLIN_CLASS">Boolean</info>
|
typealias <info textAttributesKey="KOTLIN_TYPE_ALIAS">Predicate</info><<info textAttributesKey="KOTLIN_TYPE_PARAMETER">T</info>> = (<info textAttributesKey="KOTLIN_TYPE_PARAMETER">T</info>) -> <info textAttributesKey="KOTLIN_CLASS">Boolean</info>
|
||||||
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">baz</info>(<info textAttributesKey="KOTLIN_PARAMETER">p</info>: <info textAttributesKey="KOTLIN_TYPE_ALIAS">Predicate</info><<info textAttributesKey="KOTLIN_CLASS">Int</info>>) = <info textAttributesKey="KOTLIN_PARAMETER"><info textAttributesKey="KOTLIN_VARIABLE_AS_FUNCTION">p</info></info>(42)
|
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">baz</info>(<info textAttributesKey="KOTLIN_PARAMETER">p</info>: <info textAttributesKey="KOTLIN_TYPE_ALIAS">Predicate</info><<info textAttributesKey="KOTLIN_CLASS">Int</info>>) = <info textAttributesKey="KOTLIN_PARAMETER"><info textAttributesKey="KOTLIN_VARIABLE_AS_FUNCTION">p</info></info>(42)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
||||||
|
|
||||||
var <info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_PACKAGE_PROPERTY">x</info></info> = 5
|
var <info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_PACKAGE_PROPERTY">x</info></info> = 5
|
||||||
|
|
||||||
val <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="KOTLIN_EXTENSION_PROPERTY">sq</info> : <info textAttributesKey="KOTLIN_CLASS">Int</info>
|
val <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="KOTLIN_EXTENSION_PROPERTY">sq</info> : <info textAttributesKey="KOTLIN_CLASS">Int</info>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
||||||
|
|
||||||
interface <info textAttributesKey="KOTLIN_TRAIT">FunctionLike</info> {
|
interface <info textAttributesKey="KOTLIN_TRAIT">FunctionLike</info> {
|
||||||
<info descr="null" textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">operator</info> fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">invoke</info>() {
|
<info descr="null" textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">operator</info> fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">invoke</info>() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,19 +23,31 @@ public abstract class AbstractHighlightingTest extends KotlinLightCodeInsightFix
|
|||||||
boolean checkInfos = !InTextDirectivesUtils.isDirectiveDefined(fileText, "// NO_CHECK_INFOS");
|
boolean checkInfos = !InTextDirectivesUtils.isDirectiveDefined(fileText, "// NO_CHECK_INFOS");
|
||||||
boolean checkWeakWarnings = !InTextDirectivesUtils.isDirectiveDefined(fileText, "// NO_CHECK_WEAK_WARNINGS");
|
boolean checkWeakWarnings = !InTextDirectivesUtils.isDirectiveDefined(fileText, "// NO_CHECK_WEAK_WARNINGS");
|
||||||
boolean checkWarnings = !InTextDirectivesUtils.isDirectiveDefined(fileText, "// NO_CHECK_WARNINGS");
|
boolean checkWarnings = !InTextDirectivesUtils.isDirectiveDefined(fileText, "// NO_CHECK_WARNINGS");
|
||||||
|
boolean expectedDuplicatedHighlighting = InTextDirectivesUtils.isDirectiveDefined(fileText, "// EXPECTED_DUPLICATED_HIGHLIGHTING");
|
||||||
|
|
||||||
myFixture.configureByFile(filePath);
|
myFixture.configureByFile(filePath);
|
||||||
|
|
||||||
try {
|
withExpectedDuplicatedHighlighting(expectedDuplicatedHighlighting, () -> {
|
||||||
myFixture.checkHighlighting(checkWarnings, checkInfos, checkWeakWarnings);
|
try {
|
||||||
}
|
myFixture.checkHighlighting(checkWarnings, checkInfos, checkWeakWarnings);
|
||||||
catch (FileComparisonFailure e) {
|
}
|
||||||
List<HighlightInfo> highlights =
|
catch (FileComparisonFailure e) {
|
||||||
DaemonCodeAnalyzerImpl.getHighlights(myFixture.getDocument(myFixture.getFile()), null, myFixture.getProject());
|
List<HighlightInfo> highlights =
|
||||||
String text = myFixture.getFile().getText();
|
DaemonCodeAnalyzerImpl.getHighlights(myFixture.getDocument(myFixture.getFile()), null, myFixture.getProject());
|
||||||
|
String text = myFixture.getFile().getText();
|
||||||
|
|
||||||
System.out.println(TagsTestDataUtil.insertInfoTags(highlights, text));
|
System.out.println(TagsTestDataUtil.insertInfoTags(highlights, text));
|
||||||
throw e;
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void withExpectedDuplicatedHighlighting(boolean expectedDuplicatedHighlighting, Runnable runnable) {
|
||||||
|
if (!expectedDuplicatedHighlighting) {
|
||||||
|
runnable.run();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DuplicateHighlightingKt.expectedDuplicatedHighlighting(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.highlighter
|
||||||
|
|
||||||
|
// Idea 191 has an additional check for duplicate highlighting
|
||||||
|
// BUNCH: 183
|
||||||
|
fun expectedDuplicatedHighlighting(runnable: Runnable) {
|
||||||
|
runnable.run()
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.highlighter
|
||||||
|
|
||||||
|
import com.intellij.testFramework.ExpectedHighlightingData
|
||||||
|
|
||||||
|
// Idea 191 has an additional check for duplicate highlighting
|
||||||
|
// BUNCH: 183
|
||||||
|
fun expectedDuplicatedHighlighting(runnable: Runnable) {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
ExpectedHighlightingData.expectedDuplicatedHighlighting(runnable)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user