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

324 Коммитов

Автор SHA1 Сообщение Дата
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 cfacbf8cba Merge pull request #454 from Azure/publish/0.9.0
Prepare release for ADL 0.9.0, etc
2021-04-20 08:32:47 -07:00
David Wilson 56d97cba06 Prepare release for ADL 0.9.0, etc 2021-04-20 08:24:59 -07:00
Nick Guerrera 7d13fa1a53 Merge pull request #452 from nguerrera/mocha-improvements
Small test infrastructure improvements
2021-04-15 13:35:38 -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 164f4561b3 Merge pull request #440 from nguerrera/vsix-version
* Move VS vsix to root of npm package
* Stamp VS vsix and assembly with version from package.json
2021-04-10 09:52:51 -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 2b9ebdae64 Merge pull request #431 from nguerrera/inline-grammar
Inline grammar into spec source, speed up watch
2021-04-06 17:04:19 -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 d7b5d8e0d5 Add tutorial (#424) 2021-04-05 16:44:40 -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 e586f71251 Merge pull request #419 from daviwil/ref-common-types
Add initial support for referencing model and parameter definitions from ARM common types
2021-04-05 11:09:03 -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 d116d0c064 Merge pull request #408 from nguerrera/publish-vs-extension
Publish VS extension
2021-03-31 16:46:47 -07:00
Nick Guerrera 3be20331b5 Bump versions 2021-03-31 15:05:01 -07:00