Skip to content

Commit cc8d957

Browse files
committed
refactor: split body to real field
1 parent 837bf22 commit cc8d957

File tree

17 files changed

+48
-26
lines changed

17 files changed

+48
-26
lines changed

src/main/java/org/jd/core/v1/ClassFileToJavaSourceDecompiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void decompile(Loader loader, Printer printer, String internalName, Map<S
5353
protected void decompile(DecompileContext decompileContext) throws Exception {
5454
ClassFile classFile = this.deserializer.loadClassFile(decompileContext.getLoader(),
5555
decompileContext.getMainInternalTypeName());
56-
decompileContext.setBody(classFile);
56+
decompileContext.setClassFile(classFile);
5757

5858
this.converter.process(decompileContext);
5959
this.fragmenter.process(decompileContext);

src/main/java/org/jd/core/v1/model/message/DecompileContext.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
import lombok.Setter;
1212
import org.jd.core.v1.api.loader.Loader;
1313
import org.jd.core.v1.api.printer.Printer;
14+
import org.jd.core.v1.model.classfile.ClassFile;
15+
import org.jd.core.v1.model.fragment.Fragment;
16+
import org.jd.core.v1.model.javasyntax.CompilationUnit;
17+
import org.jd.core.v1.model.token.Token;
1418
import org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker;
19+
import org.jd.core.v1.util.DefaultList;
1520

1621
import java.util.HashMap;
1722
import java.util.Map;
@@ -31,19 +36,27 @@ public class DecompileContext {
3136
protected boolean containsByteCode;
3237
protected boolean showBridgeAndSynthetic;
3338

39+
protected ClassFile classFile;
40+
protected CompilationUnit compilationUnit;
41+
protected DefaultList<Token> tokens;
42+
43+
@Deprecated
3444
protected Object body;
3545

3646
public DecompileContext() {}
3747

38-
public DecompileContext(Object body) {
39-
this.body = body;
48+
@Deprecated
49+
public DecompileContext(DefaultList<Fragment> fragments) {
50+
this.body = fragments;
4051
}
4152

4253
@SuppressWarnings("unchecked")
54+
@Deprecated
4355
public <T> T getBody() {
4456
return (T)body;
4557
}
4658

59+
@Deprecated
4760
public void setBody(Object body) {
4861
this.body = body;
4962
}

src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/processor/ConvertClassFileProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void visit(TypeParameterWithTypeBounds parameter) {
9393

9494
public void process(DecompileContext decompileContext) throws Exception {
9595
TypeMaker typeMaker = decompileContext.getTypeMaker();
96-
ClassFile classFile = decompileContext.getBody();
96+
ClassFile classFile = decompileContext.getClassFile();
9797

9898
AnnotationConverter annotationConverter = new AnnotationConverter(typeMaker);
9999

@@ -113,7 +113,7 @@ public void process(DecompileContext decompileContext) throws Exception {
113113

114114
decompileContext.setMajorVersion(classFile.getMajorVersion());
115115
decompileContext.setMinorVersion(classFile.getMinorVersion());
116-
decompileContext.setBody(new CompilationUnit(typeDeclaration));
116+
decompileContext.setCompilationUnit(new CompilationUnit(typeDeclaration));
117117
}
118118

119119
protected ClassFileInterfaceDeclaration convertInterfaceDeclaration(TypeMaker parser, AnnotationConverter converter, ClassFile classFile, ClassFileBodyDeclaration outerClassFileBodyDeclaration) {

src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/processor/UpdateJavaSyntaxTreeProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class UpdateJavaSyntaxTreeProcessor {
2424

2525
public void process(DecompileContext decompileContext) throws Exception {
2626
TypeMaker typeMaker = decompileContext.getTypeMaker();
27-
CompilationUnit compilationUnit = decompileContext.getBody();
27+
CompilationUnit compilationUnit = decompileContext.getCompilationUnit();
2828

2929
new UpdateJavaSyntaxTreeStep0Visitor(typeMaker).visit(compilationUnit);
3030
new UpdateJavaSyntaxTreeStep1Visitor(typeMaker).visit(compilationUnit);

src/main/java/org/jd/core/v1/service/fragmenter/javasyntaxtojavafragment/JavaSyntaxToJavaFragmentProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void process(DecompileContext decompileContext) throws Exception {
2626
Loader loader = decompileContext.getLoader();
2727
String mainInternalTypeName = decompileContext.getMainInternalTypeName();
2828
int majorVersion = decompileContext.getMajorVersion();
29-
CompilationUnit compilationUnit = decompileContext.getBody();
29+
CompilationUnit compilationUnit = decompileContext.getCompilationUnit();
3030

3131
SearchImportsVisitor importsVisitor = new SearchImportsVisitor(loader, mainInternalTypeName);
3232
importsVisitor.visit(compilationUnit);

src/main/java/org/jd/core/v1/service/tokenizer/javafragmenttotoken/JavaFragmentToTokenProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public void process(DecompileContext decompileContext) throws Exception {
3030
fragment.accept(visitor);
3131
}
3232

33-
decompileContext.setBody(visitor.getTokens());
33+
decompileContext.setTokens(visitor.getTokens());
3434
}
3535
}

src/main/java/org/jd/core/v1/service/writer/WriteTokenProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class WriteTokenProcessor {
2424

2525
public void process(DecompileContext decompileContext) throws Exception {
2626
Printer printer = decompileContext.getPrinter();
27-
List<Token> tokens = decompileContext.getBody();
27+
List<Token> tokens = decompileContext.getTokens();
2828
PrintTokenVisitor visitor = new PrintTokenVisitor();
2929
int maxLineNumber = decompileContext.getMaxLineNumber();
3030
int majorVersion = decompileContext.getMajorVersion();

src/test/java/org/jd/core/v1/AbstractJdTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected String decompile(Loader loader, Printer printer, String internalTypeNa
3131
decompileContext.setConfiguration(configuration);
3232

3333
ClassFile classFile = deserializer.loadClassFile(loader, internalTypeName);
34-
decompileContext.setBody(classFile);
34+
decompileContext.setClassFile(classFile);
3535

3636
converter.process(decompileContext);
3737
fragmenter.process(decompileContext);

src/test/java/org/jd/core/v1/AnnotationConverterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void test() throws Exception {
3939
decompileContext.setLoader(loader);
4040

4141
ClassFile classFile = deserializer.loadClassFile(loader, decompileContext.getMainInternalTypeName());
42-
decompileContext.setBody(classFile);
42+
decompileContext.setClassFile(classFile);
4343

4444
// Check class
4545
assertNotNull(classFile);

src/test/java/org/jd/core/v1/ClassFileDeserializerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void testAnnotatedClass() throws Exception {
6060
decompileContext.setLoader(loader);
6161

6262
ClassFile classFile = deserializer.loadClassFile(loader, decompileContext.getMainInternalTypeName());
63-
decompileContext.setBody(classFile);
63+
decompileContext.setClassFile(classFile);
6464

6565
// Check class
6666
assertNotNull(classFile);

0 commit comments

Comments
 (0)