mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
redundant throws inspection: mark all problems in method hierarchy as fixed when has been applied to super method
This commit is contained in:
+13
-22
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.codeInspection.unneededThrows;
|
||||
|
||||
@@ -262,15 +250,10 @@ public class RedundantThrowsDeclarationInspection extends GlobalJavaBatchInspect
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void removeException(final RefMethod refMethod,
|
||||
final PsiType exceptionType,
|
||||
final List<PsiJavaCodeReferenceElement> refsToDelete,
|
||||
final PsiMethod psiMethod) {
|
||||
private void removeException(RefMethod refMethod,
|
||||
PsiType exceptionType,
|
||||
List<PsiJavaCodeReferenceElement> refsToDelete,
|
||||
PsiMethod psiMethod) {
|
||||
PsiManager psiManager = psiMethod.getManager();
|
||||
|
||||
PsiJavaCodeReferenceElement[] refs = psiMethod.getThrowsList().getReferenceElements();
|
||||
@@ -282,12 +265,15 @@ public class RedundantThrowsDeclarationInspection extends GlobalJavaBatchInspect
|
||||
}
|
||||
|
||||
if (refMethod != null) {
|
||||
assert myProcessor != null;
|
||||
|
||||
for (RefMethod refDerived : refMethod.getDerivedMethods()) {
|
||||
PsiModifierListOwner method = refDerived.getElement();
|
||||
if (method != null) {
|
||||
removeException(refDerived, exceptionType, refsToDelete, (PsiMethod)method);
|
||||
}
|
||||
}
|
||||
ProblemDescriptionsProcessor.resolveAllProblemsInElement(myProcessor, refMethod);
|
||||
} else {
|
||||
final Query<PsiMethod> query = OverridingMethodsSearch.search(psiMethod);
|
||||
query.forEach(m -> {
|
||||
@@ -296,6 +282,11 @@ public class RedundantThrowsDeclarationInspection extends GlobalJavaBatchInspect
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+13
-15
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* 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.codeInspection;
|
||||
|
||||
@@ -43,8 +31,9 @@ public interface ProblemDescriptionsProcessor {
|
||||
*
|
||||
* @param refEntity the reference graph node.
|
||||
*/
|
||||
default void ignoreElement(@NotNull RefEntity refEntity) {
|
||||
}
|
||||
default void ignoreElement(@NotNull RefEntity refEntity) {}
|
||||
|
||||
default void resolveProblem(@NotNull CommonProblemDescriptor descriptor) {}
|
||||
|
||||
/**
|
||||
* Registers a problem or several problems, with optional quickfixes, for the specified
|
||||
@@ -59,4 +48,13 @@ public interface ProblemDescriptionsProcessor {
|
||||
default RefEntity getElement(@NotNull CommonProblemDescriptor descriptor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static void resolveAllProblemsInElement(@NotNull ProblemDescriptionsProcessor processor, @NotNull RefEntity element) {
|
||||
CommonProblemDescriptor[] descriptors = processor.getDescriptions(element);
|
||||
if (descriptors != null) {
|
||||
for (CommonProblemDescriptor descriptor : descriptors) {
|
||||
processor.resolveProblem(descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.codeInspection;
|
||||
|
||||
@@ -199,7 +187,12 @@ public class InspectionEngine {
|
||||
|
||||
@Override
|
||||
public void ignoreElement(@NotNull RefEntity refEntity) {
|
||||
throw new RuntimeException();
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolveProblem(@NotNull CommonProblemDescriptor descriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -53,8 +53,6 @@ public interface InspectionToolPresentation extends ProblemDescriptionsProcessor
|
||||
@NotNull
|
||||
Map<String, Set<RefEntity>> getContent();
|
||||
|
||||
void resolveProblem(@NotNull CommonProblemDescriptor descriptor);
|
||||
|
||||
boolean isProblemResolved(@Nullable CommonProblemDescriptor descriptor);
|
||||
|
||||
boolean isProblemResolved(@Nullable RefEntity entity);
|
||||
|
||||
Reference in New Issue
Block a user