private static ExpressionTree getPackageName(CompilationUnitTree cut) { return cut.packageDeclaration() != null ? cut.packageDeclaration().packageName() : null; }
private static ExpressionTree getPackageName(CompilationUnitTree cut) { return cut.packageDeclaration() != null ? cut.packageDeclaration().packageName() : null; }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { if (tree.packageDeclaration() != null) { String name = PackageUtils.packageName(tree.packageDeclaration(), "."); if (!pattern.matcher(name).matches()) { context.reportIssue(this, tree.packageDeclaration().packageName(), "Rename this package name to match the regular expression '" + format + "'."); } } }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { if (tree.packageDeclaration() != null) { String packageName = PackageUtils.packageName(tree.packageDeclaration(), "."); LOGGER.info("PackageName : " + packageName); } super.visitCompilationUnit(tree); }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { if (tree.packageDeclaration() != null) { String name = PackageUtils.packageName(tree.packageDeclaration(), "."); if (!pattern.matcher(name).matches()) { context.reportIssue(this, tree.packageDeclaration().packageName(), "Rename this package name to match the regular expression '" + format + "'."); } } }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { //do not scan imports and package name identifiers. if (tree.packageDeclaration() != null) { scan(tree.packageDeclaration().annotations()); } scan(tree.types()); }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { //do not scan imports and package name identifiers. if (tree.packageDeclaration() != null) { scan(tree.packageDeclaration().annotations()); } scan(tree.types()); }
private static boolean isNodeInDefaultPackage(Tree tree) { while (!tree.is(Tree.Kind.COMPILATION_UNIT)) { tree = tree.parent(); } return ((CompilationUnitTree) tree).packageDeclaration() == null; }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { packageName = PackageUtils.packageName(tree.packageDeclaration(), "."); super.visitCompilationUnit(tree); }
private static boolean isNodeInDefaultPackage(Tree tree) { while (!tree.is(Tree.Kind.COMPILATION_UNIT)) { tree = tree.parent(); } return ((CompilationUnitTree) tree).packageDeclaration() == null; }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { packageName = PackageUtils.packageName(tree.packageDeclaration(), "."); super.visitCompilationUnit(tree); }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { PackageDeclarationTree packageDeclaration = tree.packageDeclaration(); if (packageDeclaration != null) { String packageName = PackageUtils.packageName(packageDeclaration, File.separator); File javaFile = context.getFile(); String dir = javaFile.getParent(); if (!dir.endsWith(packageName)) { String dirWithoutDots = dir.replace(".", File.separator); String issueMessage = MessageFormat.format(MESSAGE, javaFile.getName(), packageName, dir); if (dirWithoutDots.endsWith(packageName)) { context.reportIssue(this, packageDeclaration.packageName(), issueMessage + "(Do not use dots in directory names)."); } else { context.reportIssue( this, packageDeclaration.packageName(), issueMessage + "."); } } } }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { PackageDeclarationTree packageDeclaration = tree.packageDeclaration(); if (packageDeclaration != null) { String packageName = PackageUtils.packageName(packageDeclaration, File.separator); File javaFile = context.getFile(); String dir = javaFile.getParent(); if (!dir.endsWith(packageName)) { String dirWithoutDots = dir.replace(".", File.separator); String issueMessage = MessageFormat.format(MESSAGE, javaFile.getName(), packageName, dir); if (dirWithoutDots.endsWith(packageName)) { context.reportIssue(this, packageDeclaration.packageName(), issueMessage + "(Do not use dots in directory names)."); } else { context.reportIssue( this, packageDeclaration.packageName(), issueMessage + "."); } } } }
@Override public void scanFile(JavaFileScannerContext context) { if (context.fileParsed()) { CompilationUnitTree cut = context.getTree(); if (cut.moduleDeclaration() == null && cut.packageDeclaration() == null && cut.types().isEmpty()) { context.addIssueOnFile(this, "This file has 0 lines of code."); } } }
@Override public void scanFile(JavaFileScannerContext context) { if (context.fileParsed()) { CompilationUnitTree cut = context.getTree(); if (cut.moduleDeclaration() == null && cut.packageDeclaration() == null && cut.types().isEmpty()) { context.addIssueOnFile(this, "This file has 0 lines of code."); } } }
@Override public void scanFile(JavaFileScannerContext context) { if (context.fileParsed()) { CompilationUnitTree cut = context.getTree(); if (cut.moduleDeclaration() == null && cut.packageDeclaration() == null) { context.addIssueOnFile(this, "Move this file to a named package."); } } }
@Override public void scanFile(JavaFileScannerContext context) { if (context.fileParsed()) { CompilationUnitTree cut = context.getTree(); if (cut.moduleDeclaration() == null && cut.packageDeclaration() == null) { context.addIssueOnFile(this, "Move this file to a named package."); } } }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { scan(tree.packageDeclaration()); scan(tree.imports()); scan(tree.types()); }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { scan(tree.packageDeclaration()); scan(tree.imports()); scan(tree.types()); scan(tree.moduleDeclaration()); }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { scan(tree.packageDeclaration()); scan(tree.imports()); scan(tree.types()); scan(tree.moduleDeclaration()); }