diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetMultiDeclaration.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetMultiDeclaration.java index 129364dc992..0dad5633e66 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetMultiDeclaration.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetMultiDeclaration.java @@ -22,13 +22,10 @@ import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; -import org.jetbrains.jet.lexer.JetTokens; import java.util.List; -import static org.jetbrains.jet.lexer.JetTokens.EQ; -import static org.jetbrains.jet.lexer.JetTokens.VAL_KEYWORD; -import static org.jetbrains.jet.lexer.JetTokens.VAR_KEYWORD; +import static org.jetbrains.jet.lexer.JetTokens.*; public class JetMultiDeclaration extends JetDeclarationImpl { public JetMultiDeclaration(@NotNull ASTNode node) { @@ -58,4 +55,9 @@ public class JetMultiDeclaration extends JetDeclarationImpl { } return PsiTreeUtil.getNextSiblingOfType(eqNode.getPsi(), JetExpression.class); } + + @Nullable + public ASTNode getValOrVarNode() { + return getNode().findChildByType(TokenSet.create(VAL_KEYWORD, VAR_KEYWORD)); + } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java index a05442b676e..b3c25a4439d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java @@ -197,11 +197,22 @@ public class JetPsiFactory { } public static JetModifierList createModifierList(Project project, JetKeywordToken modifier) { - String text = modifier.getValue() + " val x"; - JetProperty property = createProperty(project, text); + return createModifierList(project, modifier.getValue()); + } + + public static JetModifierList createModifierList(Project project, String text) { + JetProperty property = createProperty(project, text + " val x"); return property.getModifierList(); } + @NotNull + public static JetAnnotation createAnnotation(Project project, String text) { + JetProperty property = createProperty(project, text + " val x"); + JetModifierList modifierList = property.getModifierList(); + assert modifierList != null; + return modifierList.getAnnotations().get(0); + } + public static JetModifierList createConstructorModifierList(Project project, JetKeywordToken modifier) { JetClass aClass = createClass(project, "class C " + modifier.getValue() + " (){}"); return aClass.getPrimaryConstructorModifierList(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java index a462ab8f612..20694ec5204 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java @@ -1003,4 +1003,22 @@ public class JetPsiUtil { return new StringBuilder(inFileParent.getText()).insert(inFileParentOffset, "").toString(); } + + @Nullable + public static JetModifierList replaceModifierList(@NotNull JetModifierListOwner owner, @Nullable JetModifierList modifierList) { + JetModifierList oldModifierList = owner.getModifierList(); + if (modifierList == null) { + if (oldModifierList != null) oldModifierList.delete(); + return null; + } + else { + if (oldModifierList == null) { + PsiElement firstChild = owner.getFirstChild(); + return (JetModifierList) owner.addBefore(modifierList, firstChild); + } + else { + return (JetModifierList) oldModifierList.replace(modifierList); + } + } + } } diff --git a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties index da67c03c6c3..26f81e9529c 100644 --- a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties +++ b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties @@ -278,4 +278,7 @@ find.what.derived.classes.checkbox=&Derived classes convert.to.extension=Convert to extension replace.by.reconstructed.type.family.name=Replace by Reconstructed Type -replace.by.reconstructed.type=Replace by ''{0}'' \ No newline at end of file +replace.by.reconstructed.type=Replace by ''{0}'' + +suppress.warnings.family=Suppress Warnings +suppress.warning.for=Suppress ''{0}'' for {1} {2} \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java index cd38a64effe..d655e1673df 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java @@ -17,6 +17,7 @@ package org.jetbrains.jet.plugin.highlighter; import com.google.common.collect.Sets; +import com.intellij.codeInsight.intention.EmptyIntentionAction; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.lang.annotation.Annotation; @@ -225,6 +226,17 @@ public class JetPsiChecker implements Annotator { annotation.registerFix(action); } + // Making warnings suppressable + if (diagnostic.getSeverity() == Severity.WARNING) { + annotation.setProblemGroup(new KotlinSuppressableWarningProblemGroup(diagnostic.getFactory())); + + List fixes = annotation.getQuickFixes(); + if (fixes == null || fixes.isEmpty()) { + // if there are no quick fixes we need to register an EmptyIntentionAction to enable 'suppress' actions + annotation.registerFix(new EmptyIntentionAction(diagnostic.getFactory().getName())); + } + } + return annotation; } diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/KotlinSuppressableWarningProblemGroup.kt b/idea/src/org/jetbrains/jet/plugin/highlighter/KotlinSuppressableWarningProblemGroup.kt new file mode 100644 index 00000000000..ae708da52cb --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/KotlinSuppressableWarningProblemGroup.kt @@ -0,0 +1,101 @@ +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.highlighter + +import com.intellij.codeInspection.SuppressableProblemGroup +import com.intellij.psi.PsiElement +import com.intellij.codeInspection.SuppressIntentionAction +import org.jetbrains.jet.lang.diagnostics.Severity +import java.util.Collections +import org.jetbrains.jet.plugin.quickfix.KotlinSuppressIntentionAction +import org.jetbrains.jet.lang.psi.* +import org.jetbrains.jet.plugin.quickfix.DeclarationKind +import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory +import com.intellij.psi.util.PsiTreeUtil + +class KotlinSuppressableWarningProblemGroup( + private val diagnosticFactory: DiagnosticFactory +) : SuppressableProblemGroup { + + { + assert (diagnosticFactory.getSeverity() == Severity.WARNING) + } + + override fun getProblemName() = diagnosticFactory.getName() + + override fun getSuppressActions(element: PsiElement?): Array { + if (element == null) + return SuppressIntentionAction.EMPTY_ARRAY + + val actions = createSuppressWarningActions(element, diagnosticFactory) + return actions.toArray(Array(actions.size) {null}) as Array + } + +} + +fun createSuppressWarningActions(element: PsiElement, diagnosticFactory: DiagnosticFactory): List { + if (diagnosticFactory.getSeverity() != Severity.WARNING) + return Collections.emptyList() + + val actions = arrayListOf() + var current: PsiElement? = element + while (current != null) { + if (current is JetDeclaration) { + val declaration = current as JetDeclaration + val kind = DeclarationKindDetector.detect(declaration) + if (kind != null) { + actions.add(KotlinSuppressIntentionAction(declaration, diagnosticFactory, kind)) + } + } + + current = current?.getParent() + } + return actions +} + +private object DeclarationKindDetector : JetVisitor() { + + fun detect(declaration: JetDeclaration) = declaration.accept(this, null) + + override fun visitDeclaration(d: JetDeclaration, _: Unit?) = null + + override fun visitClass(d: JetClass, _: Unit?) = detect(d, if (d.isTrait()) "trait" else "class") + + override fun visitClassObject(d: JetClassObject, _: Unit?) = detect(d, "class object", + name = "of " + PsiTreeUtil.getParentOfType(d, javaClass())?.getName()) + + override fun visitNamedFunction(d: JetNamedFunction, _: Unit?) = detect(d, "fun") + + override fun visitProperty(d: JetProperty, _: Unit?) = detect(d, d.getValOrVarNode().getText()!!) + + override fun visitMultiDeclaration(d: JetMultiDeclaration, _: Unit?) = detect(d, d.getValOrVarNode()?.getText() ?: "val", + name = d.getEntries().map { it.getName() }.makeString(", ", "(", ")")) + + override fun visitTypeParameter(d: JetTypeParameter, _: Unit?) = detect(d, "type parameter", newLineNeeded = false) + + override fun visitEnumEntry(d: JetEnumEntry, _: Unit?) = detect(d, "enum entry") + + override fun visitParameter(d: JetParameter, _: Unit?) = detect(d, "parameter", newLineNeeded = false) + + override fun visitObjectDeclaration(d: JetObjectDeclaration, _: Unit?): DeclarationKind? { + if (d.getParent() is JetClassObject) return null + return detect(d, "object") + } + + private fun detect(declaration: JetDeclaration, kind: String, name: String = declaration.getName() ?: "", newLineNeeded: Boolean = true) + = DeclarationKind(kind, name, newLineNeeded) +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/KotlinSuppressIntentionAction.kt b/idea/src/org/jetbrains/jet/plugin/quickfix/KotlinSuppressIntentionAction.kt new file mode 100644 index 00000000000..ecce290046a --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/KotlinSuppressIntentionAction.kt @@ -0,0 +1,104 @@ +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.quickfix + +import com.intellij.codeInsight.intention.IntentionAction +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElement +import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory +import org.jetbrains.jet.lang.diagnostics.Diagnostic +import org.jetbrains.jet.lang.diagnostics.Severity +import org.jetbrains.jet.lang.psi.* +import org.jetbrains.jet.plugin.JetBundle +import java.util.Collections +import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache +import org.jetbrains.jet.lang.resolve.BindingContext +import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns +import com.intellij.codeInspection.SuppressIntentionAction + +public class KotlinSuppressIntentionAction( + private val suppressAt: JetDeclaration, + private val diagnosticFactory: DiagnosticFactory, + private val kind: DeclarationKind +) : SuppressIntentionAction() { + + override fun getFamilyName() = JetBundle.message("suppress.warnings.family") + override fun getText() = JetBundle.message("suppress.warning.for", diagnosticFactory.getName(), kind.kind, kind.name) + + override fun isAvailable(project: Project, editor: Editor?, element: PsiElement) = element.isValid() + + override fun invoke(project: Project, editor: Editor?, element: PsiElement) { + val id = "\"${diagnosticFactory.getName()}\"" + val modifierList = suppressAt.getModifierList() + if (modifierList == null) { + // create a modifier list from scratch + val newModifierList = JetPsiFactory.createModifierList(project, "[suppress($id)]") + val replaced = JetPsiUtil.replaceModifierList(suppressAt, newModifierList) + val whiteSpace = project.createWhiteSpace(kind) + suppressAt.addAfter(whiteSpace, replaced) + } + else { + val entry = findSuppressAnnotation(modifierList) + if (entry == null) { + val newAnnotation = JetPsiFactory.createAnnotation(project, "[suppress($id)]") + val addedAnnotation = modifierList.addBefore(newAnnotation, modifierList.getFirstChild()) + val whiteSpace = project.createWhiteSpace(kind) + modifierList.addAfter(whiteSpace, addedAnnotation) + } + else { + // add new arguments to an existing entry + val args = entry.getValueArgumentList() + val newArgList = JetPsiFactory.createCallArguments(project, "($id)") + if (args == null) { + // new argument list + entry.addAfter(newArgList, entry.getLastChild()) + } + else if (args.getArguments().isEmpty()) { + // replace '()' with a new argument list + args.replace(newArgList) + } + else { + val rightParen = args.getRightParenthesis() + args.addBefore(JetPsiFactory.createComma(project), rightParen) + args.addBefore(JetPsiFactory.createWhiteSpace(project), rightParen) + args.addBefore(newArgList.getArguments()[0], rightParen) + } + } + } + + } + + private fun findSuppressAnnotation(modifierList: JetModifierList): JetAnnotationEntry? { + val suppressAnnotationClass = KotlinBuiltIns.getInstance().getSuppressAnnotationClass() + val context = AnalyzerFacadeWithCache.getContextForElement(modifierList) + for (entry in modifierList.getAnnotationEntries()) { + val annotationDescriptor = context.get(BindingContext.ANNOTATION, entry) + if (annotationDescriptor != null && suppressAnnotationClass.getTypeConstructor() == annotationDescriptor.getType().getConstructor()) { + return entry + } + } + return null + } +} + +public class DeclarationKind(val kind: String, val name: String, val newLineNeeded: Boolean) +private fun Project.createWhiteSpace(kind: DeclarationKind): PsiElement = + if (kind.newLineNeeded) + JetPsiFactory.createNewLine(this) + else + JetPsiFactory.createWhiteSpace(this) \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterParamWithModifier.kt b/idea/testData/quickfix/suppress/annotationPosition/afterParamWithModifier.kt new file mode 100644 index 00000000000..c3a54564ecc --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterParamWithModifier.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for parameter p" "true" + +fun foo([suppress("REDUNDANT_NULLABLE")] vararg p: String??) = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionModifierOnThePreviousLine.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionModifierOnThePreviousLine.kt new file mode 100644 index 00000000000..2c5e84fd98c --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionModifierOnThePreviousLine.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +public +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionModifierOnTheSameLine.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionModifierOnTheSameLine.kt new file mode 100644 index 00000000000..b957caf8145 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionModifierOnTheSameLine.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +public fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionNoModifiers.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionNoModifiers.kt new file mode 100644 index 00000000000..5b773f9a5e3 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionNoModifiers.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressAnotherPreviousLine.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressAnotherPreviousLine.kt new file mode 100644 index 00000000000..391b0f862e4 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressAnotherPreviousLine.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("FOO", "REDUNDANT_NULLABLE")] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressEmptyArgsPreviousLine.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressEmptyArgsPreviousLine.kt new file mode 100644 index 00000000000..5b773f9a5e3 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressEmptyArgsPreviousLine.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsPreviousLine.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsPreviousLine.kt new file mode 100644 index 00000000000..5b773f9a5e3 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsPreviousLine.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsPreviousLineBare.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsPreviousLineBare.kt new file mode 100644 index 00000000000..bafb1c35a83 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsPreviousLineBare.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +suppress("REDUNDANT_NULLABLE") +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsTheSameLine.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsTheSameLine.kt new file mode 100644 index 00000000000..83346e6b90f --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsTheSameLine.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsTheSameLineBare.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsTheSameLineBare.kt new file mode 100644 index 00000000000..3755f0ae839 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionSuppressNoArgsTheSameLineBare.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +suppress("REDUNDANT_NULLABLE") fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionUnrelatedAnnotation.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionUnrelatedAnnotation.kt new file mode 100644 index 00000000000..f27eb5a8375 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionUnrelatedAnnotation.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +[ann] fun foo(): String?? = null + +annotation class ann \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionUnrelatedAnnotationBare.kt b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionUnrelatedAnnotationBare.kt new file mode 100644 index 00000000000..08022a3d989 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/afterTopLevelFunctionUnrelatedAnnotationBare.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +ann fun foo(): String?? = null + +annotation class ann \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeParamWithModifier.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeParamWithModifier.kt new file mode 100644 index 00000000000..87a6b6858fe --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeParamWithModifier.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for parameter p" "true" + +fun foo(vararg p: String??) = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionModifierOnThePreviousLine.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionModifierOnThePreviousLine.kt new file mode 100644 index 00000000000..e94f46d5047 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionModifierOnThePreviousLine.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +public +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionModifierOnTheSameLine.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionModifierOnTheSameLine.kt new file mode 100644 index 00000000000..e0ec9e01aa3 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionModifierOnTheSameLine.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +public fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionNoModifiers.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionNoModifiers.kt new file mode 100644 index 00000000000..4c97e8cd714 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionNoModifiers.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressAnotherPreviousLine.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressAnotherPreviousLine.kt new file mode 100644 index 00000000000..c9788a92595 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressAnotherPreviousLine.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("FOO")] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressEmptyArgsPreviousLine.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressEmptyArgsPreviousLine.kt new file mode 100644 index 00000000000..f321895982c --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressEmptyArgsPreviousLine.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress()] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsPreviousLine.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsPreviousLine.kt new file mode 100644 index 00000000000..06db94442f3 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsPreviousLine.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsPreviousLineBare.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsPreviousLineBare.kt new file mode 100644 index 00000000000..6116b22a5e0 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsPreviousLineBare.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +suppress +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsTheSameLine.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsTheSameLine.kt new file mode 100644 index 00000000000..d32ec69a5ca --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsTheSameLine.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress] fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsTheSameLineBare.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsTheSameLineBare.kt new file mode 100644 index 00000000000..7aa70d32710 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsTheSameLineBare.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +suppress fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionUnrelatedAnnotation.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionUnrelatedAnnotation.kt new file mode 100644 index 00000000000..4bcc291c49c --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionUnrelatedAnnotation.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[ann] fun foo(): String?? = null + +annotation class ann \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionUnrelatedAnnotationBare.kt b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionUnrelatedAnnotationBare.kt new file mode 100644 index 00000000000..0acbd653c58 --- /dev/null +++ b/idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionUnrelatedAnnotationBare.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +ann fun foo(): String?? = null + +annotation class ann \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/afterLocalFunSuppressForLocal.kt b/idea/testData/quickfix/suppress/availability/afterLocalFunSuppressForLocal.kt new file mode 100644 index 00000000000..09bb6a2fcfb --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/afterLocalFunSuppressForLocal.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun local" "true" + +fun foo() { + [suppress("REDUNDANT_NULLABLE")] + fun local(): String?? = null +} diff --git a/idea/testData/quickfix/suppress/availability/afterLocalFunSuppressForOuter.kt b/idea/testData/quickfix/suppress/availability/afterLocalFunSuppressForOuter.kt new file mode 100644 index 00000000000..80246e35932 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/afterLocalFunSuppressForOuter.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +fun foo() { + fun local(): String?? = null +} diff --git a/idea/testData/quickfix/suppress/availability/afterLocalValSuppressForFun.kt b/idea/testData/quickfix/suppress/availability/afterLocalValSuppressForFun.kt new file mode 100644 index 00000000000..7be052419b3 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/afterLocalValSuppressForFun.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +fun foo() { + val a: String?? = null +} diff --git a/idea/testData/quickfix/suppress/availability/afterLocalValSuppressForVal.kt b/idea/testData/quickfix/suppress/availability/afterLocalValSuppressForVal.kt new file mode 100644 index 00000000000..bfa71eb333f --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/afterLocalValSuppressForVal.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for val a" "true" + +fun foo() { + [suppress("REDUNDANT_NULLABLE")] + val a: String?? = null +} diff --git a/idea/testData/quickfix/suppress/availability/afterMemberOfNestedSuppressForMember.kt b/idea/testData/quickfix/suppress/availability/afterMemberOfNestedSuppressForMember.kt new file mode 100644 index 00000000000..3d7de15ed42 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/afterMemberOfNestedSuppressForMember.kt @@ -0,0 +1,8 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +class C { + class D { + [suppress("REDUNDANT_NULLABLE")] + fun foo(): String?? = null + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/afterMemberOfNestedSuppressForNested.kt b/idea/testData/quickfix/suppress/availability/afterMemberOfNestedSuppressForNested.kt new file mode 100644 index 00000000000..c06df09b4d4 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/afterMemberOfNestedSuppressForNested.kt @@ -0,0 +1,8 @@ +// "Suppress 'REDUNDANT_NULLABLE' for class D" "true" + +class C { + [suppress("REDUNDANT_NULLABLE")] + class D { + fun foo(): String?? = null + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/afterMemberOfNestedSuppressForOuter.kt b/idea/testData/quickfix/suppress/availability/afterMemberOfNestedSuppressForOuter.kt new file mode 100644 index 00000000000..20ddb337079 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/afterMemberOfNestedSuppressForOuter.kt @@ -0,0 +1,8 @@ +// "Suppress 'REDUNDANT_NULLABLE' for class C" "true" + +[suppress("REDUNDANT_NULLABLE")] +class C { + class D { + fun foo(): String?? = null + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/afterMemberSuppressForClass.kt b/idea/testData/quickfix/suppress/availability/afterMemberSuppressForClass.kt new file mode 100644 index 00000000000..edba48c9888 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/afterMemberSuppressForClass.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for class C" "true" + +[suppress("REDUNDANT_NULLABLE")] +class C { + fun foo(): String?? = null +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/afterMemberSuppressForMember.kt b/idea/testData/quickfix/suppress/availability/afterMemberSuppressForMember.kt new file mode 100644 index 00000000000..a91eb852842 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/afterMemberSuppressForMember.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +class C { + [suppress("REDUNDANT_NULLABLE")] + fun foo(): String?? = null +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/beforeLocalFunSuppressForLocal.kt b/idea/testData/quickfix/suppress/availability/beforeLocalFunSuppressForLocal.kt new file mode 100644 index 00000000000..1b35c3feeff --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/beforeLocalFunSuppressForLocal.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun local" "true" + +fun foo() { + fun local(): String?? = null +} diff --git a/idea/testData/quickfix/suppress/availability/beforeLocalFunSuppressForOuter.kt b/idea/testData/quickfix/suppress/availability/beforeLocalFunSuppressForOuter.kt new file mode 100644 index 00000000000..702b16ffdad --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/beforeLocalFunSuppressForOuter.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +fun foo() { + fun local(): String?? = null +} diff --git a/idea/testData/quickfix/suppress/availability/beforeLocalValSuppressForFun.kt b/idea/testData/quickfix/suppress/availability/beforeLocalValSuppressForFun.kt new file mode 100644 index 00000000000..34ddd40d05a --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/beforeLocalValSuppressForFun.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +fun foo() { + val a: String?? = null +} diff --git a/idea/testData/quickfix/suppress/availability/beforeLocalValSuppressForVal.kt b/idea/testData/quickfix/suppress/availability/beforeLocalValSuppressForVal.kt new file mode 100644 index 00000000000..546c074ad30 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/beforeLocalValSuppressForVal.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for val a" "true" + +fun foo() { + val a: String?? = null +} diff --git a/idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForMember.kt b/idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForMember.kt new file mode 100644 index 00000000000..7512b864430 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForMember.kt @@ -0,0 +1,7 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +class C { + class D { + fun foo(): String?? = null + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForNested.kt b/idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForNested.kt new file mode 100644 index 00000000000..4ac9e57f612 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForNested.kt @@ -0,0 +1,7 @@ +// "Suppress 'REDUNDANT_NULLABLE' for class D" "true" + +class C { + class D { + fun foo(): String?? = null + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForOuter.kt b/idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForOuter.kt new file mode 100644 index 00000000000..8ac03b9f2b1 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForOuter.kt @@ -0,0 +1,7 @@ +// "Suppress 'REDUNDANT_NULLABLE' for class C" "true" + +class C { + class D { + fun foo(): String?? = null + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/beforeMemberSuppressForClass.kt b/idea/testData/quickfix/suppress/availability/beforeMemberSuppressForClass.kt new file mode 100644 index 00000000000..be3bb01ebe5 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/beforeMemberSuppressForClass.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for class C" "true" + +class C { + fun foo(): String?? = null +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/beforeMemberSuppressForMember.kt b/idea/testData/quickfix/suppress/availability/beforeMemberSuppressForMember.kt new file mode 100644 index 00000000000..f1146acce0c --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/beforeMemberSuppressForMember.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +class C { + fun foo(): String?? = null +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/availability/beforeTopLevelFunctionAlreadySuppressed.kt b/idea/testData/quickfix/suppress/availability/beforeTopLevelFunctionAlreadySuppressed.kt new file mode 100644 index 00000000000..132e43e84c6 --- /dev/null +++ b/idea/testData/quickfix/suppress/availability/beforeTopLevelFunctionAlreadySuppressed.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "false" + +[suppress("REDUNDANT_NULLABLE")] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterClass.kt b/idea/testData/quickfix/suppress/declarationKinds/afterClass.kt new file mode 100644 index 00000000000..15b0eb98386 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterClass.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for class C" "true" + +[suppress("REDUNDANT_NULLABLE")] +class C { + var foo: String?? = null +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterClassObject.kt b/idea/testData/quickfix/suppress/declarationKinds/afterClassObject.kt new file mode 100644 index 00000000000..d6f897ae27f --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterClassObject.kt @@ -0,0 +1,8 @@ +// "Suppress 'REDUNDANT_NULLABLE' for class object of C" "true" + +class C { + [suppress("REDUNDANT_NULLABLE")] + class object { + var foo: String?? = null + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterEnumEntry.kt b/idea/testData/quickfix/suppress/declarationKinds/afterEnumEntry.kt new file mode 100644 index 00000000000..b4441394dd9 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterEnumEntry.kt @@ -0,0 +1,8 @@ +// "Suppress 'REDUNDANT_NULLABLE' for enum entry A" "true" + +enum class E { + [suppress("REDUNDANT_NULLABLE")] + A { + fun foo(): String?? = null + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterFun.kt b/idea/testData/quickfix/suppress/declarationKinds/afterFun.kt new file mode 100644 index 00000000000..5b773f9a5e3 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterFun.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterMultiVal.kt b/idea/testData/quickfix/suppress/declarationKinds/afterMultiVal.kt new file mode 100644 index 00000000000..f735fbca7e5 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterMultiVal.kt @@ -0,0 +1,8 @@ +// "Suppress 'REDUNDANT_NULLABLE' for val (a, b)" "true" + +fun foo() { + [suppress("REDUNDANT_NULLABLE")] + val (a, b) = Pair?, String>("", "") +} + +data class Pair(val a: A, val b: B) \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterMultiVar.kt b/idea/testData/quickfix/suppress/declarationKinds/afterMultiVar.kt new file mode 100644 index 00000000000..ada5a8a8dc8 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterMultiVar.kt @@ -0,0 +1,8 @@ +// "Suppress 'REDUNDANT_NULLABLE' for var (a, b)" "true" + +fun foo() { + [suppress("REDUNDANT_NULLABLE")] + var (a, b) = Pair?, String>("", "") +} + +data class Pair(val a: A, val b: B) \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterObject.kt b/idea/testData/quickfix/suppress/declarationKinds/afterObject.kt new file mode 100644 index 00000000000..2921f8eb12c --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterObject.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for object C" "true" + +[suppress("REDUNDANT_NULLABLE")] +object C { + var foo: String?? = null +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterParam.kt b/idea/testData/quickfix/suppress/declarationKinds/afterParam.kt new file mode 100644 index 00000000000..3d54009f4a0 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterParam.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for parameter p" "true" + +fun foo([suppress("REDUNDANT_NULLABLE")] p: String??) = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterTrait.kt b/idea/testData/quickfix/suppress/declarationKinds/afterTrait.kt new file mode 100644 index 00000000000..42b30e21d0e --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterTrait.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for trait C" "true" + +[suppress("REDUNDANT_NULLABLE")] +trait C { + var foo: String?? +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterVal.kt b/idea/testData/quickfix/suppress/declarationKinds/afterVal.kt new file mode 100644 index 00000000000..1fce4182587 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterVal.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for val foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +val foo: String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/afterVar.kt b/idea/testData/quickfix/suppress/declarationKinds/afterVar.kt new file mode 100644 index 00000000000..9c00afb3a7b --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/afterVar.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for var foo" "true" + +[suppress("REDUNDANT_NULLABLE")] +var foo: String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeClass.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeClass.kt new file mode 100644 index 00000000000..6c09a222676 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeClass.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for class C" "true" + +class C { + var foo: String?? = null +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeClassObject.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeClassObject.kt new file mode 100644 index 00000000000..92865aee6a8 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeClassObject.kt @@ -0,0 +1,7 @@ +// "Suppress 'REDUNDANT_NULLABLE' for class object of C" "true" + +class C { + class object { + var foo: String?? = null + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeEnumEntry.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeEnumEntry.kt new file mode 100644 index 00000000000..b31b568a035 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeEnumEntry.kt @@ -0,0 +1,7 @@ +// "Suppress 'REDUNDANT_NULLABLE' for enum entry A" "true" + +enum class E { + A { + fun foo(): String?? = null + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeFun.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeFun.kt new file mode 100644 index 00000000000..4c97e8cd714 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeFun.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" + +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeMultiVal.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeMultiVal.kt new file mode 100644 index 00000000000..9eda17844b7 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeMultiVal.kt @@ -0,0 +1,7 @@ +// "Suppress 'REDUNDANT_NULLABLE' for val (a, b)" "true" + +fun foo() { + val (a, b) = Pair?, String>("", "") +} + +data class Pair(val a: A, val b: B) \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeMultiVar.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeMultiVar.kt new file mode 100644 index 00000000000..f09ea4dd436 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeMultiVar.kt @@ -0,0 +1,7 @@ +// "Suppress 'REDUNDANT_NULLABLE' for var (a, b)" "true" + +fun foo() { + var (a, b) = Pair?, String>("", "") +} + +data class Pair(val a: A, val b: B) \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeObject.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeObject.kt new file mode 100644 index 00000000000..d16bc92a3d6 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeObject.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for object C" "true" + +object C { + var foo: String?? = null +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeParam.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeParam.kt new file mode 100644 index 00000000000..c418942e175 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeParam.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for parameter p" "true" + +fun foo(p: String??) = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeTrait.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeTrait.kt new file mode 100644 index 00000000000..606dd96e76e --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeTrait.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for trait C" "true" + +trait C { + var foo: String?? +} \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeVal.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeVal.kt new file mode 100644 index 00000000000..31225bfe2b8 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeVal.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for val foo" "true" + +val foo: String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/declarationKinds/beforeVar.kt b/idea/testData/quickfix/suppress/declarationKinds/beforeVar.kt new file mode 100644 index 00000000000..08e6e05a332 --- /dev/null +++ b/idea/testData/quickfix/suppress/declarationKinds/beforeVar.kt @@ -0,0 +1,3 @@ +// "Suppress 'REDUNDANT_NULLABLE' for var foo" "true" + +var foo: String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/errorRecovery/afterNonStringInSuppress.kt b/idea/testData/quickfix/suppress/errorRecovery/afterNonStringInSuppress.kt new file mode 100644 index 00000000000..e0d1e1c2638 --- /dev/null +++ b/idea/testData/quickfix/suppress/errorRecovery/afterNonStringInSuppress.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" +// ERROR: An integer literal does not conform to the expected type jet.String +// ERROR: An integer literal does not conform to the expected type jet.String + +[suppress(1, "REDUNDANT_NULLABLE")] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/errorRecovery/afterUnresolvedAnnotation.kt b/idea/testData/quickfix/suppress/errorRecovery/afterUnresolvedAnnotation.kt new file mode 100644 index 00000000000..77dd6a293cc --- /dev/null +++ b/idea/testData/quickfix/suppress/errorRecovery/afterUnresolvedAnnotation.kt @@ -0,0 +1,5 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" +// ERROR: Unresolved reference: ann + +[suppress("REDUNDANT_NULLABLE")] +[ann] fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/errorRecovery/beforeNonStringInSuppress.kt b/idea/testData/quickfix/suppress/errorRecovery/beforeNonStringInSuppress.kt new file mode 100644 index 00000000000..1facd931ebb --- /dev/null +++ b/idea/testData/quickfix/suppress/errorRecovery/beforeNonStringInSuppress.kt @@ -0,0 +1,6 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" +// ERROR: An integer literal does not conform to the expected type jet.String +// ERROR: An integer literal does not conform to the expected type jet.String + +[suppress(1)] +fun foo(): String?? = null \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/errorRecovery/beforeUnresolvedAnnotation.kt b/idea/testData/quickfix/suppress/errorRecovery/beforeUnresolvedAnnotation.kt new file mode 100644 index 00000000000..3a6cca8b210 --- /dev/null +++ b/idea/testData/quickfix/suppress/errorRecovery/beforeUnresolvedAnnotation.kt @@ -0,0 +1,4 @@ +// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true" +// ERROR: Unresolved reference: ann + +[ann] fun foo(): String?? = null \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/quickfix/AbstractQuickFixTest.java b/idea/tests/org/jetbrains/jet/plugin/quickfix/AbstractQuickFixTest.java index 9d2171039b5..5c663aa1bc0 100644 --- a/idea/tests/org/jetbrains/jet/plugin/quickfix/AbstractQuickFixTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/quickfix/AbstractQuickFixTest.java @@ -16,13 +16,18 @@ package org.jetbrains.jet.plugin.quickfix; +import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase; import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInspection.SuppressIntentionAction; +import com.intellij.codeInspection.SuppressableProblemGroup; import com.intellij.ide.startup.impl.StartupManagerImpl; +import com.intellij.lang.annotation.ProblemGroup; import com.intellij.openapi.projectRoots.JavaSdk; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.util.Pair; +import com.intellij.psi.PsiElement; import org.apache.commons.lang.SystemUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.psi.JetFile; @@ -71,6 +76,28 @@ public abstract class AbstractQuickFixTest extends LightQuickFixTestCase { QuickFixActionsUtils.checkForUnexpectedErrors((JetFile) getFile()); } + @Override + protected IntentionAction findActionWithText(String text) { + IntentionAction intention = super.findActionWithText(text); + if (intention != null) return intention; + + // Support warning suppression + for (HighlightInfo highlight : doHighlighting()) { + ProblemGroup group = highlight.getProblemGroup(); + if (group instanceof SuppressableProblemGroup) { + SuppressableProblemGroup problemGroup = (SuppressableProblemGroup) group; + PsiElement at = getFile().findElementAt(highlight.getActualStartOffset()); + SuppressIntentionAction[] actions = problemGroup.getSuppressActions(at); + for (SuppressIntentionAction action : actions) { + if (action.getText().equals(text)) { + return action; + } + } + } + } + return null; + } + @Override protected String getBasePath() { return getClass().getAnnotation(TestMetadata.class).value(); diff --git a/idea/tests/org/jetbrains/jet/plugin/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/quickfix/QuickFixMultiFileTestGenerated.java index b585c4a7827..112f9381222 100644 --- a/idea/tests/org/jetbrains/jet/plugin/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/quickfix/QuickFixMultiFileTestGenerated.java @@ -31,7 +31,7 @@ import org.jetbrains.jet.plugin.quickfix.AbstractQuickFixMultiFileTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") @TestMetadata("idea/testData/quickfix") -@InnerTestClasses({QuickFixMultiFileTestGenerated.AddStarProjections.class, QuickFixMultiFileTestGenerated.AutoImports.class, QuickFixMultiFileTestGenerated.CreateFromUsage.class, QuickFixMultiFileTestGenerated.Modifiers.class, QuickFixMultiFileTestGenerated.Nullables.class, QuickFixMultiFileTestGenerated.Override.class, QuickFixMultiFileTestGenerated.TypeImports.class, QuickFixMultiFileTestGenerated.TypeMismatch.class, QuickFixMultiFileTestGenerated.Variables.class}) +@InnerTestClasses({QuickFixMultiFileTestGenerated.AddStarProjections.class, QuickFixMultiFileTestGenerated.AutoImports.class, QuickFixMultiFileTestGenerated.CreateFromUsage.class, QuickFixMultiFileTestGenerated.Modifiers.class, QuickFixMultiFileTestGenerated.Nullables.class, QuickFixMultiFileTestGenerated.Override.class, QuickFixMultiFileTestGenerated.Suppress.class, QuickFixMultiFileTestGenerated.TypeImports.class, QuickFixMultiFileTestGenerated.TypeMismatch.class, QuickFixMultiFileTestGenerated.Variables.class}) public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTest { public void testAllFilesPresentInQuickfix() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/quickfix"), Pattern.compile("^(\\w+)\\.before\\.Main\\.kt$"), true); @@ -249,6 +249,20 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes } } + @TestMetadata("idea/testData/quickfix/suppress") + @InnerTestClasses({}) + public static class Suppress extends AbstractQuickFixMultiFileTest { + public void testAllFilesPresentInSuppress() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/quickfix/suppress"), Pattern.compile("^(\\w+)\\.before\\.Main\\.kt$"), true); + } + + public static Test innerSuite() { + TestSuite suite = new TestSuite("Suppress"); + suite.addTestSuite(Suppress.class); + return suite; + } + } + @TestMetadata("idea/testData/quickfix/typeImports") public static class TypeImports extends AbstractQuickFixMultiFileTest { public void testAllFilesPresentInTypeImports() throws Exception { @@ -299,6 +313,7 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes suite.addTest(Modifiers.innerSuite()); suite.addTest(Nullables.innerSuite()); suite.addTest(Override.innerSuite()); + suite.addTest(Suppress.innerSuite()); suite.addTestSuite(TypeImports.class); suite.addTest(TypeMismatch.innerSuite()); suite.addTest(Variables.innerSuite()); diff --git a/idea/tests/org/jetbrains/jet/plugin/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/quickfix/QuickFixTestGenerated.java index 2a20992374f..4f1b66ee85e 100644 --- a/idea/tests/org/jetbrains/jet/plugin/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/quickfix/QuickFixTestGenerated.java @@ -31,7 +31,7 @@ import org.jetbrains.jet.plugin.quickfix.AbstractQuickFixTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") @TestMetadata("idea/testData/quickfix") -@InnerTestClasses({QuickFixTestGenerated.Abstract.class, QuickFixTestGenerated.AddStarProjections.class, QuickFixTestGenerated.AutoImports.class, QuickFixTestGenerated.ChangeSignature.class, QuickFixTestGenerated.CheckArguments.class, QuickFixTestGenerated.CreateFromUsage.class, QuickFixTestGenerated.Expressions.class, QuickFixTestGenerated.Migration.class, QuickFixTestGenerated.Modifiers.class, QuickFixTestGenerated.Nullables.class, QuickFixTestGenerated.Override.class, QuickFixTestGenerated.PlatformClasses.class, QuickFixTestGenerated.Supercalls.class, QuickFixTestGenerated.SupertypeInitialization.class, QuickFixTestGenerated.TypeAddition.class, QuickFixTestGenerated.TypeImports.class, QuickFixTestGenerated.TypeMismatch.class, QuickFixTestGenerated.TypeProjection.class, QuickFixTestGenerated.UselessImports.class, QuickFixTestGenerated.Variables.class, QuickFixTestGenerated.When.class}) +@InnerTestClasses({QuickFixTestGenerated.Abstract.class, QuickFixTestGenerated.AddStarProjections.class, QuickFixTestGenerated.AutoImports.class, QuickFixTestGenerated.ChangeSignature.class, QuickFixTestGenerated.CheckArguments.class, QuickFixTestGenerated.CreateFromUsage.class, QuickFixTestGenerated.Expressions.class, QuickFixTestGenerated.Migration.class, QuickFixTestGenerated.Modifiers.class, QuickFixTestGenerated.Nullables.class, QuickFixTestGenerated.Override.class, QuickFixTestGenerated.PlatformClasses.class, QuickFixTestGenerated.Supercalls.class, QuickFixTestGenerated.SupertypeInitialization.class, QuickFixTestGenerated.Suppress.class, QuickFixTestGenerated.TypeAddition.class, QuickFixTestGenerated.TypeImports.class, QuickFixTestGenerated.TypeMismatch.class, QuickFixTestGenerated.TypeProjection.class, QuickFixTestGenerated.UselessImports.class, QuickFixTestGenerated.Variables.class, QuickFixTestGenerated.When.class}) public class QuickFixTestGenerated extends AbstractQuickFixTest { public void testAllFilesPresentInQuickfix() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/quickfix"), Pattern.compile("^before(\\w+)\\.kt$"), true); @@ -1371,6 +1371,231 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { } + @TestMetadata("idea/testData/quickfix/suppress") + @InnerTestClasses({Suppress.AnnotationPosition.class, Suppress.Availability.class, Suppress.DeclarationKinds.class, Suppress.ErrorRecovery.class}) + public static class Suppress extends AbstractQuickFixTest { + public void testAllFilesPresentInSuppress() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/quickfix/suppress"), Pattern.compile("^before(\\w+)\\.kt$"), true); + } + + @TestMetadata("idea/testData/quickfix/suppress/annotationPosition") + public static class AnnotationPosition extends AbstractQuickFixTest { + public void testAllFilesPresentInAnnotationPosition() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/quickfix/suppress/annotationPosition"), Pattern.compile("^before(\\w+)\\.kt$"), true); + } + + @TestMetadata("beforeParamWithModifier.kt") + public void testParamWithModifier() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeParamWithModifier.kt"); + } + + @TestMetadata("beforeTopLevelFunctionModifierOnThePreviousLine.kt") + public void testTopLevelFunctionModifierOnThePreviousLine() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionModifierOnThePreviousLine.kt"); + } + + @TestMetadata("beforeTopLevelFunctionModifierOnTheSameLine.kt") + public void testTopLevelFunctionModifierOnTheSameLine() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionModifierOnTheSameLine.kt"); + } + + @TestMetadata("beforeTopLevelFunctionNoModifiers.kt") + public void testTopLevelFunctionNoModifiers() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionNoModifiers.kt"); + } + + @TestMetadata("beforeTopLevelFunctionSuppressAnotherPreviousLine.kt") + public void testTopLevelFunctionSuppressAnotherPreviousLine() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressAnotherPreviousLine.kt"); + } + + @TestMetadata("beforeTopLevelFunctionSuppressEmptyArgsPreviousLine.kt") + public void testTopLevelFunctionSuppressEmptyArgsPreviousLine() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressEmptyArgsPreviousLine.kt"); + } + + @TestMetadata("beforeTopLevelFunctionSuppressNoArgsPreviousLine.kt") + public void testTopLevelFunctionSuppressNoArgsPreviousLine() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsPreviousLine.kt"); + } + + @TestMetadata("beforeTopLevelFunctionSuppressNoArgsPreviousLineBare.kt") + public void testTopLevelFunctionSuppressNoArgsPreviousLineBare() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsPreviousLineBare.kt"); + } + + @TestMetadata("beforeTopLevelFunctionSuppressNoArgsTheSameLine.kt") + public void testTopLevelFunctionSuppressNoArgsTheSameLine() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsTheSameLine.kt"); + } + + @TestMetadata("beforeTopLevelFunctionSuppressNoArgsTheSameLineBare.kt") + public void testTopLevelFunctionSuppressNoArgsTheSameLineBare() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionSuppressNoArgsTheSameLineBare.kt"); + } + + @TestMetadata("beforeTopLevelFunctionUnrelatedAnnotation.kt") + public void testTopLevelFunctionUnrelatedAnnotation() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionUnrelatedAnnotation.kt"); + } + + @TestMetadata("beforeTopLevelFunctionUnrelatedAnnotationBare.kt") + public void testTopLevelFunctionUnrelatedAnnotationBare() throws Exception { + doTest("idea/testData/quickfix/suppress/annotationPosition/beforeTopLevelFunctionUnrelatedAnnotationBare.kt"); + } + + } + + @TestMetadata("idea/testData/quickfix/suppress/availability") + public static class Availability extends AbstractQuickFixTest { + public void testAllFilesPresentInAvailability() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/quickfix/suppress/availability"), Pattern.compile("^before(\\w+)\\.kt$"), true); + } + + @TestMetadata("beforeLocalFunSuppressForLocal.kt") + public void testLocalFunSuppressForLocal() throws Exception { + doTest("idea/testData/quickfix/suppress/availability/beforeLocalFunSuppressForLocal.kt"); + } + + @TestMetadata("beforeLocalFunSuppressForOuter.kt") + public void testLocalFunSuppressForOuter() throws Exception { + doTest("idea/testData/quickfix/suppress/availability/beforeLocalFunSuppressForOuter.kt"); + } + + @TestMetadata("beforeLocalValSuppressForFun.kt") + public void testLocalValSuppressForFun() throws Exception { + doTest("idea/testData/quickfix/suppress/availability/beforeLocalValSuppressForFun.kt"); + } + + @TestMetadata("beforeLocalValSuppressForVal.kt") + public void testLocalValSuppressForVal() throws Exception { + doTest("idea/testData/quickfix/suppress/availability/beforeLocalValSuppressForVal.kt"); + } + + @TestMetadata("beforeMemberOfNestedSuppressForMember.kt") + public void testMemberOfNestedSuppressForMember() throws Exception { + doTest("idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForMember.kt"); + } + + @TestMetadata("beforeMemberOfNestedSuppressForNested.kt") + public void testMemberOfNestedSuppressForNested() throws Exception { + doTest("idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForNested.kt"); + } + + @TestMetadata("beforeMemberOfNestedSuppressForOuter.kt") + public void testMemberOfNestedSuppressForOuter() throws Exception { + doTest("idea/testData/quickfix/suppress/availability/beforeMemberOfNestedSuppressForOuter.kt"); + } + + @TestMetadata("beforeMemberSuppressForClass.kt") + public void testMemberSuppressForClass() throws Exception { + doTest("idea/testData/quickfix/suppress/availability/beforeMemberSuppressForClass.kt"); + } + + @TestMetadata("beforeMemberSuppressForMember.kt") + public void testMemberSuppressForMember() throws Exception { + doTest("idea/testData/quickfix/suppress/availability/beforeMemberSuppressForMember.kt"); + } + + @TestMetadata("beforeTopLevelFunctionAlreadySuppressed.kt") + public void testTopLevelFunctionAlreadySuppressed() throws Exception { + doTest("idea/testData/quickfix/suppress/availability/beforeTopLevelFunctionAlreadySuppressed.kt"); + } + + } + + @TestMetadata("idea/testData/quickfix/suppress/declarationKinds") + public static class DeclarationKinds extends AbstractQuickFixTest { + public void testAllFilesPresentInDeclarationKinds() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/quickfix/suppress/declarationKinds"), Pattern.compile("^before(\\w+)\\.kt$"), true); + } + + @TestMetadata("beforeClass.kt") + public void testClass() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeClass.kt"); + } + + @TestMetadata("beforeClassObject.kt") + public void testClassObject() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeClassObject.kt"); + } + + @TestMetadata("beforeEnumEntry.kt") + public void testEnumEntry() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeEnumEntry.kt"); + } + + @TestMetadata("beforeFun.kt") + public void testFun() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeFun.kt"); + } + + @TestMetadata("beforeMultiVal.kt") + public void testMultiVal() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeMultiVal.kt"); + } + + @TestMetadata("beforeMultiVar.kt") + public void testMultiVar() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeMultiVar.kt"); + } + + @TestMetadata("beforeObject.kt") + public void testObject() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeObject.kt"); + } + + @TestMetadata("beforeParam.kt") + public void testParam() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeParam.kt"); + } + + @TestMetadata("beforeTrait.kt") + public void testTrait() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeTrait.kt"); + } + + @TestMetadata("beforeVal.kt") + public void testVal() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeVal.kt"); + } + + @TestMetadata("beforeVar.kt") + public void testVar() throws Exception { + doTest("idea/testData/quickfix/suppress/declarationKinds/beforeVar.kt"); + } + + } + + @TestMetadata("idea/testData/quickfix/suppress/errorRecovery") + public static class ErrorRecovery extends AbstractQuickFixTest { + public void testAllFilesPresentInErrorRecovery() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/quickfix/suppress/errorRecovery"), Pattern.compile("^before(\\w+)\\.kt$"), true); + } + + @TestMetadata("beforeNonStringInSuppress.kt") + public void testNonStringInSuppress() throws Exception { + doTest("idea/testData/quickfix/suppress/errorRecovery/beforeNonStringInSuppress.kt"); + } + + @TestMetadata("beforeUnresolvedAnnotation.kt") + public void testUnresolvedAnnotation() throws Exception { + doTest("idea/testData/quickfix/suppress/errorRecovery/beforeUnresolvedAnnotation.kt"); + } + + } + + public static Test innerSuite() { + TestSuite suite = new TestSuite("Suppress"); + suite.addTestSuite(Suppress.class); + suite.addTestSuite(AnnotationPosition.class); + suite.addTestSuite(Availability.class); + suite.addTestSuite(DeclarationKinds.class); + suite.addTestSuite(ErrorRecovery.class); + return suite; + } + } + @TestMetadata("idea/testData/quickfix/typeAddition") public static class TypeAddition extends AbstractQuickFixTest { public void testAllFilesPresentInTypeAddition() throws Exception { @@ -2012,6 +2237,7 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { suite.addTestSuite(PlatformClasses.class); suite.addTestSuite(Supercalls.class); suite.addTestSuite(SupertypeInitialization.class); + suite.addTest(Suppress.innerSuite()); suite.addTestSuite(TypeAddition.class); suite.addTestSuite(TypeImports.class); suite.addTest(TypeMismatch.innerSuite());