Skip to content

Commit 0da2e51

Browse files
author
emmanue1
committed
Refactoring
1 parent 27eb220 commit 0da2e51

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

src/main/java/org/jd/core/v1/model/javasyntax/AbstractJavaSyntaxVisitor.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ public void visit(TypeParameters parameters) {
637637
iterator.next().accept(this);
638638
}
639639

640-
protected void visit(TypeDeclaration declaration) {
640+
public void visit(TypeDeclaration declaration) {
641641
safeAccept(declaration.getAnnotationReferences());
642642
}
643643

@@ -653,64 +653,64 @@ public void visit(Types types) {
653653
}
654654
}
655655

656-
protected void acceptListDeclaration(List<? extends Declaration> list) {
656+
public void acceptListDeclaration(List<? extends Declaration> list) {
657657
for (Declaration declaration : list)
658658
declaration.accept(this);
659659
}
660660

661-
protected void acceptListExpression(List<? extends Expression> list) {
661+
public void acceptListExpression(List<? extends Expression> list) {
662662
for (Expression expression : list)
663663
expression.accept(this);
664664
}
665665

666-
protected void acceptListReference(List<? extends Reference> list) {
666+
public void acceptListReference(List<? extends Reference> list) {
667667
for (Reference reference : list)
668668
reference.accept(this);
669669
}
670670

671-
protected void acceptListStatement(List<? extends Statement> list) {
671+
public void acceptListStatement(List<? extends Statement> list) {
672672
for (Statement statement : list)
673673
statement.accept(this);
674674
}
675675

676-
protected void safeAccept(Declaration declaration) {
676+
public void safeAccept(Declaration declaration) {
677677
if (declaration != null)
678678
declaration.accept(this);
679679
}
680680

681-
protected void safeAccept(BaseExpression expression) {
681+
public void safeAccept(BaseExpression expression) {
682682
if (expression != null)
683683
expression.accept(this);
684684
}
685685

686-
protected void safeAccept(Reference reference) {
686+
public void safeAccept(Reference reference) {
687687
if (reference != null)
688688
reference.accept(this);
689689
}
690690

691-
protected void safeAccept(BaseStatement list) {
691+
public void safeAccept(BaseStatement list) {
692692
if (list != null)
693693
list.accept(this);
694694
}
695695

696-
protected void safeAccept(BaseType list) {
696+
public void safeAccept(BaseType list) {
697697
if (list != null)
698698
list.accept(this);
699699
}
700700

701-
protected void safeAccept(BaseTypeParameter list) {
701+
public void safeAccept(BaseTypeParameter list) {
702702
if (list != null)
703703
list.accept(this);
704704
}
705705

706-
protected void safeAcceptListDeclaration(List<? extends Declaration> list) {
706+
public void safeAcceptListDeclaration(List<? extends Declaration> list) {
707707
if (list != null) {
708708
for (Declaration declaration : list)
709709
declaration.accept(this);
710710
}
711711
}
712712

713-
protected void safeAcceptListStatement(List<? extends Statement> list) {
713+
public void safeAcceptListStatement(List<? extends Statement> list) {
714714
if (list != null) {
715715
for (Statement statement : list)
716716
statement.accept(this);

src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/visitor/UpdateJavaSyntaxTreeStep0Visitor.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,24 @@
99

1010
import org.jd.core.v1.model.javasyntax.AbstractJavaSyntaxVisitor;
1111
import org.jd.core.v1.model.javasyntax.declaration.*;
12+
import org.jd.core.v1.service.converter.classfiletojavasyntax.model.javasyntax.declaration.ClassFileBodyDeclaration;
1213
import org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker;
1314

1415
public class UpdateJavaSyntaxTreeStep0Visitor extends AbstractJavaSyntaxVisitor {
15-
protected UpdateOuterFieldTypeVisitor updateSyntheticMemberVisitor;
16+
protected UpdateOuterFieldTypeVisitor updateOuterFieldTypeVisitor;
1617

1718
public UpdateJavaSyntaxTreeStep0Visitor(TypeMaker typeMaker) {
18-
updateSyntheticMemberVisitor = new UpdateOuterFieldTypeVisitor(typeMaker);
19+
updateOuterFieldTypeVisitor = new UpdateOuterFieldTypeVisitor(typeMaker);
1920
}
2021

2122
@Override
2223
public void visit(BodyDeclaration declaration) {
23-
updateSyntheticMemberVisitor.visit(declaration);
24+
ClassFileBodyDeclaration bodyDeclaration = (ClassFileBodyDeclaration)declaration;
25+
boolean genericTypesSupported = (bodyDeclaration.getClassFile().getMajorVersion() >= 49); // (majorVersion >= Java 5)
26+
27+
if (genericTypesSupported) {
28+
updateOuterFieldTypeVisitor.safeAcceptListDeclaration(bodyDeclaration.getInnerTypeDeclarations());
29+
}
2430
}
2531

2632
@Override

src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/visitor/UpdateOuterFieldTypeVisitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public UpdateOuterFieldTypeVisitor(TypeMaker typeMaker) {
3737
@Override
3838
public void visit(BodyDeclaration declaration) {
3939
ClassFileBodyDeclaration bodyDeclaration = (ClassFileBodyDeclaration)declaration;
40-
boolean genericTypesSupported = (bodyDeclaration.getClassFile().getMajorVersion() >= 49); // (majorVersion >= Java 5)
4140

42-
if (genericTypesSupported) {
41+
if (!bodyDeclaration.getClassFile().matchAccessFlags(ACC_STATIC)) {
4342
safeAcceptListDeclaration(bodyDeclaration.getMethodDeclarations());
44-
safeAcceptListDeclaration(bodyDeclaration.getInnerTypeDeclarations());
4543
}
44+
45+
safeAcceptListDeclaration(bodyDeclaration.getInnerTypeDeclarations());
4646
}
4747

4848
@Override

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void visit(WhileStatement statement) {
191191
statementCount = 2;
192192
}
193193

194-
protected void acceptListStatement(List<? extends Statement> list) {
194+
public void acceptListStatement(List<? extends Statement> list) {
195195
int size = list.size();
196196

197197
switch (size) {
@@ -214,7 +214,7 @@ protected void acceptListStatement(List<? extends Statement> list) {
214214
}
215215
}
216216

217-
protected void safeAcceptListStatement(List<? extends Statement> list) {
217+
public void safeAcceptListStatement(List<? extends Statement> list) {
218218
if (list == null) {
219219
minLineNumber = maxLineNumber = 0;
220220
} else {
@@ -284,7 +284,7 @@ public void visit(NewExpression expression) {
284284
}
285285
}
286286

287-
protected void acceptListExpression(List<? extends Expression> list) {
287+
public void acceptListExpression(List<? extends Expression> list) {
288288
int size = list.size();
289289

290290
if (size == 0) {

0 commit comments

Comments
 (0)