mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[junit] do not check for type annotations (IDEA-181206)
This commit is contained in:
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.junit;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
@@ -70,7 +56,7 @@ public class JUnit4Framework extends JavaTestFramework {
|
||||
@Override
|
||||
protected PsiMethod findSetUpMethod(@NotNull PsiClass clazz) {
|
||||
for (PsiMethod each : clazz.getMethods()) {
|
||||
if (AnnotationUtil.isAnnotated(each, JUnitUtil.BEFORE_ANNOTATION_NAME, false)) return each;
|
||||
if (AnnotationUtil.isAnnotated(each, JUnitUtil.BEFORE_ANNOTATION_NAME, 0)) return each;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -79,7 +65,7 @@ public class JUnit4Framework extends JavaTestFramework {
|
||||
@Override
|
||||
protected PsiMethod findTearDownMethod(@NotNull PsiClass clazz) {
|
||||
for (PsiMethod each : clazz.getMethods()) {
|
||||
if (AnnotationUtil.isAnnotated(each, JUnitUtil.AFTER_ANNOTATION_NAME, false)) return each;
|
||||
if (AnnotationUtil.isAnnotated(each, JUnitUtil.AFTER_ANNOTATION_NAME, 0)) return each;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -102,7 +88,7 @@ public class JUnit4Framework extends JavaTestFramework {
|
||||
method = createSetUpPatternMethod(factory);
|
||||
PsiMethod existingMethod = clazz.findMethodBySignature(method, false);
|
||||
if (existingMethod != null) {
|
||||
if (AnnotationUtil.isAnnotated(existingMethod, beforeClassAnnotationName, false)) return existingMethod;
|
||||
if (AnnotationUtil.isAnnotated(existingMethod, beforeClassAnnotationName, 0)) return existingMethod;
|
||||
int exit = ApplicationManager.getApplication().isUnitTestMode() ?
|
||||
Messages.OK :
|
||||
Messages.showOkCancelDialog("Method setUp already exist but is not annotated as @Before. Annotate?",
|
||||
@@ -127,7 +113,7 @@ public class JUnit4Framework extends JavaTestFramework {
|
||||
@Override
|
||||
public boolean isIgnoredMethod(PsiElement element) {
|
||||
final PsiMethod testMethod = element instanceof PsiMethod ? JUnitUtil.getTestMethod(element) : null;
|
||||
return testMethod != null && AnnotationUtil.isAnnotated(testMethod, JUnitUtil.IGNORE_ANNOTATION, false);
|
||||
return testMethod != null && AnnotationUtil.isAnnotated(testMethod, JUnitUtil.IGNORE_ANNOTATION, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,9 +175,9 @@ public class JUnit4Framework extends JavaTestFramework {
|
||||
public PsiMethod findParametersMethod(PsiClass clazz) {
|
||||
final PsiMethod[] methods = clazz.getAllMethods();
|
||||
for (PsiMethod method : methods) {
|
||||
if (method.hasModifierProperty(PsiModifier.PUBLIC) &&
|
||||
if (method.hasModifierProperty(PsiModifier.PUBLIC) &&
|
||||
method.hasModifierProperty(PsiModifier.STATIC) &&
|
||||
AnnotationUtil.isAnnotated(method, "org.junit.runners.Parameterized.Parameters", false)) {
|
||||
AnnotationUtil.isAnnotated(method, "org.junit.runners.Parameterized.Parameters", 0)) {
|
||||
//todo check return value
|
||||
return method;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.junit;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
@@ -70,7 +56,7 @@ public class JUnit5Framework extends JavaTestFramework {
|
||||
@Override
|
||||
protected PsiMethod findSetUpMethod(@NotNull PsiClass clazz) {
|
||||
for (PsiMethod each : clazz.getMethods()) {
|
||||
if (AnnotationUtil.isAnnotated(each, JUnitUtil.BEFORE_EACH_ANNOTATION_NAME, false)) return each;
|
||||
if (AnnotationUtil.isAnnotated(each, JUnitUtil.BEFORE_EACH_ANNOTATION_NAME, 0)) return each;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -79,7 +65,7 @@ public class JUnit5Framework extends JavaTestFramework {
|
||||
@Override
|
||||
protected PsiMethod findTearDownMethod(@NotNull PsiClass clazz) {
|
||||
for (PsiMethod each : clazz.getMethods()) {
|
||||
if (AnnotationUtil.isAnnotated(each, JUnitUtil.AFTER_EACH_ANNOTATION_NAME, false)) return each;
|
||||
if (AnnotationUtil.isAnnotated(each, JUnitUtil.AFTER_EACH_ANNOTATION_NAME, 0)) return each;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -96,7 +82,7 @@ public class JUnit5Framework extends JavaTestFramework {
|
||||
method = createSetUpPatternMethod(factory);
|
||||
PsiMethod existingMethod = clazz.findMethodBySignature(method, false);
|
||||
if (existingMethod != null) {
|
||||
if (AnnotationUtil.isAnnotated(existingMethod, JUnitUtil.BEFORE_ALL_ANNOTATION_NAME, false)) return existingMethod;
|
||||
if (AnnotationUtil.isAnnotated(existingMethod, JUnitUtil.BEFORE_ALL_ANNOTATION_NAME, 0)) return existingMethod;
|
||||
int exit = ApplicationManager.getApplication().isUnitTestMode() ?
|
||||
Messages.OK :
|
||||
Messages.showOkCancelDialog("Method setUp already exist but is not annotated as @BeforeEach. Annotate?",
|
||||
@@ -121,7 +107,7 @@ public class JUnit5Framework extends JavaTestFramework {
|
||||
@Override
|
||||
public boolean isIgnoredMethod(PsiElement element) {
|
||||
final PsiMethod testMethod = element instanceof PsiMethod ? JUnitUtil.getTestMethod(element) : null;
|
||||
return testMethod != null && AnnotationUtil.isAnnotated(testMethod, JUnitUtil.IGNORE_ANNOTATION, false);
|
||||
return testMethod != null && AnnotationUtil.isAnnotated(testMethod, JUnitUtil.IGNORE_ANNOTATION, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.execution.junit;
|
||||
|
||||
@@ -127,7 +113,7 @@ class TestMethod extends TestObject {
|
||||
throw new RuntimeConfigurationWarning(ExecutionBundle.message("test.method.doesnt.exist.error.message", methodName));
|
||||
}
|
||||
|
||||
if (!AnnotationUtil.isAnnotated(psiClass, JUnitUtil.RUN_WITH, true) && !testAnnotated) {
|
||||
if (!AnnotationUtil.isAnnotated(psiClass, JUnitUtil.RUN_WITH, AnnotationUtil.CHECK_HIERARCHY) && !testAnnotated) {
|
||||
try {
|
||||
final PsiClass testCaseClass = JUnitUtil.getTestCaseClass(configurationModule.getModule());
|
||||
if (!psiClass.isInheritor(testCaseClass, true)) {
|
||||
|
||||
+2
-3
@@ -220,7 +220,7 @@ class JUnit5MalformedParameterizedInspection : AbstractBaseJavaLocalInspectionTo
|
||||
if (qualifiedName != null && qualifiedName.startsWith("java.time.")) return
|
||||
}
|
||||
}
|
||||
if (AnnotationUtil.isAnnotated(parameters[0], JUnitCommonClassNames.ORG_JUNIT_JUPITER_PARAMS_CONVERTER_CONVERT_WITH, false)) return
|
||||
if (AnnotationUtil.isAnnotated(parameters[0], JUnitCommonClassNames.ORG_JUNIT_JUPITER_PARAMS_CONVERTER_CONVERT_WITH, 0)) return
|
||||
holder.registerProblem(attributeValue,
|
||||
"No implicit conversion found to convert object of type " + componentType.presentableText + " to " + paramType.presentableText)
|
||||
}
|
||||
@@ -257,8 +257,7 @@ class JUnit5MalformedParameterizedInspection : AbstractBaseJavaLocalInspectionTo
|
||||
!InheritanceUtil.isInheritor(it.type, JUnitCommonClassNames.ORG_JUNIT_JUPITER_API_TEST_INFO) &&
|
||||
!InheritanceUtil.isInheritor(it.type, JUnitCommonClassNames.ORG_JUNIT_JUPITER_API_TEST_REPORTER)
|
||||
}
|
||||
.count() > 1 && !AnnotationUtil.isAnnotated(method, Collections.singleton(
|
||||
JUnitCommonClassNames.ORG_JUNIT_JUPITER_API_EXTENSION_EXTEND_WITH))
|
||||
.count() > 1 && !AnnotationUtil.isAnnotated(method, JUnitCommonClassNames.ORG_JUNIT_JUPITER_API_EXTENSION_EXTEND_WITH, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,8 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.execution.junit2.inspection;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInspection.reference.EntryPoint;
|
||||
import com.intellij.codeInspection.reference.RefElement;
|
||||
import com.intellij.codeInspection.visibility.EntryPointWithVisibilityLevel;
|
||||
import com.intellij.execution.junit.JUnitUtil;
|
||||
@@ -75,7 +60,7 @@ public class JUnitEntryPoint extends EntryPointWithVisibilityLevel {
|
||||
if (JUnitUtil.isTestMethodOrConfig(method)) return true;
|
||||
}
|
||||
else if (psiElement instanceof PsiField) {
|
||||
return AnnotationUtil.isAnnotated((PsiField)psiElement, JUnitUtil.PARAMETRIZED_PARAMETER_ANNOTATION_NAME, false);
|
||||
return AnnotationUtil.isAnnotated((PsiField)psiElement, JUnitUtil.PARAMETRIZED_PARAMETER_ANNOTATION_NAME, 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-19
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.junit2.inspection;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
@@ -46,10 +32,8 @@ public class JUnitImplicitUsageProvider implements ImplicitUsageProvider {
|
||||
|
||||
@Override
|
||||
public boolean isImplicitWrite(PsiElement element) {
|
||||
if (element instanceof PsiParameter) {
|
||||
return AnnotationUtil.isAnnotated((PsiParameter)element, MOCK, false);
|
||||
}
|
||||
return element instanceof PsiField && AnnotationUtil.isAnnotated((PsiField) element, INJECTED_FIELD_ANNOTATIONS);
|
||||
return element instanceof PsiParameter && AnnotationUtil.isAnnotated((PsiParameter)element, MOCK, 0) ||
|
||||
element instanceof PsiField && AnnotationUtil.isAnnotated((PsiField)element, INJECTED_FIELD_ANNOTATIONS, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user