Java Code Examples for proguard.classfile.ClassConstants#ATTR_Signature

The following examples show how to use proguard.classfile.ClassConstants#ATTR_Signature . 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: ClassSpecificationVisitorFactory.java    From proguard with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a ClassPoolVisitor to efficiently travel to the specified
 * classes and class members.
 *
 * @param keepClassSpecification the specifications of the class(es) and
 *                               class members to visit.
 * @param classVisitor           the ClassVisitor to be applied to
 *                               matching classes.
 * @param memberVisitor          the MemberVisitor to be applied to
 *                               matching class members.
 */
public static ClassPoolVisitor createClassPoolVisitor(KeepClassSpecification keepClassSpecification,
                                                      ClassVisitor           classVisitor,
                                                      MemberVisitor          memberVisitor)
{
    // If specified, let the class visitor also visit the descriptor
    // classes and the signature classes.
    if (keepClassSpecification.markDescriptorClasses &&
        classVisitor != null)
    {
        memberVisitor = memberVisitor == null ?
            new MemberDescriptorReferencedClassVisitor(classVisitor) :
            new MultiMemberVisitor(new MemberVisitor[]
            {
                memberVisitor,

                new MemberDescriptorReferencedClassVisitor(classVisitor),

                new AllAttributeVisitor(
                new AttributeNameFilter(ClassConstants.ATTR_Signature,
                new ReferencedClassVisitor(classVisitor)))
            });
    }

    // Don't  visit the classes if not specified.
    if (!keepClassSpecification.markClasses &&
        !keepClassSpecification.markConditionally)
    {
        classVisitor = null;
    }

    // If specified, let the marker visit the class and its class
    // members conditionally.
    if (keepClassSpecification.markConditionally)
    {
        // Combine both visitors.
        ClassVisitor composedClassVisitor =
            createCombinedClassVisitor(keepClassSpecification,
                                       classVisitor,
                                       memberVisitor);

        // Replace the class visitor.
        classVisitor =
            createClassMemberTester(keepClassSpecification,
                                    composedClassVisitor);

        // Discard the member visitor, because it has already been included.
        memberVisitor = null;
    }

    return createClassPoolVisitor((ClassSpecification)keepClassSpecification,
                                  classVisitor,
                                  memberVisitor);
}
 
Example 2
Source File: ClassSpecificationVisitorFactory.java    From bazel with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a ClassPoolVisitor to efficiently travel to the specified
 * classes and class members.
 *
 * @param keepClassSpecification the specifications of the class(es) and
 *                               class members to visit.
 * @param classVisitor           the ClassVisitor to be applied to
 *                               matching classes.
 * @param memberVisitor          the MemberVisitor to be applied to
 *                               matching class members.
 */
public static ClassPoolVisitor createClassPoolVisitor(KeepClassSpecification keepClassSpecification,
                                                      ClassVisitor           classVisitor,
                                                      MemberVisitor          memberVisitor)
{
    // If specified, let the class visitor also visit the descriptor
    // classes and the signature classes.
    if (keepClassSpecification.markDescriptorClasses &&
        classVisitor != null)
    {
        memberVisitor = memberVisitor == null ?
            new MemberDescriptorReferencedClassVisitor(classVisitor) :
            new MultiMemberVisitor(new MemberVisitor[]
            {
                memberVisitor,

                new MemberDescriptorReferencedClassVisitor(classVisitor),

                new AllAttributeVisitor(
                new AttributeNameFilter(ClassConstants.ATTR_Signature,
                new ReferencedClassVisitor(classVisitor)))
            });
    }

    // Don't  visit the classes if not specified.
    if (!keepClassSpecification.markClasses &&
        !keepClassSpecification.markConditionally)
    {
        classVisitor = null;
    }

    // If specified, let the marker visit the class and its class
    // members conditionally.
    if (keepClassSpecification.markConditionally)
    {
        // Combine both visitors.
        ClassVisitor composedClassVisitor =
            createCombinedClassVisitor(keepClassSpecification,
                                       classVisitor,
                                       memberVisitor);

        // Replace the class visitor.
        classVisitor =
            createClassMemberTester(keepClassSpecification,
                                    composedClassVisitor);

        // Discard the member visitor, because it has already been included.
        memberVisitor = null;
    }

    return createClassPoolVisitor((ClassSpecification)keepClassSpecification,
                                  classVisitor,
                                  memberVisitor);
}