mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-100840 ("No-op method in abstract class": Complains about native methods)
This commit is contained in:
+6
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,26 +28,22 @@ public class NoopMethodInAbstractClassInspection extends BaseInspection {
|
||||
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"noop.method.in.abstract.class.display.name");
|
||||
return InspectionGadgetsBundle.message("noop.method.in.abstract.class.display.name");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String buildErrorString(Object... infos) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"noop.method.in.abstract.class.problem.descriptor");
|
||||
return InspectionGadgetsBundle.message("noop.method.in.abstract.class.problem.descriptor");
|
||||
}
|
||||
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new NoopMethodInAbstractClassVisitor();
|
||||
}
|
||||
|
||||
private static class NoopMethodInAbstractClassVisitor
|
||||
extends BaseInspectionVisitor {
|
||||
private static class NoopMethodInAbstractClassVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitMethod(@NotNull PsiMethod method) {
|
||||
//no call to super, so we don't drill into anonymous classes
|
||||
if (method.isConstructor()) {
|
||||
return;
|
||||
}
|
||||
@@ -55,14 +51,13 @@ public class NoopMethodInAbstractClassInspection extends BaseInspection {
|
||||
if (containingClass == null) {
|
||||
return;
|
||||
}
|
||||
if (containingClass.isInterface() ||
|
||||
containingClass.isAnnotationType()) {
|
||||
if (containingClass.isInterface() || containingClass.isAnnotationType()) {
|
||||
return;
|
||||
}
|
||||
if (!containingClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
return;
|
||||
}
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT) || method.hasModifierProperty(PsiModifier.NATIVE)) {
|
||||
return;
|
||||
}
|
||||
if (!MethodUtils.isEmpty(method)) {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.siyeh.igtest.classlayout.noop_method_in_abstract_class;
|
||||
|
||||
abstract class NoopMethodInAbstractClass {
|
||||
|
||||
void foo() {}
|
||||
|
||||
native int bar();
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>NoopMethodInAbstractClass.java</file>
|
||||
<line>5</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">No-op method in abstract class</problem_class>
|
||||
<description>No-op Method <code>foo()</code> should be made abstract #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.siyeh.ig.classlayout;
|
||||
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class NoopMethodInAbstractClassInspectionTest extends IGInspectionTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/classlayout/noop_method_in_abstract_class", new NoopMethodInAbstractClassInspection());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user