2 * Copyright 2006 Dave Griffith
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 import com
.intellij
.codeHighlighting
.HighlightDisplayLevel
;
19 import com
.intellij
.codeInspection
.GlobalJavaInspectionTool
;
20 import com
.siyeh
.InspectionGadgetsBundle
;
21 import org
.jetbrains
.annotations
.NonNls
;
22 import org
.jetbrains
.annotations
.NotNull
;
24 public abstract class BaseGlobalInspection
extends GlobalJavaInspectionTool
{
26 private String shortName
= null;
27 @NonNls private static final String INSPECTION
= "Inspection";
30 public String
getShortName() {
31 if (shortName
== null) {
32 final Class
<?
extends BaseGlobalInspection
> aClass
= getClass();
33 final String name
= aClass
.getName();
34 shortName
= name
.substring(name
.lastIndexOf((int)'.') + 1,
35 name
.length() - INSPECTION
.length());
40 private String
getPropertyPrefixForInspection() {
41 final String shortName
= getShortName();
42 return getPrefix(shortName
);
45 public static String
getPrefix(String shortName
) {
46 final StringBuilder builder
= new StringBuilder(shortName
.length() + 10);
47 builder
.append(Character
.toLowerCase(shortName
.charAt(0)));
48 for (int i
= 1; i
< shortName
.length(); i
++) {
49 final char c
= shortName
.charAt(i
);
50 if (Character
.isUpperCase(c
)) {
51 builder
.append('.').append(Character
.toLowerCase(c
));
56 return builder
.toString();
60 public String
getDisplayName() {
61 @NonNls final String displayNameSuffix
= ".display.name";
62 return InspectionGadgetsBundle
.message(getPropertyPrefixForInspection() +
67 public HighlightDisplayLevel
getDefaultLevel() {
68 return HighlightDisplayLevel
.WARNING
;
71 public boolean isEnabledByDefault() {