Skip to content

Commit bb033bc

Browse files
committed
0.18.0 - Update jfile-io@0.8.3 (fix loading empty stream/file), new '-threads #' and '-debug' command line arguments, additional debugging/performance information.
1 parent 7745de0 commit bb033bc

22 files changed

+294
-175
lines changed

CHANGELOG.md

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

55

66
--------
7-
### [0.17.0](N/A) - 2019-03-30
7+
### [0.18.0](N/A) - 2019-03-30
8+
#### Changed
9+
* Added `-debug` and `-threads #` command line arguments
10+
* More detailed debug and log file information
11+
* Renamed `TokenizeStepLogger` -> `ParserActionLogger`
12+
* `ParseTimes.log()` renamed `setActionTime()`
13+
* Simplified and synchronized `PerformanceTrackers` so instance can be shared across threads
14+
* Renamed node.js plugin file `plugins/node-js/jparser-tools-cli` -> `plugins/node-js/jparse-code-cli` and renamed associated test file
15+
16+
#### Removed
17+
* Unused `ScopeType` enum
18+
19+
#### Fixed
20+
* Fixed multi-threaded parsing! Handling of FileReadUtil, performance logs, and result lists are now synchronized in `ParserMisc.parseFileSet()`
21+
* Update dependency jfile-io@0.8.3 (fix for decoding empty streams/files)
22+
23+
24+
--------
25+
### [0.17.0](https://github.com/TeamworkGuy2/JParseCode/commit/7745de03fb4ce135ddb8e6a7f158f6d1f27c5329) - 2019-03-30
826
Performance refactor, several libraries updated: JArrays, JCollectionUtil, JFileIo, JTextParser, and JTextTokenizer
927
#### Changed
1028
* Changed to new `FileReadUtil.readChars(InputStream)` (`jfile-io@0.8.2`)

README.md

+17-7
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,22 @@ JSON Result (printed to System.out):
179179

180180
--------
181181

182-
### Command Line Interface (CLI)
182+
## Command Line Interface (CLI)
183183

