Skip to content

Commit

Permalink
fix: use nice name for 'package-private' in modifiers change message
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jul 28, 2019
1 parent 1e6b303 commit e842e02
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions jadx-core/src/main/java/jadx/core/dex/info/AccessInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.android.dx.rop.code.AccessFlags;

import jadx.core.Consts;
import jadx.core.utils.exceptions.JadxRuntimeException;

public class AccessInfo {

Expand Down Expand Up @@ -63,6 +64,10 @@ public boolean isPrivate() {
return (accFlags & AccessFlags.ACC_PRIVATE) != 0;
}

public boolean isPackagePrivate() {
return (accFlags & VISIBILITY_FLAGS) == 0;
}

public boolean isAbstract() {
return (accFlags & AccessFlags.ACC_ABSTRACT) != 0;
}
Expand Down Expand Up @@ -188,6 +193,22 @@ public String makeString() {
return code.toString();
}

public String visibilityName() {
if (isPackagePrivate()) {
return "package-private";
}
if (isPublic()) {
return "public";
}
if (isPrivate()) {
return "private";
}
if (isProtected()) {
return "protected";
}
throw new JadxRuntimeException("Unknown visibility flags: " + getVisibility());
}

public String rawString() {
switch (type) {
case CLASS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void changeVisibility(ICodeNode node, int newVisFlag) {
AccessInfo newAccFlags = accessFlags.changeVisibility(newVisFlag);
if (newAccFlags != accessFlags) {
node.setAccessFlags(newAccFlags);
node.addAttr(AType.COMMENTS, "access modifiers changed from: " + accessFlags.getVisibility().rawString());
node.addAttr(AType.COMMENTS, "access modifiers changed from: " + accessFlags.visibilityName());
}
}

Expand Down

0 comments on commit e842e02

Please sign in to comment.