@@ -18,43 +18,39 @@ Example:
18
18
Source Code (SimpleCs.cs):
19
19
``` C#
20
20
namespace ParserExamples .Samples {
21
-
22
- /// <summary >
23
- /// A simple class to test parsing.
24
- /// </summary >
25
- public class SimpleCs {
26
-
27
- /// <value >The modification count.</value >
28
- private int mod ;
29
-
30
- /// <value >The name.</value >
31
- private string _name ;
32
-
33
- /// <value >The names.</value >
34
- public IList <string > Names { get ; }
35
-
36
- /// <value >The number of names.</value >
37
- public int Count { set ; }
38
-
39
- /// <value >The access timestamps.</value >
40
- public DateTime [] accesses { set { this .mod ++ ; this .accesses = value ; } }
41
-
42
- /// <value >The access timestamps.</value >
43
- public string name { get { this .mod ++ ; return this ._name ; } set { this .mod ++ ; this ._name = value ; } }
44
-
45
- /// <summary >Add name</summary >
46
- /// <param name =" name" >the name</param >
47
- /// <returns >the names</returns >
48
- [OperationContract ]
49
- [WebInvoke (Method = " POST" , UriTemplate = " /AddName?name={name}" ,
50
- ResponseFormat = WebMessageFormat .Json )]
51
- [TransactionFlow (TransactionFlowOption .Allowed )]
52
- Result <IList <String >> AddName (string name ) {
53
- content of block ;
54
- }
55
-
56
- }
57
-
21
+ /// <summary >
22
+ /// A simple class to test parsing.
23
+ /// </summary >
24
+ public class SimpleCs {
25
+ /// <value >The modification count.</value >
26
+ private int mod ;
27
+
28
+ /// <value >The name.</value >
29
+ private string _name ;
30
+
31
+ /// <value >The names.</value >
32
+ public IList <string > Names { get ; }
33
+
34
+ /// <value >The number of names.</value >
35
+ public int Count { set ; }
36
+
37
+ /// <value >The access timestamps.</value >
38
+ public DateTime [] accesses { set { this .mod ++ ; this .accesses = value ; } }
39
+
40
+ /// <value >The access timestamps.</value >
41
+ public string name { get { this .mod ++ ; return this ._name ; } set { this .mod ++ ; this ._name = value ; } }
42
+
43
+ /// <summary >Add name</summary >
44
+ /// <param name =" name" >the name</param >
45
+ /// <returns >the names</returns >
46
+ [OperationContract ]
47
+ [WebInvoke (Method = " POST" , UriTemplate = " /AddName?name={name}" ,
48
+ ResponseFormat = WebMessageFormat .Json )]
49
+ [TransactionFlow (TransactionFlowOption .Allowed )]
50
+ Result <IList <String >> AddName (string name ) {
51
+ content of block ;
52
+ }
53
+ }
58
54
}
59
55
```
60
56
@@ -65,114 +61,114 @@ CodeFileSrc<CodeLanguage> simpleCsAst = ParseCodeFile.parseCode("SimpleCs.cs", C
65
61
WriteSettings ws = new WriteSettings (true , true , true , true );
66
62
67
63
for (Map . Entry<SimpleTree<CodeToken > , ClassAst .SimpleImpl<CsBlock > > block : CodeLanguageOptions . C_SHARP. getExtractor(). extractClassFieldsAndMethodSignatures(simpleCsAst. getDoc())) {
68
- CodeFileParsed . Simple<String , CsBlock > fileParsed = new CodeFileParsed .Simple<> (" SimpleCs.cs" , block. getValue(), block. getKey());
64
+ CodeFileParsed . Simple<String , CsBlock > fileParsed = new CodeFileParsed .Simple<> (" SimpleCs.cs" , block. getValue(), block. getKey());
69
65
70
- StringBuilder sb = new StringBuilder ();
71
- fileParsed. getParsedClass(). toJson(sb, ws);
72
- System . out. println(sb. toString()); // Print the parsed AST to System.out
66
+ StringBuilder sb = new StringBuilder ();
67
+ fileParsed. getParsedClass(). toJson(sb, ws);
68
+ System . out. println(sb. toString()); // Print the parsed AST to System.out
73
69
}
74
70
```
75
71
76
72
77
73
JSON Result (printed to System.out):
78
74
``` JSON
79
75
{
80
- "classSignature" : {
81
- "access" : " PUBLIC" ,
82
- "name" : " ParserExamples.Samples.SimpleCs" ,
83
- "declarationType" : " class"
84
- },
85
- "blockType" : " CLASS" ,
86
- "using" : [],
87
- "fields" : [{
88
- "name" : " ParserExamples.Samples.SimpleCs.mod" ,
89
- "type" : {
90
- "typeName" : " int" ,
91
- "primitive" : true
92
- },
93
- "accessModifiers" : [" private" ],
94
- "annotations" : [],
95
- "comments" : [" <value>The modification count.</value>\n " ]
96
- }, {
97
- "name" : " ParserExamples.Samples.SimpleCs._name" ,
98
- "type" : {
99
- "typeName" : " string"
100
- },
101
- "accessModifiers" : [" private" ],
102
- "annotations" : [],
103
- "comments" : [" <value>The name.</value>\n " ]
104
- }, {
105
- "name" : " ParserExamples.Samples.SimpleCs.Names" ,
106
- "type" : {
107
- "typeName" : " IList" ,
108
- "genericParameters" : [{
109
- "typeName" : " string"
110
- }]
111
- },
112
- "accessModifiers" : [" public" ],
113
- "annotations" : [],
114
- "comments" : [" <value>The names.</value>\n " ]
115
- }, {
116
- "name" : " ParserExamples.Samples.SimpleCs.Count" ,
117
- "type" : {
118
- "typeName" : " int" ,
119
- "primitive" : true
120
- },
121
- "accessModifiers" : [" public" ],
122
- "annotations" : [],
123
- "comments" : [" <value>The number of names.</value>\n " ]
124
- }, {
125
- "name" : " ParserExamples.Samples.SimpleCs.accesses" ,
126
- "type" : {
127
- "typeName" : " DateTime" ,
128
- "arrayDimensions" : 1
129
- },
130
- "accessModifiers" : [" public" ],
131
- "annotations" : [],
132
- "comments" : [" <value>The access timestamps.</value>\n " ]
133
- }, {
134
- "name" : " ParserExamples.Samples.SimpleCs.name" ,
135
- "type" : {
136
- "typeName" : " string"
137
- },
138
- "accessModifiers" : [" public" ],
139
- "annotations" : [],
140
- "comments" : [" <value>The access timestamps.</value>\n " ]
141
- }],
142
- "methods" : [{
143
- "name" : " ParserExamples.Samples.SimpleCs.AddName" ,
144
- "parameters" : [{
145
- "type" : " string" ,
146
- "name" : " name"
147
- }],
148
- "accessModifiers" : [],
149
- "annotations" : [{
150
- "name" : " OperationContract" ,
151
- "arguments" : {}
152
- }, {
153
- "name" : " WebInvoke" ,
154
- "arguments" : {
155
- "ResponseFormat" : " WebMessageFormat.Json" ,
156
- "Method" : " POST" ,
157
- "UriTemplate" : " /AddName?name={name}"
158
- }
159
- }, {
160
- "name" : " TransactionFlow" ,
161
- "arguments" : {
162
- "value" : " TransactionFlowOption.Allowed"
163
- }
164
- }],
165
- "returnType" : {
166
- "typeName" : " Result" ,
167
- "genericParameters" : [{
168
- "typeName" : " IList" ,
169
- "genericParameters" : [{
170
- "typeName" : " String"
171
- }]
172
- }]
173
- },
174
- "comments" : [" <summary>Add name</summary>\n " , " <param name=\" name\" >the name</param>\n " , " <returns>the names</returns>\n " ]
175
- }]
76
+ "classSignature" : {
77
+ "access" : " PUBLIC" ,
78
+ "name" : " ParserExamples.Samples.SimpleCs" ,
79
+ "declarationType" : " class"
80
+ },
81
+ "blockType" : " CLASS" ,
82
+ "using" : [],
83
+ "fields" : [{
84
+ "name" : " ParserExamples.Samples.SimpleCs.mod" ,
85
+ "type" : {
86
+ "typeName" : " int" ,
87
+ "primitive" : true
88
+ },
89
+ "accessModifiers" : [" private" ],
90
+ "annotations" : [],
91
+ "comments" : [" <value>The modification count.</value>\n " ]
92
+ }, {
93
+ "name" : " ParserExamples.Samples.SimpleCs._name" ,
94
+ "type" : {
95
+ "typeName" : " string"
96
+ },
97
+ "accessModifiers" : [" private" ],
98
+ "annotations" : [],
99
+ "comments" : [" <value>The name.</value>\n " ]
100
+ }, {
101
+ "name" : " ParserExamples.Samples.SimpleCs.Names" ,
102
+ "type" : {
103
+ "typeName" : " IList" ,
104
+ "genericParameters" : [{
105
+ "typeName" : " string"
106
+ }]
107
+ },
108
+ "accessModifiers" : [" public" ],
109
+ "annotations" : [],
110
+ "comments" : [" <value>The names.</value>\n " ]
111
+ }, {
112
+ "name" : " ParserExamples.Samples.SimpleCs.Count" ,
113
+ "type" : {
114
+ "typeName" : " int" ,
115
+ "primitive" : true
116
+ },
117
+ "accessModifiers" : [" public" ],
118
+ "annotations" : [],
119
+ "comments" : [" <value>The number of names.</value>\n " ]
120
+ }, {
121
+ "name" : " ParserExamples.Samples.SimpleCs.accesses" ,
122
+ "type" : {
123
+ "typeName" : " DateTime" ,
124
+ "arrayDimensions" : 1
125
+ },
126
+ "accessModifiers" : [" public" ],
127
+ "annotations" : [],
128
+ "comments" : [" <value>The access timestamps.</value>\n " ]
129
+ }, {
130
+ "name" : " ParserExamples.Samples.SimpleCs.name" ,
131
+ "type" : {
132
+ "typeName" : " string"
133
+ },
134
+ "accessModifiers" : [" public" ],
135
+ "annotations" : [],
136
+ "comments" : [" <value>The access timestamps.</value>\n " ]
137
+ }],
138
+ "methods" : [{
139
+ "name" : " ParserExamples.Samples.SimpleCs.AddName" ,
140
+ "parameters" : [{
141
+ "type" : " string" ,
142
+ "name" : " name"
143
+ }],
144
+ "accessModifiers" : [],
145
+ "annotations" : [{
146
+ "name" : " OperationContract" ,
147
+ "arguments" : {}
148
+ }, {
149
+ "name" : " WebInvoke" ,
150
+ "arguments" : {
151
+ "ResponseFormat" : " WebMessageFormat.Json" ,
152
+ "Method" : " POST" ,
153
+ "UriTemplate" : " /AddName?name={name}"
154
+ }
155
+ }, {
156
+ "name" : " TransactionFlow" ,
157
+ "arguments" : {
158
+ "value" : " TransactionFlowOption.Allowed"
159
+ }
160
+ }],
161
+ "returnType" : {
162
+ "typeName" : " Result" ,
163
+ "genericParameters" : [{
164
+ "typeName" : " IList" ,
165
+ "genericParameters" : [{
166
+ "typeName" : " String"
167
+ }]
168
+ }]
169
+ },
170
+ "comments" : [" <summary>Add name</summary>\n " , " <param name=\" name\" >the name</param>\n " , " <returns>the names</returns>\n " ]
171
+ }]
176
172
}
177
173
```
178
174
0 commit comments