proguard.classfile.VisitorAccepter Java Examples

The following examples show how to use proguard.classfile.VisitorAccepter. 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: ShortestUsagePrinter.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private void printReason(VisitorAccepter visitorAccepter)
{
    if (shortestUsageMarker.isUsed(visitorAccepter))
    {
        ShortestUsageMark shortestUsageMark = shortestUsageMarker.getShortestUsageMark(visitorAccepter);

        // Print the reason for keeping this class.
        ps.print("  " + shortestUsageMark.getReason());

        // Print the class or method that is responsible, with its reasons.
        shortestUsageMark.acceptClassVisitor(this);
        shortestUsageMark.acceptMemberVisitor(this);
    }
    else
    {
        ps.println("  is not being kept.\n");
    }
}
 
Example #2
Source File: ShortestUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private void checkCause(VisitorAccepter visitorAccepter)
{
    if (ShortestUsageMarker.this.isUsed(visitorAccepter))
    {
        ShortestUsageMark shortestUsageMark = ShortestUsageMarker.this.getShortestUsageMark(visitorAccepter);

        // Check the class of this mark, if any
        isRecursing = shortestUsageMark.isCausedBy(checkClass);

        // Check the causing class or method, if still necessary.
        if (!isRecursing)
        {
            shortestUsageMark.acceptClassVisitor(this);
            shortestUsageMark.acceptMemberVisitor(this);
        }
    }
}
 
Example #3
Source File: ClassShrinker.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Removes all VisitorAccepter objects that are not marked as being used
 * from the given array.
 * @return the new number of VisitorAccepter objects.
 */
private int shrinkArray(VisitorAccepter[] array, int length)
{
    int counter = 0;

    // Shift the used objects together.
    for (int index = 0; index < length; index++)
    {
        if (usageMarker.isUsed(array[index]))
        {
            array[counter++] = array[index];
        }
    }

    // Clear the remaining array elements.
    for (int index = counter; index < length; index++)
    {
        array[index] = null;
    }

    return counter;
}
 
Example #4
Source File: AttributeShrinker.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Removes all VisitorAccepter objects that are not marked as being used
 * from the given array.
 * @return the new number of VisitorAccepter objects.
 */
private static int shrinkArray(VisitorAccepter[] array, int length)
{
    int counter = 0;

    // Shift the used objects together.
    for (int index = 0; index < length; index++)
    {
        if (AttributeUsageMarker.isUsed(array[index]))
        {
            array[counter++] = array[index];
        }
    }

    // Clear the remaining array elements.
    for (int index = counter; index < length; index++)
    {
        array[index] = null;
    }

    return counter;
}
 
Example #5
Source File: MemberObfuscator.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns whether the new name of the given class member is fixed.
 * @param member the class member.
 * @return whether its new name is fixed.
 */
static boolean hasFixedNewMemberName(Member member)
{
    VisitorAccepter lastVisitorAccepter = MethodLinker.lastVisitorAccepter(member);

    return lastVisitorAccepter instanceof LibraryMember ||
           lastVisitorAccepter instanceof MyFixedName;
}
 
Example #6
Source File: MemberObfuscator.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Assigns a fixed new name to the given class member.
 * @param member the class member.
 * @param name   the new name.
 */
static void setFixedNewMemberName(Member member, String name)
{
    VisitorAccepter lastVisitorAccepter = MethodLinker.lastVisitorAccepter(member);

    if (!(lastVisitorAccepter instanceof LibraryMember) &&
        !(lastVisitorAccepter instanceof MyFixedName))
    {
        lastVisitorAccepter.setVisitorInfo(new MyFixedName(name));
    }
    else
    {
        lastVisitorAccepter.setVisitorInfo(name);
    }
}
 
Example #7
Source File: ShortestUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
protected void markAsUsed(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    ShortestUsageMark shortestUsageMark =
        visitorInfo != null                           &&
        visitorInfo instanceof ShortestUsageMark &&
        !((ShortestUsageMark)visitorInfo).isCertain() &&
        !currentUsageMark.isShorter((ShortestUsageMark)visitorInfo) ?
            new ShortestUsageMark((ShortestUsageMark)visitorInfo, true):
            currentUsageMark;

    visitorAccepter.setVisitorInfo(shortestUsageMark);
}
 
