Java Code Examples for proguard.classfile.Clazz#accept()

The following examples show how to use proguard.classfile.Clazz#accept() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamicReturnedClassVisitor.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
{
    // Is the method returning a class type?
    Clazz[] referencedClasses = invokeDynamicConstant.referencedClasses;
    if (referencedClasses != null    &&
        referencedClasses.length > 0 &&
        ClassUtil.isInternalClassType(ClassUtil.internalMethodReturnType(invokeDynamicConstant.getType(clazz))))
    {
        // Let the visitor visit the return type class, if any.
        Clazz referencedClass = referencedClasses[referencedClasses.length - 1];
        if (referencedClass != null)
        {
            referencedClass.accept(classVisitor);
        }
    }
}
 
Example 2
Source File: DynamicReturnedClassVisitor.java    From bazel with Apache License 2.0 6 votes vote down vote up
public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
{
    // Is the method returning a class type?
    Clazz[] referencedClasses = invokeDynamicConstant.referencedClasses;
    if (referencedClasses != null    &&
        referencedClasses.length > 0 &&
        ClassUtil.isInternalClassType(ClassUtil.internalMethodReturnType(invokeDynamicConstant.getType(clazz))))
    {
        // Let the visitor visit the return type class, if any.
        Clazz referencedClass = referencedClasses[referencedClasses.length - 1];
        if (referencedClass != null)
        {
            referencedClass.accept(classVisitor);
        }
    }
}
 
Example 3
Source File: UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitLibraryClass(LibraryClass libraryClass)
{
    if (shouldBeMarkedAsUsed(libraryClass))
    {
        markAsUsed(libraryClass);

        // We're not going to analyze all library code. We're assuming that
        // if this class is being used, all of its methods will be used as
        // well. We'll mark them as such (here and in all subclasses).

        // Mark the superclass.
        Clazz superClass = libraryClass.superClass;
        if (superClass != null)
        {
            superClass.accept(this);
        }

        // Mark the interfaces.
        Clazz[] interfaceClasses = libraryClass.interfaceClasses;
        if (interfaceClasses != null)
        {
            for (int index = 0; index < interfaceClasses.length; index++)
            {
                if (interfaceClasses[index] != null)
                {
                    interfaceClasses[index].accept(this);
                }
            }
        }

        // Mark all methods.
        libraryClass.methodsAccept(this);
    }
}
 
Example 4
Source File: UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Marks the hierarchy of implementing or overriding methods corresponding
 * to the given method, if any.
 */
protected void markMethodHierarchy(Clazz clazz, Method method)
{
    if ((method.getAccessFlags() &
         (ClassConstants.INTERNAL_ACC_PRIVATE |
          ClassConstants.INTERNAL_ACC_STATIC)) == 0)
    {
        clazz.accept(new ConcreteClassDownTraveler(
                     new ClassHierarchyTraveler(true, true, false, true,
                     new NamedMethodVisitor(method.getName(clazz),
                                            method.getDescriptor(clazz),
                     new MemberAccessFilter(0, ClassConstants.INTERNAL_ACC_PRIVATE | ClassConstants.INTERNAL_ACC_STATIC | ClassConstants.INTERNAL_ACC_ABSTRACT,
                     this)))));
    }
}
 
Example 5
Source File: Annotation.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given visitor to the first referenced class. This is the
 * main annotation class.
 */
public void referencedClassAccept(ClassVisitor classVisitor)
{
    if (referencedClasses != null)
    {
        Clazz referencedClass = referencedClasses[0];
        if (referencedClass != null)
        {
            referencedClass.accept(classVisitor);
        }
    }
}
 
Example 6
Source File: Annotation.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given visitor to all referenced classes.
 */
public void referencedClassesAccept(ClassVisitor classVisitor)
{
    if (referencedClasses != null)
    {
        for (int index = 0; index < referencedClasses.length; index++)
        {
            Clazz referencedClass = referencedClasses[index];
            if (referencedClass != null)
            {
                referencedClass.accept(classVisitor);
            }
        }
    }
}
 
Example 7
Source File: EnumConstantElementValue.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given visitor to all referenced classes.
 */
public void referencedClassesAccept(ClassVisitor classVisitor)
{
    if (referencedClasses != null)
    {
        for (int index = 0; index < referencedClasses.length; index++)
        {
            Clazz referencedClass = referencedClasses[index];
            if (referencedClass != null)
            {
                referencedClass.accept(classVisitor);
            }
        }
    }
}
 
Example 8
Source File: ClassElementValue.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given visitor to all referenced classes.
 */
public void referencedClassesAccept(ClassVisitor classVisitor)
{
    if (referencedClasses != null)
    {
        for (int index = 0; index < referencedClasses.length; index++)
        {
            Clazz referencedClass = referencedClasses[index];
            if (referencedClass != null)
            {
                referencedClass.accept(classVisitor);
            }
        }
    }
}
 
Example 9
Source File: AnnotatedClassVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    if (!clazz.equals(lastVisitedClass))
    {
        clazz.accept(classVisitor);

        lastVisitedClass = clazz;
    }
}
 
Example 10
Source File: LocalVariableTypeInfo.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Applies the given visitor to all referenced classes.
 */
public void referencedClassesAccept(ClassVisitor classVisitor)
{
    if (referencedClasses != null)
    {
        for (int index = 0; index < referencedClasses.length; index++)
        {
            Clazz referencedClass = referencedClasses[index];
            if (referencedClass != null)
            {
                referencedClass.accept(classVisitor);
            }
        }
    }
}
 
Example 11
Source File: AnnotatedClassVisitor.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    if (!clazz.equals(lastVisitedClass))
    {
        clazz.accept(classVisitor);

        lastVisitedClass = clazz;
    }
}
 
Example 12
Source File: AnnotatedClassVisitor.java    From bazel with Apache License 2.0 5 votes vote down vote up
public void visitAnnotation(Clazz clazz, Annotation annotation)
{
    if (!clazz.equals(lastVisitedClass))
    {
        clazz.accept(classVisitor);

        lastVisitedClass = clazz;
    }
}