mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
calculate default inspection name by trimming Inspection or InspectionBase
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -135,7 +135,7 @@ public abstract class InspectionProfileEntry {
|
||||
|
||||
@NotNull
|
||||
public static String getShortName(@NotNull String className) {
|
||||
return StringUtil.trimEnd(className, "Inspection");
|
||||
return StringUtil.trimEnd(StringUtil.trimEnd(className, "Inspection"),"InspectionBase");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-8
@@ -17,6 +17,7 @@ package com.siyeh.ig;
|
||||
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInspection.BaseJavaBatchLocalInspectionTool;
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.intellij.codeInspection.LocalInspectionToolSession;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
@@ -55,14 +56,9 @@ public abstract class BaseInspection extends BaseJavaBatchLocalInspectionTool {
|
||||
public String getShortName() {
|
||||
if (m_shortName == null) {
|
||||
final Class<? extends BaseInspection> aClass = getClass();
|
||||
final String name = aClass.getName();
|
||||
if (name.endsWith(INSPECTION)) {
|
||||
m_shortName = name.substring(name.lastIndexOf((int)'.') + 1, name.length() - INSPECTION.length());
|
||||
}
|
||||
else if (name.endsWith(INSPECTION_BASE)) {
|
||||
m_shortName = name.substring(name.lastIndexOf((int)'.') + 1, name.length() - INSPECTION_BASE.length());
|
||||
}
|
||||
else {
|
||||
final String name = aClass.getSimpleName();
|
||||
m_shortName = InspectionProfileEntry.getShortName(name);
|
||||
if (m_shortName.equals(name)) {
|
||||
throw new AssertionError("class name must end with 'Inspection' to correctly calculate the short name: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user