Skip to content

Commit 691c019

Browse files
committed
0.19.1 - Finish CommentAndWhitespaceExtractor.java and unit tests. Other minor code cleanup and unit test additions.
1 parent 9e95bec commit 691c019

21 files changed

+342
-249
lines changed

.classpath

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jcollection-builders/bin/jcollection_builders.jar" sourcepath="/JCollectionBuilders"/>
3333
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jcollection-interfaces/bin/jcollection_interfaces.jar" sourcepath="/JCollectionInterfaces"/>
3434
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jcollection-util/bin/jcollection_util.jar" sourcepath="/JCollectionUtil"/>
35-
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jdata-util/bin/jdata_util.jar" sourcepath="/JDataUtil"/>
3635
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jdate-times/bin/jdate_times.jar" sourcepath="/JDateTimes"/>
36+
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jdata-util/bin/jdata_util.jar" sourcepath="/JDataUtil"/>
3737
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jfile-io/bin/jfile_io.jar" sourcepath="/JFileIo"/>
3838
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jfunc/bin/jfunc.jar" sourcepath="/JFunc"/>
3939
<classpathentry kind="lib" path="C:/Users/TeamworkGuy2/Documents/Java/Libraries/jinterfaces/bin/jinterfaces.jar" sourcepath="/JInterfaces"/>

CHANGELOG.md

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

55

66
--------
7-
### [0.19.0](N/A) - 2019-07-04
7+
### [0.19.1](N/A) - 2020-04-20
8+
#### Changed
9+
* Finish `CommentAndWhitespaceExtractor` and tests for it
10+
* `TextToken` interface now includes `hashCode()` and `equals(Object)`
11+
* `TextFragmentRefToken` now implements `hashCode()` and `equals(Object)`
12+
* Minor code cleanup, use `StringSplit.split()` with `char` instead of `String` where possible
13+
14+
15+
--------
16+
### [0.19.0](https://github.com/TeamworkGuy2/JParseCode/commit/9e95bec5e50e9fd229d25f181d17da98a8d238b3) - 2019-07-04
817
#### Changed
918
* `IdentifierTokenizer.createIdentifierWithGenericTypeTokenizer()` now takes one parameter `int maxGenericTypeDepth`
1019
* Changed `CsFileTokenizer.createFileParser()` -> `createCsTokenizers()` and `JavaFileTokenizer.createFileParser()` -> `createJavaTokenizers()`

README.md

+133-137
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,39 @@ Example:
1818
Source Code (SimpleCs.cs):
1919
```C#
2020
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+
}
5854
}
5955
```
6056

@@ -65,114 +61,114 @@ CodeFileSrc<CodeLanguage> simpleCsAst = ParseCodeFile.parseCode("SimpleCs.cs", C
6561
WriteSettings ws = new WriteSettings(true, true, true, true);
6662

6763
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());
6965

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
7369
}
7470
```
7571

7672

7773
JSON Result (printed to System.out):
7874
```JSON
7975
{
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+
}]
176172
}
177173
```
178174

bin/jparse_code-with-tests.jar

1.89 KB
Binary file not shown.

bin/jparse_code.jar

-31.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.19.0",
2+
"version" : "0.19.1",
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/codeParser/codeStats/ParseDirectoryCodeFiles.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static Entry<Map<CodeLanguage, ParsedCategoryStats>, List<ParsedFileStats>> cate
6767
Map<CodeLanguage, List<ParsedFileStats>> filesPerCategory = new HashMap<>();
6868

6969
for(ParsedFileStats fileStat : fileStats) {
70-
CodeLanguage lang = CodeLanguageOptions.tryFromFileExtension(StringSplit.lastMatch(fileStat.getSrcId(), "."));
70+
CodeLanguage lang = CodeLanguageOptions.tryFromFileExtension(StringSplit.lastMatch(fileStat.getSrcId(), '.'));
7171
if(lang == null) {
7272
uncategorizedFiles.add(fileStat);
7373
}
@@ -140,7 +140,7 @@ public static ParseDirectoryCodeFiles parseFileStats(Path relativePath, List<Pat
140140
char[] src = fileReader.readChars(new FileInputStream(file));
141141
int srcOff = 0;
142142
int srcLen = src.length;
143-
Entry<String, String> fileNameExt = StringSplit.lastMatchParts(fullFileName, ".");
143+
Entry<String, String> fileNameExt = StringSplit.lastMatchParts(fullFileName, '.');
144144
if("json".equals(fileNameExt.getValue())) {
145145
int lineCount = StringSplit.countMatches(src, srcOff, srcLen, new char[] { '\n' }, 0, 1);
146146
var parsedStats = new ParsedFileStats(file.toString(), srcLen, 0, 0, lineCount);

src/twg2/parser/codeParser/codeStats/ParsedFileStats.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package twg2.parser.codeParser.codeStats;
22

33
import lombok.Getter;
4-
import lombok.NoArgsConstructor;
54
import twg2.collections.primitiveCollections.IntArrayList;
65
import twg2.collections.primitiveCollections.IntList;
76

@@ -12,7 +11,6 @@
1211
* @author TeamworkGuy2
1312
* @since 2015-9-19
1413
*/
15-
@NoArgsConstructor
1614
public final class ParsedFileStats {
1715
@Getter String srcId;
1816
@Getter int charCount;
@@ -25,6 +23,10 @@ public final class ParsedFileStats {
2523
@Getter int totalLineCount;
2624

2725

26+
public ParsedFileStats() {
27+
}
28+
29+
2830
public ParsedFileStats(String srcId, int charCount, int whitespaceLineCount, int commentLineCount, int totalLineCount) {
2931
this.srcId = srcId;
3032
this.charCount = charCount;

0 commit comments

Comments
 (0)