private boolean verify(ClassTree ct, Element topElement) { currentClass = ct; CompilationUnitTree cut = getCompilationUnit(); String className = ct.getSimpleName().toString(); ExpressionTree pkgName = cut.getPackageName(); if (pkgName != null) { className = pkgName + "." + className; } classNames.add(className); if (hasTrustedAnnotation(ct, topElement)) { return true; } Boolean value = ct.accept(new VerifierVisitor(this, topElement), null); return value == null? true : value; }
"Expected at most one top-level class declaration, instead found: %s", Joiner.on(", ").join(names)); return buildDescription(firstNonNull(tree.getPackageName(), tree.getTypeDecls().get(0))) .setMessage(message) .build();
@Override public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState state) { if (tree.getTypeDecls().isEmpty() || tree.getPackageName() == null) { return Description.NO_MATCH; "Expected a class declaration named %s inside %s.java, instead found: %s", filename, filename, Joiner.on(", ").join(names)); return buildDescription(tree.getPackageName()).setMessage(message).build();
@Override public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState state) { if (tree.getPackageName() == null) { return Description.NO_MATCH; "Expected package %s to be declared in a directory ending with %s, instead found %s", packageName, expectedSuffix, actualPath); return buildDescription(tree.getPackageName()).setMessage(message).build();
private static String getPackageName(CompilationUnitTree unit) { ExpressionTree pkg = unit.getPackageName(); return pkg == null ? "" : pkg.toString(); } }
public static String getPackageName(CompilationUnitTree cu) { ExpressionTree packageName = cu.getPackageName(); if(packageName==null) return ""; return packageName.toString(); }
private String getExtendedClassName() { String extendedClassName = _tp.getCompilationUnit().getPackageName().toString(); int iExt = extendedClassName.indexOf( ExtensionManifold.EXTENSIONS_PACKAGE + '.' ); if( iExt < 0 ) { return null; } extendedClassName = extendedClassName.substring( iExt + ExtensionManifold.EXTENSIONS_PACKAGE.length() + 1 ); return extendedClassName; }
private boolean isEvil(Tree tree) { Tree.Kind kind = tree.getKind(); switch (kind) { case COMPILATION_UNIT: CompilationUnitTree cut = (CompilationUnitTree) tree; return cut.getPackageName() == null; // case MODIFIERS: case PRIMITIVE_TYPE: return true; default: return false; } }
private String getExtendedClassName() { String extendedClassName = _tp.getCompilationUnit().getPackageName().toString(); int iExt = extendedClassName.indexOf( ExtensionManifold.EXTENSIONS_PACKAGE + '.' ); if( iExt < 0 ) { return null; } extendedClassName = extendedClassName.substring( iExt + ExtensionManifold.EXTENSIONS_PACKAGE.length() + 1 ); return extendedClassName; }
public void setCompilationUnit(CompilationUnitTree cut) { setPackageNameTree(cut.getPackageName()); } public void enterClass(ClassTree ct) {
/** * Gets the relative path name inside the output directory where * the AST JavaScript should be written. */ public String getRelativePath() { ExpressionTree packageName = compUnit.getPackageName(); String pkg = packageName==null?"":packageName.toString().replace('.','/')+'/'; String name = new File(compUnit.getSourceFile().getName()).getName(); return pkg + name+".js"; }
@Override public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) { if (tree.getPackageName() != null) { visitDecl(tree, null); } return super.visitCompilationUnit(tree, ignore); }
@Override public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) { if (tree.getPackageName() != null) { visitDecl(tree, null); } return super.visitCompilationUnit(tree, ignore); }
private boolean verify(ClassTree ct, Element topElement) { currentClass = ct; CompilationUnitTree cut = getCompilationUnit(); String className = ct.getSimpleName().toString(); ExpressionTree pkgName = cut.getPackageName(); if (pkgName != null) { className = pkgName + "." + className; } classNames.add(className); Boolean value = unsafe? Boolean.TRUE : ct.accept(new VerifierVisitor(this, topElement), null); return value == null? true : value.booleanValue(); }
private CompilationUnitTree modifyCompUnitImport(CompilationUnitTree compilationUnit, int index, ImportTree importt, Operation op) { CompilationUnitTree copy = CompilationUnit( compilationUnit.getPackageAnnotations(), compilationUnit.getPackageName(), c(compilationUnit.getImports(), index, importt, op), compilationUnit.getTypeDecls(), compilationUnit.getSourceFile() ); return copy; }
private CompilationUnitTree modifyCompUnitTypeDecl(CompilationUnitTree compilationUnit, int index, Tree typeDeclaration, Operation op) { CompilationUnitTree copy = CompilationUnit( compilationUnit.getPackageAnnotations(), compilationUnit.getPackageName(), compilationUnit.getImports(), c(compilationUnit.getTypeDecls(), index, typeDeclaration, op), compilationUnit.getSourceFile() ); return copy; }
private CompilationUnitTree modifyPackageAnnotation(CompilationUnitTree cut, int index, AnnotationTree annotation, Operation op) { CompilationUnitTree copy = CompilationUnit( c(cut.getPackageAnnotations(), index, annotation, op), cut.getPackageName(), cut.getImports(), cut.getTypeDecls(), cut.getSourceFile() ); return copy; }
public R visitCompilationUnit(CompilationUnitTree node, P p) { R r = scan(node.getPackageAnnotations(), p); r = scanAndReduce(node.getPackageName(), p, r); r = scanAndReduce(node.getImports(), p, r); r = scanAndReduce(node.getTypeDecls(), p, r); return r; }
public R visitCompilationUnit(CompilationUnitTree node, P p) { R r = scan(node.getPackageAnnotations(), p); r = scanAndReduce(node.getPackageName(), p, r); r = scanAndReduce(node.getImports(), p, r); r = scanAndReduce(node.getTypeDecls(), p, r); return r; }
public R visitCompilationUnit(CompilationUnitTree node, P p) { R r = scan(node.getPackageAnnotations(), p); r = scanAndReduce(node.getPackageName(), p, r); r = scanAndReduce(node.getImports(), p, r); r = scanAndReduce(node.getTypeDecls(), p, r); return r; }