1
- package twg2 .parser . intermAst .classes ;
1
+ package twg2 .ast . interm .classes ;
2
2
3
3
import java .io .IOException ;
4
4
import java .util .List ;
5
5
6
6
import lombok .Getter ;
7
7
import lombok .val ;
8
8
import twg2 .annotations .Immutable ;
9
+ import twg2 .ast .interm .field .FieldSig ;
10
+ import twg2 .ast .interm .field .FieldSigResolved ;
11
+ import twg2 .ast .interm .method .MethodSig ;
12
+ import twg2 .ast .interm .method .ParameterSig ;
13
+ import twg2 .ast .interm .method .ParameterSigResolved ;
9
14
import twg2 .io .write .JsonWrite ;
10
15
import twg2 .parser .baseAst .CompoundBlock ;
11
16
import twg2 .parser .baseAst .tools .NameUtil ;
12
- import twg2 .parser .intermAst .field .IntermFieldSig ;
13
- import twg2 .parser .intermAst .field .ResolvedFieldSig ;
14
- import twg2 .parser .intermAst .method .IntermMethodSig ;
15
- import twg2 .parser .intermAst .method .IntermParameterSig ;
16
- import twg2 .parser .intermAst .method .ResolvedParameterSig ;
17
17
import twg2 .parser .output .JsonWritableSig ;
18
18
import twg2 .parser .output .WriteSettings ;
19
19
import twg2 .text .stringUtils .StringJoin ;
22
22
* @author TeamworkGuy2
23
23
* @since 2015-12-4
24
24
*/
25
- public interface IntermClass <T_SIG extends IntermClassSig , T_METHOD extends JsonWritableSig , T_BLOCK extends CompoundBlock > extends JsonWritableSig {
25
+ public interface ClassAst <T_SIG extends ClassSig , T_METHOD extends JsonWritableSig , T_BLOCK extends CompoundBlock > extends JsonWritableSig {
26
26
27
27
public T_SIG getSignature ();
28
28
@@ -40,8 +40,8 @@ public interface IntermClass<T_SIG extends IntermClassSig, T_METHOD extends Json
40
40
* @since 2015-12-4
41
41
*/
42
42
@ Immutable
43
- public static class Impl <T_SIG extends IntermClassSig , T_FIELD extends JsonWritableSig , T_METHOD extends JsonWritableSig , T_PARAM extends JsonWritableSig , T_BLOCK extends CompoundBlock >
44
- implements IntermClass <T_SIG , T_METHOD , T_BLOCK > {
43
+ public static class Impl <T_SIG extends ClassSig , T_FIELD extends JsonWritableSig , T_METHOD extends JsonWritableSig , T_PARAM extends JsonWritableSig , T_BLOCK extends CompoundBlock >
44
+ implements ClassAst <T_SIG , T_METHOD , T_BLOCK > {
45
45
private final @ Getter T_SIG signature ;
46
46
private final @ Getter List <List <String >> usingStatements ;
47
47
private final @ Getter List <T_FIELD > fields ;
@@ -67,22 +67,30 @@ public Impl(T_SIG signature, List<List<String>> usingStatements, List<? extends
67
67
public void toJson (Appendable dst , WriteSettings st ) throws IOException {
68
68
dst .append ("{\n " );
69
69
70
- dst .append ("\" classSignature\" : " );
70
+ dst .append ("\t \ " classSignature\" : " );
71
71
signature .toJson (dst , st );
72
72
dst .append (",\n " );
73
73
74
- dst .append ("\" blockType\" : \" " + blockType + "\" ,\n " );
74
+ dst .append ("\t \ " blockType\" : \" " + blockType + "\" ,\n " );
75
75
76
- dst .append ("\" using\" : [" );
76
+ dst .append ("\t \ " using\" : [" );
77
77
JsonWrite .joinStr (usingStatements , ", " , dst , (us ) -> '"' + NameUtil .joinFqName (us ) + '"' );
78
78
dst .append ("],\n " );
79
79
80
- dst .append ("\" fields\" : [" );
81
- JsonWrite .joinStrConsume (fields , ", " , dst , (f ) -> f .toJson (dst , st ));
80
+ dst .append ("\t \" fields\" : [" );
81
+ if (fields .size () > 0 ) {
82
+ dst .append ("\n \t \t " );
83
+ JsonWrite .joinStrConsume (fields , ",\n \t \t " , dst , (f ) -> f .toJson (dst , st ));
84
+ dst .append ("\n \t " );
85
+ }
82
86
dst .append ("],\n " );
83
87
84
- dst .append ("\" methods\" : [" );
85
- JsonWrite .joinStrConsume (methods , ", " , dst , (m ) -> m .toJson (dst , st ));
88
+ dst .append ("\t \" methods\" : [" );
89
+ if (methods .size () > 0 ) {
90
+ dst .append ("\n \t \t " );
91
+ JsonWrite .joinStrConsume (methods , ",\n \t \t " , dst , (m ) -> m .toJson (dst , st ));
92
+ dst .append ("\n \t " );
93
+ }
86
94
dst .append ("]\n " );
87
95
88
96
dst .append ("}" );
@@ -104,10 +112,10 @@ public String toString() {
104
112
* @since 2016-1-2
105
113
*/
106
114
@ Immutable
107
- public static class SimpleImpl <T_BLOCK extends CompoundBlock > extends Impl <IntermClassSig .SimpleImpl , IntermFieldSig , IntermMethodSig .SimpleImpl , IntermParameterSig , T_BLOCK > {
115
+ public static class SimpleImpl <T_BLOCK extends CompoundBlock > extends Impl <ClassSig .SimpleImpl , FieldSig , MethodSig .SimpleImpl , ParameterSig , T_BLOCK > {
108
116
109
- public SimpleImpl (IntermClassSig .SimpleImpl signature , List <List <String >> usingStatements , List <? extends IntermFieldSig > fields ,
110
- List <? extends IntermMethodSig .SimpleImpl > methods , T_BLOCK blockType ) {
117
+ public SimpleImpl (ClassSig .SimpleImpl signature , List <List <String >> usingStatements , List <? extends FieldSig > fields ,
118
+ List <? extends MethodSig .SimpleImpl > methods , T_BLOCK blockType ) {
111
119
super (signature , usingStatements , fields , methods , blockType );
112
120
}
113
121
@@ -121,10 +129,10 @@ public SimpleImpl(IntermClassSig.SimpleImpl signature, List<List<String>> usingS
121
129
* @since 2015-12-4
122
130
*/
123
131
@ Immutable
124
- public static class ResolvedImpl <T_BLOCK extends CompoundBlock > extends Impl <IntermClassSig .ResolvedImpl , ResolvedFieldSig , IntermMethodSig .ResolvedImpl , ResolvedParameterSig , T_BLOCK > {
132
+ public static class ResolvedImpl <T_BLOCK extends CompoundBlock > extends Impl <ClassSig .ResolvedImpl , FieldSigResolved , MethodSig .ResolvedImpl , ParameterSigResolved , T_BLOCK > {
125
133
126
- public ResolvedImpl (IntermClassSig .ResolvedImpl signature , List <List <String >> usingStatements , List <? extends ResolvedFieldSig > fields ,
127
- List <? extends IntermMethodSig .ResolvedImpl > methods , T_BLOCK blockType ) {
134
+ public ResolvedImpl (ClassSig .ResolvedImpl signature , List <List <String >> usingStatements , List <? extends FieldSigResolved > fields ,
135
+ List <? extends MethodSig .ResolvedImpl > methods , T_BLOCK blockType ) {
128
136
super (signature , usingStatements , fields , methods , blockType );
129
137
}
130
138
0 commit comments