private boolean isFinalClass(ASTNode node) { return node instanceof TypeDeclaration && isFinal(((TypeDeclaration) node).getModifiers()); }
final int internalGetSetIntProperty(SimplePropertyDescriptor property, boolean get, int value) { if (property == MODIFIERS_PROPERTY) { if (get) { return getModifiers(); } else { internalSetModifiers(value); return 0; } } // allow default implementation to flag the error return super.internalGetSetIntProperty(property, get, value); }
final int internalGetSetIntProperty(SimplePropertyDescriptor property, boolean get, int value) { if (property == MODIFIERS_PROPERTY) { if (get) { return getModifiers(); } else { internalSetModifiers(value); return 0; } } // allow default implementation to flag the error return super.internalGetSetIntProperty(property, get, value); }
@Override public void endVisit(TypeDeclaration node) { if (!isNotVisible(node.getModifiers())) { exitType(); } }
final int internalGetSetIntProperty(SimplePropertyDescriptor property, boolean get, int value) { if (property == MODIFIERS_PROPERTY) { if (get) { return getModifiers(); } else { internalSetModifiers(value); return 0; } } // allow default implementation to flag the error return super.internalGetSetIntProperty(property, get, value); }
final int internalGetSetIntProperty(SimplePropertyDescriptor property, boolean get, int value) { if (property == MODIFIERS_PROPERTY) { if (get) { return getModifiers(); } else { internalSetModifiers(value); return 0; } } // allow default implementation to flag the error return super.internalGetSetIntProperty(property, get, value); }
final int internalGetSetIntProperty(SimplePropertyDescriptor property, boolean get, int value) { if (property == MODIFIERS_PROPERTY) { if (get) { return getModifiers(); } else { internalSetModifiers(value); return 0; } } // allow default implementation to flag the error return super.internalGetSetIntProperty(property, get, value); }
private void setTypeInfo() { int modifier = typeDeclaration.getModifiers(); if (Modifier.isAbstract(modifier)) { isAbstract = true; } if (typeDeclaration.isInterface()) { isInterface = true; } }
@Override final int internalGetSetIntProperty(SimplePropertyDescriptor property, boolean get, int value) { if (property == MODIFIERS_PROPERTY) { if (get) { return getModifiers(); } else { internalSetModifiers(value); return 0; } } // allow default implementation to flag the error return super.internalGetSetIntProperty(property, get, value); }
public boolean isDummyType(final AbstractTypeDeclaration it) { if ((it instanceof TypeDeclaration)) { return (("MISSING".equals(((TypeDeclaration)it).getName().getIdentifier()) && (!((TypeDeclaration)it).isInterface())) && (((TypeDeclaration)it).getModifiers() == 0)); } return false; }
import com.github.javaparser.*; import com.github.javaparser.ast.*; import com.github.javaparser.ast.body.*; import java.io.*; import java.util.*; public class ClassnameLister { private static String parseClassname(File filename) throws Exception { try (FileInputStream fin = new FileInputStream(filename)) { CompilationUnit cu = JavaParser.parse(fin); String packagePrefix = cu.getPackage().getName().toString(); if (!packagePrefix.isEmpty()) packagePrefix += "."; for (TypeDeclaration type : cu.getTypes()) if (type instanceOf ClassOrInterfaceDeclaration && ModifierSet.isPublic(type.getModifiers())) return packagePrefix + type.getName(); } return null; } public static void main(final String[] args) throws Exception { System.out.println(parseClassname(new File(args[0]))); } }
@Override public boolean visit(TypeDeclaration node) { TypeDeclaration typeDecl= ASTNodes.getParent(node, TypeDeclaration.class); if (typeDecl != null && node.isInterface() && Modifier.isStatic(node.getModifiers())) { rewriteOperations.add(new RemoveModifiersOperation(node, Modifier.STATIC)); } return true; }
@Override public boolean visit(MethodDeclaration node) { TypeDeclaration typeDecl= ASTNodes.getParent(node, TypeDeclaration.class); if (typeDecl != null && typeDecl.isInterface()) { rewriteOperations.add(new RemoveModifiersOperation(node, Modifier.ABSTRACT)); if (!AnonymousClassDeclaration.class.isInstance(node.getParent()) && !EnumDeclaration.class.isInstance(node.getParent())) { rewriteOperations.add(new RemoveModifiersOperation(node, Modifier.PUBLIC)); } } else if (typeDecl != null && Modifier.isFinal(typeDecl.getModifiers()) && Modifier.isFinal(node.getModifiers())) { rewriteOperations.add(new RemoveModifiersOperation(node, Modifier.FINAL)); } return true; }
public SM_Type(TypeDeclaration typeDeclaration, CompilationUnit compilationUnit, SM_Package pkg, InputArgs inputArgs) { parentPkg = pkg; if (typeDeclaration == null || compilationUnit == null) throw new NullPointerException(); name = typeDeclaration.getName().toString(); this.typeDeclaration = typeDeclaration; this.inputArgs = inputArgs; setTypeInfo(); setAccessModifier(typeDeclaration.getModifiers()); setImportList(compilationUnit); }
private boolean shouldParamClassBeStatic(TypeDeclaration enclosingTypeDecl) { if (enclosingTypeDecl.isPackageMemberTypeDeclaration()) { return true; } ITypeBinding binding= enclosingTypeDecl.resolveBinding(); int modifiers= binding != null ? binding.getModifiers() : enclosingTypeDecl.getModifiers(); return Modifier.isStatic(modifiers); }
private boolean shouldParamClassBeStatic(TypeDeclaration enclosingTypeDecl) { if (enclosingTypeDecl.isPackageMemberTypeDeclaration()) { return true; } ITypeBinding binding= enclosingTypeDecl.resolveBinding(); int modifiers= binding != null ? binding.getModifiers() : enclosingTypeDecl.getModifiers(); return Modifier.isStatic(modifiers); }
@Override public boolean visit(TypeDeclaration node) { if (isNotVisible(node.getModifiers())) { return false; } enterType(node.getName()); scanTypeJavaDoc(node); return true; }
@Override public boolean visit(TypeDeclaration node) { int flags = node.getModifiers(); if (Flags.isPrivate(flags)) { isvisible &= false; } else { if (node.isMemberTypeDeclaration()) { isvisible &= (Flags.isPublic(flags) && Flags.isStatic(flags)) || Flags.isPublic(flags) || Flags.isProtected(flags) || node.isInterface(); } else { isvisible &= (!Flags.isPrivate(flags) && !Flags.isPackageDefault(flags)) || node.isInterface(); } } fStack.push(new Item(getTypeName(node), node.getModifiers(), isvisible)); return true; }
ASTNode clone0(AST target) { TypeDeclaration result = new TypeDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc())); if (this.ast.apiLevel == AST.JLS2_INTERNAL) { result.internalSetModifiers(getModifiers()); result.setSuperclass( (Name) ASTNode.copySubtree(target, getSuperclass())); result.superInterfaces().addAll( ASTNode.copySubtrees(target, superInterfaces())); } result.setInterface(isInterface()); result.setName((SimpleName) getName().clone(target)); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); result.typeParameters().addAll( ASTNode.copySubtrees(target, typeParameters())); result.setSuperclassType( (Type) ASTNode.copySubtree(target, getSuperclassType())); result.superInterfaceTypes().addAll( ASTNode.copySubtrees(target, superInterfaceTypes())); } result.bodyDeclarations().addAll( ASTNode.copySubtrees(target, bodyDeclarations())); return result; }
ASTNode clone0(AST target) { TypeDeclaration result = new TypeDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc())); if (this.ast.apiLevel == AST.JLS2_INTERNAL) { result.internalSetModifiers(getModifiers()); result.setSuperclass( (Name) ASTNode.copySubtree(target, getSuperclass())); result.superInterfaces().addAll( ASTNode.copySubtrees(target, superInterfaces())); } result.setInterface(isInterface()); result.setName((SimpleName) getName().clone(target)); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); result.typeParameters().addAll( ASTNode.copySubtrees(target, typeParameters())); result.setSuperclassType( (Type) ASTNode.copySubtree(target, getSuperclassType())); result.superInterfaceTypes().addAll( ASTNode.copySubtrees(target, superInterfaceTypes())); } result.bodyDeclarations().addAll( ASTNode.copySubtrees(target, bodyDeclarations())); return result; }