Render warning on 'class object' as deprecated
This commit is contained in:
@@ -23,6 +23,7 @@ import com.intellij.lang.annotation.Annotation
|
||||
import com.intellij.lang.annotation.AnnotationHolder
|
||||
import com.intellij.lang.annotation.Annotator
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import com.intellij.psi.MultiRangeReference
|
||||
@@ -147,6 +148,9 @@ public open class JetPsiChecker : Annotator, HighlightRangeExtension {
|
||||
}
|
||||
for (textRange in textRanges) {
|
||||
val annotation = holder.createWarningAnnotation(textRange, getDefaultMessage(diagnostic))
|
||||
|
||||
if (factory == Errors.DEPRECATED_CLASS_OBJECT_SYNTAX) annotation.setTextAttributes(CodeInsightColors.DEPRECATED_ATTRIBUTES)
|
||||
|
||||
setUpAnnotation(diagnostic, annotation, if (factory in Errors.UNUSED_ELEMENT_DIAGNOSTICS)
|
||||
ProblemHighlightType.LIKE_UNUSED_SYMBOL
|
||||
else
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class A {
|
||||
<warning textAttributesKey="DEPRECATED_ATTRIBUTES">class object</warning> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
<warning textAttributesKey="DEPRECATED_ATTRIBUTES">class object C</warning> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
default <warning textAttributesKey="DEPRECATED_ATTRIBUTES">class object G</warning> {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -136,6 +136,12 @@ public class JetPsiCheckerTestGenerated extends AbstractJetPsiCheckerTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DeprecatedClassObjectSyntax.kt")
|
||||
public void testDeprecatedClassObjectSyntax() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/checker/DeprecatedClassObjectSyntax.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionFunctions.kt")
|
||||
public void testExtensionFunctions() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/checker/ExtensionFunctions.kt");
|
||||
|
||||
Reference in New Issue
Block a user