Skip to content

Commit 8ac1384

Browse files
committed
0.14.4 - Ensure output write order (sorted by fully qualifying name). Added/update JUnit tests.
1 parent d91e7d4 commit 8ac1384

15 files changed

+488
-144
lines changed

CHANGELOG.md

+38-26
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@ This project does its best to adhere to [Semantic Versioning](http://semver.org/
44

55

66
--------
7-
###[0.14.3](N/A) - 2017-02-06
7+
### [0.14.4](N/A) - 2017-06-25
8+
#### Added
9+
* Two more JUnit tests, CsModelParseTest and JavaModelParseTest
10+
* Added unit test helpers: test.twg2.parser.test.utils FieldAssert, MethodAssert, and TypeAssert
11+
12+
#### Changed
13+
* Ensure output write order of parsed file definitions (sorted by fully qualifying name)
14+
* Updated/refactored unit tests to use new unit test helpers
15+
* Renamed unit test helper ParseAnnotationAssert -> AnnotationAssert
16+
17+
18+
--------
19+
### [0.14.3](https://github.com/TeamworkGuy2/JParseCode/commit/d91e7d4a82827c3289d72d2feea9a5b9a0fe4cd3) - 2017-02-06
820
#### Changed
921
* Forgot to remove test code from MainParser
1022

1123

1224
--------
13-
###[0.14.2](https://github.com/TeamworkGuy2/JParseCode/commit/c9ff08c26752a18e8f38e4365181876d81461190) - 2017-02-06
25+
### [0.14.2](https://github.com/TeamworkGuy2/JParseCode/commit/c9ff08c26752a18e8f38e4365181876d81461190) - 2017-02-06
1426
#### Changed
1527
* Removed lombok.val usage/dependency from from test classes.
1628

@@ -20,15 +32,15 @@ This project does its best to adhere to [Semantic Versioning](http://semver.org/
2032

2133

2234
--------
23-
###[0.14.1](https://github.com/TeamworkGuy2/JParseCode/commit/53806a53d3b8152b35e3166a81dbe9a81a49f354) - 2016-12-03
35+
### [0.14.1](https://github.com/TeamworkGuy2/JParseCode/commit/53806a53d3b8152b35e3166a81dbe9a81a49f354) - 2016-12-03
2436
#### Changed
2537
* Updated dependencies to latest versions: jtext-parser@0.11.0, jtext-tokenizer@0.2.0, jparser-primitive@0.2.0
2638
* This includes a new parsing strategy which tries to parse non-compound tokens from start to finish using one parser at a time without passing the characters to compound parser, this improves performance and simplifies some of the compound parsers, but makes some compound parsers more difficult, such as ending conditions that try to keep track of characters between the start and end of the compound parser segment
2739
* GenericTypeTokenizer and IdentifierTokenizer changes to properly parse nullable generic parameters
2840

2941

3042
--------
31-
###[0.14.0](https://github.com/TeamworkGuy2/JParseCode/commit/07bd715ecd29a42d781b663cd3a20c2436e69bff) - 2016-10-30
43+
### [0.14.0](https://github.com/TeamworkGuy2/JParseCode/commit/07bd715ecd29a42d781b663cd3a20c2436e69bff) - 2016-10-30
3244
__Reduced library complexity/scope by moving twg2.parser.text conditions/tokenizers to separate [jtext-tokenizer](https://github.com/TeamworkGuy2/JTextTokenizer) library__
3345
#### Changed
3446
* Moved twg2.parser.text package to jtext-tokenizer library
@@ -49,7 +61,7 @@ __Reduced library complexity/scope by moving twg2.parser.text conditions/tokeniz
4961

5062

5163
--------
52-
###[0.13.0](https://github.com/TeamworkGuy2/JParseCode/commit/76734b17d16c67a89df7245a2cea2a1133c3b6b0) - 2016-10-26
64+
### [0.13.0](https://github.com/TeamworkGuy2/JParseCode/commit/76734b17d16c67a89df7245a2cea2a1133c3b6b0) - 2016-10-26
5365
__Parameter modifier parsing support__ (i.e. 'final' in Java or 'params' in C#):
5466
#### Added
5567
* Added ParameterSig and ParameterSigResolved 'parameterModifiers' field
@@ -71,13 +83,13 @@ __Parameter modifier parsing support__ (i.e. 'final' in Java or 'params' in C#):
7183

7284

7385
--------
74-
###[0.12.1](https://github.com/TeamworkGuy2/JParseCode/commit/a0ef508705fb685798e8762fbc08cd5a92eff273) - 2016-10-02
86+
### [0.12.1](https://github.com/TeamworkGuy2/JParseCode/commit/a0ef508705fb685798e8762fbc08cd5a92eff273) - 2016-10-02
7587
#### Changed
7688
* Updated dependencies, specifically jfile-io to 0.7.0 which no longer contains JsonWrite, so added json-stringify library for new equivalent JsonStringify class and updated related code
7789

7890

7991
--------
80-
###[0.12.0](https://github.com/TeamworkGuy2/JParseCode/commit/0ca793a0dd5f2d41f629e7f133dbd3bf2a2c4adb) - 2016-09-13
92+
### [0.12.0](https://github.com/TeamworkGuy2/JParseCode/commit/0ca793a0dd5f2d41f629e7f133dbd3bf2a2c4adb) - 2016-09-13
8193
#### Added
8294
* PerformanceTrackers, ParseTimes, TokenizeStepDetails in new twg2.parser.codeParser.tools.performance package - used for tracking performance
8395

@@ -95,7 +107,7 @@ __Parameter modifier parsing support__ (i.e. 'final' in Java or 'params' in C#):
95107

96108

97109
--------
98-
###[0.11.0](https://github.com/TeamworkGuy2/JParseCode/commit/3029d0d08bda6cc308d3732eb09eb971fd0e6030) - 2016-09-06
110+
### [0.11.0](https://github.com/TeamworkGuy2/JParseCode/commit/3029d0d08bda6cc308d3732eb09eb971fd0e6030) - 2016-09-06
99111
#### Added
100112
* __basic C# and Java enum parsing__
101113
* Added twg2.ast.interm.field FieldDef and FieldDefResolved to represent enum members (TODO could use some clarification/refactoring)
@@ -123,15 +135,15 @@ __Parameter modifier parsing support__ (i.e. 'final' in Java or 'params' in C#):
123135

124136

125137
--------
126-
###[0.10.8](https://github.com/TeamworkGuy2/JParseCode/commit/a89e38e23341bb999ec136fc61212c8271ad4332) - 2016-09-02
138+
### [0.10.8](https://github.com/TeamworkGuy2/JParseCode/commit/a89e38e23341bb999ec136fc61212c8271ad4332) - 2016-09-02
127139
#### Changed
128140
* Updated dependency, switched jparser-data-type-like (now deprecated/removed) to jparse-primitive which is a separate project containing just the primitive parsing code from jparser-data-type-like
129141
* Renamed project from JParserTools -> JParseCode
130142
* Moved plugin-js/ -> plugin/node-js/
131143

132144

133145
--------
134-
###[0.10.7](https://github.com/TeamworkGuy2/JParseCode/commit/ee313a3fe1bfe4e4be59c85b5997c5b13c26d1c8) - 2016-08-28
146+
### [0.10.7](https://github.com/TeamworkGuy2/JParseCode/commit/ee313a3fe1bfe4e4be59c85b5997c5b13c26d1c8) - 2016-08-28
135147
#### Added
136148
* Added jdate-times dependency (since dependent date/time code was moved from jdata-util and jparser-data-type-like to jdate-times)
137149

@@ -140,27 +152,27 @@ __Parameter modifier parsing support__ (i.e. 'final' in Java or 'params' in C#):
140152

141153

142154
--------
143-
###[0.10.6](https://github.com/TeamworkGuy2/JParseCode/commit/d1099ba9ef35ff0109c2c923044efe2219bd061d) - 2016-08-27
155+
### [0.10.6](https://github.com/TeamworkGuy2/JParseCode/commit/d1099ba9ef35ff0109c2c923044efe2219bd061d) - 2016-08-27
144156
#### Changed
145157
* Fixed version numbers and jackson-* dependency names in package-lib.json
146158

147159

148160
--------
149-
###[0.10.5](https://github.com/TeamworkGuy2/JParseCode/commit/d2efb99774df457392525dbdf4341c438fb20160) - 2016-08-21
161+
### [0.10.5](https://github.com/TeamworkGuy2/JParseCode/commit/d2efb99774df457392525dbdf4341c438fb20160) - 2016-08-21
150162
#### Changed
151163
* Added JCollectionBuilders and JTuples dependencies
152164
* Updated jcollection-util to latest 0.7.x version (removed twg2.collections.builder and twg2.collections.tuple)
153165

154166

155167
--------
156-
###[0.10.4](https://github.com/TeamworkGuy2/JParseCode/commit/5a3686f828a91eac9896755fb8f6ee8d888b3ca7) - 2016-08-18
168+
### [0.10.4](https://github.com/TeamworkGuy2/JParseCode/commit/5a3686f828a91eac9896755fb8f6ee8d888b3ca7) - 2016-08-18
157169
#### Changed
158170
* Updated jdata-util to latest 0.3.x version (EnumUtil renamed ErrorUtil, TimeUnitUtil package name changed)
159171
* Fixed compiled jar path and name
160172

161173

162174
--------
163-
###[0.10.3](https://github.com/TeamworkGuy2/JParseCode/commit/5e2e75da19451f6e99427405b6b04f844fb260de) - 2016-08-07
175+
### [0.10.3](https://github.com/TeamworkGuy2/JParseCode/commit/5e2e75da19451f6e99427405b6b04f844fb260de) - 2016-08-07
164176
#### Changed
165177
* Updated jcollection-util to latest 0.5.x version
166178
* Updated jfile-io to latest 0.6.x version (SourceInfo renamed to DirectorySearchInfo)
@@ -169,14 +181,14 @@ __Parameter modifier parsing support__ (i.e. 'final' in Java or 'params' in C#):
169181

170182

171183
--------
172-
###[0.10.2](https://github.com/TeamworkGuy2/JParseCode/commit/719509161f795fbafc56c8beefd51562103b6cb7) - 2016-06-21
184+
### [0.10.2](https://github.com/TeamworkGuy2/JParseCode/commit/719509161f795fbafc56c8beefd51562103b6cb7) - 2016-06-21
173185
#### Added
174186
* plugin-js to help generate CLI strings from TypeScript/Javascript projects, with Node.js in mind
175187
* Readme section about the CLI
176188

177189

178190
--------
179-
###[0.10.1](https://github.com/TeamworkGuy2/JParseCode/commit/5cdf7fabab17d8d9d8037c83c29047979a6438e7) - 2016-05-13
191+
### [0.10.1](https://github.com/TeamworkGuy2/JParseCode/commit/5cdf7fabab17d8d9d8037c83c29047979a6438e7) - 2016-05-13
180192
#### Changed
181193
* Merged DocumentFragmentRef with DocumentFragmentText
182194
* Added some documentation
@@ -192,7 +204,7 @@ __Parameter modifier parsing support__ (i.e. 'final' in Java or 'params' in C#):
192204

193205

194206
--------
195-
###[0.10.0](https://github.com/TeamworkGuy2/JParseCode/commit/3e8a324ccada6af273339e6f29ae569795e3abcd) - 2016-04-12
207+
### [0.10.0](https://github.com/TeamworkGuy2/JParseCode/commit/3e8a324ccada6af273339e6f29ae569795e3abcd) - 2016-04-12
196208
#### Added
197209
* Added better annotation parsing, including support for negative numbers as arguments
198210
* Added CodeFragment which extends 'DocumentFragmentText<CodeFragmentType>' so don't have to keep typing that every time, updated most of the code to use CodeFragment
@@ -209,7 +221,7 @@ __Parameter modifier parsing support__ (i.e. 'final' in Java or 'params' in C#):
209221

210222

211223
--------
212-
###[0.9.0](https://github.com/TeamworkGuy2/JParseCode/commit/679778bafd13a413854bd169cabe747b12bbc894) - 2016-03-20
224+
### [0.9.0](https://github.com/TeamworkGuy2/JParseCode/commit/679778bafd13a413854bd169cabe747b12bbc894) - 2016-03-20
213225
#### Added
214226
* Added commented parsing for comments attached to methods and fields (future TODO: add comment parsing for comments attached to classes and namespaces)
215227

@@ -221,7 +233,7 @@ __Parameter modifier parsing support__ (i.e. 'final' in Java or 'params' in C#):
221233

222234

223235
--------
224-
###[0.8.0](https://github.com/TeamworkGuy2/JParseCode/commit/32ee2a5ec5c218d3f90d1438f893a86e34b9c716) - 2016-02-28
236+
### [0.8.0](https://github.com/TeamworkGuy2/JParseCode/commit/32ee2a5ec5c218d3f90d1438f893a86e34b9c716) - 2016-02-28
225237
#### Changed
226238
Move from assuming that conditions can list the initial chars that match them (CharParser.WithMarks.getMatchFirstChars()) to CharParserMatchable and new getFirstCharMatcher() method which allows for a flexible definition of matching first chars
227239
* Moved/renamed ParserWorkFlow SourceInfo and LoadResult \(renamed to SourceFiles) nested classes and ParserMain.getFilesByExtension() to [JFileIo] (https://github.com/TeamworkGuy2/JFileIo) library
@@ -232,7 +244,7 @@ Move from assuming that conditions can list the initial chars that match them (C
232244

233245

234246
--------
235-
###[0.7.0](https://github.com/TeamworkGuy2/JParseCode/commit/218036c37673615e6bced0eecfb8a9b7d6eb7808) - 2016-02-24
247+
### [0.7.0](https://github.com/TeamworkGuy2/JParseCode/commit/218036c37673615e6bced0eecfb8a9b7d6eb7808) - 2016-02-24
236248
#### Changed
237249
* Updated to latest version of JTextParser and JStreamish
238250
* Switched from StringLineSupplier for reading lines from a source string to CharLineSupplier (slightly less garbage generated due to less conversion between strings and char arrays)
@@ -245,7 +257,7 @@ Move from assuming that conditions can list the initial chars that match them (C
245257

246258

247259
--------
248-
###[0.6.0](https://github.com/TeamworkGuy2/JParseCode/commit/5ae0793feb0475654bbdf835ef5d350e91cdd438) - 2016-02-21
260+
### [0.6.0](https://github.com/TeamworkGuy2/JParseCode/commit/5ae0793feb0475654bbdf835ef5d350e91cdd438) - 2016-02-21
249261
#### Added
250262
* Added numeric literal parsing \(i.e. '23' or '1.5f')
251263
* Added field and method access modifier parsing \(i.e. public, static, synchronized, volatile)
@@ -257,7 +269,7 @@ Move from assuming that conditions can list the initial chars that match them (C
257269

258270

259271
--------
260-
###[0.5.0](https://github.com/TeamworkGuy2/JParseCode/commit/eea353c111f789b315ab5471661c6a305c0701d2) - 2016-02-09
272+
### [0.5.0](https://github.com/TeamworkGuy2/JParseCode/commit/eea353c111f789b315ab5471661c6a305c0701d2) - 2016-02-09
261273
#### Added
262274
* Added array type parsing, \(i.e. 'int\[]\[]')
263275
* Added some more tests
@@ -268,7 +280,7 @@ Move from assuming that conditions can list the initial chars that match them (C
268280

269281

270282
--------
271-
###[0.4.0](https://github.com/TeamworkGuy2/JParseCode/commit/ab23d86656221e6b1a540d7129446b08c808aca4) - 2016-01-16
283+
### [0.4.0](https://github.com/TeamworkGuy2/JParseCode/commit/ab23d86656221e6b1a540d7129446b08c808aca4) - 2016-01-16
272284
#### Changed
273285
* Moved twg2.parser.condition.AstParser -> twg2.parser.baseAst.AstParser
274286
* Modified CodeLanguageOptions, so implementation class is a sub-class and CodeLanguageOptions contains only static fields and methods
@@ -281,7 +293,7 @@ Move from assuming that conditions can list the initial chars that match them (C
281293

282294

283295
--------
284-
###[0.3.0](https://github.com/TeamworkGuy2/JParseCode/commit/0b7128980ba31623d17f85d9f10bd4d99bd1288e) - 2016-01-16
296+
### [0.3.0](https://github.com/TeamworkGuy2/JParseCode/commit/0b7128980ba31623d17f85d9f10bd4d99bd1288e) - 2016-01-16
285297
#### Added
286298
* __Java parsing support and tests.__
287299
* Added Keyword interface for generic language keyword operations such as isKeyword(), isBlockModifierKeyword(), isDataTypeKeyword(), etc.
@@ -294,13 +306,13 @@ Move from assuming that conditions can list the initial chars that match them (C
294306

295307

296308
--------
297-
###[0.2.1](https://github.com/TeamworkGuy2/JParseCode/commit/a33f37ad6a116e7e697498af88327dfaa46709a0) - 2016-01-13
309+
### [0.2.1](https://github.com/TeamworkGuy2/JParseCode/commit/a33f37ad6a116e7e697498af88327dfaa46709a0) - 2016-01-13
298310
#### Added
299311
* Simple C# parse example with resulting JSON. Added and refactored some test cases.
300312

301313

302314
--------
303-
###[0.2.0](https://github.com/TeamworkGuy2/JParseCode/commit/5b692bc3476ca94c6dedb5b6424d1319fcad2057) - 2016-01-12
315+
### [0.2.0](https://github.com/TeamworkGuy2/JParseCode/commit/5b692bc3476ca94c6dedb5b6424d1319fcad2057) - 2016-01-12
304316
#### Added
305317
* __Finished command line interface (CLI) argument parsing for ['sources', 'destinations', 'log'] and ParserWorkflow.__
306318

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
JParseCode
22
==============
3-
version: 0.14.3
3+
version: 0.14.4
44

55
In progress C#/Java/TypeScript parser tools built atop [JTextParser] (https://github.com/TeamworkGuy2/JTextParser), [Jackson] (https://github.com/FasterXML/jackson-core/) (core, databind, annotations) and half a dozen other utility libraries.
66

bin/jparse_code-with-tests.jar

10.5 KB
Binary file not shown.

bin/jparse_code.jar

10.3 KB
Binary file not shown.

package-lib.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version" : "0.14.3",
2+
"version" : "0.14.4",
33
"name" : "jparse-code",
44
"description" : "An in-progress suite of parsing/transpilation tools for C#, Java, and TypeScript code. Generates simple JSON ASTs.",
55
"homepage" : "https://github.com/TeamworkGuy2/JParseCode",

src/twg2/parser/workflow/ParserWorkflow.java

+14-12
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
import lombok.val;
2323
import twg2.ast.interm.classes.ClassAst;
24+
import twg2.collections.builder.MapBuilder;
25+
import twg2.collections.dataStructures.PairList;
2426
import twg2.dateTimes.TimeUnitUtil;
2527
import twg2.io.fileLoading.DirectorySearchInfo;
2628
import twg2.io.fileLoading.SourceFiles;
@@ -311,45 +313,45 @@ public static class WriteResult {
311313
public static void write(Map<DestinationInfo, List<CodeFileParsed.Resolved<CodeFileSrc<CodeLanguage>, BlockType>>> resSets, Collection<List<String>> missingNamespaces) throws IOException {
312314
val writeSettings = new WriteSettings(true, false, false, true);
313315
// associates file paths with how many times each has been written to (so we can append on subsequent writes)
314-
val definitionsByOutputFile = new HashMap<String, List<char[]>>();
316+
val definitionsByOutputFile = new HashMap<String, PairList<String, char[]>>();
315317

316318
val tmpSb = new StringBuilder(2048);
317319

318320
// write class definitions to JSON strings and group by output file
319321
for(val dstSet : resSets.entrySet()) {
320322
val dst = dstSet.getKey();
321323
val classes = dstSet.getValue();
322-
val resClasses = new ArrayList<>(classes);
323324

324-
resClasses.sort((c1, c2) -> NameUtil.joinFqName(c1.getParsedClass().getSignature().getFullName()).compareTo(NameUtil.joinFqName(c2.getParsedClass().getSignature().getFullName())));
325-
326-
List<char[]> definitionStrs = definitionsByOutputFile.get(dst.path);
325+
PairList<String, char[]> definitionStrs = definitionsByOutputFile.get(dst.path);
327326
if(definitionStrs == null) {
328-
definitionStrs = new ArrayList<>();
327+
definitionStrs = new PairList<>();
329328
definitionsByOutputFile.put(dst.path, definitionStrs);
330329
}
331330

332-
for(val classInfo : resClasses) {
331+
for(val classInfo : classes) {
333332
tmpSb.setLength(0);
334-
tmpSb.append("\"" + NameUtil.joinFqName(classInfo.getParsedClass().getSignature().getFullName()) + "\": ");
333+
val classNameFq = NameUtil.joinFqName(classInfo.getParsedClass().getSignature().getFullName());
334+
tmpSb.append("\"" + classNameFq + "\": ");
335335
classInfo.getParsedClass().toJson(tmpSb, writeSettings);
336336
val dstChars = new char[tmpSb.length()];
337337
tmpSb.getChars(0, tmpSb.length(), dstChars, 0);
338-
definitionStrs.add(dstChars);
338+
definitionStrs.add(classNameFq, dstChars);
339339
}
340-
341340
}
342341

343342
for(val dstData : definitionsByOutputFile.entrySet()) {
343+
List<Entry<String, char[]>> defs = new ArrayList<>(MapBuilder.mutable(dstData.getValue().keyList(), dstData.getValue().valueList(), true).entrySet());
344+
Collections.sort(defs, (c1, c2) -> c1.getKey().compareTo(c2.getKey()));
345+
344346
try(val output = Files.newBufferedWriter(Paths.get(dstData.getKey()), StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
345347
boolean first = true;
346348
output.write("{\n\"files\": {");
347349

348-
for(val defChars : dstData.getValue()) {
350+
for(val def : defs) {
349351
if(!first) {
350352
output.append(",\n");
351353
}
352-
output.write(defChars, 0, defChars.length);
354+
output.write(def.getValue(), 0, def.getValue().length);
353355
first = false;
354356
}
355357

0 commit comments

Comments
 (0)