@Override public boolean matches(final INode other, final Match match) { if (other instanceof TypeDeclaration) { final TypeDeclaration otherDeclaration = (TypeDeclaration) other; return !otherDeclaration.isNull() && _classType == otherDeclaration._classType && matchString(getName(), otherDeclaration.getName()) && matchAnnotationsAndModifiers(otherDeclaration, match) && getTypeParameters().matches(otherDeclaration.getTypeParameters(), match) && getBaseType().matches(otherDeclaration.getBaseType(), match) && getInterfaces().matches(otherDeclaration.getInterfaces(), match) && getMembers().matches(otherDeclaration.getMembers(), match); } return false; }
public final JavaTokenNode getLeftBraceToken() { return getChildByRole(Roles.LEFT_BRACE); }
public final AstNodeCollection<EntityDeclaration> getMembers() { return getChildrenByRole(Roles.TYPE_MEMBER); }
final TypeDefinition type = node.getUserData(Keys.TYPE_DEFINITION); node.getParent() instanceof AnonymousObjectCreationExpression; writeAnnotations(node.getAnnotations(), true); writeModifiers(node.getModifiers()); switch (node.getClassType()) { case ENUM: writeKeyword(Roles.ENUM_KEYWORD); node.getNameToken().acceptVisitor(this, ignored); writeTypeParameters(node.getTypeParameters()); if (!node.getBaseType().isNull()) { space(); writeKeyword(Roles.EXTENDS_KEYWORD); space(); node.getBaseType().acceptVisitor(this, ignored); if (any(node.getInterfaces())) { final Collection<AstType> interfaceTypes; if (node.getClassType() == ClassType.ANNOTATION) { interfaceTypes = new ArrayList<>(); for (final AstType t : node.getInterfaces()) { final TypeReference r = t.getUserData(Keys.TYPE_REFERENCE);
private TypeDeclaration createTypeCore(final TypeDefinition type) { final TypeDeclaration astType = new TypeDeclaration(); final String packageName = type.getPackageName(); ); astType.setName(type.getSimpleName()); astType.putUserData(Keys.TYPE_DEFINITION, type); astType.putUserData(Keys.TYPE_REFERENCE, type); astType.setClassType(ClassType.ENUM); astType.setClassType(ClassType.ANNOTATION); astType.setClassType(ClassType.INTERFACE); astType.setClassType(ClassType.CLASS); astType.getTypeParameters().addAll(typeParameters); astType.addChild(convertType(baseType), Roles.BASE_TYPE); continue; astType.addChild(convertType(interfaceType), Roles.IMPLEMENTED_INTERFACE); astType.getAnnotations().add(createAnnotation(annotation));
final TypeDeclaration type = (TypeDeclaration) node; final AstType baseType = type.getBaseType(); for (final AstType ifType : type.getInterfaces()) { if (referencesType(ifType, localType)) { return true; for (final FieldDeclaration field : ofType(type.getMembers(), FieldDeclaration.class)) { final FieldDefinition fieldDefinition = field.getUserData(Keys.FIELD_DEFINITION); for (final MethodDeclaration method : ofType(type.getMembers(), MethodDeclaration.class)) { final MethodDefinition methodDefinition = method.getUserData(Keys.METHOD_DEFINITION);
@Override public Set<Object> visitCompilationUnit(final CompilationUnit node, final String name) { Set<Object> results = null; for (final TypeDeclaration typeDeclaration : node.getTypes()) { final Set<Object> typeResults = typeDeclaration.acceptVisitor(this, name); if (typeResults.isEmpty()) { continue; } if (results == null) { results = new LinkedHashSet<>(); } results.addAll(typeResults); } for (final ImportDeclaration typeImport : node.getImports()) { final Set<Object> importResults = typeImport.acceptVisitor(this, name); if (importResults.isEmpty()) { continue; } if (results == null) { results = new LinkedHashSet<>(); } results.addAll(importResults); } if (results != null) { return results; } return Collections.emptySet(); }
private void tryAddDeprecatedAnnotationToType(final TypeDeclaration node) { if (any(node.getAnnotations(), IS_DEPRECATED_ANNOTATION)) { return; } final TypeDefinition type = node.getUserData(Keys.TYPE_DEFINITION); if (type == null || (type.getFlags() & Flags.DEPRECATED) != Flags.DEPRECATED) { return; } if (type.getCompilerMajorVersion() < CompilerTarget.JDK1_5.majorVersion) { return; } addAnnotation(node, type.getResolver(), DEPRECATED_ANNOTATION_NAME); }
private void addTypeMembers(final TypeDeclaration astType, final TypeDefinition type) { for (final FieldDefinition field : type.getDeclaredFields()) { astType.addChild(createField(field), Roles.TYPE_MEMBER); } for (final MethodDefinition method : type.getDeclaredMethods()) { if (method.isConstructor()) { astType.addChild(createConstructor(method), Roles.TYPE_MEMBER); } else { astType.addChild(createMethod(method), Roles.TYPE_MEMBER); } } final List<TypeDefinition> nestedTypes = new ArrayList<>(); for (final TypeDefinition nestedType : type.getDeclaredTypes()) { final TypeReference declaringType = nestedType.getDeclaringType(); if (!nestedType.isLocalClass() && type.isEquivalentTo(declaringType)) { if (nestedType.isAnonymous()) { _typeDeclarations.put(type.getInternalName(), new SoftReference<>(astType)); } else { nestedTypes.add(nestedType); } } } sortNestedTypes(nestedTypes); for (final TypeDefinition nestedType : nestedTypes) { astType.addChild(createTypeNoCache(nestedType), Roles.TYPE_MEMBER); } }
creation = new AnonymousObjectCreationExpression( byteCode.getOffset(), _astBuilder.createType(resolvedType).clone(), declaredType );
final TypeDefinition type = node.getUserData(Keys.TYPE_DEFINITION); node.getParent() instanceof AnonymousObjectCreationExpression; writeAnnotations(node.getAnnotations(), true); writeModifiers(node.getModifiers()); switch (node.getClassType()) { case ENUM: writeKeyword(Roles.ENUM_KEYWORD); node.getNameToken().acceptVisitor(this, ignored); writeTypeParameters(node.getTypeParameters()); if (!node.getBaseType().isNull()) { space(); writeKeyword(Roles.EXTENDS_KEYWORD); space(); node.getBaseType().acceptVisitor(this, ignored); if (any(node.getInterfaces())) { final Collection<AstType> interfaceTypes; if (node.getClassType() == ClassType.ANNOTATION) { interfaceTypes = new ArrayList<>(); for (final AstType t : node.getInterfaces()) { final TypeReference r = t.getUserData(Keys.TYPE_REFERENCE);
private TypeDeclaration createTypeCore(final TypeDefinition type) { final TypeDeclaration astType = new TypeDeclaration(); final String packageName = type.getPackageName(); ); astType.setName(type.getSimpleName()); astType.putUserData(Keys.TYPE_DEFINITION, type); astType.putUserData(Keys.TYPE_REFERENCE, type); astType.setClassType(ClassType.ENUM); astType.setClassType(ClassType.ANNOTATION); astType.setClassType(ClassType.INTERFACE); astType.setClassType(ClassType.CLASS); astType.getTypeParameters().addAll(typeParameters); astType.addChild(convertType(baseType), Roles.BASE_TYPE); continue; astType.addChild(convertType(interfaceType), Roles.IMPLEMENTED_INTERFACE); astType.getAnnotations().add(createAnnotation(annotation));
final TypeDeclaration type = (TypeDeclaration) node; final AstType baseType = type.getBaseType(); for (final AstType ifType : type.getInterfaces()) { if (referencesType(ifType, localType)) { return true; for (final FieldDeclaration field : ofType(type.getMembers(), FieldDeclaration.class)) { final FieldDefinition fieldDefinition = field.getUserData(Keys.FIELD_DEFINITION); for (final MethodDeclaration method : ofType(type.getMembers(), MethodDeclaration.class)) { final MethodDefinition methodDefinition = method.getUserData(Keys.METHOD_DEFINITION);
@Override public Set<Object> visitCompilationUnit(final CompilationUnit node, final String name) { Set<Object> results = null; for (final TypeDeclaration typeDeclaration : node.getTypes()) { final Set<Object> typeResults = typeDeclaration.acceptVisitor(this, name); if (typeResults.isEmpty()) { continue; } if (results == null) { results = new LinkedHashSet<>(); } results.addAll(typeResults); } for (final ImportDeclaration typeImport : node.getImports()) { final Set<Object> importResults = typeImport.acceptVisitor(this, name); if (importResults.isEmpty()) { continue; } if (results == null) { results = new LinkedHashSet<>(); } results.addAll(importResults); } if (results != null) { return results; } return Collections.emptySet(); }
private void addTypeMembers(final TypeDeclaration astType, final TypeDefinition type) { for (final FieldDefinition field : type.getDeclaredFields()) { astType.addChild(createField(field), Roles.TYPE_MEMBER); } for (final MethodDefinition method : type.getDeclaredMethods()) { if (method.isConstructor()) { astType.addChild(createConstructor(method), Roles.TYPE_MEMBER); } else { astType.addChild(createMethod(method), Roles.TYPE_MEMBER); } } final List<TypeDefinition> nestedTypes = new ArrayList<>(); for (final TypeDefinition nestedType : type.getDeclaredTypes()) { final TypeReference declaringType = nestedType.getDeclaringType(); if (!nestedType.isLocalClass() && type.isEquivalentTo(declaringType)) { if (nestedType.isAnonymous()) { _typeDeclarations.put(type.getInternalName(), new SoftReference<>(astType)); } else { nestedTypes.add(nestedType); } } } sortNestedTypes(nestedTypes); for (final TypeDefinition nestedType : nestedTypes) { astType.addChild(createTypeNoCache(nestedType), Roles.TYPE_MEMBER); } }
creation = new AnonymousObjectCreationExpression( byteCode.getOffset(), _astBuilder.createType(resolvedType).clone(), declaredType );
final TypeDefinition type = node.getUserData(Keys.TYPE_DEFINITION); node.getParent() instanceof AnonymousObjectCreationExpression; writeAnnotations(node.getAnnotations(), true); writeModifiers(node.getModifiers()); switch (node.getClassType()) { case ENUM: writeKeyword(Roles.ENUM_KEYWORD); node.getNameToken().acceptVisitor(this, ignored); writeTypeParameters(node.getTypeParameters()); if (!node.getBaseType().isNull()) { space(); writeKeyword(Roles.EXTENDS_KEYWORD); space(); node.getBaseType().acceptVisitor(this, ignored); if (any(node.getInterfaces())) { final Collection<AstType> interfaceTypes; if (node.getClassType() == ClassType.ANNOTATION) { interfaceTypes = new ArrayList<>(); for (final AstType t : node.getInterfaces()) { final TypeReference r = t.getUserData(Keys.TYPE_REFERENCE);
@Override public boolean matches(final INode other, final Match match) { if (other instanceof TypeDeclaration) { final TypeDeclaration otherDeclaration = (TypeDeclaration) other; return !otherDeclaration.isNull() && _classType == otherDeclaration._classType && matchString(getName(), otherDeclaration.getName()) && matchAnnotationsAndModifiers(otherDeclaration, match) && getTypeParameters().matches(otherDeclaration.getTypeParameters(), match) && getBaseType().matches(otherDeclaration.getBaseType(), match) && getInterfaces().matches(otherDeclaration.getInterfaces(), match) && getMembers().matches(otherDeclaration.getMembers(), match); } return false; }
private TypeDeclaration createTypeCore(final TypeDefinition type) { final TypeDeclaration astType = new TypeDeclaration(); final String packageName = type.getPackageName(); ); astType.setName(type.getSimpleName()); astType.putUserData(Keys.TYPE_DEFINITION, type); astType.putUserData(Keys.TYPE_REFERENCE, type); astType.setClassType(ClassType.ENUM); astType.setClassType(ClassType.ANNOTATION); astType.setClassType(ClassType.INTERFACE); astType.setClassType(ClassType.CLASS); astType.getTypeParameters().addAll(typeParameters); astType.addChild(convertType(baseType), Roles.BASE_TYPE); continue; astType.addChild(convertType(interfaceType), Roles.IMPLEMENTED_INTERFACE); astType.getAnnotations().add(createAnnotation(annotation));
final TypeDeclaration type = (TypeDeclaration) node; final AstType baseType = type.getBaseType(); for (final AstType ifType : type.getInterfaces()) { if (referencesType(ifType, localType)) { return true; for (final FieldDeclaration field : ofType(type.getMembers(), FieldDeclaration.class)) { final FieldDefinition fieldDefinition = field.getUserData(Keys.FIELD_DEFINITION); for (final MethodDeclaration method : ofType(type.getMembers(), MethodDeclaration.class)) { final MethodDefinition methodDefinition = method.getUserData(Keys.METHOD_DEFINITION);