@CheckForNull private static Symbol getPackage(Symbol symbol) { Symbol owner = symbol.owner(); while (owner != null) { if (owner.isPackageSymbol()) { break; } owner = owner.owner(); } return owner; }
@CheckForNull private static Symbol getPackage(Symbol symbol) { Symbol owner = symbol.owner(); while (owner != null) { if (owner.isPackageSymbol()) { break; } owner = owner.owner(); } return owner; }
private static boolean isTypeInDefaultPackage(Symbol symbol) { if (!symbol.isTypeSymbol()) { return false; } Symbol parent = symbol.owner(); while (!parent.isPackageSymbol()) { parent = parent.owner(); } return parent.name().isEmpty(); }
private static String packageNameOf(Symbol symbol) { Symbol owner = symbol.owner(); while (!owner.isPackageSymbol()) { owner = owner.owner(); } return owner.name(); }
private static String packageNameOf(Symbol symbol) { Symbol owner = symbol.owner(); while (!owner.isPackageSymbol()) { owner = owner.owner(); } return owner.name(); }
private static boolean isTypeInDefaultPackage(Symbol symbol) { if (!symbol.isTypeSymbol()) { return false; } Symbol parent = symbol.owner(); while (!parent.isPackageSymbol()) { parent = parent.owner(); } return parent.name().isEmpty(); }
private void checkConstructor(Symbol constructorClass) { if (!constructorClass.isStatic()) { Symbol methodPackage = getPackage(methodScopeOwner); Symbol constructorPackage = getPackage(constructorClass); if (Objects.equals(methodPackage, constructorPackage) && !constructorClass.owner().isPackageSymbol()) { setNonStaticReference(); } } }
private void checkConstructor(Symbol constructorClass) { if (!constructorClass.isStatic()) { Symbol methodPackage = getPackage(methodScopeOwner); Symbol constructorPackage = getPackage(constructorClass); if (Objects.equals(methodPackage, constructorPackage) && !constructorClass.owner().isPackageSymbol()) { setNonStaticReference(); } } }
MethodReference(Symbol.MethodSymbol symbol) { methodSymbol = symbol; methodScopeOwner = methodSymbol.owner(); if (methodScopeOwner != null && methodScopeOwner.isTypeSymbol()) { nonStaticReference = !methodScopeOwner.isStatic() && !methodScopeOwner.owner().isPackageSymbol(); } }
private static boolean isPrivateInnerClass(ClassTree classTree) { return !classTree.symbol().owner().isPackageSymbol() && ModifiersUtils.hasModifier(classTree.modifiers(), Modifier.PRIVATE); }
private static boolean isPrivateInnerClass(ClassTree classTree) { return !classTree.symbol().owner().isPackageSymbol() && ModifiersUtils.hasModifier(classTree.modifiers(), Modifier.PRIVATE); }
MethodReference(Symbol.MethodSymbol symbol) { methodSymbol = symbol; methodScopeOwner = methodSymbol.owner(); if (methodScopeOwner != null && methodScopeOwner.isTypeSymbol()) { nonStaticReference = !methodScopeOwner.isStatic() && !methodScopeOwner.owner().isPackageSymbol(); } }
private boolean couldBeDeclaredStatic(Symbol.TypeSymbol symbol) { Type superClass = symbol.superClass(); if (superClass != null) { Symbol superClassSymbol = superClass.symbol(); if (!superClassSymbol.owner().isPackageSymbol() && !superClassSymbol.isStatic()) { return false; } } if (outerClasses.size() == 1) { return true; } for (Symbol outerClass : outerClasses) { if (outerClass.isStatic()) { return true; } } return false; }
private boolean couldBeDeclaredStatic(Symbol.TypeSymbol symbol) { Type superClass = symbol.superClass(); if (superClass != null) { Symbol superClassSymbol = superClass.symbol(); if (!superClassSymbol.owner().isPackageSymbol() && !superClassSymbol.isStatic()) { return false; } } if (outerClasses.size() == 1) { return true; } for (Symbol outerClass : outerClasses) { if (outerClass.isStatic()) { return true; } } return false; }
@Override public void visitNode(Tree tree) { ClassTree node = (ClassTree) tree; Symbol.TypeSymbol symbol = node.symbol(); Symbol owner = symbol.owner(); Type ownerType = owner.type(); if (ownerType != null && ownerType.isClass() && owner.owner().isPackageSymbol()) { // raise only one issue for the first level of nesting when multiple nesting int lines = new LinesOfCodeVisitor().linesOfCode(node); if (lines > max) { reportIssue(ExpressionsHelper.reportOnClassTree(node), "Reduce this class from " + lines + " to the maximum allowed " + max + " or externalize it in a public class."); } } }
@Override public void visitNode(Tree tree) { ClassTree node = (ClassTree) tree; Symbol.TypeSymbol symbol = node.symbol(); Symbol owner = symbol.owner(); Type ownerType = owner.type(); if (ownerType != null && ownerType.isClass() && owner.owner().isPackageSymbol()) { // raise only one issue for the first level of nesting when multiple nesting int lines = new LinesOfCodeVisitor().linesOfCode(node); if (lines > max) { reportIssue(ExpressionsHelper.reportOnClassTree(node), "Reduce this class from " + lines + " to the maximum allowed " + max + " or externalize it in a public class."); } } }