184184
A command line call looks like:
185185
```
186186
path/to/java -jar path/to/jparse-code.jar
187187
-sources './src/java/Server/Services=1,[cs];./src/java/Server/Models=3,[cs]'
188188
-destinations './output/Services.json=[App.Services];./output/Models.json=[App.Entities]'
189189
-log './output/parser.log'
190+
-threads 1
191+
-debug
190192
```
191-
Where ./src/java/Server/** is where source files are kept
192-
And the files in ./src/java/Server/Services belong to the C# namespace `App.Services` and ./src/java/Server/Models/ belong to the C# namespace `App.Entities`
193+
Where `./src/java/Server/**` is where source files are kept
194+
And the files in `./src/java/Server/Services` belong to the C# namespace `App.Services` and `./src/java/Server/Models` belong to the C# namespace `App.Entities`
193195

194196

195-
#### Sources
197+
### Sources
196198
A semicolon separated list of paths set equal to a directory depth followed by a comma and a comma separated, brackets wrapped, list of file extensions.
197199
The path, child directory depth, and file extensions are used to create a file system filter and all matching files are parsed.
198200
The following formats are valid:
@@ -204,21 +206,29 @@ Example: ```/project/myApp/Models=3,[java,json]```
204206
Note: the brackets around the '[java,json]' file extension list are literal.
205207

206208

207-
#### Destinations
209+
### Destinations
208210
A semicolon separated list of output file names associated with lists of namespaces. Each parsed file who's namespace falls into one of these lists is written to that file.
209211
The following format is valid:
210212
'path=[namespace,namespace,...]'
211213

212214
Example: ```/project/output/models.json=[MyApp.Models]```
213215

214216

215-
#### Log
217+
### Log
216218
An optional log file name to write parser information to, in the format:
217219
'path'
218220

219221
Example: ```/project/output/parser-log.log```
220222

221223

224+
### Threads
225+
An optional number of threads to run parsing in parallel, 0 uses the logical number of processors on the current machine, default is 1
226+
227+
228+
### Debug
229+
An optional flag which causes extra debug and performance information to be logged
230+
231+
222232
--------
223-
Plugins:
233+
### Plugins:
224234
Currently there is one plugin, a dual purpose TypeScript/Javascript plugin for create the CLI argument strings used by jparse-code.jar

bin/jparse_code-with-tests.jar

1.54 KB
Binary file not shown.

bin/jparse_code.jar

1.13 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.17.0",
2+
"version" : "0.18.0",
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",
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"use strict";
2-
var JParserToolsCli = require("./jparser-tools-cli");
2+
var JParseCodeCli = require("./jparse-code-cli");
33
/** Simple test for jparser-tools-cli
44
* @author TeamworkGuy2
55
* @since 2016-06-21
66
*/
7-
var JParserToolsCliTest;
8-
(function (JParserToolsCliTest) {
7+
var JParseCodeCliTest;
8+
(function (JParseCodeCliTest) {
99
function testJsCli() {
10-
var opts = JParserToolsCli.createOptions({
10+
var opts = JParseCodeCli.createOptions({
1111
sources: [
1212
{ path: "src/services", depth: 1, fileExtensions: ["java"] },
1313
{ path: "src/models", depth: 2, fileExtensions: ["java"] },
@@ -16,23 +16,27 @@ var JParserToolsCliTest;
1616
{ path: "../models/service-defs.json", namespaces: ["App.Services"] },
1717
{ path: "../models/model-defs.json", namespaces: ["App.Models", "App.Core"] },
1818
],
19-
log: "../output/jparser-tools.log"
19+
log: "../output/jparser-tools.log",
20+
threads: 5,
21+
debug: true
2022
});
21-
var optsStr = JParserToolsCli.stringifyOptions(opts, '"');
23+
var optsStr = JParseCodeCli.stringifyOptions(opts, '"');
2224
var expStr = ' -sources "' + "src/services=1,[java]" + ";" + "src/models=2,[java]" + '"' +
2325
' -destinations "' + "../models/service-defs.json=[App.Services]" + ";" + "../models/model-defs.json=[App.Models,App.Core]" + '"' +
24-
' -log "' + "../output/jparser-tools.log" + '"';
26+
' -log "' + "../output/jparser-tools.log" + '"' +
27+
' -threads ' + 5 +
28+
' -debug';
2529
if (expStr !== optsStr) {
2630
throw new Error("options string mismatch, expected: \n'" + expStr + "'\nactual: \n'" + optsStr + "'");
2731
}
2832
else {
2933
console.log("success 'testJsCli()'");
3034
}
3135
}
32-
JParserToolsCliTest.testJsCli = testJsCli;
33-
})(JParserToolsCliTest || (JParserToolsCliTest = {}));
36+
JParseCodeCliTest.testJsCli = testJsCli;
37+
})(JParseCodeCliTest || (JParseCodeCliTest = {}));
3438
function main() {
35-
JParserToolsCliTest.testJsCli();
39+
JParseCodeCliTest.testJsCli();
3640
}
3741
main();
38-
module.exports = JParserToolsCliTest;
42+
module.exports = JParseCodeCliTest;

plugins/node-js/jparser-tools-cli-tests.ts plugins/node-js/jparse-code-cli-tests.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import JParserToolsCli = require("./jparser-tools-cli");
1+
import JParseCodeCli = require("./jparse-code-cli");
22

33
/** Simple test for jparser-tools-cli
44
* @author TeamworkGuy2
55
* @since 2016-06-21
66
*/
7-
module JParserToolsCliTest {
7+
module JParseCodeCliTest {
88

99
export function testJsCli() {
10-
var opts = JParserToolsCli.createOptions({
10+
var opts = JParseCodeCli.createOptions({
1111
sources: [
1212
{ path: "src/services", depth: 1, fileExtensions: ["java"] },
1313
{ path: "src/models", depth: 2, fileExtensions: ["java"] },
@@ -17,13 +17,17 @@ module JParserToolsCliTest {
1717
{ path: "../models/model-defs.json", namespaces: ["App.Models", "App.Core"] },
1818
],
1919
log: "../output/jparser-tools.log",
20+
threads: 5,
21+
debug: true
2022
});
2123

22-
var optsStr = JParserToolsCli.stringifyOptions(opts, '"');
24+
var optsStr = JParseCodeCli.stringifyOptions(opts, '"');
2325

2426
var expStr = ' -sources "' + "src/services=1,[java]" + ";" + "src/models=2,[java]" + '"' +
2527
' -destinations "' + "../models/service-defs.json=[App.Services]" + ";" + "../models/model-defs.json=[App.Models,App.Core]" + '"' +
26-
' -log "' + "../output/jparser-tools.log" + '"';
28+
' -log "' + "../output/jparser-tools.log" + '"' +
29+
' -threads ' + 5 +
30+
' -debug';
2731

2832
if (expStr !== optsStr) {
2933
throw new Error("options string mismatch, expected: \n'" + expStr + "'\nactual: \n'" + optsStr + "'");
@@ -37,10 +41,10 @@ module JParserToolsCliTest {
3741

3842

3943
function main() {
40-
JParserToolsCliTest.testJsCli();
44+
JParseCodeCliTest.testJsCli();
4145
}
4246

4347
main();
4448

4549

46-
export = JParserToolsCliTest;
50+
export = JParseCodeCliTest;
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
"use strict";
2-
/** Generate CLI strings for jparser-tools.jar from javascript objects
2+
/** Generate CLI strings for jparse-code.jar from javascript objects
33
* @author TeamworkGuy2
44
* @since 2016-06-21
55
*/
6-
var JParserToolsCli;
7-
(function (JParserToolsCli) {
6+
var JParseCodeCli;
7+
(function (JParseCodeCli) {
88
function createOptions(opts) {
99
return opts;
1010
}
11-
JParserToolsCli.createOptions = createOptions;
11+
JParseCodeCli.createOptions = createOptions;
1212
function stringifyOptions(opts, quoteChar) {
1313
if (quoteChar === void 0) { quoteChar = '"'; }
1414
var srcs = opts.sources;
1515
var dsts = opts.destinations;
1616
return " -sources " + quoteChar + srcs.map(function (s) { return s.path + "=" + s.depth + "," + "[" + s.fileExtensions.join(",") + "]"; }).join(";") + quoteChar +
1717
" -destinations " + quoteChar + dsts.map(function (d) { return d.path + "=" + "[" + d.namespaces.join(",") + "]"; }).join(";") + quoteChar +
18-
(opts.log ? " -log " + quoteChar + opts.log + quoteChar : "");
18+
(opts.log ? " -log " + quoteChar + opts.log + quoteChar : "") +
19+
(!isNaN(opts.threads) ? " -threads " + opts.threads : "") +
20+
(opts.debug === true ? " -debug" : "");
1921
}
20-
JParserToolsCli.stringifyOptions = stringifyOptions;
21-
})(JParserToolsCli || (JParserToolsCli = {}));
22-
module.exports = JParserToolsCli;
22+
JParseCodeCli.stringifyOptions = stringifyOptions;
23+
})(JParseCodeCli || (JParseCodeCli = {}));
24+
module.exports = JParseCodeCli;
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11

2-
/** Generate CLI strings for jparser-tools.jar from javascript objects
2+
/** Generate CLI strings for jparse-code.jar from javascript objects
33
* @author TeamworkGuy2
44
* @since 2016-06-21
55
*/
6-
module JParserToolsCli {
6+
module JParseCodeCli {
77

8-
export interface Options {
8+
export interface ParseOptions {
99
sources: { path: string; depth: number; fileExtensions: string[]; }[];
1010
destinations: { path: string; namespaces: string[]; }[];
11-
log: string;
11+
log?: string | null;
12+
threads?: number | null;
13+
debug?: boolean | null;
1214
}
1315

1416

15-
export function createOptions(opts: Options) {
17+
export function createOptions(opts: ParseOptions) {
1618
return opts;
1719
}
1820

1921

20-
export function stringifyOptions(opts: Options, quoteChar = '"') {
22+
export function stringifyOptions(opts: ParseOptions, quoteChar = '"') {
2123
var srcs = opts.sources;
2224
var dsts = opts.destinations;
2325

2426
return " -sources " + quoteChar + srcs.map(s => s.path + "=" + s.depth + "," + "[" + s.fileExtensions.join(",") + "]").join(";") + quoteChar +
2527
" -destinations " + quoteChar + dsts.map(d => d.path + "=" + "[" + d.namespaces.join(",") + "]").join(";") + quoteChar +
26-
(opts.log ? " -log " + quoteChar + opts.log + quoteChar : "");
28+
(opts.log ? " -log " + quoteChar + opts.log + quoteChar : "") +
29+
(!isNaN(opts.threads) ? " -threads " + opts.threads : "") +
30+
(opts.debug === true ? " -debug" : "");
2731
}
2832

2933
}
3034

31-
export = JParserToolsCli;
35+
export = JParseCodeCli;

src/twg2/parser/codeParser/ScopeType.java

-18
This file was deleted.

src/twg2/parser/codeParser/analytics/ParseTimes.java

+25-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.IOException;
44
import java.util.Map;
55

6-
import lombok.Getter;
76
import twg2.dataUtil.dataUtils.EnumError;
87
import twg2.io.files.FileUtil;
98
import twg2.io.json.stringify.JsonStringify;
@@ -27,18 +26,38 @@ public static enum TrackerAction {
2726

2827

2928

30-
@Getter long setupNs;
31-
@Getter long loadNs;
32-
@Getter long tokenizeNs;
33-
@Getter long parseNs;
29+
long setupNs;
30+
long loadNs;
31+
long tokenizeNs;
32+
long parseNs;
33+
34+
35+
public long getSetupNs() {
36+
return setupNs;
37+
}
38+
39+
40+
public long getLoadNs() {
41+
return loadNs;
42+
}
43+
44+
45+
public long getTokenizeNs() {
46+
return tokenizeNs;
47+
}
48+
49+
50+
public long getParseNs() {
51+
return parseNs;
52+
}
3453

3554

3655
public long getTotalNs() {
3756
return setupNs + loadNs + tokenizeNs + parseNs;
3857
}
3958

4059

41-
public void log(TrackerAction action, long timeNanos) {
60+
public void setActionTime(TrackerAction action, long timeNanos) {
4261
switch(action) {
4362
case SETUP:
4463
this.setupNs = timeNanos;

0 commit comments

Comments
 (0)