Граф коммитов

2356 Коммитов

Автор SHA1 Сообщение Дата
Timothee Guerin 1733d2a969
Fix show diagnostics with no target in the playground (#399) 2022-04-01 14:02:24 -07:00
Nick Guerrera d635c8535f
Prepare cadl publish (#391) 2022-03-31 12:27:52 -05:00
Timothee Guerin 25c9d20f99
Fix formatting of comment between decorator and property (#388) 2022-03-31 09:15:10 -07:00
Timothee Guerin 5d057edf60
Fix old Azure/adl links (#385) 2022-03-31 08:26:21 -07:00
Timothee Guerin bc34dadb16
Fix: Playground importing file not mocked (#386) 2022-03-30 15:52:04 -07:00
Timothee Guerin d8b0250b28
Fix: resolve location of diagnostic target in js source file (#383) 2022-03-30 13:02:37 -07:00
Timothee Guerin 161e6a00e5
Add missing docs: prop defaults, template defaults, libraries getting started (#376) 2022-03-29 20:10:10 +00:00
Timothee Guerin 319d394b46
Fix formatting of comment between decorator and statement (#374) 2022-03-29 19:41:20 +00:00
Timothee Guerin d4df855e3a
Add validation when using versioned library without @versionedDependency (#372) 2022-03-29 19:18:19 +00:00
Timothee Guerin 8dd3e026ec
Fix: Missing @key on resource create error instead of duplicate route (#375) 2022-03-29 11:19:52 -07:00
JianyeXi 5faea0d1ca
support format in bytes (#365)
* support format in bytes

* format

* changelog
2022-03-29 11:42:36 +08:00
Nick Guerrera 49bf4be36a
Add parent .model to ModelTypeProperty (#371) 2022-03-28 17:33:35 -05:00
Timothee Guerin 003854cf43
Fix eslint in vscode (#369) 2022-03-28 13:42:56 -07:00
Nick Guerrera 928be72ece
Customize VS output when language server activation fails (#366) 2022-03-28 17:55:37 +00:00
Nick Guerrera f09618c859
Turn on promise linting and fix issues (#362) 2022-03-28 11:02:24 -05:00
Nick Guerrera 7a16d48d06
Scope unpublished packages (#357) 2022-03-25 15:51:16 +00:00
Nick Guerrera 63f879c27d
Fix null ref in VS extension activation (#360) 2022-03-25 15:40:56 +00:00
Timothee Guerin 17da8d1fc5
Cadl type to Json Data converter (#292) 2022-03-24 20:52:48 -07:00
Timothee Guerin cada697bf4
Allow unversioned project to select a specific version of a versioned library (#346) 2022-03-24 18:04:36 -07:00
Timothee Guerin 3a96dddbd1
Fix various issues with template types with errors (#341) 2022-03-24 17:49:50 -07:00
Timothee Guerin dbe2f8548b
Extract the response interpretation logic out of openapi3 emitter and into http library (#355) 2022-03-25 00:38:46 +00:00
Timothee Guerin 34eaea96bb
Add base discriminator property with doc (#329) 2022-03-24 17:28:25 -07:00
David Wilson 11c0010593 rest: Raise error when child resource duplicates a parent key name 2022-03-23 21:06:48 +02:00
Timothee Guerin f5b6f86ef6
Add formatting button and shortcuts to playground (#350) 2022-03-22 15:09:13 -07:00
Jeff Fisher 99616f7d7e
[openapi3] Fix issue with enum values of `0` (#351)
* [openapi3] Fix issue with enum values of `0`.

Since `0` is falsy in JS, some checks we were doing for `undefined` were causing us to treat "Foo: 0" as if it were "Foo", resulting in errors when enums explicitly listed several enum values, including zero as the enum would no longer have members all of the same type.

* make rush happy
2022-03-22 08:23:06 -07:00
Brian Terlson 61454318f8
Implement multiple response content types (#347) 2022-03-21 22:53:50 +00:00
Timothee Guerin 326c7c7b9d
Add support for void in openapi3 emitter (#336) 2022-03-21 17:13:46 +00:00
Timothee Guerin e79ae0be46
Fix VSCode extension (#344) 2022-03-18 17:11:12 -07:00
Timothee Guerin da7b77264d
Validate template params default use latter (#295) 2022-03-18 07:50:51 -07:00
Timothee Guerin 3fb3d8849e
Fix: Joining empty routes (#334) 2022-03-17 14:23:01 -07:00
Timothee Guerin e2f82ec6a6
Don't create more diagnostics when error upstream (#299) 2022-03-17 11:03:18 -07:00
Timothee Guerin fca60c3d25
Fix Prettier plugin invalid require (#330) 2022-03-16 15:05:32 -07:00
Timothee Guerin dbd9a9117e
Allow template params to be intersected (#327) 2022-03-15 13:27:31 -07:00
Timothee Guerin fed6fd75ed
Suppress directive token error (#321) 2022-03-14 13:55:54 -07:00
Brian Terlson 4bdf8938ca
Add a playground (#302) 2022-03-11 10:52:58 -08:00
Nick Guerrera 9013c3f2d4
Prepare cadl publish (#309) 2022-03-09 12:42:38 -06:00
Timothee Guerin 83bd63759c
Fix: Issue with generated `.d.ts` file being invalid with diagnostic types (#305) 2022-03-09 08:48:49 -08:00
Nick Guerrera eedeaa92e0
Redirect console.* output in language server to stderr (#300)
Logging to stdout breaks LSP when the stdio pipe is used. The failure mode
when console.log is used unexpectedly is really bad and can take a very long
time to diagnose.

This change makes the language server use stderr for all console methods, so
now when decorators or emitters reach for console.log, they will just see
their output.

This change also restores inpsectType and inspectTypeName as decorators. I
think they never got the $ prefix, and I think this was unintentional. They
happen to serve as a good ad-hoc manual test that console.log now works as
we expect, which is why they are reinstated here.

In VS Code, the output to stderr from language server will show up in the
Cadl output pane.

However, in VS Classic, it currently goes to debugger log only. You have to
be attached to see it. It's possible to fix this, but we deleted a whole
bunch of code from the VS extension to stop making output pane messages
ourselves and I'd prefer not to reinstate it unless we decide we really need
it.
2022-03-08 14:05:10 -06:00
Nick Guerrera ba33855bef
Emit child models to OpenAPI when parent is emitted (#297) 2022-03-08 16:54:03 +00:00
Timothee Guerin aea92c72b1
Add `no-console` eslint rule (#293) 2022-03-08 08:32:49 -08:00
Timothee Guerin 8787c828f0
Export `NodeHost` in the compiler package. (#296) 2022-03-07 13:00:03 -08:00
Nick Guerrera 6037907313
Remove references to Azure/ARM/RPaaS from tests (#290) 2022-03-03 17:06:08 +00:00
Nick Guerrera 3691f113c9
Move @key decorator to core (#289) 2022-03-03 10:49:56 -06:00
Timothee Guerin b565f73c03
Feature: `@knownValues` decorator (#272) 2022-03-02 12:40:33 -08:00
Timothee Guerin 74addeed2e
Fix issue with model is primitive and error for model extends (#279) 2022-03-01 08:03:36 -08:00
Nick Guerrera a5221d5d13
Fix issue with missing namespace name in certain cases (#285) 2022-02-28 13:36:10 -06:00
Nick Guerrera 6595b501ce
Stop publishing .tsbuildinfo files (#281) 2022-02-24 16:00:03 -06:00
Timothee Guerin bdf94fa238
Feature: OpenAPI External docs (#276) 2022-02-24 09:54:41 -08:00
Timothee Guerin 4342c3cc50
Service description in openapi3 spec (#271) 2022-02-24 01:24:18 +00:00
Nick Guerrera 5075120533
rush update --full (#278) 2022-02-23 18:38:23 +00:00
Brian Terlson ac5743a9a0
Use the proper symbols to use cadl exports in eval (#277) 2022-02-23 10:02:49 -08:00
Nick Guerrera d05fa51f18
Complete using statements and qualified decorators (#274) 2022-02-22 22:17:54 +00:00
Timothee Guerin 1ef6878f01
Configure eslint for all packages with shared config pkg (#188) 2022-02-22 15:58:17 -06:00
Brian Terlson cf029ac3ad
Refactor symbols in advance of implementing reference types (#265) 2022-02-22 09:54:17 -08:00
Nick Guerrera a6a59a1fa5
Fix decorator completion on namespaces (#273) 2022-02-18 18:32:37 +00:00
Nick Guerrera 696b248662
Improve list parsing error recovery (#261)
* End lists when statement keyword or EOF is encountered.

* Do not put items that were parsed entirely out of synthesized tokens at
the end of lists.
2022-02-18 16:41:37 +00:00
Nick Guerrera b1be3793e4
Allow `op` in interfaces (#270) 2022-02-17 20:55:51 +00:00
Timothee Guerin 0c39b45d5c
Improve decorator param validation (#266) 2022-02-17 10:51:52 -08:00
Timothee Guerin 76a699dcec
Tests: TM grammar / Syntax highlighting (#263) 2022-02-16 12:57:35 -08:00
Timothee Guerin 79f8d5c434
@doc and @summary sets the description and summary on extended primitive types (#259) 2022-02-16 10:48:31 -08:00
David Wilson bba4cd1e14 Fix duplicate parameter type definitions in OpenAPI 3 output 2022-02-16 09:49:57 -08:00
David Wilson 8e6915f92c Filter out string constant path parameters when generating routes 2022-02-16 09:49:57 -08:00
Nick Guerrera a66d1c13fd
Prepare cadl publish (#264) 2022-02-15 22:52:46 +00:00
Nick Guerrera e216781b45
Small parser fixes (#258)
* Fix issue with missing error flag when using `interface extends` instead
of `interface mixes`.

* Fix issue with incorrect `op` in various projection expressions, and wrong
node type for `/` and `*`.

* Format diagnostics with location in verbose test output
2022-02-15 16:03:11 -06:00
Timothee Guerin 77b8507ba2
Fix invalid use of verb decorators in docs (#260) 2022-02-15 17:55:26 +00:00
Timothee Guerin d1b02fdd10
Add validation and test for decorators (#236) 2022-02-14 17:04:26 -08:00
Timothee Guerin 3757b340d5
Refactor resolve module to not depend on CompilerHost (#253) 2022-02-14 15:50:14 -08:00
Nick Guerrera 05b32a0c13
Add support for separate `@summary` from `@doc` (#249) 2022-02-14 11:03:33 -06:00
JianyeXi 95cac75955
Prepare cadl publish (#252) 2022-02-13 20:18:57 -08:00
Mike Kistler ee16edd8ff Update samples 2022-02-11 11:53:35 -08:00
Mike Kistler 1c140cdaf9 refactor status code handling to http library 2022-02-11 11:53:35 -08:00
Brian Terlson 5b39c45fcc
Give a better error for `interface extends` (#251) 2022-02-11 11:19:07 -08:00
Brian Terlson a055e3f165
Implement template argument defaults (#241) 2022-02-10 12:19:28 -08:00
Timothee Guerin 7fec69b503
Update decorators to take in `DecoratorContext` instead of `Program` (#247) 2022-02-09 10:12:19 -08:00
Brian Terlson 568cdb80c9
Fix bugs with projections, decorators and merged namespaces (#238) 2022-02-08 09:23:45 -08:00
Nick Guerrera f8b59f2199
Bump some dependency versions (#237) 2022-02-07 16:28:32 -06:00
Timothee Guerin 0c98c616eb
Add validation to @extension (#226) 2022-02-07 10:37:07 -08:00
Allen Zhang dbe8ec2221
Prepare cadl publish (#230) 2022-02-04 11:04:30 -08:00
Timothee Guerin 007c8dcf40
Internals: Add `clean` script to packages (#224) 2022-02-04 08:59:26 -08:00
Nick Guerrera 059488750f
Allow CLI array options to come before positional arguments (#225)
You could not do `cadl compile --import X main.cadl` or `cadl --emit X
main.cadl` because this would be interpreted as importing X and main.cadl or
emitting using X and main.cadl.

The fix is to disable this "greedy array" behavior in yargs. It means that
you have to repeat --import or --emit to specify multiple options, but that
seems fine.
2022-02-03 22:55:44 +00:00
Timothee Guerin f76ae8f8d7
Reorganizing of test hosts across library (#212) 2022-02-03 13:23:49 -08:00
Timothee Guerin ba68290633
Seperate openapi decorators into own library (#205) 2022-02-02 14:55:10 -08:00
Nick Guerrera ed1d073a8c
Move server implementation out of server program for testability (#207) 2022-02-02 20:45:34 +00:00
Timothee Guerin 0a872034fd
--emit and emitter api (#41) 2022-02-02 12:22:38 -08:00
Brian Terlson b8c461526f
Implement projections and versioning (#16)
Adds support for projections, an experimental language feature that lets users write code to modify types dynamically, and a package for implementing versioning on top of this functionality.
2022-02-01 14:18:15 -08:00
Timothee Guerin 23c736816d
Upgrade dependencies - Feb 2022 (#213) 2022-02-01 10:03:27 -08:00
Mike Kistler 305e49946a openapi3 emitter support for @error decorator 2022-02-01 07:18:56 -08:00
Mike Kistler cd48a83fe2 Add @error decorator in core 2022-02-01 07:18:56 -08:00
David Wilson 3243f82140 Add `friendlyName` decorator to customize model names for emitters 2022-02-01 04:25:52 -08:00
Timothee Guerin 47a7851d9e
Plug in code coverage collection into tests and upload to ADO (#208) 2022-01-28 17:44:56 +00:00
Mike Kistler a18d6258d4 Fix status code validation and other minor cleanup 2022-01-28 07:19:04 -08:00
Timothee Guerin 5a637e76f4
Feature: Validate operation have a unique verb&path combination (#196) 2022-01-26 19:24:01 +00:00
Timothee Guerin a5807a561f
Validate duplicate @route decorator (#203) 2022-01-26 11:14:11 -08:00
Timothee Guerin 54e196bcd9
Add validation for http verb decorators (#201) 2022-01-26 11:06:06 -08:00
David Wilson ff30cf6b33 Default `@action` operations to POST, don't override explicit verb 2022-01-26 15:54:07 +02:00
David Wilson 9321b3ebfa Move $key, $parentResource, and $copyResourceKeyParameters 2022-01-26 15:54:07 +02:00
David Wilson 80417fe61f `list` decorator should ignore TemplateParameters 2022-01-26 15:54:07 +02:00
David Wilson b068aee9e8 Add basic format capabilities to `@doc` decorator 2022-01-26 15:54:07 +02:00
Timothee Guerin 8f18ec78d1
@doc decorator validate argument is string (#198) 2022-01-25 14:48:45 -08:00
Allen Zhang 37c927f136
Adding back @format decorator to core and openapi3 (#195)
* Adding back @format decorator to core and openapi3

* updating samples

* Update change log
2022-01-25 09:42:09 -08:00
Timothee Guerin 1d3eed6f2a
Fix: invalid use of templates show correct location (#185) 2022-01-24 15:49:56 -08:00
Timothee Guerin 5c1dd0296f
Improvements to the http operation parameter validation(Duplicate body, duplicate types on params) (#167) 2022-01-24 15:48:35 -08:00
Timothee Guerin bf956d666e
Fix issue with casing in cadl path on case insensitive fs (#192) 2022-01-24 12:28:07 -08:00
Nick Guerrera b86f709cb1
Fix path normalization mismatch issue in language server (#190) 2022-01-21 20:41:40 +00:00
Mike Kistler 070dd347fc Expose response template in Http library and refactor 2022-01-20 21:34:21 -08:00
Mike Kistler ffa4c71e3e Support union values for status-code and content-type in responses 2022-01-20 21:34:21 -08:00
Timothee Guerin 02ce4094b2
Fix: Unterminated multi-line comment error when ending with multi-line comment (#187) 2022-01-20 12:03:01 -08:00
Timothee Guerin 41d8d4bc3b
Add @head decorator (#184) 2022-01-19 10:20:51 -08:00
Timothee Guerin 9a21766601
Emit diagnostic instead of exception for duplicate @key (#186) 2022-01-19 10:20:43 -08:00
Mike Kistler 06f62f6103 Refactor and improve openapi3 return type tests 2022-01-18 12:32:54 -08:00
Timothee Guerin 29fd74b85c
Remove leftover console.log (#174) 2022-01-18 10:41:03 -08:00
Timothee Guerin 5a0383c287
Add directory manipulation to CompilerHost & path utils (#157) 2022-01-14 16:22:30 -08:00
Timothee Guerin 8be380db0d
Samples: Body complex without inheritance (#49) 2022-01-14 16:21:55 -08:00
Allen Zhang a216108b67
[Core] Rename format to pattern (1/2) (#173)
* Rename format to pattern

* Update package change log
2022-01-14 12:07:32 -08:00
Timothee Guerin 0ae516d259
Formatter: Separate Enum members with decorator (#172) 2022-01-14 11:44:40 -08:00
Timothee Guerin 1cda205294
Fix nullable arrays in openapi3 emitter (#166) 2022-01-13 14:00:47 -08:00
Nick Guerrera 806c1e27c4
Remove support for "outerfaces" (#164)
Joking in the title. There was no outerface feature, but the scanner would
scan `outerface` as `interface`! LOL!

JavaScript truncates bitwise integer math to 32 bits and that caused our
actual limit in the keyword scanning algorithm that used 5 bits per letter
to be 6 characters instead of the 10 we thought we had in the "safe" integer
range. The fix is to use equivalent, but non-bitwise arithmetic.

Perf testing on my machine shows this is still faster than not having the
optimization at all by 4 or 5% when scanning petstore.cadl thousands of
times, but a little slower than the (broken) bitwise version. This isn't
likely to be noticeable in a full compile, but could be useful if we ever
need to quickly scan for something and skip most of the tokens.
2022-01-12 14:59:12 -06:00
Timothee Guerin 43ee29c7a5
Make syntax tree readonly & remove mutator (#141) 2022-01-11 12:24:20 -08:00
Mike Kistler a2cb1802b2 Add statusCode decorator for http status code 2022-01-10 10:16:22 -08:00
Mike Kistler 345ae2bd09 Add a sample for polymorphic model support 2022-01-05 10:56:19 -08:00
David Wilson 9fe481555a
Add interfaces for singleton and extension resources (#121) 2022-01-05 09:43:11 -08:00
Timothee Guerin a6831d17d8
Fix binary request & response openapi (#125) 2022-01-05 09:08:43 -08:00
Mike Kistler 5713554d3b Openapi3 support for discriminated unions 2022-01-04 13:19:23 -08:00
Timothee Guerin 20147157c7
Body string sample (#148) 2022-01-04 12:02:40 -08:00
Timothee Guerin 05a9eb21f7
Try changing dependencies to peerDependencies (#65) 2022-01-04 11:00:08 -08:00
Mike Kistler 76cbed6958 Add support for discriminator decorator 2021-12-17 10:57:48 -06:00
Nick Guerrera 5c7d1148e3
Move change to correct version in changelog (#147) 2021-12-16 11:58:09 -06:00
Mike Kistler d5131d6204 Support nullable in openapi3 emitter 2021-12-16 10:10:12 -06:00
JianyeXi 6155dacb18
Prepare cadl publish (#144)
Co-authored-by: jianye xi <jianyxi@microsoft.com>
2021-12-16 10:01:57 -06:00
Mike Kistler d026057ee6
Add findChildModels and getProperty utility functions (#129) 2021-12-16 09:40:21 -06:00
Timothee Guerin 5e002c7cc0
Fix additional circular ref issues(Alias, template) (#140) 2021-12-15 10:54:42 -08:00
Nick Guerrera 98e021d415
Add issue link (#132) 2021-12-15 12:02:57 -06:00
Nick Guerrera 6c5e9866fc
camelCase operations (#142) 2021-12-15 11:58:32 -06:00
David Wilson e93abc7b5b Update tags sample to include a recursive tag example 2021-12-15 17:41:31 +02:00
David Wilson 08ddc6a177 Add tests for new recursive tag lookup logic 2021-12-15 17:41:31 +02:00
David Wilson 87a8ba65f0 Add support for interfaces in @tag decorator; add @tag tests 2021-12-15 17:41:31 +02:00
Timothee Guerin e8bf3c920c
Handle circular reference for base types (#137) 2021-12-15 02:22:15 -08:00
Timothee Guerin bb55b0fcd2
Redesign Symbol table to keep symbol unique (#116) 2021-12-14 13:16:03 -08:00
Timothee Guerin b29baa9535
Improvements to the formatter(spread, interface mixes, ...) (#122) 2021-12-14 13:15:35 -08:00
Timothee Guerin 351d4b1009
Add support for default for unions (#127) 2021-12-14 08:48:18 -08:00
Nick Guerrera 6a6bf481ca
Add Cadl.Http.PlainData<T> (#126)
Removes `@header`, `@body`, `@query`, `@path` from properties to reuse T as
plain data.
2021-12-14 10:37:24 -06:00
Mike Kistler a4e75862db
Merge pull request #80 from mikekistler/openapi3-unions
Generate anyOf or oneOf schemas for Cadl unions in openapi3
2021-12-13 19:05:27 -06:00
Timothee Guerin ab99127d61
Fix issues with comments in auto-formatter (#120) 2021-12-10 09:32:30 -08:00
David Wilson a66ca4b53a
Merge pull request #90 from daviwil/new-route-model
Improved route decorator model and more standardized operation emit
2021-12-09 21:32:17 -08:00
David Wilson 3d58f7db7c Format source files 2021-12-09 16:58:50 +02:00
David Wilson 13c5c14965 @createOrUpdate -> @createsOrUpdatesResource 2021-12-09 16:58:50 +02:00
David Wilson 9ce04c2169 Introduce new model for defining operation routes 2021-12-09 16:58:50 +02:00
Timothee Guerin 5b23892fb6
Fix: Cadl-server issues with Visual Studio (#115) 2021-12-08 08:35:07 -08:00
David Wilson 0add8f1289 Rename REST operation decorators to remove conflict with Cadl.Http 2021-12-08 13:38:56 +02:00
Timothee Guerin 9fa7e969c6
Keyword completion and icons (#114) 2021-12-07 12:52:27 -08:00
Allen Zhang 92c4da6367
Merge pull request #109 from allenjzhang/azhang-add-put
Adding CreateOrUpdate/PUT option to rest interfaces
2021-12-07 12:20:53 -08:00
Allen Zhang 032e0eb718 Update samples 2021-12-07 11:35:00 -08:00
Timothee Guerin 97bef44b46
Fix: Using causing duplicate symbol errors even if not used (#95) 2021-12-07 09:06:01 -08:00
Nick Guerrera 4eb8ec6e40
Remove unused autorest dependency (#111) 2021-12-06 10:19:19 -08:00
JianyeXi ae5bc31d75
add mkdirp to Compilerhost (#107)
* add mkdirp to CompilerHost

* changelog

* fix test-host

* update 3Party notice

* update  changelog

Co-authored-by: jianye xi <jianyxi@microsoft.com>
2021-12-06 09:48:38 +08:00
Allen Zhang 5b92de8e96 Adding CreateOrUpdate/PUT option to rest interfaces 2021-12-03 13:11:48 -08:00
Nick Guerrera 34ff2a9644
Prepare cadl publish (#100) 2021-12-01 17:09:34 -06:00
Nick Guerrera 1e51871915
Add READMEs for all packages, update existing ones (#97) 2021-12-01 16:48:41 -06:00
Nick Guerrera 30f960832c
Fix syntax highlighting of namespace-qualified decorator application (#96) 2021-12-01 13:38:57 -06:00
Nick Guerrera 65f2881539
Fix issues with unhandled exceptions (#94)
- Simplify handling of unbound target node by replacing AggregateError with
embedding note about bug in dummy location

- Add synthetic node flag to detect case where no parent is expected

- Move onBuild catch handler to correct place

- Refine target of decorator failure diagnostic to decorator expression

- Add complete stacks to decorator and onBuild failure diagnostics in
language server builds

- Add catch-all to language server compilation and report internal compiler
error without tearing down the server

- (Unrelated) Add missing library prefix to one unit test
2021-12-01 09:13:15 -06:00
Nick Guerrera 9aca5d01ff
s/CADL/Cadl/ (#88) 2021-11-30 13:56:56 -06:00
Nick Guerrera 7b37693382
Fix issues with reporting certain unprintable parse trees as printable (#84) 2021-11-30 07:41:13 -06:00
Mike Kistler 26bca0061e
Merge pull request #81 from mikekistler/extension-decorator
Extension decorator
2021-11-29 16:38:05 -06:00
Mike Kistler 944ee85e8e Add openapi3 support for Cadl safeint 2021-11-28 14:49:43 -06:00
Mike Kistler 0e84318811 Add support for extensions on parameters 2021-11-28 12:38:34 -06:00
Mike Kistler 184c80ef10 Tests for extension decorator 2021-11-28 12:38:34 -06:00
Mike Kistler 4bab1ade4a Generate anyOf or oneOf schemas for Cadl unions in openapi3 2021-11-23 17:35:00 -06:00
Timothee Guerin 47f73ee082
Fix wrong library import in rest init template (#76) 2021-11-23 19:24:41 +00:00
Nick Guerrera d1cc00a800
Fix syntax highlighting broken by markdown embedded highlighting (#74) 2021-11-22 19:28:35 +00:00
Nick Guerrera e7d656075b
Small formatting and syntax highlighting improvements (#73)
1. Format *.cadl on save in our repo. This required some extra knobs in
.vscode/settings.json and .prettierrc.json. These are not required when
referencing the prettier plugin via npm, but we need a workaround to consume
the plugin this way from source.

2. Fix a formatter bug with operations that return anonymous models where
the braces around the return model were dropped.

3. Add cadl syntax highlighting to markdown ```cadl blocks
2021-11-22 13:04:36 -06:00
Nick Guerrera 53cbecc69c
Use prettier for markdown too (#72) 2021-11-19 15:52:17 +00:00
Nick Guerrera 63b4122362
Fix colorization of multiple mixes and crash in language server (#71) 2021-11-19 09:10:02 -06:00
Nick Guerrera a44a8ea9b5
Prepare cadl publish (#69) 2021-11-18 08:05:10 -06:00
Nick Guerrera c9e3297f81
Show `@doc` info along with completions (#63) 2021-11-16 10:44:31 -06:00
Nick Guerrera 8a751d2c40
Update compiler package prefix in test names (#60) 2021-11-16 10:42:38 -06:00
David Wilson 81dd310733 Update sample OpenAPI output 2021-11-16 14:24:53 +02:00
David Wilson a989effc71 Remove openapi3 import in REST PetStore example 2021-11-16 14:24:53 +02:00
David Wilson 7bb07725bf Properly document new resource models and operations 2021-11-16 14:24:53 +02:00
David Wilson 49a2976f9c Restore @doc additions to HTTP response types from 37c4e3ab 2021-11-16 14:19:23 +02:00
David Wilson 1db5d4aea7 Update some OpenAPI output files 2021-11-16 11:59:10 +02:00
David Wilson d0f3171caa Ensure that OperationType.interface is set for ops in interfaces 2021-11-16 11:59:10 +02:00
David Wilson 1f71488236 Add resource modelling to Cadl.Rest, refactor many decorators
There are a number of changes in this commit:

- Moved all HTTP types and decorators into `Cadl.Http`
- Moved all REST types and decorators into `Cadl.Rest`
- Renamed the `@resource` decorator to `@route`
- Created new `Cadl.Rest.Resource` namespace for core resource modelling behavior
- Updated the `openapi3` generator to support interfaces and resource modelling
- Updated all existing sample specs to use `Cadl.Http`
- Added a new REST-style PetStore sample
2021-11-16 11:59:10 +02:00
Timothee Guerin 86e3dcf4e5
Fix: Log Warning count (#62) 2021-11-15 09:09:39 -08:00
Timothee Guerin 02d9f1299c
Feature: docker image (#57) 2021-11-12 11:17:46 -08:00
Timothee Guerin 88a51f1b6d
Feature: `cadl install` command (#54) 2021-11-11 14:25:53 -08:00
Nick Guerrera f44ba2d20a
Prepare cadl publish (#59) 2021-11-11 15:55:38 -06:00
Nick Guerrera b38945792a
Add completion ("IntelliSense") support to language server (#56) 2021-11-11 15:42:38 -06:00
Timothee Guerin 9c94e514f8
Make init package.json private to remove warning for missing fields (#53) 2021-11-10 09:42:56 -08:00
Timothee Guerin 47a4149d50
Bump ecmarkup dependency and subdependency to fix deprecation warning (#51) 2021-11-10 08:57:57 -08:00
Nick Guerrera 76459b204c
Fix Visual Studio 2022 extension (#52)
Upgrade packages and react to breaking changes since preview.
2021-11-10 10:50:13 -06:00
Timothee Guerin 2300f37d1f
Feature: Duration model (#50) 2021-11-09 19:50:08 +00:00
Timothee Guerin 4c82558534
Feature: Added `--check` option to cadl format (#47) 2021-11-08 10:00:42 -08:00
Timothee Guerin e3f808b899
VSCode server path use compiler path instead of bin (#43) 2021-11-05 11:10:57 -07:00
David Wilson 6f3d632276
Merge pull request #42 from daviwil/import-argument
Add --import parameter to generate sample output using any emitter
2021-11-04 18:49:15 +02:00
David Wilson 3dea05ac00 Update regen-samples script to use --import parameter 2021-11-04 16:12:10 +02:00
David Wilson 4565d9694b Add new `--import` parameter for importing plugins/emitters via CLI 2021-11-04 16:04:23 +02:00
Timothee Guerin e169d70c1b
Feature: Log error count (#38) 2021-11-03 11:02:51 -07:00
David Wilson a1de24bc20 Add Prettier formatting support for interface mixes 2021-11-02 12:06:36 +02:00
Timothee Guerin 4bfdcd2079
Convert recursive.cadl sample to unit test (#35) 2021-11-01 09:44:53 -07:00
Timothee Guerin bf3a1deab5
Add support for model mutually referencing each other & template self reference (#32) 2021-10-29 08:42:24 -07:00
Nick Guerrera b32bdf7f95
Prepare publish (#30) 2021-10-28 17:17:12 -05:00
Timothee Guerin 57eeed4723
Add OmitDefaults model to remove default values of a model (#27) 2021-10-28 16:58:12 +00:00
Timothee Guerin 8c9f62faca
Setup cadl prettier plugin to format samples and libraries (#26) 2021-10-28 16:51:44 +00:00
Nick Guerrera 43be41e127
Remove service host default (#20) 2021-10-27 14:41:04 -05:00
Timothee Guerin 870c028894
Tweak: Decorator formatting (#25) 2021-10-27 12:26:04 -07:00
Nick Guerrera d636ea1a48
Upgrade TypeScript and react to breaking change (#23)
We need to declare catch variables as `any` explicitly now (or turn it off
with a config, but I think it's fine like this). I noticed this because VS
Code defaults to its own version of TS and was reporting this error.

Also, some tests were expecting diagnostics to be exceptions still. Fixed,
including one test that was passing when it shouldn't have been as it had
not been updated to react to ADL -> Cadl rename or $ prefix of decorators.
2021-10-27 14:11:58 -05:00
Timothee Guerin fdd8694d35
Add multiple inheritance spec sample (#24) 2021-10-27 18:03:47 +00:00
Nick Guerrera 74246edb7f
Return non-zero exit code when compilation has errors (#21) 2021-10-27 12:31:44 -05:00
Timothee Guerin aa4eed3ad3
Feature: init lets you copy files with basic templating (#7) 2021-10-27 09:44:12 -07:00
Nick Guerrera 9b8cac3740
Fix interface colorization (#18) 2021-10-27 09:03:03 -05:00
Mike Kistler ef4e4e5412
Merge pull request #13 from mikekistler/fix-empty-enums
Fix crash on empty enum in openapi3 emitter
2021-10-26 13:22:48 -07:00
Mike Kistler 7f6ad9cc9a
Use strong typing on messageId
Co-authored-by: Nick Guerrera <nicholg@microsoft.com>
2021-10-26 12:21:23 -07:00
Nick Guerrera b673f1eeef
Fix `rush regen-samples` (#17) 2021-10-26 09:32:41 -05:00
JianyeXi 37c4e3aba0
Add lint rules (#5)
* add  option `--diagnostic-level` to specify which level of messages should be reported
* add docs for built-in types
* improve & export semantic-walk lib 

Co-authored-by: jianye xi <jianyxi@microsoft.com>
2021-10-26 10:23:07 +08:00
Mike Kistler 0ab32c1929
Merge pull request #14 from mikekistler/fix-param-default
Fix param default to be in schema
2021-10-25 18:55:55 -07:00
Mike Kistler 60cb1ab734 Define response body for primitive response type 2021-10-24 08:58:34 -07:00
Mike Kistler f729b9ebae Fix param default to be in schema 2021-10-24 07:09:16 -07:00
Mike Kistler c5bd22bc76 Fix crash on empty enum in openapi3 emitter 2021-10-23 16:36:26 -07:00
Mike Kistler 58513bbc64 Set shared param definitions in components.parameters 2021-10-23 14:25:23 -07:00
Mike Kistler 6d4ea0b6e9 Fix handling of decorators on parameters in openapi3 2021-10-23 09:13:36 -07:00
Mike Kistler 8cf60e89ac Add unit test for openapi3 parameter decorators 2021-10-23 09:13:36 -07:00
Mike Kistler a03572e6d4 Fix generation of openapi3 response headers 2021-10-22 18:13:29 -07:00
Mike Kistler 396a198619 Add test to reproduce issue with openapi3 response headers 2021-10-22 18:13:12 -07:00
David Wilson 521aebea55 Add @cadl-lang/samples with existing generic samples 2021-10-21 09:24:03 -07:00
Nick Guerrera 2c5454dc1a Port build process to new OSS repo 2021-10-19 15:21:39 -05:00
Timothee Guerin 6a52d07ef9 Fix `using` formatting (#866) 2021-10-19 09:26:58 -07:00
Timothee Guerin e62aad12a0 Introduce logger to allow logging information (#865) 2021-10-18 13:46:01 -07:00
Timothee Guerin 8246666f6c Strict diagnostics in the compiler (#845) 2021-10-15 15:06:34 -07:00
markcowl b22d8ec3da Preparing package changes for release 2021-10-15 14:34:50 -07:00
Timothee Guerin 3e3bae0ebb Feature: Suppress warnings (#826) 2021-10-13 08:38:07 -07:00
Brian Terlson 1bf3922cf5 add more interface polish: walker, colorization, printer (#841) 2021-10-12 16:55:10 -07:00
Brian Terlson 04b0927a44 Implement union declaration (#832) 2021-10-11 15:38:20 -07:00
Timothee Guerin c3ce1d3256 Feature: Add support for defaults for optional properties and parameters (#825) 2021-10-08 07:42:15 -07:00
Timothee Guerin 817eb76f5c Directive parser, tmlanguage and formatter (#805) 2021-10-07 12:55:11 -07:00
Timothee Guerin ccc8de9866 Typed diagnostics for libraries (#795) 2021-10-07 12:54:58 -07:00
Brian Terlson 04a04bbe50 Implement interface (#816) 2021-10-07 09:53:36 -07:00
Brian Terlson 2cf9d6f94a Implement a clone type API on checker (#813) 2021-10-01 11:17:23 -07:00
David Wilson d8fafe8032 Merge pull request #807 from daviwil/library-namespaces
Move cadl-rpaas types and decorators into Azure.ARM namespace
2021-09-30 15:55:57 -07:00
Brian Terlson 6fac2f6a0b Reverse order of decorator evaluation (#793) 2021-09-30 13:36:37 -07:00
markcowl 7d3c79ffcb Fixing out of date comment 2021-09-29 15:34:58 -07:00
markcowl c69fd154ba Defensive code to prevent language server failure 2021-09-29 15:02:01 -07:00
David Wilson 537482d287 Ensure that binder synthesizes the namespace correctly 2021-09-28 10:54:07 -07:00
Nick Guerrera db1bb440f8 Run decorators and onBuild handlers in language server (#804)
We now run decorators and onBuild handlers in the language server and
thereby show their diagnostics to the IDE user as they code.

This put pressure on the issue of getting mismatched compiler versions since
it becomes a common case where the Cadl being edited pulls in a local
version that is different from the global version used by the global
cadl-server.

We now implement a check that resolving @cadl-lang/compiler from the entry
point cadl file either doesn't resolve or resolves to the same location as
the current compiler. If this check fails, compilation is aborted early with
a diagnostic error. The error message discusses two common causes: running
on the command line from a working directory away from the source or running
in the IDE where the root workspace dir is not the one with the node_modules
that have the cadl compiler package.

In the second error case, the recommended remedy in the message is to
configure the cadl-server path in IDE settings. We actually have this
case (which an end user can also have) in our own repo and this change also
configures our VS Code settings to use the local cadl that we are developing
on.
2021-09-24 12:45:09 -05:00
Brian Terlson dadf721c05 Fix ns bugs (#803)
Fix binding of JS files.
Fix namespace decorators referencing other namespaces.
2021-09-23 15:36:36 -07:00
Brian Terlson b2680195ca Fix using bug when using'd namespace is merged after current namespace (#790) 2021-09-22 16:31:30 -07:00
Nick Guerrera 600c72d1a6 Revert accidental change that started running decorators/onBuild in LS (#784)
A mistake during a refactoring caused us to start running decorators and
onBuild in language server. We do intend to do this soon, but doing it
prematurely revealed a version problem where we can't safely run decorators
that load a local Cadl compiler while using the globally installed language
server.

So, for now, revert back to not running decorators, and we will look at how
to deal with the version mismatch as part of doing it again deliberately.
2021-09-22 12:52:14 -05:00
markcowl 22664b5edd Publish cadl September features 2021-09-16 17:51:24 -07:00
markcowl 88da52a3ec Fixing changelog in openapi3 package 2021-09-16 17:31:32 -07:00
Brian Terlson 797589fdff Move builtins into cadl namespace, merge namespaces in checker (#766) 2021-09-14 11:56:37 -07:00
Nick Guerrera 9d8dd51a6c Fix bug preventing using latest changes to document in IDE (#758)
IDE features were not seeing latest revision of a document unless
it was untitled due to a typo in the code.
2021-09-10 11:45:21 -05:00
Timothee Guerin ad9a8e39de Feature: `cadl init` command (#707) 2021-09-10 08:55:13 -07:00
Brian Terlson 49df4cf6cd Remove multiple inheritance (#759) 2021-09-10 08:53:27 -07:00
Timothee Guerin 0452a33467 Semantic walker (#715) 2021-09-09 10:34:45 -07:00
Brian Terlson 7891561347 Change `byte` to `bytes`, add various int formats (#755) 2021-09-08 14:54:14 -07:00
Nick Guerrera e192b96caa Ensure syntax nodes report correct and consistent source positions (#754)
Code used in go-to definition depends on the invariant that a node's `[pos,
end)` range must be inside that of its parent. This invariant may prove
useful for other purposes too. However, there were some places where this
invariant did not hold and this change fixes that.

1. Statements did not include decoroators (if any) inside their `[pos, end)`
range. Incosistently, parameters, model members, and enum members did
already include decorators in their position. This change includes
decorators in positioning always.

2. Member expression positioning was incorrect and started at the position
of the last identifier rather than the start of the full member expression.

3. Namespaces using the `namespace A.B.C {}` syntax that expanded to
`namespace A { namespace B { namespace C {}}}` started the inner namespaces
at their identifiers. The only way to keep this invariant is to have all the
namespaces defined have the same `[pos, end)` range of the entire statement,
so this change does that.
2021-09-08 16:53:35 -05:00
Nick Guerrera b111bd337a Implement go-to-definition in language server (#750)
Also fix bug that broke analysis of untitled documents
2021-08-30 17:41:23 -05:00
Mike Kistler 0b024d674c Add emitter for OpenAPI 3.0 (#745) 2021-08-27 10:25:58 -05:00
Nick Guerrera d28a30a7a9 Use current tmlanguage-generator package (#744)
We were still pulling the package pre-rename from npm instead of
linking to the one in the repo with a new name.
2021-08-25 15:09:03 -05:00
markcowl df3b1b458a Updates for cadl release 0.19.0 2021-08-20 17:05:19 -07:00
David Wilson 91da40cca2 Introduce naming convention `$name` for JS-defined Cadl functions 2021-08-19 15:43:22 -07:00
markcowl afdf37df95 Publish _____ fixes 2021-08-13 12:11:19 -07:00
markcowl 26e7e9e8c8 Updatable -> updateable 2021-08-13 00:17:45 -07:00
markcowl c9eb9081cf Merge branch 'main' of github.com:azure/adl into demo 2021-08-12 16:02:17 -07:00
Nick Guerrera 897476ce91 Remove client generation command (#721) 2021-08-12 12:30:43 -05:00
Nick Guerrera 0ce25f4aa9 Fix `cadl vs uninstall` (#720)
It was throwing `YError: Invalid third argument. Expected function or object but received undefined.`
2021-08-12 10:28:30 -05:00
Nick Guerrera d117e1ac74 Rename packages in preparation for OSS release (#714) 2021-08-12 08:38:20 -05:00
markcowl 6ea0ee86b6 remove unnecessary code, fix empty response schema emission, and correct tests 2021-08-11 18:55:20 -07:00
markcowl b8a81cfef9 Merge branch 'main' of github.com:azure/adl into demo 2021-08-09 15:40:36 -07:00
David Wilson (AZURE SDK) 1c45a24904 Prepare Cadl v0.16.0 release 2021-08-09 14:15:40 -07:00
David Wilson (AZURE SDK) ddffd91688 Add `compile --watch` option to watch file changes and recompile 2021-08-09 11:29:53 -07:00
markcowl 889794028f adjust to rename for cadl 2021-08-05 17:02:05 -07:00
Timothee Guerin e94a492ab2 Update to yargs 17 and args parsing to use handler system. (#696) 2021-08-03 10:49:49 -07:00
Brian Terlson ecd98a6cdd Don't allow duplicate model and enum members (#697) 2021-08-03 10:38:14 -07:00
Brian Terlson 07949f4949 Implement model is support (#691) 2021-08-02 18:27:07 -07:00
Nick Guerrera 013db35e87 Prepare publish of Cadl v0.15.0 (#688) 2021-08-02 13:25:21 -05:00
Nick Guerrera 8e0f6be0f4 Rename ADL to Cadl (#678) 2021-08-02 13:14:53 -05:00
markcowl 7d8dbad264 Merging in generator changes 2021-07-29 15:56:42 -07:00
markcowl 2d680111b7 Publish packages for bug fixes and controller generator 2021-07-28 12:42:48 -07:00
markcowl d61e6e6b1b Responding to review feedback 2021-07-27 21:23:45 -07:00
markcowl f0ab71d9ec Adjusting to new decorators property on types 2021-07-27 11:54:34 -07:00
markcowl 28e9b96c85 Merge branch 'main' of github.com:azure/adl into adl-gen-update 2021-07-27 11:11:57 -07:00
markcowl 8e47296b6f fix commits 2021-07-27 11:11:01 -07:00
Brian Terlson 254262ce57 Allow decorators to go in namespaces. (#662)
* Refactor decorator binding out of program and into binder
* Refactor decorator execution out of program and into checker
* Decorators can have a .decorator string property with a namespace like A.B on it.
* js files can export a namespace property which has a namespace like A.B in it.
* Decorators and types occupy separate namespaces so can have the same name.
2021-07-26 10:09:31 -07:00
markcowl c2f2548ff1 Update formatting 2021-07-25 14:21:02 -07:00
Nick Guerrera 2fad9f7307 Improve unicode support in lexical structure (#673)
1. Define and implement UAX31.R2 Immutable Identifiers profile
2. Normalize identifiers to NFC
2021-07-23 10:19:21 -05:00
markcowl 66240715d2 Removing unnecessary files, cleaning up changes in adl-openapi 2021-07-22 18:11:35 -07:00
markcowl 94ec19e31d mergining with upstream 2021-07-22 17:18:12 -07:00
Nick Guerrera 5055d411fb Bump autorest version to get client gen test to pass (#675)
Also remove unnecessary `npm link` step that made running more than once on my
machine fail.
2021-07-22 15:09:12 -05:00
markcowl 03be3938d9 Merging in adl-openapi bug fixes 2021-07-11 18:34:34 -07:00
Nick Guerrera 68361251ad Prepare 0.13.0 release (#654) 2021-07-09 13:33:50 -07:00
Nick Guerrera fd57be627b Add semantic analysis to language server (#608)
Previously, the language server only parsed files and only reported
diagnostics from parse errors. Now it runs a compilation and reports
semantic errors such as unknown identifiers in open files.

For now, decorators are not invoked nor is onBuild called. There are some
unresolved design issues there still to be discussed...

The language server will try to infer the appropriate entry
point (a.k.a. "main file") for a given document. This is necessary because
you can get different diagnostics in the same files for different entry
points.

The entry point inference is not perfect and there can be unexpected
diagnostics if the imports are done sufficiently creatively to outsmart
it. It works by walking the directory tree from the changed document through
its parents and stopping when a package.json with adlMain or main.adl is
found or we reach a workspace root. If we reach a workspace root without
finding an entry point, then the document is used as its own entry
point. Untitled documents are always analyzed as their own entry points
since they do not exist in any directory where another entry point could be
found.

At some point, we may need to add some configuration to be explicit about
which entry points to use at some point, but the inference should also be
sufficient for common cases. For example, it is sufficient enough to handle
all of our samples.

Additional minor changes:

1. Fix an issue where spreading a property that had an unbound decorator
would report duplicate diagnostics at the same source location indicating
that the decorator could not be found.

2. Route config file I/O through compiler host interface.

3. Fix an issue with debugger config where VS Code was sometimes failing to
attach to language server.
2021-07-09 13:19:56 -07:00
Nick Guerrera bbcbaf3cd7 Merge pull request #600 from daviwil/fix-rpaas-linter-failures
Fixes for a few Swagger linter violations for ARM RPaaS output
2021-07-09 10:21:37 -07:00
Nick Guerrera d2d6e4a066 Remove duplicate types, unused properties (#638) 2021-07-08 14:55:52 -07:00
Timothee Guerin 04c18a00d4 Feature: Auto-fromatter can handle recoverable parsing error (#622) 2021-07-07 12:08:56 -07:00
markcowl a2e79d3854 Merging with upstream 2021-06-29 17:36:01 -07:00
Timothee Guerin f7e13664e9 Diagnostics code as string (#601)
* Change diagnostic code to be a string

* Changelog

* Remove ADL prefix
2021-06-29 11:06:43 -07:00
Nick Guerrera 5c349e7eed Use LSP to log messages from client to server (#598)
This removes the need for a custom output window pane in Visual Studio.

Also, start tracking workspace folders which will be needed soon, but just
log them for now.
2021-06-25 06:54:53 -07:00
David Wilson 55371b467a Generate RPaaS update op with all resource properties optional 2021-06-25 14:01:40 +03:00
David Wilson 5fd38c3f4e Prevent OpenAPI emitter from tripping on ErrorTypes in ADL output 2021-06-25 14:01:40 +03:00
David Wilson ade121ad67 Prepare ADL packages release 2021-06-24 06:58:07 +03:00
David Wilson f8ca46757b Merge pull request #591 from daviwil/fix-path-parameter-decorators
Fix application of intrinsic decorators to properties and parameters
2021-06-23 20:38:06 +03:00
David Wilson abd388c334 Fix application of intrinsic decorators to properties and parameters 2021-06-23 13:50:56 +03:00
Nick Guerrera ff086dd933 Add support for Visual Studio 2022 (#588)
This required splitting things into separate VSIXes per guidance here:

https://docs.microsoft.com/en-us/visualstudio/extensibility/migration/update-visual-studio-extension?view=vs-2022
2021-06-22 09:20:39 -07:00
markcowl 8ff1311033 Updating for new stored state maps 2021-06-21 20:50:55 -07:00
markcowl 2a4b85b888 Merging with main 2021-06-21 18:59:59 -07:00
David Wilson f2da3d1f5a Binder now uses reportDuplicateSymbols from Program 2021-06-21 08:16:31 +03:00
David Wilson f093f5c4f8 Pass along diagnostics raised by parsing mutation grafts 2021-06-21 08:16:31 +03:00
David Wilson (AZURE SDK) 630d6c3b0d Add mutators library for manipulating evaluated ADL types 2021-06-21 08:16:31 +03:00
Timothee Guerin 34ea3a669a Feature: ADL Program types walker (#586) 2021-06-18 09:43:28 -07:00
markcowl 341baba352 Updating with latest fixes 2021-06-15 22:04:05 -07:00
markcowl 8c8917adda Fixes for swagger gen issues 2021-06-10 20:04:32 -07:00
Nick Guerrera 2ec0c6c455 Bump TypeScript version (#582) 2021-06-10 11:16:34 -07:00
Nick Guerrera f04292734a Handle untitled source files in VS Code (#581)
Previously, there was no feedback from language server unless a document
had was written somewhere to disk at least once. Feedback happened live,
not on save, but if the document was "untitled", then there would be no
feedback at all.
2021-06-10 10:55:46 -07:00
markcowl 9d596f6c83 Fix issues over model generation 2021-06-08 14:18:55 -07:00
Nick Guerrera 8518a0bd17 Use same entry point handling for compile and import (#577)
We no longer glob files when a directory is passed to `adl
compile`. Instead, we will look for `adlMain` specified by package.json or
main.adl in the directory. This eliminates any dependency on file system
enumeration order and will make it easier for tooling to implement semantic
features.

Also:
* Fix various issues with reporting I/O errors as diagnostics.
* Fix issue where regen-samples would silently pass PR validation if nothing
  at all was emitted.
* Make regen-samples have opt-out exclude list instead of opt-in include
  list.
* Report correct location for syntax errors in decorators, and fix issue
  with copying petstore sample to another folder without type: module in
  package.json
* Allow .mjs extension for decorator imports.
* Make sure unahndled promise rejection becomes internal compiler error.
* Fix issue with dumping config with diagnostics from `adl info`
* Avoid repeating config filename in `adl info`
2021-06-04 14:12:59 -07:00
Nick Guerrera c62c1036f9 Add semantic error recovery (#574)
We now continue to semantic analysis when there are parse errors, and we do
not abort the compilation when a semantic error is encountered, but instead
recover and look for more errors.

DiagnosticError is no longer a thing as we never throw diagnostics as
exceptions anymore. throwDiagnostic is now Program.reportDiagnostic.
2021-06-03 08:46:10 -07:00
markcowl ba3de996f6 Implementation to visit all operations and models 2021-06-02 21:59:11 -07:00
Nick Guerrera 451274c269 Facilitate merge of config file loading with semantic error recovery (#572)
It ended up being tricky to merge my pending semantic error recovery change
with the config file loading change. This change extracts out some changes
to config file loading from my error recovery branch as it will be easier to
review this independently from that.

* Don't bother making a diagnostic for incorrect file extension, as compiler
  should never attempt that. It's OK to throw a regular error in this case.
* Fix issue with returning or spreading default config where mutation of
  loaded config could mutate defaults.
* Avoid fileExists + readFile race condition by not using fileExists and
  catching readFile ENOENT error instead.
* Move extra json file for multi-file test to correct folder.
* Various small refactorings to make these changes easier.
2021-06-02 15:20:45 -07:00
Nick Guerrera d2658c5e33 Run prettier plugin test in CI and mocha explorer, fix test bug (#570) 2021-05-27 09:09:14 -07:00
Timothee Guerin 62da05403d User Configuration file discovery and loading (#562) 2021-05-27 08:33:39 -07:00
Nick Guerrera 0ce71bfb7e Prepare publish of v0.11 (#561) 2021-05-18 17:58:38 -07:00
Timothee Guerin 1a34119e65 Throw diagnostic error when main adl file is not found. (#560) 2021-05-18 14:58:52 -07:00
Nick Guerrera 9427591bfe Work around npm 7+ Mac OS bug in `adl code install` (#557) 2021-05-18 14:32:50 -07:00
Nick Guerrera 8ab8f8a6c3 Prefer local install of adl package when running global `adl` (#552)
Prevents conflicts between two copies of adl modules in global and local
package locations.
2021-05-18 14:22:37 -07:00
Nick Guerrera cc90a5b228 Don't fallthrough from `adl vs` to `adl format` (#558) 2021-05-18 09:21:33 -07:00
Timothee Guerin 469b1457f4 Formatter: Multiline string (#555) 2021-05-14 10:23:32 -07:00
Timothee Guerin bb82633b6c Fix: Don't format a file that has parsing errors (#549) 2021-05-13 15:57:33 -07:00
Nick Guerrera bf53463205 Remove some unused types (#550) 2021-05-13 11:38:31 -07:00
Timothee Guerin 96de03678a Fix: Formatter not rendering template parameters of models. (#548) 2021-05-13 09:42:25 -07:00
markcowl 2651269740 making first typescript based generator 2021-05-12 22:36:30 -07:00
Nick Guerrera d7bda1f5d9 Fix issue launching adl-server on Mac OS (#547)
We were clearing environment variables down to one environment variable
rather than adding one for node options.
2021-05-12 13:27:49 -07:00
Timothee Guerin 69a6b60cab ADL prettier plugin and `adl format` command (#511)
Added a new package prettier-plugin-adl providing adl support to prettier. Just installing the plugin next to prettier will automatically enable it for .adl files.

Added new adl format command.

Usage:

adl format **/*.adl

This will format all the files matching the pattern.
2021-05-12 09:46:58 -07:00
Nick Guerrera 3f58a55bc3 Prepare publish of adl 0.10.0 (#544) 2021-05-06 08:27:14 -07:00
Brian Terlson 261465f0dd Make blockless namespaces accumulate declarations. (#543) 2021-05-05 13:11:35 -07:00
Nick Guerrera d1401ef065 Don't warn on developer builds without VS (#521)
The warning was breaking `rush dogfood`
2021-05-03 16:56:45 -07:00
Nick Guerrera efe9479cd4 Clean up editor settings (#519)
1. Move to per-language prettier formatter throughout. Global wasn't working
for some folks for TypeScript, so I suspect it's best to use the
per-language setting throughout.

2. Merge the adl-vs .editorconfig into the root .editorconfig, giving better
defaults for editors other than VS Code that support .editorconfig.

3. Add ADL, C# and XML to VS Code settings.json
2021-05-03 15:39:09 -07:00
Nick Guerrera d4924d88a6 Add describe prefix for better test navigation in IDE (#518)
Also fix a mistaken test grouping due to incorrect merge conflict resolution
2021-05-03 14:59:30 -07:00
Nick Guerrera 932c8bdc31 Disallow mocha .only in CI and PR validation (#516) 2021-05-03 12:51:18 -07:00
Nick Guerrera 7c6ef01053 Do not allow non-triple-quoted strings to be multi-line 2021-05-03 11:57:25 -07:00
Nick Guerrera 44faaadf01 More scanner optimization and fixes
* Don't allocate substrings to match keywords.
* Make at most one pass over string to get its unquoted/unescaped/unindented
  value. (**)
* Add test coverage for impacted code paths.
* Fix issue where string value of an unterminated string was missing final
  character(s) in string value.

(**) Actually, we still make two passes in the case of a non-triple-quoted,
multi-line string with \r\n, but that is about to be removed by the next
commit which will disallow non-triple-quoted, multi-line strings
altogether.
2021-05-03 11:57:18 -07:00
Nick Guerrera 158dd31eb2 Merge pull request #513 from nguerrera/test-explorer-issue-doc
Document test explorer issues and workaround
2021-05-03 11:39:51 -07:00
Brian Terlson 8c86e04427 Implement alias and enum, remove model = (#504) 2021-05-03 11:14:24 -07:00
Nick Guerrera dcb8f16cbd Guard against fuzz tests being run accidentally 2021-05-03 09:25:30 -07:00
Nick Guerrera 051862aa54 Fix some end-to-end client generation issues (#507)
1. `compile` had lost its success message. I inadvertently deleted it
   a while ago: restored.
2. `generate` was printing undefined as the output path: fixed.
3. `generate` did nothing without --client, required --client for now.
4. `generate` took a long time to do nothing without --language,
   required --language.
5. `generate` a client inside the adl tree, and tsc would to compile
   it: excluded 'adl-output' in tsconfig.

Also routed running of autorest through run helper so you can see the
autorest args we pass using `adl --debug`
2021-04-28 13:31:31 -07:00
Nick Guerrera b93b561fc4 Allow leading +/- in numeric literals and require fractional digits (#503) 2021-04-28 08:02:54 -07:00
Nick Guerrera 9bda6a8fc9 Inform tsc of project-to-project dependencies (#495)
Fixes issues with watch build when a change impacts dependent
projects.

Also fix issues preventing a watch build in VS Code from being
successful due to dist/ or dist-dev/ not being created yet.

With both of these, it is now actually possible to do only rush
update on pristine enlistment, then Ctrl+Shift+B in VS Code as
CONTRIBUTING.md claims.
2021-04-26 14:33:08 -07:00
Nick Guerrera fa575e515e Optimize finishNode calls in parser
Spreading the 3 finishing values turns out to be noticeably cheaper
than spreading the unfinished node.
2021-04-26 08:29:14 -07:00
Nick Guerrera 3ac9719b17 Allow ZWJ and ZWNJ to continue identifiers as specified 2021-04-26 08:29:13 -07:00
Nick Guerrera 5fb28d6378 Fix scanning edge cases and optimize slightly
* Bug fixes
  * tokenValue() was wrong if an identifier ever came right after a
    string literal.
  * There was an incorrect and confusing end-of-file error if file
    ends with numeric literal. Generally hardened and cleaned up EOF
    checking throughout.
  * Digits weren't allowed in identifier with non-ascii characters.

* Perf
  * Add more ASCII fast paths
  * Inline scanUntil everywhere, and simplify each use to what it
    actually needed
  * Avoid eager substring allocation and map lookup for keywords in
    more cases
2021-04-26 08:27:08 -07:00
Nick Guerrera 9063e1b63f Include error code in messages sent from language server 2021-04-25 15:36:30 -07:00
Nick Guerrera 63858dae30 Run ecmarkup with --strict 2021-04-25 15:36:30 -07:00
Nick Guerrera df4b13e4c7 Use `===` 2021-04-25 15:36:30 -07:00
Nick Guerrera a60e5c2096 Pass along warnings and actually write out spec in watch build 2021-04-25 15:36:30 -07:00
Nick Guerrera 8ba26ec85b Rename CharacterCodes to CharCode and use Pascal case for members
Also re-group members with comments
2021-04-25 15:36:15 -07:00
Nick Guerrera 586018e47b Shorten charcode filename 2021-04-24 12:27:26 -07:00
Nick Guerrera c708698a5d Shorten nonascii source file and script names 2021-04-24 12:20:44 -07:00
Nick Guerrera 5de3f5347b Check in a script to regenerate non-ascii identifier maps (#483) 2021-04-23 15:55:31 -07:00
Nick Guerrera 3b35f162c1 Use compilerAssert/throwDiagnostic as appropriate (#480) 2021-04-23 14:19:45 -07:00
Nick Guerrera 848bbd22af Deal with slower CI on Windows (#476)
* Bump mocha timeout from default 2s to 5s
* Run nuget restore in a separate step for better telemetry
2021-04-23 13:46:20 -07:00
Nick Guerrera eef42ffbdf Add API to check if a node or any descendants have parse errors (#479)
* Put empty statements and invalid statements in the tree. We now have
  an invariant that if there is a parse error, there must be a node in
  the tree with an error, and even empty statements can have errors if
  you try to decorate one. All parse tests now check this invariant.

* Refine dumpAST to sort in a more readable order and to print the
  substring of source code with each node.
2021-04-23 13:08:18 -07:00
Nick Guerrera 3a4d123075 Speed up parseExpectedOneOf (#475) 2021-04-22 17:49:54 -07:00
Nick Guerrera 78661fdbe8 Fix bugs with non-ascii identifiers (#474) 2021-04-22 13:13:32 -07:00
Nick Guerrera ea281c601c Convert remaining `<T>` casts to `as T` (#466)
The regex I used in the last round was flawed and missed these.

Also remove some casts where possible, and change TypeInstantiationMap
set function's return type from string to void.
2021-04-21 09:48:52 -07:00
Nick Guerrera 55e7d5e88a Use type checking instead of runtime assert for surrounded list req (#467) 2021-04-21 09:48:37 -07:00
Nick Guerrera 02b84e5857 Stop fuzz test from accidentally running in CI (#463) 2021-04-21 07:34:18 -07:00
Timothee Guerin 4914101cd5 Add NoContentResponse and update CreatedResponse to allow body (#385)
* Add NoContentResponse and update CreatedResponse to allow body

* Add changes

* Remove body from created

* .

* .
2021-04-21 06:39:27 -07:00
Nick Guerrera 5ad8a45c39 Remove dependencies from types.ts to implementation files (#458) 2021-04-20 19:06:35 -07:00
Nick Guerrera 473a04e35a Exclude tests from npm packages (#465) 2021-04-20 16:29:32 -07:00
Nick Guerrera 7414661e5a Import from Types without prefix in parser (#464) 2021-04-20 15:51:28 -07:00
Nick Guerrera bc216196db Add `npm run fuzz` to run parsing fuzz test (#462) 2021-04-20 15:17:56 -07:00
Nick Guerrera db4535a2f3 Use T[] for arrays and as T for casts throughout (#461) 2021-04-20 14:44:19 -07:00
Nick Guerrera 047920f606 Run prettier to organize imports 2021-04-20 11:10:19 -07:00
Nick Guerrera c807d980ba Use prettier organize imports plugin
Also remove unused dev dependencies from **/package.json
2021-04-20 11:01:06 -07:00
Nick Guerrera 223ecb6a7a Fix typo (#455)
Real position of last error should be initialized to an impossible value.
2021-04-20 09:18:07 -07:00
Nick Guerrera a6d9bc552c Implement basic parser error recovery (#453)
With this change, the parser no longer throws when it encounters an
error, but continues on to report subsequent errors to the user as
well.

For now, however, evalADLScript still throws if there are any parse
errors. More work is needed in the parser to represent which nodes
have the errors and so forth before we can meaningfully analyze a
syntax tree for source that had errors.

Our default response to a token that doesn't match our expectation is
to insert a matching token before the offending token. This is
effectively what is happening wherever we have parseExpected() without
checking the return value. Also when we expect an identifier and do
not find one, we insert an identifier with a unique yet unspeakable
name. In fact, anywhere we hit an invalid expression, we insert one of
these identifiers.

Statements are easier to correct than expressions, and our approach
there is different. Every statement in the language begins with a
reserved word, an at-sign, or a semicolon. If the leading token for
statement is none of these, we report an invalid statement starting at
that token and ending immediately before the next token that is one of
these.

There are also case-by-case refinements to this insertion
strategy. For example, we replace errant semicolons with commas in
comma-only delimited lists rather than inserting semicolons in front
of the comma.

In other cases, we take the approach of parsing a grammar that is a
superset of the language specification, augmented with known common
errors. For example, we parse decorators in many more places than
actually allowed (and signal an error still, of course). We do the
same for import statements inside namespaces.

Over time, I expect that we'll need to do more of these more
deliberate and one-off corrections, but this change still performs
relatively well and it provides the foundation for such improvements.

A major challenge with the approach of correction by inserting tokens
is that it can hang the parser such that it keeps inserting tokens
without making forward progress. To mitigate the risk of such bugs,
all list constructs that are susceptible to this are driven by the
same parseList() routine. This routine has an escape hatch in the loop
where it bails and assumes we've hit a bad representation for the end
of the list if any loop iteration fails to make progress.

A trivial example of a construct that would hit this without this
check is `model M { ]`. The parser proceeds as follows in that case:

1. Parse model keyword: OK.
2. Parse model name (M): OK.
3. Parse open brace: OK.
4. Expect property name, see close bracket: ERROR, insert synthetic
   identifier for property name.
5. Expect colon, see close bracket: ERROR, insert colon.
6. Expect property type, see close bracket: ERROR, insert synthetic
   identifier for property type.
7. Expect semicolon, see close bracket: ERROR, insert semicolon.
8. Observe that the position has not advanced after a full loop
   iteration of parsing properties: ERROR, replace with close brace,
   exit loop.

(Note that everywhere I'm saying "insert" or "replace" here, there's
no literal array of tokens that we're mutating, we are just taking the
code paths we would take if those edits were made to the source. There
is rather an implicit "behave as though" replacing/inserting, but that
is really an implementation detail and not part of the logical
algorithm.)

Without the vital step 8, we could convince ourselves that we've
parsed a real property and try to move on to the next one, and do this
over and over again, creating infinitely many synthetically named
properties of synthetically named types!

This change also adjusts many of our error messages, borrowing from
the TypeScript compiler's terse tone for mundane errors.

It also fixes various issues with imprecise or sub-optimal squiggly
locations for various errors.

There are also some ADL team developer productivity improvements in
this change...

The per-test output in Mocha Test Explorer in VS Code now shows the
input source code, the resulting syntax tree, and all parse
diagnostics formatted nicely as the CLI compiler would. The syntax
tree JSON also has boilerplate default-empty things elided and the
start and end positions augmented with line and column number.

Negative parse test cases must now provide regex(es) to match against
the reported diagnostics.

Stack traces in Mocha Test Explorer will now be reported up to 50
frames rather than 10, making it easier to diagnose a stack overflow
in the parser's recursive descent.

A new compilerAssert function is added for asserting something that
should never happen in the compiler. It takes a condition, message,
and optional source node. If the condition is not met, it throws an
AssertionError with the message and if a source node is provided, the
message will be augmented with "occurred while compiling (file) near
line (X) and column (Y)". This is used in only a couple of places
right now. I did not yet scrub the existing throws that could benefit
from this.

If a DiagnosticError or AggregateError occurs in a test, the formatted
diagnostics or inner stack traces are included in the Mocha Test
Explorer per-test output. This is done because tests don't have the
CLI catch handler that has to take special steps for these special
errors.

Note that for all Mocha Test Explorer output improvements above, if
you prefer to run tests on the command line, you can also set
environment variable ADL_VERBOSE_TEST_OUTPUT=true and get all of the
output spewed to the console.

An issue with the typing of `messages` allowed typos when used is
fixed, and the fix makes `Message.X` a `Message` and if you hover over
X in the IDE, you will see the message code, severity and text.

Finally, there's also a minor correction in the tutorial to account
for parenless decorators having been removed from the language.
2021-04-20 09:04:45 -07:00
David Wilson 56d97cba06 Prepare release for ADL 0.9.0, etc 2021-04-20 08:24:59 -07:00
Nick Guerrera 73f89b51a0 Small test infrastructure improvements
* Update to latest mocha

* Use source-map-support to get .ts in stack traces.

  This is supposed to also allow mocha explorer to navigate to .ts,
  but it isn't working. :(

* Enable verbose test logging when run through mocha explorer where
  the output is associated with individual tests and spam is not a
  concern. Prevents needing to uncomment code to investigate failures.
  On the command line, you can also set ADL_VERBOSE_TEST_OUTPUT=true
  in the environment to get all of this logging to the console.

* Set things up to allow more than one project in mocha explorer
2021-04-15 10:37:23 -07:00
Nick Guerrera 31fa512b67 Bump typescript version in one project that was missed 2021-04-15 10:30:20 -07:00
Timothee Guerin ca772c1b3e Add writeFile to CompilerHost to virtualize writing output. (#442) 2021-04-15 10:28:53 -07:00
David Wilson 94db077ee3 Merge pull request #436 from daviwil/arm-modelling-redesign
Redesign ARM service modelling to cover many more cases
2021-04-15 08:41:31 -07:00
David Wilson 6380ce6a02 Redesign ARM modelling using new @armResource decorator
- Add new @armResource, @armResourceOperations, and @armStandard* decorators
- Add new base types for ARM resources: TrackedResource, ExtensionResource, ProxyResource
- Trim base service namespace from parameter definition names
- Fix issue where dynamic namespaces were not evaluated
- Add _____ sample
- Add _____ sample
- Update _____ and _____ samples
2021-04-15 08:35:42 -07:00
Brian Terlson bd3934b7fb Implement optional prefix | and &, fix trailing comma bug (#446) 2021-04-14 09:57:08 -07:00
Nick Guerrera 7eb3b821a7 Update typescript, allow VS Code to use workspace version (#444) 2021-04-13 12:58:36 -07:00
Nick Guerrera 4d9257d900 Improve diagnostics for out-of-date VS install (#443)
* Warn if VS has older than minimum required version, and skip local build
* Ensure more descriptive warnings and errors go to `rush` summary output
* Add escape hatch ADL_SKIP_VS_BUILD env var to force VS build to skip
2021-04-13 12:38:51 -07:00
Nick Guerrera 616642b607 Housekeeping (#439)
* Add LICENSE file to root and all packages

* Standardize tsconfig.json files, invert default to esnext

* Standardize package.json files, putting metadata first, impl last

* Reduce number of stub package.json files for type=module by putting
  type=module one-level up where possible

* Standardize dependency version ranges: ~ to external, exact for
  adl-* to adl-*. The latter is a prerelease policy to avoid having to
  debug mismatches while things are churning and breaking frequently.

* `rush update --full` to pick up patches of our dependencies

* Use consistent casing for CONTRIBUTING.md and README.md

* Fix squigglies on some rush json files with comments in VS Code

* Remove some unused dependencies

* Remove some stale/unused "files" entries from package.json files

* Remove unnecessary placeholder test scripts to keep some noise out
  of `rush test`
2021-04-13 12:17:03 -07:00
Nick Guerrera ca79ff5e51 Merge pull request #441 from nguerrera/tuple-syntax-highlighting
Handle tuple expressions in syntax highlighting
2021-04-10 11:01:00 -07:00
Nick Guerrera a14b5f62cc Use more accurate key name for identifier expressions 2021-04-10 09:57:48 -07:00
Nick Guerrera 55f3910f73 Handle tuple expressions in syntax highlighting 2021-04-10 09:46:36 -07:00
Nick Guerrera dcc9fb1659 Stamp VS vsix and assembly with version from package.json 2021-04-09 17:51:29 -07:00
Nick Guerrera 0f2a5e9c48 Move VS vsix to root of npm package
Hide ugly bin/Release implementation detail
2021-04-09 17:36:06 -07:00
Nick Guerrera 33cf9b6dca Log output from ADL language server to VS output window pane (#437)
* Log output from ADL language server to VS output window pane
* Use nullable
* Turn up warnings; treat warnings as errors
* Launch petstore sample on F5 to reduce iteration time
2021-04-08 16:52:26 -07:00
Nick Guerrera 24c7bd92a6 Improve watching of tmlanguage and spec (#435)
* Fix null ref bug that broke spec generation
* Move processing in-proc to speed things up further
* Reduce polling interval to 200 ms
* Log diagnostics with appropriate source file
* Make output prettier
* Fix some breakage in launch.json after some things moved around
2021-04-08 16:48:26 -07:00
Nick Guerrera abdb700b16 Speed up watching by using fewer process hops 2021-04-06 15:35:00 -07:00
Nick Guerrera 009d15928a Inline grammar into spec source to fix link issue 2021-04-06 13:44:54 -07:00
Nick Guerrera 0d9e383315 Start language specification (#426)
* Initial commit of generated docs/spec.html with just grammar for now
* Add spec generation on source change to VS Code watch tasks
* Move tmlanguage generation from pre-lauch to watch task
* Cleanup .gitattributes
 * Automatic text/binary distinction
 * Get GitHub to collapse generated files by default
2021-04-06 12:06:43 -07:00
Brian Terlson 9d9302d9c1 Update ADL to 0.8.0 (#429) 2021-04-05 18:31:06 -07:00
Brian Terlson 3822a9daf8 new package names :( (#427) 2021-04-05 17:54:09 -07:00
Brian Terlson 4065f11f5d Remove parenless decorators (#425) 2021-04-05 16:01:20 -07:00
Brian Terlson 6079cf299f Add libraries using npm, create @adl/rpaas, @adl/rest, @adl/openapi (#422) 2021-04-05 13:18:00 -07:00
David Wilson 69dc7f8c4f Add --option parameter for passing arbitrary ADL options 2021-04-05 11:02:12 -07:00
David Wilson b1da0b2392 Add `strictCommands` to CLI configuration 2021-04-05 10:32:09 -07:00
David Wilson 8216572ff8 Add `--arm-types-path` parameter for specifying ARM types.json path 2021-04-05 10:19:03 -07:00
David Wilson 8551f4cea2 Add common ARM parameter definitions for resource operations 2021-04-05 10:19:03 -07:00
Nick Guerrera d24d5cab91 Simplify prettier setup (#418)
Use a global command that checks the whole repo to avoid having to repeat the
complex commands in each project, and to prevent some files from escaping the
check.

NOTE: This removes per-project `npm run format` and `npm run check-format`.
Use `rush format` and `rush check-format`.
2021-04-02 15:01:06 -07:00
Nick Guerrera 310942c07d Don't rebuild on pack/publish (#417) 2021-04-02 14:49:28 -07:00
Nick Guerrera 8568e3c2dc Merge pull request #414 from nguerrera/vs-dev-server
* Move source files out of roots and tidy tsconfig
* Use local build of adl-server when debugging VS extension
2021-04-02 13:49:41 -07:00
Nick Guerrera 9db0568a45 Use local build of adl-server when debugging VS extension 2021-04-02 13:41:40 -07:00
Nick Guerrera 7b0b01ac99 Move source files out of roots and tidy tsconfig 2021-04-01 16:44:38 -07:00
David Wilson 2baf28ce84 Merge pull request #410 from daviwil/openapi-security
Add default ARM security details in emitted OpenAPI specs
2021-04-01 15:38:49 -07:00
David Wilson e9fd428328 Standardize service namespace management and handling 2021-04-01 14:30:51 -07:00
Nick Guerrera a7017bb5d5 Add commands to install and uninstall VS classic extension (#412) 2021-04-01 12:28:50 -07:00
Nick Guerrera b37b35a25c Don't deploy VS extension on release builds (#411) 2021-03-31 18:02:07 -07:00
Nick Guerrera 3be20331b5 Bump versions 2021-03-31 15:05:01 -07:00
Nick Guerrera 9e082a5470 Add adl-vs to build and PR validation (#407) 2021-03-31 14:50:42 -07:00
Nick Guerrera 09f7078699 Initial implementation of Visual Studio (classic) extension 2021-03-30 12:45:58 -07:00
Nick Guerrera 48f2db5440 Switch to plist format for textmate grammar 2021-03-30 12:45:58 -07:00
Nick Guerrera a710be4a43 Build script cleanup (#399)
* Fix `rush dogfood` without prior build
* Fix not being able to run other commands while `rush watch` is running
* Switch all build scripts to esm
* Reuse "run" helper throughout for spawning processes with logging + error handling
* Remove `rush compile` and `rush pack`, not really needed
* Remove `rush clean`, didn't do anything as our projects don't have clean scripts
* Clean up `rush --help` to show which commands are custom with better descriptions
2021-03-30 12:39:09 -07:00
Nick Guerrera b0938f4978 Add import and using to syntax highlighting (#403)
Also fix bug with type parameters/arguments stopping coloring after
first parameter or argument.
2021-03-30 12:26:12 -07:00
Brian Terlson 3d5410354f Implement import statements (#397) 2021-03-29 18:00:11 -07:00
David Wilson 5f8b5c3ca9 Merge pull request #388 from daviwil/service-metadata 2021-03-29 16:01:45 -07:00
David Wilson dfd77d4898 Fix formatting issues 2021-03-29 15:56:04 -07:00
David Wilson 6960087190 Strip namespace in OpenAPI definitions when there are no conflicts 2021-03-29 15:56:04 -07:00
Nick Guerrera 0a344db306 Add configuration option for adl-server path (#395) 2021-03-29 13:51:26 -07:00
David Wilson 40e6004409 Generate ARM TrackedResource namespace inside of parent namespace 2021-03-26 17:06:38 -07:00
Brian Terlson 230c66b357 Fix referencing symbols found in parent ns of top blockless ns 2021-03-26 17:05:48 -07:00
Brian Terlson a2a5a91a1f fix immediate bug 2021-03-26 17:05:28 -07:00
Brian Terlson 6c2c434c31 add some ns test validations 2021-03-26 17:04:58 -07:00
David Wilson eaabbcba45 Propagate namespace scope in binder 2021-03-26 14:24:58 -07:00
David Wilson 9cd6611872 Add `@produces` and `@consumes` for global produces/consumes types 2021-03-26 13:42:16 -07:00
David Wilson fa5cde5972 Add `@serviceTitle` and `@serviceVersion` top-level service metadata 2021-03-26 13:42:16 -07:00
Brian Terlson 72afcd17ba Add using statement (#391) 2021-03-26 12:40:14 -07:00
Nick Guerrera 15906bfa8d Prepare publish 2021-03-26 10:07:53 -07:00
Nick Guerrera 3f91bdda96 Fix hard-coding of adl and wasm file resolution 2021-03-26 10:06:18 -07:00
Brian Terlson 1fcc7dd630 Fix id lookup with blockless namespaces (#389) 2021-03-26 09:41:02 -07:00
David Wilson cf8657b155 Add `@numeric` decorator for marking numeric intrinsic types 2021-03-25 14:49:55 -07:00
David Wilson 4efa892716 Change the Unix permissions of cmd launcher files 2021-03-25 14:38:38 -07:00
David Wilson 6cf505ac71 Add `@minValue` and `@maxValue` decorators for numeric types 2021-03-25 14:38:38 -07:00
David Wilson 1ca2a4a549 Enable the use of recursive type references in model definitions 2021-03-25 09:16:12 -07:00
Brian Terlson dc240c6c82 Namespace merging, dotted namespaces, blockless namespaces, tests (#375)
Also adds a noEmit compiler option.
2021-03-24 19:20:20 -07:00
Nick Guerrera b6bbffb873 Include language-configuration.json in vsix (#383)
This was preventing commenting and indenting operations in VS Code from
working as expected when run from VSIX (as opposed to F5) since the file
was not actually put in the package.
2021-03-24 14:32:22 -07:00
Nick Guerrera d431e83fbf A bit more s/textmate/tmlanguage-generator/ (#382) 2021-03-24 14:31:01 -07:00
Nick Guerrera 672cb699fa Extract textmate generator to helper library (#380) 2021-03-24 13:20:54 -07:00
David Wilson 7034d33f78 Merge pull request #374 from daviwil/add-read-only 2021-03-23 15:02:23 -07:00
David Wilson c9185722f0 `visibility` decorator takes multiple values, emit `x-ms-mutability` 2021-03-23 14:03:46 -07:00
Nick Guerrera b4be0340a9 Fix rollup warning filter typo
Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2021-03-23 10:05:42 -07:00
Nick Guerrera 76a95d7b84 Add dogfood command 2021-03-22 21:31:01 -07:00
Nick Guerrera 3286cd2e33 Bump versions 2021-03-22 21:28:18 -07:00
Nick Guerrera 0927bbd0c7 Add commands to install/uninstall VS Code extension 2021-03-22 21:18:19 -07:00
Nick Guerrera 01cd73067a Slight CLI refactor to make it easier to add another command 2021-03-22 17:53:11 -07:00
Nick Guerrera a1ab73d794 Remove unecessary array from rollup config 2021-03-22 17:53:11 -07:00
Nick Guerrera 1e9e8255f1 Move vscode-languageclient to dev dependency 2021-03-22 17:53:11 -07:00
David Wilson 872993ffcc Rename all date and time intrinsics to follow new JS naming pattern 2021-03-22 13:53:26 -07:00
David Wilson dcb93e9ce9 Add `time` intrinsic type 2021-03-22 13:11:05 -07:00
Nick Guerrera fe6bc05b7d Generate ThirdPartyNotices.txt 2021-03-18 08:51:36 -07:00
Nick Guerrera e80311d9af Move language server out of extension and bundle the rest 2021-03-18 08:51:36 -07:00
Nick Guerrera 794c8f3b06 Remove circular dependency + other minor rollup compat 2021-03-17 09:46:48 -07:00
Nick Guerrera 79595a1f58 Add LICENSE to adl-vscode 2021-03-17 09:46:48 -07:00
Nick Guerrera a180a0ff44 Bump versions 2021-03-17 09:46:48 -07:00
Nick Guerrera e43a5495fc Fix VSIX packaging and add PR validation 2021-03-11 16:37:56 -08:00
Nick Guerrera a424d2d68b Work around rush bug 2021-03-11 16:37:56 -08:00
Nick Guerrera 49385ddfb5 Introduce language server and add live parse errors to VS Code 2021-03-11 16:37:51 -08:00
Nick Guerrera 0975c022fc Use wasm version of oniguruma (#366) 2021-03-11 14:28:42 -08:00
David Wilson 25fa27a36e Prepare @azure-tools/adl 0.3.0 for publishing 2021-03-11 11:15:12 -08:00
Nick Guerrera d6b42466eb Fix off-by-one error preventing empty string literals (#361) 2021-03-09 15:01:01 -08:00
Nick Guerrera 50954d6b80 Fix typo in format scripts 2021-03-05 12:55:30 -08:00
Nick Guerrera 3fd267eed1 Keep diagnostic data structured in DiagnosticError (#358) 2021-03-05 12:05:24 -08:00
Nick Guerrera 346670ab43 Track extension version with rush change (#322) 2021-03-05 12:04:55 -08:00
Nick Guerrera b5ae16c98c Run prettier and check formatting on more files (#348) 2021-03-05 12:01:35 -08:00
Brian Terlson f9a2d3ce7b move some throwDiag to regular exceptions 2021-03-04 15:36:51 -08:00
Brian Terlson e993c2355c format 2021-03-04 13:50:24 -08:00
Brian Terlson 3773cb1c04 Fix type name generation 2021-03-04 13:44:04 -08:00
Brian Terlson ca96f9cf3b It's ok to run decorators on non-templated models 2021-03-04 12:29:24 -08:00
Brian Terlson 47866d53d8 Finish namespace implementation, fix circularity 2021-03-04 11:57:26 -08:00
David Wilson 55ac2208f5 Implement nested namespace parsing, rename some core types 2021-03-04 10:05:37 -08:00
Brian Terlson d617fe3000 Remove ast-node type caching, fix bugs, refactor. 2021-03-03 17:12:30 -08:00
James Casey 865bca432f Add tag decorator
This applies to both namespaces and operations.  The tags for a
operation is the union of the oeration and namespace tags.

Empty tags sections are added to an operation if no tags are specified.

Sample usage:
```
@tag("foo")
@tag("bar")
namespace test {
  @tag("my_ops")
  op create(@path id:int32): null;
}
```
2021-03-02 14:03:50 -08:00
Nick Guerrera 3ddff8ef08 Make sure to build before packaging (#318) 2021-03-01 14:16:59 -08:00
Nick Guerrera d0dbe22e0c Introduce vscode extension with syntax highlighting (#314) 2021-03-01 13:35:48 -08:00
Nick Guerrera dbe9ffd544 Prettier (#316)
* Setup prettier with config borrowed from azure-sdk-for-js
* Run prettier to format existing code
* Turn format on save on so VS Code with prettier will auto-format
* Add rush check-format / rush format to check formatting / run prettier on whole repo
* Add check-format to PR validation
2021-03-01 12:55:14 -08:00
Brian Terlson 9094a8a7c8 Add nostdlib (#317) 2021-03-01 12:33:35 -08:00
Brian Terlson 4c67999669 Fix class extends t (#315) 2021-03-01 11:37:36 -08:00
Nick Guerrera 02141ec9ba Improve programmer productivity with diagnostics (#301)
1. Make throwDiagnostic take the target directly and figure out the
   location rather than having the programmer call getSourceLocation.

2. If getting location or formatting message fails, include as much of
   the diagnostic as possible in the internal compiler error.
2021-02-16 10:41:51 -08:00
Nick Guerrera ba844ea8e5 Log source location with all errors (#295)
Everywhere we throw an error now reports a location. Use
throwDiagnostic plus getSourceLocationOfXxx helpers going forward
for new errors. (We still need to do error recovery and not just
throw at the first sign of trouble, but that isn't part of this
initial pass.)

Fix duplicate name reporting in binder to report duplicates in
the same file as an error and to report locations of all
duplicates up to the first bound source file that introduced at
least one.

Fix issue where failed compilation was saying "Compilation
completed successfully" and ensure process exits with non-zero
code on failure.
2021-02-12 15:33:02 -08:00
Brian Terlson 08cc454619 Fix language.md conflicT 2021-02-12 14:34:39 -08:00
Brian Terlson 4709e4db1f move visibility decorators into lib 2021-02-12 14:32:32 -08:00
Brian Terlson 6fd5cb1757 Add better error message 2021-02-12 14:32:31 -08:00
Brian Terlson 632ff0840e move to explicit body for Ok<T>, support explicit body in openapi emitter 2021-02-12 14:32:31 -08:00
Brian Terlson 04129fd15a cleanup 2021-02-12 14:32:31 -08:00
Brian Terlson abce858641 cleanup 2021-02-12 14:32:31 -08:00
Brian Terlson fcbb7603ef Implement #276 composition reform 2021-02-12 14:32:27 -08:00
Nick Guerrera 2a7e9394d5 Update to grammarkdown 3.1.2 (#296)
Fixes issue with git warnings about CRLF
2021-02-12 14:01:34 -08:00
Nick Guerrera a0ea765fbf Add optional properties and missing punctuation to grammar (#289) 2021-02-10 11:26:10 -08:00
Nick Guerrera a8b5456762 Remove some casts (#283) 2021-02-10 11:24:53 -08:00
David Wilson 38f915eb87 Merge pull request #288 from daviwil/testserver-media-types
Add converted autorest.testserver media-types spec
2021-02-10 09:36:58 -08:00
David Wilson 289c504a82 Enable minLength and maxLength to be applied to model properties 2021-02-09 16:16:28 -08:00
Nick Guerrera 1dad0e6bfb Include source file path in parse error log 2021-02-09 14:03:10 -08:00
Nick Guerrera 48f1f7c633 Turn off eslint, format on save (#284) 2021-02-09 09:42:34 -08:00
Nick Guerrera 2418aa6f8d Add back line and column tracking (#282) 2021-02-08 15:48:53 -08:00
David Wilson ab08676c37 Fix namespace examples in unit tests 2021-02-08 11:49:56 -08:00
David Wilson 4f704c9cc3 Add `op` keyword for namespace properties 2021-02-08 11:45:07 -08:00
David Wilson f056c012e4 Update grammar file to reflect interface -> namespace 2021-02-08 11:44:07 -08:00
David Wilson 73ddb6858b Change 'interface' keyword to 'namespace' 2021-02-08 11:44:05 -08:00
Nick Guerrera 3198caebe3 Refactor scanner to use less state (#281)
The scanner was doing a lot of work per character. While this may have
been a performance problem, the motivation here is maintainability. This
change makes it so that advancing by one character is simply Scanner.position++.
It also does more work lazily: allocating substrings on demand.

Highlights:

* Remove unused tokens
* Rename Kind to Token
* Remove token position map
* Remove character size bookkeeping
* Remove (ch, chNext, chNext) state
* Convert class to closure

Note: Line and column tracking was temporarily removed to facilitate
refactoring and will be re-added in the following change.
2021-02-08 11:38:10 -08:00
David Wilson c534f63795 Rename types with -Response suffix, add Location header model 2021-02-08 10:03:31 -08:00
David Wilson 7f8175a335 Templatize Created response 2021-02-04 16:25:00 -08:00
David Wilson b27d974e66 Add some more standard HTTP response models 2021-02-04 16:19:36 -08:00
David Wilson ad374b2ae5 Remove @doc string for Ok<T> 2021-02-04 16:12:01 -08:00
David Wilson 485c63c9e0 Add a standard Ok<T> type to rest.adl 2021-02-04 16:05:59 -08:00
David Wilson 3e5ff9af98 Add intrinsic null type, null unions, and emit x-nullable in OpenAPI 2021-02-04 15:16:17 -08:00
David Wilson 419ca7cb41 Add script and PR step to check sample output for regressions 2021-02-04 15:12:55 -08:00
David Wilson baab8f3d38 Merge pull request #273 from daviwil/parameterize-language
Add --language parameter for generate command
2021-02-02 15:56:15 -08:00
David Wilson 2f9ba63276 Remove hardcoded @autorest/core version (for now) 2021-02-02 11:02:54 -08:00
Nick Guerrera 0d626a9f6d Support arrays of arrays and parenthesized expressions (#272)
Also:
* Document template parameters in grammar
* Document empty statement in grammar
* Tighten MemberExpression (conservatively for now) to just apply to identifiers
* Use OrHigher convention in grammar and parser
2021-02-01 15:47:24 -08:00
David Wilson 3f53fd611e Update AutoRest version 2021-02-01 15:14:29 -08:00
David Wilson e01bd7b9be Add --language parameter for generate command 2021-02-01 15:14:29 -08:00
David Wilson bd988b2176 Merge pull request #269 from daviwil/add-primitives
Add byte and datetime primitives
2021-01-28 15:28:14 -08:00
David Wilson 6eb7e6d09c Merge pull request #270 from daviwil/add-rest-subpaths
Update rest and openapi libraries to support verb decorator subpaths
2021-01-28 15:27:56 -08:00
David Wilson c2bfc505bd Improve support for float and double types 2021-01-28 15:22:48 -08:00
David Wilson d11f7ed250 Update rest and openapi libraries to support verb decorator subpaths 2021-01-28 15:12:21 -08:00
David Wilson 8b75185f3b Add byte primitive type 2021-01-28 15:05:28 -08:00
David Wilson 992e18becb Add datetime primitive type 2021-01-28 14:22:21 -08:00
David Wilson 85a911b470 Prepare packages and changelogs for release 2021-01-28 13:30:15 -08:00
David Wilson 79ff089c32 Fix path resolution when loading decorator modules 2021-01-28 11:10:12 -08:00
David Wilson 6343970170 Bump ADL to 0.2.0 and establish changelog 2021-01-27 13:49:45 -08:00
David Wilson 6f3b1430cb Constrain the set of files included in npm releases 2021-01-25 14:40:29 -08:00
Nick Guerrera 6bbeb6949b Merge pull request #256 from nguerrera/grammar-cleanup
Remove some redundant language constructs
2021-01-25 14:13:23 -08:00
David Wilson 339269cb6a Require Node 14 for ECMAScript module support 2021-01-25 13:24:08 -08:00
Nick Guerrera a252cadc18 Remove square bracket alternate decorator syntax 2021-01-25 12:11:06 -08:00
Nick Guerrera a9e636432a Standardize on only double quotes for string literals 2021-01-25 12:05:32 -08:00
Nick Guerrera 74391e4540 Clean up numeric literal handling in scanner
* Document binary literals in grammar
* Remove tolerance of uppercase 0B, 0X, and E for exponent
* Remove tolerance of leading decimal point
2021-01-25 11:37:54 -08:00
Nick Guerrera 354592fbb2 Remove `alias` statement, prefer `model =` 2021-01-25 10:46:34 -08:00
David Wilson 7fafee3978 Pass through AutoRest exit code on code generation error 2021-01-22 16:38:07 -08:00
David Wilson ce89aa8880 Improve basic CLI output, add --version parameter 2021-01-22 16:26:19 -08:00
David Wilson dfdd101202 Move cli.ts to compiler/ to keep it out of stdlib folder 2021-01-22 16:26:19 -08:00
David Wilson f97bbffe71 Prepare @azure-tools/adl release automation and add README 2021-01-22 16:26:17 -08:00
David Wilson (AZURE SDK) ba9e579b11 Improve resolve of AutoRest dependency path 2021-01-22 16:25:43 -08:00
Nick Guerrera cd6d3c2015 Update grammar to reflect current state, use grammarkdown (#245)
Update language grammar to reflect current state of the language.

Grammarkdown is now used and run during the build. It will error
out if the grammar is invalid in ways such as a reference to
something that isn't defined.

Other minor changes:
* Fix up some VS Code build and launch settings
* Remove stale references to VS Code extension projections
2021-01-22 14:30:26 -08:00
David Wilson (AZURE SDK) 524e124c66 Add more generic @list decorator for pageable operations 2021-01-22 14:05:25 -08:00
David Wilson (AZURE SDK) 7b193321cf Install AutoRest as dependency and launch it from node_modules 2021-01-22 11:59:49 -08:00
David Wilson (AZURE SDK) 7a71fdc46f Launch AutoRest correctly on Windows 2021-01-22 11:54:27 -08:00
David Wilson (AZURE SDK) e5118270f2 Remove VisbilityLevels type union 2021-01-22 11:48:50 -08:00
David Wilson c4979e7d27 Add @visibility decorator 2021-01-21 07:14:18 -08:00
David Wilson dad53a5c05 Fix minor issues in CLI interface 2021-01-21 07:14:18 -08:00
David Wilson b04acc8a08 Add @secret decorator, minor cleanup 2021-01-21 06:42:46 -08:00
David Wilson 397e30c4bc Add 'generate' command for generating a client SDK from ADL 2021-01-20 16:28:57 -08:00
David Wilson 0431bd90d7 Add evalAdlScript API for full evaluation of virtual script files 2021-01-20 15:07:48 -08:00
David Wilson 8dc9aa22be Write out exception stack trace when --debug is passed 2021-01-20 14:25:31 -08:00
David Wilson 1e98dce0f9 Add ARM decorator library and ADL types 2021-01-20 11:26:48 -08:00
David Wilson c6a11b6f7c Correctly handle compile() as a promise 2021-01-14 16:17:55 -08:00
David Wilson 6e06caacd2 Enable @format, @minLength, @maxLength decorators; fix OpenAPI types 2021-01-14 16:17:10 -08:00
David Wilson 3035ec06fb Store the assignmentType when creating a ModelType from assignment 2021-01-14 16:13:21 -08:00
David Wilson 121f600f6e Add bug number for _delete issue 2021-01-14 09:17:06 -08:00
David Wilson 9da578a5d5 Add decorators for HTTP verbs (get, put, post, patch, delete) 2021-01-13 15:42:43 -08:00
David Wilson a179c95e13 Add basic ADL command line interface 2021-01-11 17:09:09 -08:00
David Wilson 7750bc98b7 Rename 'packages/language' to 'packages/adl' 2021-01-05 16:39:35 -08:00
David Wilson 23b5778230 Rename 'adl' folder to 'packages' 2021-01-05 16:39:00 -08:00