private static boolean isLocalOrAnonymous(final TypeDefinition type) { if (type == null) { return false; } return type.isLocalClass() || type.isAnonymous(); }
private static boolean isLocalOrAnonymous(final TypeDefinition type) { if (type == null) { return false; } return type.isLocalClass() || type.isAnonymous(); }
private static boolean isLocalOrAnonymous(final TypeDefinition type) { if (type == null) { return false; } return type.isLocalClass() || type.isAnonymous(); }
private static boolean isLocalOrAnonymous(final TypeDefinition type) { return type != null && (type.isLocalClass() || type.isAnonymous()); }
private static boolean isLocalOrAnonymous(final TypeDefinition type) { return type != null && (type.isLocalClass() || type.isAnonymous()); }
private static boolean isLocalOrAnonymous(final TypeDefinition type) { return type != null && (type.isLocalClass() || type.isAnonymous()); }
@Override public Void visitTypeDeclaration(final TypeDeclaration typeDeclaration, final Void p) { final TypeDefinition type = typeDeclaration.getUserData(Keys.TYPE_DEFINITION); if (type != null && (isLocalOrAnonymous(type) || type.isAnonymous())) { _localTypes.put(type, typeDeclaration); } return super.visitTypeDeclaration(typeDeclaration, p); } }
@Override public Void visitTypeDeclaration(final TypeDeclaration typeDeclaration, final Void _) { final TypeDefinition type = typeDeclaration.getUserData(Keys.TYPE_DEFINITION); if (type != null && (isLocalOrAnonymous(type) || type.isAnonymous())) { _localTypes.put(type, typeDeclaration); } return super.visitTypeDeclaration(typeDeclaration, _); } }
@Override public Void visitTypeDeclaration(final TypeDeclaration typeDeclaration, final Void _) { final TypeDefinition type = typeDeclaration.getUserData(Keys.TYPE_DEFINITION); if (type != null && (isLocalOrAnonymous(type) || type.isAnonymous())) { _localTypes.put(type, typeDeclaration); } return super.visitTypeDeclaration(typeDeclaration, _); } }
@Override protected StringBuilder appendName(final StringBuilder sb, final boolean fullName, final boolean dottedName) { if (fullName && dottedName && isNested() && !isAnonymous() && _simpleName != null) { return getDeclaringType().appendName(sb, true, true).append('.').append(_simpleName); } return super.appendName(sb, fullName, dottedName); }
@Override protected StringBuilder appendName(final StringBuilder sb, final boolean fullName, final boolean dottedName) { if (fullName && dottedName && isNested() && !isAnonymous() && _simpleName != null) { return getDeclaringType().appendName(sb, true, true).append('.').append(_simpleName); } return super.appendName(sb, fullName, dottedName); }
@Override protected StringBuilder appendName(final StringBuilder sb, final boolean fullName, final boolean dottedName) { if (fullName && dottedName && isNested() && !isAnonymous() && _simpleName != null) { return getDeclaringType().appendName(sb, true, true).append('.').append(_simpleName); } return super.appendName(sb, fullName, dottedName); }
@Override protected void visitType(TypeDefinition td) { TypeReference tr = td.getDeclaringType(); if(tr == null) return; TypeDefinition outer = tr.resolve(); if(outer == null || !outer.isAnonymous()) return; for(MethodDefinition md : td.getDeclaredMethods()) { extractCalls(md, mr -> { mis.add(new MemberInfo(mr)); return true; }); } }
public static TypeReference getDeclaredType(final TypeReference type) { if (type == null) { return null; } final TypeDefinition resolvedType = type.resolve(); if (resolvedType == null) { return type; } if (resolvedType.isAnonymous()) { final List<TypeReference> interfaces = resolvedType.getExplicitInterfaces(); final TypeReference baseType = interfaces.isEmpty() ? resolvedType.getBaseType() : interfaces.get(0); if (baseType != null) { final TypeReference asSuperType = asSuper(baseType, type); if (asSuperType != null) { return asSuperType; } return baseType.isGenericType() ? new RawType(baseType) : baseType; } } return type; }
public static TypeReference getDeclaredType(final TypeReference type) { if (type == null) { return null; } final TypeDefinition resolvedType = type.resolve(); if (resolvedType == null) { return type; } if (resolvedType.isAnonymous()) { final List<TypeReference> interfaces = resolvedType.getExplicitInterfaces(); final TypeReference baseType = interfaces.isEmpty() ? resolvedType.getBaseType() : interfaces.get(0); if (baseType != null) { final TypeReference asSuperType = asSuper(baseType, type); if (asSuperType != null) { return asSuperType; } return baseType.isGenericType() ? new RawType(baseType) : baseType; } } return type; }
public static boolean isMemberHidden(final IMemberDefinition member, final DecompilerContext context) { final DecompilerSettings settings = context.getSettings(); if (member.isSynthetic() && !settings.getShowSyntheticMembers()) { return !context.getForcedVisibleMembers().contains(member); } if (member instanceof TypeReference && ((TypeReference) member).isNested() && settings.getExcludeNestedTypes()) { final TypeDefinition resolvedType = ((TypeReference) member).resolve(); return resolvedType == null || !resolvedType.isAnonymous() && findLocalType(resolvedType) == null; } return false; }
public static boolean isMemberHidden(final IMemberDefinition member, final DecompilerContext context) { final DecompilerSettings settings = context.getSettings(); if (member.isSynthetic() && !settings.getShowSyntheticMembers()) { return !context.getForcedVisibleMembers().contains(member); } if (member instanceof TypeReference && ((TypeReference) member).isNested() && settings.getExcludeNestedTypes()) { final TypeDefinition resolvedType = ((TypeReference) member).resolve(); return resolvedType == null || !resolvedType.isAnonymous() && findLocalType(resolvedType) == null; } return false; }
public static boolean isMemberHidden(final IMemberDefinition member, final DecompilerContext context) { final DecompilerSettings settings = context.getSettings(); if (member.isSynthetic() && !settings.getShowSyntheticMembers()) { return !context.getForcedVisibleMembers().contains(member); } if (member instanceof TypeReference && ((TypeReference) member).isNested() && settings.getExcludeNestedTypes()) { final TypeDefinition resolvedType = ((TypeReference) member).resolve(); return resolvedType == null || !resolvedType.isAnonymous() && findLocalType(resolvedType) == null; } return false; }
@ClassVisitor public void visitClass(TypeDefinition td, ClassContext cc) { isSerializable = Types.isInstance(td, "java/io/Serializable"); if(Types.isInstance(td, "java/util/Comparator") && !td.isAnonymous() && !td.isLocalClass() && !isSerializable) { int priority = 0; for(FieldDefinition fd : td.getDeclaredFields()) { TypeReference fieldType = fd.getFieldType(); while(fieldType.isArray()) fieldType = fieldType.getElementType(); if(fieldType.isPrimitive()) continue; if(Types.isInstance(fieldType, "java/io/Serializable")) { priority+=10; if(priority > 20) break; } } cc.report("ComparatorIsNotSerializable", priority, SHOULD_IMPLEMENT.create("java/io/Serializable")); } }
@AstVisitor(nodes=AstNodes.EXPRESSIONS, methodName="<clinit>") public void visit(Expression expr, NodeChain nc, MethodContext mc, TypeDefinition td) { if(expr.getOperand() instanceof MemberReference) { MemberReference mr = (MemberReference) expr.getOperand(); TypeReference tr = mr.getDeclaringType(); TypeDefinition subType = tr == null ? null : tr.resolve(); if (subType != null && (subType.isAnonymous() || subType.isLocalClass())) { subType = subType.getBaseType().resolve(); } if (subType != null && !td.isEquivalentTo(subType) && Types.isInstance(subType, td) && nc .getLambdaMethod() == null) { mc.report("InitializerRefersSubclass", td.isNonPublic() || subType.isNonPublic() ? 5 : 0, expr, Roles.SUBCLASS.create(subType)); } } } }