Allow union types to have additional fields, support required fields. (#43)

- Union types can now have additional fields beyond just `type` and `value`. These can be passed to each specialized constructor along with the value.
- Adds support for required fields in schemas, which essentially just makes the parameters for these fields in the constructors be required. These are not intended to be widely used, but there are certain things which are truly required.
- Uses these features to add a required `id` field to request types, and `requestId` field to response types.
- These will be used to support multiple ongoing requests and remove hacks with global variables for cfe/analyzer internals in the future.
- Also dropped the special `_dartWrapperToJson` function - afaik this was never necessary (but please let me know if that is wrong).

If you would like, I could separate out the support here from adding the actual required fields.

## Risks

This makes requests non-hermetic, because of the `id` field. This is always only in the _outer_ request type though. We can still do caching based on the _inner_ request type, which I think should work out fine.

Note that having the IDs on the outer types means they are not generally visible to the user APIs which is good.
9 files changed
tree: b881262e48d211c5e821549cf9759515abf531de
  1. .github/
  2. introspection_goldens/
  3. pkgs/
  4. schemas/
  5. tool/
  6. .gitignore
  7. CONTRIBUTING.md
  8. LICENSE
  9. mono_repo.yaml
  10. pubspec.yaml
  11. README.md
README.md

Overview

This repository is home to various macro related Dart packages.

Packages

PackageDescriptionVersion
_analyzer_macrosMacro support for the analyzer.
_cfe_macrosMacro support for the CFE.
_macro_builderBuilds macros.
_macro_clientConnects user macro code to a macro host.
_macro_hostHosts macros.
_macro_runnerRuns macros.
_macro_serverServes a macro_service.
_test_macrosSome test macros.
dart_modelData model for information about Dart code, queries about Dart code and augmentations to Dart code. Serializable with a versioned JSON schema for use by macros, generators and other tools.pub package
macroFor implementing a macro.pub package
macro_serviceMacro communication with the macro host.pub package
generate_dart_model

Publishing automation

For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

For additional information about contributing, see our contributing page.