Add quick-fix for empty brackets after primary constructor

So #KT-18534 Fixed
This commit is contained in:
Toshiaki Kameyama
2017-06-22 06:37:39 +03:00
committed by Mikhail Glukhikh
parent 69457ef3f1
commit ed04b4debd
12 changed files with 99 additions and 1 deletions
@@ -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);
@@ -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))
}