IG: optimization

This commit is contained in:
Bas Leijdekkers
2017-05-16 14:36:05 +02:00
parent d45167c842
commit e072fd84f3
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2011 Dave Griffith, Bas Leijdekkers
* Copyright 2006-2017 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.
@@ -39,8 +39,7 @@ public class PackageWithTooManyClassesInspection extends BaseGlobalInspection {
@NotNull
@Override
public String getDisplayName() {
return InspectionGadgetsBundle.message(
"package.with.too.many.classes.display.name");
return InspectionGadgetsBundle.message("package.with.too.many.classes.display.name");
}
@Override
@@ -54,29 +53,21 @@ public class PackageWithTooManyClassesInspection extends BaseGlobalInspection {
return null;
}
final List<RefEntity> children = refEntity.getChildren();
int numClasses = 0;
for (RefEntity child : children) {
if (child instanceof RefClass) {
numClasses++;
}
if (children.size() <= limit) {
return null;
}
final int numClasses = (int)children.stream().filter(c -> c instanceof RefClass).count();
if (numClasses <= limit) {
return null;
}
final String errorString = InspectionGadgetsBundle.message(
"package.with.too.many.classes.problem.descriptor",
refEntity.getQualifiedName(), Integer.valueOf(numClasses),
Integer.valueOf(limit));
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)
};
refEntity.getQualifiedName(), Integer.valueOf(numClasses), Integer.valueOf(limit));
return new CommonProblemDescriptor[]{inspectionManager.createProblemDescriptor(errorString)};
}
@Override
public JComponent createOptionsPanel() {
return new SingleIntegerFieldOptionsPanel(
InspectionGadgetsBundle.message(
"package.with.too.many.classes.max.option"),
this, "limit");
return new SingleIntegerFieldOptionsPanel(InspectionGadgetsBundle.message("package.with.too.many.classes.max.option"), this, "limit");
}
}