Skip to content

Commit 5cdf7fa

Browse files
committed
0.10.1 - Merged DocumentFragmentRef with DocumentFragmentText. Added some documentation and fixed some warnings. Fixed annotation named parameter parsing and C# property access modifier parsing bug.
1 parent b9daa86 commit 5cdf7fa

17 files changed

+207
-128
lines changed

versions.md CHANGELOG.md

+68-63
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,56 @@
1-
--------
2-
####0.10.0
3-
date: 2016-4-13
1+
# Change Log
2+
All notable changes to this project will be documented in this file.
3+
This project does its best to adhere to [Semantic Versioning](http://semver.org/).
44

5-
commit: ?
65

7-
* Fixed minor bug in annotation named parameter parsing when annotation only had one parameter
6+
--------
7+
###[0.10.1](N/A) - 2016-05-13
8+
####Changed
9+
* Merged DocumentFragmentRef with DocumentFragmentText
10+
* Added some documentation
11+
* Fixed some code warnings
12+
* Moved full class parsing tests to twg2.parser.codeParser.test
813

14+
####Fixed
15+
* Bug in annotation named parameter parsing when annotation only had one parameter
16+
* Bug in C# property parsing not supporting field modifiers (i.e. 'private', 'protected', ...)
917

10-
--------
11-
####0.10.0
12-
date: 2016-4-12
18+
####Removed
19+
* DocumentFragmentRef (merged with DocumentFragmentText)
1320

14-
commit: 3e8a324ccada6af273339e6f29ae569795e3abcd
1521

22+
--------
23+
###[0.10.0](https://github.com/TeamworkGuy2/JParserTools/commit/3e8a324ccada6af273339e6f29ae569795e3abcd) - 2016-04-12
24+
####Added
1625
* Added better annotation parsing, including support for negative numbers as arguments
17-
* Fixed ParserWorkflow to generate and group all results by destination file before writing (previously a writer was opened in overwrite mode for each destination group, thereby overwriting data written to the same file by a previous destination group during the same program execution)
1826
* Added CodeFragment which extends 'DocumentFragmentText<CodeFragmentType>' so don't have to keep typing that every time, updated most of the code to use CodeFragment
1927
* Added OperatorUtil and Operator (with C# and Java implementation enums) similar to the existing Keyword enums
28+
29+
####Changed
2030
* Refactored how we use EnumSubSet and enum sub-categorization
2131
* Added CodeFragmentEnumSubSet with is() and parse() methods which accept CodeFragment nodes (we were starting to duplicate this parsing code in Keyword and the new Operator class, so moved it to a reusable class)
2232
* Removed KeywordUtil isXyzKeyword() and parseXyzKeyword() methods in favor of methods that return CodeFragmentEnumSubSet instances for each of the keyword categories (i.e. 'blockModifiers()' or 'operators()')
2333
* Moved twg2.parser.codeParser extractor classes (i.e. AccessModifierExtractor or BlockExtractor) to new twg2.parser.codeParser.extractors package
2434

35+
####Fixed
36+
* ParserWorkflow now generates and groups all results by destination file before writing (previously a writer was opened in overwrite mode for each destination group, thereby overwriting data written to the same file by a previous destination group during the same program execution)
2537

26-
--------
27-
####0.9.0
28-
date: 2016-3-20
29-
30-
commit: 679778bafd13a413854bd169cabe747b12bbc894
3138

39+
--------
40+
###[0.9.0](https://github.com/TeamworkGuy2/JParserTools/commit/679778bafd13a413854bd169cabe747b12bbc894) - 2016-03-20
41+
####Added
3242
* Added commented parsing for comments attached to methods and fields (future TODO: add comment parsing for comments attached to classes and namespaces)
43+
44+
####Changed
3345
* Renamed intermAst packages to 'twg2.ast.interm'
34-
* Removed 'interm' from most AST class names
46+
* Renamed most AST classes, removed 'interm' from the name
3547
* Moved type resolution out of AST classes into new 'twg2.parser.resolver' classes (i.e. ClassSigResolver, FieldSigResolver, etc.)
3648
* Created 'twg2.parser.language' package for code language management classes
3749

3850

3951
--------
40-
####0.8.0
41-
date: 2016-2-28
42-
43-
commit: 32ee2a5ec5c218d3f90d1438f893a86e34b9c716
44-
52+
###[0.8.0](https://github.com/TeamworkGuy2/JParserTools/commit/32ee2a5ec5c218d3f90d1438f893a86e34b9c716) - 2016-02-28
53+
####Changed
4554
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
4655
* Moved/renamed ParserWorkFlow SourceInfo and LoadResult \(renamed to SourceFiles) nested classes and ParserMain.getFilesByExtension() to [JFileIo] (https://github.com/TeamworkGuy2/JFileIo) library
4756
* Moved twg2.parser.output JsonWrite and JsonWritable to JFileIO project's twg2.io.write package
@@ -51,87 +60,83 @@ Move from assuming that conditions can list the initial chars that match them (C
5160

5261

5362
--------
54-
####0.7.0
55-
date: 2016-2-24
56-
57-
commit: 218036c37673615e6bced0eecfb8a9b7d6eb7808
58-
63+
###[0.7.0](https://github.com/TeamworkGuy2/JParserTools/commit/218036c37673615e6bced0eecfb8a9b7d6eb7808) - 2016-02-24
64+
####Changed
5965
* Updated to latest version of JTextParser and JStreamish
6066
* 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)
61-
* Fixed toJson() not formatting generic types correctly
6267
* By default, annotation arguments map is include in toJson() output even if empty
6368
* ITrackSearchService.cs test file was using '\r' for newlines, replaced with '\n'
6469
* Moved twg2.parser.test package to separate test directory
6570

71+
####Fixed
72+
* Fixed toJson() not formatting generic types correctly
6673

67-
--------
68-
####0.6.0
69-
date: 2016-2-21
70-
71-
commit: 5ae0793feb0475654bbdf835ef5d350e91cdd438
7274

75+
--------
76+
###[0.6.0](https://github.com/TeamworkGuy2/JParserTools/commit/5ae0793feb0475654bbdf835ef5d350e91cdd438) - 2016-02-21
77+
####Added
7378
* Added numeric literal parsing \(i.e. '23' or '1.5f')
7479
* Added field and method access modifier parsing \(i.e. public, static, synchronized, volatile)
75-
* Fields now writing their annotations when toJson\() is called
80+
81+
####Changed
82+
* Fields now write their annotations when toJson\() is called
7683
* Changed JsonWrite method names to help differentiate their purposes
7784
* Update to use latest version of multiple libraries, including: JFileIo, JStreamish, JTextParser, and JParserDataTypeLike
7885

7986

8087
--------
81-
####0.5.0
82-
date: 2016-2-9
83-
84-
commit: eea353c111f789b315ab5471661c6a305c0701d2
85-
88+
###[0.5.0](https://github.com/TeamworkGuy2/JParserTools/commit/eea353c111f789b315ab5471661c6a305c0701d2) - 2016-02-09
89+
####Added
8690
* Added array type parsing, \(i.e. 'int\[]\[]')
91+
* Added some more tests
92+
93+
#### Changed
8794
* Moved twg2.parser.codeParser.eclipseProject to another project
88-
* Added some more tests and moved none JUnit experiment files to 'miscellaneous' package
95+
* Moved none JUnit experiment files to 'miscellaneous' package
8996

9097

9198
--------
92-
####0.4.0
93-
date: 2016-1-16
94-
95-
commit: ab23d86656221e6b1a540d7129446b08c808aca4
96-
97-
* Fixed a regression in C# method signature parsing
98-
* Removed unused twg2.parser.documentParser.block package
99+
###[0.4.0](https://github.com/TeamworkGuy2/JParserTools/commit/ab23d86656221e6b1a540d7129446b08c808aca4) - 2016-01-16
100+
####Changed
99101
* Moved twg2.parser.condition.AstParser -> twg2.parser.baseAst.AstParser
100102
* Modified CodeLanguageOptions, so implementation class is a sub-class and CodeLanguageOptions contains only static fields and methods
101103

104+
####Removed
105+
* Removed unused twg2.parser.documentParser.block package
102106

103-
--------
104-
####0.3.0
105-
date: 2016-1-16
107+
####Fixed
108+
* Fixed a regression in C# method signature parsing
106109

107-
commit: 0b7128980ba31623d17f85d9f10bd4d99bd1288e
108110

109-
* __Added Java parsing support and tests.__
111+
--------
112+
###[0.3.0](https://github.com/TeamworkGuy2/JParserTools/commit/0b7128980ba31623d17f85d9f10bd4d99bd1288e) - 2016-01-16
113+
####Added
114+
* __Java parsing support and tests.__
110115
* Added Keyword interface for generic language keyword operations such as isKeyword(), isBlockModifierKeyword(), isDataTypeKeyword(), etc.
116+
117+
####Changed
111118
* Made interm parsing more generic, added a bunch of parser creator functions to AstExtractor. Converted some of the C# interm parsers into more generic parsers to be used by C# and Java (see BaseFieldExtractor, BaseMethodExtractor, BaseMethodParametersParser)
112119
* Renamed getFullyQualifyingName() methods to getFullName(), (note: this may change again in future, possibly to getFqName())
113120
* Moved and renamed ParserCondition, Precondition -> ParserFactory, TokenParserCondition -> TokenParser, CharParserCondition -> CharParser, and ParserStartChars to the [JTextParser] (https://github.com/TeamworkGuy2/JTextParser) project
114121
* Simplified CharConditions and StringConditions sub-class names (i.e. StringConditions.StringStartFilter -> StringConditions.Start)
115122

116123

117124
--------
118-
####0.2.1
119-
date: 2016-1-13
120-
121-
commit: a33f37ad6a116e7e697498af88327dfaa46709a0
122-
123-
* Added simple C# parse example with resulting JSON. Added and refactored some test cases.
125+
###[0.2.1](https://github.com/TeamworkGuy2/JParserTools/commit/a33f37ad6a116e7e697498af88327dfaa46709a0) - 2016-01-13
126+
####Added
127+
* Simple C# parse example with resulting JSON. Added and refactored some test cases.
124128

125129

126130
--------
127-
####0.2.0:
128-
date: 2016-1-12
129-
130-
commit: 5b692bc3476ca94c6dedb5b6424d1319fcad2057
131-
131+
###[0.2.0](https://github.com/TeamworkGuy2/JParserTools/commit/5b692bc3476ca94c6dedb5b6424d1319fcad2057) - 2016-01-12
132+
####Added
132133
* __Finished command line interface (CLI) argument parsing for ['sources', 'destinations', 'log'] and ParserWorkflow.__
134+
135+
####Changed
133136
* Simplified CodeFileSrc generic signature. Added interfaces and setup entire parsing process to be generic (added CodeLanguage.getExtractor() and AstExtractor interface).
134137
* Refactored C# classes to support this more generic approach.
135-
* Removed IntermClass.getBlockTree(), it should be tracked higher up in the parsing process.
136138
* Added Simple and Resolved sub-classes of ProjectClassSet. Renamed CsMain -> ParserMain.
137139
* Added some additional EclipseClasspathFile/Utils methods for finding project dependencies.
140+
141+
####Removed
142+
* Removed IntermClass.getBlockTree(), it should be tracked higher up in the parsing process.

src/twg2/parser/baseAst/csharp/CsAstUtil.java

+22-4
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,35 @@ public boolean isKeyword(CodeFragment node, CsKeyword keyword1, CsKeyword keywor
125125
}
126126

127127

128+
/** Supports property blocks in the format:
129+
* <pre><code>{
130+
* [ [access-modifier] get ( ; | {...} ) ]
131+
* [ [access-modifier] set ( ; | {...} ) ]
132+
*}</code></pre>
133+
*/
128134
@Override
129135
public boolean isFieldBlock(SimpleTree<CodeFragment> block) {
130136
if(block == null) { return true; }
131137
val childs = block.getChildren();
132-
// properties must have at-least one indexer
138+
// properties must have at-least one indexer (i.e. 'get' or 'set')
133139
if(childs.size() == 0) { return false; }
134140

141+
val keywords = this.getLanguage().getKeywordUtil();
142+
135143
boolean prevWasGetOrSet = false;
136-
for(val child : childs) {
144+
for(int i = 0, size = childs.size(); i < size; i++) {
145+
val child = childs.get(i);
146+
val nextChild = i < size - 1 ? childs.get(i + 1) : null;
137147
val frag = child.getData();
138148
val fragType = frag.getFragmentType();
139149
if(fragType == CodeFragmentType.COMMENT) {
140150
continue;
141151
}
142-
val isGetOrSet = fragType == CodeFragmentType.IDENTIFIER && ("get".equals(frag.getText()) || "set".equals(frag.getText()));
143-
if(isGetOrSet || (prevWasGetOrSet && (fragType == CodeFragmentType.BLOCK || fragType == CodeFragmentType.SEPARATOR))) {
152+
val isGetOrSet = isGetOrSet(frag);
153+
val isAccessMod = keywords.fieldModifiers().is(frag);
154+
if(isGetOrSet ||
155+
(prevWasGetOrSet && (fragType == CodeFragmentType.BLOCK || fragType == CodeFragmentType.SEPARATOR)) ||
156+
(isAccessMod && nextChild != null && isGetOrSet(nextChild.getData()))) {
144157
// allow
145158
}
146159
else {
@@ -151,4 +164,9 @@ public boolean isFieldBlock(SimpleTree<CodeFragment> block) {
151164
return true;
152165
}
153166

167+
168+
private static boolean isGetOrSet(CodeFragment frag) {
169+
return frag.getFragmentType() == CodeFragmentType.IDENTIFIER && ("get".equals(frag.getText()) || "set".equals(frag.getText()));
170+
}
171+
154172
}

src/twg2/parser/codeParser/tools/EnumSplitter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.util.function.Function;
66
import java.util.function.Predicate;
77

8-
/**
8+
/** Static methods for splitting/extracting subsets of values from enums
99
* @author TeamworkGuy2
1010
* @since 2016-4-9
1111
*/

src/twg2/parser/codeParser/tools/EnumSubSet.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import java.util.function.Function;
88
import java.util.function.Predicate;
99

10-
/** A class and builder for a list of enum values and names and searching those names
10+
import twg2.collections.util.ToStringUtil;
11+
12+
/** A class and builder for a list of enum values and names and find() method to retrieve the value associated with a name
1113
* @author TeamworkGuy2
1214
* @since 2016-2-20
1315
*/
@@ -49,7 +51,13 @@ public E find(String name) {
4951
}
5052

5153

52-
/** Given a list of names in original order (names) and sorted order (namesSorted) and a list of values (values), create a sorted values array containing 'values'
54+
@Override
55+
public String toString() {
56+
return ToStringUtil.toStringKeyValuePairs(enumNames, enumValues, enumNames.length, null).toString();
57+
}
58+
59+
60+
/** Given a list of names in original order (names) and sorted order (namesSorted) and a list of values (values), return a sorted 'values' array
5361
* in the same order as (namesSorted) by using names.indexOf() to determine which index from (values) goes into each index of the returned array
5462
*/
5563
private static <G> G[] sortSecondListIntoArrayMatchingFirst(List<String> names, String[] namesSorted, List<G> values) {
@@ -84,13 +92,22 @@ private static <G> G[] sortSecondListIntoArrayMatchingFirst(List<String> names,
8492

8593

8694

95+
/** Build a subset of names and values from a enum
96+
* @author TeamworkGuy2
97+
* @since 2016-2-20
98+
* @param <F> this is the type of enum
99+
*/
87100
public static class Builder<F> {
88101
List<String> enumNameList = new ArrayList<>();
89102
List<F> enumValuesList = new ArrayList<>();
90103
Predicate<F> filter;
91104
Function<F, String> getName;
92105

93106

107+
/** Create a build for a subset of enum names and values
108+
* @param filter predicate to determine if an enum instance matches
109+
* @param getName used to transform each matching enum's name into the form that will be matched by {@link EnumSubSet#find(String)}
110+
*/
94111
public Builder(Predicate<F> filter, Function<F, String> getName) {
95112
this.filter = filter;
96113
this.getName = getName;
@@ -106,6 +123,7 @@ public boolean add(F enm) {
106123
return false;
107124
}
108125

126+
109127
public EnumSubSet<F> build() {
110128
String[] enumNames = enumNameList.toArray(new String[enumNameList.size()]);
111129
Arrays.sort(enumNames);
@@ -114,6 +132,7 @@ public EnumSubSet<F> build() {
114132

115133
return new EnumSubSet<>(enumNames, enumValues);
116134
}
135+
117136
}
118137

119138
}

src/twg2/parser/codeParser/tools/TokenListIterable.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,23 @@
99
import twg2.streams.EnhancedListBuilderIterator;
1010
import twg2.treeLike.simpleTree.SimpleTree;
1111

12-
/**
12+
/** Create an iterator for AST nodes, which skips {@link CodeFragmentType} COMMENT and STRING nodes.
1313
* @author TeamworkGuy2
1414
* @since 2016-1-1
1515
*/
1616
public class TokenListIterable implements Iterable<SimpleTree<CodeFragment>> {
1717

18+
/** A {@link SimpleTree}{@code <}{@link CodeFragment}{@code >} {@link Supplier}. When given an {@link Iterable}, this creates
19+
* a supplier which returns them in order, returns null once all the values have been iterated over
20+
* @author TeamworkGuy2
21+
* @since 2016-1-1
22+
*/
1823
static class TokenSupplier implements Supplier<SimpleTree<CodeFragment>> {
1924
Iterator<SimpleTree<CodeFragment>> childIter;
2025
Predicate<? super CodeFragment> cond;
2126
int i;
2227

28+
2329
public TokenSupplier(Iterable<? extends SimpleTree<? extends CodeFragment>> childs) {
2430
this(childs, null);
2531
}

src/twg2/parser/documentParser/DocumentFragmentRef.java

-38
This file was deleted.

0 commit comments

Comments
 (0)