mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
naming convention: class naming convention disabled by default
This commit is contained in:
@@ -32,6 +32,7 @@ import com.intellij.testFramework.InspectionsKt;
|
||||
import com.intellij.testFramework.LightIdeaTestCase;
|
||||
import com.intellij.util.JdomKt;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.siyeh.ig.naming.ClassNamingConvention;
|
||||
import com.siyeh.ig.naming.NewClassNamingConventionInspection;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
@@ -342,11 +343,6 @@ public class InspectionProfileTest extends LightIdeaTestCase {
|
||||
" <inspection_tool class=\"AnnotationNamingConvention\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\">\n" +
|
||||
" <option name=\"m_regex\" value=\"[A-Z][A-Za-z\\d]*\" />\n" +
|
||||
" <option name=\"m_minLength\" value=\"8\" />\n" +
|
||||
" <option name=\"m_maxLength\" value=\"64\" />\n" +
|
||||
" </inspection_tool>\n" +
|
||||
" <inspection_tool class=\"ClassNamingConvention\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\">\n" +
|
||||
" <option name=\"m_regex\" value=\"[A-Z][A-Za-z\\d]*\" />\n" +
|
||||
" <option name=\"m_minLength\" value=\"8\" />\n" +
|
||||
" <option name=\"m_maxLength\" value=\"256\" />\n" +
|
||||
" </inspection_tool>\n" +
|
||||
" <inspection_tool class=\"EnumeratedClassNamingConvention\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\">\n" +
|
||||
@@ -370,10 +366,11 @@ public class InspectionProfileTest extends LightIdeaTestCase {
|
||||
InspectionToolWrapper wrapper = profile.getInspectionTool("NewClassNamingConvention", getProject());
|
||||
assertNotNull(wrapper);
|
||||
NewClassNamingConventionInspection tool = (NewClassNamingConventionInspection)wrapper.getTool();
|
||||
assertEquals(256, tool.getNamingConventionBean("ClassNamingConvention").m_maxLength);
|
||||
assertEquals(256, tool.getNamingConventionBean("AnnotationNamingConvention").m_maxLength);
|
||||
assertEquals(1, tool.getNamingConventionBean("EnumeratedClassNamingConvention").m_minLength);
|
||||
assertTrue(profile.isToolEnabled(HighlightDisplayKey.find("NewClassNamingConvention"), null));
|
||||
assertFalse(tool.isConventionEnabled("TypeParameterNamingConvention"));
|
||||
assertFalse(tool.isConventionEnabled(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME));
|
||||
|
||||
Element toImportElement = profile.writeScheme();
|
||||
final InspectionProfileImpl importedProfile =
|
||||
|
||||
+11
-7
@@ -67,12 +67,12 @@ public class NewClassNamingConventionInspection extends BaseInspection {
|
||||
myNamingConventionBeans.put(convention.getShortName(), convention.createDefaultBean());
|
||||
}
|
||||
initDisabledState();
|
||||
myDisabledShortNames.remove(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME);
|
||||
}
|
||||
|
||||
private void initDisabledState() {
|
||||
myDisabledShortNames.clear();
|
||||
myDisabledShortNames.addAll(myNamingConventions.keySet());
|
||||
myDisabledShortNames.remove(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME);
|
||||
}
|
||||
|
||||
public NamingConventionBean getNamingConventionBean(String shortName) {
|
||||
@@ -133,7 +133,7 @@ public class NewClassNamingConventionInspection extends BaseInspection {
|
||||
XmlSerializer.serializeInto(conventionBean, element);
|
||||
}
|
||||
else {
|
||||
if (shortName.equals(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME) != disabled) continue;
|
||||
if (disabled) continue;
|
||||
}
|
||||
node.addContent(element);
|
||||
}
|
||||
@@ -161,11 +161,15 @@ public class NewClassNamingConventionInspection extends BaseInspection {
|
||||
if (myDisabledShortNames.contains(shortName)) {
|
||||
break;
|
||||
}
|
||||
NamingConventionBean conventionBean = myNamingConventionBeans.get(shortName);
|
||||
NamingConventionBean activeConventionBean =
|
||||
conventionBean instanceof NamingConventionWithFallbackBean && ((NamingConventionWithFallbackBean)conventionBean).isInheritDefaultSettings()
|
||||
? myNamingConventionBeans.get(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME) : conventionBean;
|
||||
if (!activeConventionBean.isValid(name)) {
|
||||
NamingConventionBean activeBean = myNamingConventionBeans.get(shortName);
|
||||
if (activeBean instanceof NamingConventionWithFallbackBean && ((NamingConventionWithFallbackBean)activeBean).isInheritDefaultSettings()) {
|
||||
//disabled when fallback is disabled
|
||||
if (myDisabledShortNames.contains(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME)) {
|
||||
break;
|
||||
}
|
||||
activeBean = myNamingConventionBeans.get(ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME);
|
||||
}
|
||||
if (!activeBean.isValid(name)) {
|
||||
registerClassError(aClass, name, shortName);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user