Skip to content

Commit db38f7e

Browse files
committed
0.15.0 - Refactoring, simplifying generic type signatures and switching some classes from using getters to 'public final' fields.
1 parent 283d487 commit db38f7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+573
-505
lines changed

CHANGELOG.md

+21-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@
22
All notable changes to this project will be documented in this file.
33
This project does its best to adhere to [Semantic Versioning](http://semver.org/).
44

5+
6+
--------
7+
### [0.15.0](N/A) - 2017-10-15
8+
#### Changed
9+
Simplified class names and generic type signatures:
10+
* Changed `AnnotationSig`, `BlockAst`, `MethodSig`, `CodeFileSrc`, and `CodeFileParsed` to have `public final` properties and remove getters
11+
* CodeFileSrc `language` property type is now `CodeLanguage`, not a generic type parameter
12+
* CodeFileSrc `doc` property renamed `astTree`
13+
* `CodeFileParsed`, `CodeTokenizerBuilder`,
14+
* `CodeFileParsed` and `ProjectClassSet` added `Intermediate` implementations to existing `Simple` and `Resolved` implementations with simplified generic type parameters
15+
* Split ClassSig `SimpleImpl` and `ResolvedImpl` into separate files
16+
* Split MethodSig `SimpleImpl` and `ResolvedImpl` into separate `MethodSigSimple` and `MethodSigResolved` files
17+
18+
519
--------
6-
### [0.14.5](N/A) - 2017-08-20
20+
### [0.14.5](https://github.com/TeamworkGuy2/JParseCode/commit/283d487a7e04d7355451f2fe641cacff2e026cc3) - 2017-08-20
721
#### Changed
822
* Update dependencies:
923
* jfunc@0.3.0 (Predicates.Char -> CharPredicate)
@@ -41,9 +55,12 @@ This project does its best to adhere to [Semantic Versioning](http://semver.org/
4155
--------
4256
### [0.14.1](https://github.com/TeamworkGuy2/JParseCode/commit/53806a53d3b8152b35e3166a81dbe9a81a49f354) - 2016-12-03
4357
#### Changed
44-
* Updated dependencies to latest versions: jtext-parser@0.11.0, jtext-tokenizer@0.2.0, jparser-primitive@0.2.0
45-
* 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
46-
* GenericTypeTokenizer and IdentifierTokenizer changes to properly parse nullable generic parameters
58+
* Updated dependencies:
59+
* jtext-parser@0.11.0
60+
* jtext-tokenizer@0.2.0
61+
* jparser-primitive@0.2.0
62+
* 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
63+
* `GenericTypeTokenizer` and `IdentifierTokenizer` changes to properly parse nullable generic parameters
4764

4865

4966
--------

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
JParseCode
22
==============
3-
version: 0.14.5
3+
version: 0.15.0
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

-930 Bytes
Binary file not shown.

bin/jparse_code.jar

-509 Bytes
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.5",
2+
"version" : "0.15.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",

src/twg2/ast/interm/annotation/AnnotationSig.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.Map;
66

77
import lombok.AllArgsConstructor;
8-
import lombok.Getter;
98
import lombok.val;
109
import twg2.annotations.Immutable;
1110
import twg2.parser.codeParser.tools.NameUtil;
@@ -15,9 +14,9 @@
1514
@Immutable
1615
@AllArgsConstructor
1716
public class AnnotationSig implements JsonWritableSig {
18-
private final @Getter String name;
19-
private final @Getter List<String> fullName;
20-
private final @Getter Map<String, String> arguments;
17+
public final String name;
18+
public final List<String> fullName;
19+
public final Map<String, String> arguments;
2120

2221

2322
@Override

src/twg2/ast/interm/block/BlockAst.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package twg2.ast.interm.block;
22

3-
import lombok.Getter;
43
import twg2.annotations.Immutable;
5-
import twg2.ast.interm.classes.ClassSig;
4+
import twg2.ast.interm.classes.ClassSigSimple;
65
import twg2.parser.codeParser.BlockType;
76
import twg2.parser.fragment.CodeToken;
87
import twg2.treeLike.simpleTree.SimpleTree;
@@ -13,12 +12,12 @@
1312
*/
1413
@Immutable
1514
public class BlockAst<T_BLOCK extends BlockType> {
16-
private final @Getter ClassSig.SimpleImpl declaration;
17-
private final @Getter SimpleTree<CodeToken> blockTree;
18-
private final @Getter T_BLOCK blockType;
15+
public final ClassSigSimple declaration;
16+
public final SimpleTree<CodeToken> blockTree;
17+
public final T_BLOCK blockType;
1918

2019

21-
public BlockAst(ClassSig.SimpleImpl declaration, SimpleTree<CodeToken> blockTree, T_BLOCK blockType) {
20+
public BlockAst(ClassSigSimple declaration, SimpleTree<CodeToken> blockTree, T_BLOCK blockType) {
2221
this.declaration = declaration;
2322
this.blockTree = blockTree;
2423
this.blockType = blockType;

src/twg2/ast/interm/classes/ClassAst.java

+10-13
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import twg2.ast.interm.field.FieldDefResolved;
1111
import twg2.ast.interm.field.FieldSig;
1212
import twg2.ast.interm.field.FieldSigResolved;
13-
import twg2.ast.interm.method.MethodSig;
13+
import twg2.ast.interm.method.MethodSigResolved;
14+
import twg2.ast.interm.method.MethodSigSimple;
1415
import twg2.ast.interm.method.ParameterSig;
1516
import twg2.ast.interm.method.ParameterSigResolved;
1617
import twg2.io.json.stringify.JsonStringify;
@@ -24,14 +25,10 @@
2425
* @author TeamworkGuy2
2526
* @since 2015-12-4
2627
*/
27-
public interface ClassAst<T_SIG extends ClassSig, T_METHOD extends JsonWritableSig, T_BLOCK extends BlockType> extends JsonWritableSig {
28+
public interface ClassAst<T_SIG extends ClassSig, T_BLOCK extends BlockType> extends JsonWritableSig {
2829

2930
public T_SIG getSignature();
3031

31-
public List<List<String>> getUsingStatements();
32-
33-
public List<T_METHOD> getMethods();
34-
3532
public T_BLOCK getBlockType();
3633

3734

@@ -43,7 +40,7 @@ public interface ClassAst<T_SIG extends ClassSig, T_METHOD extends JsonWritableS
4340
*/
4441
@Immutable
4542
public static class Impl<T_SIG extends ClassSig, T_ENUM extends JsonWritableSig, T_FIELD extends JsonWritableSig, T_METHOD extends JsonWritableSig, T_PARAM extends JsonWritableSig, T_BLOCK extends BlockType>
46-
implements ClassAst<T_SIG, T_METHOD, T_BLOCK> {
43+
implements ClassAst<T_SIG, T_BLOCK> {
4744
private final @Getter T_SIG signature;
4845
private final @Getter List<List<String>> usingStatements;
4946
private final @Getter List<T_ENUM> enumMembers;
@@ -128,10 +125,10 @@ public String toString() {
128125
* @since 2016-1-2
129126
*/
130127
@Immutable
131-
public static class SimpleImpl<T_BLOCK extends BlockType> extends Impl<ClassSig.SimpleImpl, FieldDef, FieldSig, MethodSig.SimpleImpl, ParameterSig, T_BLOCK> {
128+
public static class SimpleImpl<T_BLOCK extends BlockType> extends Impl<ClassSigSimple, FieldDef, FieldSig, MethodSigSimple, ParameterSig, T_BLOCK> {
132129

133-
public SimpleImpl(ClassSig.SimpleImpl signature, List<List<String>> usingStatements, List<? extends FieldSig> fields,
134-
List<? extends MethodSig.SimpleImpl> methods, List<? extends FieldDef> enums, T_BLOCK blockType) {
130+
public SimpleImpl(ClassSigSimple signature, List<List<String>> usingStatements, List<? extends FieldSig> fields,
131+
List<? extends MethodSigSimple> methods, List<? extends FieldDef> enums, T_BLOCK blockType) {
135132
super(signature, usingStatements, fields, methods, enums, blockType);
136133
}
137134

@@ -145,10 +142,10 @@ public SimpleImpl(ClassSig.SimpleImpl signature, List<List<String>> usingStateme
145142
* @since 2015-12-4
146143
*/
147144
@Immutable
148-
public static class ResolvedImpl<T_BLOCK extends BlockType> extends Impl<ClassSig.ResolvedImpl, FieldDefResolved, FieldSigResolved, MethodSig.ResolvedImpl, ParameterSigResolved, T_BLOCK> {
145+
public static class ResolvedImpl<T_BLOCK extends BlockType> extends Impl<ClassSigResolved, FieldDefResolved, FieldSigResolved, MethodSigResolved, ParameterSigResolved, T_BLOCK> {
149146

150-
public ResolvedImpl(ClassSig.ResolvedImpl signature, List<List<String>> usingStatements, List<? extends FieldSigResolved> fields,
151-
List<? extends MethodSig.ResolvedImpl> methods, List<? extends FieldDefResolved> enums, T_BLOCK blockType) {
147+
public ResolvedImpl(ClassSigResolved signature, List<List<String>> usingStatements, List<? extends FieldSigResolved> fields,
148+
List<? extends MethodSigResolved> methods, List<? extends FieldDefResolved> enums, T_BLOCK blockType) {
152149
super(signature, usingStatements, fields, methods, enums, blockType);
153150
}
154151

-135
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
package twg2.ast.interm.classes;
22

3-
import java.io.IOException;
43
import java.util.List;
54

6-
import lombok.AllArgsConstructor;
7-
import lombok.Getter;
8-
import lombok.val;
9-
import twg2.annotations.Immutable;
10-
import twg2.ast.interm.type.TypeSig;
11-
import twg2.io.json.stringify.JsonStringify;
125
import twg2.parser.codeParser.AccessModifier;
13-
import twg2.parser.codeParser.tools.NameUtil;
146
import twg2.parser.output.JsonWritableSig;
15-
import twg2.parser.output.WriteSettings;
167

178
/**
189
* @author TeamworkGuy2
@@ -28,130 +19,4 @@ public interface ClassSig extends JsonWritableSig {
2819

2920
public String getSimpleName();
3021

31-
32-
33-
34-
@Immutable
35-
@AllArgsConstructor
36-
public static class SimpleImpl implements ClassSig {
37-
private final @Getter List<String> fullName;
38-
/** This type's generic type parameters, if any */
39-
private final @Getter List<TypeSig.TypeSigSimple> params;
40-
/** The block's type (i.e. 'interface', 'class', 'enum', etc.) */
41-
private final @Getter AccessModifier accessModifier;
42-
private final @Getter String declarationType;
43-
private final @Getter List<String> extendImplementSimpleNames;
44-
45-
46-
@Override
47-
public String getSimpleName() {
48-
return fullName.get(fullName.size() - 1);
49-
}
50-
51-
52-
public boolean isGeneric() {
53-
return params.size() > 0;
54-
}
55-
56-
57-
@Override
58-
public void toJson(Appendable dst, WriteSettings st) throws IOException {
59-
val json = JsonStringify.inst;
60-
61-
dst.append("{ ");
62-
63-
json.toProp("access", accessModifier.toSrc(), dst);
64-
json.comma(dst).toProp("name", (st.fullClassName ? NameUtil.joinFqName(fullName) : fullName.get(fullName.size() - 1)), dst);
65-
66-
if(declarationType != null) {
67-
json.comma(dst).toProp("declarationType", declarationType, dst);
68-
}
69-
70-
if(params != null && params.size() > 0) {
71-
json.comma(dst).propName("genericParameters", dst)
72-
.toArrayConsume(params, dst, (p) -> p.toJson(dst, st));
73-
}
74-
75-
if(extendImplementSimpleNames.size() > 0) {
76-
json.comma(dst).propName("extendImplementClassNames", dst)
77-
.toStringArray(extendImplementSimpleNames, dst);
78-
}
79-
80-
dst.append(" }");
81-
}
82-
83-
84-
@Override
85-
public String toString() {
86-
return accessModifier.toSrc() + " " + declarationType + " " + NameUtil.joinFqName(fullName);
87-
}
88-
89-
}
90-
91-
92-
93-
94-
/**
95-
* @author TeamworkGuy2
96-
* @since 2015-12-5
97-
*/
98-
@Immutable
99-
@AllArgsConstructor
100-
public static class ResolvedImpl implements ClassSig {
101-
private final @Getter List<String> fullName;
102-
/** This type's generic type parameters, if any */
103-
private final @Getter List<TypeSig.TypeSigResolved> params;
104-
private final @Getter AccessModifier accessModifier;
105-
/** The block's type (i.e. 'interface', 'class', 'enum', etc.) */
106-
private final @Getter String declarationType;
107-
private final @Getter TypeSig.TypeSigResolved extendClass;
108-
private final @Getter List<TypeSig.TypeSigResolved> implementInterfaces;
109-
110-
111-
@Override
112-
public String getSimpleName() {
113-
return fullName.get(fullName.size() - 1);
114-
}
115-
116-
117-
public boolean isGeneric() {
118-
return params.size() > 0;
119-
}
120-
121-
122-
@Override
123-
public void toJson(Appendable dst, WriteSettings st) throws IOException {
124-
val json = JsonStringify.inst;
125-
126-
dst.append("{ ");
127-
json.toProp("access", accessModifier.toSrc(), dst).comma(dst)
128-
.toProp("name", (st.fullClassName ? NameUtil.joinFqName(fullName) : fullName.get(fullName.size() - 1)), dst).comma(dst)
129-
.toProp("declarationType", declarationType, dst);
130-
131-
if(params != null && params.size() > 0) {
132-
json.comma(dst).append("\"genericParameters\": ", dst);
133-
json.toArrayConsume(params, dst, (p) -> p.toJson(dst, st));
134-
}
135-
136-
if(extendClass != null) {
137-
json.comma(dst).append("\"extendClassName\": ", dst);
138-
extendClass.toJson(dst, st);
139-
}
140-
141-
if(implementInterfaces.size() > 0) {
142-
json.comma(dst).append("\"implementClassNames\": ", dst);
143-
json.toArrayConsume(implementInterfaces, dst, (intfType) -> intfType.toJson(dst, st));
144-
}
145-
146-
dst.append(" }");
147-
}
148-
149-
150-
@Override
151-
public String toString() {
152-
return accessModifier.toSrc() + " " + declarationType + " " + NameUtil.joinFqName(fullName);
153-
}
154-
155-
}
156-
15722
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package twg2.ast.interm.classes;
2+
3+
import java.io.IOException;
4+
import java.util.List;
5+
6+
import lombok.AllArgsConstructor;
7+
import lombok.Getter;
8+
import lombok.val;
9+
import twg2.annotations.Immutable;
10+
import twg2.ast.interm.type.TypeSig;
11+
import twg2.io.json.stringify.JsonStringify;
12+
import twg2.parser.codeParser.AccessModifier;
13+
import twg2.parser.codeParser.tools.NameUtil;
14+
import twg2.parser.output.WriteSettings;
15+
16+
/**
17+
* @author TeamworkGuy2
18+
* @since 2015-12-5
19+
*/
20+
@Immutable
21+
@AllArgsConstructor
22+
public class ClassSigResolved implements ClassSig {
23+
private final @Getter List<String> fullName;
24+
/** This type's generic type parameters, if any */
25+
private final @Getter List<TypeSig.TypeSigResolved> params;
26+
/** The block's access (i.e. 'public', 'private', etc.) */
27+
private final @Getter AccessModifier accessModifier;
28+
/** The block's type (i.e. 'interface', 'class', 'enum', etc.) */
29+
private final @Getter String declarationType;
30+
private final @Getter TypeSig.TypeSigResolved extendClass;
31+
private final @Getter List<TypeSig.TypeSigResolved> implementInterfaces;
32+
33+
34+
@Override
35+
public String getSimpleName() {
36+
return fullName.get(fullName.size() - 1);
37+
}
38+
39+
40+
public boolean isGeneric() {
41+
return params.size() > 0;
42+
}
43+
44+
45+
@Override
46+
public void toJson(Appendable dst, WriteSettings st) throws IOException {
47+
val json = JsonStringify.inst;
48+
49+
dst.append("{ ");
50+
json.toProp("access", accessModifier.toSrc(), dst).comma(dst)
51+
.toProp("name", (st.fullClassName ? NameUtil.joinFqName(fullName) : fullName.get(fullName.size() - 1)), dst).comma(dst)
52+
.toProp("declarationType", declarationType, dst);
53+
54+
if(params != null && params.size() > 0) {
55+
json.comma(dst).append("\"genericParameters\": ", dst);
56+
json.toArrayConsume(params, dst, (p) -> p.toJson(dst, st));
57+
}
58+
59+
if(extendClass != null) {
60+
json.comma(dst).append("\"extendClassName\": ", dst);
61+
extendClass.toJson(dst, st);
62+
}
63+
64+
if(implementInterfaces.size() > 0) {
65+
json.comma(dst).append("\"implementClassNames\": ", dst);
66+
json.toArrayConsume(implementInterfaces, dst, (intfType) -> intfType.toJson(dst, st));
67+
}
68+
69+
dst.append(" }");
70+
}
71+
72+
73+
@Override
74+
public String toString() {
75+
return accessModifier.toSrc() + " " + declarationType + " " + NameUtil.joinFqName(fullName);
76+
}
77+
78+
}

0 commit comments

Comments
 (0)