Example #8
Source File: ShortestUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
protected boolean shouldBeMarkedAsUsed(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    return //!(visitorAccepter instanceof Clazz &&
           //  isCausedBy(currentUsageMark, (Clazz)visitorAccepter)) &&
           (visitorInfo == null                           ||
           !(visitorInfo instanceof ShortestUsageMark)   ||
           !((ShortestUsageMark)visitorInfo).isCertain() ||
           currentUsageMark.isShorter((ShortestUsageMark)visitorInfo));
}
 
Example #9
Source File: ShortestUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
protected boolean isUsed(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    return visitorInfo != null                      &&
           visitorInfo instanceof ShortestUsageMark &&
           ((ShortestUsageMark)visitorInfo).isCertain();
}
 
Example #10
Source File: ShortestUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
protected boolean shouldBeMarkedAsPossiblyUsed(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    return visitorInfo == null                         ||
           !(visitorInfo instanceof ShortestUsageMark) ||
           (!((ShortestUsageMark)visitorInfo).isCertain() &&
            currentUsageMark.isShorter((ShortestUsageMark)visitorInfo));
}
 
Example #11
Source File: ShortestUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
protected boolean isPossiblyUsed(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    return visitorInfo != null                      &&
           visitorInfo instanceof ShortestUsageMark &&
           !((ShortestUsageMark)visitorInfo).isCertain();
}
 
Example #12
Source File: KeepMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public static boolean isKept(VisitorAccepter visitorAccepter)
{
    return MethodLinker.lastVisitorAccepter(visitorAccepter).getVisitorInfo() == KEPT;
}
 
Example #13
Source File: AttributeUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given VisitorAccepter has been marked as being used.
 * In this context, the VisitorAccepter will be an Attribute object.
 */
static boolean isUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == USED;
}
 
Example #14
Source File: Utf8UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Marks the given VisitorAccepter as being used.
 * In this context, the VisitorAccepter will be a Utf8Constant object.
 */
private static void markAsUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(USED);
}
 
Example #15
Source File: Utf8UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given VisitorAccepter has been marked as being used.
 * In this context, the VisitorAccepter will be a Utf8Constant object.
 */
static boolean isUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == USED;
}
 
Example #16
Source File: NameAndTypeUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Marks the given VisitorAccepter as being used.
 * In this context, the VisitorAccepter will be a NameAndTypeConstant object.
 */
private static void markAsUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(USED);
}
 
Example #17
Source File: NameAndTypeUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given VisitorAccepter has been marked as being used.
 * In this context, the VisitorAccepter will be a NameAndTypeConstant object.
 */
static boolean isUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == USED;
}
 
Example #18
Source File: AttributeUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Marks the given VisitorAccepter as being used (or useful).
 * In this context, the VisitorAccepter will be an Attribute object.
 */
private static void markAsUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(USED);
}
 
Example #19
Source File: UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Marks the given visitor accepter as being used.
 */
protected void markAsUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(USED);
}
 
Example #20
Source File: KeepMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
private static void markAsKept(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(KEPT);
}
 
Example #21
Source File: ClassCleaner.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
private void clean(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(null);
}
 
Example #22
Source File: ClassPrinter.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
private String visitorInfo(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == null ? "-" : "+";
}
 
Example #23
Source File: ShortestUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
protected ShortestUsageMark getShortestUsageMark(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    return (ShortestUsageMark)visitorInfo;
}
 
Example #24
Source File: ShortestUsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
protected void markAsPossiblyUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(new ShortestUsageMark(currentUsageMark, false));
}
 
Example #25
Source File: UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Clears any usage marks from the given visitor accepter.
 */
protected void markAsUnused(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(null);
}
 
Example #26
Source File: UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given visitor accepter has been marked as possibly
 * being used.
 */
protected boolean isPossiblyUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == POSSIBLY_USED;
}
 
Example #27
Source File: UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given visitor accepter should still be marked as
 * possibly being used.
 */
protected boolean shouldBeMarkedAsPossiblyUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() != USED &&
           visitorAccepter.getVisitorInfo() != POSSIBLY_USED;
}
 
Example #28
Source File: UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Marks the given visitor accepter as possibly being used.
 */
protected void markAsPossiblyUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(POSSIBLY_USED);
}
 
Example #29
Source File: UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given visitor accepter has been marked as being used.
 */
protected boolean isUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == USED;
}
 
Example #30
Source File: UsageMarker.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given visitor accepter should still be marked as
 * being used.
 */
protected boolean shouldBeMarkedAsUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() != USED;
}