Add quick-fix for empty brackets after primary constructor
So #KT-18534 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
69457ef3f1
commit
ed04b4debd
@@ -273,6 +273,8 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<KtElement> MISSING_CONSTRUCTOR_KEYWORD = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> MISSING_CONSTRUCTOR_BRACKETS = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> NON_PRIVATE_CONSTRUCTOR_IN_ENUM = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> NON_PRIVATE_CONSTRUCTOR_IN_SEALED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
|
||||
+1
@@ -591,6 +591,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(ALWAYS_NULL, "The result of the expression is always null");
|
||||
|
||||
MAP.put(MISSING_CONSTRUCTOR_KEYWORD, "Use 'constructor' keyword after modifiers of primary constructor");
|
||||
MAP.put(MISSING_CONSTRUCTOR_BRACKETS, "Constructor requires brackets");
|
||||
|
||||
MAP.put(NON_PRIVATE_CONSTRUCTOR_IN_ENUM, "Constructor must be private in enum class");
|
||||
MAP.put(NON_PRIVATE_CONSTRUCTOR_IN_SEALED, "Constructor must be private in sealed class");
|
||||
|
||||
@@ -449,6 +449,10 @@ class DeclarationsChecker(
|
||||
declaration.modifierList?.let { trace.report(MISSING_CONSTRUCTOR_KEYWORD.on(it)) }
|
||||
}
|
||||
|
||||
if (declaration.valueParameterList == null) {
|
||||
declaration.getConstructorKeyword()?.let { trace.report(MISSING_CONSTRUCTOR_BRACKETS.on(it)) }
|
||||
}
|
||||
|
||||
if (classOrObject !is KtClass) {
|
||||
trace.report(CONSTRUCTOR_IN_OBJECT.on(declaration))
|
||||
}
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
class A private <!MISSING_CONSTRUCTOR_BRACKETS!>constructor<!><!SYNTAX!><!> {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
private constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -12904,6 +12904,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primaryConstructorMissingBrackets.kt")
|
||||
public void testPrimaryConstructorMissingBrackets() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingBrackets.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primaryConstructorMissingKeyword.kt")
|
||||
public void testPrimaryConstructorMissingKeyword() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.kt");
|
||||
|
||||
Reference in New Issue
Block a user