@cparra/apex-reflection 4.0.0-beta.4 → 4.0.0-beta.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/README.md +26 -28
- package/dist/index.d.mts +5 -0
- package/dist/node.mjs +0 -1
- package/dist/node.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,13 +11,12 @@ npm i @cparra/apex-reflection
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
This library exposes a single function that handles parsing the body of an Apex top level type (class, interface, or
|
|
14
|
-
enum)
|
|
15
|
-
and returns the result.
|
|
14
|
+
enum) and returns the result.
|
|
16
15
|
|
|
17
16
|
```typescript
|
|
18
|
-
import {reflect} from
|
|
17
|
+
import { reflect } from "@cparra/apex-reflection";
|
|
19
18
|
|
|
20
|
-
const classBody =
|
|
19
|
+
const classBody = "public with sharing class ExampleClass {}";
|
|
21
20
|
const response = reflect(classBody);
|
|
22
21
|
```
|
|
23
22
|
|
|
@@ -34,23 +33,33 @@ const response = reflect(rawFile.toString());
|
|
|
34
33
|
```
|
|
35
34
|
|
|
36
35
|
The `reflect` function returns a `ReflectionResult` which contains either the results of the parsed `Type`
|
|
37
|
-
(which will either be a `ClassMirror`, an `InterfaceMirror
|
|
36
|
+
(which will either be a `ClassMirror`, an `InterfaceMirror`, or an `EnumMirror`) or a `ParsingError` if the passed in
|
|
38
37
|
body was not parsed successfully, with a message indicating where the error occurred.
|
|
39
38
|
|
|
40
39
|
## Contributing
|
|
41
40
|
|
|
42
41
|
Even though this library is exposed as a Node.js library, the project's source code is written in Dart. The source can
|
|
43
|
-
be found in the `lib/src` directory.
|
|
42
|
+
be found in the `lib/src` directory of the repository.
|
|
43
|
+
|
|
44
|
+
This package ships the Dart code compiled to a WebAssembly module (`dist/node.wasm`) together with its JS loader
|
|
45
|
+
(`dist/node.mjs`), loaded lazily by the thin TypeScript wrapper in `index.mts`. Node.js 22 or newer is required (the
|
|
46
|
+
module uses WasmGC). To rebuild the module after changing the Dart source, run from the repository root:
|
|
47
|
+
|
|
48
|
+
```shell
|
|
49
|
+
dart compile wasm lib/src/node/node.dart -o js/node.wasm
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`npm run build` compiles the TypeScript wrapper and copies the wasm module and its loader into `dist/`.
|
|
44
53
|
|
|
45
54
|
### Tests
|
|
46
55
|
|
|
47
|
-
Both the Dart source code and the
|
|
56
|
+
Both the Dart source code and the packaged WebAssembly module must be tested.
|
|
48
57
|
|
|
49
|
-
The Dart tests live in the `test` directory. The Dart source code must have unit tests testing each
|
|
50
|
-
as well as end-to-end tests that verify the overall parsing functionality.
|
|
58
|
+
The Dart tests live in the repository's `test` directory. The Dart source code must have unit tests testing each
|
|
59
|
+
individual Dart file as well as end-to-end tests that verify the overall parsing functionality.
|
|
51
60
|
|
|
52
|
-
The JS tests live in `
|
|
53
|
-
|
|
61
|
+
The JS tests live in `__tests__`. These are end-to-end tests that run against the built package (`dist/`), so they
|
|
62
|
+
also guard against publishing a stale WebAssembly artifact. Run them with `npm test`.
|
|
54
63
|
|
|
55
64
|
### JSON serialization
|
|
56
65
|
|
|
@@ -62,27 +71,16 @@ helps automatically create the round-trip code for serialization and de-serializ
|
|
|
62
71
|
|
|
63
72
|
When changing any of the model classes with serialization support, to re-build the serialization code run
|
|
64
73
|
|
|
65
|
-
```
|
|
66
|
-
pub run build_runner build
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Parsing
|
|
70
|
-
|
|
71
|
-
The parsing algorithm relies on using ANTLR4 and its Dart target. Currently `dart2js` is not able to transpile the
|
|
72
|
-
source from the `antrl4` library hosted in pub.dev, so we rely on a local copy that fixes the transpilation issues,
|
|
73
|
-
which lives in `lib/antrl4-4.9.2`.
|
|
74
|
-
|
|
75
|
-
To generate the Antlr4 Apex output run:
|
|
76
|
-
|
|
77
74
|
```shell
|
|
78
|
-
|
|
75
|
+
dart run build_runner build
|
|
79
76
|
```
|
|
80
77
|
|
|
81
|
-
|
|
78
|
+
### Parsing
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
Parsing is implemented with handwritten [petitparser](https://pub.dev/packages/petitparser) grammars.
|
|
81
|
+
The Apex grammar parses only the declaration structure needed for reflection (bodies are skipped as
|
|
82
|
+
balanced blocks), and the Apexdoc grammar is composed into it, so doc comments are parsed in the same single pass. See
|
|
83
|
+
the repository README for details.
|
|
86
84
|
|
|
87
85
|
## Typescript
|
|
88
86
|
|
package/dist/index.d.mts
CHANGED
|
@@ -29,6 +29,11 @@ export interface DocComment {
|
|
|
29
29
|
descriptionLines: string[];
|
|
30
30
|
description: string;
|
|
31
31
|
error?: string;
|
|
32
|
+
/**
|
|
33
|
+
* True when the comment contains an `{@hidden}` inline tag, meaning the
|
|
34
|
+
* documented element should be excluded from generated documentation.
|
|
35
|
+
*/
|
|
36
|
+
hidden?: boolean;
|
|
32
37
|
}
|
|
33
38
|
export interface AnnotationElementValue {
|
|
34
39
|
key: string;
|
package/dist/node.mjs
CHANGED
package/dist/node.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED