@futpib/parser 1.0.3 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +24 -0
- package/.github/workflows/main.yml +1 -0
- package/build/androidPackageParser.js +30 -32
- package/build/arbitraryDalvikBytecode.d.ts +3 -3
- package/build/arbitraryDalvikBytecode.js +33 -27
- package/build/arbitraryDalvikExecutable.js +55 -17
- package/build/arbitraryJava.d.ts +31 -0
- package/build/arbitraryJava.js +532 -0
- package/build/arbitraryJavaScript.d.ts +3 -0
- package/build/arbitraryJavaScript.js +263 -0
- package/build/arbitraryJavascript.d.ts +3 -0
- package/build/arbitraryJavascript.js +263 -0
- package/build/arbitraryZig.d.ts +3 -0
- package/build/arbitraryZig.js +240 -0
- package/build/arbitraryZipStream.d.ts +1 -1
- package/build/arrayParser.js +72 -13
- package/build/backsmali.d.ts +4 -3
- package/build/backsmali.js +26 -6
- package/build/bash.d.ts +89 -0
- package/build/bash.js +1 -0
- package/build/bashParser.d.ts +6 -0
- package/build/bashParser.js +335 -0
- package/build/bashParser.test.d.ts +1 -0
- package/build/bashParser.test.js +343 -0
- package/build/bashParserEdgeCases.test.d.ts +1 -0
- package/build/bashParserEdgeCases.test.js +117 -0
- package/build/dalvikBytecodeParser/addressConversion.d.ts +110 -0
- package/build/dalvikBytecodeParser/addressConversion.js +334 -0
- package/build/dalvikBytecodeParser/formatParsers.d.ts +7 -6
- package/build/dalvikBytecodeParser/formatParsers.js +13 -14
- package/build/dalvikBytecodeParser.d.ts +60 -31
- package/build/dalvikBytecodeParser.js +92 -35
- package/build/dalvikBytecodeParser.test-d.d.ts +1 -0
- package/build/dalvikBytecodeParser.test-d.js +268 -0
- package/build/dalvikBytecodeUnparser/formatUnparsers.d.ts +9 -8
- package/build/dalvikBytecodeUnparser/formatUnparsers.js +13 -12
- package/build/dalvikBytecodeUnparser.d.ts +2 -2
- package/build/dalvikBytecodeUnparser.js +23 -23
- package/build/dalvikBytecodeUnparser.test.js +7 -7
- package/build/dalvikExecutable.d.ts +3 -3
- package/build/dalvikExecutable.test-d.d.ts +1 -0
- package/build/dalvikExecutable.test-d.js +59 -0
- package/build/dalvikExecutableParser/typedNumbers.d.ts +18 -0
- package/build/dalvikExecutableParser/typedNumbers.js +3 -0
- package/build/dalvikExecutableParser.d.ts +2 -1
- package/build/dalvikExecutableParser.js +96 -77
- package/build/dalvikExecutableParser.test.js +24 -3
- package/build/dalvikExecutableParserAgainstSmaliParser.test.js +3 -0
- package/build/dalvikExecutableUnparser/poolScanners.d.ts +2 -2
- package/build/dalvikExecutableUnparser/sectionUnparsers.d.ts +3 -3
- package/build/dalvikExecutableUnparser/sectionUnparsers.js +26 -11
- package/build/dalvikExecutableUnparser.d.ts +2 -2
- package/build/dalvikExecutableUnparser.test.js +2 -1
- package/build/disjunctionParser.d.ts +5 -3
- package/build/disjunctionParser.js +79 -17
- package/build/disjunctionParser.test-d.d.ts +1 -0
- package/build/disjunctionParser.test-d.js +72 -0
- package/build/elementSwitchParser.d.ts +4 -0
- package/build/{exactElementSwitchParser.js → elementSwitchParser.js} +3 -4
- package/build/elementSwitchParser.test-d.d.ts +1 -0
- package/build/elementSwitchParser.test-d.js +44 -0
- package/build/exactSequenceParser.d.ts +4 -2
- package/build/exactSequenceParser.test-d.d.ts +1 -0
- package/build/exactSequenceParser.test-d.js +36 -0
- package/build/fetchCid.js +2 -66
- package/build/index.d.ts +25 -2
- package/build/index.js +23 -1
- package/build/index.test.js +16 -1
- package/build/inputReader.d.ts +10 -0
- package/build/inputReader.js +36 -0
- package/build/java.d.ts +502 -0
- package/build/java.js +2 -0
- package/build/javaKeyStoreParser.js +14 -17
- package/build/javaParser.d.ts +51 -0
- package/build/javaParser.js +1538 -0
- package/build/javaParser.test.d.ts +1 -0
- package/build/javaParser.test.js +1287 -0
- package/build/javaScript.d.ts +35 -0
- package/build/javaScript.js +1 -0
- package/build/javaScriptParser.d.ts +9 -0
- package/build/javaScriptParser.js +34 -0
- package/build/javaScriptUnparser.d.ts +3 -0
- package/build/javaScriptUnparser.js +4 -0
- package/build/javaScriptUnparser.test.d.ts +1 -0
- package/build/javaScriptUnparser.test.js +24 -0
- package/build/javaUnparser.d.ts +2 -0
- package/build/javaUnparser.js +519 -0
- package/build/javaUnparser.test.d.ts +1 -0
- package/build/javaUnparser.test.js +24 -0
- package/build/javascript.d.ts +35 -0
- package/build/javascript.js +1 -0
- package/build/javascriptParser.d.ts +9 -0
- package/build/javascriptParser.js +34 -0
- package/build/javascriptUnparser.d.ts +3 -0
- package/build/javascriptUnparser.js +4 -0
- package/build/javascriptUnparser.test.d.ts +1 -0
- package/build/javascriptUnparser.test.js +24 -0
- package/build/jsonParser.js +2 -12
- package/build/lazyMessageError.d.ts +3 -0
- package/build/lookaheadParser.js +60 -3
- package/build/negativeLookaheadParser.js +70 -11
- package/build/nonEmptyArrayParser.js +72 -13
- package/build/objectParser.d.ts +12 -0
- package/build/objectParser.js +31 -0
- package/build/objectParser.test-d.d.ts +1 -0
- package/build/objectParser.test-d.js +112 -0
- package/build/objectParser.test.d.ts +1 -0
- package/build/objectParser.test.js +55 -0
- package/build/optionalParser.js +69 -10
- package/build/parser.d.ts +4 -0
- package/build/parser.js +3 -1
- package/build/parser.test.js +114 -1
- package/build/parserConsumedSequenceParser.js +66 -7
- package/build/parserContext.d.ts +6 -0
- package/build/parserContext.js +20 -11
- package/build/parserError.d.ts +119 -27
- package/build/parserError.js +16 -8
- package/build/regexpParser.d.ts +2 -0
- package/build/regexpParser.js +101 -0
- package/build/regexpParser.test.d.ts +1 -0
- package/build/regexpParser.test.js +114 -0
- package/build/regularExpression.d.ts +63 -0
- package/build/regularExpression.js +1 -0
- package/build/regularExpressionParser.d.ts +3 -0
- package/build/regularExpressionParser.js +600 -0
- package/build/regularExpressionParser.test.d.ts +1 -0
- package/build/regularExpressionParser.test.js +89 -0
- package/build/separatedArrayParser.js +73 -14
- package/build/separatedNonEmptyArrayParser.js +73 -14
- package/build/sliceBoundedParser.js +62 -5
- package/build/smaliParser.d.ts +7 -7
- package/build/smaliParser.js +185 -268
- package/build/smaliParser.test.js +58 -0
- package/build/stringEscapes.d.ts +5 -0
- package/build/stringEscapes.js +244 -0
- package/build/symbolicExpression.d.ts +29 -0
- package/build/symbolicExpression.js +1 -0
- package/build/symbolicExpressionParser.d.ts +4 -0
- package/build/symbolicExpressionParser.js +123 -0
- package/build/symbolicExpressionParser.test.d.ts +1 -0
- package/build/symbolicExpressionParser.test.js +289 -0
- package/build/terminatedArrayParser.js +113 -38
- package/build/terminatedArrayParser.test.js +4 -2
- package/build/tupleParser.d.ts +7 -15
- package/build/tupleParser.js +1 -0
- package/build/unionParser.d.ts +5 -3
- package/build/unionParser.js +7 -2
- package/build/unionParser.test-d.d.ts +1 -0
- package/build/unionParser.test-d.js +72 -0
- package/build/unionParser.test.js +10 -11
- package/build/zig.d.ts +280 -0
- package/build/zig.js +2 -0
- package/build/zigParser.d.ts +3 -0
- package/build/zigParser.js +1119 -0
- package/build/zigParser.test.d.ts +1 -0
- package/build/zigParser.test.js +1590 -0
- package/build/zigUnparser.d.ts +2 -0
- package/build/zigUnparser.js +460 -0
- package/build/zigUnparser.test.d.ts +1 -0
- package/build/zigUnparser.test.js +24 -0
- package/build/zipParser.js +19 -32
- package/build/zipUnparser.js +19 -7
- package/build/zipUnparser.test.js +1 -1
- package/node_modules-@types/s-expression/index.d.ts +5 -0
- package/package.json +25 -6
- package/src/androidPackageParser.ts +33 -60
- package/src/arbitraryDalvikBytecode.ts +39 -31
- package/src/arbitraryDalvikExecutable.ts +65 -20
- package/src/arbitraryJava.ts +804 -0
- package/src/arbitraryJavaScript.ts +410 -0
- package/src/arbitraryZig.ts +380 -0
- package/src/arrayParser.ts +1 -3
- package/src/backsmali.ts +35 -4
- package/src/bash.ts +127 -0
- package/src/bashParser.test.ts +590 -0
- package/src/bashParser.ts +498 -0
- package/src/dalvikBytecodeParser/addressConversion.ts +496 -0
- package/src/dalvikBytecodeParser/formatParsers.ts +19 -29
- package/src/dalvikBytecodeParser.test-d.ts +310 -0
- package/src/dalvikBytecodeParser.ts +194 -69
- package/src/dalvikBytecodeUnparser/formatUnparsers.ts +27 -26
- package/src/dalvikBytecodeUnparser.test.ts +7 -7
- package/src/dalvikBytecodeUnparser.ts +31 -30
- package/src/dalvikExecutable.test-d.ts +132 -0
- package/src/dalvikExecutable.ts +3 -3
- package/src/dalvikExecutableParser/typedNumbers.ts +11 -0
- package/src/dalvikExecutableParser.test.ts +37 -3
- package/src/dalvikExecutableParser.test.ts.md +163 -2
- package/src/dalvikExecutableParser.test.ts.snap +0 -0
- package/src/dalvikExecutableParser.ts +121 -139
- package/src/dalvikExecutableParserAgainstSmaliParser.test.ts +4 -0
- package/src/dalvikExecutableUnparser/poolScanners.ts +6 -6
- package/src/dalvikExecutableUnparser/sectionUnparsers.ts +38 -14
- package/src/dalvikExecutableUnparser.test.ts +3 -2
- package/src/dalvikExecutableUnparser.ts +4 -4
- package/src/disjunctionParser.test-d.ts +105 -0
- package/src/disjunctionParser.ts +18 -15
- package/src/elementSwitchParser.test-d.ts +74 -0
- package/src/elementSwitchParser.ts +51 -0
- package/src/exactSequenceParser.test-d.ts +43 -0
- package/src/exactSequenceParser.ts +13 -8
- package/src/fetchCid.ts +2 -76
- package/src/index.test.ts +22 -1
- package/src/index.ts +119 -2
- package/src/inputReader.ts +53 -0
- package/src/java.ts +708 -0
- package/src/javaKeyStoreParser.ts +18 -32
- package/src/javaParser.test.ts +1592 -0
- package/src/javaParser.ts +2640 -0
- package/src/javaScript.ts +36 -0
- package/src/javaScriptParser.ts +57 -0
- package/src/javaScriptUnparser.test.ts +37 -0
- package/src/javaScriptUnparser.ts +7 -0
- package/src/javaUnparser.test.ts +37 -0
- package/src/javaUnparser.ts +640 -0
- package/src/jsonParser.ts +6 -27
- package/src/lookaheadParser.ts +2 -6
- package/src/negativeLookaheadParser.ts +1 -3
- package/src/nonEmptyArrayParser.ts +1 -3
- package/src/objectParser.test-d.ts +152 -0
- package/src/objectParser.test.ts +71 -0
- package/src/objectParser.ts +69 -0
- package/src/optionalParser.ts +1 -3
- package/src/parser.test.ts +151 -4
- package/src/parser.ts +11 -1
- package/src/parserConsumedSequenceParser.ts +2 -4
- package/src/parserContext.ts +26 -11
- package/src/parserError.ts +17 -3
- package/src/regexpParser.test.ts +264 -0
- package/src/regexpParser.ts +126 -0
- package/src/regularExpression.ts +24 -0
- package/src/regularExpressionParser.test.ts +102 -0
- package/src/regularExpressionParser.ts +920 -0
- package/src/separatedArrayParser.ts +1 -3
- package/src/separatedNonEmptyArrayParser.ts +1 -3
- package/src/sliceBoundedParser.test.ts +2 -2
- package/src/sliceBoundedParser.ts +15 -19
- package/src/smaliParser.test.ts +64 -0
- package/src/smaliParser.test.ts.md +12 -12
- package/src/smaliParser.test.ts.snap +0 -0
- package/src/smaliParser.ts +246 -534
- package/src/stringEscapes.ts +253 -0
- package/src/symbolicExpression.ts +17 -0
- package/src/symbolicExpressionParser.test.ts +466 -0
- package/src/symbolicExpressionParser.ts +190 -0
- package/src/terminatedArrayParser.test.ts +9 -6
- package/src/terminatedArrayParser.ts +25 -29
- package/src/tupleParser.ts +21 -18
- package/src/unionParser.test-d.ts +105 -0
- package/src/unionParser.test.ts +18 -17
- package/src/unionParser.ts +28 -16
- package/src/zig.ts +411 -0
- package/src/zigParser.test.ts +1693 -0
- package/src/zigParser.ts +1745 -0
- package/src/zigUnparser.test.ts +37 -0
- package/src/zigUnparser.ts +615 -0
- package/src/zipParser.ts +20 -56
- package/src/zipUnparser.test.ts +1 -1
- package/src/zipUnparser.ts +22 -7
- package/tsconfig.json +2 -2
- package/build/exactElementSwitchParser.d.ts +0 -3
- package/src/exactElementSwitchParser.ts +0 -41
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import * as fc from 'fast-check';
|
|
2
|
+
const javaKeywords = new Set([
|
|
3
|
+
'abstract', 'assert', 'boolean', 'break', 'byte', 'case', 'catch', 'char',
|
|
4
|
+
'class', 'const', 'continue', 'default', 'do', 'double', 'else', 'enum',
|
|
5
|
+
'extends', 'final', 'finally', 'float', 'for', 'goto', 'if', 'implements',
|
|
6
|
+
'import', 'instanceof', 'int', 'interface', 'long', 'native', 'new',
|
|
7
|
+
'package', 'private', 'protected', 'public', 'return', 'short', 'static',
|
|
8
|
+
'strictfp', 'super', 'switch', 'synchronized', 'this', 'throw', 'throws',
|
|
9
|
+
'transient', 'try', 'void', 'volatile', 'while', 'true', 'false', 'null',
|
|
10
|
+
'sealed', 'non-sealed', 'record', 'yield', 'var',
|
|
11
|
+
]);
|
|
12
|
+
const arbitraryJavaIdentifier = fc.stringMatching(/^[a-zA-Z_][a-zA-Z0-9_]*$/).filter(id => !javaKeywords.has(id));
|
|
13
|
+
const arbitrarySimpleName = fc.record({
|
|
14
|
+
type: fc.constant('SimpleName'),
|
|
15
|
+
identifier: arbitraryJavaIdentifier,
|
|
16
|
+
});
|
|
17
|
+
const arbitraryName = fc.nat({ max: 2 }).chain(depth => {
|
|
18
|
+
if (depth === 0) {
|
|
19
|
+
return fc.record({
|
|
20
|
+
type: fc.constant('Name'),
|
|
21
|
+
identifier: arbitraryJavaIdentifier,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return arbitraryJavaIdentifier.chain(identifier => {
|
|
25
|
+
const buildQualifier = (d) => {
|
|
26
|
+
if (d === 0) {
|
|
27
|
+
return fc.record({
|
|
28
|
+
type: fc.constant('Name'),
|
|
29
|
+
identifier: arbitraryJavaIdentifier,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return fc.record({
|
|
33
|
+
type: fc.constant('Name'),
|
|
34
|
+
identifier: arbitraryJavaIdentifier,
|
|
35
|
+
qualifier: buildQualifier(d - 1),
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
return fc.record({
|
|
39
|
+
type: fc.constant('Name'),
|
|
40
|
+
identifier: fc.constant(identifier),
|
|
41
|
+
qualifier: buildQualifier(depth - 1),
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
// Types
|
|
46
|
+
const arbitraryPrimitiveType = fc.record({
|
|
47
|
+
type: fc.constant('PrimitiveType'),
|
|
48
|
+
type_: fc.oneof(fc.constant('BOOLEAN'), fc.constant('BYTE'), fc.constant('CHAR'), fc.constant('DOUBLE'), fc.constant('FLOAT'), fc.constant('INT'), fc.constant('LONG'), fc.constant('SHORT')),
|
|
49
|
+
annotations: fc.constant([]),
|
|
50
|
+
});
|
|
51
|
+
const arbitraryVoidType = fc.record({
|
|
52
|
+
type: fc.constant('VoidType'),
|
|
53
|
+
annotations: fc.constant([]),
|
|
54
|
+
});
|
|
55
|
+
const arbitraryAnnotation = fc.record({
|
|
56
|
+
type: fc.constant('MarkerAnnotationExpr'),
|
|
57
|
+
name: arbitraryName,
|
|
58
|
+
});
|
|
59
|
+
const arbitraryClassOrInterfaceType = fc.nat({ max: 1 }).chain(depth => {
|
|
60
|
+
const buildType = (d) => {
|
|
61
|
+
if (d === 0) {
|
|
62
|
+
return fc.record({
|
|
63
|
+
type: fc.constant('ClassOrInterfaceType'),
|
|
64
|
+
name: arbitrarySimpleName,
|
|
65
|
+
annotations: fc.constant([]),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return fc.record({
|
|
69
|
+
type: fc.constant('ClassOrInterfaceType'),
|
|
70
|
+
scope: buildType(d - 1),
|
|
71
|
+
name: arbitrarySimpleName,
|
|
72
|
+
annotations: fc.constant([]),
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
return buildType(depth);
|
|
76
|
+
});
|
|
77
|
+
// ClassOrInterfaceType with optional type arguments (for extends/implements)
|
|
78
|
+
const arbitraryClassOrInterfaceTypeWithTypeArgs = fc.nat({ max: 1 }).chain(depth => {
|
|
79
|
+
const buildType = (d) => {
|
|
80
|
+
const baseFields = {
|
|
81
|
+
type: fc.constant('ClassOrInterfaceType'),
|
|
82
|
+
name: arbitrarySimpleName,
|
|
83
|
+
annotations: fc.constant([]),
|
|
84
|
+
};
|
|
85
|
+
if (d === 0) {
|
|
86
|
+
return fc.oneof(fc.record(baseFields), fc.record({
|
|
87
|
+
...baseFields,
|
|
88
|
+
typeArguments: fc.array(fc.oneof(arbitraryPrimitiveType, fc.record({
|
|
89
|
+
type: fc.constant('ClassOrInterfaceType'),
|
|
90
|
+
name: arbitrarySimpleName,
|
|
91
|
+
annotations: fc.constant([]),
|
|
92
|
+
}), fc.record({
|
|
93
|
+
type: fc.constant('WildcardType'),
|
|
94
|
+
annotations: fc.constant([]),
|
|
95
|
+
})), { minLength: 1, maxLength: 2 }),
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
return fc.record({
|
|
99
|
+
...baseFields,
|
|
100
|
+
scope: buildType(d - 1),
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
return buildType(depth);
|
|
104
|
+
});
|
|
105
|
+
const arbitraryNonArrayType = fc.oneof(arbitraryPrimitiveType, arbitraryClassOrInterfaceType);
|
|
106
|
+
const arbitraryType = fc.oneof({ weight: 3, arbitrary: arbitraryNonArrayType }, {
|
|
107
|
+
weight: 1,
|
|
108
|
+
arbitrary: arbitraryNonArrayType.map(componentType => ({
|
|
109
|
+
type: 'ArrayType',
|
|
110
|
+
componentType,
|
|
111
|
+
origin: 'TYPE',
|
|
112
|
+
annotations: [],
|
|
113
|
+
})),
|
|
114
|
+
});
|
|
115
|
+
const arbitraryReturnType = fc.oneof({ weight: 3, arbitrary: arbitraryType }, { weight: 1, arbitrary: arbitraryVoidType });
|
|
116
|
+
// Leaf expressions (used as operands in compound expressions to avoid precedence issues)
|
|
117
|
+
const arbitraryNameExpr = fc.record({
|
|
118
|
+
type: fc.constant('NameExpr'),
|
|
119
|
+
name: arbitrarySimpleName,
|
|
120
|
+
});
|
|
121
|
+
const arbitraryStringLiteralExpr = fc.record({
|
|
122
|
+
type: fc.constant('StringLiteralExpr'),
|
|
123
|
+
value: fc.oneof(fc.stringMatching(/^[a-zA-Z0-9 ]*$/), fc.constantFrom('hello\nworld', 'tab\there', 'back\\slash', 'quote\ttab\nnewline')),
|
|
124
|
+
});
|
|
125
|
+
const arbitraryIntegerLiteralExpr = fc.record({
|
|
126
|
+
type: fc.constant('IntegerLiteralExpr'),
|
|
127
|
+
value: fc.nat({ max: 999 }).map(n => String(n)),
|
|
128
|
+
});
|
|
129
|
+
const arbitraryNullLiteralExpr = fc.record({
|
|
130
|
+
type: fc.constant('NullLiteralExpr'),
|
|
131
|
+
});
|
|
132
|
+
const arbitraryBooleanLiteralExpr = fc.record({
|
|
133
|
+
type: fc.constant('BooleanLiteralExpr'),
|
|
134
|
+
value: fc.boolean(),
|
|
135
|
+
});
|
|
136
|
+
const arbitraryThisExpr = fc.record({
|
|
137
|
+
type: fc.constant('ThisExpr'),
|
|
138
|
+
});
|
|
139
|
+
const arbitraryLeafExpression = fc.oneof(arbitraryNameExpr, arbitraryStringLiteralExpr, arbitraryIntegerLiteralExpr, arbitraryNullLiteralExpr, arbitraryBooleanLiteralExpr, arbitraryThisExpr);
|
|
140
|
+
// Compound expressions (only use leaf operands)
|
|
141
|
+
const arbitraryMethodCallExpr = fc.oneof(
|
|
142
|
+
// Without scope
|
|
143
|
+
fc.record({
|
|
144
|
+
type: fc.constant('MethodCallExpr'),
|
|
145
|
+
name: arbitrarySimpleName,
|
|
146
|
+
arguments: fc.array(arbitraryLeafExpression, { maxLength: 2 }),
|
|
147
|
+
}),
|
|
148
|
+
// With scope
|
|
149
|
+
fc.record({
|
|
150
|
+
type: fc.constant('MethodCallExpr'),
|
|
151
|
+
scope: arbitraryLeafExpression,
|
|
152
|
+
name: arbitrarySimpleName,
|
|
153
|
+
arguments: fc.array(arbitraryLeafExpression, { maxLength: 2 }),
|
|
154
|
+
}));
|
|
155
|
+
const arbitraryFieldAccessExpr = fc.record({
|
|
156
|
+
type: fc.constant('FieldAccessExpr'),
|
|
157
|
+
scope: arbitraryLeafExpression,
|
|
158
|
+
name: arbitrarySimpleName,
|
|
159
|
+
});
|
|
160
|
+
const arbitraryEnclosedExpr = fc.record({
|
|
161
|
+
type: fc.constant('EnclosedExpr'),
|
|
162
|
+
inner: arbitraryLeafExpression,
|
|
163
|
+
});
|
|
164
|
+
const arbitraryArrayAccessExpr = fc.record({
|
|
165
|
+
type: fc.constant('ArrayAccessExpr'),
|
|
166
|
+
name: arbitraryLeafExpression,
|
|
167
|
+
index: arbitraryLeafExpression,
|
|
168
|
+
});
|
|
169
|
+
const arbitraryObjectCreationExpr = fc.oneof(fc.record({
|
|
170
|
+
type: fc.constant('ObjectCreationExpr'),
|
|
171
|
+
type_: arbitraryClassOrInterfaceType,
|
|
172
|
+
arguments: fc.array(arbitraryLeafExpression, { maxLength: 2 }),
|
|
173
|
+
}),
|
|
174
|
+
// With diamond operator (empty typeArguments)
|
|
175
|
+
fc.record({
|
|
176
|
+
type: fc.constant('ObjectCreationExpr'),
|
|
177
|
+
type_: arbitraryClassOrInterfaceType.map(t => ({
|
|
178
|
+
...t,
|
|
179
|
+
typeArguments: [],
|
|
180
|
+
})),
|
|
181
|
+
arguments: fc.array(arbitraryLeafExpression, { maxLength: 2 }),
|
|
182
|
+
}));
|
|
183
|
+
const arbitraryPrimaryExpression = fc.oneof(arbitraryLeafExpression, arbitraryMethodCallExpr, arbitraryFieldAccessExpr, arbitraryEnclosedExpr, arbitraryArrayAccessExpr, arbitraryObjectCreationExpr);
|
|
184
|
+
const arbitraryBinaryOperator = fc.oneof(fc.constant('PLUS'), fc.constant('MINUS'), fc.constant('MULTIPLY'), fc.constant('DIVIDE'), fc.constant('REMAINDER'), fc.constant('LESS'), fc.constant('GREATER'), fc.constant('LESS_EQUALS'), fc.constant('GREATER_EQUALS'), fc.constant('EQUALS'), fc.constant('NOT_EQUALS'), fc.constant('AND'), fc.constant('OR'));
|
|
185
|
+
const arbitraryBinaryExpr = fc.record({
|
|
186
|
+
type: fc.constant('BinaryExpr'),
|
|
187
|
+
left: arbitraryLeafExpression,
|
|
188
|
+
right: arbitraryLeafExpression,
|
|
189
|
+
operator: arbitraryBinaryOperator,
|
|
190
|
+
});
|
|
191
|
+
// UnaryExpr in parser output has NO prefix field - operator encodes prefix/postfix
|
|
192
|
+
const arbitraryUnaryExpr = fc.record({
|
|
193
|
+
type: fc.constant('UnaryExpr'),
|
|
194
|
+
operator: fc.oneof(fc.constant('PREFIX_INCREMENT'), fc.constant('PREFIX_DECREMENT'), fc.constant('POSTFIX_INCREMENT'), fc.constant('POSTFIX_DECREMENT'), fc.constant('MINUS'), fc.constant('PLUS'), fc.constant('LOGICAL_COMPLEMENT')),
|
|
195
|
+
expression: arbitraryLeafExpression,
|
|
196
|
+
});
|
|
197
|
+
const arbitraryAssignOperator = fc.oneof(fc.constant('ASSIGN'), fc.constant('PLUS'), fc.constant('MINUS'), fc.constant('MULTIPLY'), fc.constant('DIVIDE'));
|
|
198
|
+
const arbitraryAssignExpr = fc.record({
|
|
199
|
+
type: fc.constant('AssignExpr'),
|
|
200
|
+
target: arbitraryNameExpr,
|
|
201
|
+
value: arbitraryLeafExpression,
|
|
202
|
+
operator: arbitraryAssignOperator,
|
|
203
|
+
});
|
|
204
|
+
const arbitraryConditionalExpr = fc.record({
|
|
205
|
+
type: fc.constant('ConditionalExpr'),
|
|
206
|
+
condition: arbitraryLeafExpression,
|
|
207
|
+
thenExpr: arbitraryLeafExpression,
|
|
208
|
+
elseExpr: arbitraryLeafExpression,
|
|
209
|
+
});
|
|
210
|
+
const arbitraryCastExpr = fc.record({
|
|
211
|
+
type: fc.constant('CastExpr'),
|
|
212
|
+
type_: arbitraryType,
|
|
213
|
+
expression: arbitraryPrimaryExpression,
|
|
214
|
+
});
|
|
215
|
+
const arbitraryInstanceOfExpr = fc.record({
|
|
216
|
+
type: fc.constant('InstanceOfExpr'),
|
|
217
|
+
expression: arbitraryLeafExpression,
|
|
218
|
+
type_: fc.oneof(arbitraryClassOrInterfaceType, arbitraryNonArrayType.map(componentType => ({
|
|
219
|
+
type: 'ArrayType',
|
|
220
|
+
componentType,
|
|
221
|
+
origin: 'TYPE',
|
|
222
|
+
annotations: [],
|
|
223
|
+
}))),
|
|
224
|
+
});
|
|
225
|
+
// Lambda expressions
|
|
226
|
+
const arbitraryLambdaExpr = fc.oneof(
|
|
227
|
+
// With parenthesized params
|
|
228
|
+
fc.record({
|
|
229
|
+
type: fc.constant('LambdaExpr'),
|
|
230
|
+
parameters: fc.array(fc.record({
|
|
231
|
+
type: fc.constant('Parameter'),
|
|
232
|
+
annotations: fc.constant([]),
|
|
233
|
+
modifiers: fc.constant([]),
|
|
234
|
+
isVarArgs: fc.constant(false),
|
|
235
|
+
varArgsAnnotations: fc.constant([]),
|
|
236
|
+
name: arbitrarySimpleName,
|
|
237
|
+
type_: fc.constant({ type: 'UnknownType', annotations: [] }),
|
|
238
|
+
}), { maxLength: 2 }),
|
|
239
|
+
body: fc.oneof(
|
|
240
|
+
// Expression body (wrapped in ExpressionStmt)
|
|
241
|
+
arbitraryLeafExpression.map(expr => ({
|
|
242
|
+
type: 'ExpressionStmt',
|
|
243
|
+
expression: expr,
|
|
244
|
+
})),
|
|
245
|
+
// Block body
|
|
246
|
+
fc.constant({ type: 'BlockStmt', statements: [] })),
|
|
247
|
+
isEnclosingParameters: fc.constant(true),
|
|
248
|
+
}),
|
|
249
|
+
// Single unparenthesized param
|
|
250
|
+
fc.record({
|
|
251
|
+
type: fc.constant('LambdaExpr'),
|
|
252
|
+
parameters: arbitrarySimpleName.map(name => ([{
|
|
253
|
+
type: 'Parameter',
|
|
254
|
+
annotations: [],
|
|
255
|
+
modifiers: [],
|
|
256
|
+
isVarArgs: false,
|
|
257
|
+
varArgsAnnotations: [],
|
|
258
|
+
name,
|
|
259
|
+
type_: { type: 'UnknownType', annotations: [] },
|
|
260
|
+
}])),
|
|
261
|
+
body: fc.oneof(arbitraryLeafExpression.map(expr => ({
|
|
262
|
+
type: 'ExpressionStmt',
|
|
263
|
+
expression: expr,
|
|
264
|
+
})), fc.constant({ type: 'BlockStmt', statements: [] })),
|
|
265
|
+
isEnclosingParameters: fc.constant(false),
|
|
266
|
+
}));
|
|
267
|
+
const arbitraryExpression = fc.oneof({ weight: 4, arbitrary: arbitraryLeafExpression }, { weight: 1, arbitrary: arbitraryBinaryExpr }, { weight: 1, arbitrary: arbitraryUnaryExpr }, { weight: 1, arbitrary: arbitraryAssignExpr }, { weight: 1, arbitrary: arbitraryConditionalExpr }, { weight: 1, arbitrary: arbitraryCastExpr }, { weight: 1, arbitrary: arbitraryEnclosedExpr }, { weight: 1, arbitrary: arbitraryMethodCallExpr }, { weight: 1, arbitrary: arbitraryFieldAccessExpr }, { weight: 1, arbitrary: arbitraryObjectCreationExpr }, { weight: 1, arbitrary: arbitraryArrayAccessExpr }, { weight: 1, arbitrary: arbitraryInstanceOfExpr }, { weight: 1, arbitrary: arbitraryLambdaExpr });
|
|
268
|
+
// Variable declarations
|
|
269
|
+
const arbitraryVariableDeclarator = fc.record({
|
|
270
|
+
type: fc.constant('VariableDeclarator'),
|
|
271
|
+
name: arbitrarySimpleName,
|
|
272
|
+
type_: arbitraryType,
|
|
273
|
+
}).chain(base => fc.oneof(fc.constant(base), arbitraryLeafExpression.map(init => ({
|
|
274
|
+
...base,
|
|
275
|
+
initializer: init,
|
|
276
|
+
}))));
|
|
277
|
+
const arbitraryVariableDeclarationExpr = arbitraryType.chain(type_ => fc.record({
|
|
278
|
+
type: fc.constant('VariableDeclarationExpr'),
|
|
279
|
+
modifiers: fc.constant([]),
|
|
280
|
+
annotations: fc.constant([]),
|
|
281
|
+
variables: fc.array(fc.record({
|
|
282
|
+
type: fc.constant('VariableDeclarator'),
|
|
283
|
+
name: arbitrarySimpleName,
|
|
284
|
+
type_: fc.constant(type_),
|
|
285
|
+
}).chain(base => fc.oneof(fc.constant(base), arbitraryLeafExpression.map(init => ({
|
|
286
|
+
...base,
|
|
287
|
+
initializer: init,
|
|
288
|
+
})))), { minLength: 1, maxLength: 2 }),
|
|
289
|
+
}));
|
|
290
|
+
// Statements
|
|
291
|
+
const arbitraryBlockStmt = fc.record({
|
|
292
|
+
type: fc.constant('BlockStmt'),
|
|
293
|
+
statements: fc.constant([]),
|
|
294
|
+
});
|
|
295
|
+
const arbitraryExpressionStmt = fc.record({
|
|
296
|
+
type: fc.constant('ExpressionStmt'),
|
|
297
|
+
expression: arbitraryExpression,
|
|
298
|
+
});
|
|
299
|
+
const arbitraryReturnStmt = fc.oneof(fc.constant({ type: 'ReturnStmt' }), fc.record({
|
|
300
|
+
type: fc.constant('ReturnStmt'),
|
|
301
|
+
expression: arbitraryExpression,
|
|
302
|
+
}));
|
|
303
|
+
const arbitraryThrowStmt = fc.record({
|
|
304
|
+
type: fc.constant('ThrowStmt'),
|
|
305
|
+
expression: arbitraryExpression,
|
|
306
|
+
});
|
|
307
|
+
const arbitraryIfStmt = fc.oneof(fc.record({
|
|
308
|
+
type: fc.constant('IfStmt'),
|
|
309
|
+
condition: arbitraryExpression,
|
|
310
|
+
thenStmt: arbitraryBlockStmt,
|
|
311
|
+
}), fc.record({
|
|
312
|
+
type: fc.constant('IfStmt'),
|
|
313
|
+
condition: arbitraryExpression,
|
|
314
|
+
thenStmt: arbitraryBlockStmt,
|
|
315
|
+
elseStmt: arbitraryBlockStmt,
|
|
316
|
+
}));
|
|
317
|
+
const arbitraryForStmt = fc.oneof(
|
|
318
|
+
// Empty for
|
|
319
|
+
fc.record({
|
|
320
|
+
type: fc.constant('ForStmt'),
|
|
321
|
+
initialization: fc.constant([]),
|
|
322
|
+
update: fc.constant([]),
|
|
323
|
+
body: arbitraryBlockStmt,
|
|
324
|
+
}),
|
|
325
|
+
// For with init and compare
|
|
326
|
+
fc.record({
|
|
327
|
+
type: fc.constant('ForStmt'),
|
|
328
|
+
initialization: fc.array(arbitraryVariableDeclarationExpr, { minLength: 1, maxLength: 1 }),
|
|
329
|
+
compare: arbitraryExpression,
|
|
330
|
+
update: fc.array(arbitraryExpression, { maxLength: 2 }),
|
|
331
|
+
body: arbitraryBlockStmt,
|
|
332
|
+
}));
|
|
333
|
+
const arbitraryForEachStmt = fc.record({
|
|
334
|
+
type: fc.constant('ForEachStmt'),
|
|
335
|
+
variable: arbitraryVariableDeclarationExpr,
|
|
336
|
+
iterable: arbitraryExpression,
|
|
337
|
+
body: arbitraryBlockStmt,
|
|
338
|
+
});
|
|
339
|
+
const arbitraryParameter = fc.record({
|
|
340
|
+
type: fc.constant('Parameter'),
|
|
341
|
+
modifiers: fc.constant([]),
|
|
342
|
+
annotations: fc.constant([]),
|
|
343
|
+
type_: arbitraryType,
|
|
344
|
+
isVarArgs: fc.constant(false),
|
|
345
|
+
varArgsAnnotations: fc.constant([]),
|
|
346
|
+
name: arbitrarySimpleName,
|
|
347
|
+
});
|
|
348
|
+
const arbitraryCatchClause = fc.record({
|
|
349
|
+
type: fc.constant('CatchClause'),
|
|
350
|
+
parameter: arbitraryParameter,
|
|
351
|
+
body: fc.record({
|
|
352
|
+
type: fc.constant('BlockStmt'),
|
|
353
|
+
statements: fc.constant([]),
|
|
354
|
+
}),
|
|
355
|
+
});
|
|
356
|
+
const arbitraryTryStmt = fc.oneof(
|
|
357
|
+
// try-catch
|
|
358
|
+
fc.record({
|
|
359
|
+
type: fc.constant('TryStmt'),
|
|
360
|
+
resources: fc.constant([]),
|
|
361
|
+
tryBlock: fc.record({
|
|
362
|
+
type: fc.constant('BlockStmt'),
|
|
363
|
+
statements: fc.constant([]),
|
|
364
|
+
}),
|
|
365
|
+
catchClauses: fc.array(arbitraryCatchClause, { minLength: 1, maxLength: 2 }),
|
|
366
|
+
}),
|
|
367
|
+
// try-catch-finally
|
|
368
|
+
fc.record({
|
|
369
|
+
type: fc.constant('TryStmt'),
|
|
370
|
+
resources: fc.constant([]),
|
|
371
|
+
tryBlock: fc.record({
|
|
372
|
+
type: fc.constant('BlockStmt'),
|
|
373
|
+
statements: fc.constant([]),
|
|
374
|
+
}),
|
|
375
|
+
catchClauses: fc.array(arbitraryCatchClause, { maxLength: 1 }),
|
|
376
|
+
finallyBlock: fc.record({
|
|
377
|
+
type: fc.constant('BlockStmt'),
|
|
378
|
+
statements: fc.constant([]),
|
|
379
|
+
}),
|
|
380
|
+
}),
|
|
381
|
+
// try-with-resources
|
|
382
|
+
fc.record({
|
|
383
|
+
type: fc.constant('TryStmt'),
|
|
384
|
+
resources: fc.array(arbitraryVariableDeclarationExpr, { minLength: 1, maxLength: 1 }),
|
|
385
|
+
tryBlock: fc.record({
|
|
386
|
+
type: fc.constant('BlockStmt'),
|
|
387
|
+
statements: fc.constant([]),
|
|
388
|
+
}),
|
|
389
|
+
catchClauses: fc.constant([]),
|
|
390
|
+
}));
|
|
391
|
+
const arbitrarySwitchEntry = fc.oneof(
|
|
392
|
+
// case
|
|
393
|
+
fc.record({
|
|
394
|
+
type: fc.constant('SwitchEntry'),
|
|
395
|
+
isDefault: fc.constant(false),
|
|
396
|
+
labels: fc.array(arbitraryExpression, { minLength: 1, maxLength: 1 }),
|
|
397
|
+
statements: fc.constant([]),
|
|
398
|
+
type_: fc.constant('STATEMENT_GROUP'),
|
|
399
|
+
}),
|
|
400
|
+
// default
|
|
401
|
+
fc.record({
|
|
402
|
+
type: fc.constant('SwitchEntry'),
|
|
403
|
+
isDefault: fc.constant(true),
|
|
404
|
+
labels: fc.constant([]),
|
|
405
|
+
statements: fc.constant([]),
|
|
406
|
+
type_: fc.constant('STATEMENT_GROUP'),
|
|
407
|
+
}));
|
|
408
|
+
const arbitrarySwitchStmt = fc.record({
|
|
409
|
+
type: fc.constant('SwitchStmt'),
|
|
410
|
+
selector: arbitraryExpression,
|
|
411
|
+
entries: fc.array(arbitrarySwitchEntry, { maxLength: 3 }),
|
|
412
|
+
});
|
|
413
|
+
const arbitraryExplicitConstructorInvocationStmt = fc.record({
|
|
414
|
+
type: fc.constant('ExplicitConstructorInvocationStmt'),
|
|
415
|
+
isThis: fc.boolean(),
|
|
416
|
+
arguments: fc.array(arbitraryLeafExpression, { maxLength: 2 }),
|
|
417
|
+
});
|
|
418
|
+
const arbitraryLocalVarDeclStmt = fc.record({
|
|
419
|
+
type: fc.constant('ExpressionStmt'),
|
|
420
|
+
expression: arbitraryVariableDeclarationExpr,
|
|
421
|
+
});
|
|
422
|
+
const arbitraryStatement = fc.oneof({ weight: 2, arbitrary: arbitraryBlockStmt }, { weight: 2, arbitrary: arbitraryExpressionStmt }, { weight: 2, arbitrary: arbitraryReturnStmt }, { weight: 1, arbitrary: arbitraryThrowStmt }, { weight: 1, arbitrary: arbitraryIfStmt }, { weight: 1, arbitrary: arbitraryForStmt }, { weight: 1, arbitrary: arbitraryForEachStmt }, { weight: 1, arbitrary: arbitraryTryStmt }, { weight: 1, arbitrary: arbitrarySwitchStmt }, { weight: 1, arbitrary: arbitraryExplicitConstructorInvocationStmt }, { weight: 1, arbitrary: arbitraryLocalVarDeclStmt });
|
|
423
|
+
// Body declarations
|
|
424
|
+
const arbitraryModifier = fc.record({
|
|
425
|
+
type: fc.constant('Modifier'),
|
|
426
|
+
keyword: fc.oneof(fc.constant('PUBLIC'), fc.constant('PROTECTED'), fc.constant('PRIVATE'), fc.constant('STATIC'), fc.constant('FINAL'), fc.constant('ABSTRACT')),
|
|
427
|
+
});
|
|
428
|
+
const arbitraryFieldDeclaration = arbitraryType.chain(type_ => fc.record({
|
|
429
|
+
type: fc.constant('FieldDeclaration'),
|
|
430
|
+
modifiers: fc.array(arbitraryModifier, { maxLength: 2 }),
|
|
431
|
+
annotations: fc.array(arbitraryAnnotation, { maxLength: 1 }),
|
|
432
|
+
variables: fc.array(fc.record({
|
|
433
|
+
type: fc.constant('VariableDeclarator'),
|
|
434
|
+
name: arbitrarySimpleName,
|
|
435
|
+
type_: fc.constant(type_),
|
|
436
|
+
}).chain(base => fc.oneof(fc.constant(base), arbitraryLeafExpression.map(init => ({
|
|
437
|
+
...base,
|
|
438
|
+
initializer: init,
|
|
439
|
+
})))), { minLength: 1, maxLength: 2 }),
|
|
440
|
+
}));
|
|
441
|
+
const arbitraryMethodDeclaration = fc.oneof(
|
|
442
|
+
// Method with body
|
|
443
|
+
fc.record({
|
|
444
|
+
type: fc.constant('MethodDeclaration'),
|
|
445
|
+
modifiers: fc.array(arbitraryModifier, { maxLength: 2 }),
|
|
446
|
+
annotations: fc.array(arbitraryAnnotation, { maxLength: 1 }),
|
|
447
|
+
typeParameters: fc.constant([]),
|
|
448
|
+
type_: arbitraryReturnType,
|
|
449
|
+
name: arbitrarySimpleName,
|
|
450
|
+
parameters: fc.array(arbitraryParameter, { maxLength: 2 }),
|
|
451
|
+
thrownExceptions: fc.constant([]),
|
|
452
|
+
body: fc.record({
|
|
453
|
+
type: fc.constant('BlockStmt'),
|
|
454
|
+
statements: fc.array(arbitraryStatement, { maxLength: 2 }),
|
|
455
|
+
}),
|
|
456
|
+
}),
|
|
457
|
+
// Abstract method (no body)
|
|
458
|
+
fc.record({
|
|
459
|
+
type: fc.constant('MethodDeclaration'),
|
|
460
|
+
modifiers: fc.array(arbitraryModifier, { maxLength: 2 }),
|
|
461
|
+
annotations: fc.array(arbitraryAnnotation, { maxLength: 1 }),
|
|
462
|
+
typeParameters: fc.constant([]),
|
|
463
|
+
type_: arbitraryReturnType,
|
|
464
|
+
name: arbitrarySimpleName,
|
|
465
|
+
parameters: fc.array(arbitraryParameter, { maxLength: 2 }),
|
|
466
|
+
thrownExceptions: fc.constant([]),
|
|
467
|
+
}));
|
|
468
|
+
const arbitraryConstructorDeclaration = fc.record({
|
|
469
|
+
type: fc.constant('ConstructorDeclaration'),
|
|
470
|
+
modifiers: fc.array(arbitraryModifier, { maxLength: 1 }),
|
|
471
|
+
annotations: fc.constant([]),
|
|
472
|
+
typeParameters: fc.constant([]),
|
|
473
|
+
name: arbitrarySimpleName,
|
|
474
|
+
parameters: fc.array(arbitraryParameter, { maxLength: 2 }),
|
|
475
|
+
thrownExceptions: fc.constant([]),
|
|
476
|
+
body: fc.record({
|
|
477
|
+
type: fc.constant('BlockStmt'),
|
|
478
|
+
statements: fc.array(arbitraryStatement, { maxLength: 2 }),
|
|
479
|
+
}),
|
|
480
|
+
});
|
|
481
|
+
const arbitraryBodyDeclaration = fc.oneof({ weight: 2, arbitrary: arbitraryFieldDeclaration }, { weight: 2, arbitrary: arbitraryMethodDeclaration }, { weight: 1, arbitrary: arbitraryConstructorDeclaration });
|
|
482
|
+
// Type declarations
|
|
483
|
+
const arbitraryEnumDeclaration = fc.record({
|
|
484
|
+
type: fc.constant('EnumDeclaration'),
|
|
485
|
+
modifiers: fc.array(arbitraryModifier, { maxLength: 2 }),
|
|
486
|
+
annotations: fc.array(arbitraryAnnotation, { maxLength: 1 }),
|
|
487
|
+
name: arbitrarySimpleName,
|
|
488
|
+
implementedTypes: fc.constant([]),
|
|
489
|
+
entries: fc.constant([]),
|
|
490
|
+
members: fc.constant([]),
|
|
491
|
+
});
|
|
492
|
+
const arbitraryClassOrInterfaceDeclaration = fc.boolean().chain(isInterface => fc.record({
|
|
493
|
+
type: fc.constant('ClassOrInterfaceDeclaration'),
|
|
494
|
+
modifiers: fc.array(arbitraryModifier, { maxLength: 2 }),
|
|
495
|
+
annotations: fc.array(arbitraryAnnotation, { maxLength: 1 }),
|
|
496
|
+
name: arbitrarySimpleName,
|
|
497
|
+
isInterface: fc.constant(isInterface),
|
|
498
|
+
typeParameters: fc.oneof(fc.constant([]), fc.array(fc.record({
|
|
499
|
+
type: fc.constant('TypeParameter'),
|
|
500
|
+
annotations: fc.constant([]),
|
|
501
|
+
name: arbitrarySimpleName,
|
|
502
|
+
typeBound: fc.constant([]),
|
|
503
|
+
}), { minLength: 1, maxLength: 2 })),
|
|
504
|
+
extendedTypes: fc.oneof(fc.constant([]), fc.array(arbitraryClassOrInterfaceTypeWithTypeArgs, { minLength: 1, maxLength: 1 })),
|
|
505
|
+
// Interfaces always have implementedTypes: [] (parser outputs empty array for interfaces)
|
|
506
|
+
implementedTypes: isInterface
|
|
507
|
+
? fc.constant([])
|
|
508
|
+
: fc.oneof(fc.constant([]), fc.array(arbitraryClassOrInterfaceTypeWithTypeArgs, { minLength: 1, maxLength: 2 })),
|
|
509
|
+
permittedTypes: fc.constant([]),
|
|
510
|
+
members: fc.array(arbitraryBodyDeclaration, { maxLength: 3 }),
|
|
511
|
+
}));
|
|
512
|
+
const arbitraryTypeDeclaration = fc.oneof({ weight: 3, arbitrary: arbitraryClassOrInterfaceDeclaration }, { weight: 1, arbitrary: arbitraryEnumDeclaration });
|
|
513
|
+
// Import declaration
|
|
514
|
+
const arbitraryImportDeclaration = fc.record({
|
|
515
|
+
type: fc.constant('ImportDeclaration'),
|
|
516
|
+
isStatic: fc.boolean(),
|
|
517
|
+
isAsterisk: fc.boolean(),
|
|
518
|
+
name: arbitraryName,
|
|
519
|
+
});
|
|
520
|
+
// Package declaration
|
|
521
|
+
const arbitraryPackageDeclaration = fc.record({
|
|
522
|
+
type: fc.constant('PackageDeclaration'),
|
|
523
|
+
annotations: fc.array(arbitraryAnnotation, { maxLength: 1 }),
|
|
524
|
+
name: arbitraryName,
|
|
525
|
+
});
|
|
526
|
+
// Compilation unit
|
|
527
|
+
export const arbitraryJavaCompilationUnit = fc.record({
|
|
528
|
+
type: fc.constant('CompilationUnit'),
|
|
529
|
+
packageDeclaration: fc.option(arbitraryPackageDeclaration, { nil: undefined }),
|
|
530
|
+
imports: fc.array(arbitraryImportDeclaration, { maxLength: 2 }),
|
|
531
|
+
types: fc.array(arbitraryTypeDeclaration, { minLength: 1, maxLength: 2 }),
|
|
532
|
+
});
|