use of jadx.core.dex.info.AccessInfo in project jadx by skylot.
the class MethodGen method addDefinition.
public boolean addDefinition(CodeWriter code) {
if (mth.getMethodInfo().isClassInit()) {
code.attachDefinition(mth);
code.startLine("static");
return true;
}
if (mth.contains(AFlag.ANONYMOUS_CONSTRUCTOR)) {
// don't add method name and arguments
code.startLine();
code.attachDefinition(mth);
return false;
}
annotationGen.addForMethod(code, mth);
AccessInfo clsAccFlags = mth.getParentClass().getAccessFlags();
AccessInfo ai = mth.getAccessFlags();
// don't add 'abstract' and 'public' to methods in interface
if (clsAccFlags.isInterface()) {
ai = ai.remove(AccessFlags.ACC_ABSTRACT);
ai = ai.remove(AccessFlags.ACC_PUBLIC);
}
// don't add 'public' for annotations
if (clsAccFlags.isAnnotation()) {
ai = ai.remove(AccessFlags.ACC_PUBLIC);
}
code.startLineWithNum(mth.getSourceLine());
code.add(ai.makeString());
if (classGen.addGenericMap(code, mth.getGenericMap())) {
code.add(' ');
}
if (mth.getAccessFlags().isConstructor()) {
code.attachDefinition(mth);
// constructor
code.add(classGen.getClassNode().getShortName());
} else {
classGen.useType(code, mth.getReturnType());
code.add(' ');
code.attachDefinition(mth);
code.add(mth.getAlias());
}
code.add('(');
List<RegisterArg> args = mth.getArguments(false);
if (mth.getMethodInfo().isConstructor() && mth.getParentClass().contains(AType.ENUM_CLASS)) {
if (args.size() == 2) {
args.clear();
} else if (args.size() > 2) {
args = args.subList(2, args.size());
} else {
LOG.warn(ErrorsCounter.formatErrorMsg(mth, "Incorrect number of args for enum constructor: " + args.size() + " (expected >= 2)"));
}
}
addMethodArguments(code, args);
code.add(')');
annotationGen.addThrows(mth, code);
return true;
}
use of jadx.core.dex.info.AccessInfo in project jadx by skylot.
the class JField method getIcon.
@Override
public Icon getIcon() {
AccessInfo af = field.getAccessFlags();
OverlayIcon icon = Utils.makeIcon(af, ICON_FLD_PUB, ICON_FLD_PRI, ICON_FLD_PRO, ICON_FLD_DEF);
if (af.isTransient()) {
icon.add(ICON_TRANSIENT);
}
if (af.isVolatile()) {
icon.add(ICON_VOLATILE);
}
return icon;
}
use of jadx.core.dex.info.AccessInfo in project jadx by skylot.
the class ClassGen method addClassDeclaration.
public void addClassDeclaration(CodeWriter clsCode) {
AccessInfo af = cls.getAccessFlags();
if (af.isInterface()) {
af = af.remove(AccessFlags.ACC_ABSTRACT).remove(AccessFlags.ACC_STATIC);
} else if (af.isEnum()) {
af = af.remove(AccessFlags.ACC_FINAL).remove(AccessFlags.ACC_ABSTRACT).remove(AccessFlags.ACC_STATIC);
}
// 'static' and 'private' modifier not allowed for top classes (not inner)
if (!cls.getAlias().isInner()) {
af = af.remove(AccessFlags.ACC_STATIC).remove(AccessFlags.ACC_PRIVATE);
}
annotationGen.addForClass(clsCode);
insertSourceFileInfo(clsCode, cls);
insertRenameInfo(clsCode, cls);
clsCode.startLine(af.makeString());
if (af.isInterface()) {
if (af.isAnnotation()) {
clsCode.add('@');
}
clsCode.add("interface ");
} else if (af.isEnum()) {
clsCode.add("enum ");
} else {
clsCode.add("class ");
}
clsCode.attachDefinition(cls);
clsCode.add(cls.getShortName());
addGenericMap(clsCode, cls.getGenericMap());
clsCode.add(' ');
ArgType sup = cls.getSuperClass();
if (sup != null && !sup.equals(ArgType.OBJECT) && !sup.getObject().equals(ArgType.ENUM.getObject())) {
clsCode.add("extends ");
useClass(clsCode, sup);
clsCode.add(' ');
}
if (!cls.getInterfaces().isEmpty() && !af.isAnnotation()) {
if (cls.getAccessFlags().isInterface()) {
clsCode.add("extends ");
} else {
clsCode.add("implements ");
}
for (Iterator<ArgType> it = cls.getInterfaces().iterator(); it.hasNext(); ) {
ArgType interf = it.next();
useClass(clsCode, interf);
if (it.hasNext()) {
clsCode.add(", ");
}
}
if (!cls.getInterfaces().isEmpty()) {
clsCode.add(' ');
}
}
}
use of jadx.core.dex.info.AccessInfo in project jadx by skylot.
the class JMethod method getIcon.
@Override
public Icon getIcon() {
AccessInfo accessFlags = mth.getAccessFlags();
OverlayIcon icon = Utils.makeIcon(accessFlags, ICON_MTH_PUB, ICON_MTH_PRI, ICON_MTH_PRO, ICON_MTH_DEF);
if (accessFlags.isConstructor()) {
icon.add(ICON_CONSTRUCTOR);
}
if (accessFlags.isSynchronized()) {
icon.add(ICON_SYNC);
}
return icon;
}
use of jadx.core.dex.info.AccessInfo in project jadx by skylot.
the class MethodInlineVisitor method visit.
@Override
public void visit(MethodNode mth) throws JadxException {
AccessInfo accessFlags = mth.getAccessFlags();
if (accessFlags.isSynthetic() && accessFlags.isStatic() && mth.getBasicBlocks().size() == 2) {
BlockNode returnBlock = mth.getBasicBlocks().get(1);
if (returnBlock.contains(AFlag.RETURN) || returnBlock.getInstructions().isEmpty()) {
BlockNode firstBlock = mth.getBasicBlocks().get(0);
inlineMth(mth, firstBlock, returnBlock);
}
}
}
Aggregations