Upload original JAVA语言程序设计 course files (part 23)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/README.md +69 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/SECURITY.md +41 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/LICENSE.md +9 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/README.md +67 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/SECURITY.md +41 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/lib/umd/utils.d.ts +58 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/lib/umd/utils.js +123 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/package.json +43 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/package.json +50 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/thirdpartynotices.txt +49 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/dist/node/jsonServerMain.js +0 -0
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/README.md +42 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/dist/browser.js +103 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/dist/main.d.ts +130 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/dist/main.js +151 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/dist/tsdoc-metadata.json +11 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/package.json +50 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/CHANGELOG.md +72 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/LICENSE.md +21 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/README.md +362 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/SECURITY.md +41 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/impl/parser.js +632 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/main.d.ts +349 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/main.js +178 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/impl/parser.js +655 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/main.d.ts +349 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/main.js +194 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/package.json +37 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/License.txt +11 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/README.md +69 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/browser.d.ts +6 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/browser.js +7 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/browser/main.d.ts +17 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/browser/main.js +76 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/browser/ril.d.ts +12 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/browser/ril.js +156 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/api.d.ts +14 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/api.js +82 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/cancellation.d.ts +32 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/cancellation.js +96 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/connection.d.ts +365 -3
- Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/connection.js +1220 -3
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/README.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# vscode-html-languageservice
|
| 2 |
+
HTML language service extracted from VSCode to be reused, e.g in the Monaco editor.
|
| 3 |
+
|
| 4 |
+
[](https://www.npmjs.org/package/vscode-html-languageservice)
|
| 5 |
+
[](https://npmjs.org/package/vscode-html-languageservice)
|
| 6 |
+
[](https://github.com/microsoft/vscode-html-languageservice/actions)
|
| 7 |
+
[](https://opensource.org/licenses/MIT)
|
| 8 |
+
|
| 9 |
+
Why?
|
| 10 |
+
----
|
| 11 |
+
|
| 12 |
+
The _vscode-html-languageservice_ contains the language smarts behind the HTML editing experience of Visual Studio Code
|
| 13 |
+
and the Monaco editor.
|
| 14 |
+
|
| 15 |
+
- *doComplete* / *doComplete2* (async) provide completion proposals for a given location.
|
| 16 |
+
- *setCompletionParticipants* allows participant to provide suggestions for specific tokens.
|
| 17 |
+
- *doHover* provides hover information at a given location.
|
| 18 |
+
|
| 19 |
+
- *format* formats the code at the given range.
|
| 20 |
+
- *findDocumentLinks* finds all links in the document.
|
| 21 |
+
- *findDocumentSymbols* finds all the symbols in the document.
|
| 22 |
+
- *getFoldingRanges* return folding ranges for the given document.
|
| 23 |
+
- *getSelectionRanges* return the selection ranges for the given document.
|
| 24 |
+
...
|
| 25 |
+
|
| 26 |
+
For the complete API see [htmlLanguageService.ts](./src/htmlLanguageService.ts) and [htmlLanguageTypes.ts](./src/htmlLanguageTypes.ts)
|
| 27 |
+
|
| 28 |
+
Installation
|
| 29 |
+
------------
|
| 30 |
+
|
| 31 |
+
npm install --save vscode-html-languageservice
|
| 32 |
+
|
| 33 |
+
Development
|
| 34 |
+
-----------
|
| 35 |
+
|
| 36 |
+
- clone this repo, run `npm i``
|
| 37 |
+
- `npm test` to compile and run tests
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
How can I run and debug the service?
|
| 41 |
+
|
| 42 |
+
- open the folder in VSCode.
|
| 43 |
+
- set breakpoints, e.g. in `htmlCompletion.ts`
|
| 44 |
+
- run the Unit tests from the run viewlet and wait until a breakpoint is hit:
|
| 45 |
+

|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
How can I run and debug the service inside an instance of VSCode?
|
| 49 |
+
|
| 50 |
+
- run VSCode out of sources setup as described here: https://github.com/Microsoft/vscode/wiki/How-to-Contribute
|
| 51 |
+
- link the folder of the `vscode-html-languageservice` repo to `vscode/extensions/html-language-features/server` to run VSCode with the latest changes from that folder:
|
| 52 |
+
- cd `vscode-html-languageservice`, `npm link`
|
| 53 |
+
- cd `vscode/extensions/html-language-features/server`, `npm link vscode-html-languageservice`
|
| 54 |
+
- run VSCode out of source (`vscode/scripts/code.sh|bat`) and open a `.html` file
|
| 55 |
+
- in VSCode window that is open on the `vscode-html-languageservice` sources, run command `Debug: Attach to Node process` and pick the `code-oss` process with the `html-language-features` path
|
| 56 |
+

|
| 57 |
+
- set breakpoints, e.g. in `htmlCompletion.ts`
|
| 58 |
+
- in the instance run from sources, invoke code completion in the `.html` file
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
License
|
| 62 |
+
-------
|
| 63 |
+
|
| 64 |
+
(MIT License)
|
| 65 |
+
|
| 66 |
+
Copyright 2016-2023, Microsoft
|
| 67 |
+
|
| 68 |
+
`src/languageFacts/data/webCustomData.ts` (shipped as `lib/esm/languageFacts/data/webCustomData.ts` and `lib/umd/languageFacts/data/webCustomData.ts`)
|
| 69 |
+
are built upon content from [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web) and distributed under CC BY-SA 2.5.
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/SECURITY.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.8 BLOCK -->
|
| 2 |
+
|
| 3 |
+
## Security
|
| 4 |
+
|
| 5 |
+
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
|
| 6 |
+
|
| 7 |
+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
|
| 8 |
+
|
| 9 |
+
## Reporting Security Issues
|
| 10 |
+
|
| 11 |
+
**Please do not report security vulnerabilities through public GitHub issues.**
|
| 12 |
+
|
| 13 |
+
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
|
| 14 |
+
|
| 15 |
+
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
|
| 16 |
+
|
| 17 |
+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
|
| 18 |
+
|
| 19 |
+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
| 20 |
+
|
| 21 |
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
| 22 |
+
* Full paths of source file(s) related to the manifestation of the issue
|
| 23 |
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
| 24 |
+
* Any special configuration required to reproduce the issue
|
| 25 |
+
* Step-by-step instructions to reproduce the issue
|
| 26 |
+
* Proof-of-concept or exploit code (if possible)
|
| 27 |
+
* Impact of the issue, including how an attacker might exploit the issue
|
| 28 |
+
|
| 29 |
+
This information will help us triage your report more quickly.
|
| 30 |
+
|
| 31 |
+
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
|
| 32 |
+
|
| 33 |
+
## Preferred Languages
|
| 34 |
+
|
| 35 |
+
We prefer all communications to be in English.
|
| 36 |
+
|
| 37 |
+
## Policy
|
| 38 |
+
|
| 39 |
+
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
|
| 40 |
+
|
| 41 |
+
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/LICENSE.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) Microsoft
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 6 |
+
|
| 7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 8 |
+
|
| 9 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/README.md
CHANGED
|
@@ -1,3 +1,67 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## vscode-uri
|
| 2 |
+
|
| 3 |
+
[](https://travis-ci.org/Microsoft/vscode-uri)
|
| 4 |
+
|
| 5 |
+
This module contains the URI implementation that is used by VS Code and its extensions.
|
| 6 |
+
It has support for parsing a string into `scheme`, `authority`, `path`, `query`, and
|
| 7 |
+
`fragment` URI components as defined in: http://tools.ietf.org/html/rfc3986
|
| 8 |
+
|
| 9 |
+
```
|
| 10 |
+
foo://example.com:8042/over/there?name=ferret#nose
|
| 11 |
+
\_/ \______________/\_________/ \_________/ \__/
|
| 12 |
+
| | | | |
|
| 13 |
+
scheme authority path query fragment
|
| 14 |
+
| _____________________|__
|
| 15 |
+
/ \ / \
|
| 16 |
+
urn:example:animal:ferret:nose
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
## Usage
|
| 20 |
+
|
| 21 |
+
```js
|
| 22 |
+
import { URI } from 'vscode-uri'
|
| 23 |
+
|
| 24 |
+
// parse an URI from string
|
| 25 |
+
|
| 26 |
+
let uri = URI.parse('https://code.visualstudio.com/docs/extensions/overview#frag')
|
| 27 |
+
|
| 28 |
+
assert.ok(uri.scheme === 'https');
|
| 29 |
+
assert.ok(uri.authority === 'code.visualstudio.com');
|
| 30 |
+
assert.ok(uri.path === '/docs/extensions/overview');
|
| 31 |
+
assert.ok(uri.query === '');
|
| 32 |
+
assert.ok(uri.fragment === 'frag');
|
| 33 |
+
assert.ok(uri.toString() === 'https://code.visualstudio.com/docs/extensions/overview#frag')
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
// create an URI from a fs path
|
| 37 |
+
|
| 38 |
+
let uri = URI.file('/users/me/c#-projects/');
|
| 39 |
+
|
| 40 |
+
assert.ok(uri.scheme === 'file');
|
| 41 |
+
assert.ok(uri.authority === '');
|
| 42 |
+
assert.ok(uri.path === '/users/me/c#-projects/');
|
| 43 |
+
assert.ok(uri.query === '');
|
| 44 |
+
assert.ok(uri.fragment === '');
|
| 45 |
+
assert.ok(uri.toString() === 'file:///users/me/c%23-projects/')
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Usage: Util
|
| 49 |
+
|
| 50 |
+
This module also exports a `Utils` package which is an extension, not part of `vscode.Uri`, and useful for path-math. There is:
|
| 51 |
+
|
| 52 |
+
* `Utils.joinPath(URI, paths): URI`
|
| 53 |
+
* `Utils.resolvePath(URI, paths): URI`
|
| 54 |
+
* `Utils.dirname(URI): string`
|
| 55 |
+
* `Utils.basename(URI): string`
|
| 56 |
+
* `Utils.extname(URI): string`
|
| 57 |
+
|
| 58 |
+
All util use posix path-math as defined by the node.js path module.
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
## Contributing
|
| 62 |
+
|
| 63 |
+
The source of this module is taken straight from the [vscode](https://github.com/microsoft/vscode)-sources and because of that issues and pull request should be created in that repository. Thanks and Happy Coding!
|
| 64 |
+
|
| 65 |
+
## Code of Conduct
|
| 66 |
+
|
| 67 |
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/SECURITY.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.8 BLOCK -->
|
| 2 |
+
|
| 3 |
+
## Security
|
| 4 |
+
|
| 5 |
+
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
|
| 6 |
+
|
| 7 |
+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
|
| 8 |
+
|
| 9 |
+
## Reporting Security Issues
|
| 10 |
+
|
| 11 |
+
**Please do not report security vulnerabilities through public GitHub issues.**
|
| 12 |
+
|
| 13 |
+
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
|
| 14 |
+
|
| 15 |
+
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
|
| 16 |
+
|
| 17 |
+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
|
| 18 |
+
|
| 19 |
+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
| 20 |
+
|
| 21 |
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
| 22 |
+
* Full paths of source file(s) related to the manifestation of the issue
|
| 23 |
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
| 24 |
+
* Any special configuration required to reproduce the issue
|
| 25 |
+
* Step-by-step instructions to reproduce the issue
|
| 26 |
+
* Proof-of-concept or exploit code (if possible)
|
| 27 |
+
* Impact of the issue, including how an attacker might exploit the issue
|
| 28 |
+
|
| 29 |
+
This information will help us triage your report more quickly.
|
| 30 |
+
|
| 31 |
+
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
|
| 32 |
+
|
| 33 |
+
## Preferred Languages
|
| 34 |
+
|
| 35 |
+
We prefer all communications to be in English.
|
| 36 |
+
|
| 37 |
+
## Policy
|
| 38 |
+
|
| 39 |
+
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
|
| 40 |
+
|
| 41 |
+
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/lib/umd/utils.d.ts
CHANGED
|
@@ -1,3 +1,58 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { URI } from './uri';
|
| 2 |
+
export declare namespace Utils {
|
| 3 |
+
/**
|
| 4 |
+
* Joins one or more input paths to the path of URI.
|
| 5 |
+
* '/' is used as the directory separation character.
|
| 6 |
+
*
|
| 7 |
+
* The resolved path will be normalized. That means:
|
| 8 |
+
* - all '..' and '.' segments are resolved.
|
| 9 |
+
* - multiple, sequential occurences of '/' are replaced by a single instance of '/'.
|
| 10 |
+
* - trailing separators are preserved.
|
| 11 |
+
*
|
| 12 |
+
* @param uri The input URI.
|
| 13 |
+
* @param paths The paths to be joined with the path of URI.
|
| 14 |
+
* @returns A URI with the joined path. All other properties of the URI (scheme, authority, query, fragments, ...) will be taken from the input URI.
|
| 15 |
+
*/
|
| 16 |
+
function joinPath(uri: URI, ...paths: string[]): URI;
|
| 17 |
+
/**
|
| 18 |
+
* Resolves one or more paths against the path of a URI.
|
| 19 |
+
* '/' is used as the directory separation character.
|
| 20 |
+
*
|
| 21 |
+
* The resolved path will be normalized. That means:
|
| 22 |
+
* - all '..' and '.' segments are resolved.
|
| 23 |
+
* - multiple, sequential occurences of '/' are replaced by a single instance of '/'.
|
| 24 |
+
* - trailing separators are removed.
|
| 25 |
+
*
|
| 26 |
+
* @param uri The input URI.
|
| 27 |
+
* @param paths The paths to resolve against the path of URI.
|
| 28 |
+
* @returns A URI with the resolved path. All other properties of the URI (scheme, authority, query, fragments, ...) will be taken from the input URI.
|
| 29 |
+
*/
|
| 30 |
+
function resolvePath(uri: URI, ...paths: string[]): URI;
|
| 31 |
+
/**
|
| 32 |
+
* Returns a URI where the path is the directory name of the input uri, similar to the Unix dirname command.
|
| 33 |
+
* In the path, '/' is recognized as the directory separation character. Trailing directory separators are ignored.
|
| 34 |
+
* The orignal URI is returned if the URIs path is empty or does not contain any path segments.
|
| 35 |
+
*
|
| 36 |
+
* @param uri The input URI.
|
| 37 |
+
* @return The last segment of the URIs path.
|
| 38 |
+
*/
|
| 39 |
+
function dirname(uri: URI): URI;
|
| 40 |
+
/**
|
| 41 |
+
* Returns the last segment of the path of a URI, similar to the Unix basename command.
|
| 42 |
+
* In the path, '/' is recognized as the directory separation character. Trailing directory separators are ignored.
|
| 43 |
+
* The empty string is returned if the URIs path is empty or does not contain any path segments.
|
| 44 |
+
*
|
| 45 |
+
* @param uri The input URI.
|
| 46 |
+
* @return The base name of the URIs path.
|
| 47 |
+
*/
|
| 48 |
+
function basename(uri: URI): string;
|
| 49 |
+
/**
|
| 50 |
+
* Returns the extension name of the path of a URI, similar to the Unix extname command.
|
| 51 |
+
* In the path, '/' is recognized as the directory separation character. Trailing directory separators are ignored.
|
| 52 |
+
* The empty string is returned if the URIs path is empty or does not contain any path segments.
|
| 53 |
+
*
|
| 54 |
+
* @param uri The input URI.
|
| 55 |
+
* @return The extension name of the URIs path.
|
| 56 |
+
*/
|
| 57 |
+
function extname(uri: URI): string;
|
| 58 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/lib/umd/utils.js
CHANGED
|
@@ -1,3 +1,123 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*---------------------------------------------------------------------------------------------
|
| 2 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 3 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 4 |
+
*--------------------------------------------------------------------------------------------*/
|
| 5 |
+
'use strict';
|
| 6 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 7 |
+
if (k2 === undefined) k2 = k;
|
| 8 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 9 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 10 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 11 |
+
}
|
| 12 |
+
Object.defineProperty(o, k2, desc);
|
| 13 |
+
}) : (function(o, m, k, k2) {
|
| 14 |
+
if (k2 === undefined) k2 = k;
|
| 15 |
+
o[k2] = m[k];
|
| 16 |
+
}));
|
| 17 |
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
| 18 |
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
| 19 |
+
}) : function(o, v) {
|
| 20 |
+
o["default"] = v;
|
| 21 |
+
});
|
| 22 |
+
var __importStar = (this && this.__importStar) || function (mod) {
|
| 23 |
+
if (mod && mod.__esModule) return mod;
|
| 24 |
+
var result = {};
|
| 25 |
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
| 26 |
+
__setModuleDefault(result, mod);
|
| 27 |
+
return result;
|
| 28 |
+
};
|
| 29 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 30 |
+
exports.Utils = void 0;
|
| 31 |
+
const nodePath = __importStar(require("path"));
|
| 32 |
+
const posixPath = nodePath.posix || nodePath;
|
| 33 |
+
const slash = '/';
|
| 34 |
+
var Utils;
|
| 35 |
+
(function (Utils) {
|
| 36 |
+
/**
|
| 37 |
+
* Joins one or more input paths to the path of URI.
|
| 38 |
+
* '/' is used as the directory separation character.
|
| 39 |
+
*
|
| 40 |
+
* The resolved path will be normalized. That means:
|
| 41 |
+
* - all '..' and '.' segments are resolved.
|
| 42 |
+
* - multiple, sequential occurences of '/' are replaced by a single instance of '/'.
|
| 43 |
+
* - trailing separators are preserved.
|
| 44 |
+
*
|
| 45 |
+
* @param uri The input URI.
|
| 46 |
+
* @param paths The paths to be joined with the path of URI.
|
| 47 |
+
* @returns A URI with the joined path. All other properties of the URI (scheme, authority, query, fragments, ...) will be taken from the input URI.
|
| 48 |
+
*/
|
| 49 |
+
function joinPath(uri, ...paths) {
|
| 50 |
+
return uri.with({ path: posixPath.join(uri.path, ...paths) });
|
| 51 |
+
}
|
| 52 |
+
Utils.joinPath = joinPath;
|
| 53 |
+
/**
|
| 54 |
+
* Resolves one or more paths against the path of a URI.
|
| 55 |
+
* '/' is used as the directory separation character.
|
| 56 |
+
*
|
| 57 |
+
* The resolved path will be normalized. That means:
|
| 58 |
+
* - all '..' and '.' segments are resolved.
|
| 59 |
+
* - multiple, sequential occurences of '/' are replaced by a single instance of '/'.
|
| 60 |
+
* - trailing separators are removed.
|
| 61 |
+
*
|
| 62 |
+
* @param uri The input URI.
|
| 63 |
+
* @param paths The paths to resolve against the path of URI.
|
| 64 |
+
* @returns A URI with the resolved path. All other properties of the URI (scheme, authority, query, fragments, ...) will be taken from the input URI.
|
| 65 |
+
*/
|
| 66 |
+
function resolvePath(uri, ...paths) {
|
| 67 |
+
let path = uri.path;
|
| 68 |
+
let slashAdded = false;
|
| 69 |
+
if (path[0] !== slash) {
|
| 70 |
+
path = slash + path; // make the path abstract: for posixPath.resolve the first segments has to be absolute or cwd is used.
|
| 71 |
+
slashAdded = true;
|
| 72 |
+
}
|
| 73 |
+
let resolvedPath = posixPath.resolve(path, ...paths);
|
| 74 |
+
if (slashAdded && resolvedPath[0] === slash && !uri.authority) {
|
| 75 |
+
resolvedPath = resolvedPath.substring(1);
|
| 76 |
+
}
|
| 77 |
+
return uri.with({ path: resolvedPath });
|
| 78 |
+
}
|
| 79 |
+
Utils.resolvePath = resolvePath;
|
| 80 |
+
/**
|
| 81 |
+
* Returns a URI where the path is the directory name of the input uri, similar to the Unix dirname command.
|
| 82 |
+
* In the path, '/' is recognized as the directory separation character. Trailing directory separators are ignored.
|
| 83 |
+
* The orignal URI is returned if the URIs path is empty or does not contain any path segments.
|
| 84 |
+
*
|
| 85 |
+
* @param uri The input URI.
|
| 86 |
+
* @return The last segment of the URIs path.
|
| 87 |
+
*/
|
| 88 |
+
function dirname(uri) {
|
| 89 |
+
if (uri.path.length === 0 || uri.path === slash) {
|
| 90 |
+
return uri;
|
| 91 |
+
}
|
| 92 |
+
let path = posixPath.dirname(uri.path);
|
| 93 |
+
if (path.length === 1 && path.charCodeAt(0) === 46 /* CharCode.Period */) {
|
| 94 |
+
path = '';
|
| 95 |
+
}
|
| 96 |
+
return uri.with({ path });
|
| 97 |
+
}
|
| 98 |
+
Utils.dirname = dirname;
|
| 99 |
+
/**
|
| 100 |
+
* Returns the last segment of the path of a URI, similar to the Unix basename command.
|
| 101 |
+
* In the path, '/' is recognized as the directory separation character. Trailing directory separators are ignored.
|
| 102 |
+
* The empty string is returned if the URIs path is empty or does not contain any path segments.
|
| 103 |
+
*
|
| 104 |
+
* @param uri The input URI.
|
| 105 |
+
* @return The base name of the URIs path.
|
| 106 |
+
*/
|
| 107 |
+
function basename(uri) {
|
| 108 |
+
return posixPath.basename(uri.path);
|
| 109 |
+
}
|
| 110 |
+
Utils.basename = basename;
|
| 111 |
+
/**
|
| 112 |
+
* Returns the extension name of the path of a URI, similar to the Unix extname command.
|
| 113 |
+
* In the path, '/' is recognized as the directory separation character. Trailing directory separators are ignored.
|
| 114 |
+
* The empty string is returned if the URIs path is empty or does not contain any path segments.
|
| 115 |
+
*
|
| 116 |
+
* @param uri The input URI.
|
| 117 |
+
* @return The extension name of the URIs path.
|
| 118 |
+
*/
|
| 119 |
+
function extname(uri) {
|
| 120 |
+
return posixPath.extname(uri.path);
|
| 121 |
+
}
|
| 122 |
+
Utils.extname = extname;
|
| 123 |
+
})(Utils || (exports.Utils = Utils = {}));
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/node_modules/vscode-uri/package.json
CHANGED
|
@@ -1,3 +1,43 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "vscode-uri",
|
| 3 |
+
"author": "Microsoft",
|
| 4 |
+
"version": "3.0.8",
|
| 5 |
+
"description": "The URI implementation that is used by VS Code and its extensions",
|
| 6 |
+
"main": "./lib/umd/index.js",
|
| 7 |
+
"typings": "./lib/umd/index",
|
| 8 |
+
"exports": {
|
| 9 |
+
"import": "./lib/esm/index.mjs",
|
| 10 |
+
"require": "./lib/umd/index.js",
|
| 11 |
+
"types": "./lib/umd/index.d.ts",
|
| 12 |
+
"browser": "./lib/esm/index.mjs"
|
| 13 |
+
},
|
| 14 |
+
"sideEffects": false,
|
| 15 |
+
"scripts": {
|
| 16 |
+
"clean": "rimraf lib",
|
| 17 |
+
"pack-production": "webpack --mode=production",
|
| 18 |
+
"pack-dev": "webpack",
|
| 19 |
+
"compile": "tsc -p ./src",
|
| 20 |
+
"prepublish": "npm run pack-production",
|
| 21 |
+
"test": "tsc -p ./src && npm run pack-dev && mocha"
|
| 22 |
+
},
|
| 23 |
+
"repository": {
|
| 24 |
+
"type": "git",
|
| 25 |
+
"url": "git+https://github.com/microsoft/vscode-uri.git"
|
| 26 |
+
},
|
| 27 |
+
"license": "MIT",
|
| 28 |
+
"bugs": {
|
| 29 |
+
"url": "https://github.com/microsoft/vscode-uri/issues"
|
| 30 |
+
},
|
| 31 |
+
"homepage": "https://github.com/microsoft/vscode-uri#readme",
|
| 32 |
+
"devDependencies": {
|
| 33 |
+
"@types/mocha": "^10.0.2",
|
| 34 |
+
"@types/node": "16.x",
|
| 35 |
+
"mocha": "^10.2.0",
|
| 36 |
+
"path-browserify": "^1.0.1",
|
| 37 |
+
"rimraf": "^5.0.5",
|
| 38 |
+
"ts-loader": "^9.4.4",
|
| 39 |
+
"typescript": "^5.2.2",
|
| 40 |
+
"webpack": "^5.88.2",
|
| 41 |
+
"webpack-cli": "^5.1.4"
|
| 42 |
+
}
|
| 43 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/package.json
CHANGED
|
@@ -1,3 +1,50 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "vscode-html-languageservice",
|
| 3 |
+
"version": "5.2.0",
|
| 4 |
+
"description": "Language service for HTML",
|
| 5 |
+
"main": "./lib/umd/htmlLanguageService.js",
|
| 6 |
+
"typings": "./lib/umd/htmlLanguageService",
|
| 7 |
+
"module": "./lib/esm/htmlLanguageService.js",
|
| 8 |
+
"author": "Microsoft Corporation",
|
| 9 |
+
"repository": {
|
| 10 |
+
"type": "git",
|
| 11 |
+
"url": "https://github.com/Microsoft/vscode-html-languageservice"
|
| 12 |
+
},
|
| 13 |
+
"license": "MIT",
|
| 14 |
+
"bugs": {
|
| 15 |
+
"url": "https://github.com/Microsoft/vscode-html-languageservice"
|
| 16 |
+
},
|
| 17 |
+
"devDependencies": {
|
| 18 |
+
"@types/mocha": "^10.0.6",
|
| 19 |
+
"@types/node": "16.x",
|
| 20 |
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
| 21 |
+
"@typescript-eslint/parser": "^6.21.0",
|
| 22 |
+
"@vscode/web-custom-data": "^0.4.9",
|
| 23 |
+
"eslint": "^8.57.0",
|
| 24 |
+
"js-beautify": "^1.15.1",
|
| 25 |
+
"mocha": "^10.3.0",
|
| 26 |
+
"rimraf": "^5.0.5",
|
| 27 |
+
"typescript": "^5.3.3"
|
| 28 |
+
},
|
| 29 |
+
"dependencies": {
|
| 30 |
+
"@vscode/l10n": "^0.0.18",
|
| 31 |
+
"vscode-languageserver-textdocument": "^1.0.11",
|
| 32 |
+
"vscode-languageserver-types": "^3.17.5",
|
| 33 |
+
"vscode-uri": "^3.0.8"
|
| 34 |
+
},
|
| 35 |
+
"scripts": {
|
| 36 |
+
"prepack": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs",
|
| 37 |
+
"compile": "tsc -p ./src && npm run copy-jsbeautify",
|
| 38 |
+
"compile-esm": "tsc -p ./src/tsconfig.esm.json",
|
| 39 |
+
"watch": "tsc -w -p ./src && npm run copy-jsbeautify",
|
| 40 |
+
"clean": "rimraf lib",
|
| 41 |
+
"remove-sourcemap-refs": "node ./build/remove-sourcemap-refs.js",
|
| 42 |
+
"test": "npm run compile && mocha --timeout 5000 ./lib/umd/test/*.js && npm run lint",
|
| 43 |
+
"lint": "eslint src/**/*.ts",
|
| 44 |
+
"install-types-next": "npm i vscode-languageserver-types@next -f -S && npm i vscode-languageserver-textdocument@next -f -S",
|
| 45 |
+
"copy-jsbeautify": "node ./build/copy-jsbeautify.js",
|
| 46 |
+
"update-jsbeautify": "npm i js-beautify && node ./build/update-jsbeautify.js",
|
| 47 |
+
"update-jsbeautify-next": "npm i js-beautify@next && node ./build/update-jsbeautify.js",
|
| 48 |
+
"update-data": "npm i @vscode/web-custom-data -D && node ./build/generateData.js"
|
| 49 |
+
}
|
| 50 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-html-languageservice/thirdpartynotices.txt
CHANGED
|
@@ -1,3 +1,49 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
|
| 2 |
+
|
| 3 |
+
vscode-html-languageservice incorporates third party material from the projects listed below. The original copyright
|
| 4 |
+
notice and the license under which Microsoft received such third party material are set forth below. Microsoft
|
| 5 |
+
reserves all other rights not expressly granted, whether by implication, estoppel or otherwise.
|
| 6 |
+
|
| 7 |
+
1. JS Beautifier (https://github.com/beautify-web/js-beautify)
|
| 8 |
+
|
| 9 |
+
The MIT License (MIT)
|
| 10 |
+
|
| 11 |
+
Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors.
|
| 12 |
+
|
| 13 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 14 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 15 |
+
in the Software without restriction, including without limitation the rights
|
| 16 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 17 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 18 |
+
furnished to do so, subject to the following conditions:
|
| 19 |
+
|
| 20 |
+
The above copyright notice and this permission notice shall be included in
|
| 21 |
+
all copies or substantial portions of the Software.
|
| 22 |
+
|
| 23 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 24 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 26 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 27 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 28 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 29 |
+
THE SOFTWARE.
|
| 30 |
+
|
| 31 |
+
2. HTML 5.1 W3C Working Draft version 08 October 2015 (http://www.w3.org/TR/2015/WD-html51-20151008/)
|
| 32 |
+
|
| 33 |
+
%% HTML 5.1 W3C Working Draft NOTICES AND INFORMATION BEGIN HERE
|
| 34 |
+
=========================================
|
| 35 |
+
Copyright © 2015 W3C® (MIT, ERCIM, Keio, Beihang). This software or document includes material copied
|
| 36 |
+
from or derived from HTML 5.1 W3C Working Draft (http://www.w3.org/TR/2015/WD-html51-20151008/.)
|
| 37 |
+
|
| 38 |
+
THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT
|
| 39 |
+
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF
|
| 40 |
+
THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY
|
| 41 |
+
PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
| 42 |
+
|
| 43 |
+
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE
|
| 44 |
+
DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.
|
| 45 |
+
|
| 46 |
+
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to this document or its contents
|
| 47 |
+
without specific, written prior permission. Title to copyright in this document will at all times remain with copyright holders.
|
| 48 |
+
=========================================
|
| 49 |
+
END OF HTML 5.1 W3C Working Draft NOTICES AND INFORMATION
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/dist/node/jsonServerMain.js
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @vscode/l10n
|
| 2 |
+
|
| 3 |
+
Library used for loading the translations into subprocesses of your extension. These usages also get picked up by [l10n-dev](https://github.com/microsoft/vscode-l10n/tree/main/l10n-dev) string extraction tooling.
|
| 4 |
+
|
| 5 |
+
> **Note**
|
| 6 |
+
>
|
| 7 |
+
> You should _NOT_ use this library in your extension's main process. The translations are loaded into the main process by VS Code itself.
|
| 8 |
+
|
| 9 |
+
## Usage
|
| 10 |
+
|
| 11 |
+
```typescript
|
| 12 |
+
import * as l10n from '@vscode/l10n';
|
| 13 |
+
|
| 14 |
+
// Load the translations for the current locale
|
| 15 |
+
l10n.config({
|
| 16 |
+
contents: JSON.parse(process.env.BUNDLE_FROM_EXTENSION)
|
| 17 |
+
});
|
| 18 |
+
// or
|
| 19 |
+
l10n.config({
|
| 20 |
+
fsPath: process.env.FSPATH_TO_BUNDLE_FROM_EXTENSION
|
| 21 |
+
});
|
| 22 |
+
// or (warning, this is async)
|
| 23 |
+
await l10n.config({
|
| 24 |
+
uri: JSON.parse(process.env.BUNDLE_URI_FROM_EXTENSION)
|
| 25 |
+
});
|
| 26 |
+
|
| 27 |
+
// returns the translated string or the original string if no translation is available
|
| 28 |
+
l10n.t('Hello World');
|
| 29 |
+
|
| 30 |
+
// supports arguments just like the vscode API
|
| 31 |
+
l10n.t('Hello {0}', 'John');
|
| 32 |
+
|
| 33 |
+
// supports comments for translators
|
| 34 |
+
l10n.t({
|
| 35 |
+
message: 'Hello {0}',
|
| 36 |
+
args: ['John'],
|
| 37 |
+
comment: ['This is a comment']
|
| 38 |
+
});
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
The input for `l10n.config` pairs nicely with the `bundle` and `uri` properties on the `l10n` namespace that are provided by the [VS Code API](https://code.visualstudio.com/api/references/vscode-api#l10n).
|
| 42 |
+
You should send the value of one of these properties from your extension to your subprocess that is consuming `@vscode/l10n`.
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/dist/browser.js
CHANGED
|
@@ -1,3 +1,103 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// src/browser/reader.ts
|
| 2 |
+
async function readFileFromUri(uri) {
|
| 3 |
+
if (uri.protocol === "http:" || uri.protocol === "https:") {
|
| 4 |
+
const res = await fetch(uri);
|
| 5 |
+
return await res.text();
|
| 6 |
+
}
|
| 7 |
+
throw new Error("Unsupported protocol");
|
| 8 |
+
}
|
| 9 |
+
function readFileFromFsPath(_) {
|
| 10 |
+
throw new Error("Unsupported in browser");
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
// src/main.ts
|
| 14 |
+
var bundle;
|
| 15 |
+
function config(config2) {
|
| 16 |
+
if ("contents" in config2) {
|
| 17 |
+
if (typeof config2.contents === "string") {
|
| 18 |
+
bundle = JSON.parse(config2.contents);
|
| 19 |
+
} else {
|
| 20 |
+
bundle = config2.contents;
|
| 21 |
+
}
|
| 22 |
+
return;
|
| 23 |
+
}
|
| 24 |
+
if ("fsPath" in config2) {
|
| 25 |
+
const fileContent = readFileFromFsPath(config2.fsPath);
|
| 26 |
+
const content = JSON.parse(fileContent);
|
| 27 |
+
bundle = isBuiltinExtension(content) ? content.contents.bundle : content;
|
| 28 |
+
return;
|
| 29 |
+
}
|
| 30 |
+
if (config2.uri) {
|
| 31 |
+
let uri = config2.uri;
|
| 32 |
+
if (typeof config2.uri === "string") {
|
| 33 |
+
uri = new URL(config2.uri);
|
| 34 |
+
}
|
| 35 |
+
return new Promise((resolve, reject) => {
|
| 36 |
+
readFileFromUri(uri).then((uriContent) => {
|
| 37 |
+
try {
|
| 38 |
+
const content = JSON.parse(uriContent);
|
| 39 |
+
bundle = isBuiltinExtension(content) ? content.contents.bundle : content;
|
| 40 |
+
resolve();
|
| 41 |
+
} catch (err) {
|
| 42 |
+
reject(err);
|
| 43 |
+
}
|
| 44 |
+
}).catch((err) => {
|
| 45 |
+
reject(err);
|
| 46 |
+
});
|
| 47 |
+
});
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
function t(...args) {
|
| 51 |
+
const firstArg = args[0];
|
| 52 |
+
let key;
|
| 53 |
+
let message;
|
| 54 |
+
let formatArgs;
|
| 55 |
+
if (typeof firstArg === "string") {
|
| 56 |
+
key = firstArg;
|
| 57 |
+
message = firstArg;
|
| 58 |
+
args.splice(0, 1);
|
| 59 |
+
formatArgs = !args || typeof args[0] !== "object" ? args : args[0];
|
| 60 |
+
} else if (firstArg instanceof Array) {
|
| 61 |
+
const replacements = args.slice(1);
|
| 62 |
+
if (firstArg.length !== replacements.length + 1) {
|
| 63 |
+
throw new Error("expected a string as the first argument to l10n.t");
|
| 64 |
+
}
|
| 65 |
+
let str = firstArg[0];
|
| 66 |
+
for (let i = 1; i < firstArg.length; i++) {
|
| 67 |
+
str += `{${i - 1}}` + firstArg[i];
|
| 68 |
+
}
|
| 69 |
+
return t(str, ...replacements);
|
| 70 |
+
} else {
|
| 71 |
+
message = firstArg.message;
|
| 72 |
+
key = message;
|
| 73 |
+
if (firstArg.comment && firstArg.comment.length > 0) {
|
| 74 |
+
key += `/${Array.isArray(firstArg.comment) ? firstArg.comment.join("") : firstArg.comment}`;
|
| 75 |
+
}
|
| 76 |
+
formatArgs = firstArg.args ?? {};
|
| 77 |
+
}
|
| 78 |
+
const messageFromBundle = bundle?.[key];
|
| 79 |
+
if (!messageFromBundle) {
|
| 80 |
+
return format(message, formatArgs);
|
| 81 |
+
}
|
| 82 |
+
if (typeof messageFromBundle === "string") {
|
| 83 |
+
return format(messageFromBundle, formatArgs);
|
| 84 |
+
}
|
| 85 |
+
if (messageFromBundle.comment) {
|
| 86 |
+
return format(messageFromBundle.message, formatArgs);
|
| 87 |
+
}
|
| 88 |
+
return format(message, formatArgs);
|
| 89 |
+
}
|
| 90 |
+
var _format2Regexp = /{([^}]+)}/g;
|
| 91 |
+
function format(template, values) {
|
| 92 |
+
if (Object.keys(values).length === 0) {
|
| 93 |
+
return template;
|
| 94 |
+
}
|
| 95 |
+
return template.replace(_format2Regexp, (match, group) => values[group] ?? match);
|
| 96 |
+
}
|
| 97 |
+
function isBuiltinExtension(json) {
|
| 98 |
+
return !!(typeof json?.contents?.bundle === "object" && typeof json?.version === "string");
|
| 99 |
+
}
|
| 100 |
+
export {
|
| 101 |
+
config,
|
| 102 |
+
t
|
| 103 |
+
};
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/dist/main.d.ts
CHANGED
|
@@ -1,3 +1,130 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @public
|
| 3 |
+
* Loads the bundle from the given contents. Must be run before the first call to any `l10n.t()` variant.
|
| 4 |
+
* **Note** The best way to set this is to pass the value of the VS Code API `vscode.l10n.contents`
|
| 5 |
+
* to the process that uses `@vscode/l10n`.
|
| 6 |
+
* @param config - An object that contains one property, contents, which should contain the contents of the bundle.
|
| 7 |
+
*/
|
| 8 |
+
export declare function config(config: {
|
| 9 |
+
contents: string | l10nJsonFormat;
|
| 10 |
+
}): void;
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* @public
|
| 14 |
+
* Loads the bundle from the given fsPath. Must be run before the first call to any `l10n.t()` variant.
|
| 15 |
+
* **Warning** This is not implemented in the browser and will throw an Error.
|
| 16 |
+
* **Note** The best way to set this is to pass the value of the VS Code API `vscode.l10n.uri.fsPath`
|
| 17 |
+
* to the process that uses `@vscode/l10n`.
|
| 18 |
+
* @param config - An object that contains one property, fsPath, which should be a path to a file that contains the bundle.
|
| 19 |
+
*/
|
| 20 |
+
export declare function config(config: {
|
| 21 |
+
fsPath: string;
|
| 22 |
+
}): void;
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @public
|
| 26 |
+
* Loads the bundle from the given URI using an asynchronous fetch request.
|
| 27 |
+
* **Warning** Since this is an asynchronous API, you need to ensure that it resolves before
|
| 28 |
+
* the first call to any `l10n.t()` variant.
|
| 29 |
+
* **Note** The best way to set this is to pass the value of the VS Code API `vscode.l10n.uri.toString()`
|
| 30 |
+
* to the process that uses `@vscode/l10n`.
|
| 31 |
+
* @param config - An object that contains one property, uri, which should be a URL to the bundle.
|
| 32 |
+
*/
|
| 33 |
+
export declare function config(config: {
|
| 34 |
+
uri: string | URL;
|
| 35 |
+
}): Promise<void>;
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* @public
|
| 39 |
+
* The format of package.nls.json and l10n bundle files.
|
| 40 |
+
*/
|
| 41 |
+
export declare interface l10nJsonFormat {
|
| 42 |
+
[key: string]: l10nJsonMessageFormat;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* @public
|
| 47 |
+
* The format of a message in a bundle.
|
| 48 |
+
*/
|
| 49 |
+
export declare type l10nJsonMessageFormat = string | {
|
| 50 |
+
message: string;
|
| 51 |
+
comment: string[];
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* @public
|
| 56 |
+
* Type that can be used as replacements in `l10n.t()` calls.
|
| 57 |
+
*/
|
| 58 |
+
export declare type L10nReplacement = string | number | boolean;
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* @public
|
| 62 |
+
* Marks a string for localization. If the bundle has a localized value for this message, then that localized
|
| 63 |
+
* value will be returned (with injected `args` values for any templated values).
|
| 64 |
+
* @param message - The message to localize. Supports index templating where strings like `{0}` and `{1}` are
|
| 65 |
+
* replaced by the item at that index in the `args` array.
|
| 66 |
+
* @param args - The arguments to be used in the localized string. The index of the argument is used to
|
| 67 |
+
* match the template placeholder in the localized string.
|
| 68 |
+
* @returns localized string with injected arguments.
|
| 69 |
+
* @example `l10n.localize('hello', 'Hello {0}!', 'World');`
|
| 70 |
+
*/
|
| 71 |
+
export declare function t(message: string, ...args: Array<L10nReplacement>): string;
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* @public
|
| 75 |
+
* Marks a string for localization. If the bundle has a localized value for this message, then that localized
|
| 76 |
+
* value will be returned (with injected `args` values for any templated values).
|
| 77 |
+
* @param message - The message to localize. Supports named templating where strings like `{foo}` and `{bar}` are
|
| 78 |
+
* replaced by the value in the Record for that key (foo, bar, etc).
|
| 79 |
+
* @param args - The arguments to be used in the localized string. The name of the key in the record is used to
|
| 80 |
+
* match the template placeholder in the localized string.
|
| 81 |
+
* @returns localized string with injected arguments.
|
| 82 |
+
* @example `l10n.t('Hello {name}', { name: 'Erich' });`
|
| 83 |
+
*/
|
| 84 |
+
export declare function t(message: string, args: Record<string, L10nReplacement>): string;
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* @public
|
| 88 |
+
* Marks a string for localization. This function signature is made for usage
|
| 89 |
+
* with tagged template literals.
|
| 90 |
+
*
|
| 91 |
+
* The more verbose overload should still be used if comments are required.
|
| 92 |
+
* @example
|
| 93 |
+
* ```
|
| 94 |
+
* l10n.t`Hello ${name}!`
|
| 95 |
+
* ```
|
| 96 |
+
* @param message - String message components
|
| 97 |
+
* @param args - Replacement components in the string
|
| 98 |
+
* @returns localized string with injected arguments.
|
| 99 |
+
*/
|
| 100 |
+
export declare function t(strs: TemplateStringsArray, ...replacements: L10nReplacement[]): string;
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* @public
|
| 104 |
+
* Marks a string for localization. If the bundle has a localized value for this message, then that localized
|
| 105 |
+
* value will be returned (with injected args values for any templated values).
|
| 106 |
+
* @param options - The options to use when localizing the message.
|
| 107 |
+
* @returns localized string with injected arguments.
|
| 108 |
+
* @example `l10n.t({ message: 'Hello {0}', args: ['Erich'], comment: 'This is a comment' } );`
|
| 109 |
+
*/
|
| 110 |
+
export declare function t(options: {
|
| 111 |
+
/**
|
| 112 |
+
* The message to localize. If `args` is an array, this message supports index templating where strings like
|
| 113 |
+
* `{0}` and `{1}` are replaced by the item at that index in the `args` array. If `args` is a `Record<string, any>`,
|
| 114 |
+
* this supports named templating where strings like `{foo}` and `{bar}` are replaced by the value in
|
| 115 |
+
* the Record for that key (foo, bar, etc).
|
| 116 |
+
*/
|
| 117 |
+
message: string;
|
| 118 |
+
/**
|
| 119 |
+
* The arguments to be used in the localized string. As an array, the index of the argument is used to
|
| 120 |
+
* match the template placeholder in the localized string. As a Record, the key is used to match the template
|
| 121 |
+
* placeholder in the localized string.
|
| 122 |
+
*/
|
| 123 |
+
args?: Array<string | number | boolean> | Record<string, any>;
|
| 124 |
+
/**
|
| 125 |
+
* A comment to help translators understand the context of the message.
|
| 126 |
+
*/
|
| 127 |
+
comment: string | string[];
|
| 128 |
+
}): string;
|
| 129 |
+
|
| 130 |
+
export { }
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/dist/main.js
CHANGED
|
@@ -1,3 +1,151 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
|
| 20 |
+
// src/main.ts
|
| 21 |
+
var main_exports = {};
|
| 22 |
+
__export(main_exports, {
|
| 23 |
+
config: () => config,
|
| 24 |
+
t: () => t
|
| 25 |
+
});
|
| 26 |
+
module.exports = __toCommonJS(main_exports);
|
| 27 |
+
|
| 28 |
+
// src/node/reader.ts
|
| 29 |
+
var import_fs = require("fs");
|
| 30 |
+
var import_promises = require("fs/promises");
|
| 31 |
+
async function readFileFromUri(uri) {
|
| 32 |
+
if (uri.protocol === "file:") {
|
| 33 |
+
return await (0, import_promises.readFile)(uri, "utf8");
|
| 34 |
+
}
|
| 35 |
+
if (uri.protocol === "http:" || uri.protocol === "https:") {
|
| 36 |
+
const res = await fetch(uri.toString(), {
|
| 37 |
+
headers: {
|
| 38 |
+
"Accept-Encoding": "gzip, deflate",
|
| 39 |
+
"Accept": "application/json"
|
| 40 |
+
},
|
| 41 |
+
redirect: "follow"
|
| 42 |
+
});
|
| 43 |
+
if (!res.ok) {
|
| 44 |
+
let error = `Unexpected ${res.status} response while trying to read ${uri}`;
|
| 45 |
+
try {
|
| 46 |
+
error += `: ${await res.text()}`;
|
| 47 |
+
} catch {
|
| 48 |
+
}
|
| 49 |
+
throw new Error(error);
|
| 50 |
+
}
|
| 51 |
+
const decoded = await res.text();
|
| 52 |
+
return decoded;
|
| 53 |
+
}
|
| 54 |
+
throw new Error("Unsupported protocol");
|
| 55 |
+
}
|
| 56 |
+
function readFileFromFsPath(fsPath) {
|
| 57 |
+
return (0, import_fs.readFileSync)(fsPath, "utf8");
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
// src/main.ts
|
| 61 |
+
var bundle;
|
| 62 |
+
function config(config2) {
|
| 63 |
+
if ("contents" in config2) {
|
| 64 |
+
if (typeof config2.contents === "string") {
|
| 65 |
+
bundle = JSON.parse(config2.contents);
|
| 66 |
+
} else {
|
| 67 |
+
bundle = config2.contents;
|
| 68 |
+
}
|
| 69 |
+
return;
|
| 70 |
+
}
|
| 71 |
+
if ("fsPath" in config2) {
|
| 72 |
+
const fileContent = readFileFromFsPath(config2.fsPath);
|
| 73 |
+
const content = JSON.parse(fileContent);
|
| 74 |
+
bundle = isBuiltinExtension(content) ? content.contents.bundle : content;
|
| 75 |
+
return;
|
| 76 |
+
}
|
| 77 |
+
if (config2.uri) {
|
| 78 |
+
let uri = config2.uri;
|
| 79 |
+
if (typeof config2.uri === "string") {
|
| 80 |
+
uri = new URL(config2.uri);
|
| 81 |
+
}
|
| 82 |
+
return new Promise((resolve, reject) => {
|
| 83 |
+
readFileFromUri(uri).then((uriContent) => {
|
| 84 |
+
try {
|
| 85 |
+
const content = JSON.parse(uriContent);
|
| 86 |
+
bundle = isBuiltinExtension(content) ? content.contents.bundle : content;
|
| 87 |
+
resolve();
|
| 88 |
+
} catch (err) {
|
| 89 |
+
reject(err);
|
| 90 |
+
}
|
| 91 |
+
}).catch((err) => {
|
| 92 |
+
reject(err);
|
| 93 |
+
});
|
| 94 |
+
});
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
function t(...args) {
|
| 98 |
+
const firstArg = args[0];
|
| 99 |
+
let key;
|
| 100 |
+
let message;
|
| 101 |
+
let formatArgs;
|
| 102 |
+
if (typeof firstArg === "string") {
|
| 103 |
+
key = firstArg;
|
| 104 |
+
message = firstArg;
|
| 105 |
+
args.splice(0, 1);
|
| 106 |
+
formatArgs = !args || typeof args[0] !== "object" ? args : args[0];
|
| 107 |
+
} else if (firstArg instanceof Array) {
|
| 108 |
+
const replacements = args.slice(1);
|
| 109 |
+
if (firstArg.length !== replacements.length + 1) {
|
| 110 |
+
throw new Error("expected a string as the first argument to l10n.t");
|
| 111 |
+
}
|
| 112 |
+
let str = firstArg[0];
|
| 113 |
+
for (let i = 1; i < firstArg.length; i++) {
|
| 114 |
+
str += `{${i - 1}}` + firstArg[i];
|
| 115 |
+
}
|
| 116 |
+
return t(str, ...replacements);
|
| 117 |
+
} else {
|
| 118 |
+
message = firstArg.message;
|
| 119 |
+
key = message;
|
| 120 |
+
if (firstArg.comment && firstArg.comment.length > 0) {
|
| 121 |
+
key += `/${Array.isArray(firstArg.comment) ? firstArg.comment.join("") : firstArg.comment}`;
|
| 122 |
+
}
|
| 123 |
+
formatArgs = firstArg.args ?? {};
|
| 124 |
+
}
|
| 125 |
+
const messageFromBundle = bundle?.[key];
|
| 126 |
+
if (!messageFromBundle) {
|
| 127 |
+
return format(message, formatArgs);
|
| 128 |
+
}
|
| 129 |
+
if (typeof messageFromBundle === "string") {
|
| 130 |
+
return format(messageFromBundle, formatArgs);
|
| 131 |
+
}
|
| 132 |
+
if (messageFromBundle.comment) {
|
| 133 |
+
return format(messageFromBundle.message, formatArgs);
|
| 134 |
+
}
|
| 135 |
+
return format(message, formatArgs);
|
| 136 |
+
}
|
| 137 |
+
var _format2Regexp = /{([^}]+)}/g;
|
| 138 |
+
function format(template, values) {
|
| 139 |
+
if (Object.keys(values).length === 0) {
|
| 140 |
+
return template;
|
| 141 |
+
}
|
| 142 |
+
return template.replace(_format2Regexp, (match, group) => values[group] ?? match);
|
| 143 |
+
}
|
| 144 |
+
function isBuiltinExtension(json) {
|
| 145 |
+
return !!(typeof json?.contents?.bundle === "object" && typeof json?.version === "string");
|
| 146 |
+
}
|
| 147 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 148 |
+
0 && (module.exports = {
|
| 149 |
+
config,
|
| 150 |
+
t
|
| 151 |
+
});
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/dist/tsdoc-metadata.json
CHANGED
|
@@ -1,3 +1,11 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
| 2 |
+
// It should be published with your NPM package. It should not be tracked by Git.
|
| 3 |
+
{
|
| 4 |
+
"tsdocVersion": "0.12",
|
| 5 |
+
"toolPackages": [
|
| 6 |
+
{
|
| 7 |
+
"packageName": "@microsoft/api-extractor",
|
| 8 |
+
"packageVersion": "7.36.3"
|
| 9 |
+
}
|
| 10 |
+
]
|
| 11 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/@vscode/l10n/package.json
CHANGED
|
@@ -1,3 +1,50 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@vscode/l10n",
|
| 3 |
+
"version": "0.0.18",
|
| 4 |
+
"description": "A helper library to assist in localizing subprocesses spun up by VS Code extensions",
|
| 5 |
+
"author": "Microsoft Corporation",
|
| 6 |
+
"license": "MIT",
|
| 7 |
+
"repository": {
|
| 8 |
+
"type": "git",
|
| 9 |
+
"url": "https://github.com/Microsoft/vscode-l10n.git"
|
| 10 |
+
},
|
| 11 |
+
"bugs": {
|
| 12 |
+
"url": "https://github.com/Microsoft/vscode-l10n/issues"
|
| 13 |
+
},
|
| 14 |
+
"main": "./dist/main.js",
|
| 15 |
+
"sideEffects": false,
|
| 16 |
+
"browser": {
|
| 17 |
+
"./dist/main.js": "./dist/browser.js",
|
| 18 |
+
"./src/node/reader": "./src/browser/reader"
|
| 19 |
+
},
|
| 20 |
+
"types": "dist/main.d.ts",
|
| 21 |
+
"files": [
|
| 22 |
+
"dist/*"
|
| 23 |
+
],
|
| 24 |
+
"devDependencies": {
|
| 25 |
+
"@jest/globals": "^29.7.0",
|
| 26 |
+
"@microsoft/api-extractor": "^7.32.1",
|
| 27 |
+
"@types/mock-fs": "^4.13.1",
|
| 28 |
+
"@types/node": "^18",
|
| 29 |
+
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
| 30 |
+
"@typescript-eslint/parser": "^6.13.2",
|
| 31 |
+
"esbuild": "^0.15.5",
|
| 32 |
+
"eslint": "^7.29.0",
|
| 33 |
+
"http-proxy-agent": "^5.0.0",
|
| 34 |
+
"https-proxy-agent": "^5.0.1",
|
| 35 |
+
"jest": "^29.7.0",
|
| 36 |
+
"jest-fetch-mock": "^3.0.3",
|
| 37 |
+
"mock-fs": "^5.1.4",
|
| 38 |
+
"rimraf": "^3.0.2",
|
| 39 |
+
"ts-jest": "^29.1.1",
|
| 40 |
+
"typescript": "^4.7.4"
|
| 41 |
+
},
|
| 42 |
+
"scripts": {
|
| 43 |
+
"clean": "rimraf dist && rimraf lib",
|
| 44 |
+
"compile": "npm run clean && tsc --emitDeclarationOnly --outDir lib && node .esbuild.config.js",
|
| 45 |
+
"lint": "eslint src --ext ts",
|
| 46 |
+
"watch": "node .esbuild.config.js --watch",
|
| 47 |
+
"test": "jest --preset ts-jest",
|
| 48 |
+
"prepublishOnly": "npm run lint && npm run compile && npm run test"
|
| 49 |
+
}
|
| 50 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,72 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
3.2.0 2022-08-30
|
| 3 |
+
=================
|
| 4 |
+
- update the version of the bundled Javascript files to `es2020`.
|
| 5 |
+
- include all `const enum` values in the bundled JavaScript files (`ScanError`, `SyntaxKind`, `ParseErrorCode`).
|
| 6 |
+
|
| 7 |
+
3.1.0 2022-07-07
|
| 8 |
+
==================
|
| 9 |
+
* added new API `FormattingOptions.keepLines` : It leaves the initial line positions in the formatting.
|
| 10 |
+
|
| 11 |
+
3.0.0 2020-11-13
|
| 12 |
+
==================
|
| 13 |
+
* fixed API spec for `parseTree`. Can return `undefine` for empty input.
|
| 14 |
+
* added new API `FormattingOptions.insertFinalNewline`.
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
2.3.0 2020-07-03
|
| 18 |
+
==================
|
| 19 |
+
* new API `ModificationOptions.isArrayInsertion`: If `JSONPath` refers to an index of an array and `isArrayInsertion` is `true`, then `modify` will insert a new item at that location instead of overwriting its contents.
|
| 20 |
+
* `ModificationOptions.formattingOptions` is now optional. If not set, newly inserted content will not be formatted.
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
2.2.0 2019-10-25
|
| 24 |
+
==================
|
| 25 |
+
* added `ParseOptions.allowEmptyContent`. Default is `false`.
|
| 26 |
+
* new API `getNodeType`: Returns the type of a value returned by parse.
|
| 27 |
+
* `parse`: Fix issue with empty property name
|
| 28 |
+
|
| 29 |
+
2.1.0 2019-03-29
|
| 30 |
+
==================
|
| 31 |
+
* `JSONScanner` and `JSONVisitor` return lineNumber / character.
|
| 32 |
+
|
| 33 |
+
2.0.0 2018-04-12
|
| 34 |
+
==================
|
| 35 |
+
* renamed `Node.columnOffset` to `Node.colonOffset`
|
| 36 |
+
* new API `getNodePath`: Gets the JSON path of the given JSON DOM node
|
| 37 |
+
* new API `findNodeAtOffset`: Finds the most inner node at the given offset. If `includeRightBound` is set, also finds nodes that end at the given offset.
|
| 38 |
+
|
| 39 |
+
1.0.3 2018-03-07
|
| 40 |
+
==================
|
| 41 |
+
* provide ems modules
|
| 42 |
+
|
| 43 |
+
1.0.2 2018-03-05
|
| 44 |
+
==================
|
| 45 |
+
* added the `visit.onComment` API, reported when comments are allowed.
|
| 46 |
+
* added the `ParseErrorCode.InvalidCommentToken` enum value, reported when comments are disallowed.
|
| 47 |
+
|
| 48 |
+
1.0.1
|
| 49 |
+
==================
|
| 50 |
+
* added the `format` API: computes edits to format a JSON document.
|
| 51 |
+
* added the `modify` API: computes edits to insert, remove or replace a property or value in a JSON document.
|
| 52 |
+
* added the `allyEdits` API: applies edits to a document
|
| 53 |
+
|
| 54 |
+
1.0.0
|
| 55 |
+
==================
|
| 56 |
+
* remove nls dependency (remove `getParseErrorMessage`)
|
| 57 |
+
|
| 58 |
+
0.4.2 / 2017-05-05
|
| 59 |
+
==================
|
| 60 |
+
* added `ParseError.offset` & `ParseError.length`
|
| 61 |
+
|
| 62 |
+
0.4.1 / 2017-04-02
|
| 63 |
+
==================
|
| 64 |
+
* added `ParseOptions.allowTrailingComma`
|
| 65 |
+
|
| 66 |
+
0.4.0 / 2017-02-23
|
| 67 |
+
==================
|
| 68 |
+
* fix for `getLocation`. Now `getLocation` inside an object will always return a property from inside that property. Can be empty string if the object has no properties or if the offset is before a actual property `{ "a": { | }} will return location ['a', ' ']`
|
| 69 |
+
|
| 70 |
+
0.3.0 / 2017-01-17
|
| 71 |
+
==================
|
| 72 |
+
* Updating to typescript 2.0
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/LICENSE.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) Microsoft
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/README.md
CHANGED
|
@@ -1,3 +1,362 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# jsonc-parser
|
| 2 |
+
Scanner and parser for JSON with comments.
|
| 3 |
+
|
| 4 |
+
[](https://www.npmjs.org/package/jsonc-parser)
|
| 5 |
+
[](https://npmjs.org/package/jsonc-parser)
|
| 6 |
+
[](https://github.com/microsoft/node-jsonc-parser/workflows/Tests)
|
| 7 |
+
[](https://opensource.org/licenses/MIT)
|
| 8 |
+
|
| 9 |
+
Why?
|
| 10 |
+
----
|
| 11 |
+
JSONC is JSON with JavaScript style comments. This node module provides a scanner and fault tolerant parser that can process JSONC but is also useful for standard JSON.
|
| 12 |
+
- the *scanner* tokenizes the input string into tokens and token offsets
|
| 13 |
+
- the *visit* function implements a 'SAX' style parser with callbacks for the encountered properties and values.
|
| 14 |
+
- the *parseTree* function computes a hierarchical DOM with offsets representing the encountered properties and values.
|
| 15 |
+
- the *parse* function evaluates the JavaScript object represented by JSON string in a fault tolerant fashion.
|
| 16 |
+
- the *getLocation* API returns a location object that describes the property or value located at a given offset in a JSON document.
|
| 17 |
+
- the *findNodeAtLocation* API finds the node at a given location path in a JSON DOM.
|
| 18 |
+
- the *format* API computes edits to format a JSON document.
|
| 19 |
+
- the *modify* API computes edits to insert, remove or replace a property or value in a JSON document.
|
| 20 |
+
- the *applyEdits* API applies edits to a document.
|
| 21 |
+
|
| 22 |
+
Installation
|
| 23 |
+
------------
|
| 24 |
+
|
| 25 |
+
```
|
| 26 |
+
npm install --save jsonc-parser
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
API
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
### Scanner:
|
| 33 |
+
```typescript
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Creates a JSON scanner on the given text.
|
| 37 |
+
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
| 38 |
+
*/
|
| 39 |
+
export function createScanner(text: string, ignoreTrivia: boolean = false): JSONScanner;
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* The scanner object, representing a JSON scanner at a position in the input string.
|
| 43 |
+
*/
|
| 44 |
+
export interface JSONScanner {
|
| 45 |
+
/**
|
| 46 |
+
* Sets the scan position to a new offset. A call to 'scan' is needed to get the first token.
|
| 47 |
+
*/
|
| 48 |
+
setPosition(pos: number): any;
|
| 49 |
+
/**
|
| 50 |
+
* Read the next token. Returns the token code.
|
| 51 |
+
*/
|
| 52 |
+
scan(): SyntaxKind;
|
| 53 |
+
/**
|
| 54 |
+
* Returns the zero-based current scan position, which is after the last read token.
|
| 55 |
+
*/
|
| 56 |
+
getPosition(): number;
|
| 57 |
+
/**
|
| 58 |
+
* Returns the last read token.
|
| 59 |
+
*/
|
| 60 |
+
getToken(): SyntaxKind;
|
| 61 |
+
/**
|
| 62 |
+
* Returns the last read token value. The value for strings is the decoded string content. For numbers it's of type number, for boolean it's true or false.
|
| 63 |
+
*/
|
| 64 |
+
getTokenValue(): string;
|
| 65 |
+
/**
|
| 66 |
+
* The zero-based start offset of the last read token.
|
| 67 |
+
*/
|
| 68 |
+
getTokenOffset(): number;
|
| 69 |
+
/**
|
| 70 |
+
* The length of the last read token.
|
| 71 |
+
*/
|
| 72 |
+
getTokenLength(): number;
|
| 73 |
+
/**
|
| 74 |
+
* The zero-based start line number of the last read token.
|
| 75 |
+
*/
|
| 76 |
+
getTokenStartLine(): number;
|
| 77 |
+
/**
|
| 78 |
+
* The zero-based start character (column) of the last read token.
|
| 79 |
+
*/
|
| 80 |
+
getTokenStartCharacter(): number;
|
| 81 |
+
/**
|
| 82 |
+
* An error code of the last scan.
|
| 83 |
+
*/
|
| 84 |
+
getTokenError(): ScanError;
|
| 85 |
+
}
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
### Parser:
|
| 89 |
+
```typescript
|
| 90 |
+
|
| 91 |
+
export interface ParseOptions {
|
| 92 |
+
disallowComments?: boolean;
|
| 93 |
+
allowTrailingComma?: boolean;
|
| 94 |
+
allowEmptyContent?: boolean;
|
| 95 |
+
}
|
| 96 |
+
/**
|
| 97 |
+
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 98 |
+
* Therefore always check the errors list to find out if the input was valid.
|
| 99 |
+
*/
|
| 100 |
+
export declare function parse(text: string, errors?: {error: ParseErrorCode;}[], options?: ParseOptions): any;
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
| 104 |
+
*/
|
| 105 |
+
export declare function visit(text: string, visitor: JSONVisitor, options?: ParseOptions): any;
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* Visitor called by {@linkcode visit} when parsing JSON.
|
| 109 |
+
*
|
| 110 |
+
* The visitor functions have the following common parameters:
|
| 111 |
+
* - `offset`: Global offset within the JSON document, starting at 0
|
| 112 |
+
* - `startLine`: Line number, starting at 0
|
| 113 |
+
* - `startCharacter`: Start character (column) within the current line, starting at 0
|
| 114 |
+
*
|
| 115 |
+
* Additionally some functions have a `pathSupplier` parameter which can be used to obtain the
|
| 116 |
+
* current `JSONPath` within the document.
|
| 117 |
+
*/
|
| 118 |
+
export interface JSONVisitor {
|
| 119 |
+
/**
|
| 120 |
+
* Invoked when an open brace is encountered and an object is started. The offset and length represent the location of the open brace.
|
| 121 |
+
*/
|
| 122 |
+
onObjectBegin?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* Invoked when a property is encountered. The offset and length represent the location of the property name.
|
| 126 |
+
* The `JSONPath` created by the `pathSupplier` refers to the enclosing JSON object, it does not include the
|
| 127 |
+
* property name yet.
|
| 128 |
+
*/
|
| 129 |
+
onObjectProperty?: (property: string, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 130 |
+
/**
|
| 131 |
+
* Invoked when a closing brace is encountered and an object is completed. The offset and length represent the location of the closing brace.
|
| 132 |
+
*/
|
| 133 |
+
onObjectEnd?: (offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 134 |
+
/**
|
| 135 |
+
* Invoked when an open bracket is encountered. The offset and length represent the location of the open bracket.
|
| 136 |
+
*/
|
| 137 |
+
onArrayBegin?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 138 |
+
/**
|
| 139 |
+
* Invoked when a closing bracket is encountered. The offset and length represent the location of the closing bracket.
|
| 140 |
+
*/
|
| 141 |
+
onArrayEnd?: (offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 142 |
+
/**
|
| 143 |
+
* Invoked when a literal value is encountered. The offset and length represent the location of the literal value.
|
| 144 |
+
*/
|
| 145 |
+
onLiteralValue?: (value: any, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 146 |
+
/**
|
| 147 |
+
* Invoked when a comma or colon separator is encountered. The offset and length represent the location of the separator.
|
| 148 |
+
*/
|
| 149 |
+
onSeparator?: (character: string, offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 150 |
+
/**
|
| 151 |
+
* When comments are allowed, invoked when a line or block comment is encountered. The offset and length represent the location of the comment.
|
| 152 |
+
*/
|
| 153 |
+
onComment?: (offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 154 |
+
/**
|
| 155 |
+
* Invoked on an error.
|
| 156 |
+
*/
|
| 157 |
+
onError?: (error: ParseErrorCode, offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
/**
|
| 161 |
+
* Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 162 |
+
*/
|
| 163 |
+
export declare function parseTree(text: string, errors?: ParseError[], options?: ParseOptions): Node | undefined;
|
| 164 |
+
|
| 165 |
+
export declare type NodeType = "object" | "array" | "property" | "string" | "number" | "boolean" | "null";
|
| 166 |
+
export interface Node {
|
| 167 |
+
type: NodeType;
|
| 168 |
+
value?: any;
|
| 169 |
+
offset: number;
|
| 170 |
+
length: number;
|
| 171 |
+
colonOffset?: number;
|
| 172 |
+
parent?: Node;
|
| 173 |
+
children?: Node[];
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
### Utilities:
|
| 179 |
+
```typescript
|
| 180 |
+
/**
|
| 181 |
+
* Takes JSON with JavaScript-style comments and remove
|
| 182 |
+
* them. Optionally replaces every none-newline character
|
| 183 |
+
* of comments with a replaceCharacter
|
| 184 |
+
*/
|
| 185 |
+
export declare function stripComments(text: string, replaceCh?: string): string;
|
| 186 |
+
|
| 187 |
+
/**
|
| 188 |
+
* For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
|
| 189 |
+
*/
|
| 190 |
+
export declare function getLocation(text: string, position: number): Location;
|
| 191 |
+
|
| 192 |
+
/**
|
| 193 |
+
* A {@linkcode JSONPath} segment. Either a string representing an object property name
|
| 194 |
+
* or a number (starting at 0) for array indices.
|
| 195 |
+
*/
|
| 196 |
+
export declare type Segment = string | number;
|
| 197 |
+
export declare type JSONPath = Segment[];
|
| 198 |
+
export interface Location {
|
| 199 |
+
/**
|
| 200 |
+
* The previous property key or literal value (string, number, boolean or null) or undefined.
|
| 201 |
+
*/
|
| 202 |
+
previousNode?: Node;
|
| 203 |
+
/**
|
| 204 |
+
* The path describing the location in the JSON document. The path consists of a sequence strings
|
| 205 |
+
* representing an object property or numbers for array indices.
|
| 206 |
+
*/
|
| 207 |
+
path: JSONPath;
|
| 208 |
+
/**
|
| 209 |
+
* Matches the locations path against a pattern consisting of strings (for properties) and numbers (for array indices).
|
| 210 |
+
* '*' will match a single segment, of any property name or index.
|
| 211 |
+
* '**' will match a sequence of segments or no segment, of any property name or index.
|
| 212 |
+
*/
|
| 213 |
+
matches: (patterns: JSONPath) => boolean;
|
| 214 |
+
/**
|
| 215 |
+
* If set, the location's offset is at a property key.
|
| 216 |
+
*/
|
| 217 |
+
isAtPropertyKey: boolean;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* Finds the node at the given path in a JSON DOM.
|
| 222 |
+
*/
|
| 223 |
+
export function findNodeAtLocation(root: Node, path: JSONPath): Node | undefined;
|
| 224 |
+
|
| 225 |
+
/**
|
| 226 |
+
* Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
|
| 227 |
+
*/
|
| 228 |
+
export function findNodeAtOffset(root: Node, offset: number, includeRightBound?: boolean) : Node | undefined;
|
| 229 |
+
|
| 230 |
+
/**
|
| 231 |
+
* Gets the JSON path of the given JSON DOM node
|
| 232 |
+
*/
|
| 233 |
+
export function getNodePath(node: Node): JSONPath;
|
| 234 |
+
|
| 235 |
+
/**
|
| 236 |
+
* Evaluates the JavaScript object of the given JSON DOM node
|
| 237 |
+
*/
|
| 238 |
+
export function getNodeValue(node: Node): any;
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
* Computes the edit operations needed to format a JSON document.
|
| 242 |
+
*
|
| 243 |
+
* @param documentText The input text
|
| 244 |
+
* @param range The range to format or `undefined` to format the full content
|
| 245 |
+
* @param options The formatting options
|
| 246 |
+
* @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.
|
| 247 |
+
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
| 248 |
+
*/
|
| 249 |
+
export function format(documentText: string, range: Range, options: FormattingOptions): EditResult;
|
| 250 |
+
|
| 251 |
+
/**
|
| 252 |
+
* Computes the edit operations needed to modify a value in the JSON document.
|
| 253 |
+
*
|
| 254 |
+
* @param documentText The input text
|
| 255 |
+
* @param path The path of the value to change. The path represents either to the document root, a property or an array item.
|
| 256 |
+
* If the path points to an non-existing property or item, it will be created.
|
| 257 |
+
* @param value The new value for the specified property or item. If the value is undefined,
|
| 258 |
+
* the property or item will be removed.
|
| 259 |
+
* @param options Options
|
| 260 |
+
* @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
|
| 261 |
+
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
| 262 |
+
*/
|
| 263 |
+
export function modify(text: string, path: JSONPath, value: any, options: ModificationOptions): EditResult;
|
| 264 |
+
|
| 265 |
+
/**
|
| 266 |
+
* Applies edits to an input string.
|
| 267 |
+
* @param text The input text
|
| 268 |
+
* @param edits Edit operations following the format described in {@linkcode EditResult}.
|
| 269 |
+
* @returns The text with the applied edits.
|
| 270 |
+
* @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
|
| 271 |
+
*/
|
| 272 |
+
export function applyEdits(text: string, edits: EditResult): string;
|
| 273 |
+
|
| 274 |
+
/**
|
| 275 |
+
* An edit result describes a textual edit operation. It is the result of a {@linkcode format} and {@linkcode modify} operation.
|
| 276 |
+
* It consist of one or more edits describing insertions, replacements or removals of text segments.
|
| 277 |
+
* * The offsets of the edits refer to the original state of the document.
|
| 278 |
+
* * No two edits change or remove the same range of text in the original document.
|
| 279 |
+
* * Multiple edits can have the same offset if they are multiple inserts, or an insert followed by a remove or replace.
|
| 280 |
+
* * The order in the array defines which edit is applied first.
|
| 281 |
+
* To apply an edit result use {@linkcode applyEdits}.
|
| 282 |
+
* In general multiple EditResults must not be concatenated because they might impact each other, producing incorrect or malformed JSON data.
|
| 283 |
+
*/
|
| 284 |
+
export type EditResult = Edit[];
|
| 285 |
+
|
| 286 |
+
/**
|
| 287 |
+
* Represents a text modification
|
| 288 |
+
*/
|
| 289 |
+
export interface Edit {
|
| 290 |
+
/**
|
| 291 |
+
* The start offset of the modification.
|
| 292 |
+
*/
|
| 293 |
+
offset: number;
|
| 294 |
+
/**
|
| 295 |
+
* The length of the modification. Must not be negative. Empty length represents an *insert*.
|
| 296 |
+
*/
|
| 297 |
+
length: number;
|
| 298 |
+
/**
|
| 299 |
+
* The new content. Empty content represents a *remove*.
|
| 300 |
+
*/
|
| 301 |
+
content: string;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
/**
|
| 305 |
+
* A text range in the document
|
| 306 |
+
*/
|
| 307 |
+
export interface Range {
|
| 308 |
+
/**
|
| 309 |
+
* The start offset of the range.
|
| 310 |
+
*/
|
| 311 |
+
offset: number;
|
| 312 |
+
/**
|
| 313 |
+
* The length of the range. Must not be negative.
|
| 314 |
+
*/
|
| 315 |
+
length: number;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
/**
|
| 319 |
+
* Options used by {@linkcode format} when computing the formatting edit operations
|
| 320 |
+
*/
|
| 321 |
+
export interface FormattingOptions {
|
| 322 |
+
/**
|
| 323 |
+
* If indentation is based on spaces (`insertSpaces` = true), then what is the number of spaces that make an indent?
|
| 324 |
+
*/
|
| 325 |
+
tabSize: number;
|
| 326 |
+
/**
|
| 327 |
+
* Is indentation based on spaces?
|
| 328 |
+
*/
|
| 329 |
+
insertSpaces: boolean;
|
| 330 |
+
/**
|
| 331 |
+
* The default 'end of line' character
|
| 332 |
+
*/
|
| 333 |
+
eol: string;
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
/**
|
| 337 |
+
* Options used by {@linkcode modify} when computing the modification edit operations
|
| 338 |
+
*/
|
| 339 |
+
export interface ModificationOptions {
|
| 340 |
+
/**
|
| 341 |
+
* Formatting options. If undefined, the newly inserted code will be inserted unformatted.
|
| 342 |
+
*/
|
| 343 |
+
formattingOptions?: FormattingOptions;
|
| 344 |
+
/**
|
| 345 |
+
* Default false. If `JSONPath` refers to an index of an array and `isArrayInsertion` is `true`, then
|
| 346 |
+
* {@linkcode modify} will insert a new item at that location instead of overwriting its contents.
|
| 347 |
+
*/
|
| 348 |
+
isArrayInsertion?: boolean;
|
| 349 |
+
/**
|
| 350 |
+
* Optional function to define the insertion index given an existing list of properties.
|
| 351 |
+
*/
|
| 352 |
+
getInsertionIndex?: (properties: string[]) => number;
|
| 353 |
+
}
|
| 354 |
+
```
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
License
|
| 358 |
+
-------
|
| 359 |
+
|
| 360 |
+
(MIT License)
|
| 361 |
+
|
| 362 |
+
Copyright 2018, Microsoft
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/SECURITY.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
|
| 2 |
+
|
| 3 |
+
## Security
|
| 4 |
+
|
| 5 |
+
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
|
| 6 |
+
|
| 7 |
+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
|
| 8 |
+
|
| 9 |
+
## Reporting Security Issues
|
| 10 |
+
|
| 11 |
+
**Please do not report security vulnerabilities through public GitHub issues.**
|
| 12 |
+
|
| 13 |
+
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
|
| 14 |
+
|
| 15 |
+
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
|
| 16 |
+
|
| 17 |
+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
|
| 18 |
+
|
| 19 |
+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
| 20 |
+
|
| 21 |
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
| 22 |
+
* Full paths of source file(s) related to the manifestation of the issue
|
| 23 |
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
| 24 |
+
* Any special configuration required to reproduce the issue
|
| 25 |
+
* Step-by-step instructions to reproduce the issue
|
| 26 |
+
* Proof-of-concept or exploit code (if possible)
|
| 27 |
+
* Impact of the issue, including how an attacker might exploit the issue
|
| 28 |
+
|
| 29 |
+
This information will help us triage your report more quickly.
|
| 30 |
+
|
| 31 |
+
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
|
| 32 |
+
|
| 33 |
+
## Preferred Languages
|
| 34 |
+
|
| 35 |
+
We prefer all communications to be in English.
|
| 36 |
+
|
| 37 |
+
## Policy
|
| 38 |
+
|
| 39 |
+
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
|
| 40 |
+
|
| 41 |
+
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/impl/edit.js
CHANGED
|
@@ -1,3 +1,185 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*---------------------------------------------------------------------------------------------
|
| 2 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 3 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 4 |
+
*--------------------------------------------------------------------------------------------*/
|
| 5 |
+
'use strict';
|
| 6 |
+
import { format, isEOL } from './format';
|
| 7 |
+
import { parseTree, findNodeAtLocation } from './parser';
|
| 8 |
+
export function removeProperty(text, path, options) {
|
| 9 |
+
return setProperty(text, path, void 0, options);
|
| 10 |
+
}
|
| 11 |
+
export function setProperty(text, originalPath, value, options) {
|
| 12 |
+
const path = originalPath.slice();
|
| 13 |
+
const errors = [];
|
| 14 |
+
const root = parseTree(text, errors);
|
| 15 |
+
let parent = void 0;
|
| 16 |
+
let lastSegment = void 0;
|
| 17 |
+
while (path.length > 0) {
|
| 18 |
+
lastSegment = path.pop();
|
| 19 |
+
parent = findNodeAtLocation(root, path);
|
| 20 |
+
if (parent === void 0 && value !== void 0) {
|
| 21 |
+
if (typeof lastSegment === 'string') {
|
| 22 |
+
value = { [lastSegment]: value };
|
| 23 |
+
}
|
| 24 |
+
else {
|
| 25 |
+
value = [value];
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
else {
|
| 29 |
+
break;
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
if (!parent) {
|
| 33 |
+
// empty document
|
| 34 |
+
if (value === void 0) { // delete
|
| 35 |
+
throw new Error('Can not delete in empty document');
|
| 36 |
+
}
|
| 37 |
+
return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
|
| 38 |
+
}
|
| 39 |
+
else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {
|
| 40 |
+
const existing = findNodeAtLocation(parent, [lastSegment]);
|
| 41 |
+
if (existing !== void 0) {
|
| 42 |
+
if (value === void 0) { // delete
|
| 43 |
+
if (!existing.parent) {
|
| 44 |
+
throw new Error('Malformed AST');
|
| 45 |
+
}
|
| 46 |
+
const propertyIndex = parent.children.indexOf(existing.parent);
|
| 47 |
+
let removeBegin;
|
| 48 |
+
let removeEnd = existing.parent.offset + existing.parent.length;
|
| 49 |
+
if (propertyIndex > 0) {
|
| 50 |
+
// remove the comma of the previous node
|
| 51 |
+
let previous = parent.children[propertyIndex - 1];
|
| 52 |
+
removeBegin = previous.offset + previous.length;
|
| 53 |
+
}
|
| 54 |
+
else {
|
| 55 |
+
removeBegin = parent.offset + 1;
|
| 56 |
+
if (parent.children.length > 1) {
|
| 57 |
+
// remove the comma of the next node
|
| 58 |
+
let next = parent.children[1];
|
| 59 |
+
removeEnd = next.offset;
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: '' }, options);
|
| 63 |
+
}
|
| 64 |
+
else {
|
| 65 |
+
// set value of existing property
|
| 66 |
+
return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
else {
|
| 70 |
+
if (value === void 0) { // delete
|
| 71 |
+
return []; // property does not exist, nothing to do
|
| 72 |
+
}
|
| 73 |
+
const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
|
| 74 |
+
const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map(p => p.children[0].value)) : parent.children.length;
|
| 75 |
+
let edit;
|
| 76 |
+
if (index > 0) {
|
| 77 |
+
let previous = parent.children[index - 1];
|
| 78 |
+
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
| 79 |
+
}
|
| 80 |
+
else if (parent.children.length === 0) {
|
| 81 |
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
| 82 |
+
}
|
| 83 |
+
else {
|
| 84 |
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty + ',' };
|
| 85 |
+
}
|
| 86 |
+
return withFormatting(text, edit, options);
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
else if (parent.type === 'array' && typeof lastSegment === 'number' && Array.isArray(parent.children)) {
|
| 90 |
+
const insertIndex = lastSegment;
|
| 91 |
+
if (insertIndex === -1) {
|
| 92 |
+
// Insert
|
| 93 |
+
const newProperty = `${JSON.stringify(value)}`;
|
| 94 |
+
let edit;
|
| 95 |
+
if (parent.children.length === 0) {
|
| 96 |
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
| 97 |
+
}
|
| 98 |
+
else {
|
| 99 |
+
const previous = parent.children[parent.children.length - 1];
|
| 100 |
+
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
| 101 |
+
}
|
| 102 |
+
return withFormatting(text, edit, options);
|
| 103 |
+
}
|
| 104 |
+
else if (value === void 0 && parent.children.length >= 0) {
|
| 105 |
+
// Removal
|
| 106 |
+
const removalIndex = lastSegment;
|
| 107 |
+
const toRemove = parent.children[removalIndex];
|
| 108 |
+
let edit;
|
| 109 |
+
if (parent.children.length === 1) {
|
| 110 |
+
// only item
|
| 111 |
+
edit = { offset: parent.offset + 1, length: parent.length - 2, content: '' };
|
| 112 |
+
}
|
| 113 |
+
else if (parent.children.length - 1 === removalIndex) {
|
| 114 |
+
// last item
|
| 115 |
+
let previous = parent.children[removalIndex - 1];
|
| 116 |
+
let offset = previous.offset + previous.length;
|
| 117 |
+
let parentEndOffset = parent.offset + parent.length;
|
| 118 |
+
edit = { offset, length: parentEndOffset - 2 - offset, content: '' };
|
| 119 |
+
}
|
| 120 |
+
else {
|
| 121 |
+
edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: '' };
|
| 122 |
+
}
|
| 123 |
+
return withFormatting(text, edit, options);
|
| 124 |
+
}
|
| 125 |
+
else if (value !== void 0) {
|
| 126 |
+
let edit;
|
| 127 |
+
const newProperty = `${JSON.stringify(value)}`;
|
| 128 |
+
if (!options.isArrayInsertion && parent.children.length > lastSegment) {
|
| 129 |
+
const toModify = parent.children[lastSegment];
|
| 130 |
+
edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
|
| 131 |
+
}
|
| 132 |
+
else if (parent.children.length === 0 || lastSegment === 0) {
|
| 133 |
+
edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + ',' };
|
| 134 |
+
}
|
| 135 |
+
else {
|
| 136 |
+
const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
|
| 137 |
+
const previous = parent.children[index - 1];
|
| 138 |
+
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
| 139 |
+
}
|
| 140 |
+
return withFormatting(text, edit, options);
|
| 141 |
+
}
|
| 142 |
+
else {
|
| 143 |
+
throw new Error(`Can not ${value === void 0 ? 'remove' : (options.isArrayInsertion ? 'insert' : 'modify')} Array index ${insertIndex} as length is not sufficient`);
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
else {
|
| 147 |
+
throw new Error(`Can not add ${typeof lastSegment !== 'number' ? 'index' : 'property'} to parent of type ${parent.type}`);
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
function withFormatting(text, edit, options) {
|
| 151 |
+
if (!options.formattingOptions) {
|
| 152 |
+
return [edit];
|
| 153 |
+
}
|
| 154 |
+
// apply the edit
|
| 155 |
+
let newText = applyEdit(text, edit);
|
| 156 |
+
// format the new text
|
| 157 |
+
let begin = edit.offset;
|
| 158 |
+
let end = edit.offset + edit.content.length;
|
| 159 |
+
if (edit.length === 0 || edit.content.length === 0) { // insert or remove
|
| 160 |
+
while (begin > 0 && !isEOL(newText, begin - 1)) {
|
| 161 |
+
begin--;
|
| 162 |
+
}
|
| 163 |
+
while (end < newText.length && !isEOL(newText, end)) {
|
| 164 |
+
end++;
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
const edits = format(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
|
| 168 |
+
// apply the formatting edits and track the begin and end offsets of the changes
|
| 169 |
+
for (let i = edits.length - 1; i >= 0; i--) {
|
| 170 |
+
const edit = edits[i];
|
| 171 |
+
newText = applyEdit(newText, edit);
|
| 172 |
+
begin = Math.min(begin, edit.offset);
|
| 173 |
+
end = Math.max(end, edit.offset + edit.length);
|
| 174 |
+
end += edit.content.length - edit.length;
|
| 175 |
+
}
|
| 176 |
+
// create a single edit with all changes
|
| 177 |
+
const editLength = text.length - (newText.length - end) - begin;
|
| 178 |
+
return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
|
| 179 |
+
}
|
| 180 |
+
export function applyEdit(text, edit) {
|
| 181 |
+
return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
|
| 182 |
+
}
|
| 183 |
+
export function isWS(text, offset) {
|
| 184 |
+
return '\r\n \t'.indexOf(text.charAt(offset)) !== -1;
|
| 185 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/impl/format.js
CHANGED
|
@@ -1,3 +1,261 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*---------------------------------------------------------------------------------------------
|
| 2 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 3 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 4 |
+
*--------------------------------------------------------------------------------------------*/
|
| 5 |
+
'use strict';
|
| 6 |
+
import { createScanner } from './scanner';
|
| 7 |
+
import { cachedSpaces, cachedBreakLinesWithSpaces, supportedEols } from './string-intern';
|
| 8 |
+
export function format(documentText, range, options) {
|
| 9 |
+
let initialIndentLevel;
|
| 10 |
+
let formatText;
|
| 11 |
+
let formatTextStart;
|
| 12 |
+
let rangeStart;
|
| 13 |
+
let rangeEnd;
|
| 14 |
+
if (range) {
|
| 15 |
+
rangeStart = range.offset;
|
| 16 |
+
rangeEnd = rangeStart + range.length;
|
| 17 |
+
formatTextStart = rangeStart;
|
| 18 |
+
while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
|
| 19 |
+
formatTextStart--;
|
| 20 |
+
}
|
| 21 |
+
let endOffset = rangeEnd;
|
| 22 |
+
while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
|
| 23 |
+
endOffset++;
|
| 24 |
+
}
|
| 25 |
+
formatText = documentText.substring(formatTextStart, endOffset);
|
| 26 |
+
initialIndentLevel = computeIndentLevel(formatText, options);
|
| 27 |
+
}
|
| 28 |
+
else {
|
| 29 |
+
formatText = documentText;
|
| 30 |
+
initialIndentLevel = 0;
|
| 31 |
+
formatTextStart = 0;
|
| 32 |
+
rangeStart = 0;
|
| 33 |
+
rangeEnd = documentText.length;
|
| 34 |
+
}
|
| 35 |
+
const eol = getEOL(options, documentText);
|
| 36 |
+
const eolFastPathSupported = supportedEols.includes(eol);
|
| 37 |
+
let numberLineBreaks = 0;
|
| 38 |
+
let indentLevel = 0;
|
| 39 |
+
let indentValue;
|
| 40 |
+
if (options.insertSpaces) {
|
| 41 |
+
indentValue = cachedSpaces[options.tabSize || 4] ?? repeat(cachedSpaces[1], options.tabSize || 4);
|
| 42 |
+
}
|
| 43 |
+
else {
|
| 44 |
+
indentValue = '\t';
|
| 45 |
+
}
|
| 46 |
+
const indentType = indentValue === '\t' ? '\t' : ' ';
|
| 47 |
+
let scanner = createScanner(formatText, false);
|
| 48 |
+
let hasError = false;
|
| 49 |
+
function newLinesAndIndent() {
|
| 50 |
+
if (numberLineBreaks > 1) {
|
| 51 |
+
return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
|
| 52 |
+
}
|
| 53 |
+
const amountOfSpaces = indentValue.length * (initialIndentLevel + indentLevel);
|
| 54 |
+
if (!eolFastPathSupported || amountOfSpaces > cachedBreakLinesWithSpaces[indentType][eol].length) {
|
| 55 |
+
return eol + repeat(indentValue, initialIndentLevel + indentLevel);
|
| 56 |
+
}
|
| 57 |
+
if (amountOfSpaces <= 0) {
|
| 58 |
+
return eol;
|
| 59 |
+
}
|
| 60 |
+
return cachedBreakLinesWithSpaces[indentType][eol][amountOfSpaces];
|
| 61 |
+
}
|
| 62 |
+
function scanNext() {
|
| 63 |
+
let token = scanner.scan();
|
| 64 |
+
numberLineBreaks = 0;
|
| 65 |
+
while (token === 15 /* SyntaxKind.Trivia */ || token === 14 /* SyntaxKind.LineBreakTrivia */) {
|
| 66 |
+
if (token === 14 /* SyntaxKind.LineBreakTrivia */ && options.keepLines) {
|
| 67 |
+
numberLineBreaks += 1;
|
| 68 |
+
}
|
| 69 |
+
else if (token === 14 /* SyntaxKind.LineBreakTrivia */) {
|
| 70 |
+
numberLineBreaks = 1;
|
| 71 |
+
}
|
| 72 |
+
token = scanner.scan();
|
| 73 |
+
}
|
| 74 |
+
hasError = token === 16 /* SyntaxKind.Unknown */ || scanner.getTokenError() !== 0 /* ScanError.None */;
|
| 75 |
+
return token;
|
| 76 |
+
}
|
| 77 |
+
const editOperations = [];
|
| 78 |
+
function addEdit(text, startOffset, endOffset) {
|
| 79 |
+
if (!hasError && (!range || (startOffset < rangeEnd && endOffset > rangeStart)) && documentText.substring(startOffset, endOffset) !== text) {
|
| 80 |
+
editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
let firstToken = scanNext();
|
| 84 |
+
if (options.keepLines && numberLineBreaks > 0) {
|
| 85 |
+
addEdit(repeat(eol, numberLineBreaks), 0, 0);
|
| 86 |
+
}
|
| 87 |
+
if (firstToken !== 17 /* SyntaxKind.EOF */) {
|
| 88 |
+
let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
|
| 89 |
+
let initialIndent = (indentValue.length * initialIndentLevel < 20) && options.insertSpaces
|
| 90 |
+
? cachedSpaces[indentValue.length * initialIndentLevel]
|
| 91 |
+
: repeat(indentValue, initialIndentLevel);
|
| 92 |
+
addEdit(initialIndent, formatTextStart, firstTokenStart);
|
| 93 |
+
}
|
| 94 |
+
while (firstToken !== 17 /* SyntaxKind.EOF */) {
|
| 95 |
+
let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
| 96 |
+
let secondToken = scanNext();
|
| 97 |
+
let replaceContent = '';
|
| 98 |
+
let needsLineBreak = false;
|
| 99 |
+
while (numberLineBreaks === 0 && (secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */)) {
|
| 100 |
+
let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
|
| 101 |
+
addEdit(cachedSpaces[1], firstTokenEnd, commentTokenStart);
|
| 102 |
+
firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
| 103 |
+
needsLineBreak = secondToken === 12 /* SyntaxKind.LineCommentTrivia */;
|
| 104 |
+
replaceContent = needsLineBreak ? newLinesAndIndent() : '';
|
| 105 |
+
secondToken = scanNext();
|
| 106 |
+
}
|
| 107 |
+
if (secondToken === 2 /* SyntaxKind.CloseBraceToken */) {
|
| 108 |
+
if (firstToken !== 1 /* SyntaxKind.OpenBraceToken */) {
|
| 109 |
+
indentLevel--;
|
| 110 |
+
}
|
| 111 |
+
;
|
| 112 |
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1 /* SyntaxKind.OpenBraceToken */) {
|
| 113 |
+
replaceContent = newLinesAndIndent();
|
| 114 |
+
}
|
| 115 |
+
else if (options.keepLines) {
|
| 116 |
+
replaceContent = cachedSpaces[1];
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
else if (secondToken === 4 /* SyntaxKind.CloseBracketToken */) {
|
| 120 |
+
if (firstToken !== 3 /* SyntaxKind.OpenBracketToken */) {
|
| 121 |
+
indentLevel--;
|
| 122 |
+
}
|
| 123 |
+
;
|
| 124 |
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3 /* SyntaxKind.OpenBracketToken */) {
|
| 125 |
+
replaceContent = newLinesAndIndent();
|
| 126 |
+
}
|
| 127 |
+
else if (options.keepLines) {
|
| 128 |
+
replaceContent = cachedSpaces[1];
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
else {
|
| 132 |
+
switch (firstToken) {
|
| 133 |
+
case 3 /* SyntaxKind.OpenBracketToken */:
|
| 134 |
+
case 1 /* SyntaxKind.OpenBraceToken */:
|
| 135 |
+
indentLevel++;
|
| 136 |
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
| 137 |
+
replaceContent = newLinesAndIndent();
|
| 138 |
+
}
|
| 139 |
+
else {
|
| 140 |
+
replaceContent = cachedSpaces[1];
|
| 141 |
+
}
|
| 142 |
+
break;
|
| 143 |
+
case 5 /* SyntaxKind.CommaToken */:
|
| 144 |
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
| 145 |
+
replaceContent = newLinesAndIndent();
|
| 146 |
+
}
|
| 147 |
+
else {
|
| 148 |
+
replaceContent = cachedSpaces[1];
|
| 149 |
+
}
|
| 150 |
+
break;
|
| 151 |
+
case 12 /* SyntaxKind.LineCommentTrivia */:
|
| 152 |
+
replaceContent = newLinesAndIndent();
|
| 153 |
+
break;
|
| 154 |
+
case 13 /* SyntaxKind.BlockCommentTrivia */:
|
| 155 |
+
if (numberLineBreaks > 0) {
|
| 156 |
+
replaceContent = newLinesAndIndent();
|
| 157 |
+
}
|
| 158 |
+
else if (!needsLineBreak) {
|
| 159 |
+
replaceContent = cachedSpaces[1];
|
| 160 |
+
}
|
| 161 |
+
break;
|
| 162 |
+
case 6 /* SyntaxKind.ColonToken */:
|
| 163 |
+
if (options.keepLines && numberLineBreaks > 0) {
|
| 164 |
+
replaceContent = newLinesAndIndent();
|
| 165 |
+
}
|
| 166 |
+
else if (!needsLineBreak) {
|
| 167 |
+
replaceContent = cachedSpaces[1];
|
| 168 |
+
}
|
| 169 |
+
break;
|
| 170 |
+
case 10 /* SyntaxKind.StringLiteral */:
|
| 171 |
+
if (options.keepLines && numberLineBreaks > 0) {
|
| 172 |
+
replaceContent = newLinesAndIndent();
|
| 173 |
+
}
|
| 174 |
+
else if (secondToken === 6 /* SyntaxKind.ColonToken */ && !needsLineBreak) {
|
| 175 |
+
replaceContent = '';
|
| 176 |
+
}
|
| 177 |
+
break;
|
| 178 |
+
case 7 /* SyntaxKind.NullKeyword */:
|
| 179 |
+
case 8 /* SyntaxKind.TrueKeyword */:
|
| 180 |
+
case 9 /* SyntaxKind.FalseKeyword */:
|
| 181 |
+
case 11 /* SyntaxKind.NumericLiteral */:
|
| 182 |
+
case 2 /* SyntaxKind.CloseBraceToken */:
|
| 183 |
+
case 4 /* SyntaxKind.CloseBracketToken */:
|
| 184 |
+
if (options.keepLines && numberLineBreaks > 0) {
|
| 185 |
+
replaceContent = newLinesAndIndent();
|
| 186 |
+
}
|
| 187 |
+
else {
|
| 188 |
+
if ((secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */) && !needsLineBreak) {
|
| 189 |
+
replaceContent = cachedSpaces[1];
|
| 190 |
+
}
|
| 191 |
+
else if (secondToken !== 5 /* SyntaxKind.CommaToken */ && secondToken !== 17 /* SyntaxKind.EOF */) {
|
| 192 |
+
hasError = true;
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
break;
|
| 196 |
+
case 16 /* SyntaxKind.Unknown */:
|
| 197 |
+
hasError = true;
|
| 198 |
+
break;
|
| 199 |
+
}
|
| 200 |
+
if (numberLineBreaks > 0 && (secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */)) {
|
| 201 |
+
replaceContent = newLinesAndIndent();
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
if (secondToken === 17 /* SyntaxKind.EOF */) {
|
| 205 |
+
if (options.keepLines && numberLineBreaks > 0) {
|
| 206 |
+
replaceContent = newLinesAndIndent();
|
| 207 |
+
}
|
| 208 |
+
else {
|
| 209 |
+
replaceContent = options.insertFinalNewline ? eol : '';
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
|
| 213 |
+
addEdit(replaceContent, firstTokenEnd, secondTokenStart);
|
| 214 |
+
firstToken = secondToken;
|
| 215 |
+
}
|
| 216 |
+
return editOperations;
|
| 217 |
+
}
|
| 218 |
+
function repeat(s, count) {
|
| 219 |
+
let result = '';
|
| 220 |
+
for (let i = 0; i < count; i++) {
|
| 221 |
+
result += s;
|
| 222 |
+
}
|
| 223 |
+
return result;
|
| 224 |
+
}
|
| 225 |
+
function computeIndentLevel(content, options) {
|
| 226 |
+
let i = 0;
|
| 227 |
+
let nChars = 0;
|
| 228 |
+
const tabSize = options.tabSize || 4;
|
| 229 |
+
while (i < content.length) {
|
| 230 |
+
let ch = content.charAt(i);
|
| 231 |
+
if (ch === cachedSpaces[1]) {
|
| 232 |
+
nChars++;
|
| 233 |
+
}
|
| 234 |
+
else if (ch === '\t') {
|
| 235 |
+
nChars += tabSize;
|
| 236 |
+
}
|
| 237 |
+
else {
|
| 238 |
+
break;
|
| 239 |
+
}
|
| 240 |
+
i++;
|
| 241 |
+
}
|
| 242 |
+
return Math.floor(nChars / tabSize);
|
| 243 |
+
}
|
| 244 |
+
function getEOL(options, text) {
|
| 245 |
+
for (let i = 0; i < text.length; i++) {
|
| 246 |
+
const ch = text.charAt(i);
|
| 247 |
+
if (ch === '\r') {
|
| 248 |
+
if (i + 1 < text.length && text.charAt(i + 1) === '\n') {
|
| 249 |
+
return '\r\n';
|
| 250 |
+
}
|
| 251 |
+
return '\r';
|
| 252 |
+
}
|
| 253 |
+
else if (ch === '\n') {
|
| 254 |
+
return '\n';
|
| 255 |
+
}
|
| 256 |
+
}
|
| 257 |
+
return (options && options.eol) || '\n';
|
| 258 |
+
}
|
| 259 |
+
export function isEOL(text, offset) {
|
| 260 |
+
return '\r\n'.indexOf(text.charAt(offset)) !== -1;
|
| 261 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/impl/parser.js
CHANGED
|
@@ -1,3 +1,632 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*---------------------------------------------------------------------------------------------
|
| 2 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 3 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 4 |
+
*--------------------------------------------------------------------------------------------*/
|
| 5 |
+
'use strict';
|
| 6 |
+
import { createScanner } from './scanner';
|
| 7 |
+
var ParseOptions;
|
| 8 |
+
(function (ParseOptions) {
|
| 9 |
+
ParseOptions.DEFAULT = {
|
| 10 |
+
allowTrailingComma: false
|
| 11 |
+
};
|
| 12 |
+
})(ParseOptions || (ParseOptions = {}));
|
| 13 |
+
/**
|
| 14 |
+
* For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
|
| 15 |
+
*/
|
| 16 |
+
export function getLocation(text, position) {
|
| 17 |
+
const segments = []; // strings or numbers
|
| 18 |
+
const earlyReturnException = new Object();
|
| 19 |
+
let previousNode = undefined;
|
| 20 |
+
const previousNodeInst = {
|
| 21 |
+
value: {},
|
| 22 |
+
offset: 0,
|
| 23 |
+
length: 0,
|
| 24 |
+
type: 'object',
|
| 25 |
+
parent: undefined
|
| 26 |
+
};
|
| 27 |
+
let isAtPropertyKey = false;
|
| 28 |
+
function setPreviousNode(value, offset, length, type) {
|
| 29 |
+
previousNodeInst.value = value;
|
| 30 |
+
previousNodeInst.offset = offset;
|
| 31 |
+
previousNodeInst.length = length;
|
| 32 |
+
previousNodeInst.type = type;
|
| 33 |
+
previousNodeInst.colonOffset = undefined;
|
| 34 |
+
previousNode = previousNodeInst;
|
| 35 |
+
}
|
| 36 |
+
try {
|
| 37 |
+
visit(text, {
|
| 38 |
+
onObjectBegin: (offset, length) => {
|
| 39 |
+
if (position <= offset) {
|
| 40 |
+
throw earlyReturnException;
|
| 41 |
+
}
|
| 42 |
+
previousNode = undefined;
|
| 43 |
+
isAtPropertyKey = position > offset;
|
| 44 |
+
segments.push(''); // push a placeholder (will be replaced)
|
| 45 |
+
},
|
| 46 |
+
onObjectProperty: (name, offset, length) => {
|
| 47 |
+
if (position < offset) {
|
| 48 |
+
throw earlyReturnException;
|
| 49 |
+
}
|
| 50 |
+
setPreviousNode(name, offset, length, 'property');
|
| 51 |
+
segments[segments.length - 1] = name;
|
| 52 |
+
if (position <= offset + length) {
|
| 53 |
+
throw earlyReturnException;
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
onObjectEnd: (offset, length) => {
|
| 57 |
+
if (position <= offset) {
|
| 58 |
+
throw earlyReturnException;
|
| 59 |
+
}
|
| 60 |
+
previousNode = undefined;
|
| 61 |
+
segments.pop();
|
| 62 |
+
},
|
| 63 |
+
onArrayBegin: (offset, length) => {
|
| 64 |
+
if (position <= offset) {
|
| 65 |
+
throw earlyReturnException;
|
| 66 |
+
}
|
| 67 |
+
previousNode = undefined;
|
| 68 |
+
segments.push(0);
|
| 69 |
+
},
|
| 70 |
+
onArrayEnd: (offset, length) => {
|
| 71 |
+
if (position <= offset) {
|
| 72 |
+
throw earlyReturnException;
|
| 73 |
+
}
|
| 74 |
+
previousNode = undefined;
|
| 75 |
+
segments.pop();
|
| 76 |
+
},
|
| 77 |
+
onLiteralValue: (value, offset, length) => {
|
| 78 |
+
if (position < offset) {
|
| 79 |
+
throw earlyReturnException;
|
| 80 |
+
}
|
| 81 |
+
setPreviousNode(value, offset, length, getNodeType(value));
|
| 82 |
+
if (position <= offset + length) {
|
| 83 |
+
throw earlyReturnException;
|
| 84 |
+
}
|
| 85 |
+
},
|
| 86 |
+
onSeparator: (sep, offset, length) => {
|
| 87 |
+
if (position <= offset) {
|
| 88 |
+
throw earlyReturnException;
|
| 89 |
+
}
|
| 90 |
+
if (sep === ':' && previousNode && previousNode.type === 'property') {
|
| 91 |
+
previousNode.colonOffset = offset;
|
| 92 |
+
isAtPropertyKey = false;
|
| 93 |
+
previousNode = undefined;
|
| 94 |
+
}
|
| 95 |
+
else if (sep === ',') {
|
| 96 |
+
const last = segments[segments.length - 1];
|
| 97 |
+
if (typeof last === 'number') {
|
| 98 |
+
segments[segments.length - 1] = last + 1;
|
| 99 |
+
}
|
| 100 |
+
else {
|
| 101 |
+
isAtPropertyKey = true;
|
| 102 |
+
segments[segments.length - 1] = '';
|
| 103 |
+
}
|
| 104 |
+
previousNode = undefined;
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
});
|
| 108 |
+
}
|
| 109 |
+
catch (e) {
|
| 110 |
+
if (e !== earlyReturnException) {
|
| 111 |
+
throw e;
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
return {
|
| 115 |
+
path: segments,
|
| 116 |
+
previousNode,
|
| 117 |
+
isAtPropertyKey,
|
| 118 |
+
matches: (pattern) => {
|
| 119 |
+
let k = 0;
|
| 120 |
+
for (let i = 0; k < pattern.length && i < segments.length; i++) {
|
| 121 |
+
if (pattern[k] === segments[i] || pattern[k] === '*') {
|
| 122 |
+
k++;
|
| 123 |
+
}
|
| 124 |
+
else if (pattern[k] !== '**') {
|
| 125 |
+
return false;
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
return k === pattern.length;
|
| 129 |
+
}
|
| 130 |
+
};
|
| 131 |
+
}
|
| 132 |
+
/**
|
| 133 |
+
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 134 |
+
* Therefore always check the errors list to find out if the input was valid.
|
| 135 |
+
*/
|
| 136 |
+
export function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
| 137 |
+
let currentProperty = null;
|
| 138 |
+
let currentParent = [];
|
| 139 |
+
const previousParents = [];
|
| 140 |
+
function onValue(value) {
|
| 141 |
+
if (Array.isArray(currentParent)) {
|
| 142 |
+
currentParent.push(value);
|
| 143 |
+
}
|
| 144 |
+
else if (currentProperty !== null) {
|
| 145 |
+
currentParent[currentProperty] = value;
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
const visitor = {
|
| 149 |
+
onObjectBegin: () => {
|
| 150 |
+
const object = {};
|
| 151 |
+
onValue(object);
|
| 152 |
+
previousParents.push(currentParent);
|
| 153 |
+
currentParent = object;
|
| 154 |
+
currentProperty = null;
|
| 155 |
+
},
|
| 156 |
+
onObjectProperty: (name) => {
|
| 157 |
+
currentProperty = name;
|
| 158 |
+
},
|
| 159 |
+
onObjectEnd: () => {
|
| 160 |
+
currentParent = previousParents.pop();
|
| 161 |
+
},
|
| 162 |
+
onArrayBegin: () => {
|
| 163 |
+
const array = [];
|
| 164 |
+
onValue(array);
|
| 165 |
+
previousParents.push(currentParent);
|
| 166 |
+
currentParent = array;
|
| 167 |
+
currentProperty = null;
|
| 168 |
+
},
|
| 169 |
+
onArrayEnd: () => {
|
| 170 |
+
currentParent = previousParents.pop();
|
| 171 |
+
},
|
| 172 |
+
onLiteralValue: onValue,
|
| 173 |
+
onError: (error, offset, length) => {
|
| 174 |
+
errors.push({ error, offset, length });
|
| 175 |
+
}
|
| 176 |
+
};
|
| 177 |
+
visit(text, visitor, options);
|
| 178 |
+
return currentParent[0];
|
| 179 |
+
}
|
| 180 |
+
/**
|
| 181 |
+
* Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 182 |
+
*/
|
| 183 |
+
export function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
| 184 |
+
let currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root
|
| 185 |
+
function ensurePropertyComplete(endOffset) {
|
| 186 |
+
if (currentParent.type === 'property') {
|
| 187 |
+
currentParent.length = endOffset - currentParent.offset;
|
| 188 |
+
currentParent = currentParent.parent;
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
function onValue(valueNode) {
|
| 192 |
+
currentParent.children.push(valueNode);
|
| 193 |
+
return valueNode;
|
| 194 |
+
}
|
| 195 |
+
const visitor = {
|
| 196 |
+
onObjectBegin: (offset) => {
|
| 197 |
+
currentParent = onValue({ type: 'object', offset, length: -1, parent: currentParent, children: [] });
|
| 198 |
+
},
|
| 199 |
+
onObjectProperty: (name, offset, length) => {
|
| 200 |
+
currentParent = onValue({ type: 'property', offset, length: -1, parent: currentParent, children: [] });
|
| 201 |
+
currentParent.children.push({ type: 'string', value: name, offset, length, parent: currentParent });
|
| 202 |
+
},
|
| 203 |
+
onObjectEnd: (offset, length) => {
|
| 204 |
+
ensurePropertyComplete(offset + length); // in case of a missing value for a property: make sure property is complete
|
| 205 |
+
currentParent.length = offset + length - currentParent.offset;
|
| 206 |
+
currentParent = currentParent.parent;
|
| 207 |
+
ensurePropertyComplete(offset + length);
|
| 208 |
+
},
|
| 209 |
+
onArrayBegin: (offset, length) => {
|
| 210 |
+
currentParent = onValue({ type: 'array', offset, length: -1, parent: currentParent, children: [] });
|
| 211 |
+
},
|
| 212 |
+
onArrayEnd: (offset, length) => {
|
| 213 |
+
currentParent.length = offset + length - currentParent.offset;
|
| 214 |
+
currentParent = currentParent.parent;
|
| 215 |
+
ensurePropertyComplete(offset + length);
|
| 216 |
+
},
|
| 217 |
+
onLiteralValue: (value, offset, length) => {
|
| 218 |
+
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
| 219 |
+
ensurePropertyComplete(offset + length);
|
| 220 |
+
},
|
| 221 |
+
onSeparator: (sep, offset, length) => {
|
| 222 |
+
if (currentParent.type === 'property') {
|
| 223 |
+
if (sep === ':') {
|
| 224 |
+
currentParent.colonOffset = offset;
|
| 225 |
+
}
|
| 226 |
+
else if (sep === ',') {
|
| 227 |
+
ensurePropertyComplete(offset);
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
},
|
| 231 |
+
onError: (error, offset, length) => {
|
| 232 |
+
errors.push({ error, offset, length });
|
| 233 |
+
}
|
| 234 |
+
};
|
| 235 |
+
visit(text, visitor, options);
|
| 236 |
+
const result = currentParent.children[0];
|
| 237 |
+
if (result) {
|
| 238 |
+
delete result.parent;
|
| 239 |
+
}
|
| 240 |
+
return result;
|
| 241 |
+
}
|
| 242 |
+
/**
|
| 243 |
+
* Finds the node at the given path in a JSON DOM.
|
| 244 |
+
*/
|
| 245 |
+
export function findNodeAtLocation(root, path) {
|
| 246 |
+
if (!root) {
|
| 247 |
+
return undefined;
|
| 248 |
+
}
|
| 249 |
+
let node = root;
|
| 250 |
+
for (let segment of path) {
|
| 251 |
+
if (typeof segment === 'string') {
|
| 252 |
+
if (node.type !== 'object' || !Array.isArray(node.children)) {
|
| 253 |
+
return undefined;
|
| 254 |
+
}
|
| 255 |
+
let found = false;
|
| 256 |
+
for (const propertyNode of node.children) {
|
| 257 |
+
if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
|
| 258 |
+
node = propertyNode.children[1];
|
| 259 |
+
found = true;
|
| 260 |
+
break;
|
| 261 |
+
}
|
| 262 |
+
}
|
| 263 |
+
if (!found) {
|
| 264 |
+
return undefined;
|
| 265 |
+
}
|
| 266 |
+
}
|
| 267 |
+
else {
|
| 268 |
+
const index = segment;
|
| 269 |
+
if (node.type !== 'array' || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
|
| 270 |
+
return undefined;
|
| 271 |
+
}
|
| 272 |
+
node = node.children[index];
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
return node;
|
| 276 |
+
}
|
| 277 |
+
/**
|
| 278 |
+
* Gets the JSON path of the given JSON DOM node
|
| 279 |
+
*/
|
| 280 |
+
export function getNodePath(node) {
|
| 281 |
+
if (!node.parent || !node.parent.children) {
|
| 282 |
+
return [];
|
| 283 |
+
}
|
| 284 |
+
const path = getNodePath(node.parent);
|
| 285 |
+
if (node.parent.type === 'property') {
|
| 286 |
+
const key = node.parent.children[0].value;
|
| 287 |
+
path.push(key);
|
| 288 |
+
}
|
| 289 |
+
else if (node.parent.type === 'array') {
|
| 290 |
+
const index = node.parent.children.indexOf(node);
|
| 291 |
+
if (index !== -1) {
|
| 292 |
+
path.push(index);
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
return path;
|
| 296 |
+
}
|
| 297 |
+
/**
|
| 298 |
+
* Evaluates the JavaScript object of the given JSON DOM node
|
| 299 |
+
*/
|
| 300 |
+
export function getNodeValue(node) {
|
| 301 |
+
switch (node.type) {
|
| 302 |
+
case 'array':
|
| 303 |
+
return node.children.map(getNodeValue);
|
| 304 |
+
case 'object':
|
| 305 |
+
const obj = Object.create(null);
|
| 306 |
+
for (let prop of node.children) {
|
| 307 |
+
const valueNode = prop.children[1];
|
| 308 |
+
if (valueNode) {
|
| 309 |
+
obj[prop.children[0].value] = getNodeValue(valueNode);
|
| 310 |
+
}
|
| 311 |
+
}
|
| 312 |
+
return obj;
|
| 313 |
+
case 'null':
|
| 314 |
+
case 'string':
|
| 315 |
+
case 'number':
|
| 316 |
+
case 'boolean':
|
| 317 |
+
return node.value;
|
| 318 |
+
default:
|
| 319 |
+
return undefined;
|
| 320 |
+
}
|
| 321 |
+
}
|
| 322 |
+
export function contains(node, offset, includeRightBound = false) {
|
| 323 |
+
return (offset >= node.offset && offset < (node.offset + node.length)) || includeRightBound && (offset === (node.offset + node.length));
|
| 324 |
+
}
|
| 325 |
+
/**
|
| 326 |
+
* Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
|
| 327 |
+
*/
|
| 328 |
+
export function findNodeAtOffset(node, offset, includeRightBound = false) {
|
| 329 |
+
if (contains(node, offset, includeRightBound)) {
|
| 330 |
+
const children = node.children;
|
| 331 |
+
if (Array.isArray(children)) {
|
| 332 |
+
for (let i = 0; i < children.length && children[i].offset <= offset; i++) {
|
| 333 |
+
const item = findNodeAtOffset(children[i], offset, includeRightBound);
|
| 334 |
+
if (item) {
|
| 335 |
+
return item;
|
| 336 |
+
}
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
return node;
|
| 340 |
+
}
|
| 341 |
+
return undefined;
|
| 342 |
+
}
|
| 343 |
+
/**
|
| 344 |
+
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
| 345 |
+
*/
|
| 346 |
+
export function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
| 347 |
+
const _scanner = createScanner(text, false);
|
| 348 |
+
// Important: Only pass copies of this to visitor functions to prevent accidental modification, and
|
| 349 |
+
// to not affect visitor functions which stored a reference to a previous JSONPath
|
| 350 |
+
const _jsonPath = [];
|
| 351 |
+
function toNoArgVisit(visitFunction) {
|
| 352 |
+
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
| 353 |
+
}
|
| 354 |
+
function toNoArgVisitWithPath(visitFunction) {
|
| 355 |
+
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
| 356 |
+
}
|
| 357 |
+
function toOneArgVisit(visitFunction) {
|
| 358 |
+
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
| 359 |
+
}
|
| 360 |
+
function toOneArgVisitWithPath(visitFunction) {
|
| 361 |
+
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
| 362 |
+
}
|
| 363 |
+
const onObjectBegin = toNoArgVisitWithPath(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisitWithPath(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
| 364 |
+
const disallowComments = options && options.disallowComments;
|
| 365 |
+
const allowTrailingComma = options && options.allowTrailingComma;
|
| 366 |
+
function scanNext() {
|
| 367 |
+
while (true) {
|
| 368 |
+
const token = _scanner.scan();
|
| 369 |
+
switch (_scanner.getTokenError()) {
|
| 370 |
+
case 4 /* ScanError.InvalidUnicode */:
|
| 371 |
+
handleError(14 /* ParseErrorCode.InvalidUnicode */);
|
| 372 |
+
break;
|
| 373 |
+
case 5 /* ScanError.InvalidEscapeCharacter */:
|
| 374 |
+
handleError(15 /* ParseErrorCode.InvalidEscapeCharacter */);
|
| 375 |
+
break;
|
| 376 |
+
case 3 /* ScanError.UnexpectedEndOfNumber */:
|
| 377 |
+
handleError(13 /* ParseErrorCode.UnexpectedEndOfNumber */);
|
| 378 |
+
break;
|
| 379 |
+
case 1 /* ScanError.UnexpectedEndOfComment */:
|
| 380 |
+
if (!disallowComments) {
|
| 381 |
+
handleError(11 /* ParseErrorCode.UnexpectedEndOfComment */);
|
| 382 |
+
}
|
| 383 |
+
break;
|
| 384 |
+
case 2 /* ScanError.UnexpectedEndOfString */:
|
| 385 |
+
handleError(12 /* ParseErrorCode.UnexpectedEndOfString */);
|
| 386 |
+
break;
|
| 387 |
+
case 6 /* ScanError.InvalidCharacter */:
|
| 388 |
+
handleError(16 /* ParseErrorCode.InvalidCharacter */);
|
| 389 |
+
break;
|
| 390 |
+
}
|
| 391 |
+
switch (token) {
|
| 392 |
+
case 12 /* SyntaxKind.LineCommentTrivia */:
|
| 393 |
+
case 13 /* SyntaxKind.BlockCommentTrivia */:
|
| 394 |
+
if (disallowComments) {
|
| 395 |
+
handleError(10 /* ParseErrorCode.InvalidCommentToken */);
|
| 396 |
+
}
|
| 397 |
+
else {
|
| 398 |
+
onComment();
|
| 399 |
+
}
|
| 400 |
+
break;
|
| 401 |
+
case 16 /* SyntaxKind.Unknown */:
|
| 402 |
+
handleError(1 /* ParseErrorCode.InvalidSymbol */);
|
| 403 |
+
break;
|
| 404 |
+
case 15 /* SyntaxKind.Trivia */:
|
| 405 |
+
case 14 /* SyntaxKind.LineBreakTrivia */:
|
| 406 |
+
break;
|
| 407 |
+
default:
|
| 408 |
+
return token;
|
| 409 |
+
}
|
| 410 |
+
}
|
| 411 |
+
}
|
| 412 |
+
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
| 413 |
+
onError(error);
|
| 414 |
+
if (skipUntilAfter.length + skipUntil.length > 0) {
|
| 415 |
+
let token = _scanner.getToken();
|
| 416 |
+
while (token !== 17 /* SyntaxKind.EOF */) {
|
| 417 |
+
if (skipUntilAfter.indexOf(token) !== -1) {
|
| 418 |
+
scanNext();
|
| 419 |
+
break;
|
| 420 |
+
}
|
| 421 |
+
else if (skipUntil.indexOf(token) !== -1) {
|
| 422 |
+
break;
|
| 423 |
+
}
|
| 424 |
+
token = scanNext();
|
| 425 |
+
}
|
| 426 |
+
}
|
| 427 |
+
}
|
| 428 |
+
function parseString(isValue) {
|
| 429 |
+
const value = _scanner.getTokenValue();
|
| 430 |
+
if (isValue) {
|
| 431 |
+
onLiteralValue(value);
|
| 432 |
+
}
|
| 433 |
+
else {
|
| 434 |
+
onObjectProperty(value);
|
| 435 |
+
// add property name afterwards
|
| 436 |
+
_jsonPath.push(value);
|
| 437 |
+
}
|
| 438 |
+
scanNext();
|
| 439 |
+
return true;
|
| 440 |
+
}
|
| 441 |
+
function parseLiteral() {
|
| 442 |
+
switch (_scanner.getToken()) {
|
| 443 |
+
case 11 /* SyntaxKind.NumericLiteral */:
|
| 444 |
+
const tokenValue = _scanner.getTokenValue();
|
| 445 |
+
let value = Number(tokenValue);
|
| 446 |
+
if (isNaN(value)) {
|
| 447 |
+
handleError(2 /* ParseErrorCode.InvalidNumberFormat */);
|
| 448 |
+
value = 0;
|
| 449 |
+
}
|
| 450 |
+
onLiteralValue(value);
|
| 451 |
+
break;
|
| 452 |
+
case 7 /* SyntaxKind.NullKeyword */:
|
| 453 |
+
onLiteralValue(null);
|
| 454 |
+
break;
|
| 455 |
+
case 8 /* SyntaxKind.TrueKeyword */:
|
| 456 |
+
onLiteralValue(true);
|
| 457 |
+
break;
|
| 458 |
+
case 9 /* SyntaxKind.FalseKeyword */:
|
| 459 |
+
onLiteralValue(false);
|
| 460 |
+
break;
|
| 461 |
+
default:
|
| 462 |
+
return false;
|
| 463 |
+
}
|
| 464 |
+
scanNext();
|
| 465 |
+
return true;
|
| 466 |
+
}
|
| 467 |
+
function parseProperty() {
|
| 468 |
+
if (_scanner.getToken() !== 10 /* SyntaxKind.StringLiteral */) {
|
| 469 |
+
handleError(3 /* ParseErrorCode.PropertyNameExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
| 470 |
+
return false;
|
| 471 |
+
}
|
| 472 |
+
parseString(false);
|
| 473 |
+
if (_scanner.getToken() === 6 /* SyntaxKind.ColonToken */) {
|
| 474 |
+
onSeparator(':');
|
| 475 |
+
scanNext(); // consume colon
|
| 476 |
+
if (!parseValue()) {
|
| 477 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
| 478 |
+
}
|
| 479 |
+
}
|
| 480 |
+
else {
|
| 481 |
+
handleError(5 /* ParseErrorCode.ColonExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
| 482 |
+
}
|
| 483 |
+
_jsonPath.pop(); // remove processed property name
|
| 484 |
+
return true;
|
| 485 |
+
}
|
| 486 |
+
function parseObject() {
|
| 487 |
+
onObjectBegin();
|
| 488 |
+
scanNext(); // consume open brace
|
| 489 |
+
let needsComma = false;
|
| 490 |
+
while (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
| 491 |
+
if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
|
| 492 |
+
if (!needsComma) {
|
| 493 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
| 494 |
+
}
|
| 495 |
+
onSeparator(',');
|
| 496 |
+
scanNext(); // consume comma
|
| 497 |
+
if (_scanner.getToken() === 2 /* SyntaxKind.CloseBraceToken */ && allowTrailingComma) {
|
| 498 |
+
break;
|
| 499 |
+
}
|
| 500 |
+
}
|
| 501 |
+
else if (needsComma) {
|
| 502 |
+
handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
|
| 503 |
+
}
|
| 504 |
+
if (!parseProperty()) {
|
| 505 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
| 506 |
+
}
|
| 507 |
+
needsComma = true;
|
| 508 |
+
}
|
| 509 |
+
onObjectEnd();
|
| 510 |
+
if (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */) {
|
| 511 |
+
handleError(7 /* ParseErrorCode.CloseBraceExpected */, [2 /* SyntaxKind.CloseBraceToken */], []);
|
| 512 |
+
}
|
| 513 |
+
else {
|
| 514 |
+
scanNext(); // consume close brace
|
| 515 |
+
}
|
| 516 |
+
return true;
|
| 517 |
+
}
|
| 518 |
+
function parseArray() {
|
| 519 |
+
onArrayBegin();
|
| 520 |
+
scanNext(); // consume open bracket
|
| 521 |
+
let isFirstElement = true;
|
| 522 |
+
let needsComma = false;
|
| 523 |
+
while (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
| 524 |
+
if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
|
| 525 |
+
if (!needsComma) {
|
| 526 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
| 527 |
+
}
|
| 528 |
+
onSeparator(',');
|
| 529 |
+
scanNext(); // consume comma
|
| 530 |
+
if (_scanner.getToken() === 4 /* SyntaxKind.CloseBracketToken */ && allowTrailingComma) {
|
| 531 |
+
break;
|
| 532 |
+
}
|
| 533 |
+
}
|
| 534 |
+
else if (needsComma) {
|
| 535 |
+
handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
|
| 536 |
+
}
|
| 537 |
+
if (isFirstElement) {
|
| 538 |
+
_jsonPath.push(0);
|
| 539 |
+
isFirstElement = false;
|
| 540 |
+
}
|
| 541 |
+
else {
|
| 542 |
+
_jsonPath[_jsonPath.length - 1]++;
|
| 543 |
+
}
|
| 544 |
+
if (!parseValue()) {
|
| 545 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], [4 /* SyntaxKind.CloseBracketToken */, 5 /* SyntaxKind.CommaToken */]);
|
| 546 |
+
}
|
| 547 |
+
needsComma = true;
|
| 548 |
+
}
|
| 549 |
+
onArrayEnd();
|
| 550 |
+
if (!isFirstElement) {
|
| 551 |
+
_jsonPath.pop(); // remove array index
|
| 552 |
+
}
|
| 553 |
+
if (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */) {
|
| 554 |
+
handleError(8 /* ParseErrorCode.CloseBracketExpected */, [4 /* SyntaxKind.CloseBracketToken */], []);
|
| 555 |
+
}
|
| 556 |
+
else {
|
| 557 |
+
scanNext(); // consume close bracket
|
| 558 |
+
}
|
| 559 |
+
return true;
|
| 560 |
+
}
|
| 561 |
+
function parseValue() {
|
| 562 |
+
switch (_scanner.getToken()) {
|
| 563 |
+
case 3 /* SyntaxKind.OpenBracketToken */:
|
| 564 |
+
return parseArray();
|
| 565 |
+
case 1 /* SyntaxKind.OpenBraceToken */:
|
| 566 |
+
return parseObject();
|
| 567 |
+
case 10 /* SyntaxKind.StringLiteral */:
|
| 568 |
+
return parseString(true);
|
| 569 |
+
default:
|
| 570 |
+
return parseLiteral();
|
| 571 |
+
}
|
| 572 |
+
}
|
| 573 |
+
scanNext();
|
| 574 |
+
if (_scanner.getToken() === 17 /* SyntaxKind.EOF */) {
|
| 575 |
+
if (options.allowEmptyContent) {
|
| 576 |
+
return true;
|
| 577 |
+
}
|
| 578 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
| 579 |
+
return false;
|
| 580 |
+
}
|
| 581 |
+
if (!parseValue()) {
|
| 582 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
| 583 |
+
return false;
|
| 584 |
+
}
|
| 585 |
+
if (_scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
| 586 |
+
handleError(9 /* ParseErrorCode.EndOfFileExpected */, [], []);
|
| 587 |
+
}
|
| 588 |
+
return true;
|
| 589 |
+
}
|
| 590 |
+
/**
|
| 591 |
+
* Takes JSON with JavaScript-style comments and remove
|
| 592 |
+
* them. Optionally replaces every none-newline character
|
| 593 |
+
* of comments with a replaceCharacter
|
| 594 |
+
*/
|
| 595 |
+
export function stripComments(text, replaceCh) {
|
| 596 |
+
let _scanner = createScanner(text), parts = [], kind, offset = 0, pos;
|
| 597 |
+
do {
|
| 598 |
+
pos = _scanner.getPosition();
|
| 599 |
+
kind = _scanner.scan();
|
| 600 |
+
switch (kind) {
|
| 601 |
+
case 12 /* SyntaxKind.LineCommentTrivia */:
|
| 602 |
+
case 13 /* SyntaxKind.BlockCommentTrivia */:
|
| 603 |
+
case 17 /* SyntaxKind.EOF */:
|
| 604 |
+
if (offset !== pos) {
|
| 605 |
+
parts.push(text.substring(offset, pos));
|
| 606 |
+
}
|
| 607 |
+
if (replaceCh !== undefined) {
|
| 608 |
+
parts.push(_scanner.getTokenValue().replace(/[^\r\n]/g, replaceCh));
|
| 609 |
+
}
|
| 610 |
+
offset = _scanner.getPosition();
|
| 611 |
+
break;
|
| 612 |
+
}
|
| 613 |
+
} while (kind !== 17 /* SyntaxKind.EOF */);
|
| 614 |
+
return parts.join('');
|
| 615 |
+
}
|
| 616 |
+
export function getNodeType(value) {
|
| 617 |
+
switch (typeof value) {
|
| 618 |
+
case 'boolean': return 'boolean';
|
| 619 |
+
case 'number': return 'number';
|
| 620 |
+
case 'string': return 'string';
|
| 621 |
+
case 'object': {
|
| 622 |
+
if (!value) {
|
| 623 |
+
return 'null';
|
| 624 |
+
}
|
| 625 |
+
else if (Array.isArray(value)) {
|
| 626 |
+
return 'array';
|
| 627 |
+
}
|
| 628 |
+
return 'object';
|
| 629 |
+
}
|
| 630 |
+
default: return 'null';
|
| 631 |
+
}
|
| 632 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/impl/scanner.js
CHANGED
|
@@ -1,3 +1,443 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*---------------------------------------------------------------------------------------------
|
| 2 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 3 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 4 |
+
*--------------------------------------------------------------------------------------------*/
|
| 5 |
+
'use strict';
|
| 6 |
+
/**
|
| 7 |
+
* Creates a JSON scanner on the given text.
|
| 8 |
+
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
| 9 |
+
*/
|
| 10 |
+
export function createScanner(text, ignoreTrivia = false) {
|
| 11 |
+
const len = text.length;
|
| 12 |
+
let pos = 0, value = '', tokenOffset = 0, token = 16 /* SyntaxKind.Unknown */, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0 /* ScanError.None */;
|
| 13 |
+
function scanHexDigits(count, exact) {
|
| 14 |
+
let digits = 0;
|
| 15 |
+
let value = 0;
|
| 16 |
+
while (digits < count || !exact) {
|
| 17 |
+
let ch = text.charCodeAt(pos);
|
| 18 |
+
if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) {
|
| 19 |
+
value = value * 16 + ch - 48 /* CharacterCodes._0 */;
|
| 20 |
+
}
|
| 21 |
+
else if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) {
|
| 22 |
+
value = value * 16 + ch - 65 /* CharacterCodes.A */ + 10;
|
| 23 |
+
}
|
| 24 |
+
else if (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */) {
|
| 25 |
+
value = value * 16 + ch - 97 /* CharacterCodes.a */ + 10;
|
| 26 |
+
}
|
| 27 |
+
else {
|
| 28 |
+
break;
|
| 29 |
+
}
|
| 30 |
+
pos++;
|
| 31 |
+
digits++;
|
| 32 |
+
}
|
| 33 |
+
if (digits < count) {
|
| 34 |
+
value = -1;
|
| 35 |
+
}
|
| 36 |
+
return value;
|
| 37 |
+
}
|
| 38 |
+
function setPosition(newPosition) {
|
| 39 |
+
pos = newPosition;
|
| 40 |
+
value = '';
|
| 41 |
+
tokenOffset = 0;
|
| 42 |
+
token = 16 /* SyntaxKind.Unknown */;
|
| 43 |
+
scanError = 0 /* ScanError.None */;
|
| 44 |
+
}
|
| 45 |
+
function scanNumber() {
|
| 46 |
+
let start = pos;
|
| 47 |
+
if (text.charCodeAt(pos) === 48 /* CharacterCodes._0 */) {
|
| 48 |
+
pos++;
|
| 49 |
+
}
|
| 50 |
+
else {
|
| 51 |
+
pos++;
|
| 52 |
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
| 53 |
+
pos++;
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
if (pos < text.length && text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) {
|
| 57 |
+
pos++;
|
| 58 |
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
| 59 |
+
pos++;
|
| 60 |
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
| 61 |
+
pos++;
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
else {
|
| 65 |
+
scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
|
| 66 |
+
return text.substring(start, pos);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
let end = pos;
|
| 70 |
+
if (pos < text.length && (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */)) {
|
| 71 |
+
pos++;
|
| 72 |
+
if (pos < text.length && text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) {
|
| 73 |
+
pos++;
|
| 74 |
+
}
|
| 75 |
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
| 76 |
+
pos++;
|
| 77 |
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
| 78 |
+
pos++;
|
| 79 |
+
}
|
| 80 |
+
end = pos;
|
| 81 |
+
}
|
| 82 |
+
else {
|
| 83 |
+
scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
return text.substring(start, end);
|
| 87 |
+
}
|
| 88 |
+
function scanString() {
|
| 89 |
+
let result = '', start = pos;
|
| 90 |
+
while (true) {
|
| 91 |
+
if (pos >= len) {
|
| 92 |
+
result += text.substring(start, pos);
|
| 93 |
+
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
| 94 |
+
break;
|
| 95 |
+
}
|
| 96 |
+
const ch = text.charCodeAt(pos);
|
| 97 |
+
if (ch === 34 /* CharacterCodes.doubleQuote */) {
|
| 98 |
+
result += text.substring(start, pos);
|
| 99 |
+
pos++;
|
| 100 |
+
break;
|
| 101 |
+
}
|
| 102 |
+
if (ch === 92 /* CharacterCodes.backslash */) {
|
| 103 |
+
result += text.substring(start, pos);
|
| 104 |
+
pos++;
|
| 105 |
+
if (pos >= len) {
|
| 106 |
+
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
| 107 |
+
break;
|
| 108 |
+
}
|
| 109 |
+
const ch2 = text.charCodeAt(pos++);
|
| 110 |
+
switch (ch2) {
|
| 111 |
+
case 34 /* CharacterCodes.doubleQuote */:
|
| 112 |
+
result += '\"';
|
| 113 |
+
break;
|
| 114 |
+
case 92 /* CharacterCodes.backslash */:
|
| 115 |
+
result += '\\';
|
| 116 |
+
break;
|
| 117 |
+
case 47 /* CharacterCodes.slash */:
|
| 118 |
+
result += '/';
|
| 119 |
+
break;
|
| 120 |
+
case 98 /* CharacterCodes.b */:
|
| 121 |
+
result += '\b';
|
| 122 |
+
break;
|
| 123 |
+
case 102 /* CharacterCodes.f */:
|
| 124 |
+
result += '\f';
|
| 125 |
+
break;
|
| 126 |
+
case 110 /* CharacterCodes.n */:
|
| 127 |
+
result += '\n';
|
| 128 |
+
break;
|
| 129 |
+
case 114 /* CharacterCodes.r */:
|
| 130 |
+
result += '\r';
|
| 131 |
+
break;
|
| 132 |
+
case 116 /* CharacterCodes.t */:
|
| 133 |
+
result += '\t';
|
| 134 |
+
break;
|
| 135 |
+
case 117 /* CharacterCodes.u */:
|
| 136 |
+
const ch3 = scanHexDigits(4, true);
|
| 137 |
+
if (ch3 >= 0) {
|
| 138 |
+
result += String.fromCharCode(ch3);
|
| 139 |
+
}
|
| 140 |
+
else {
|
| 141 |
+
scanError = 4 /* ScanError.InvalidUnicode */;
|
| 142 |
+
}
|
| 143 |
+
break;
|
| 144 |
+
default:
|
| 145 |
+
scanError = 5 /* ScanError.InvalidEscapeCharacter */;
|
| 146 |
+
}
|
| 147 |
+
start = pos;
|
| 148 |
+
continue;
|
| 149 |
+
}
|
| 150 |
+
if (ch >= 0 && ch <= 0x1f) {
|
| 151 |
+
if (isLineBreak(ch)) {
|
| 152 |
+
result += text.substring(start, pos);
|
| 153 |
+
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
| 154 |
+
break;
|
| 155 |
+
}
|
| 156 |
+
else {
|
| 157 |
+
scanError = 6 /* ScanError.InvalidCharacter */;
|
| 158 |
+
// mark as error but continue with string
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
pos++;
|
| 162 |
+
}
|
| 163 |
+
return result;
|
| 164 |
+
}
|
| 165 |
+
function scanNext() {
|
| 166 |
+
value = '';
|
| 167 |
+
scanError = 0 /* ScanError.None */;
|
| 168 |
+
tokenOffset = pos;
|
| 169 |
+
lineStartOffset = lineNumber;
|
| 170 |
+
prevTokenLineStartOffset = tokenLineStartOffset;
|
| 171 |
+
if (pos >= len) {
|
| 172 |
+
// at the end
|
| 173 |
+
tokenOffset = len;
|
| 174 |
+
return token = 17 /* SyntaxKind.EOF */;
|
| 175 |
+
}
|
| 176 |
+
let code = text.charCodeAt(pos);
|
| 177 |
+
// trivia: whitespace
|
| 178 |
+
if (isWhiteSpace(code)) {
|
| 179 |
+
do {
|
| 180 |
+
pos++;
|
| 181 |
+
value += String.fromCharCode(code);
|
| 182 |
+
code = text.charCodeAt(pos);
|
| 183 |
+
} while (isWhiteSpace(code));
|
| 184 |
+
return token = 15 /* SyntaxKind.Trivia */;
|
| 185 |
+
}
|
| 186 |
+
// trivia: newlines
|
| 187 |
+
if (isLineBreak(code)) {
|
| 188 |
+
pos++;
|
| 189 |
+
value += String.fromCharCode(code);
|
| 190 |
+
if (code === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
|
| 191 |
+
pos++;
|
| 192 |
+
value += '\n';
|
| 193 |
+
}
|
| 194 |
+
lineNumber++;
|
| 195 |
+
tokenLineStartOffset = pos;
|
| 196 |
+
return token = 14 /* SyntaxKind.LineBreakTrivia */;
|
| 197 |
+
}
|
| 198 |
+
switch (code) {
|
| 199 |
+
// tokens: []{}:,
|
| 200 |
+
case 123 /* CharacterCodes.openBrace */:
|
| 201 |
+
pos++;
|
| 202 |
+
return token = 1 /* SyntaxKind.OpenBraceToken */;
|
| 203 |
+
case 125 /* CharacterCodes.closeBrace */:
|
| 204 |
+
pos++;
|
| 205 |
+
return token = 2 /* SyntaxKind.CloseBraceToken */;
|
| 206 |
+
case 91 /* CharacterCodes.openBracket */:
|
| 207 |
+
pos++;
|
| 208 |
+
return token = 3 /* SyntaxKind.OpenBracketToken */;
|
| 209 |
+
case 93 /* CharacterCodes.closeBracket */:
|
| 210 |
+
pos++;
|
| 211 |
+
return token = 4 /* SyntaxKind.CloseBracketToken */;
|
| 212 |
+
case 58 /* CharacterCodes.colon */:
|
| 213 |
+
pos++;
|
| 214 |
+
return token = 6 /* SyntaxKind.ColonToken */;
|
| 215 |
+
case 44 /* CharacterCodes.comma */:
|
| 216 |
+
pos++;
|
| 217 |
+
return token = 5 /* SyntaxKind.CommaToken */;
|
| 218 |
+
// strings
|
| 219 |
+
case 34 /* CharacterCodes.doubleQuote */:
|
| 220 |
+
pos++;
|
| 221 |
+
value = scanString();
|
| 222 |
+
return token = 10 /* SyntaxKind.StringLiteral */;
|
| 223 |
+
// comments
|
| 224 |
+
case 47 /* CharacterCodes.slash */:
|
| 225 |
+
const start = pos - 1;
|
| 226 |
+
// Single-line comment
|
| 227 |
+
if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
|
| 228 |
+
pos += 2;
|
| 229 |
+
while (pos < len) {
|
| 230 |
+
if (isLineBreak(text.charCodeAt(pos))) {
|
| 231 |
+
break;
|
| 232 |
+
}
|
| 233 |
+
pos++;
|
| 234 |
+
}
|
| 235 |
+
value = text.substring(start, pos);
|
| 236 |
+
return token = 12 /* SyntaxKind.LineCommentTrivia */;
|
| 237 |
+
}
|
| 238 |
+
// Multi-line comment
|
| 239 |
+
if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
|
| 240 |
+
pos += 2;
|
| 241 |
+
const safeLength = len - 1; // For lookahead.
|
| 242 |
+
let commentClosed = false;
|
| 243 |
+
while (pos < safeLength) {
|
| 244 |
+
const ch = text.charCodeAt(pos);
|
| 245 |
+
if (ch === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
|
| 246 |
+
pos += 2;
|
| 247 |
+
commentClosed = true;
|
| 248 |
+
break;
|
| 249 |
+
}
|
| 250 |
+
pos++;
|
| 251 |
+
if (isLineBreak(ch)) {
|
| 252 |
+
if (ch === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
|
| 253 |
+
pos++;
|
| 254 |
+
}
|
| 255 |
+
lineNumber++;
|
| 256 |
+
tokenLineStartOffset = pos;
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
if (!commentClosed) {
|
| 260 |
+
pos++;
|
| 261 |
+
scanError = 1 /* ScanError.UnexpectedEndOfComment */;
|
| 262 |
+
}
|
| 263 |
+
value = text.substring(start, pos);
|
| 264 |
+
return token = 13 /* SyntaxKind.BlockCommentTrivia */;
|
| 265 |
+
}
|
| 266 |
+
// just a single slash
|
| 267 |
+
value += String.fromCharCode(code);
|
| 268 |
+
pos++;
|
| 269 |
+
return token = 16 /* SyntaxKind.Unknown */;
|
| 270 |
+
// numbers
|
| 271 |
+
case 45 /* CharacterCodes.minus */:
|
| 272 |
+
value += String.fromCharCode(code);
|
| 273 |
+
pos++;
|
| 274 |
+
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
| 275 |
+
return token = 16 /* SyntaxKind.Unknown */;
|
| 276 |
+
}
|
| 277 |
+
// found a minus, followed by a number so
|
| 278 |
+
// we fall through to proceed with scanning
|
| 279 |
+
// numbers
|
| 280 |
+
case 48 /* CharacterCodes._0 */:
|
| 281 |
+
case 49 /* CharacterCodes._1 */:
|
| 282 |
+
case 50 /* CharacterCodes._2 */:
|
| 283 |
+
case 51 /* CharacterCodes._3 */:
|
| 284 |
+
case 52 /* CharacterCodes._4 */:
|
| 285 |
+
case 53 /* CharacterCodes._5 */:
|
| 286 |
+
case 54 /* CharacterCodes._6 */:
|
| 287 |
+
case 55 /* CharacterCodes._7 */:
|
| 288 |
+
case 56 /* CharacterCodes._8 */:
|
| 289 |
+
case 57 /* CharacterCodes._9 */:
|
| 290 |
+
value += scanNumber();
|
| 291 |
+
return token = 11 /* SyntaxKind.NumericLiteral */;
|
| 292 |
+
// literals and unknown symbols
|
| 293 |
+
default:
|
| 294 |
+
// is a literal? Read the full word.
|
| 295 |
+
while (pos < len && isUnknownContentCharacter(code)) {
|
| 296 |
+
pos++;
|
| 297 |
+
code = text.charCodeAt(pos);
|
| 298 |
+
}
|
| 299 |
+
if (tokenOffset !== pos) {
|
| 300 |
+
value = text.substring(tokenOffset, pos);
|
| 301 |
+
// keywords: true, false, null
|
| 302 |
+
switch (value) {
|
| 303 |
+
case 'true': return token = 8 /* SyntaxKind.TrueKeyword */;
|
| 304 |
+
case 'false': return token = 9 /* SyntaxKind.FalseKeyword */;
|
| 305 |
+
case 'null': return token = 7 /* SyntaxKind.NullKeyword */;
|
| 306 |
+
}
|
| 307 |
+
return token = 16 /* SyntaxKind.Unknown */;
|
| 308 |
+
}
|
| 309 |
+
// some
|
| 310 |
+
value += String.fromCharCode(code);
|
| 311 |
+
pos++;
|
| 312 |
+
return token = 16 /* SyntaxKind.Unknown */;
|
| 313 |
+
}
|
| 314 |
+
}
|
| 315 |
+
function isUnknownContentCharacter(code) {
|
| 316 |
+
if (isWhiteSpace(code) || isLineBreak(code)) {
|
| 317 |
+
return false;
|
| 318 |
+
}
|
| 319 |
+
switch (code) {
|
| 320 |
+
case 125 /* CharacterCodes.closeBrace */:
|
| 321 |
+
case 93 /* CharacterCodes.closeBracket */:
|
| 322 |
+
case 123 /* CharacterCodes.openBrace */:
|
| 323 |
+
case 91 /* CharacterCodes.openBracket */:
|
| 324 |
+
case 34 /* CharacterCodes.doubleQuote */:
|
| 325 |
+
case 58 /* CharacterCodes.colon */:
|
| 326 |
+
case 44 /* CharacterCodes.comma */:
|
| 327 |
+
case 47 /* CharacterCodes.slash */:
|
| 328 |
+
return false;
|
| 329 |
+
}
|
| 330 |
+
return true;
|
| 331 |
+
}
|
| 332 |
+
function scanNextNonTrivia() {
|
| 333 |
+
let result;
|
| 334 |
+
do {
|
| 335 |
+
result = scanNext();
|
| 336 |
+
} while (result >= 12 /* SyntaxKind.LineCommentTrivia */ && result <= 15 /* SyntaxKind.Trivia */);
|
| 337 |
+
return result;
|
| 338 |
+
}
|
| 339 |
+
return {
|
| 340 |
+
setPosition: setPosition,
|
| 341 |
+
getPosition: () => pos,
|
| 342 |
+
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
| 343 |
+
getToken: () => token,
|
| 344 |
+
getTokenValue: () => value,
|
| 345 |
+
getTokenOffset: () => tokenOffset,
|
| 346 |
+
getTokenLength: () => pos - tokenOffset,
|
| 347 |
+
getTokenStartLine: () => lineStartOffset,
|
| 348 |
+
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
|
| 349 |
+
getTokenError: () => scanError,
|
| 350 |
+
};
|
| 351 |
+
}
|
| 352 |
+
function isWhiteSpace(ch) {
|
| 353 |
+
return ch === 32 /* CharacterCodes.space */ || ch === 9 /* CharacterCodes.tab */;
|
| 354 |
+
}
|
| 355 |
+
function isLineBreak(ch) {
|
| 356 |
+
return ch === 10 /* CharacterCodes.lineFeed */ || ch === 13 /* CharacterCodes.carriageReturn */;
|
| 357 |
+
}
|
| 358 |
+
function isDigit(ch) {
|
| 359 |
+
return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */;
|
| 360 |
+
}
|
| 361 |
+
var CharacterCodes;
|
| 362 |
+
(function (CharacterCodes) {
|
| 363 |
+
CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
|
| 364 |
+
CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
|
| 365 |
+
CharacterCodes[CharacterCodes["space"] = 32] = "space";
|
| 366 |
+
CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
|
| 367 |
+
CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
|
| 368 |
+
CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
|
| 369 |
+
CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
|
| 370 |
+
CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
|
| 371 |
+
CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
|
| 372 |
+
CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
|
| 373 |
+
CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
|
| 374 |
+
CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
|
| 375 |
+
CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
|
| 376 |
+
CharacterCodes[CharacterCodes["a"] = 97] = "a";
|
| 377 |
+
CharacterCodes[CharacterCodes["b"] = 98] = "b";
|
| 378 |
+
CharacterCodes[CharacterCodes["c"] = 99] = "c";
|
| 379 |
+
CharacterCodes[CharacterCodes["d"] = 100] = "d";
|
| 380 |
+
CharacterCodes[CharacterCodes["e"] = 101] = "e";
|
| 381 |
+
CharacterCodes[CharacterCodes["f"] = 102] = "f";
|
| 382 |
+
CharacterCodes[CharacterCodes["g"] = 103] = "g";
|
| 383 |
+
CharacterCodes[CharacterCodes["h"] = 104] = "h";
|
| 384 |
+
CharacterCodes[CharacterCodes["i"] = 105] = "i";
|
| 385 |
+
CharacterCodes[CharacterCodes["j"] = 106] = "j";
|
| 386 |
+
CharacterCodes[CharacterCodes["k"] = 107] = "k";
|
| 387 |
+
CharacterCodes[CharacterCodes["l"] = 108] = "l";
|
| 388 |
+
CharacterCodes[CharacterCodes["m"] = 109] = "m";
|
| 389 |
+
CharacterCodes[CharacterCodes["n"] = 110] = "n";
|
| 390 |
+
CharacterCodes[CharacterCodes["o"] = 111] = "o";
|
| 391 |
+
CharacterCodes[CharacterCodes["p"] = 112] = "p";
|
| 392 |
+
CharacterCodes[CharacterCodes["q"] = 113] = "q";
|
| 393 |
+
CharacterCodes[CharacterCodes["r"] = 114] = "r";
|
| 394 |
+
CharacterCodes[CharacterCodes["s"] = 115] = "s";
|
| 395 |
+
CharacterCodes[CharacterCodes["t"] = 116] = "t";
|
| 396 |
+
CharacterCodes[CharacterCodes["u"] = 117] = "u";
|
| 397 |
+
CharacterCodes[CharacterCodes["v"] = 118] = "v";
|
| 398 |
+
CharacterCodes[CharacterCodes["w"] = 119] = "w";
|
| 399 |
+
CharacterCodes[CharacterCodes["x"] = 120] = "x";
|
| 400 |
+
CharacterCodes[CharacterCodes["y"] = 121] = "y";
|
| 401 |
+
CharacterCodes[CharacterCodes["z"] = 122] = "z";
|
| 402 |
+
CharacterCodes[CharacterCodes["A"] = 65] = "A";
|
| 403 |
+
CharacterCodes[CharacterCodes["B"] = 66] = "B";
|
| 404 |
+
CharacterCodes[CharacterCodes["C"] = 67] = "C";
|
| 405 |
+
CharacterCodes[CharacterCodes["D"] = 68] = "D";
|
| 406 |
+
CharacterCodes[CharacterCodes["E"] = 69] = "E";
|
| 407 |
+
CharacterCodes[CharacterCodes["F"] = 70] = "F";
|
| 408 |
+
CharacterCodes[CharacterCodes["G"] = 71] = "G";
|
| 409 |
+
CharacterCodes[CharacterCodes["H"] = 72] = "H";
|
| 410 |
+
CharacterCodes[CharacterCodes["I"] = 73] = "I";
|
| 411 |
+
CharacterCodes[CharacterCodes["J"] = 74] = "J";
|
| 412 |
+
CharacterCodes[CharacterCodes["K"] = 75] = "K";
|
| 413 |
+
CharacterCodes[CharacterCodes["L"] = 76] = "L";
|
| 414 |
+
CharacterCodes[CharacterCodes["M"] = 77] = "M";
|
| 415 |
+
CharacterCodes[CharacterCodes["N"] = 78] = "N";
|
| 416 |
+
CharacterCodes[CharacterCodes["O"] = 79] = "O";
|
| 417 |
+
CharacterCodes[CharacterCodes["P"] = 80] = "P";
|
| 418 |
+
CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
|
| 419 |
+
CharacterCodes[CharacterCodes["R"] = 82] = "R";
|
| 420 |
+
CharacterCodes[CharacterCodes["S"] = 83] = "S";
|
| 421 |
+
CharacterCodes[CharacterCodes["T"] = 84] = "T";
|
| 422 |
+
CharacterCodes[CharacterCodes["U"] = 85] = "U";
|
| 423 |
+
CharacterCodes[CharacterCodes["V"] = 86] = "V";
|
| 424 |
+
CharacterCodes[CharacterCodes["W"] = 87] = "W";
|
| 425 |
+
CharacterCodes[CharacterCodes["X"] = 88] = "X";
|
| 426 |
+
CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
|
| 427 |
+
CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
|
| 428 |
+
CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
|
| 429 |
+
CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
|
| 430 |
+
CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
|
| 431 |
+
CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
|
| 432 |
+
CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
|
| 433 |
+
CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
|
| 434 |
+
CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
|
| 435 |
+
CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
|
| 436 |
+
CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
|
| 437 |
+
CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
|
| 438 |
+
CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
|
| 439 |
+
CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
|
| 440 |
+
CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
|
| 441 |
+
CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
|
| 442 |
+
CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
|
| 443 |
+
})(CharacterCodes || (CharacterCodes = {}));
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
CHANGED
|
@@ -1,3 +1,29 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export const cachedSpaces = new Array(20).fill(0).map((_, index) => {
|
| 2 |
+
return ' '.repeat(index);
|
| 3 |
+
});
|
| 4 |
+
const maxCachedValues = 200;
|
| 5 |
+
export const cachedBreakLinesWithSpaces = {
|
| 6 |
+
' ': {
|
| 7 |
+
'\n': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 8 |
+
return '\n' + ' '.repeat(index);
|
| 9 |
+
}),
|
| 10 |
+
'\r': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 11 |
+
return '\r' + ' '.repeat(index);
|
| 12 |
+
}),
|
| 13 |
+
'\r\n': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 14 |
+
return '\r\n' + ' '.repeat(index);
|
| 15 |
+
}),
|
| 16 |
+
},
|
| 17 |
+
'\t': {
|
| 18 |
+
'\n': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 19 |
+
return '\n' + '\t'.repeat(index);
|
| 20 |
+
}),
|
| 21 |
+
'\r': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 22 |
+
return '\r' + '\t'.repeat(index);
|
| 23 |
+
}),
|
| 24 |
+
'\r\n': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 25 |
+
return '\r\n' + '\t'.repeat(index);
|
| 26 |
+
}),
|
| 27 |
+
}
|
| 28 |
+
};
|
| 29 |
+
export const supportedEols = ['\n', '\r', '\r\n'];
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/main.d.ts
CHANGED
|
@@ -1,3 +1,349 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Creates a JSON scanner on the given text.
|
| 3 |
+
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
| 4 |
+
*/
|
| 5 |
+
export declare const createScanner: (text: string, ignoreTrivia?: boolean) => JSONScanner;
|
| 6 |
+
export declare const enum ScanError {
|
| 7 |
+
None = 0,
|
| 8 |
+
UnexpectedEndOfComment = 1,
|
| 9 |
+
UnexpectedEndOfString = 2,
|
| 10 |
+
UnexpectedEndOfNumber = 3,
|
| 11 |
+
InvalidUnicode = 4,
|
| 12 |
+
InvalidEscapeCharacter = 5,
|
| 13 |
+
InvalidCharacter = 6
|
| 14 |
+
}
|
| 15 |
+
export declare const enum SyntaxKind {
|
| 16 |
+
OpenBraceToken = 1,
|
| 17 |
+
CloseBraceToken = 2,
|
| 18 |
+
OpenBracketToken = 3,
|
| 19 |
+
CloseBracketToken = 4,
|
| 20 |
+
CommaToken = 5,
|
| 21 |
+
ColonToken = 6,
|
| 22 |
+
NullKeyword = 7,
|
| 23 |
+
TrueKeyword = 8,
|
| 24 |
+
FalseKeyword = 9,
|
| 25 |
+
StringLiteral = 10,
|
| 26 |
+
NumericLiteral = 11,
|
| 27 |
+
LineCommentTrivia = 12,
|
| 28 |
+
BlockCommentTrivia = 13,
|
| 29 |
+
LineBreakTrivia = 14,
|
| 30 |
+
Trivia = 15,
|
| 31 |
+
Unknown = 16,
|
| 32 |
+
EOF = 17
|
| 33 |
+
}
|
| 34 |
+
/**
|
| 35 |
+
* The scanner object, representing a JSON scanner at a position in the input string.
|
| 36 |
+
*/
|
| 37 |
+
export interface JSONScanner {
|
| 38 |
+
/**
|
| 39 |
+
* Sets the scan position to a new offset. A call to 'scan' is needed to get the first token.
|
| 40 |
+
*/
|
| 41 |
+
setPosition(pos: number): void;
|
| 42 |
+
/**
|
| 43 |
+
* Read the next token. Returns the token code.
|
| 44 |
+
*/
|
| 45 |
+
scan(): SyntaxKind;
|
| 46 |
+
/**
|
| 47 |
+
* Returns the zero-based current scan position, which is after the last read token.
|
| 48 |
+
*/
|
| 49 |
+
getPosition(): number;
|
| 50 |
+
/**
|
| 51 |
+
* Returns the last read token.
|
| 52 |
+
*/
|
| 53 |
+
getToken(): SyntaxKind;
|
| 54 |
+
/**
|
| 55 |
+
* Returns the last read token value. The value for strings is the decoded string content. For numbers it's of type number, for boolean it's true or false.
|
| 56 |
+
*/
|
| 57 |
+
getTokenValue(): string;
|
| 58 |
+
/**
|
| 59 |
+
* The zero-based start offset of the last read token.
|
| 60 |
+
*/
|
| 61 |
+
getTokenOffset(): number;
|
| 62 |
+
/**
|
| 63 |
+
* The length of the last read token.
|
| 64 |
+
*/
|
| 65 |
+
getTokenLength(): number;
|
| 66 |
+
/**
|
| 67 |
+
* The zero-based start line number of the last read token.
|
| 68 |
+
*/
|
| 69 |
+
getTokenStartLine(): number;
|
| 70 |
+
/**
|
| 71 |
+
* The zero-based start character (column) of the last read token.
|
| 72 |
+
*/
|
| 73 |
+
getTokenStartCharacter(): number;
|
| 74 |
+
/**
|
| 75 |
+
* An error code of the last scan.
|
| 76 |
+
*/
|
| 77 |
+
getTokenError(): ScanError;
|
| 78 |
+
}
|
| 79 |
+
/**
|
| 80 |
+
* For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
|
| 81 |
+
*/
|
| 82 |
+
export declare const getLocation: (text: string, position: number) => Location;
|
| 83 |
+
/**
|
| 84 |
+
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 85 |
+
* Therefore, always check the errors list to find out if the input was valid.
|
| 86 |
+
*/
|
| 87 |
+
export declare const parse: (text: string, errors?: ParseError[], options?: ParseOptions) => any;
|
| 88 |
+
/**
|
| 89 |
+
* Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 90 |
+
*/
|
| 91 |
+
export declare const parseTree: (text: string, errors?: ParseError[], options?: ParseOptions) => Node | undefined;
|
| 92 |
+
/**
|
| 93 |
+
* Finds the node at the given path in a JSON DOM.
|
| 94 |
+
*/
|
| 95 |
+
export declare const findNodeAtLocation: (root: Node, path: JSONPath) => Node | undefined;
|
| 96 |
+
/**
|
| 97 |
+
* Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
|
| 98 |
+
*/
|
| 99 |
+
export declare const findNodeAtOffset: (root: Node, offset: number, includeRightBound?: boolean) => Node | undefined;
|
| 100 |
+
/**
|
| 101 |
+
* Gets the JSON path of the given JSON DOM node
|
| 102 |
+
*/
|
| 103 |
+
export declare const getNodePath: (node: Node) => JSONPath;
|
| 104 |
+
/**
|
| 105 |
+
* Evaluates the JavaScript object of the given JSON DOM node
|
| 106 |
+
*/
|
| 107 |
+
export declare const getNodeValue: (node: Node) => any;
|
| 108 |
+
/**
|
| 109 |
+
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
| 110 |
+
*/
|
| 111 |
+
export declare const visit: (text: string, visitor: JSONVisitor, options?: ParseOptions) => any;
|
| 112 |
+
/**
|
| 113 |
+
* Takes JSON with JavaScript-style comments and remove
|
| 114 |
+
* them. Optionally replaces every none-newline character
|
| 115 |
+
* of comments with a replaceCharacter
|
| 116 |
+
*/
|
| 117 |
+
export declare const stripComments: (text: string, replaceCh?: string) => string;
|
| 118 |
+
export interface ParseError {
|
| 119 |
+
error: ParseErrorCode;
|
| 120 |
+
offset: number;
|
| 121 |
+
length: number;
|
| 122 |
+
}
|
| 123 |
+
export declare const enum ParseErrorCode {
|
| 124 |
+
InvalidSymbol = 1,
|
| 125 |
+
InvalidNumberFormat = 2,
|
| 126 |
+
PropertyNameExpected = 3,
|
| 127 |
+
ValueExpected = 4,
|
| 128 |
+
ColonExpected = 5,
|
| 129 |
+
CommaExpected = 6,
|
| 130 |
+
CloseBraceExpected = 7,
|
| 131 |
+
CloseBracketExpected = 8,
|
| 132 |
+
EndOfFileExpected = 9,
|
| 133 |
+
InvalidCommentToken = 10,
|
| 134 |
+
UnexpectedEndOfComment = 11,
|
| 135 |
+
UnexpectedEndOfString = 12,
|
| 136 |
+
UnexpectedEndOfNumber = 13,
|
| 137 |
+
InvalidUnicode = 14,
|
| 138 |
+
InvalidEscapeCharacter = 15,
|
| 139 |
+
InvalidCharacter = 16
|
| 140 |
+
}
|
| 141 |
+
export declare function printParseErrorCode(code: ParseErrorCode): "InvalidSymbol" | "InvalidNumberFormat" | "PropertyNameExpected" | "ValueExpected" | "ColonExpected" | "CommaExpected" | "CloseBraceExpected" | "CloseBracketExpected" | "EndOfFileExpected" | "InvalidCommentToken" | "UnexpectedEndOfComment" | "UnexpectedEndOfString" | "UnexpectedEndOfNumber" | "InvalidUnicode" | "InvalidEscapeCharacter" | "InvalidCharacter" | "<unknown ParseErrorCode>";
|
| 142 |
+
export type NodeType = 'object' | 'array' | 'property' | 'string' | 'number' | 'boolean' | 'null';
|
| 143 |
+
export interface Node {
|
| 144 |
+
readonly type: NodeType;
|
| 145 |
+
readonly value?: any;
|
| 146 |
+
readonly offset: number;
|
| 147 |
+
readonly length: number;
|
| 148 |
+
readonly colonOffset?: number;
|
| 149 |
+
readonly parent?: Node;
|
| 150 |
+
readonly children?: Node[];
|
| 151 |
+
}
|
| 152 |
+
/**
|
| 153 |
+
* A {@linkcode JSONPath} segment. Either a string representing an object property name
|
| 154 |
+
* or a number (starting at 0) for array indices.
|
| 155 |
+
*/
|
| 156 |
+
export type Segment = string | number;
|
| 157 |
+
export type JSONPath = Segment[];
|
| 158 |
+
export interface Location {
|
| 159 |
+
/**
|
| 160 |
+
* The previous property key or literal value (string, number, boolean or null) or undefined.
|
| 161 |
+
*/
|
| 162 |
+
previousNode?: Node;
|
| 163 |
+
/**
|
| 164 |
+
* The path describing the location in the JSON document. The path consists of a sequence of strings
|
| 165 |
+
* representing an object property or numbers for array indices.
|
| 166 |
+
*/
|
| 167 |
+
path: JSONPath;
|
| 168 |
+
/**
|
| 169 |
+
* Matches the locations path against a pattern consisting of strings (for properties) and numbers (for array indices).
|
| 170 |
+
* '*' will match a single segment of any property name or index.
|
| 171 |
+
* '**' will match a sequence of segments of any property name or index, or no segment.
|
| 172 |
+
*/
|
| 173 |
+
matches: (patterns: JSONPath) => boolean;
|
| 174 |
+
/**
|
| 175 |
+
* If set, the location's offset is at a property key.
|
| 176 |
+
*/
|
| 177 |
+
isAtPropertyKey: boolean;
|
| 178 |
+
}
|
| 179 |
+
export interface ParseOptions {
|
| 180 |
+
disallowComments?: boolean;
|
| 181 |
+
allowTrailingComma?: boolean;
|
| 182 |
+
allowEmptyContent?: boolean;
|
| 183 |
+
}
|
| 184 |
+
/**
|
| 185 |
+
* Visitor called by {@linkcode visit} when parsing JSON.
|
| 186 |
+
*
|
| 187 |
+
* The visitor functions have the following common parameters:
|
| 188 |
+
* - `offset`: Global offset within the JSON document, starting at 0
|
| 189 |
+
* - `startLine`: Line number, starting at 0
|
| 190 |
+
* - `startCharacter`: Start character (column) within the current line, starting at 0
|
| 191 |
+
*
|
| 192 |
+
* Additionally some functions have a `pathSupplier` parameter which can be used to obtain the
|
| 193 |
+
* current `JSONPath` within the document.
|
| 194 |
+
*/
|
| 195 |
+
export interface JSONVisitor {
|
| 196 |
+
/**
|
| 197 |
+
* Invoked when an open brace is encountered and an object is started. The offset and length represent the location of the open brace.
|
| 198 |
+
*/
|
| 199 |
+
onObjectBegin?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 200 |
+
/**
|
| 201 |
+
* Invoked when a property is encountered. The offset and length represent the location of the property name.
|
| 202 |
+
* The `JSONPath` created by the `pathSupplier` refers to the enclosing JSON object, it does not include the
|
| 203 |
+
* property name yet.
|
| 204 |
+
*/
|
| 205 |
+
onObjectProperty?: (property: string, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 206 |
+
/**
|
| 207 |
+
* Invoked when a closing brace is encountered and an object is completed. The offset and length represent the location of the closing brace.
|
| 208 |
+
*/
|
| 209 |
+
onObjectEnd?: (offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 210 |
+
/**
|
| 211 |
+
* Invoked when an open bracket is encountered. The offset and length represent the location of the open bracket.
|
| 212 |
+
*/
|
| 213 |
+
onArrayBegin?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 214 |
+
/**
|
| 215 |
+
* Invoked when a closing bracket is encountered. The offset and length represent the location of the closing bracket.
|
| 216 |
+
*/
|
| 217 |
+
onArrayEnd?: (offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 218 |
+
/**
|
| 219 |
+
* Invoked when a literal value is encountered. The offset and length represent the location of the literal value.
|
| 220 |
+
*/
|
| 221 |
+
onLiteralValue?: (value: any, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 222 |
+
/**
|
| 223 |
+
* Invoked when a comma or colon separator is encountered. The offset and length represent the location of the separator.
|
| 224 |
+
*/
|
| 225 |
+
onSeparator?: (character: string, offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 226 |
+
/**
|
| 227 |
+
* When comments are allowed, invoked when a line or block comment is encountered. The offset and length represent the location of the comment.
|
| 228 |
+
*/
|
| 229 |
+
onComment?: (offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 230 |
+
/**
|
| 231 |
+
* Invoked on an error.
|
| 232 |
+
*/
|
| 233 |
+
onError?: (error: ParseErrorCode, offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 234 |
+
}
|
| 235 |
+
/**
|
| 236 |
+
* An edit result describes a textual edit operation. It is the result of a {@linkcode format} and {@linkcode modify} operation.
|
| 237 |
+
* It consist of one or more edits describing insertions, replacements or removals of text segments.
|
| 238 |
+
* * The offsets of the edits refer to the original state of the document.
|
| 239 |
+
* * No two edits change or remove the same range of text in the original document.
|
| 240 |
+
* * Multiple edits can have the same offset if they are multiple inserts, or an insert followed by a remove or replace.
|
| 241 |
+
* * The order in the array defines which edit is applied first.
|
| 242 |
+
* To apply an edit result use {@linkcode applyEdits}.
|
| 243 |
+
* In general multiple EditResults must not be concatenated because they might impact each other, producing incorrect or malformed JSON data.
|
| 244 |
+
*/
|
| 245 |
+
export type EditResult = Edit[];
|
| 246 |
+
/**
|
| 247 |
+
* Represents a text modification
|
| 248 |
+
*/
|
| 249 |
+
export interface Edit {
|
| 250 |
+
/**
|
| 251 |
+
* The start offset of the modification.
|
| 252 |
+
*/
|
| 253 |
+
offset: number;
|
| 254 |
+
/**
|
| 255 |
+
* The length of the modification. Must not be negative. Empty length represents an *insert*.
|
| 256 |
+
*/
|
| 257 |
+
length: number;
|
| 258 |
+
/**
|
| 259 |
+
* The new content. Empty content represents a *remove*.
|
| 260 |
+
*/
|
| 261 |
+
content: string;
|
| 262 |
+
}
|
| 263 |
+
/**
|
| 264 |
+
* A text range in the document
|
| 265 |
+
*/
|
| 266 |
+
export interface Range {
|
| 267 |
+
/**
|
| 268 |
+
* The start offset of the range.
|
| 269 |
+
*/
|
| 270 |
+
offset: number;
|
| 271 |
+
/**
|
| 272 |
+
* The length of the range. Must not be negative.
|
| 273 |
+
*/
|
| 274 |
+
length: number;
|
| 275 |
+
}
|
| 276 |
+
/**
|
| 277 |
+
* Options used by {@linkcode format} when computing the formatting edit operations
|
| 278 |
+
*/
|
| 279 |
+
export interface FormattingOptions {
|
| 280 |
+
/**
|
| 281 |
+
* If indentation is based on spaces (`insertSpaces` = true), the number of spaces that make an indent.
|
| 282 |
+
*/
|
| 283 |
+
tabSize?: number;
|
| 284 |
+
/**
|
| 285 |
+
* Is indentation based on spaces?
|
| 286 |
+
*/
|
| 287 |
+
insertSpaces?: boolean;
|
| 288 |
+
/**
|
| 289 |
+
* The default 'end of line' character. If not set, '\n' is used as default.
|
| 290 |
+
*/
|
| 291 |
+
eol?: string;
|
| 292 |
+
/**
|
| 293 |
+
* If set, will add a new line at the end of the document.
|
| 294 |
+
*/
|
| 295 |
+
insertFinalNewline?: boolean;
|
| 296 |
+
/**
|
| 297 |
+
* If true, will keep line positions as is in the formatting
|
| 298 |
+
*/
|
| 299 |
+
keepLines?: boolean;
|
| 300 |
+
}
|
| 301 |
+
/**
|
| 302 |
+
* Computes the edit operations needed to format a JSON document.
|
| 303 |
+
*
|
| 304 |
+
* @param documentText The input text
|
| 305 |
+
* @param range The range to format or `undefined` to format the full content
|
| 306 |
+
* @param options The formatting options
|
| 307 |
+
* @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.
|
| 308 |
+
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
| 309 |
+
*/
|
| 310 |
+
export declare function format(documentText: string, range: Range | undefined, options: FormattingOptions): EditResult;
|
| 311 |
+
/**
|
| 312 |
+
* Options used by {@linkcode modify} when computing the modification edit operations
|
| 313 |
+
*/
|
| 314 |
+
export interface ModificationOptions {
|
| 315 |
+
/**
|
| 316 |
+
* Formatting options. If undefined, the newly inserted code will be inserted unformatted.
|
| 317 |
+
*/
|
| 318 |
+
formattingOptions?: FormattingOptions;
|
| 319 |
+
/**
|
| 320 |
+
* Default false. If `JSONPath` refers to an index of an array and `isArrayInsertion` is `true`, then
|
| 321 |
+
* {@linkcode modify} will insert a new item at that location instead of overwriting its contents.
|
| 322 |
+
*/
|
| 323 |
+
isArrayInsertion?: boolean;
|
| 324 |
+
/**
|
| 325 |
+
* Optional function to define the insertion index given an existing list of properties.
|
| 326 |
+
*/
|
| 327 |
+
getInsertionIndex?: (properties: string[]) => number;
|
| 328 |
+
}
|
| 329 |
+
/**
|
| 330 |
+
* Computes the edit operations needed to modify a value in the JSON document.
|
| 331 |
+
*
|
| 332 |
+
* @param documentText The input text
|
| 333 |
+
* @param path The path of the value to change. The path represents either to the document root, a property or an array item.
|
| 334 |
+
* If the path points to an non-existing property or item, it will be created.
|
| 335 |
+
* @param value The new value for the specified property or item. If the value is undefined,
|
| 336 |
+
* the property or item will be removed.
|
| 337 |
+
* @param options Options
|
| 338 |
+
* @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
|
| 339 |
+
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
| 340 |
+
*/
|
| 341 |
+
export declare function modify(text: string, path: JSONPath, value: any, options: ModificationOptions): EditResult;
|
| 342 |
+
/**
|
| 343 |
+
* Applies edits to an input string.
|
| 344 |
+
* @param text The input text
|
| 345 |
+
* @param edits Edit operations following the format described in {@linkcode EditResult}.
|
| 346 |
+
* @returns The text with the applied edits.
|
| 347 |
+
* @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
|
| 348 |
+
*/
|
| 349 |
+
export declare function applyEdits(text: string, edits: EditResult): string;
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/esm/main.js
CHANGED
|
@@ -1,3 +1,178 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*---------------------------------------------------------------------------------------------
|
| 2 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 3 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 4 |
+
*--------------------------------------------------------------------------------------------*/
|
| 5 |
+
'use strict';
|
| 6 |
+
import * as formatter from './impl/format';
|
| 7 |
+
import * as edit from './impl/edit';
|
| 8 |
+
import * as scanner from './impl/scanner';
|
| 9 |
+
import * as parser from './impl/parser';
|
| 10 |
+
/**
|
| 11 |
+
* Creates a JSON scanner on the given text.
|
| 12 |
+
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
| 13 |
+
*/
|
| 14 |
+
export const createScanner = scanner.createScanner;
|
| 15 |
+
export var ScanError;
|
| 16 |
+
(function (ScanError) {
|
| 17 |
+
ScanError[ScanError["None"] = 0] = "None";
|
| 18 |
+
ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
| 19 |
+
ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
| 20 |
+
ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
| 21 |
+
ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
|
| 22 |
+
ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
| 23 |
+
ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
|
| 24 |
+
})(ScanError || (ScanError = {}));
|
| 25 |
+
export var SyntaxKind;
|
| 26 |
+
(function (SyntaxKind) {
|
| 27 |
+
SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
|
| 28 |
+
SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
|
| 29 |
+
SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
|
| 30 |
+
SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
|
| 31 |
+
SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
|
| 32 |
+
SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
|
| 33 |
+
SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
|
| 34 |
+
SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
|
| 35 |
+
SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
|
| 36 |
+
SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
|
| 37 |
+
SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
|
| 38 |
+
SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
| 39 |
+
SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
| 40 |
+
SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
| 41 |
+
SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
|
| 42 |
+
SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
|
| 43 |
+
SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
|
| 44 |
+
})(SyntaxKind || (SyntaxKind = {}));
|
| 45 |
+
/**
|
| 46 |
+
* For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
|
| 47 |
+
*/
|
| 48 |
+
export const getLocation = parser.getLocation;
|
| 49 |
+
/**
|
| 50 |
+
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 51 |
+
* Therefore, always check the errors list to find out if the input was valid.
|
| 52 |
+
*/
|
| 53 |
+
export const parse = parser.parse;
|
| 54 |
+
/**
|
| 55 |
+
* Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 56 |
+
*/
|
| 57 |
+
export const parseTree = parser.parseTree;
|
| 58 |
+
/**
|
| 59 |
+
* Finds the node at the given path in a JSON DOM.
|
| 60 |
+
*/
|
| 61 |
+
export const findNodeAtLocation = parser.findNodeAtLocation;
|
| 62 |
+
/**
|
| 63 |
+
* Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
|
| 64 |
+
*/
|
| 65 |
+
export const findNodeAtOffset = parser.findNodeAtOffset;
|
| 66 |
+
/**
|
| 67 |
+
* Gets the JSON path of the given JSON DOM node
|
| 68 |
+
*/
|
| 69 |
+
export const getNodePath = parser.getNodePath;
|
| 70 |
+
/**
|
| 71 |
+
* Evaluates the JavaScript object of the given JSON DOM node
|
| 72 |
+
*/
|
| 73 |
+
export const getNodeValue = parser.getNodeValue;
|
| 74 |
+
/**
|
| 75 |
+
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
| 76 |
+
*/
|
| 77 |
+
export const visit = parser.visit;
|
| 78 |
+
/**
|
| 79 |
+
* Takes JSON with JavaScript-style comments and remove
|
| 80 |
+
* them. Optionally replaces every none-newline character
|
| 81 |
+
* of comments with a replaceCharacter
|
| 82 |
+
*/
|
| 83 |
+
export const stripComments = parser.stripComments;
|
| 84 |
+
export var ParseErrorCode;
|
| 85 |
+
(function (ParseErrorCode) {
|
| 86 |
+
ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
|
| 87 |
+
ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
| 88 |
+
ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
| 89 |
+
ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
|
| 90 |
+
ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
|
| 91 |
+
ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
|
| 92 |
+
ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
| 93 |
+
ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
| 94 |
+
ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
| 95 |
+
ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
| 96 |
+
ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
| 97 |
+
ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
| 98 |
+
ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
| 99 |
+
ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
|
| 100 |
+
ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
| 101 |
+
ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
|
| 102 |
+
})(ParseErrorCode || (ParseErrorCode = {}));
|
| 103 |
+
export function printParseErrorCode(code) {
|
| 104 |
+
switch (code) {
|
| 105 |
+
case 1 /* ParseErrorCode.InvalidSymbol */: return 'InvalidSymbol';
|
| 106 |
+
case 2 /* ParseErrorCode.InvalidNumberFormat */: return 'InvalidNumberFormat';
|
| 107 |
+
case 3 /* ParseErrorCode.PropertyNameExpected */: return 'PropertyNameExpected';
|
| 108 |
+
case 4 /* ParseErrorCode.ValueExpected */: return 'ValueExpected';
|
| 109 |
+
case 5 /* ParseErrorCode.ColonExpected */: return 'ColonExpected';
|
| 110 |
+
case 6 /* ParseErrorCode.CommaExpected */: return 'CommaExpected';
|
| 111 |
+
case 7 /* ParseErrorCode.CloseBraceExpected */: return 'CloseBraceExpected';
|
| 112 |
+
case 8 /* ParseErrorCode.CloseBracketExpected */: return 'CloseBracketExpected';
|
| 113 |
+
case 9 /* ParseErrorCode.EndOfFileExpected */: return 'EndOfFileExpected';
|
| 114 |
+
case 10 /* ParseErrorCode.InvalidCommentToken */: return 'InvalidCommentToken';
|
| 115 |
+
case 11 /* ParseErrorCode.UnexpectedEndOfComment */: return 'UnexpectedEndOfComment';
|
| 116 |
+
case 12 /* ParseErrorCode.UnexpectedEndOfString */: return 'UnexpectedEndOfString';
|
| 117 |
+
case 13 /* ParseErrorCode.UnexpectedEndOfNumber */: return 'UnexpectedEndOfNumber';
|
| 118 |
+
case 14 /* ParseErrorCode.InvalidUnicode */: return 'InvalidUnicode';
|
| 119 |
+
case 15 /* ParseErrorCode.InvalidEscapeCharacter */: return 'InvalidEscapeCharacter';
|
| 120 |
+
case 16 /* ParseErrorCode.InvalidCharacter */: return 'InvalidCharacter';
|
| 121 |
+
}
|
| 122 |
+
return '<unknown ParseErrorCode>';
|
| 123 |
+
}
|
| 124 |
+
/**
|
| 125 |
+
* Computes the edit operations needed to format a JSON document.
|
| 126 |
+
*
|
| 127 |
+
* @param documentText The input text
|
| 128 |
+
* @param range The range to format or `undefined` to format the full content
|
| 129 |
+
* @param options The formatting options
|
| 130 |
+
* @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.
|
| 131 |
+
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
| 132 |
+
*/
|
| 133 |
+
export function format(documentText, range, options) {
|
| 134 |
+
return formatter.format(documentText, range, options);
|
| 135 |
+
}
|
| 136 |
+
/**
|
| 137 |
+
* Computes the edit operations needed to modify a value in the JSON document.
|
| 138 |
+
*
|
| 139 |
+
* @param documentText The input text
|
| 140 |
+
* @param path The path of the value to change. The path represents either to the document root, a property or an array item.
|
| 141 |
+
* If the path points to an non-existing property or item, it will be created.
|
| 142 |
+
* @param value The new value for the specified property or item. If the value is undefined,
|
| 143 |
+
* the property or item will be removed.
|
| 144 |
+
* @param options Options
|
| 145 |
+
* @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
|
| 146 |
+
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
| 147 |
+
*/
|
| 148 |
+
export function modify(text, path, value, options) {
|
| 149 |
+
return edit.setProperty(text, path, value, options);
|
| 150 |
+
}
|
| 151 |
+
/**
|
| 152 |
+
* Applies edits to an input string.
|
| 153 |
+
* @param text The input text
|
| 154 |
+
* @param edits Edit operations following the format described in {@linkcode EditResult}.
|
| 155 |
+
* @returns The text with the applied edits.
|
| 156 |
+
* @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
|
| 157 |
+
*/
|
| 158 |
+
export function applyEdits(text, edits) {
|
| 159 |
+
let sortedEdits = edits.slice(0).sort((a, b) => {
|
| 160 |
+
const diff = a.offset - b.offset;
|
| 161 |
+
if (diff === 0) {
|
| 162 |
+
return a.length - b.length;
|
| 163 |
+
}
|
| 164 |
+
return diff;
|
| 165 |
+
});
|
| 166 |
+
let lastModifiedOffset = text.length;
|
| 167 |
+
for (let i = sortedEdits.length - 1; i >= 0; i--) {
|
| 168 |
+
let e = sortedEdits[i];
|
| 169 |
+
if (e.offset + e.length <= lastModifiedOffset) {
|
| 170 |
+
text = edit.applyEdit(text, e);
|
| 171 |
+
}
|
| 172 |
+
else {
|
| 173 |
+
throw new Error('Overlapping edit');
|
| 174 |
+
}
|
| 175 |
+
lastModifiedOffset = e.offset;
|
| 176 |
+
}
|
| 177 |
+
return text;
|
| 178 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/impl/edit.js
CHANGED
|
@@ -1,3 +1,201 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function (factory) {
|
| 2 |
+
if (typeof module === "object" && typeof module.exports === "object") {
|
| 3 |
+
var v = factory(require, exports);
|
| 4 |
+
if (v !== undefined) module.exports = v;
|
| 5 |
+
}
|
| 6 |
+
else if (typeof define === "function" && define.amd) {
|
| 7 |
+
define(["require", "exports", "./format", "./parser"], factory);
|
| 8 |
+
}
|
| 9 |
+
})(function (require, exports) {
|
| 10 |
+
/*---------------------------------------------------------------------------------------------
|
| 11 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 12 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 13 |
+
*--------------------------------------------------------------------------------------------*/
|
| 14 |
+
'use strict';
|
| 15 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 16 |
+
exports.isWS = exports.applyEdit = exports.setProperty = exports.removeProperty = void 0;
|
| 17 |
+
const format_1 = require("./format");
|
| 18 |
+
const parser_1 = require("./parser");
|
| 19 |
+
function removeProperty(text, path, options) {
|
| 20 |
+
return setProperty(text, path, void 0, options);
|
| 21 |
+
}
|
| 22 |
+
exports.removeProperty = removeProperty;
|
| 23 |
+
function setProperty(text, originalPath, value, options) {
|
| 24 |
+
const path = originalPath.slice();
|
| 25 |
+
const errors = [];
|
| 26 |
+
const root = (0, parser_1.parseTree)(text, errors);
|
| 27 |
+
let parent = void 0;
|
| 28 |
+
let lastSegment = void 0;
|
| 29 |
+
while (path.length > 0) {
|
| 30 |
+
lastSegment = path.pop();
|
| 31 |
+
parent = (0, parser_1.findNodeAtLocation)(root, path);
|
| 32 |
+
if (parent === void 0 && value !== void 0) {
|
| 33 |
+
if (typeof lastSegment === 'string') {
|
| 34 |
+
value = { [lastSegment]: value };
|
| 35 |
+
}
|
| 36 |
+
else {
|
| 37 |
+
value = [value];
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
else {
|
| 41 |
+
break;
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
if (!parent) {
|
| 45 |
+
// empty document
|
| 46 |
+
if (value === void 0) { // delete
|
| 47 |
+
throw new Error('Can not delete in empty document');
|
| 48 |
+
}
|
| 49 |
+
return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
|
| 50 |
+
}
|
| 51 |
+
else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {
|
| 52 |
+
const existing = (0, parser_1.findNodeAtLocation)(parent, [lastSegment]);
|
| 53 |
+
if (existing !== void 0) {
|
| 54 |
+
if (value === void 0) { // delete
|
| 55 |
+
if (!existing.parent) {
|
| 56 |
+
throw new Error('Malformed AST');
|
| 57 |
+
}
|
| 58 |
+
const propertyIndex = parent.children.indexOf(existing.parent);
|
| 59 |
+
let removeBegin;
|
| 60 |
+
let removeEnd = existing.parent.offset + existing.parent.length;
|
| 61 |
+
if (propertyIndex > 0) {
|
| 62 |
+
// remove the comma of the previous node
|
| 63 |
+
let previous = parent.children[propertyIndex - 1];
|
| 64 |
+
removeBegin = previous.offset + previous.length;
|
| 65 |
+
}
|
| 66 |
+
else {
|
| 67 |
+
removeBegin = parent.offset + 1;
|
| 68 |
+
if (parent.children.length > 1) {
|
| 69 |
+
// remove the comma of the next node
|
| 70 |
+
let next = parent.children[1];
|
| 71 |
+
removeEnd = next.offset;
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: '' }, options);
|
| 75 |
+
}
|
| 76 |
+
else {
|
| 77 |
+
// set value of existing property
|
| 78 |
+
return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
else {
|
| 82 |
+
if (value === void 0) { // delete
|
| 83 |
+
return []; // property does not exist, nothing to do
|
| 84 |
+
}
|
| 85 |
+
const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
|
| 86 |
+
const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map(p => p.children[0].value)) : parent.children.length;
|
| 87 |
+
let edit;
|
| 88 |
+
if (index > 0) {
|
| 89 |
+
let previous = parent.children[index - 1];
|
| 90 |
+
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
| 91 |
+
}
|
| 92 |
+
else if (parent.children.length === 0) {
|
| 93 |
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
| 94 |
+
}
|
| 95 |
+
else {
|
| 96 |
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty + ',' };
|
| 97 |
+
}
|
| 98 |
+
return withFormatting(text, edit, options);
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
else if (parent.type === 'array' && typeof lastSegment === 'number' && Array.isArray(parent.children)) {
|
| 102 |
+
const insertIndex = lastSegment;
|
| 103 |
+
if (insertIndex === -1) {
|
| 104 |
+
// Insert
|
| 105 |
+
const newProperty = `${JSON.stringify(value)}`;
|
| 106 |
+
let edit;
|
| 107 |
+
if (parent.children.length === 0) {
|
| 108 |
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
| 109 |
+
}
|
| 110 |
+
else {
|
| 111 |
+
const previous = parent.children[parent.children.length - 1];
|
| 112 |
+
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
| 113 |
+
}
|
| 114 |
+
return withFormatting(text, edit, options);
|
| 115 |
+
}
|
| 116 |
+
else if (value === void 0 && parent.children.length >= 0) {
|
| 117 |
+
// Removal
|
| 118 |
+
const removalIndex = lastSegment;
|
| 119 |
+
const toRemove = parent.children[removalIndex];
|
| 120 |
+
let edit;
|
| 121 |
+
if (parent.children.length === 1) {
|
| 122 |
+
// only item
|
| 123 |
+
edit = { offset: parent.offset + 1, length: parent.length - 2, content: '' };
|
| 124 |
+
}
|
| 125 |
+
else if (parent.children.length - 1 === removalIndex) {
|
| 126 |
+
// last item
|
| 127 |
+
let previous = parent.children[removalIndex - 1];
|
| 128 |
+
let offset = previous.offset + previous.length;
|
| 129 |
+
let parentEndOffset = parent.offset + parent.length;
|
| 130 |
+
edit = { offset, length: parentEndOffset - 2 - offset, content: '' };
|
| 131 |
+
}
|
| 132 |
+
else {
|
| 133 |
+
edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: '' };
|
| 134 |
+
}
|
| 135 |
+
return withFormatting(text, edit, options);
|
| 136 |
+
}
|
| 137 |
+
else if (value !== void 0) {
|
| 138 |
+
let edit;
|
| 139 |
+
const newProperty = `${JSON.stringify(value)}`;
|
| 140 |
+
if (!options.isArrayInsertion && parent.children.length > lastSegment) {
|
| 141 |
+
const toModify = parent.children[lastSegment];
|
| 142 |
+
edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
|
| 143 |
+
}
|
| 144 |
+
else if (parent.children.length === 0 || lastSegment === 0) {
|
| 145 |
+
edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + ',' };
|
| 146 |
+
}
|
| 147 |
+
else {
|
| 148 |
+
const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
|
| 149 |
+
const previous = parent.children[index - 1];
|
| 150 |
+
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
| 151 |
+
}
|
| 152 |
+
return withFormatting(text, edit, options);
|
| 153 |
+
}
|
| 154 |
+
else {
|
| 155 |
+
throw new Error(`Can not ${value === void 0 ? 'remove' : (options.isArrayInsertion ? 'insert' : 'modify')} Array index ${insertIndex} as length is not sufficient`);
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
else {
|
| 159 |
+
throw new Error(`Can not add ${typeof lastSegment !== 'number' ? 'index' : 'property'} to parent of type ${parent.type}`);
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
exports.setProperty = setProperty;
|
| 163 |
+
function withFormatting(text, edit, options) {
|
| 164 |
+
if (!options.formattingOptions) {
|
| 165 |
+
return [edit];
|
| 166 |
+
}
|
| 167 |
+
// apply the edit
|
| 168 |
+
let newText = applyEdit(text, edit);
|
| 169 |
+
// format the new text
|
| 170 |
+
let begin = edit.offset;
|
| 171 |
+
let end = edit.offset + edit.content.length;
|
| 172 |
+
if (edit.length === 0 || edit.content.length === 0) { // insert or remove
|
| 173 |
+
while (begin > 0 && !(0, format_1.isEOL)(newText, begin - 1)) {
|
| 174 |
+
begin--;
|
| 175 |
+
}
|
| 176 |
+
while (end < newText.length && !(0, format_1.isEOL)(newText, end)) {
|
| 177 |
+
end++;
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
const edits = (0, format_1.format)(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
|
| 181 |
+
// apply the formatting edits and track the begin and end offsets of the changes
|
| 182 |
+
for (let i = edits.length - 1; i >= 0; i--) {
|
| 183 |
+
const edit = edits[i];
|
| 184 |
+
newText = applyEdit(newText, edit);
|
| 185 |
+
begin = Math.min(begin, edit.offset);
|
| 186 |
+
end = Math.max(end, edit.offset + edit.length);
|
| 187 |
+
end += edit.content.length - edit.length;
|
| 188 |
+
}
|
| 189 |
+
// create a single edit with all changes
|
| 190 |
+
const editLength = text.length - (newText.length - end) - begin;
|
| 191 |
+
return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
|
| 192 |
+
}
|
| 193 |
+
function applyEdit(text, edit) {
|
| 194 |
+
return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
|
| 195 |
+
}
|
| 196 |
+
exports.applyEdit = applyEdit;
|
| 197 |
+
function isWS(text, offset) {
|
| 198 |
+
return '\r\n \t'.indexOf(text.charAt(offset)) !== -1;
|
| 199 |
+
}
|
| 200 |
+
exports.isWS = isWS;
|
| 201 |
+
});
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/impl/format.js
CHANGED
|
@@ -1,3 +1,275 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function (factory) {
|
| 2 |
+
if (typeof module === "object" && typeof module.exports === "object") {
|
| 3 |
+
var v = factory(require, exports);
|
| 4 |
+
if (v !== undefined) module.exports = v;
|
| 5 |
+
}
|
| 6 |
+
else if (typeof define === "function" && define.amd) {
|
| 7 |
+
define(["require", "exports", "./scanner", "./string-intern"], factory);
|
| 8 |
+
}
|
| 9 |
+
})(function (require, exports) {
|
| 10 |
+
/*---------------------------------------------------------------------------------------------
|
| 11 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 12 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 13 |
+
*--------------------------------------------------------------------------------------------*/
|
| 14 |
+
'use strict';
|
| 15 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 16 |
+
exports.isEOL = exports.format = void 0;
|
| 17 |
+
const scanner_1 = require("./scanner");
|
| 18 |
+
const string_intern_1 = require("./string-intern");
|
| 19 |
+
function format(documentText, range, options) {
|
| 20 |
+
let initialIndentLevel;
|
| 21 |
+
let formatText;
|
| 22 |
+
let formatTextStart;
|
| 23 |
+
let rangeStart;
|
| 24 |
+
let rangeEnd;
|
| 25 |
+
if (range) {
|
| 26 |
+
rangeStart = range.offset;
|
| 27 |
+
rangeEnd = rangeStart + range.length;
|
| 28 |
+
formatTextStart = rangeStart;
|
| 29 |
+
while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
|
| 30 |
+
formatTextStart--;
|
| 31 |
+
}
|
| 32 |
+
let endOffset = rangeEnd;
|
| 33 |
+
while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
|
| 34 |
+
endOffset++;
|
| 35 |
+
}
|
| 36 |
+
formatText = documentText.substring(formatTextStart, endOffset);
|
| 37 |
+
initialIndentLevel = computeIndentLevel(formatText, options);
|
| 38 |
+
}
|
| 39 |
+
else {
|
| 40 |
+
formatText = documentText;
|
| 41 |
+
initialIndentLevel = 0;
|
| 42 |
+
formatTextStart = 0;
|
| 43 |
+
rangeStart = 0;
|
| 44 |
+
rangeEnd = documentText.length;
|
| 45 |
+
}
|
| 46 |
+
const eol = getEOL(options, documentText);
|
| 47 |
+
const eolFastPathSupported = string_intern_1.supportedEols.includes(eol);
|
| 48 |
+
let numberLineBreaks = 0;
|
| 49 |
+
let indentLevel = 0;
|
| 50 |
+
let indentValue;
|
| 51 |
+
if (options.insertSpaces) {
|
| 52 |
+
indentValue = string_intern_1.cachedSpaces[options.tabSize || 4] ?? repeat(string_intern_1.cachedSpaces[1], options.tabSize || 4);
|
| 53 |
+
}
|
| 54 |
+
else {
|
| 55 |
+
indentValue = '\t';
|
| 56 |
+
}
|
| 57 |
+
const indentType = indentValue === '\t' ? '\t' : ' ';
|
| 58 |
+
let scanner = (0, scanner_1.createScanner)(formatText, false);
|
| 59 |
+
let hasError = false;
|
| 60 |
+
function newLinesAndIndent() {
|
| 61 |
+
if (numberLineBreaks > 1) {
|
| 62 |
+
return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
|
| 63 |
+
}
|
| 64 |
+
const amountOfSpaces = indentValue.length * (initialIndentLevel + indentLevel);
|
| 65 |
+
if (!eolFastPathSupported || amountOfSpaces > string_intern_1.cachedBreakLinesWithSpaces[indentType][eol].length) {
|
| 66 |
+
return eol + repeat(indentValue, initialIndentLevel + indentLevel);
|
| 67 |
+
}
|
| 68 |
+
if (amountOfSpaces <= 0) {
|
| 69 |
+
return eol;
|
| 70 |
+
}
|
| 71 |
+
return string_intern_1.cachedBreakLinesWithSpaces[indentType][eol][amountOfSpaces];
|
| 72 |
+
}
|
| 73 |
+
function scanNext() {
|
| 74 |
+
let token = scanner.scan();
|
| 75 |
+
numberLineBreaks = 0;
|
| 76 |
+
while (token === 15 /* SyntaxKind.Trivia */ || token === 14 /* SyntaxKind.LineBreakTrivia */) {
|
| 77 |
+
if (token === 14 /* SyntaxKind.LineBreakTrivia */ && options.keepLines) {
|
| 78 |
+
numberLineBreaks += 1;
|
| 79 |
+
}
|
| 80 |
+
else if (token === 14 /* SyntaxKind.LineBreakTrivia */) {
|
| 81 |
+
numberLineBreaks = 1;
|
| 82 |
+
}
|
| 83 |
+
token = scanner.scan();
|
| 84 |
+
}
|
| 85 |
+
hasError = token === 16 /* SyntaxKind.Unknown */ || scanner.getTokenError() !== 0 /* ScanError.None */;
|
| 86 |
+
return token;
|
| 87 |
+
}
|
| 88 |
+
const editOperations = [];
|
| 89 |
+
function addEdit(text, startOffset, endOffset) {
|
| 90 |
+
if (!hasError && (!range || (startOffset < rangeEnd && endOffset > rangeStart)) && documentText.substring(startOffset, endOffset) !== text) {
|
| 91 |
+
editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
let firstToken = scanNext();
|
| 95 |
+
if (options.keepLines && numberLineBreaks > 0) {
|
| 96 |
+
addEdit(repeat(eol, numberLineBreaks), 0, 0);
|
| 97 |
+
}
|
| 98 |
+
if (firstToken !== 17 /* SyntaxKind.EOF */) {
|
| 99 |
+
let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
|
| 100 |
+
let initialIndent = (indentValue.length * initialIndentLevel < 20) && options.insertSpaces
|
| 101 |
+
? string_intern_1.cachedSpaces[indentValue.length * initialIndentLevel]
|
| 102 |
+
: repeat(indentValue, initialIndentLevel);
|
| 103 |
+
addEdit(initialIndent, formatTextStart, firstTokenStart);
|
| 104 |
+
}
|
| 105 |
+
while (firstToken !== 17 /* SyntaxKind.EOF */) {
|
| 106 |
+
let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
| 107 |
+
let secondToken = scanNext();
|
| 108 |
+
let replaceContent = '';
|
| 109 |
+
let needsLineBreak = false;
|
| 110 |
+
while (numberLineBreaks === 0 && (secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */)) {
|
| 111 |
+
let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
|
| 112 |
+
addEdit(string_intern_1.cachedSpaces[1], firstTokenEnd, commentTokenStart);
|
| 113 |
+
firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
| 114 |
+
needsLineBreak = secondToken === 12 /* SyntaxKind.LineCommentTrivia */;
|
| 115 |
+
replaceContent = needsLineBreak ? newLinesAndIndent() : '';
|
| 116 |
+
secondToken = scanNext();
|
| 117 |
+
}
|
| 118 |
+
if (secondToken === 2 /* SyntaxKind.CloseBraceToken */) {
|
| 119 |
+
if (firstToken !== 1 /* SyntaxKind.OpenBraceToken */) {
|
| 120 |
+
indentLevel--;
|
| 121 |
+
}
|
| 122 |
+
;
|
| 123 |
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1 /* SyntaxKind.OpenBraceToken */) {
|
| 124 |
+
replaceContent = newLinesAndIndent();
|
| 125 |
+
}
|
| 126 |
+
else if (options.keepLines) {
|
| 127 |
+
replaceContent = string_intern_1.cachedSpaces[1];
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
else if (secondToken === 4 /* SyntaxKind.CloseBracketToken */) {
|
| 131 |
+
if (firstToken !== 3 /* SyntaxKind.OpenBracketToken */) {
|
| 132 |
+
indentLevel--;
|
| 133 |
+
}
|
| 134 |
+
;
|
| 135 |
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3 /* SyntaxKind.OpenBracketToken */) {
|
| 136 |
+
replaceContent = newLinesAndIndent();
|
| 137 |
+
}
|
| 138 |
+
else if (options.keepLines) {
|
| 139 |
+
replaceContent = string_intern_1.cachedSpaces[1];
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
else {
|
| 143 |
+
switch (firstToken) {
|
| 144 |
+
case 3 /* SyntaxKind.OpenBracketToken */:
|
| 145 |
+
case 1 /* SyntaxKind.OpenBraceToken */:
|
| 146 |
+
indentLevel++;
|
| 147 |
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
| 148 |
+
replaceContent = newLinesAndIndent();
|
| 149 |
+
}
|
| 150 |
+
else {
|
| 151 |
+
replaceContent = string_intern_1.cachedSpaces[1];
|
| 152 |
+
}
|
| 153 |
+
break;
|
| 154 |
+
case 5 /* SyntaxKind.CommaToken */:
|
| 155 |
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
| 156 |
+
replaceContent = newLinesAndIndent();
|
| 157 |
+
}
|
| 158 |
+
else {
|
| 159 |
+
replaceContent = string_intern_1.cachedSpaces[1];
|
| 160 |
+
}
|
| 161 |
+
break;
|
| 162 |
+
case 12 /* SyntaxKind.LineCommentTrivia */:
|
| 163 |
+
replaceContent = newLinesAndIndent();
|
| 164 |
+
break;
|
| 165 |
+
case 13 /* SyntaxKind.BlockCommentTrivia */:
|
| 166 |
+
if (numberLineBreaks > 0) {
|
| 167 |
+
replaceContent = newLinesAndIndent();
|
| 168 |
+
}
|
| 169 |
+
else if (!needsLineBreak) {
|
| 170 |
+
replaceContent = string_intern_1.cachedSpaces[1];
|
| 171 |
+
}
|
| 172 |
+
break;
|
| 173 |
+
case 6 /* SyntaxKind.ColonToken */:
|
| 174 |
+
if (options.keepLines && numberLineBreaks > 0) {
|
| 175 |
+
replaceContent = newLinesAndIndent();
|
| 176 |
+
}
|
| 177 |
+
else if (!needsLineBreak) {
|
| 178 |
+
replaceContent = string_intern_1.cachedSpaces[1];
|
| 179 |
+
}
|
| 180 |
+
break;
|
| 181 |
+
case 10 /* SyntaxKind.StringLiteral */:
|
| 182 |
+
if (options.keepLines && numberLineBreaks > 0) {
|
| 183 |
+
replaceContent = newLinesAndIndent();
|
| 184 |
+
}
|
| 185 |
+
else if (secondToken === 6 /* SyntaxKind.ColonToken */ && !needsLineBreak) {
|
| 186 |
+
replaceContent = '';
|
| 187 |
+
}
|
| 188 |
+
break;
|
| 189 |
+
case 7 /* SyntaxKind.NullKeyword */:
|
| 190 |
+
case 8 /* SyntaxKind.TrueKeyword */:
|
| 191 |
+
case 9 /* SyntaxKind.FalseKeyword */:
|
| 192 |
+
case 11 /* SyntaxKind.NumericLiteral */:
|
| 193 |
+
case 2 /* SyntaxKind.CloseBraceToken */:
|
| 194 |
+
case 4 /* SyntaxKind.CloseBracketToken */:
|
| 195 |
+
if (options.keepLines && numberLineBreaks > 0) {
|
| 196 |
+
replaceContent = newLinesAndIndent();
|
| 197 |
+
}
|
| 198 |
+
else {
|
| 199 |
+
if ((secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */) && !needsLineBreak) {
|
| 200 |
+
replaceContent = string_intern_1.cachedSpaces[1];
|
| 201 |
+
}
|
| 202 |
+
else if (secondToken !== 5 /* SyntaxKind.CommaToken */ && secondToken !== 17 /* SyntaxKind.EOF */) {
|
| 203 |
+
hasError = true;
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
break;
|
| 207 |
+
case 16 /* SyntaxKind.Unknown */:
|
| 208 |
+
hasError = true;
|
| 209 |
+
break;
|
| 210 |
+
}
|
| 211 |
+
if (numberLineBreaks > 0 && (secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */)) {
|
| 212 |
+
replaceContent = newLinesAndIndent();
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
if (secondToken === 17 /* SyntaxKind.EOF */) {
|
| 216 |
+
if (options.keepLines && numberLineBreaks > 0) {
|
| 217 |
+
replaceContent = newLinesAndIndent();
|
| 218 |
+
}
|
| 219 |
+
else {
|
| 220 |
+
replaceContent = options.insertFinalNewline ? eol : '';
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
|
| 224 |
+
addEdit(replaceContent, firstTokenEnd, secondTokenStart);
|
| 225 |
+
firstToken = secondToken;
|
| 226 |
+
}
|
| 227 |
+
return editOperations;
|
| 228 |
+
}
|
| 229 |
+
exports.format = format;
|
| 230 |
+
function repeat(s, count) {
|
| 231 |
+
let result = '';
|
| 232 |
+
for (let i = 0; i < count; i++) {
|
| 233 |
+
result += s;
|
| 234 |
+
}
|
| 235 |
+
return result;
|
| 236 |
+
}
|
| 237 |
+
function computeIndentLevel(content, options) {
|
| 238 |
+
let i = 0;
|
| 239 |
+
let nChars = 0;
|
| 240 |
+
const tabSize = options.tabSize || 4;
|
| 241 |
+
while (i < content.length) {
|
| 242 |
+
let ch = content.charAt(i);
|
| 243 |
+
if (ch === string_intern_1.cachedSpaces[1]) {
|
| 244 |
+
nChars++;
|
| 245 |
+
}
|
| 246 |
+
else if (ch === '\t') {
|
| 247 |
+
nChars += tabSize;
|
| 248 |
+
}
|
| 249 |
+
else {
|
| 250 |
+
break;
|
| 251 |
+
}
|
| 252 |
+
i++;
|
| 253 |
+
}
|
| 254 |
+
return Math.floor(nChars / tabSize);
|
| 255 |
+
}
|
| 256 |
+
function getEOL(options, text) {
|
| 257 |
+
for (let i = 0; i < text.length; i++) {
|
| 258 |
+
const ch = text.charAt(i);
|
| 259 |
+
if (ch === '\r') {
|
| 260 |
+
if (i + 1 < text.length && text.charAt(i + 1) === '\n') {
|
| 261 |
+
return '\r\n';
|
| 262 |
+
}
|
| 263 |
+
return '\r';
|
| 264 |
+
}
|
| 265 |
+
else if (ch === '\n') {
|
| 266 |
+
return '\n';
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
return (options && options.eol) || '\n';
|
| 270 |
+
}
|
| 271 |
+
function isEOL(text, offset) {
|
| 272 |
+
return '\r\n'.indexOf(text.charAt(offset)) !== -1;
|
| 273 |
+
}
|
| 274 |
+
exports.isEOL = isEOL;
|
| 275 |
+
});
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/impl/parser.js
CHANGED
|
@@ -1,3 +1,655 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function (factory) {
|
| 2 |
+
if (typeof module === "object" && typeof module.exports === "object") {
|
| 3 |
+
var v = factory(require, exports);
|
| 4 |
+
if (v !== undefined) module.exports = v;
|
| 5 |
+
}
|
| 6 |
+
else if (typeof define === "function" && define.amd) {
|
| 7 |
+
define(["require", "exports", "./scanner"], factory);
|
| 8 |
+
}
|
| 9 |
+
})(function (require, exports) {
|
| 10 |
+
/*---------------------------------------------------------------------------------------------
|
| 11 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 12 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 13 |
+
*--------------------------------------------------------------------------------------------*/
|
| 14 |
+
'use strict';
|
| 15 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 16 |
+
exports.getNodeType = exports.stripComments = exports.visit = exports.findNodeAtOffset = exports.contains = exports.getNodeValue = exports.getNodePath = exports.findNodeAtLocation = exports.parseTree = exports.parse = exports.getLocation = void 0;
|
| 17 |
+
const scanner_1 = require("./scanner");
|
| 18 |
+
var ParseOptions;
|
| 19 |
+
(function (ParseOptions) {
|
| 20 |
+
ParseOptions.DEFAULT = {
|
| 21 |
+
allowTrailingComma: false
|
| 22 |
+
};
|
| 23 |
+
})(ParseOptions || (ParseOptions = {}));
|
| 24 |
+
/**
|
| 25 |
+
* For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
|
| 26 |
+
*/
|
| 27 |
+
function getLocation(text, position) {
|
| 28 |
+
const segments = []; // strings or numbers
|
| 29 |
+
const earlyReturnException = new Object();
|
| 30 |
+
let previousNode = undefined;
|
| 31 |
+
const previousNodeInst = {
|
| 32 |
+
value: {},
|
| 33 |
+
offset: 0,
|
| 34 |
+
length: 0,
|
| 35 |
+
type: 'object',
|
| 36 |
+
parent: undefined
|
| 37 |
+
};
|
| 38 |
+
let isAtPropertyKey = false;
|
| 39 |
+
function setPreviousNode(value, offset, length, type) {
|
| 40 |
+
previousNodeInst.value = value;
|
| 41 |
+
previousNodeInst.offset = offset;
|
| 42 |
+
previousNodeInst.length = length;
|
| 43 |
+
previousNodeInst.type = type;
|
| 44 |
+
previousNodeInst.colonOffset = undefined;
|
| 45 |
+
previousNode = previousNodeInst;
|
| 46 |
+
}
|
| 47 |
+
try {
|
| 48 |
+
visit(text, {
|
| 49 |
+
onObjectBegin: (offset, length) => {
|
| 50 |
+
if (position <= offset) {
|
| 51 |
+
throw earlyReturnException;
|
| 52 |
+
}
|
| 53 |
+
previousNode = undefined;
|
| 54 |
+
isAtPropertyKey = position > offset;
|
| 55 |
+
segments.push(''); // push a placeholder (will be replaced)
|
| 56 |
+
},
|
| 57 |
+
onObjectProperty: (name, offset, length) => {
|
| 58 |
+
if (position < offset) {
|
| 59 |
+
throw earlyReturnException;
|
| 60 |
+
}
|
| 61 |
+
setPreviousNode(name, offset, length, 'property');
|
| 62 |
+
segments[segments.length - 1] = name;
|
| 63 |
+
if (position <= offset + length) {
|
| 64 |
+
throw earlyReturnException;
|
| 65 |
+
}
|
| 66 |
+
},
|
| 67 |
+
onObjectEnd: (offset, length) => {
|
| 68 |
+
if (position <= offset) {
|
| 69 |
+
throw earlyReturnException;
|
| 70 |
+
}
|
| 71 |
+
previousNode = undefined;
|
| 72 |
+
segments.pop();
|
| 73 |
+
},
|
| 74 |
+
onArrayBegin: (offset, length) => {
|
| 75 |
+
if (position <= offset) {
|
| 76 |
+
throw earlyReturnException;
|
| 77 |
+
}
|
| 78 |
+
previousNode = undefined;
|
| 79 |
+
segments.push(0);
|
| 80 |
+
},
|
| 81 |
+
onArrayEnd: (offset, length) => {
|
| 82 |
+
if (position <= offset) {
|
| 83 |
+
throw earlyReturnException;
|
| 84 |
+
}
|
| 85 |
+
previousNode = undefined;
|
| 86 |
+
segments.pop();
|
| 87 |
+
},
|
| 88 |
+
onLiteralValue: (value, offset, length) => {
|
| 89 |
+
if (position < offset) {
|
| 90 |
+
throw earlyReturnException;
|
| 91 |
+
}
|
| 92 |
+
setPreviousNode(value, offset, length, getNodeType(value));
|
| 93 |
+
if (position <= offset + length) {
|
| 94 |
+
throw earlyReturnException;
|
| 95 |
+
}
|
| 96 |
+
},
|
| 97 |
+
onSeparator: (sep, offset, length) => {
|
| 98 |
+
if (position <= offset) {
|
| 99 |
+
throw earlyReturnException;
|
| 100 |
+
}
|
| 101 |
+
if (sep === ':' && previousNode && previousNode.type === 'property') {
|
| 102 |
+
previousNode.colonOffset = offset;
|
| 103 |
+
isAtPropertyKey = false;
|
| 104 |
+
previousNode = undefined;
|
| 105 |
+
}
|
| 106 |
+
else if (sep === ',') {
|
| 107 |
+
const last = segments[segments.length - 1];
|
| 108 |
+
if (typeof last === 'number') {
|
| 109 |
+
segments[segments.length - 1] = last + 1;
|
| 110 |
+
}
|
| 111 |
+
else {
|
| 112 |
+
isAtPropertyKey = true;
|
| 113 |
+
segments[segments.length - 1] = '';
|
| 114 |
+
}
|
| 115 |
+
previousNode = undefined;
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
});
|
| 119 |
+
}
|
| 120 |
+
catch (e) {
|
| 121 |
+
if (e !== earlyReturnException) {
|
| 122 |
+
throw e;
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
return {
|
| 126 |
+
path: segments,
|
| 127 |
+
previousNode,
|
| 128 |
+
isAtPropertyKey,
|
| 129 |
+
matches: (pattern) => {
|
| 130 |
+
let k = 0;
|
| 131 |
+
for (let i = 0; k < pattern.length && i < segments.length; i++) {
|
| 132 |
+
if (pattern[k] === segments[i] || pattern[k] === '*') {
|
| 133 |
+
k++;
|
| 134 |
+
}
|
| 135 |
+
else if (pattern[k] !== '**') {
|
| 136 |
+
return false;
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
return k === pattern.length;
|
| 140 |
+
}
|
| 141 |
+
};
|
| 142 |
+
}
|
| 143 |
+
exports.getLocation = getLocation;
|
| 144 |
+
/**
|
| 145 |
+
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 146 |
+
* Therefore always check the errors list to find out if the input was valid.
|
| 147 |
+
*/
|
| 148 |
+
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
| 149 |
+
let currentProperty = null;
|
| 150 |
+
let currentParent = [];
|
| 151 |
+
const previousParents = [];
|
| 152 |
+
function onValue(value) {
|
| 153 |
+
if (Array.isArray(currentParent)) {
|
| 154 |
+
currentParent.push(value);
|
| 155 |
+
}
|
| 156 |
+
else if (currentProperty !== null) {
|
| 157 |
+
currentParent[currentProperty] = value;
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
const visitor = {
|
| 161 |
+
onObjectBegin: () => {
|
| 162 |
+
const object = {};
|
| 163 |
+
onValue(object);
|
| 164 |
+
previousParents.push(currentParent);
|
| 165 |
+
currentParent = object;
|
| 166 |
+
currentProperty = null;
|
| 167 |
+
},
|
| 168 |
+
onObjectProperty: (name) => {
|
| 169 |
+
currentProperty = name;
|
| 170 |
+
},
|
| 171 |
+
onObjectEnd: () => {
|
| 172 |
+
currentParent = previousParents.pop();
|
| 173 |
+
},
|
| 174 |
+
onArrayBegin: () => {
|
| 175 |
+
const array = [];
|
| 176 |
+
onValue(array);
|
| 177 |
+
previousParents.push(currentParent);
|
| 178 |
+
currentParent = array;
|
| 179 |
+
currentProperty = null;
|
| 180 |
+
},
|
| 181 |
+
onArrayEnd: () => {
|
| 182 |
+
currentParent = previousParents.pop();
|
| 183 |
+
},
|
| 184 |
+
onLiteralValue: onValue,
|
| 185 |
+
onError: (error, offset, length) => {
|
| 186 |
+
errors.push({ error, offset, length });
|
| 187 |
+
}
|
| 188 |
+
};
|
| 189 |
+
visit(text, visitor, options);
|
| 190 |
+
return currentParent[0];
|
| 191 |
+
}
|
| 192 |
+
exports.parse = parse;
|
| 193 |
+
/**
|
| 194 |
+
* Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 195 |
+
*/
|
| 196 |
+
function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
| 197 |
+
let currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root
|
| 198 |
+
function ensurePropertyComplete(endOffset) {
|
| 199 |
+
if (currentParent.type === 'property') {
|
| 200 |
+
currentParent.length = endOffset - currentParent.offset;
|
| 201 |
+
currentParent = currentParent.parent;
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
function onValue(valueNode) {
|
| 205 |
+
currentParent.children.push(valueNode);
|
| 206 |
+
return valueNode;
|
| 207 |
+
}
|
| 208 |
+
const visitor = {
|
| 209 |
+
onObjectBegin: (offset) => {
|
| 210 |
+
currentParent = onValue({ type: 'object', offset, length: -1, parent: currentParent, children: [] });
|
| 211 |
+
},
|
| 212 |
+
onObjectProperty: (name, offset, length) => {
|
| 213 |
+
currentParent = onValue({ type: 'property', offset, length: -1, parent: currentParent, children: [] });
|
| 214 |
+
currentParent.children.push({ type: 'string', value: name, offset, length, parent: currentParent });
|
| 215 |
+
},
|
| 216 |
+
onObjectEnd: (offset, length) => {
|
| 217 |
+
ensurePropertyComplete(offset + length); // in case of a missing value for a property: make sure property is complete
|
| 218 |
+
currentParent.length = offset + length - currentParent.offset;
|
| 219 |
+
currentParent = currentParent.parent;
|
| 220 |
+
ensurePropertyComplete(offset + length);
|
| 221 |
+
},
|
| 222 |
+
onArrayBegin: (offset, length) => {
|
| 223 |
+
currentParent = onValue({ type: 'array', offset, length: -1, parent: currentParent, children: [] });
|
| 224 |
+
},
|
| 225 |
+
onArrayEnd: (offset, length) => {
|
| 226 |
+
currentParent.length = offset + length - currentParent.offset;
|
| 227 |
+
currentParent = currentParent.parent;
|
| 228 |
+
ensurePropertyComplete(offset + length);
|
| 229 |
+
},
|
| 230 |
+
onLiteralValue: (value, offset, length) => {
|
| 231 |
+
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
| 232 |
+
ensurePropertyComplete(offset + length);
|
| 233 |
+
},
|
| 234 |
+
onSeparator: (sep, offset, length) => {
|
| 235 |
+
if (currentParent.type === 'property') {
|
| 236 |
+
if (sep === ':') {
|
| 237 |
+
currentParent.colonOffset = offset;
|
| 238 |
+
}
|
| 239 |
+
else if (sep === ',') {
|
| 240 |
+
ensurePropertyComplete(offset);
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
},
|
| 244 |
+
onError: (error, offset, length) => {
|
| 245 |
+
errors.push({ error, offset, length });
|
| 246 |
+
}
|
| 247 |
+
};
|
| 248 |
+
visit(text, visitor, options);
|
| 249 |
+
const result = currentParent.children[0];
|
| 250 |
+
if (result) {
|
| 251 |
+
delete result.parent;
|
| 252 |
+
}
|
| 253 |
+
return result;
|
| 254 |
+
}
|
| 255 |
+
exports.parseTree = parseTree;
|
| 256 |
+
/**
|
| 257 |
+
* Finds the node at the given path in a JSON DOM.
|
| 258 |
+
*/
|
| 259 |
+
function findNodeAtLocation(root, path) {
|
| 260 |
+
if (!root) {
|
| 261 |
+
return undefined;
|
| 262 |
+
}
|
| 263 |
+
let node = root;
|
| 264 |
+
for (let segment of path) {
|
| 265 |
+
if (typeof segment === 'string') {
|
| 266 |
+
if (node.type !== 'object' || !Array.isArray(node.children)) {
|
| 267 |
+
return undefined;
|
| 268 |
+
}
|
| 269 |
+
let found = false;
|
| 270 |
+
for (const propertyNode of node.children) {
|
| 271 |
+
if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
|
| 272 |
+
node = propertyNode.children[1];
|
| 273 |
+
found = true;
|
| 274 |
+
break;
|
| 275 |
+
}
|
| 276 |
+
}
|
| 277 |
+
if (!found) {
|
| 278 |
+
return undefined;
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
else {
|
| 282 |
+
const index = segment;
|
| 283 |
+
if (node.type !== 'array' || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
|
| 284 |
+
return undefined;
|
| 285 |
+
}
|
| 286 |
+
node = node.children[index];
|
| 287 |
+
}
|
| 288 |
+
}
|
| 289 |
+
return node;
|
| 290 |
+
}
|
| 291 |
+
exports.findNodeAtLocation = findNodeAtLocation;
|
| 292 |
+
/**
|
| 293 |
+
* Gets the JSON path of the given JSON DOM node
|
| 294 |
+
*/
|
| 295 |
+
function getNodePath(node) {
|
| 296 |
+
if (!node.parent || !node.parent.children) {
|
| 297 |
+
return [];
|
| 298 |
+
}
|
| 299 |
+
const path = getNodePath(node.parent);
|
| 300 |
+
if (node.parent.type === 'property') {
|
| 301 |
+
const key = node.parent.children[0].value;
|
| 302 |
+
path.push(key);
|
| 303 |
+
}
|
| 304 |
+
else if (node.parent.type === 'array') {
|
| 305 |
+
const index = node.parent.children.indexOf(node);
|
| 306 |
+
if (index !== -1) {
|
| 307 |
+
path.push(index);
|
| 308 |
+
}
|
| 309 |
+
}
|
| 310 |
+
return path;
|
| 311 |
+
}
|
| 312 |
+
exports.getNodePath = getNodePath;
|
| 313 |
+
/**
|
| 314 |
+
* Evaluates the JavaScript object of the given JSON DOM node
|
| 315 |
+
*/
|
| 316 |
+
function getNodeValue(node) {
|
| 317 |
+
switch (node.type) {
|
| 318 |
+
case 'array':
|
| 319 |
+
return node.children.map(getNodeValue);
|
| 320 |
+
case 'object':
|
| 321 |
+
const obj = Object.create(null);
|
| 322 |
+
for (let prop of node.children) {
|
| 323 |
+
const valueNode = prop.children[1];
|
| 324 |
+
if (valueNode) {
|
| 325 |
+
obj[prop.children[0].value] = getNodeValue(valueNode);
|
| 326 |
+
}
|
| 327 |
+
}
|
| 328 |
+
return obj;
|
| 329 |
+
case 'null':
|
| 330 |
+
case 'string':
|
| 331 |
+
case 'number':
|
| 332 |
+
case 'boolean':
|
| 333 |
+
return node.value;
|
| 334 |
+
default:
|
| 335 |
+
return undefined;
|
| 336 |
+
}
|
| 337 |
+
}
|
| 338 |
+
exports.getNodeValue = getNodeValue;
|
| 339 |
+
function contains(node, offset, includeRightBound = false) {
|
| 340 |
+
return (offset >= node.offset && offset < (node.offset + node.length)) || includeRightBound && (offset === (node.offset + node.length));
|
| 341 |
+
}
|
| 342 |
+
exports.contains = contains;
|
| 343 |
+
/**
|
| 344 |
+
* Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
|
| 345 |
+
*/
|
| 346 |
+
function findNodeAtOffset(node, offset, includeRightBound = false) {
|
| 347 |
+
if (contains(node, offset, includeRightBound)) {
|
| 348 |
+
const children = node.children;
|
| 349 |
+
if (Array.isArray(children)) {
|
| 350 |
+
for (let i = 0; i < children.length && children[i].offset <= offset; i++) {
|
| 351 |
+
const item = findNodeAtOffset(children[i], offset, includeRightBound);
|
| 352 |
+
if (item) {
|
| 353 |
+
return item;
|
| 354 |
+
}
|
| 355 |
+
}
|
| 356 |
+
}
|
| 357 |
+
return node;
|
| 358 |
+
}
|
| 359 |
+
return undefined;
|
| 360 |
+
}
|
| 361 |
+
exports.findNodeAtOffset = findNodeAtOffset;
|
| 362 |
+
/**
|
| 363 |
+
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
| 364 |
+
*/
|
| 365 |
+
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
| 366 |
+
const _scanner = (0, scanner_1.createScanner)(text, false);
|
| 367 |
+
// Important: Only pass copies of this to visitor functions to prevent accidental modification, and
|
| 368 |
+
// to not affect visitor functions which stored a reference to a previous JSONPath
|
| 369 |
+
const _jsonPath = [];
|
| 370 |
+
function toNoArgVisit(visitFunction) {
|
| 371 |
+
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
| 372 |
+
}
|
| 373 |
+
function toNoArgVisitWithPath(visitFunction) {
|
| 374 |
+
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
| 375 |
+
}
|
| 376 |
+
function toOneArgVisit(visitFunction) {
|
| 377 |
+
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
| 378 |
+
}
|
| 379 |
+
function toOneArgVisitWithPath(visitFunction) {
|
| 380 |
+
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
| 381 |
+
}
|
| 382 |
+
const onObjectBegin = toNoArgVisitWithPath(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisitWithPath(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
| 383 |
+
const disallowComments = options && options.disallowComments;
|
| 384 |
+
const allowTrailingComma = options && options.allowTrailingComma;
|
| 385 |
+
function scanNext() {
|
| 386 |
+
while (true) {
|
| 387 |
+
const token = _scanner.scan();
|
| 388 |
+
switch (_scanner.getTokenError()) {
|
| 389 |
+
case 4 /* ScanError.InvalidUnicode */:
|
| 390 |
+
handleError(14 /* ParseErrorCode.InvalidUnicode */);
|
| 391 |
+
break;
|
| 392 |
+
case 5 /* ScanError.InvalidEscapeCharacter */:
|
| 393 |
+
handleError(15 /* ParseErrorCode.InvalidEscapeCharacter */);
|
| 394 |
+
break;
|
| 395 |
+
case 3 /* ScanError.UnexpectedEndOfNumber */:
|
| 396 |
+
handleError(13 /* ParseErrorCode.UnexpectedEndOfNumber */);
|
| 397 |
+
break;
|
| 398 |
+
case 1 /* ScanError.UnexpectedEndOfComment */:
|
| 399 |
+
if (!disallowComments) {
|
| 400 |
+
handleError(11 /* ParseErrorCode.UnexpectedEndOfComment */);
|
| 401 |
+
}
|
| 402 |
+
break;
|
| 403 |
+
case 2 /* ScanError.UnexpectedEndOfString */:
|
| 404 |
+
handleError(12 /* ParseErrorCode.UnexpectedEndOfString */);
|
| 405 |
+
break;
|
| 406 |
+
case 6 /* ScanError.InvalidCharacter */:
|
| 407 |
+
handleError(16 /* ParseErrorCode.InvalidCharacter */);
|
| 408 |
+
break;
|
| 409 |
+
}
|
| 410 |
+
switch (token) {
|
| 411 |
+
case 12 /* SyntaxKind.LineCommentTrivia */:
|
| 412 |
+
case 13 /* SyntaxKind.BlockCommentTrivia */:
|
| 413 |
+
if (disallowComments) {
|
| 414 |
+
handleError(10 /* ParseErrorCode.InvalidCommentToken */);
|
| 415 |
+
}
|
| 416 |
+
else {
|
| 417 |
+
onComment();
|
| 418 |
+
}
|
| 419 |
+
break;
|
| 420 |
+
case 16 /* SyntaxKind.Unknown */:
|
| 421 |
+
handleError(1 /* ParseErrorCode.InvalidSymbol */);
|
| 422 |
+
break;
|
| 423 |
+
case 15 /* SyntaxKind.Trivia */:
|
| 424 |
+
case 14 /* SyntaxKind.LineBreakTrivia */:
|
| 425 |
+
break;
|
| 426 |
+
default:
|
| 427 |
+
return token;
|
| 428 |
+
}
|
| 429 |
+
}
|
| 430 |
+
}
|
| 431 |
+
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
| 432 |
+
onError(error);
|
| 433 |
+
if (skipUntilAfter.length + skipUntil.length > 0) {
|
| 434 |
+
let token = _scanner.getToken();
|
| 435 |
+
while (token !== 17 /* SyntaxKind.EOF */) {
|
| 436 |
+
if (skipUntilAfter.indexOf(token) !== -1) {
|
| 437 |
+
scanNext();
|
| 438 |
+
break;
|
| 439 |
+
}
|
| 440 |
+
else if (skipUntil.indexOf(token) !== -1) {
|
| 441 |
+
break;
|
| 442 |
+
}
|
| 443 |
+
token = scanNext();
|
| 444 |
+
}
|
| 445 |
+
}
|
| 446 |
+
}
|
| 447 |
+
function parseString(isValue) {
|
| 448 |
+
const value = _scanner.getTokenValue();
|
| 449 |
+
if (isValue) {
|
| 450 |
+
onLiteralValue(value);
|
| 451 |
+
}
|
| 452 |
+
else {
|
| 453 |
+
onObjectProperty(value);
|
| 454 |
+
// add property name afterwards
|
| 455 |
+
_jsonPath.push(value);
|
| 456 |
+
}
|
| 457 |
+
scanNext();
|
| 458 |
+
return true;
|
| 459 |
+
}
|
| 460 |
+
function parseLiteral() {
|
| 461 |
+
switch (_scanner.getToken()) {
|
| 462 |
+
case 11 /* SyntaxKind.NumericLiteral */:
|
| 463 |
+
const tokenValue = _scanner.getTokenValue();
|
| 464 |
+
let value = Number(tokenValue);
|
| 465 |
+
if (isNaN(value)) {
|
| 466 |
+
handleError(2 /* ParseErrorCode.InvalidNumberFormat */);
|
| 467 |
+
value = 0;
|
| 468 |
+
}
|
| 469 |
+
onLiteralValue(value);
|
| 470 |
+
break;
|
| 471 |
+
case 7 /* SyntaxKind.NullKeyword */:
|
| 472 |
+
onLiteralValue(null);
|
| 473 |
+
break;
|
| 474 |
+
case 8 /* SyntaxKind.TrueKeyword */:
|
| 475 |
+
onLiteralValue(true);
|
| 476 |
+
break;
|
| 477 |
+
case 9 /* SyntaxKind.FalseKeyword */:
|
| 478 |
+
onLiteralValue(false);
|
| 479 |
+
break;
|
| 480 |
+
default:
|
| 481 |
+
return false;
|
| 482 |
+
}
|
| 483 |
+
scanNext();
|
| 484 |
+
return true;
|
| 485 |
+
}
|
| 486 |
+
function parseProperty() {
|
| 487 |
+
if (_scanner.getToken() !== 10 /* SyntaxKind.StringLiteral */) {
|
| 488 |
+
handleError(3 /* ParseErrorCode.PropertyNameExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
| 489 |
+
return false;
|
| 490 |
+
}
|
| 491 |
+
parseString(false);
|
| 492 |
+
if (_scanner.getToken() === 6 /* SyntaxKind.ColonToken */) {
|
| 493 |
+
onSeparator(':');
|
| 494 |
+
scanNext(); // consume colon
|
| 495 |
+
if (!parseValue()) {
|
| 496 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
| 497 |
+
}
|
| 498 |
+
}
|
| 499 |
+
else {
|
| 500 |
+
handleError(5 /* ParseErrorCode.ColonExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
| 501 |
+
}
|
| 502 |
+
_jsonPath.pop(); // remove processed property name
|
| 503 |
+
return true;
|
| 504 |
+
}
|
| 505 |
+
function parseObject() {
|
| 506 |
+
onObjectBegin();
|
| 507 |
+
scanNext(); // consume open brace
|
| 508 |
+
let needsComma = false;
|
| 509 |
+
while (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
| 510 |
+
if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
|
| 511 |
+
if (!needsComma) {
|
| 512 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
| 513 |
+
}
|
| 514 |
+
onSeparator(',');
|
| 515 |
+
scanNext(); // consume comma
|
| 516 |
+
if (_scanner.getToken() === 2 /* SyntaxKind.CloseBraceToken */ && allowTrailingComma) {
|
| 517 |
+
break;
|
| 518 |
+
}
|
| 519 |
+
}
|
| 520 |
+
else if (needsComma) {
|
| 521 |
+
handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
|
| 522 |
+
}
|
| 523 |
+
if (!parseProperty()) {
|
| 524 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
| 525 |
+
}
|
| 526 |
+
needsComma = true;
|
| 527 |
+
}
|
| 528 |
+
onObjectEnd();
|
| 529 |
+
if (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */) {
|
| 530 |
+
handleError(7 /* ParseErrorCode.CloseBraceExpected */, [2 /* SyntaxKind.CloseBraceToken */], []);
|
| 531 |
+
}
|
| 532 |
+
else {
|
| 533 |
+
scanNext(); // consume close brace
|
| 534 |
+
}
|
| 535 |
+
return true;
|
| 536 |
+
}
|
| 537 |
+
function parseArray() {
|
| 538 |
+
onArrayBegin();
|
| 539 |
+
scanNext(); // consume open bracket
|
| 540 |
+
let isFirstElement = true;
|
| 541 |
+
let needsComma = false;
|
| 542 |
+
while (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
| 543 |
+
if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
|
| 544 |
+
if (!needsComma) {
|
| 545 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
| 546 |
+
}
|
| 547 |
+
onSeparator(',');
|
| 548 |
+
scanNext(); // consume comma
|
| 549 |
+
if (_scanner.getToken() === 4 /* SyntaxKind.CloseBracketToken */ && allowTrailingComma) {
|
| 550 |
+
break;
|
| 551 |
+
}
|
| 552 |
+
}
|
| 553 |
+
else if (needsComma) {
|
| 554 |
+
handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
|
| 555 |
+
}
|
| 556 |
+
if (isFirstElement) {
|
| 557 |
+
_jsonPath.push(0);
|
| 558 |
+
isFirstElement = false;
|
| 559 |
+
}
|
| 560 |
+
else {
|
| 561 |
+
_jsonPath[_jsonPath.length - 1]++;
|
| 562 |
+
}
|
| 563 |
+
if (!parseValue()) {
|
| 564 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], [4 /* SyntaxKind.CloseBracketToken */, 5 /* SyntaxKind.CommaToken */]);
|
| 565 |
+
}
|
| 566 |
+
needsComma = true;
|
| 567 |
+
}
|
| 568 |
+
onArrayEnd();
|
| 569 |
+
if (!isFirstElement) {
|
| 570 |
+
_jsonPath.pop(); // remove array index
|
| 571 |
+
}
|
| 572 |
+
if (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */) {
|
| 573 |
+
handleError(8 /* ParseErrorCode.CloseBracketExpected */, [4 /* SyntaxKind.CloseBracketToken */], []);
|
| 574 |
+
}
|
| 575 |
+
else {
|
| 576 |
+
scanNext(); // consume close bracket
|
| 577 |
+
}
|
| 578 |
+
return true;
|
| 579 |
+
}
|
| 580 |
+
function parseValue() {
|
| 581 |
+
switch (_scanner.getToken()) {
|
| 582 |
+
case 3 /* SyntaxKind.OpenBracketToken */:
|
| 583 |
+
return parseArray();
|
| 584 |
+
case 1 /* SyntaxKind.OpenBraceToken */:
|
| 585 |
+
return parseObject();
|
| 586 |
+
case 10 /* SyntaxKind.StringLiteral */:
|
| 587 |
+
return parseString(true);
|
| 588 |
+
default:
|
| 589 |
+
return parseLiteral();
|
| 590 |
+
}
|
| 591 |
+
}
|
| 592 |
+
scanNext();
|
| 593 |
+
if (_scanner.getToken() === 17 /* SyntaxKind.EOF */) {
|
| 594 |
+
if (options.allowEmptyContent) {
|
| 595 |
+
return true;
|
| 596 |
+
}
|
| 597 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
| 598 |
+
return false;
|
| 599 |
+
}
|
| 600 |
+
if (!parseValue()) {
|
| 601 |
+
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
| 602 |
+
return false;
|
| 603 |
+
}
|
| 604 |
+
if (_scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
| 605 |
+
handleError(9 /* ParseErrorCode.EndOfFileExpected */, [], []);
|
| 606 |
+
}
|
| 607 |
+
return true;
|
| 608 |
+
}
|
| 609 |
+
exports.visit = visit;
|
| 610 |
+
/**
|
| 611 |
+
* Takes JSON with JavaScript-style comments and remove
|
| 612 |
+
* them. Optionally replaces every none-newline character
|
| 613 |
+
* of comments with a replaceCharacter
|
| 614 |
+
*/
|
| 615 |
+
function stripComments(text, replaceCh) {
|
| 616 |
+
let _scanner = (0, scanner_1.createScanner)(text), parts = [], kind, offset = 0, pos;
|
| 617 |
+
do {
|
| 618 |
+
pos = _scanner.getPosition();
|
| 619 |
+
kind = _scanner.scan();
|
| 620 |
+
switch (kind) {
|
| 621 |
+
case 12 /* SyntaxKind.LineCommentTrivia */:
|
| 622 |
+
case 13 /* SyntaxKind.BlockCommentTrivia */:
|
| 623 |
+
case 17 /* SyntaxKind.EOF */:
|
| 624 |
+
if (offset !== pos) {
|
| 625 |
+
parts.push(text.substring(offset, pos));
|
| 626 |
+
}
|
| 627 |
+
if (replaceCh !== undefined) {
|
| 628 |
+
parts.push(_scanner.getTokenValue().replace(/[^\r\n]/g, replaceCh));
|
| 629 |
+
}
|
| 630 |
+
offset = _scanner.getPosition();
|
| 631 |
+
break;
|
| 632 |
+
}
|
| 633 |
+
} while (kind !== 17 /* SyntaxKind.EOF */);
|
| 634 |
+
return parts.join('');
|
| 635 |
+
}
|
| 636 |
+
exports.stripComments = stripComments;
|
| 637 |
+
function getNodeType(value) {
|
| 638 |
+
switch (typeof value) {
|
| 639 |
+
case 'boolean': return 'boolean';
|
| 640 |
+
case 'number': return 'number';
|
| 641 |
+
case 'string': return 'string';
|
| 642 |
+
case 'object': {
|
| 643 |
+
if (!value) {
|
| 644 |
+
return 'null';
|
| 645 |
+
}
|
| 646 |
+
else if (Array.isArray(value)) {
|
| 647 |
+
return 'array';
|
| 648 |
+
}
|
| 649 |
+
return 'object';
|
| 650 |
+
}
|
| 651 |
+
default: return 'null';
|
| 652 |
+
}
|
| 653 |
+
}
|
| 654 |
+
exports.getNodeType = getNodeType;
|
| 655 |
+
});
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/impl/scanner.js
CHANGED
|
@@ -1,3 +1,456 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function (factory) {
|
| 2 |
+
if (typeof module === "object" && typeof module.exports === "object") {
|
| 3 |
+
var v = factory(require, exports);
|
| 4 |
+
if (v !== undefined) module.exports = v;
|
| 5 |
+
}
|
| 6 |
+
else if (typeof define === "function" && define.amd) {
|
| 7 |
+
define(["require", "exports"], factory);
|
| 8 |
+
}
|
| 9 |
+
})(function (require, exports) {
|
| 10 |
+
/*---------------------------------------------------------------------------------------------
|
| 11 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 12 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 13 |
+
*--------------------------------------------------------------------------------------------*/
|
| 14 |
+
'use strict';
|
| 15 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 16 |
+
exports.createScanner = void 0;
|
| 17 |
+
/**
|
| 18 |
+
* Creates a JSON scanner on the given text.
|
| 19 |
+
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
| 20 |
+
*/
|
| 21 |
+
function createScanner(text, ignoreTrivia = false) {
|
| 22 |
+
const len = text.length;
|
| 23 |
+
let pos = 0, value = '', tokenOffset = 0, token = 16 /* SyntaxKind.Unknown */, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0 /* ScanError.None */;
|
| 24 |
+
function scanHexDigits(count, exact) {
|
| 25 |
+
let digits = 0;
|
| 26 |
+
let value = 0;
|
| 27 |
+
while (digits < count || !exact) {
|
| 28 |
+
let ch = text.charCodeAt(pos);
|
| 29 |
+
if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) {
|
| 30 |
+
value = value * 16 + ch - 48 /* CharacterCodes._0 */;
|
| 31 |
+
}
|
| 32 |
+
else if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) {
|
| 33 |
+
value = value * 16 + ch - 65 /* CharacterCodes.A */ + 10;
|
| 34 |
+
}
|
| 35 |
+
else if (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */) {
|
| 36 |
+
value = value * 16 + ch - 97 /* CharacterCodes.a */ + 10;
|
| 37 |
+
}
|
| 38 |
+
else {
|
| 39 |
+
break;
|
| 40 |
+
}
|
| 41 |
+
pos++;
|
| 42 |
+
digits++;
|
| 43 |
+
}
|
| 44 |
+
if (digits < count) {
|
| 45 |
+
value = -1;
|
| 46 |
+
}
|
| 47 |
+
return value;
|
| 48 |
+
}
|
| 49 |
+
function setPosition(newPosition) {
|
| 50 |
+
pos = newPosition;
|
| 51 |
+
value = '';
|
| 52 |
+
tokenOffset = 0;
|
| 53 |
+
token = 16 /* SyntaxKind.Unknown */;
|
| 54 |
+
scanError = 0 /* ScanError.None */;
|
| 55 |
+
}
|
| 56 |
+
function scanNumber() {
|
| 57 |
+
let start = pos;
|
| 58 |
+
if (text.charCodeAt(pos) === 48 /* CharacterCodes._0 */) {
|
| 59 |
+
pos++;
|
| 60 |
+
}
|
| 61 |
+
else {
|
| 62 |
+
pos++;
|
| 63 |
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
| 64 |
+
pos++;
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
if (pos < text.length && text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) {
|
| 68 |
+
pos++;
|
| 69 |
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
| 70 |
+
pos++;
|
| 71 |
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
| 72 |
+
pos++;
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
else {
|
| 76 |
+
scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
|
| 77 |
+
return text.substring(start, pos);
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
let end = pos;
|
| 81 |
+
if (pos < text.length && (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */)) {
|
| 82 |
+
pos++;
|
| 83 |
+
if (pos < text.length && text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) {
|
| 84 |
+
pos++;
|
| 85 |
+
}
|
| 86 |
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
| 87 |
+
pos++;
|
| 88 |
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
| 89 |
+
pos++;
|
| 90 |
+
}
|
| 91 |
+
end = pos;
|
| 92 |
+
}
|
| 93 |
+
else {
|
| 94 |
+
scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
return text.substring(start, end);
|
| 98 |
+
}
|
| 99 |
+
function scanString() {
|
| 100 |
+
let result = '', start = pos;
|
| 101 |
+
while (true) {
|
| 102 |
+
if (pos >= len) {
|
| 103 |
+
result += text.substring(start, pos);
|
| 104 |
+
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
| 105 |
+
break;
|
| 106 |
+
}
|
| 107 |
+
const ch = text.charCodeAt(pos);
|
| 108 |
+
if (ch === 34 /* CharacterCodes.doubleQuote */) {
|
| 109 |
+
result += text.substring(start, pos);
|
| 110 |
+
pos++;
|
| 111 |
+
break;
|
| 112 |
+
}
|
| 113 |
+
if (ch === 92 /* CharacterCodes.backslash */) {
|
| 114 |
+
result += text.substring(start, pos);
|
| 115 |
+
pos++;
|
| 116 |
+
if (pos >= len) {
|
| 117 |
+
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
| 118 |
+
break;
|
| 119 |
+
}
|
| 120 |
+
const ch2 = text.charCodeAt(pos++);
|
| 121 |
+
switch (ch2) {
|
| 122 |
+
case 34 /* CharacterCodes.doubleQuote */:
|
| 123 |
+
result += '\"';
|
| 124 |
+
break;
|
| 125 |
+
case 92 /* CharacterCodes.backslash */:
|
| 126 |
+
result += '\\';
|
| 127 |
+
break;
|
| 128 |
+
case 47 /* CharacterCodes.slash */:
|
| 129 |
+
result += '/';
|
| 130 |
+
break;
|
| 131 |
+
case 98 /* CharacterCodes.b */:
|
| 132 |
+
result += '\b';
|
| 133 |
+
break;
|
| 134 |
+
case 102 /* CharacterCodes.f */:
|
| 135 |
+
result += '\f';
|
| 136 |
+
break;
|
| 137 |
+
case 110 /* CharacterCodes.n */:
|
| 138 |
+
result += '\n';
|
| 139 |
+
break;
|
| 140 |
+
case 114 /* CharacterCodes.r */:
|
| 141 |
+
result += '\r';
|
| 142 |
+
break;
|
| 143 |
+
case 116 /* CharacterCodes.t */:
|
| 144 |
+
result += '\t';
|
| 145 |
+
break;
|
| 146 |
+
case 117 /* CharacterCodes.u */:
|
| 147 |
+
const ch3 = scanHexDigits(4, true);
|
| 148 |
+
if (ch3 >= 0) {
|
| 149 |
+
result += String.fromCharCode(ch3);
|
| 150 |
+
}
|
| 151 |
+
else {
|
| 152 |
+
scanError = 4 /* ScanError.InvalidUnicode */;
|
| 153 |
+
}
|
| 154 |
+
break;
|
| 155 |
+
default:
|
| 156 |
+
scanError = 5 /* ScanError.InvalidEscapeCharacter */;
|
| 157 |
+
}
|
| 158 |
+
start = pos;
|
| 159 |
+
continue;
|
| 160 |
+
}
|
| 161 |
+
if (ch >= 0 && ch <= 0x1f) {
|
| 162 |
+
if (isLineBreak(ch)) {
|
| 163 |
+
result += text.substring(start, pos);
|
| 164 |
+
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
| 165 |
+
break;
|
| 166 |
+
}
|
| 167 |
+
else {
|
| 168 |
+
scanError = 6 /* ScanError.InvalidCharacter */;
|
| 169 |
+
// mark as error but continue with string
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
pos++;
|
| 173 |
+
}
|
| 174 |
+
return result;
|
| 175 |
+
}
|
| 176 |
+
function scanNext() {
|
| 177 |
+
value = '';
|
| 178 |
+
scanError = 0 /* ScanError.None */;
|
| 179 |
+
tokenOffset = pos;
|
| 180 |
+
lineStartOffset = lineNumber;
|
| 181 |
+
prevTokenLineStartOffset = tokenLineStartOffset;
|
| 182 |
+
if (pos >= len) {
|
| 183 |
+
// at the end
|
| 184 |
+
tokenOffset = len;
|
| 185 |
+
return token = 17 /* SyntaxKind.EOF */;
|
| 186 |
+
}
|
| 187 |
+
let code = text.charCodeAt(pos);
|
| 188 |
+
// trivia: whitespace
|
| 189 |
+
if (isWhiteSpace(code)) {
|
| 190 |
+
do {
|
| 191 |
+
pos++;
|
| 192 |
+
value += String.fromCharCode(code);
|
| 193 |
+
code = text.charCodeAt(pos);
|
| 194 |
+
} while (isWhiteSpace(code));
|
| 195 |
+
return token = 15 /* SyntaxKind.Trivia */;
|
| 196 |
+
}
|
| 197 |
+
// trivia: newlines
|
| 198 |
+
if (isLineBreak(code)) {
|
| 199 |
+
pos++;
|
| 200 |
+
value += String.fromCharCode(code);
|
| 201 |
+
if (code === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
|
| 202 |
+
pos++;
|
| 203 |
+
value += '\n';
|
| 204 |
+
}
|
| 205 |
+
lineNumber++;
|
| 206 |
+
tokenLineStartOffset = pos;
|
| 207 |
+
return token = 14 /* SyntaxKind.LineBreakTrivia */;
|
| 208 |
+
}
|
| 209 |
+
switch (code) {
|
| 210 |
+
// tokens: []{}:,
|
| 211 |
+
case 123 /* CharacterCodes.openBrace */:
|
| 212 |
+
pos++;
|
| 213 |
+
return token = 1 /* SyntaxKind.OpenBraceToken */;
|
| 214 |
+
case 125 /* CharacterCodes.closeBrace */:
|
| 215 |
+
pos++;
|
| 216 |
+
return token = 2 /* SyntaxKind.CloseBraceToken */;
|
| 217 |
+
case 91 /* CharacterCodes.openBracket */:
|
| 218 |
+
pos++;
|
| 219 |
+
return token = 3 /* SyntaxKind.OpenBracketToken */;
|
| 220 |
+
case 93 /* CharacterCodes.closeBracket */:
|
| 221 |
+
pos++;
|
| 222 |
+
return token = 4 /* SyntaxKind.CloseBracketToken */;
|
| 223 |
+
case 58 /* CharacterCodes.colon */:
|
| 224 |
+
pos++;
|
| 225 |
+
return token = 6 /* SyntaxKind.ColonToken */;
|
| 226 |
+
case 44 /* CharacterCodes.comma */:
|
| 227 |
+
pos++;
|
| 228 |
+
return token = 5 /* SyntaxKind.CommaToken */;
|
| 229 |
+
// strings
|
| 230 |
+
case 34 /* CharacterCodes.doubleQuote */:
|
| 231 |
+
pos++;
|
| 232 |
+
value = scanString();
|
| 233 |
+
return token = 10 /* SyntaxKind.StringLiteral */;
|
| 234 |
+
// comments
|
| 235 |
+
case 47 /* CharacterCodes.slash */:
|
| 236 |
+
const start = pos - 1;
|
| 237 |
+
// Single-line comment
|
| 238 |
+
if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
|
| 239 |
+
pos += 2;
|
| 240 |
+
while (pos < len) {
|
| 241 |
+
if (isLineBreak(text.charCodeAt(pos))) {
|
| 242 |
+
break;
|
| 243 |
+
}
|
| 244 |
+
pos++;
|
| 245 |
+
}
|
| 246 |
+
value = text.substring(start, pos);
|
| 247 |
+
return token = 12 /* SyntaxKind.LineCommentTrivia */;
|
| 248 |
+
}
|
| 249 |
+
// Multi-line comment
|
| 250 |
+
if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
|
| 251 |
+
pos += 2;
|
| 252 |
+
const safeLength = len - 1; // For lookahead.
|
| 253 |
+
let commentClosed = false;
|
| 254 |
+
while (pos < safeLength) {
|
| 255 |
+
const ch = text.charCodeAt(pos);
|
| 256 |
+
if (ch === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
|
| 257 |
+
pos += 2;
|
| 258 |
+
commentClosed = true;
|
| 259 |
+
break;
|
| 260 |
+
}
|
| 261 |
+
pos++;
|
| 262 |
+
if (isLineBreak(ch)) {
|
| 263 |
+
if (ch === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
|
| 264 |
+
pos++;
|
| 265 |
+
}
|
| 266 |
+
lineNumber++;
|
| 267 |
+
tokenLineStartOffset = pos;
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
if (!commentClosed) {
|
| 271 |
+
pos++;
|
| 272 |
+
scanError = 1 /* ScanError.UnexpectedEndOfComment */;
|
| 273 |
+
}
|
| 274 |
+
value = text.substring(start, pos);
|
| 275 |
+
return token = 13 /* SyntaxKind.BlockCommentTrivia */;
|
| 276 |
+
}
|
| 277 |
+
// just a single slash
|
| 278 |
+
value += String.fromCharCode(code);
|
| 279 |
+
pos++;
|
| 280 |
+
return token = 16 /* SyntaxKind.Unknown */;
|
| 281 |
+
// numbers
|
| 282 |
+
case 45 /* CharacterCodes.minus */:
|
| 283 |
+
value += String.fromCharCode(code);
|
| 284 |
+
pos++;
|
| 285 |
+
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
| 286 |
+
return token = 16 /* SyntaxKind.Unknown */;
|
| 287 |
+
}
|
| 288 |
+
// found a minus, followed by a number so
|
| 289 |
+
// we fall through to proceed with scanning
|
| 290 |
+
// numbers
|
| 291 |
+
case 48 /* CharacterCodes._0 */:
|
| 292 |
+
case 49 /* CharacterCodes._1 */:
|
| 293 |
+
case 50 /* CharacterCodes._2 */:
|
| 294 |
+
case 51 /* CharacterCodes._3 */:
|
| 295 |
+
case 52 /* CharacterCodes._4 */:
|
| 296 |
+
case 53 /* CharacterCodes._5 */:
|
| 297 |
+
case 54 /* CharacterCodes._6 */:
|
| 298 |
+
case 55 /* CharacterCodes._7 */:
|
| 299 |
+
case 56 /* CharacterCodes._8 */:
|
| 300 |
+
case 57 /* CharacterCodes._9 */:
|
| 301 |
+
value += scanNumber();
|
| 302 |
+
return token = 11 /* SyntaxKind.NumericLiteral */;
|
| 303 |
+
// literals and unknown symbols
|
| 304 |
+
default:
|
| 305 |
+
// is a literal? Read the full word.
|
| 306 |
+
while (pos < len && isUnknownContentCharacter(code)) {
|
| 307 |
+
pos++;
|
| 308 |
+
code = text.charCodeAt(pos);
|
| 309 |
+
}
|
| 310 |
+
if (tokenOffset !== pos) {
|
| 311 |
+
value = text.substring(tokenOffset, pos);
|
| 312 |
+
// keywords: true, false, null
|
| 313 |
+
switch (value) {
|
| 314 |
+
case 'true': return token = 8 /* SyntaxKind.TrueKeyword */;
|
| 315 |
+
case 'false': return token = 9 /* SyntaxKind.FalseKeyword */;
|
| 316 |
+
case 'null': return token = 7 /* SyntaxKind.NullKeyword */;
|
| 317 |
+
}
|
| 318 |
+
return token = 16 /* SyntaxKind.Unknown */;
|
| 319 |
+
}
|
| 320 |
+
// some
|
| 321 |
+
value += String.fromCharCode(code);
|
| 322 |
+
pos++;
|
| 323 |
+
return token = 16 /* SyntaxKind.Unknown */;
|
| 324 |
+
}
|
| 325 |
+
}
|
| 326 |
+
function isUnknownContentCharacter(code) {
|
| 327 |
+
if (isWhiteSpace(code) || isLineBreak(code)) {
|
| 328 |
+
return false;
|
| 329 |
+
}
|
| 330 |
+
switch (code) {
|
| 331 |
+
case 125 /* CharacterCodes.closeBrace */:
|
| 332 |
+
case 93 /* CharacterCodes.closeBracket */:
|
| 333 |
+
case 123 /* CharacterCodes.openBrace */:
|
| 334 |
+
case 91 /* CharacterCodes.openBracket */:
|
| 335 |
+
case 34 /* CharacterCodes.doubleQuote */:
|
| 336 |
+
case 58 /* CharacterCodes.colon */:
|
| 337 |
+
case 44 /* CharacterCodes.comma */:
|
| 338 |
+
case 47 /* CharacterCodes.slash */:
|
| 339 |
+
return false;
|
| 340 |
+
}
|
| 341 |
+
return true;
|
| 342 |
+
}
|
| 343 |
+
function scanNextNonTrivia() {
|
| 344 |
+
let result;
|
| 345 |
+
do {
|
| 346 |
+
result = scanNext();
|
| 347 |
+
} while (result >= 12 /* SyntaxKind.LineCommentTrivia */ && result <= 15 /* SyntaxKind.Trivia */);
|
| 348 |
+
return result;
|
| 349 |
+
}
|
| 350 |
+
return {
|
| 351 |
+
setPosition: setPosition,
|
| 352 |
+
getPosition: () => pos,
|
| 353 |
+
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
| 354 |
+
getToken: () => token,
|
| 355 |
+
getTokenValue: () => value,
|
| 356 |
+
getTokenOffset: () => tokenOffset,
|
| 357 |
+
getTokenLength: () => pos - tokenOffset,
|
| 358 |
+
getTokenStartLine: () => lineStartOffset,
|
| 359 |
+
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
|
| 360 |
+
getTokenError: () => scanError,
|
| 361 |
+
};
|
| 362 |
+
}
|
| 363 |
+
exports.createScanner = createScanner;
|
| 364 |
+
function isWhiteSpace(ch) {
|
| 365 |
+
return ch === 32 /* CharacterCodes.space */ || ch === 9 /* CharacterCodes.tab */;
|
| 366 |
+
}
|
| 367 |
+
function isLineBreak(ch) {
|
| 368 |
+
return ch === 10 /* CharacterCodes.lineFeed */ || ch === 13 /* CharacterCodes.carriageReturn */;
|
| 369 |
+
}
|
| 370 |
+
function isDigit(ch) {
|
| 371 |
+
return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */;
|
| 372 |
+
}
|
| 373 |
+
var CharacterCodes;
|
| 374 |
+
(function (CharacterCodes) {
|
| 375 |
+
CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
|
| 376 |
+
CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
|
| 377 |
+
CharacterCodes[CharacterCodes["space"] = 32] = "space";
|
| 378 |
+
CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
|
| 379 |
+
CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
|
| 380 |
+
CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
|
| 381 |
+
CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
|
| 382 |
+
CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
|
| 383 |
+
CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
|
| 384 |
+
CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
|
| 385 |
+
CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
|
| 386 |
+
CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
|
| 387 |
+
CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
|
| 388 |
+
CharacterCodes[CharacterCodes["a"] = 97] = "a";
|
| 389 |
+
CharacterCodes[CharacterCodes["b"] = 98] = "b";
|
| 390 |
+
CharacterCodes[CharacterCodes["c"] = 99] = "c";
|
| 391 |
+
CharacterCodes[CharacterCodes["d"] = 100] = "d";
|
| 392 |
+
CharacterCodes[CharacterCodes["e"] = 101] = "e";
|
| 393 |
+
CharacterCodes[CharacterCodes["f"] = 102] = "f";
|
| 394 |
+
CharacterCodes[CharacterCodes["g"] = 103] = "g";
|
| 395 |
+
CharacterCodes[CharacterCodes["h"] = 104] = "h";
|
| 396 |
+
CharacterCodes[CharacterCodes["i"] = 105] = "i";
|
| 397 |
+
CharacterCodes[CharacterCodes["j"] = 106] = "j";
|
| 398 |
+
CharacterCodes[CharacterCodes["k"] = 107] = "k";
|
| 399 |
+
CharacterCodes[CharacterCodes["l"] = 108] = "l";
|
| 400 |
+
CharacterCodes[CharacterCodes["m"] = 109] = "m";
|
| 401 |
+
CharacterCodes[CharacterCodes["n"] = 110] = "n";
|
| 402 |
+
CharacterCodes[CharacterCodes["o"] = 111] = "o";
|
| 403 |
+
CharacterCodes[CharacterCodes["p"] = 112] = "p";
|
| 404 |
+
CharacterCodes[CharacterCodes["q"] = 113] = "q";
|
| 405 |
+
CharacterCodes[CharacterCodes["r"] = 114] = "r";
|
| 406 |
+
CharacterCodes[CharacterCodes["s"] = 115] = "s";
|
| 407 |
+
CharacterCodes[CharacterCodes["t"] = 116] = "t";
|
| 408 |
+
CharacterCodes[CharacterCodes["u"] = 117] = "u";
|
| 409 |
+
CharacterCodes[CharacterCodes["v"] = 118] = "v";
|
| 410 |
+
CharacterCodes[CharacterCodes["w"] = 119] = "w";
|
| 411 |
+
CharacterCodes[CharacterCodes["x"] = 120] = "x";
|
| 412 |
+
CharacterCodes[CharacterCodes["y"] = 121] = "y";
|
| 413 |
+
CharacterCodes[CharacterCodes["z"] = 122] = "z";
|
| 414 |
+
CharacterCodes[CharacterCodes["A"] = 65] = "A";
|
| 415 |
+
CharacterCodes[CharacterCodes["B"] = 66] = "B";
|
| 416 |
+
CharacterCodes[CharacterCodes["C"] = 67] = "C";
|
| 417 |
+
CharacterCodes[CharacterCodes["D"] = 68] = "D";
|
| 418 |
+
CharacterCodes[CharacterCodes["E"] = 69] = "E";
|
| 419 |
+
CharacterCodes[CharacterCodes["F"] = 70] = "F";
|
| 420 |
+
CharacterCodes[CharacterCodes["G"] = 71] = "G";
|
| 421 |
+
CharacterCodes[CharacterCodes["H"] = 72] = "H";
|
| 422 |
+
CharacterCodes[CharacterCodes["I"] = 73] = "I";
|
| 423 |
+
CharacterCodes[CharacterCodes["J"] = 74] = "J";
|
| 424 |
+
CharacterCodes[CharacterCodes["K"] = 75] = "K";
|
| 425 |
+
CharacterCodes[CharacterCodes["L"] = 76] = "L";
|
| 426 |
+
CharacterCodes[CharacterCodes["M"] = 77] = "M";
|
| 427 |
+
CharacterCodes[CharacterCodes["N"] = 78] = "N";
|
| 428 |
+
CharacterCodes[CharacterCodes["O"] = 79] = "O";
|
| 429 |
+
CharacterCodes[CharacterCodes["P"] = 80] = "P";
|
| 430 |
+
CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
|
| 431 |
+
CharacterCodes[CharacterCodes["R"] = 82] = "R";
|
| 432 |
+
CharacterCodes[CharacterCodes["S"] = 83] = "S";
|
| 433 |
+
CharacterCodes[CharacterCodes["T"] = 84] = "T";
|
| 434 |
+
CharacterCodes[CharacterCodes["U"] = 85] = "U";
|
| 435 |
+
CharacterCodes[CharacterCodes["V"] = 86] = "V";
|
| 436 |
+
CharacterCodes[CharacterCodes["W"] = 87] = "W";
|
| 437 |
+
CharacterCodes[CharacterCodes["X"] = 88] = "X";
|
| 438 |
+
CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
|
| 439 |
+
CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
|
| 440 |
+
CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
|
| 441 |
+
CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
|
| 442 |
+
CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
|
| 443 |
+
CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
|
| 444 |
+
CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
|
| 445 |
+
CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
|
| 446 |
+
CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
|
| 447 |
+
CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
|
| 448 |
+
CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
|
| 449 |
+
CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
|
| 450 |
+
CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
|
| 451 |
+
CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
|
| 452 |
+
CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
|
| 453 |
+
CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
|
| 454 |
+
CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
|
| 455 |
+
})(CharacterCodes || (CharacterCodes = {}));
|
| 456 |
+
});
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/impl/string-intern.js
CHANGED
|
@@ -1,3 +1,42 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function (factory) {
|
| 2 |
+
if (typeof module === "object" && typeof module.exports === "object") {
|
| 3 |
+
var v = factory(require, exports);
|
| 4 |
+
if (v !== undefined) module.exports = v;
|
| 5 |
+
}
|
| 6 |
+
else if (typeof define === "function" && define.amd) {
|
| 7 |
+
define(["require", "exports"], factory);
|
| 8 |
+
}
|
| 9 |
+
})(function (require, exports) {
|
| 10 |
+
"use strict";
|
| 11 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 12 |
+
exports.supportedEols = exports.cachedBreakLinesWithSpaces = exports.cachedSpaces = void 0;
|
| 13 |
+
exports.cachedSpaces = new Array(20).fill(0).map((_, index) => {
|
| 14 |
+
return ' '.repeat(index);
|
| 15 |
+
});
|
| 16 |
+
const maxCachedValues = 200;
|
| 17 |
+
exports.cachedBreakLinesWithSpaces = {
|
| 18 |
+
' ': {
|
| 19 |
+
'\n': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 20 |
+
return '\n' + ' '.repeat(index);
|
| 21 |
+
}),
|
| 22 |
+
'\r': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 23 |
+
return '\r' + ' '.repeat(index);
|
| 24 |
+
}),
|
| 25 |
+
'\r\n': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 26 |
+
return '\r\n' + ' '.repeat(index);
|
| 27 |
+
}),
|
| 28 |
+
},
|
| 29 |
+
'\t': {
|
| 30 |
+
'\n': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 31 |
+
return '\n' + '\t'.repeat(index);
|
| 32 |
+
}),
|
| 33 |
+
'\r': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 34 |
+
return '\r' + '\t'.repeat(index);
|
| 35 |
+
}),
|
| 36 |
+
'\r\n': new Array(maxCachedValues).fill(0).map((_, index) => {
|
| 37 |
+
return '\r\n' + '\t'.repeat(index);
|
| 38 |
+
}),
|
| 39 |
+
}
|
| 40 |
+
};
|
| 41 |
+
exports.supportedEols = ['\n', '\r', '\r\n'];
|
| 42 |
+
});
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/main.d.ts
CHANGED
|
@@ -1,3 +1,349 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Creates a JSON scanner on the given text.
|
| 3 |
+
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
| 4 |
+
*/
|
| 5 |
+
export declare const createScanner: (text: string, ignoreTrivia?: boolean) => JSONScanner;
|
| 6 |
+
export declare const enum ScanError {
|
| 7 |
+
None = 0,
|
| 8 |
+
UnexpectedEndOfComment = 1,
|
| 9 |
+
UnexpectedEndOfString = 2,
|
| 10 |
+
UnexpectedEndOfNumber = 3,
|
| 11 |
+
InvalidUnicode = 4,
|
| 12 |
+
InvalidEscapeCharacter = 5,
|
| 13 |
+
InvalidCharacter = 6
|
| 14 |
+
}
|
| 15 |
+
export declare const enum SyntaxKind {
|
| 16 |
+
OpenBraceToken = 1,
|
| 17 |
+
CloseBraceToken = 2,
|
| 18 |
+
OpenBracketToken = 3,
|
| 19 |
+
CloseBracketToken = 4,
|
| 20 |
+
CommaToken = 5,
|
| 21 |
+
ColonToken = 6,
|
| 22 |
+
NullKeyword = 7,
|
| 23 |
+
TrueKeyword = 8,
|
| 24 |
+
FalseKeyword = 9,
|
| 25 |
+
StringLiteral = 10,
|
| 26 |
+
NumericLiteral = 11,
|
| 27 |
+
LineCommentTrivia = 12,
|
| 28 |
+
BlockCommentTrivia = 13,
|
| 29 |
+
LineBreakTrivia = 14,
|
| 30 |
+
Trivia = 15,
|
| 31 |
+
Unknown = 16,
|
| 32 |
+
EOF = 17
|
| 33 |
+
}
|
| 34 |
+
/**
|
| 35 |
+
* The scanner object, representing a JSON scanner at a position in the input string.
|
| 36 |
+
*/
|
| 37 |
+
export interface JSONScanner {
|
| 38 |
+
/**
|
| 39 |
+
* Sets the scan position to a new offset. A call to 'scan' is needed to get the first token.
|
| 40 |
+
*/
|
| 41 |
+
setPosition(pos: number): void;
|
| 42 |
+
/**
|
| 43 |
+
* Read the next token. Returns the token code.
|
| 44 |
+
*/
|
| 45 |
+
scan(): SyntaxKind;
|
| 46 |
+
/**
|
| 47 |
+
* Returns the zero-based current scan position, which is after the last read token.
|
| 48 |
+
*/
|
| 49 |
+
getPosition(): number;
|
| 50 |
+
/**
|
| 51 |
+
* Returns the last read token.
|
| 52 |
+
*/
|
| 53 |
+
getToken(): SyntaxKind;
|
| 54 |
+
/**
|
| 55 |
+
* Returns the last read token value. The value for strings is the decoded string content. For numbers it's of type number, for boolean it's true or false.
|
| 56 |
+
*/
|
| 57 |
+
getTokenValue(): string;
|
| 58 |
+
/**
|
| 59 |
+
* The zero-based start offset of the last read token.
|
| 60 |
+
*/
|
| 61 |
+
getTokenOffset(): number;
|
| 62 |
+
/**
|
| 63 |
+
* The length of the last read token.
|
| 64 |
+
*/
|
| 65 |
+
getTokenLength(): number;
|
| 66 |
+
/**
|
| 67 |
+
* The zero-based start line number of the last read token.
|
| 68 |
+
*/
|
| 69 |
+
getTokenStartLine(): number;
|
| 70 |
+
/**
|
| 71 |
+
* The zero-based start character (column) of the last read token.
|
| 72 |
+
*/
|
| 73 |
+
getTokenStartCharacter(): number;
|
| 74 |
+
/**
|
| 75 |
+
* An error code of the last scan.
|
| 76 |
+
*/
|
| 77 |
+
getTokenError(): ScanError;
|
| 78 |
+
}
|
| 79 |
+
/**
|
| 80 |
+
* For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
|
| 81 |
+
*/
|
| 82 |
+
export declare const getLocation: (text: string, position: number) => Location;
|
| 83 |
+
/**
|
| 84 |
+
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 85 |
+
* Therefore, always check the errors list to find out if the input was valid.
|
| 86 |
+
*/
|
| 87 |
+
export declare const parse: (text: string, errors?: ParseError[], options?: ParseOptions) => any;
|
| 88 |
+
/**
|
| 89 |
+
* Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 90 |
+
*/
|
| 91 |
+
export declare const parseTree: (text: string, errors?: ParseError[], options?: ParseOptions) => Node | undefined;
|
| 92 |
+
/**
|
| 93 |
+
* Finds the node at the given path in a JSON DOM.
|
| 94 |
+
*/
|
| 95 |
+
export declare const findNodeAtLocation: (root: Node, path: JSONPath) => Node | undefined;
|
| 96 |
+
/**
|
| 97 |
+
* Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
|
| 98 |
+
*/
|
| 99 |
+
export declare const findNodeAtOffset: (root: Node, offset: number, includeRightBound?: boolean) => Node | undefined;
|
| 100 |
+
/**
|
| 101 |
+
* Gets the JSON path of the given JSON DOM node
|
| 102 |
+
*/
|
| 103 |
+
export declare const getNodePath: (node: Node) => JSONPath;
|
| 104 |
+
/**
|
| 105 |
+
* Evaluates the JavaScript object of the given JSON DOM node
|
| 106 |
+
*/
|
| 107 |
+
export declare const getNodeValue: (node: Node) => any;
|
| 108 |
+
/**
|
| 109 |
+
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
| 110 |
+
*/
|
| 111 |
+
export declare const visit: (text: string, visitor: JSONVisitor, options?: ParseOptions) => any;
|
| 112 |
+
/**
|
| 113 |
+
* Takes JSON with JavaScript-style comments and remove
|
| 114 |
+
* them. Optionally replaces every none-newline character
|
| 115 |
+
* of comments with a replaceCharacter
|
| 116 |
+
*/
|
| 117 |
+
export declare const stripComments: (text: string, replaceCh?: string) => string;
|
| 118 |
+
export interface ParseError {
|
| 119 |
+
error: ParseErrorCode;
|
| 120 |
+
offset: number;
|
| 121 |
+
length: number;
|
| 122 |
+
}
|
| 123 |
+
export declare const enum ParseErrorCode {
|
| 124 |
+
InvalidSymbol = 1,
|
| 125 |
+
InvalidNumberFormat = 2,
|
| 126 |
+
PropertyNameExpected = 3,
|
| 127 |
+
ValueExpected = 4,
|
| 128 |
+
ColonExpected = 5,
|
| 129 |
+
CommaExpected = 6,
|
| 130 |
+
CloseBraceExpected = 7,
|
| 131 |
+
CloseBracketExpected = 8,
|
| 132 |
+
EndOfFileExpected = 9,
|
| 133 |
+
InvalidCommentToken = 10,
|
| 134 |
+
UnexpectedEndOfComment = 11,
|
| 135 |
+
UnexpectedEndOfString = 12,
|
| 136 |
+
UnexpectedEndOfNumber = 13,
|
| 137 |
+
InvalidUnicode = 14,
|
| 138 |
+
InvalidEscapeCharacter = 15,
|
| 139 |
+
InvalidCharacter = 16
|
| 140 |
+
}
|
| 141 |
+
export declare function printParseErrorCode(code: ParseErrorCode): "InvalidSymbol" | "InvalidNumberFormat" | "PropertyNameExpected" | "ValueExpected" | "ColonExpected" | "CommaExpected" | "CloseBraceExpected" | "CloseBracketExpected" | "EndOfFileExpected" | "InvalidCommentToken" | "UnexpectedEndOfComment" | "UnexpectedEndOfString" | "UnexpectedEndOfNumber" | "InvalidUnicode" | "InvalidEscapeCharacter" | "InvalidCharacter" | "<unknown ParseErrorCode>";
|
| 142 |
+
export type NodeType = 'object' | 'array' | 'property' | 'string' | 'number' | 'boolean' | 'null';
|
| 143 |
+
export interface Node {
|
| 144 |
+
readonly type: NodeType;
|
| 145 |
+
readonly value?: any;
|
| 146 |
+
readonly offset: number;
|
| 147 |
+
readonly length: number;
|
| 148 |
+
readonly colonOffset?: number;
|
| 149 |
+
readonly parent?: Node;
|
| 150 |
+
readonly children?: Node[];
|
| 151 |
+
}
|
| 152 |
+
/**
|
| 153 |
+
* A {@linkcode JSONPath} segment. Either a string representing an object property name
|
| 154 |
+
* or a number (starting at 0) for array indices.
|
| 155 |
+
*/
|
| 156 |
+
export type Segment = string | number;
|
| 157 |
+
export type JSONPath = Segment[];
|
| 158 |
+
export interface Location {
|
| 159 |
+
/**
|
| 160 |
+
* The previous property key or literal value (string, number, boolean or null) or undefined.
|
| 161 |
+
*/
|
| 162 |
+
previousNode?: Node;
|
| 163 |
+
/**
|
| 164 |
+
* The path describing the location in the JSON document. The path consists of a sequence of strings
|
| 165 |
+
* representing an object property or numbers for array indices.
|
| 166 |
+
*/
|
| 167 |
+
path: JSONPath;
|
| 168 |
+
/**
|
| 169 |
+
* Matches the locations path against a pattern consisting of strings (for properties) and numbers (for array indices).
|
| 170 |
+
* '*' will match a single segment of any property name or index.
|
| 171 |
+
* '**' will match a sequence of segments of any property name or index, or no segment.
|
| 172 |
+
*/
|
| 173 |
+
matches: (patterns: JSONPath) => boolean;
|
| 174 |
+
/**
|
| 175 |
+
* If set, the location's offset is at a property key.
|
| 176 |
+
*/
|
| 177 |
+
isAtPropertyKey: boolean;
|
| 178 |
+
}
|
| 179 |
+
export interface ParseOptions {
|
| 180 |
+
disallowComments?: boolean;
|
| 181 |
+
allowTrailingComma?: boolean;
|
| 182 |
+
allowEmptyContent?: boolean;
|
| 183 |
+
}
|
| 184 |
+
/**
|
| 185 |
+
* Visitor called by {@linkcode visit} when parsing JSON.
|
| 186 |
+
*
|
| 187 |
+
* The visitor functions have the following common parameters:
|
| 188 |
+
* - `offset`: Global offset within the JSON document, starting at 0
|
| 189 |
+
* - `startLine`: Line number, starting at 0
|
| 190 |
+
* - `startCharacter`: Start character (column) within the current line, starting at 0
|
| 191 |
+
*
|
| 192 |
+
* Additionally some functions have a `pathSupplier` parameter which can be used to obtain the
|
| 193 |
+
* current `JSONPath` within the document.
|
| 194 |
+
*/
|
| 195 |
+
export interface JSONVisitor {
|
| 196 |
+
/**
|
| 197 |
+
* Invoked when an open brace is encountered and an object is started. The offset and length represent the location of the open brace.
|
| 198 |
+
*/
|
| 199 |
+
onObjectBegin?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 200 |
+
/**
|
| 201 |
+
* Invoked when a property is encountered. The offset and length represent the location of the property name.
|
| 202 |
+
* The `JSONPath` created by the `pathSupplier` refers to the enclosing JSON object, it does not include the
|
| 203 |
+
* property name yet.
|
| 204 |
+
*/
|
| 205 |
+
onObjectProperty?: (property: string, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 206 |
+
/**
|
| 207 |
+
* Invoked when a closing brace is encountered and an object is completed. The offset and length represent the location of the closing brace.
|
| 208 |
+
*/
|
| 209 |
+
onObjectEnd?: (offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 210 |
+
/**
|
| 211 |
+
* Invoked when an open bracket is encountered. The offset and length represent the location of the open bracket.
|
| 212 |
+
*/
|
| 213 |
+
onArrayBegin?: (offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 214 |
+
/**
|
| 215 |
+
* Invoked when a closing bracket is encountered. The offset and length represent the location of the closing bracket.
|
| 216 |
+
*/
|
| 217 |
+
onArrayEnd?: (offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 218 |
+
/**
|
| 219 |
+
* Invoked when a literal value is encountered. The offset and length represent the location of the literal value.
|
| 220 |
+
*/
|
| 221 |
+
onLiteralValue?: (value: any, offset: number, length: number, startLine: number, startCharacter: number, pathSupplier: () => JSONPath) => void;
|
| 222 |
+
/**
|
| 223 |
+
* Invoked when a comma or colon separator is encountered. The offset and length represent the location of the separator.
|
| 224 |
+
*/
|
| 225 |
+
onSeparator?: (character: string, offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 226 |
+
/**
|
| 227 |
+
* When comments are allowed, invoked when a line or block comment is encountered. The offset and length represent the location of the comment.
|
| 228 |
+
*/
|
| 229 |
+
onComment?: (offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 230 |
+
/**
|
| 231 |
+
* Invoked on an error.
|
| 232 |
+
*/
|
| 233 |
+
onError?: (error: ParseErrorCode, offset: number, length: number, startLine: number, startCharacter: number) => void;
|
| 234 |
+
}
|
| 235 |
+
/**
|
| 236 |
+
* An edit result describes a textual edit operation. It is the result of a {@linkcode format} and {@linkcode modify} operation.
|
| 237 |
+
* It consist of one or more edits describing insertions, replacements or removals of text segments.
|
| 238 |
+
* * The offsets of the edits refer to the original state of the document.
|
| 239 |
+
* * No two edits change or remove the same range of text in the original document.
|
| 240 |
+
* * Multiple edits can have the same offset if they are multiple inserts, or an insert followed by a remove or replace.
|
| 241 |
+
* * The order in the array defines which edit is applied first.
|
| 242 |
+
* To apply an edit result use {@linkcode applyEdits}.
|
| 243 |
+
* In general multiple EditResults must not be concatenated because they might impact each other, producing incorrect or malformed JSON data.
|
| 244 |
+
*/
|
| 245 |
+
export type EditResult = Edit[];
|
| 246 |
+
/**
|
| 247 |
+
* Represents a text modification
|
| 248 |
+
*/
|
| 249 |
+
export interface Edit {
|
| 250 |
+
/**
|
| 251 |
+
* The start offset of the modification.
|
| 252 |
+
*/
|
| 253 |
+
offset: number;
|
| 254 |
+
/**
|
| 255 |
+
* The length of the modification. Must not be negative. Empty length represents an *insert*.
|
| 256 |
+
*/
|
| 257 |
+
length: number;
|
| 258 |
+
/**
|
| 259 |
+
* The new content. Empty content represents a *remove*.
|
| 260 |
+
*/
|
| 261 |
+
content: string;
|
| 262 |
+
}
|
| 263 |
+
/**
|
| 264 |
+
* A text range in the document
|
| 265 |
+
*/
|
| 266 |
+
export interface Range {
|
| 267 |
+
/**
|
| 268 |
+
* The start offset of the range.
|
| 269 |
+
*/
|
| 270 |
+
offset: number;
|
| 271 |
+
/**
|
| 272 |
+
* The length of the range. Must not be negative.
|
| 273 |
+
*/
|
| 274 |
+
length: number;
|
| 275 |
+
}
|
| 276 |
+
/**
|
| 277 |
+
* Options used by {@linkcode format} when computing the formatting edit operations
|
| 278 |
+
*/
|
| 279 |
+
export interface FormattingOptions {
|
| 280 |
+
/**
|
| 281 |
+
* If indentation is based on spaces (`insertSpaces` = true), the number of spaces that make an indent.
|
| 282 |
+
*/
|
| 283 |
+
tabSize?: number;
|
| 284 |
+
/**
|
| 285 |
+
* Is indentation based on spaces?
|
| 286 |
+
*/
|
| 287 |
+
insertSpaces?: boolean;
|
| 288 |
+
/**
|
| 289 |
+
* The default 'end of line' character. If not set, '\n' is used as default.
|
| 290 |
+
*/
|
| 291 |
+
eol?: string;
|
| 292 |
+
/**
|
| 293 |
+
* If set, will add a new line at the end of the document.
|
| 294 |
+
*/
|
| 295 |
+
insertFinalNewline?: boolean;
|
| 296 |
+
/**
|
| 297 |
+
* If true, will keep line positions as is in the formatting
|
| 298 |
+
*/
|
| 299 |
+
keepLines?: boolean;
|
| 300 |
+
}
|
| 301 |
+
/**
|
| 302 |
+
* Computes the edit operations needed to format a JSON document.
|
| 303 |
+
*
|
| 304 |
+
* @param documentText The input text
|
| 305 |
+
* @param range The range to format or `undefined` to format the full content
|
| 306 |
+
* @param options The formatting options
|
| 307 |
+
* @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.
|
| 308 |
+
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
| 309 |
+
*/
|
| 310 |
+
export declare function format(documentText: string, range: Range | undefined, options: FormattingOptions): EditResult;
|
| 311 |
+
/**
|
| 312 |
+
* Options used by {@linkcode modify} when computing the modification edit operations
|
| 313 |
+
*/
|
| 314 |
+
export interface ModificationOptions {
|
| 315 |
+
/**
|
| 316 |
+
* Formatting options. If undefined, the newly inserted code will be inserted unformatted.
|
| 317 |
+
*/
|
| 318 |
+
formattingOptions?: FormattingOptions;
|
| 319 |
+
/**
|
| 320 |
+
* Default false. If `JSONPath` refers to an index of an array and `isArrayInsertion` is `true`, then
|
| 321 |
+
* {@linkcode modify} will insert a new item at that location instead of overwriting its contents.
|
| 322 |
+
*/
|
| 323 |
+
isArrayInsertion?: boolean;
|
| 324 |
+
/**
|
| 325 |
+
* Optional function to define the insertion index given an existing list of properties.
|
| 326 |
+
*/
|
| 327 |
+
getInsertionIndex?: (properties: string[]) => number;
|
| 328 |
+
}
|
| 329 |
+
/**
|
| 330 |
+
* Computes the edit operations needed to modify a value in the JSON document.
|
| 331 |
+
*
|
| 332 |
+
* @param documentText The input text
|
| 333 |
+
* @param path The path of the value to change. The path represents either to the document root, a property or an array item.
|
| 334 |
+
* If the path points to an non-existing property or item, it will be created.
|
| 335 |
+
* @param value The new value for the specified property or item. If the value is undefined,
|
| 336 |
+
* the property or item will be removed.
|
| 337 |
+
* @param options Options
|
| 338 |
+
* @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
|
| 339 |
+
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
| 340 |
+
*/
|
| 341 |
+
export declare function modify(text: string, path: JSONPath, value: any, options: ModificationOptions): EditResult;
|
| 342 |
+
/**
|
| 343 |
+
* Applies edits to an input string.
|
| 344 |
+
* @param text The input text
|
| 345 |
+
* @param edits Edit operations following the format described in {@linkcode EditResult}.
|
| 346 |
+
* @returns The text with the applied edits.
|
| 347 |
+
* @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
|
| 348 |
+
*/
|
| 349 |
+
export declare function applyEdits(text: string, edits: EditResult): string;
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/lib/umd/main.js
CHANGED
|
@@ -1,3 +1,194 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function (factory) {
|
| 2 |
+
if (typeof module === "object" && typeof module.exports === "object") {
|
| 3 |
+
var v = factory(require, exports);
|
| 4 |
+
if (v !== undefined) module.exports = v;
|
| 5 |
+
}
|
| 6 |
+
else if (typeof define === "function" && define.amd) {
|
| 7 |
+
define(["require", "exports", "./impl/format", "./impl/edit", "./impl/scanner", "./impl/parser"], factory);
|
| 8 |
+
}
|
| 9 |
+
})(function (require, exports) {
|
| 10 |
+
/*---------------------------------------------------------------------------------------------
|
| 11 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 12 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 13 |
+
*--------------------------------------------------------------------------------------------*/
|
| 14 |
+
'use strict';
|
| 15 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 16 |
+
exports.applyEdits = exports.modify = exports.format = exports.printParseErrorCode = exports.ParseErrorCode = exports.stripComments = exports.visit = exports.getNodeValue = exports.getNodePath = exports.findNodeAtOffset = exports.findNodeAtLocation = exports.parseTree = exports.parse = exports.getLocation = exports.SyntaxKind = exports.ScanError = exports.createScanner = void 0;
|
| 17 |
+
const formatter = require("./impl/format");
|
| 18 |
+
const edit = require("./impl/edit");
|
| 19 |
+
const scanner = require("./impl/scanner");
|
| 20 |
+
const parser = require("./impl/parser");
|
| 21 |
+
/**
|
| 22 |
+
* Creates a JSON scanner on the given text.
|
| 23 |
+
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
| 24 |
+
*/
|
| 25 |
+
exports.createScanner = scanner.createScanner;
|
| 26 |
+
var ScanError;
|
| 27 |
+
(function (ScanError) {
|
| 28 |
+
ScanError[ScanError["None"] = 0] = "None";
|
| 29 |
+
ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
| 30 |
+
ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
| 31 |
+
ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
| 32 |
+
ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
|
| 33 |
+
ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
| 34 |
+
ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
|
| 35 |
+
})(ScanError || (exports.ScanError = ScanError = {}));
|
| 36 |
+
var SyntaxKind;
|
| 37 |
+
(function (SyntaxKind) {
|
| 38 |
+
SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
|
| 39 |
+
SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
|
| 40 |
+
SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
|
| 41 |
+
SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
|
| 42 |
+
SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
|
| 43 |
+
SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
|
| 44 |
+
SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
|
| 45 |
+
SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
|
| 46 |
+
SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
|
| 47 |
+
SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
|
| 48 |
+
SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
|
| 49 |
+
SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
| 50 |
+
SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
| 51 |
+
SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
| 52 |
+
SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
|
| 53 |
+
SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
|
| 54 |
+
SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
|
| 55 |
+
})(SyntaxKind || (exports.SyntaxKind = SyntaxKind = {}));
|
| 56 |
+
/**
|
| 57 |
+
* For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
|
| 58 |
+
*/
|
| 59 |
+
exports.getLocation = parser.getLocation;
|
| 60 |
+
/**
|
| 61 |
+
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 62 |
+
* Therefore, always check the errors list to find out if the input was valid.
|
| 63 |
+
*/
|
| 64 |
+
exports.parse = parser.parse;
|
| 65 |
+
/**
|
| 66 |
+
* Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
| 67 |
+
*/
|
| 68 |
+
exports.parseTree = parser.parseTree;
|
| 69 |
+
/**
|
| 70 |
+
* Finds the node at the given path in a JSON DOM.
|
| 71 |
+
*/
|
| 72 |
+
exports.findNodeAtLocation = parser.findNodeAtLocation;
|
| 73 |
+
/**
|
| 74 |
+
* Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
|
| 75 |
+
*/
|
| 76 |
+
exports.findNodeAtOffset = parser.findNodeAtOffset;
|
| 77 |
+
/**
|
| 78 |
+
* Gets the JSON path of the given JSON DOM node
|
| 79 |
+
*/
|
| 80 |
+
exports.getNodePath = parser.getNodePath;
|
| 81 |
+
/**
|
| 82 |
+
* Evaluates the JavaScript object of the given JSON DOM node
|
| 83 |
+
*/
|
| 84 |
+
exports.getNodeValue = parser.getNodeValue;
|
| 85 |
+
/**
|
| 86 |
+
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
| 87 |
+
*/
|
| 88 |
+
exports.visit = parser.visit;
|
| 89 |
+
/**
|
| 90 |
+
* Takes JSON with JavaScript-style comments and remove
|
| 91 |
+
* them. Optionally replaces every none-newline character
|
| 92 |
+
* of comments with a replaceCharacter
|
| 93 |
+
*/
|
| 94 |
+
exports.stripComments = parser.stripComments;
|
| 95 |
+
var ParseErrorCode;
|
| 96 |
+
(function (ParseErrorCode) {
|
| 97 |
+
ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
|
| 98 |
+
ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
| 99 |
+
ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
| 100 |
+
ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
|
| 101 |
+
ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
|
| 102 |
+
ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
|
| 103 |
+
ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
| 104 |
+
ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
| 105 |
+
ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
| 106 |
+
ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
| 107 |
+
ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
| 108 |
+
ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
| 109 |
+
ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
| 110 |
+
ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
|
| 111 |
+
ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
| 112 |
+
ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
|
| 113 |
+
})(ParseErrorCode || (exports.ParseErrorCode = ParseErrorCode = {}));
|
| 114 |
+
function printParseErrorCode(code) {
|
| 115 |
+
switch (code) {
|
| 116 |
+
case 1 /* ParseErrorCode.InvalidSymbol */: return 'InvalidSymbol';
|
| 117 |
+
case 2 /* ParseErrorCode.InvalidNumberFormat */: return 'InvalidNumberFormat';
|
| 118 |
+
case 3 /* ParseErrorCode.PropertyNameExpected */: return 'PropertyNameExpected';
|
| 119 |
+
case 4 /* ParseErrorCode.ValueExpected */: return 'ValueExpected';
|
| 120 |
+
case 5 /* ParseErrorCode.ColonExpected */: return 'ColonExpected';
|
| 121 |
+
case 6 /* ParseErrorCode.CommaExpected */: return 'CommaExpected';
|
| 122 |
+
case 7 /* ParseErrorCode.CloseBraceExpected */: return 'CloseBraceExpected';
|
| 123 |
+
case 8 /* ParseErrorCode.CloseBracketExpected */: return 'CloseBracketExpected';
|
| 124 |
+
case 9 /* ParseErrorCode.EndOfFileExpected */: return 'EndOfFileExpected';
|
| 125 |
+
case 10 /* ParseErrorCode.InvalidCommentToken */: return 'InvalidCommentToken';
|
| 126 |
+
case 11 /* ParseErrorCode.UnexpectedEndOfComment */: return 'UnexpectedEndOfComment';
|
| 127 |
+
case 12 /* ParseErrorCode.UnexpectedEndOfString */: return 'UnexpectedEndOfString';
|
| 128 |
+
case 13 /* ParseErrorCode.UnexpectedEndOfNumber */: return 'UnexpectedEndOfNumber';
|
| 129 |
+
case 14 /* ParseErrorCode.InvalidUnicode */: return 'InvalidUnicode';
|
| 130 |
+
case 15 /* ParseErrorCode.InvalidEscapeCharacter */: return 'InvalidEscapeCharacter';
|
| 131 |
+
case 16 /* ParseErrorCode.InvalidCharacter */: return 'InvalidCharacter';
|
| 132 |
+
}
|
| 133 |
+
return '<unknown ParseErrorCode>';
|
| 134 |
+
}
|
| 135 |
+
exports.printParseErrorCode = printParseErrorCode;
|
| 136 |
+
/**
|
| 137 |
+
* Computes the edit operations needed to format a JSON document.
|
| 138 |
+
*
|
| 139 |
+
* @param documentText The input text
|
| 140 |
+
* @param range The range to format or `undefined` to format the full content
|
| 141 |
+
* @param options The formatting options
|
| 142 |
+
* @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.
|
| 143 |
+
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
| 144 |
+
*/
|
| 145 |
+
function format(documentText, range, options) {
|
| 146 |
+
return formatter.format(documentText, range, options);
|
| 147 |
+
}
|
| 148 |
+
exports.format = format;
|
| 149 |
+
/**
|
| 150 |
+
* Computes the edit operations needed to modify a value in the JSON document.
|
| 151 |
+
*
|
| 152 |
+
* @param documentText The input text
|
| 153 |
+
* @param path The path of the value to change. The path represents either to the document root, a property or an array item.
|
| 154 |
+
* If the path points to an non-existing property or item, it will be created.
|
| 155 |
+
* @param value The new value for the specified property or item. If the value is undefined,
|
| 156 |
+
* the property or item will be removed.
|
| 157 |
+
* @param options Options
|
| 158 |
+
* @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
|
| 159 |
+
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
| 160 |
+
*/
|
| 161 |
+
function modify(text, path, value, options) {
|
| 162 |
+
return edit.setProperty(text, path, value, options);
|
| 163 |
+
}
|
| 164 |
+
exports.modify = modify;
|
| 165 |
+
/**
|
| 166 |
+
* Applies edits to an input string.
|
| 167 |
+
* @param text The input text
|
| 168 |
+
* @param edits Edit operations following the format described in {@linkcode EditResult}.
|
| 169 |
+
* @returns The text with the applied edits.
|
| 170 |
+
* @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
|
| 171 |
+
*/
|
| 172 |
+
function applyEdits(text, edits) {
|
| 173 |
+
let sortedEdits = edits.slice(0).sort((a, b) => {
|
| 174 |
+
const diff = a.offset - b.offset;
|
| 175 |
+
if (diff === 0) {
|
| 176 |
+
return a.length - b.length;
|
| 177 |
+
}
|
| 178 |
+
return diff;
|
| 179 |
+
});
|
| 180 |
+
let lastModifiedOffset = text.length;
|
| 181 |
+
for (let i = sortedEdits.length - 1; i >= 0; i--) {
|
| 182 |
+
let e = sortedEdits[i];
|
| 183 |
+
if (e.offset + e.length <= lastModifiedOffset) {
|
| 184 |
+
text = edit.applyEdit(text, e);
|
| 185 |
+
}
|
| 186 |
+
else {
|
| 187 |
+
throw new Error('Overlapping edit');
|
| 188 |
+
}
|
| 189 |
+
lastModifiedOffset = e.offset;
|
| 190 |
+
}
|
| 191 |
+
return text;
|
| 192 |
+
}
|
| 193 |
+
exports.applyEdits = applyEdits;
|
| 194 |
+
});
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/jsonc-parser/package.json
CHANGED
|
@@ -1,3 +1,37 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "jsonc-parser",
|
| 3 |
+
"version": "3.2.1",
|
| 4 |
+
"description": "Scanner and parser for JSON with comments.",
|
| 5 |
+
"main": "./lib/umd/main.js",
|
| 6 |
+
"typings": "./lib/umd/main.d.ts",
|
| 7 |
+
"module": "./lib/esm/main.js",
|
| 8 |
+
"author": "Microsoft Corporation",
|
| 9 |
+
"repository": {
|
| 10 |
+
"type": "git",
|
| 11 |
+
"url": "https://github.com/microsoft/node-jsonc-parser"
|
| 12 |
+
},
|
| 13 |
+
"license": "MIT",
|
| 14 |
+
"bugs": {
|
| 15 |
+
"url": "https://github.com/microsoft/node-jsonc-parser/issues"
|
| 16 |
+
},
|
| 17 |
+
"devDependencies": {
|
| 18 |
+
"mocha": "^10.2.0",
|
| 19 |
+
"typescript": "^5.3.3",
|
| 20 |
+
"@types/node": "^16.x",
|
| 21 |
+
"@types/mocha": "^10.0.6",
|
| 22 |
+
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
| 23 |
+
"@typescript-eslint/parser": "^6.19.1",
|
| 24 |
+
"eslint": "^8.56.0",
|
| 25 |
+
"rimraf": "^5.0.5"
|
| 26 |
+
},
|
| 27 |
+
"scripts": {
|
| 28 |
+
"prepack": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs",
|
| 29 |
+
"compile": "tsc -p ./src && npm run lint",
|
| 30 |
+
"compile-esm": "tsc -p ./src/tsconfig.esm.json",
|
| 31 |
+
"remove-sourcemap-refs": "node ./build/remove-sourcemap-refs.js",
|
| 32 |
+
"clean": "rimraf lib",
|
| 33 |
+
"watch": "tsc -w -p ./src",
|
| 34 |
+
"test": "npm run compile && mocha ./lib/umd/test",
|
| 35 |
+
"lint": "eslint src/**/*.ts"
|
| 36 |
+
}
|
| 37 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/License.txt
CHANGED
|
@@ -1,3 +1,11 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) Microsoft Corporation
|
| 2 |
+
|
| 3 |
+
All rights reserved.
|
| 4 |
+
|
| 5 |
+
MIT License
|
| 6 |
+
|
| 7 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 8 |
+
|
| 9 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 10 |
+
|
| 11 |
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/README.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# VSCode JSON RPC
|
| 2 |
+
|
| 3 |
+
[](https://npmjs.org/package/vscode-jsonrpc)
|
| 4 |
+
[](https://npmjs.org/package/vscode-jsonrpc)
|
| 5 |
+
[](https://dev.azure.com/ms/vscode-languageserver-node/_build/latest?definitionId=439&branchName=main)
|
| 6 |
+
|
| 7 |
+
This npm module implements the base messaging protocol spoken between a VSCode language server and a VSCode language client.
|
| 8 |
+
|
| 9 |
+
The npm module can also be used standalone to establish a [JSON-RPC](http://www.jsonrpc.org/) channel between
|
| 10 |
+
a client and a server. Below an example how to setup a JSON-RPC connection. First the client side.
|
| 11 |
+
|
| 12 |
+
```ts
|
| 13 |
+
import * as cp from 'child_process';
|
| 14 |
+
import * as rpc from 'vscode-jsonrpc/node';
|
| 15 |
+
|
| 16 |
+
let childProcess = cp.spawn(...);
|
| 17 |
+
|
| 18 |
+
// Use stdin and stdout for communication:
|
| 19 |
+
let connection = rpc.createMessageConnection(
|
| 20 |
+
new rpc.StreamMessageReader(childProcess.stdout),
|
| 21 |
+
new rpc.StreamMessageWriter(childProcess.stdin));
|
| 22 |
+
|
| 23 |
+
let notification = new rpc.NotificationType<string, void>('testNotification');
|
| 24 |
+
|
| 25 |
+
connection.listen();
|
| 26 |
+
|
| 27 |
+
connection.sendNotification(notification, 'Hello World');
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
The server side looks very symmetrical:
|
| 31 |
+
|
| 32 |
+
```ts
|
| 33 |
+
import * as rpc from 'vscode-jsonrpc/node';
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
let connection = rpc.createMessageConnection(
|
| 37 |
+
new rpc.StreamMessageReader(process.stdin),
|
| 38 |
+
new rpc.StreamMessageWriter(process.stdout));
|
| 39 |
+
|
| 40 |
+
let notification = new rpc.NotificationType<string, void>('testNotification');
|
| 41 |
+
connection.onNotification(notification, (param: string) => {
|
| 42 |
+
console.log(param); // This prints Hello World
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
connection.listen();
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
# History
|
| 49 |
+
|
| 50 |
+
### 5.0.0
|
| 51 |
+
|
| 52 |
+
- add progress support
|
| 53 |
+
- move JS target to ES2017
|
| 54 |
+
|
| 55 |
+
### 4.0.0
|
| 56 |
+
|
| 57 |
+
- move JS target to ES6.
|
| 58 |
+
|
| 59 |
+
### 3.0.0:
|
| 60 |
+
|
| 61 |
+
- converted the NPM module to use TypeScript 2.0.3.
|
| 62 |
+
- added strict null support.
|
| 63 |
+
- support for passing more than one parameter to a request or notification.
|
| 64 |
+
- Breaking changes:
|
| 65 |
+
- due to the use of TypeScript 2.0.3 and differences in d.ts generation users of the new version need to move to
|
| 66 |
+
TypeScript 2.0.3 as well.
|
| 67 |
+
|
| 68 |
+
## License
|
| 69 |
+
[MIT](https://github.com/Microsoft/vscode-languageserver-node/blob/master/License.txt)
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/browser.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* --------------------------------------------------------------------------------------------
|
| 2 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 3 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 4 |
+
* ----------------------------------------------------------------------------------------- */
|
| 5 |
+
|
| 6 |
+
export * from './lib/browser/main';
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/browser.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* --------------------------------------------------------------------------------------------
|
| 2 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 3 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 4 |
+
* ----------------------------------------------------------------------------------------- */
|
| 5 |
+
'use strict';
|
| 6 |
+
|
| 7 |
+
module.exports = require('./lib/browser/main');
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/browser/main.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { AbstractMessageReader, DataCallback, AbstractMessageWriter, Message, Disposable, ConnectionStrategy, ConnectionOptions, MessageReader, MessageWriter, Logger, MessageConnection } from '../common/api';
|
| 2 |
+
export * from '../common/api';
|
| 3 |
+
export declare class BrowserMessageReader extends AbstractMessageReader implements MessageReader {
|
| 4 |
+
private _onData;
|
| 5 |
+
private _messageListener;
|
| 6 |
+
constructor(port: MessagePort | Worker | DedicatedWorkerGlobalScope);
|
| 7 |
+
listen(callback: DataCallback): Disposable;
|
| 8 |
+
}
|
| 9 |
+
export declare class BrowserMessageWriter extends AbstractMessageWriter implements MessageWriter {
|
| 10 |
+
private port;
|
| 11 |
+
private errorCount;
|
| 12 |
+
constructor(port: MessagePort | Worker | DedicatedWorkerGlobalScope);
|
| 13 |
+
write(msg: Message): Promise<void>;
|
| 14 |
+
private handleError;
|
| 15 |
+
end(): void;
|
| 16 |
+
}
|
| 17 |
+
export declare function createMessageConnection(reader: MessageReader, writer: MessageWriter, logger?: Logger, options?: ConnectionStrategy | ConnectionOptions): MessageConnection;
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/browser/main.js
CHANGED
|
@@ -1,3 +1,76 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/* --------------------------------------------------------------------------------------------
|
| 3 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 4 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 5 |
+
* ------------------------------------------------------------------------------------------ */
|
| 6 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 7 |
+
if (k2 === undefined) k2 = k;
|
| 8 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 9 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 10 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 11 |
+
}
|
| 12 |
+
Object.defineProperty(o, k2, desc);
|
| 13 |
+
}) : (function(o, m, k, k2) {
|
| 14 |
+
if (k2 === undefined) k2 = k;
|
| 15 |
+
o[k2] = m[k];
|
| 16 |
+
}));
|
| 17 |
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
| 18 |
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
| 19 |
+
};
|
| 20 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 21 |
+
exports.createMessageConnection = exports.BrowserMessageWriter = exports.BrowserMessageReader = void 0;
|
| 22 |
+
const ril_1 = require("./ril");
|
| 23 |
+
// Install the browser runtime abstract.
|
| 24 |
+
ril_1.default.install();
|
| 25 |
+
const api_1 = require("../common/api");
|
| 26 |
+
__exportStar(require("../common/api"), exports);
|
| 27 |
+
class BrowserMessageReader extends api_1.AbstractMessageReader {
|
| 28 |
+
constructor(port) {
|
| 29 |
+
super();
|
| 30 |
+
this._onData = new api_1.Emitter();
|
| 31 |
+
this._messageListener = (event) => {
|
| 32 |
+
this._onData.fire(event.data);
|
| 33 |
+
};
|
| 34 |
+
port.addEventListener('error', (event) => this.fireError(event));
|
| 35 |
+
port.onmessage = this._messageListener;
|
| 36 |
+
}
|
| 37 |
+
listen(callback) {
|
| 38 |
+
return this._onData.event(callback);
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
exports.BrowserMessageReader = BrowserMessageReader;
|
| 42 |
+
class BrowserMessageWriter extends api_1.AbstractMessageWriter {
|
| 43 |
+
constructor(port) {
|
| 44 |
+
super();
|
| 45 |
+
this.port = port;
|
| 46 |
+
this.errorCount = 0;
|
| 47 |
+
port.addEventListener('error', (event) => this.fireError(event));
|
| 48 |
+
}
|
| 49 |
+
write(msg) {
|
| 50 |
+
try {
|
| 51 |
+
this.port.postMessage(msg);
|
| 52 |
+
return Promise.resolve();
|
| 53 |
+
}
|
| 54 |
+
catch (error) {
|
| 55 |
+
this.handleError(error, msg);
|
| 56 |
+
return Promise.reject(error);
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
handleError(error, msg) {
|
| 60 |
+
this.errorCount++;
|
| 61 |
+
this.fireError(error, msg, this.errorCount);
|
| 62 |
+
}
|
| 63 |
+
end() {
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
exports.BrowserMessageWriter = BrowserMessageWriter;
|
| 67 |
+
function createMessageConnection(reader, writer, logger, options) {
|
| 68 |
+
if (logger === undefined) {
|
| 69 |
+
logger = api_1.NullLogger;
|
| 70 |
+
}
|
| 71 |
+
if (api_1.ConnectionStrategy.is(options)) {
|
| 72 |
+
options = { connectionStrategy: options };
|
| 73 |
+
}
|
| 74 |
+
return (0, api_1.createMessageConnection)(reader, writer, logger, options);
|
| 75 |
+
}
|
| 76 |
+
exports.createMessageConnection = createMessageConnection;
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/browser/ril.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { RAL } from '../common/api';
|
| 2 |
+
interface RIL extends RAL {
|
| 3 |
+
readonly stream: {
|
| 4 |
+
readonly asReadableStream: (stream: WebSocket) => RAL.ReadableStream;
|
| 5 |
+
readonly asWritableStream: (stream: WebSocket) => RAL.WritableStream;
|
| 6 |
+
};
|
| 7 |
+
}
|
| 8 |
+
declare function RIL(): RIL;
|
| 9 |
+
declare namespace RIL {
|
| 10 |
+
function install(): void;
|
| 11 |
+
}
|
| 12 |
+
export default RIL;
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/browser/ril.js
CHANGED
|
@@ -1,3 +1,156 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/* --------------------------------------------------------------------------------------------
|
| 3 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 4 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 5 |
+
* ------------------------------------------------------------------------------------------ */
|
| 6 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 7 |
+
const api_1 = require("../common/api");
|
| 8 |
+
class MessageBuffer extends api_1.AbstractMessageBuffer {
|
| 9 |
+
constructor(encoding = 'utf-8') {
|
| 10 |
+
super(encoding);
|
| 11 |
+
this.asciiDecoder = new TextDecoder('ascii');
|
| 12 |
+
}
|
| 13 |
+
emptyBuffer() {
|
| 14 |
+
return MessageBuffer.emptyBuffer;
|
| 15 |
+
}
|
| 16 |
+
fromString(value, _encoding) {
|
| 17 |
+
return (new TextEncoder()).encode(value);
|
| 18 |
+
}
|
| 19 |
+
toString(value, encoding) {
|
| 20 |
+
if (encoding === 'ascii') {
|
| 21 |
+
return this.asciiDecoder.decode(value);
|
| 22 |
+
}
|
| 23 |
+
else {
|
| 24 |
+
return (new TextDecoder(encoding)).decode(value);
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
asNative(buffer, length) {
|
| 28 |
+
if (length === undefined) {
|
| 29 |
+
return buffer;
|
| 30 |
+
}
|
| 31 |
+
else {
|
| 32 |
+
return buffer.slice(0, length);
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
allocNative(length) {
|
| 36 |
+
return new Uint8Array(length);
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
MessageBuffer.emptyBuffer = new Uint8Array(0);
|
| 40 |
+
class ReadableStreamWrapper {
|
| 41 |
+
constructor(socket) {
|
| 42 |
+
this.socket = socket;
|
| 43 |
+
this._onData = new api_1.Emitter();
|
| 44 |
+
this._messageListener = (event) => {
|
| 45 |
+
const blob = event.data;
|
| 46 |
+
blob.arrayBuffer().then((buffer) => {
|
| 47 |
+
this._onData.fire(new Uint8Array(buffer));
|
| 48 |
+
}, () => {
|
| 49 |
+
(0, api_1.RAL)().console.error(`Converting blob to array buffer failed.`);
|
| 50 |
+
});
|
| 51 |
+
};
|
| 52 |
+
this.socket.addEventListener('message', this._messageListener);
|
| 53 |
+
}
|
| 54 |
+
onClose(listener) {
|
| 55 |
+
this.socket.addEventListener('close', listener);
|
| 56 |
+
return api_1.Disposable.create(() => this.socket.removeEventListener('close', listener));
|
| 57 |
+
}
|
| 58 |
+
onError(listener) {
|
| 59 |
+
this.socket.addEventListener('error', listener);
|
| 60 |
+
return api_1.Disposable.create(() => this.socket.removeEventListener('error', listener));
|
| 61 |
+
}
|
| 62 |
+
onEnd(listener) {
|
| 63 |
+
this.socket.addEventListener('end', listener);
|
| 64 |
+
return api_1.Disposable.create(() => this.socket.removeEventListener('end', listener));
|
| 65 |
+
}
|
| 66 |
+
onData(listener) {
|
| 67 |
+
return this._onData.event(listener);
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
class WritableStreamWrapper {
|
| 71 |
+
constructor(socket) {
|
| 72 |
+
this.socket = socket;
|
| 73 |
+
}
|
| 74 |
+
onClose(listener) {
|
| 75 |
+
this.socket.addEventListener('close', listener);
|
| 76 |
+
return api_1.Disposable.create(() => this.socket.removeEventListener('close', listener));
|
| 77 |
+
}
|
| 78 |
+
onError(listener) {
|
| 79 |
+
this.socket.addEventListener('error', listener);
|
| 80 |
+
return api_1.Disposable.create(() => this.socket.removeEventListener('error', listener));
|
| 81 |
+
}
|
| 82 |
+
onEnd(listener) {
|
| 83 |
+
this.socket.addEventListener('end', listener);
|
| 84 |
+
return api_1.Disposable.create(() => this.socket.removeEventListener('end', listener));
|
| 85 |
+
}
|
| 86 |
+
write(data, encoding) {
|
| 87 |
+
if (typeof data === 'string') {
|
| 88 |
+
if (encoding !== undefined && encoding !== 'utf-8') {
|
| 89 |
+
throw new Error(`In a Browser environments only utf-8 text encoding is supported. But got encoding: ${encoding}`);
|
| 90 |
+
}
|
| 91 |
+
this.socket.send(data);
|
| 92 |
+
}
|
| 93 |
+
else {
|
| 94 |
+
this.socket.send(data);
|
| 95 |
+
}
|
| 96 |
+
return Promise.resolve();
|
| 97 |
+
}
|
| 98 |
+
end() {
|
| 99 |
+
this.socket.close();
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
const _textEncoder = new TextEncoder();
|
| 103 |
+
const _ril = Object.freeze({
|
| 104 |
+
messageBuffer: Object.freeze({
|
| 105 |
+
create: (encoding) => new MessageBuffer(encoding)
|
| 106 |
+
}),
|
| 107 |
+
applicationJson: Object.freeze({
|
| 108 |
+
encoder: Object.freeze({
|
| 109 |
+
name: 'application/json',
|
| 110 |
+
encode: (msg, options) => {
|
| 111 |
+
if (options.charset !== 'utf-8') {
|
| 112 |
+
throw new Error(`In a Browser environments only utf-8 text encoding is supported. But got encoding: ${options.charset}`);
|
| 113 |
+
}
|
| 114 |
+
return Promise.resolve(_textEncoder.encode(JSON.stringify(msg, undefined, 0)));
|
| 115 |
+
}
|
| 116 |
+
}),
|
| 117 |
+
decoder: Object.freeze({
|
| 118 |
+
name: 'application/json',
|
| 119 |
+
decode: (buffer, options) => {
|
| 120 |
+
if (!(buffer instanceof Uint8Array)) {
|
| 121 |
+
throw new Error(`In a Browser environments only Uint8Arrays are supported.`);
|
| 122 |
+
}
|
| 123 |
+
return Promise.resolve(JSON.parse(new TextDecoder(options.charset).decode(buffer)));
|
| 124 |
+
}
|
| 125 |
+
})
|
| 126 |
+
}),
|
| 127 |
+
stream: Object.freeze({
|
| 128 |
+
asReadableStream: (socket) => new ReadableStreamWrapper(socket),
|
| 129 |
+
asWritableStream: (socket) => new WritableStreamWrapper(socket)
|
| 130 |
+
}),
|
| 131 |
+
console: console,
|
| 132 |
+
timer: Object.freeze({
|
| 133 |
+
setTimeout(callback, ms, ...args) {
|
| 134 |
+
const handle = setTimeout(callback, ms, ...args);
|
| 135 |
+
return { dispose: () => clearTimeout(handle) };
|
| 136 |
+
},
|
| 137 |
+
setImmediate(callback, ...args) {
|
| 138 |
+
const handle = setTimeout(callback, 0, ...args);
|
| 139 |
+
return { dispose: () => clearTimeout(handle) };
|
| 140 |
+
},
|
| 141 |
+
setInterval(callback, ms, ...args) {
|
| 142 |
+
const handle = setInterval(callback, ms, ...args);
|
| 143 |
+
return { dispose: () => clearInterval(handle) };
|
| 144 |
+
},
|
| 145 |
+
})
|
| 146 |
+
});
|
| 147 |
+
function RIL() {
|
| 148 |
+
return _ril;
|
| 149 |
+
}
|
| 150 |
+
(function (RIL) {
|
| 151 |
+
function install() {
|
| 152 |
+
api_1.RAL.install(_ril);
|
| 153 |
+
}
|
| 154 |
+
RIL.install = install;
|
| 155 |
+
})(RIL || (RIL = {}));
|
| 156 |
+
exports.default = RIL;
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/api.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/// <reference path="../../typings/thenable.d.ts" />
|
| 2 |
+
import { Message, MessageSignature, RequestMessage, RequestType, RequestType0, RequestType1, RequestType2, RequestType3, RequestType4, RequestType5, RequestType6, RequestType7, RequestType8, RequestType9, ResponseError, ErrorCodes, NotificationMessage, NotificationType, NotificationType0, NotificationType1, NotificationType2, NotificationType3, NotificationType4, NotificationType5, NotificationType6, NotificationType7, NotificationType8, NotificationType9, ResponseMessage, ParameterStructures, _EM } from './messages';
|
| 3 |
+
import { LinkedMap, LRUCache, Touch } from './linkedMap';
|
| 4 |
+
import { Disposable } from './disposable';
|
| 5 |
+
import { Event, Emitter } from './events';
|
| 6 |
+
import { AbstractCancellationTokenSource, CancellationTokenSource, CancellationToken } from './cancellation';
|
| 7 |
+
import { SharedArraySenderStrategy, SharedArrayReceiverStrategy } from './sharedArrayCancellation';
|
| 8 |
+
import { MessageReader, AbstractMessageReader, ReadableStreamMessageReader, DataCallback, MessageReaderOptions, PartialMessageInfo } from './messageReader';
|
| 9 |
+
import { MessageWriter, AbstractMessageWriter, WriteableStreamMessageWriter, MessageWriterOptions } from './messageWriter';
|
| 10 |
+
import { AbstractMessageBuffer } from './messageBuffer';
|
| 11 |
+
import { ContentTypeEncoderOptions, ContentEncoder, ContentTypeEncoder, ContentTypeDecoderOptions, ContentDecoder, ContentTypeDecoder } from './encoding';
|
| 12 |
+
import { Logger, ConnectionStrategy, ConnectionOptions, MessageConnection, NullLogger, createMessageConnection, ProgressToken, ProgressType, HandlerResult, StarRequestHandler, GenericRequestHandler, RequestHandler0, RequestHandler, RequestHandler1, RequestHandler2, RequestHandler3, RequestHandler4, RequestHandler5, RequestHandler6, RequestHandler7, RequestHandler8, RequestHandler9, StarNotificationHandler, GenericNotificationHandler, NotificationHandler0, NotificationHandler, NotificationHandler1, NotificationHandler2, NotificationHandler3, NotificationHandler4, NotificationHandler5, NotificationHandler6, NotificationHandler7, NotificationHandler8, NotificationHandler9, Trace, TraceValue, TraceFormat, TraceOptions, SetTraceParams, SetTraceNotification, LogTraceParams, LogTraceNotification, Tracer, ConnectionErrors, ConnectionError, CancellationId, CancellationReceiverStrategy, CancellationSenderStrategy, CancellationStrategy, MessageStrategy, TraceValues } from './connection';
|
| 13 |
+
import RAL from './ral';
|
| 14 |
+
export { RAL, Message, MessageSignature, RequestMessage, RequestType, RequestType0, RequestType1, RequestType2, RequestType3, RequestType4, RequestType5, RequestType6, RequestType7, RequestType8, RequestType9, ResponseError, ErrorCodes, NotificationMessage, NotificationType, NotificationType0, NotificationType1, NotificationType2, NotificationType3, NotificationType4, NotificationType5, NotificationType6, NotificationType7, NotificationType8, NotificationType9, ResponseMessage, ParameterStructures, _EM, LinkedMap, Touch, LRUCache, Disposable, Event, Emitter, AbstractCancellationTokenSource, CancellationTokenSource, CancellationToken, SharedArraySenderStrategy, SharedArrayReceiverStrategy, MessageReader, AbstractMessageReader, ReadableStreamMessageReader, DataCallback, MessageReaderOptions, PartialMessageInfo, MessageWriter, AbstractMessageWriter, WriteableStreamMessageWriter, MessageWriterOptions, AbstractMessageBuffer, ContentTypeEncoderOptions, ContentEncoder, ContentTypeEncoder, ContentTypeDecoderOptions, ContentDecoder, ContentTypeDecoder, Logger, ConnectionStrategy, ConnectionOptions, MessageConnection, NullLogger, createMessageConnection, ProgressToken, ProgressType, HandlerResult, StarRequestHandler, GenericRequestHandler, RequestHandler0, RequestHandler, RequestHandler1, RequestHandler2, RequestHandler3, RequestHandler4, RequestHandler5, RequestHandler6, RequestHandler7, RequestHandler8, RequestHandler9, StarNotificationHandler, GenericNotificationHandler, NotificationHandler0, NotificationHandler, NotificationHandler1, NotificationHandler2, NotificationHandler3, NotificationHandler4, NotificationHandler5, NotificationHandler6, NotificationHandler7, NotificationHandler8, NotificationHandler9, Trace, TraceValue, TraceValues, TraceFormat, TraceOptions, SetTraceParams, SetTraceNotification, LogTraceParams, LogTraceNotification, Tracer, ConnectionErrors, ConnectionError, CancellationId, CancellationReceiverStrategy, CancellationSenderStrategy, CancellationStrategy, MessageStrategy };
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/api.js
CHANGED
|
@@ -1,3 +1,82 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/* --------------------------------------------------------------------------------------------
|
| 3 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 4 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 5 |
+
* ------------------------------------------------------------------------------------------ */
|
| 6 |
+
/// <reference path="../../typings/thenable.d.ts" />
|
| 7 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 8 |
+
exports.ProgressType = exports.ProgressToken = exports.createMessageConnection = exports.NullLogger = exports.ConnectionOptions = exports.ConnectionStrategy = exports.AbstractMessageBuffer = exports.WriteableStreamMessageWriter = exports.AbstractMessageWriter = exports.MessageWriter = exports.ReadableStreamMessageReader = exports.AbstractMessageReader = exports.MessageReader = exports.SharedArrayReceiverStrategy = exports.SharedArraySenderStrategy = exports.CancellationToken = exports.CancellationTokenSource = exports.Emitter = exports.Event = exports.Disposable = exports.LRUCache = exports.Touch = exports.LinkedMap = exports.ParameterStructures = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.ErrorCodes = exports.ResponseError = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType0 = exports.RequestType = exports.Message = exports.RAL = void 0;
|
| 9 |
+
exports.MessageStrategy = exports.CancellationStrategy = exports.CancellationSenderStrategy = exports.CancellationReceiverStrategy = exports.ConnectionError = exports.ConnectionErrors = exports.LogTraceNotification = exports.SetTraceNotification = exports.TraceFormat = exports.TraceValues = exports.TraceValue = exports.Trace = void 0;
|
| 10 |
+
const messages_1 = require("./messages");
|
| 11 |
+
Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return messages_1.Message; } });
|
| 12 |
+
Object.defineProperty(exports, "RequestType", { enumerable: true, get: function () { return messages_1.RequestType; } });
|
| 13 |
+
Object.defineProperty(exports, "RequestType0", { enumerable: true, get: function () { return messages_1.RequestType0; } });
|
| 14 |
+
Object.defineProperty(exports, "RequestType1", { enumerable: true, get: function () { return messages_1.RequestType1; } });
|
| 15 |
+
Object.defineProperty(exports, "RequestType2", { enumerable: true, get: function () { return messages_1.RequestType2; } });
|
| 16 |
+
Object.defineProperty(exports, "RequestType3", { enumerable: true, get: function () { return messages_1.RequestType3; } });
|
| 17 |
+
Object.defineProperty(exports, "RequestType4", { enumerable: true, get: function () { return messages_1.RequestType4; } });
|
| 18 |
+
Object.defineProperty(exports, "RequestType5", { enumerable: true, get: function () { return messages_1.RequestType5; } });
|
| 19 |
+
Object.defineProperty(exports, "RequestType6", { enumerable: true, get: function () { return messages_1.RequestType6; } });
|
| 20 |
+
Object.defineProperty(exports, "RequestType7", { enumerable: true, get: function () { return messages_1.RequestType7; } });
|
| 21 |
+
Object.defineProperty(exports, "RequestType8", { enumerable: true, get: function () { return messages_1.RequestType8; } });
|
| 22 |
+
Object.defineProperty(exports, "RequestType9", { enumerable: true, get: function () { return messages_1.RequestType9; } });
|
| 23 |
+
Object.defineProperty(exports, "ResponseError", { enumerable: true, get: function () { return messages_1.ResponseError; } });
|
| 24 |
+
Object.defineProperty(exports, "ErrorCodes", { enumerable: true, get: function () { return messages_1.ErrorCodes; } });
|
| 25 |
+
Object.defineProperty(exports, "NotificationType", { enumerable: true, get: function () { return messages_1.NotificationType; } });
|
| 26 |
+
Object.defineProperty(exports, "NotificationType0", { enumerable: true, get: function () { return messages_1.NotificationType0; } });
|
| 27 |
+
Object.defineProperty(exports, "NotificationType1", { enumerable: true, get: function () { return messages_1.NotificationType1; } });
|
| 28 |
+
Object.defineProperty(exports, "NotificationType2", { enumerable: true, get: function () { return messages_1.NotificationType2; } });
|
| 29 |
+
Object.defineProperty(exports, "NotificationType3", { enumerable: true, get: function () { return messages_1.NotificationType3; } });
|
| 30 |
+
Object.defineProperty(exports, "NotificationType4", { enumerable: true, get: function () { return messages_1.NotificationType4; } });
|
| 31 |
+
Object.defineProperty(exports, "NotificationType5", { enumerable: true, get: function () { return messages_1.NotificationType5; } });
|
| 32 |
+
Object.defineProperty(exports, "NotificationType6", { enumerable: true, get: function () { return messages_1.NotificationType6; } });
|
| 33 |
+
Object.defineProperty(exports, "NotificationType7", { enumerable: true, get: function () { return messages_1.NotificationType7; } });
|
| 34 |
+
Object.defineProperty(exports, "NotificationType8", { enumerable: true, get: function () { return messages_1.NotificationType8; } });
|
| 35 |
+
Object.defineProperty(exports, "NotificationType9", { enumerable: true, get: function () { return messages_1.NotificationType9; } });
|
| 36 |
+
Object.defineProperty(exports, "ParameterStructures", { enumerable: true, get: function () { return messages_1.ParameterStructures; } });
|
| 37 |
+
const linkedMap_1 = require("./linkedMap");
|
| 38 |
+
Object.defineProperty(exports, "LinkedMap", { enumerable: true, get: function () { return linkedMap_1.LinkedMap; } });
|
| 39 |
+
Object.defineProperty(exports, "LRUCache", { enumerable: true, get: function () { return linkedMap_1.LRUCache; } });
|
| 40 |
+
Object.defineProperty(exports, "Touch", { enumerable: true, get: function () { return linkedMap_1.Touch; } });
|
| 41 |
+
const disposable_1 = require("./disposable");
|
| 42 |
+
Object.defineProperty(exports, "Disposable", { enumerable: true, get: function () { return disposable_1.Disposable; } });
|
| 43 |
+
const events_1 = require("./events");
|
| 44 |
+
Object.defineProperty(exports, "Event", { enumerable: true, get: function () { return events_1.Event; } });
|
| 45 |
+
Object.defineProperty(exports, "Emitter", { enumerable: true, get: function () { return events_1.Emitter; } });
|
| 46 |
+
const cancellation_1 = require("./cancellation");
|
| 47 |
+
Object.defineProperty(exports, "CancellationTokenSource", { enumerable: true, get: function () { return cancellation_1.CancellationTokenSource; } });
|
| 48 |
+
Object.defineProperty(exports, "CancellationToken", { enumerable: true, get: function () { return cancellation_1.CancellationToken; } });
|
| 49 |
+
const sharedArrayCancellation_1 = require("./sharedArrayCancellation");
|
| 50 |
+
Object.defineProperty(exports, "SharedArraySenderStrategy", { enumerable: true, get: function () { return sharedArrayCancellation_1.SharedArraySenderStrategy; } });
|
| 51 |
+
Object.defineProperty(exports, "SharedArrayReceiverStrategy", { enumerable: true, get: function () { return sharedArrayCancellation_1.SharedArrayReceiverStrategy; } });
|
| 52 |
+
const messageReader_1 = require("./messageReader");
|
| 53 |
+
Object.defineProperty(exports, "MessageReader", { enumerable: true, get: function () { return messageReader_1.MessageReader; } });
|
| 54 |
+
Object.defineProperty(exports, "AbstractMessageReader", { enumerable: true, get: function () { return messageReader_1.AbstractMessageReader; } });
|
| 55 |
+
Object.defineProperty(exports, "ReadableStreamMessageReader", { enumerable: true, get: function () { return messageReader_1.ReadableStreamMessageReader; } });
|
| 56 |
+
const messageWriter_1 = require("./messageWriter");
|
| 57 |
+
Object.defineProperty(exports, "MessageWriter", { enumerable: true, get: function () { return messageWriter_1.MessageWriter; } });
|
| 58 |
+
Object.defineProperty(exports, "AbstractMessageWriter", { enumerable: true, get: function () { return messageWriter_1.AbstractMessageWriter; } });
|
| 59 |
+
Object.defineProperty(exports, "WriteableStreamMessageWriter", { enumerable: true, get: function () { return messageWriter_1.WriteableStreamMessageWriter; } });
|
| 60 |
+
const messageBuffer_1 = require("./messageBuffer");
|
| 61 |
+
Object.defineProperty(exports, "AbstractMessageBuffer", { enumerable: true, get: function () { return messageBuffer_1.AbstractMessageBuffer; } });
|
| 62 |
+
const connection_1 = require("./connection");
|
| 63 |
+
Object.defineProperty(exports, "ConnectionStrategy", { enumerable: true, get: function () { return connection_1.ConnectionStrategy; } });
|
| 64 |
+
Object.defineProperty(exports, "ConnectionOptions", { enumerable: true, get: function () { return connection_1.ConnectionOptions; } });
|
| 65 |
+
Object.defineProperty(exports, "NullLogger", { enumerable: true, get: function () { return connection_1.NullLogger; } });
|
| 66 |
+
Object.defineProperty(exports, "createMessageConnection", { enumerable: true, get: function () { return connection_1.createMessageConnection; } });
|
| 67 |
+
Object.defineProperty(exports, "ProgressToken", { enumerable: true, get: function () { return connection_1.ProgressToken; } });
|
| 68 |
+
Object.defineProperty(exports, "ProgressType", { enumerable: true, get: function () { return connection_1.ProgressType; } });
|
| 69 |
+
Object.defineProperty(exports, "Trace", { enumerable: true, get: function () { return connection_1.Trace; } });
|
| 70 |
+
Object.defineProperty(exports, "TraceValue", { enumerable: true, get: function () { return connection_1.TraceValue; } });
|
| 71 |
+
Object.defineProperty(exports, "TraceFormat", { enumerable: true, get: function () { return connection_1.TraceFormat; } });
|
| 72 |
+
Object.defineProperty(exports, "SetTraceNotification", { enumerable: true, get: function () { return connection_1.SetTraceNotification; } });
|
| 73 |
+
Object.defineProperty(exports, "LogTraceNotification", { enumerable: true, get: function () { return connection_1.LogTraceNotification; } });
|
| 74 |
+
Object.defineProperty(exports, "ConnectionErrors", { enumerable: true, get: function () { return connection_1.ConnectionErrors; } });
|
| 75 |
+
Object.defineProperty(exports, "ConnectionError", { enumerable: true, get: function () { return connection_1.ConnectionError; } });
|
| 76 |
+
Object.defineProperty(exports, "CancellationReceiverStrategy", { enumerable: true, get: function () { return connection_1.CancellationReceiverStrategy; } });
|
| 77 |
+
Object.defineProperty(exports, "CancellationSenderStrategy", { enumerable: true, get: function () { return connection_1.CancellationSenderStrategy; } });
|
| 78 |
+
Object.defineProperty(exports, "CancellationStrategy", { enumerable: true, get: function () { return connection_1.CancellationStrategy; } });
|
| 79 |
+
Object.defineProperty(exports, "MessageStrategy", { enumerable: true, get: function () { return connection_1.MessageStrategy; } });
|
| 80 |
+
Object.defineProperty(exports, "TraceValues", { enumerable: true, get: function () { return connection_1.TraceValues; } });
|
| 81 |
+
const ral_1 = require("./ral");
|
| 82 |
+
exports.RAL = ral_1.default;
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/cancellation.d.ts
CHANGED
|
@@ -1,3 +1,32 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Event } from './events';
|
| 2 |
+
import { Disposable } from './disposable';
|
| 3 |
+
/**
|
| 4 |
+
* Defines a CancellationToken. This interface is not
|
| 5 |
+
* intended to be implemented. A CancellationToken must
|
| 6 |
+
* be created via a CancellationTokenSource.
|
| 7 |
+
*/
|
| 8 |
+
export interface CancellationToken {
|
| 9 |
+
/**
|
| 10 |
+
* Is `true` when the token has been cancelled, `false` otherwise.
|
| 11 |
+
*/
|
| 12 |
+
readonly isCancellationRequested: boolean;
|
| 13 |
+
/**
|
| 14 |
+
* An {@link Event event} which fires upon cancellation.
|
| 15 |
+
*/
|
| 16 |
+
readonly onCancellationRequested: Event<any>;
|
| 17 |
+
}
|
| 18 |
+
export declare namespace CancellationToken {
|
| 19 |
+
const None: CancellationToken;
|
| 20 |
+
const Cancelled: CancellationToken;
|
| 21 |
+
function is(value: any): value is CancellationToken;
|
| 22 |
+
}
|
| 23 |
+
export interface AbstractCancellationTokenSource extends Disposable {
|
| 24 |
+
token: CancellationToken;
|
| 25 |
+
cancel(): void;
|
| 26 |
+
}
|
| 27 |
+
export declare class CancellationTokenSource implements AbstractCancellationTokenSource {
|
| 28 |
+
private _token;
|
| 29 |
+
get token(): CancellationToken;
|
| 30 |
+
cancel(): void;
|
| 31 |
+
dispose(): void;
|
| 32 |
+
}
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/cancellation.js
CHANGED
|
@@ -1,3 +1,96 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/*---------------------------------------------------------------------------------------------
|
| 3 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 4 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 5 |
+
*--------------------------------------------------------------------------------------------*/
|
| 6 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 7 |
+
exports.CancellationTokenSource = exports.CancellationToken = void 0;
|
| 8 |
+
const ral_1 = require("./ral");
|
| 9 |
+
const Is = require("./is");
|
| 10 |
+
const events_1 = require("./events");
|
| 11 |
+
var CancellationToken;
|
| 12 |
+
(function (CancellationToken) {
|
| 13 |
+
CancellationToken.None = Object.freeze({
|
| 14 |
+
isCancellationRequested: false,
|
| 15 |
+
onCancellationRequested: events_1.Event.None
|
| 16 |
+
});
|
| 17 |
+
CancellationToken.Cancelled = Object.freeze({
|
| 18 |
+
isCancellationRequested: true,
|
| 19 |
+
onCancellationRequested: events_1.Event.None
|
| 20 |
+
});
|
| 21 |
+
function is(value) {
|
| 22 |
+
const candidate = value;
|
| 23 |
+
return candidate && (candidate === CancellationToken.None
|
| 24 |
+
|| candidate === CancellationToken.Cancelled
|
| 25 |
+
|| (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
|
| 26 |
+
}
|
| 27 |
+
CancellationToken.is = is;
|
| 28 |
+
})(CancellationToken || (exports.CancellationToken = CancellationToken = {}));
|
| 29 |
+
const shortcutEvent = Object.freeze(function (callback, context) {
|
| 30 |
+
const handle = (0, ral_1.default)().timer.setTimeout(callback.bind(context), 0);
|
| 31 |
+
return { dispose() { handle.dispose(); } };
|
| 32 |
+
});
|
| 33 |
+
class MutableToken {
|
| 34 |
+
constructor() {
|
| 35 |
+
this._isCancelled = false;
|
| 36 |
+
}
|
| 37 |
+
cancel() {
|
| 38 |
+
if (!this._isCancelled) {
|
| 39 |
+
this._isCancelled = true;
|
| 40 |
+
if (this._emitter) {
|
| 41 |
+
this._emitter.fire(undefined);
|
| 42 |
+
this.dispose();
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
get isCancellationRequested() {
|
| 47 |
+
return this._isCancelled;
|
| 48 |
+
}
|
| 49 |
+
get onCancellationRequested() {
|
| 50 |
+
if (this._isCancelled) {
|
| 51 |
+
return shortcutEvent;
|
| 52 |
+
}
|
| 53 |
+
if (!this._emitter) {
|
| 54 |
+
this._emitter = new events_1.Emitter();
|
| 55 |
+
}
|
| 56 |
+
return this._emitter.event;
|
| 57 |
+
}
|
| 58 |
+
dispose() {
|
| 59 |
+
if (this._emitter) {
|
| 60 |
+
this._emitter.dispose();
|
| 61 |
+
this._emitter = undefined;
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
class CancellationTokenSource {
|
| 66 |
+
get token() {
|
| 67 |
+
if (!this._token) {
|
| 68 |
+
// be lazy and create the token only when
|
| 69 |
+
// actually needed
|
| 70 |
+
this._token = new MutableToken();
|
| 71 |
+
}
|
| 72 |
+
return this._token;
|
| 73 |
+
}
|
| 74 |
+
cancel() {
|
| 75 |
+
if (!this._token) {
|
| 76 |
+
// save an object by returning the default
|
| 77 |
+
// cancelled token when cancellation happens
|
| 78 |
+
// before someone asks for the token
|
| 79 |
+
this._token = CancellationToken.Cancelled;
|
| 80 |
+
}
|
| 81 |
+
else {
|
| 82 |
+
this._token.cancel();
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
dispose() {
|
| 86 |
+
if (!this._token) {
|
| 87 |
+
// ensure to initialize with an empty token if we had none
|
| 88 |
+
this._token = CancellationToken.None;
|
| 89 |
+
}
|
| 90 |
+
else if (this._token instanceof MutableToken) {
|
| 91 |
+
// actually dispose
|
| 92 |
+
this._token.dispose();
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
exports.CancellationTokenSource = CancellationTokenSource;
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/connection.d.ts
CHANGED
|
@@ -1,3 +1,365 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Message, RequestMessage, RequestType, RequestType0, RequestType1, RequestType2, RequestType3, RequestType4, RequestType5, RequestType6, RequestType7, RequestType8, RequestType9, ResponseMessage, ResponseError, NotificationMessage, NotificationType, NotificationType0, NotificationType1, NotificationType2, NotificationType3, NotificationType4, NotificationType5, NotificationType6, NotificationType7, NotificationType8, NotificationType9, _EM, ParameterStructures } from './messages';
|
| 2 |
+
import type { Disposable } from './disposable';
|
| 3 |
+
import { Event } from './events';
|
| 4 |
+
import { CancellationToken, AbstractCancellationTokenSource } from './cancellation';
|
| 5 |
+
import { MessageReader } from './messageReader';
|
| 6 |
+
import { MessageWriter } from './messageWriter';
|
| 7 |
+
export type ProgressToken = number | string;
|
| 8 |
+
export declare namespace ProgressToken {
|
| 9 |
+
function is(value: any): value is number | string;
|
| 10 |
+
}
|
| 11 |
+
interface ProgressParams<T> {
|
| 12 |
+
/**
|
| 13 |
+
* The progress token provided by the client or server.
|
| 14 |
+
*/
|
| 15 |
+
token: ProgressToken;
|
| 16 |
+
/**
|
| 17 |
+
* The progress data.
|
| 18 |
+
*/
|
| 19 |
+
value: T;
|
| 20 |
+
}
|
| 21 |
+
export declare class ProgressType<PR> {
|
| 22 |
+
/**
|
| 23 |
+
* Clients must not use these properties. They are here to ensure correct typing.
|
| 24 |
+
* in TypeScript
|
| 25 |
+
*/
|
| 26 |
+
readonly __: [PR, _EM] | undefined;
|
| 27 |
+
readonly _pr: PR | undefined;
|
| 28 |
+
constructor();
|
| 29 |
+
}
|
| 30 |
+
export type HandlerResult<R, E> = R | ResponseError<E> | Thenable<R> | Thenable<ResponseError<E>> | Thenable<R | ResponseError<E>>;
|
| 31 |
+
export interface StarRequestHandler {
|
| 32 |
+
(method: string, params: any[] | object | undefined, token: CancellationToken): HandlerResult<any, any>;
|
| 33 |
+
}
|
| 34 |
+
export interface GenericRequestHandler<R, E> {
|
| 35 |
+
(...params: any[]): HandlerResult<R, E>;
|
| 36 |
+
}
|
| 37 |
+
export interface RequestHandler0<R, E> {
|
| 38 |
+
(token: CancellationToken): HandlerResult<R, E>;
|
| 39 |
+
}
|
| 40 |
+
export interface RequestHandler<P, R, E> {
|
| 41 |
+
(params: P, token: CancellationToken): HandlerResult<R, E>;
|
| 42 |
+
}
|
| 43 |
+
export interface RequestHandler1<P1, R, E> {
|
| 44 |
+
(p1: P1, token: CancellationToken): HandlerResult<R, E>;
|
| 45 |
+
}
|
| 46 |
+
export interface RequestHandler2<P1, P2, R, E> {
|
| 47 |
+
(p1: P1, p2: P2, token: CancellationToken): HandlerResult<R, E>;
|
| 48 |
+
}
|
| 49 |
+
export interface RequestHandler3<P1, P2, P3, R, E> {
|
| 50 |
+
(p1: P1, p2: P2, p3: P3, token: CancellationToken): HandlerResult<R, E>;
|
| 51 |
+
}
|
| 52 |
+
export interface RequestHandler4<P1, P2, P3, P4, R, E> {
|
| 53 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, token: CancellationToken): HandlerResult<R, E>;
|
| 54 |
+
}
|
| 55 |
+
export interface RequestHandler5<P1, P2, P3, P4, P5, R, E> {
|
| 56 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, token: CancellationToken): HandlerResult<R, E>;
|
| 57 |
+
}
|
| 58 |
+
export interface RequestHandler6<P1, P2, P3, P4, P5, P6, R, E> {
|
| 59 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, token: CancellationToken): HandlerResult<R, E>;
|
| 60 |
+
}
|
| 61 |
+
export interface RequestHandler7<P1, P2, P3, P4, P5, P6, P7, R, E> {
|
| 62 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, token: CancellationToken): HandlerResult<R, E>;
|
| 63 |
+
}
|
| 64 |
+
export interface RequestHandler8<P1, P2, P3, P4, P5, P6, P7, P8, R, E> {
|
| 65 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, token: CancellationToken): HandlerResult<R, E>;
|
| 66 |
+
}
|
| 67 |
+
export interface RequestHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E> {
|
| 68 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, token: CancellationToken): HandlerResult<R, E>;
|
| 69 |
+
}
|
| 70 |
+
export type NotificationResult = void | Promise<void>;
|
| 71 |
+
export interface StarNotificationHandler {
|
| 72 |
+
(method: string, params: any[] | object | undefined): NotificationResult;
|
| 73 |
+
}
|
| 74 |
+
export interface GenericNotificationHandler {
|
| 75 |
+
(...params: any[]): NotificationResult;
|
| 76 |
+
}
|
| 77 |
+
export interface NotificationHandler0 {
|
| 78 |
+
(): NotificationResult;
|
| 79 |
+
}
|
| 80 |
+
export interface NotificationHandler<P> {
|
| 81 |
+
(params: P): NotificationResult;
|
| 82 |
+
}
|
| 83 |
+
export interface NotificationHandler1<P1> {
|
| 84 |
+
(p1: P1): NotificationResult;
|
| 85 |
+
}
|
| 86 |
+
export interface NotificationHandler2<P1, P2> {
|
| 87 |
+
(p1: P1, p2: P2): NotificationResult;
|
| 88 |
+
}
|
| 89 |
+
export interface NotificationHandler3<P1, P2, P3> {
|
| 90 |
+
(p1: P1, p2: P2, p3: P3): NotificationResult;
|
| 91 |
+
}
|
| 92 |
+
export interface NotificationHandler4<P1, P2, P3, P4> {
|
| 93 |
+
(p1: P1, p2: P2, p3: P3, p4: P4): NotificationResult;
|
| 94 |
+
}
|
| 95 |
+
export interface NotificationHandler5<P1, P2, P3, P4, P5> {
|
| 96 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): NotificationResult;
|
| 97 |
+
}
|
| 98 |
+
export interface NotificationHandler6<P1, P2, P3, P4, P5, P6> {
|
| 99 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): NotificationResult;
|
| 100 |
+
}
|
| 101 |
+
export interface NotificationHandler7<P1, P2, P3, P4, P5, P6, P7> {
|
| 102 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): NotificationResult;
|
| 103 |
+
}
|
| 104 |
+
export interface NotificationHandler8<P1, P2, P3, P4, P5, P6, P7, P8> {
|
| 105 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): NotificationResult;
|
| 106 |
+
}
|
| 107 |
+
export interface NotificationHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9> {
|
| 108 |
+
(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): NotificationResult;
|
| 109 |
+
}
|
| 110 |
+
export interface Logger {
|
| 111 |
+
error(message: string): void;
|
| 112 |
+
warn(message: string): void;
|
| 113 |
+
info(message: string): void;
|
| 114 |
+
log(message: string): void;
|
| 115 |
+
}
|
| 116 |
+
export declare const NullLogger: Logger;
|
| 117 |
+
export declare enum Trace {
|
| 118 |
+
Off = 0,
|
| 119 |
+
Messages = 1,
|
| 120 |
+
Compact = 2,
|
| 121 |
+
Verbose = 3
|
| 122 |
+
}
|
| 123 |
+
export declare namespace TraceValue {
|
| 124 |
+
/**
|
| 125 |
+
* Turn tracing off.
|
| 126 |
+
*/
|
| 127 |
+
const Off: 'off';
|
| 128 |
+
/**
|
| 129 |
+
* Trace messages only.
|
| 130 |
+
*/
|
| 131 |
+
const Messages: 'messages';
|
| 132 |
+
/**
|
| 133 |
+
* Compact message tracing.
|
| 134 |
+
*/
|
| 135 |
+
const Compact: 'compact';
|
| 136 |
+
/**
|
| 137 |
+
* Verbose message tracing.
|
| 138 |
+
*/
|
| 139 |
+
const Verbose: 'verbose';
|
| 140 |
+
}
|
| 141 |
+
export type TraceValue = 'off' | 'messages' | 'compact' | 'verbose';
|
| 142 |
+
/**
|
| 143 |
+
* @deprecated Use TraceValue instead
|
| 144 |
+
*/
|
| 145 |
+
export declare const TraceValues: typeof TraceValue;
|
| 146 |
+
export type TraceValues = TraceValue;
|
| 147 |
+
export declare namespace Trace {
|
| 148 |
+
function fromString(value: string): Trace;
|
| 149 |
+
function toString(value: Trace): TraceValue;
|
| 150 |
+
}
|
| 151 |
+
export declare enum TraceFormat {
|
| 152 |
+
Text = "text",
|
| 153 |
+
JSON = "json"
|
| 154 |
+
}
|
| 155 |
+
export declare namespace TraceFormat {
|
| 156 |
+
function fromString(value: string): TraceFormat;
|
| 157 |
+
}
|
| 158 |
+
export interface TraceOptions {
|
| 159 |
+
sendNotification?: boolean;
|
| 160 |
+
traceFormat?: TraceFormat;
|
| 161 |
+
}
|
| 162 |
+
export interface SetTraceParams {
|
| 163 |
+
value: TraceValue;
|
| 164 |
+
}
|
| 165 |
+
export declare namespace SetTraceNotification {
|
| 166 |
+
const type: NotificationType<SetTraceParams>;
|
| 167 |
+
}
|
| 168 |
+
export interface LogTraceParams {
|
| 169 |
+
message: string;
|
| 170 |
+
verbose?: string;
|
| 171 |
+
}
|
| 172 |
+
export declare namespace LogTraceNotification {
|
| 173 |
+
const type: NotificationType<LogTraceParams>;
|
| 174 |
+
}
|
| 175 |
+
export interface Tracer {
|
| 176 |
+
log(dataObject: any): void;
|
| 177 |
+
log(message: string, data?: string): void;
|
| 178 |
+
}
|
| 179 |
+
export declare enum ConnectionErrors {
|
| 180 |
+
/**
|
| 181 |
+
* The connection is closed.
|
| 182 |
+
*/
|
| 183 |
+
Closed = 1,
|
| 184 |
+
/**
|
| 185 |
+
* The connection got disposed.
|
| 186 |
+
*/
|
| 187 |
+
Disposed = 2,
|
| 188 |
+
/**
|
| 189 |
+
* The connection is already in listening mode.
|
| 190 |
+
*/
|
| 191 |
+
AlreadyListening = 3
|
| 192 |
+
}
|
| 193 |
+
export declare class ConnectionError extends Error {
|
| 194 |
+
readonly code: ConnectionErrors;
|
| 195 |
+
constructor(code: ConnectionErrors, message: string);
|
| 196 |
+
}
|
| 197 |
+
export type ConnectionStrategy = {
|
| 198 |
+
cancelUndispatched?: (message: Message, next: (message: Message) => ResponseMessage | undefined) => ResponseMessage | undefined;
|
| 199 |
+
};
|
| 200 |
+
export declare namespace ConnectionStrategy {
|
| 201 |
+
function is(value: any): value is ConnectionStrategy;
|
| 202 |
+
}
|
| 203 |
+
export type CancellationId = number | string;
|
| 204 |
+
export interface IdCancellationReceiverStrategy {
|
| 205 |
+
kind?: 'id';
|
| 206 |
+
/**
|
| 207 |
+
* Creates a CancellationTokenSource from a cancellation id.
|
| 208 |
+
*
|
| 209 |
+
* @param id The cancellation id.
|
| 210 |
+
*/
|
| 211 |
+
createCancellationTokenSource(id: CancellationId): AbstractCancellationTokenSource;
|
| 212 |
+
/**
|
| 213 |
+
* An optional method to dispose the strategy.
|
| 214 |
+
*/
|
| 215 |
+
dispose?(): void;
|
| 216 |
+
}
|
| 217 |
+
export declare namespace IdCancellationReceiverStrategy {
|
| 218 |
+
function is(value: any): value is IdCancellationReceiverStrategy;
|
| 219 |
+
}
|
| 220 |
+
export interface RequestCancellationReceiverStrategy {
|
| 221 |
+
kind: 'request';
|
| 222 |
+
/**
|
| 223 |
+
* Create a cancellation token source from a given request message.
|
| 224 |
+
*
|
| 225 |
+
* @param requestMessage The request message.
|
| 226 |
+
*/
|
| 227 |
+
createCancellationTokenSource(requestMessage: RequestMessage): AbstractCancellationTokenSource;
|
| 228 |
+
/**
|
| 229 |
+
* An optional method to dispose the strategy.
|
| 230 |
+
*/
|
| 231 |
+
dispose?(): void;
|
| 232 |
+
}
|
| 233 |
+
export declare namespace RequestCancellationReceiverStrategy {
|
| 234 |
+
function is(value: any): value is RequestCancellationReceiverStrategy;
|
| 235 |
+
}
|
| 236 |
+
export type CancellationReceiverStrategy = IdCancellationReceiverStrategy | RequestCancellationReceiverStrategy;
|
| 237 |
+
export declare namespace CancellationReceiverStrategy {
|
| 238 |
+
const Message: CancellationReceiverStrategy;
|
| 239 |
+
function is(value: any): value is CancellationReceiverStrategy;
|
| 240 |
+
}
|
| 241 |
+
export interface CancellationSenderStrategy {
|
| 242 |
+
/**
|
| 243 |
+
* Hook to enable cancellation for the given request.
|
| 244 |
+
*
|
| 245 |
+
* @param request The request to enable cancellation for.
|
| 246 |
+
*/
|
| 247 |
+
enableCancellation?(request: RequestMessage): void;
|
| 248 |
+
/**
|
| 249 |
+
* Send cancellation for the given cancellation id
|
| 250 |
+
*
|
| 251 |
+
* @param conn The connection used.
|
| 252 |
+
* @param id The cancellation id.
|
| 253 |
+
*/
|
| 254 |
+
sendCancellation(conn: MessageConnection, id: CancellationId): Promise<void>;
|
| 255 |
+
/**
|
| 256 |
+
* Cleanup any cancellation state for the given cancellation id. After this
|
| 257 |
+
* method has been call no cancellation will be sent anymore for the given id.
|
| 258 |
+
*
|
| 259 |
+
* @param id The cancellation id.
|
| 260 |
+
*/
|
| 261 |
+
cleanup(id: CancellationId): void;
|
| 262 |
+
/**
|
| 263 |
+
* An optional method to dispose the strategy.
|
| 264 |
+
*/
|
| 265 |
+
dispose?(): void;
|
| 266 |
+
}
|
| 267 |
+
export declare namespace CancellationSenderStrategy {
|
| 268 |
+
const Message: CancellationSenderStrategy;
|
| 269 |
+
function is(value: any): value is CancellationSenderStrategy;
|
| 270 |
+
}
|
| 271 |
+
export interface CancellationStrategy {
|
| 272 |
+
receiver: CancellationReceiverStrategy | RequestCancellationReceiverStrategy;
|
| 273 |
+
sender: CancellationSenderStrategy;
|
| 274 |
+
}
|
| 275 |
+
export declare namespace CancellationStrategy {
|
| 276 |
+
const Message: CancellationStrategy;
|
| 277 |
+
function is(value: any): value is CancellationStrategy;
|
| 278 |
+
}
|
| 279 |
+
export interface MessageStrategy {
|
| 280 |
+
handleMessage(message: Message, next: (message: Message) => NotificationResult): NotificationResult;
|
| 281 |
+
}
|
| 282 |
+
export declare namespace MessageStrategy {
|
| 283 |
+
function is(value: any): value is MessageStrategy;
|
| 284 |
+
}
|
| 285 |
+
/**
|
| 286 |
+
* Connection options. A valid connection option must have at least a
|
| 287 |
+
* `CancellationStrategy` or a `MessageStrategy` or a `ConnectionStrategy`.
|
| 288 |
+
*/
|
| 289 |
+
export interface ConnectionOptions {
|
| 290 |
+
cancellationStrategy?: CancellationStrategy;
|
| 291 |
+
connectionStrategy?: ConnectionStrategy;
|
| 292 |
+
messageStrategy?: MessageStrategy;
|
| 293 |
+
maxParallelism?: number;
|
| 294 |
+
}
|
| 295 |
+
export declare namespace ConnectionOptions {
|
| 296 |
+
function is(value: any): value is ConnectionOptions;
|
| 297 |
+
}
|
| 298 |
+
export interface MessageConnection {
|
| 299 |
+
sendRequest<R, E>(type: RequestType0<R, E>, token?: CancellationToken): Promise<R>;
|
| 300 |
+
sendRequest<P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken): Promise<R>;
|
| 301 |
+
sendRequest<P1, R, E>(type: RequestType1<P1, R, E>, p1: P1, token?: CancellationToken): Promise<R>;
|
| 302 |
+
sendRequest<P1, P2, R, E>(type: RequestType2<P1, P2, R, E>, p1: P1, p2: P2, token?: CancellationToken): Promise<R>;
|
| 303 |
+
sendRequest<P1, P2, P3, R, E>(type: RequestType3<P1, P2, P3, R, E>, p1: P1, p2: P2, p3: P3, token?: CancellationToken): Promise<R>;
|
| 304 |
+
sendRequest<P1, P2, P3, P4, R, E>(type: RequestType4<P1, P2, P3, P4, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, token?: CancellationToken): Promise<R>;
|
| 305 |
+
sendRequest<P1, P2, P3, P4, P5, R, E>(type: RequestType5<P1, P2, P3, P4, P5, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, token?: CancellationToken): Promise<R>;
|
| 306 |
+
sendRequest<P1, P2, P3, P4, P5, P6, R, E>(type: RequestType6<P1, P2, P3, P4, P5, P6, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, token?: CancellationToken): Promise<R>;
|
| 307 |
+
sendRequest<P1, P2, P3, P4, P5, P6, P7, R, E>(type: RequestType7<P1, P2, P3, P4, P5, P6, P7, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, token?: CancellationToken): Promise<R>;
|
| 308 |
+
sendRequest<P1, P2, P3, P4, P5, P6, P7, P8, R, E>(type: RequestType8<P1, P2, P3, P4, P5, P6, P7, P8, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, token?: CancellationToken): Promise<R>;
|
| 309 |
+
sendRequest<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>(type: RequestType9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, token?: CancellationToken): Promise<R>;
|
| 310 |
+
sendRequest<R>(method: string, r0?: ParameterStructures | any, ...rest: any[]): Promise<R>;
|
| 311 |
+
onRequest<R, E>(type: RequestType0<R, E>, handler: RequestHandler0<R, E>): Disposable;
|
| 312 |
+
onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): Disposable;
|
| 313 |
+
onRequest<P1, R, E>(type: RequestType1<P1, R, E>, handler: RequestHandler1<P1, R, E>): Disposable;
|
| 314 |
+
onRequest<P1, P2, R, E>(type: RequestType2<P1, P2, R, E>, handler: RequestHandler2<P1, P2, R, E>): Disposable;
|
| 315 |
+
onRequest<P1, P2, P3, R, E>(type: RequestType3<P1, P2, P3, R, E>, handler: RequestHandler3<P1, P2, P3, R, E>): Disposable;
|
| 316 |
+
onRequest<P1, P2, P3, P4, R, E>(type: RequestType4<P1, P2, P3, P4, R, E>, handler: RequestHandler4<P1, P2, P3, P4, R, E>): Disposable;
|
| 317 |
+
onRequest<P1, P2, P3, P4, P5, R, E>(type: RequestType5<P1, P2, P3, P4, P5, R, E>, handler: RequestHandler5<P1, P2, P3, P4, P5, R, E>): Disposable;
|
| 318 |
+
onRequest<P1, P2, P3, P4, P5, P6, R, E>(type: RequestType6<P1, P2, P3, P4, P5, P6, R, E>, handler: RequestHandler6<P1, P2, P3, P4, P5, P6, R, E>): Disposable;
|
| 319 |
+
onRequest<P1, P2, P3, P4, P5, P6, P7, R, E>(type: RequestType7<P1, P2, P3, P4, P5, P6, P7, R, E>, handler: RequestHandler7<P1, P2, P3, P4, P5, P6, P7, R, E>): Disposable;
|
| 320 |
+
onRequest<P1, P2, P3, P4, P5, P6, P7, P8, R, E>(type: RequestType8<P1, P2, P3, P4, P5, P6, P7, P8, R, E>, handler: RequestHandler8<P1, P2, P3, P4, P5, P6, P7, P8, R, E>): Disposable;
|
| 321 |
+
onRequest<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>(type: RequestType9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>, handler: RequestHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>): Disposable;
|
| 322 |
+
onRequest<R, E>(method: string, handler: GenericRequestHandler<R, E>): Disposable;
|
| 323 |
+
onRequest(handler: StarRequestHandler): Disposable;
|
| 324 |
+
hasPendingResponse(): boolean;
|
| 325 |
+
sendNotification(type: NotificationType0): Promise<void>;
|
| 326 |
+
sendNotification<P>(type: NotificationType<P>, params?: P): Promise<void>;
|
| 327 |
+
sendNotification<P1>(type: NotificationType1<P1>, p1: P1): Promise<void>;
|
| 328 |
+
sendNotification<P1, P2>(type: NotificationType2<P1, P2>, p1: P1, p2: P2): Promise<void>;
|
| 329 |
+
sendNotification<P1, P2, P3>(type: NotificationType3<P1, P2, P3>, p1: P1, p2: P2, p3: P3): Promise<void>;
|
| 330 |
+
sendNotification<P1, P2, P3, P4>(type: NotificationType4<P1, P2, P3, P4>, p1: P1, p2: P2, p3: P3, p4: P4): Promise<void>;
|
| 331 |
+
sendNotification<P1, P2, P3, P4, P5>(type: NotificationType5<P1, P2, P3, P4, P5>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): Promise<void>;
|
| 332 |
+
sendNotification<P1, P2, P3, P4, P5, P6>(type: NotificationType6<P1, P2, P3, P4, P5, P6>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): Promise<void>;
|
| 333 |
+
sendNotification<P1, P2, P3, P4, P5, P6, P7>(type: NotificationType7<P1, P2, P3, P4, P5, P6, P7>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): Promise<void>;
|
| 334 |
+
sendNotification<P1, P2, P3, P4, P5, P6, P7, P8>(type: NotificationType8<P1, P2, P3, P4, P5, P6, P7, P8>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): Promise<void>;
|
| 335 |
+
sendNotification<P1, P2, P3, P4, P5, P6, P7, P8, P9>(type: NotificationType9<P1, P2, P3, P4, P5, P6, P7, P8, P9>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): Promise<void>;
|
| 336 |
+
sendNotification(method: string, r0?: ParameterStructures | any, ...rest: any[]): Promise<void>;
|
| 337 |
+
onNotification(type: NotificationType0, handler: NotificationHandler0): Disposable;
|
| 338 |
+
onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): Disposable;
|
| 339 |
+
onNotification<P1>(type: NotificationType1<P1>, handler: NotificationHandler1<P1>): Disposable;
|
| 340 |
+
onNotification<P1, P2>(type: NotificationType2<P1, P2>, handler: NotificationHandler2<P1, P2>): Disposable;
|
| 341 |
+
onNotification<P1, P2, P3>(type: NotificationType3<P1, P2, P3>, handler: NotificationHandler3<P1, P2, P3>): Disposable;
|
| 342 |
+
onNotification<P1, P2, P3, P4>(type: NotificationType4<P1, P2, P3, P4>, handler: NotificationHandler4<P1, P2, P3, P4>): Disposable;
|
| 343 |
+
onNotification<P1, P2, P3, P4, P5>(type: NotificationType5<P1, P2, P3, P4, P5>, handler: NotificationHandler5<P1, P2, P3, P4, P5>): Disposable;
|
| 344 |
+
onNotification<P1, P2, P3, P4, P5, P6>(type: NotificationType6<P1, P2, P3, P4, P5, P6>, handler: NotificationHandler6<P1, P2, P3, P4, P5, P6>): Disposable;
|
| 345 |
+
onNotification<P1, P2, P3, P4, P5, P6, P7>(type: NotificationType7<P1, P2, P3, P4, P5, P6, P7>, handler: NotificationHandler7<P1, P2, P3, P4, P5, P6, P7>): Disposable;
|
| 346 |
+
onNotification<P1, P2, P3, P4, P5, P6, P7, P8>(type: NotificationType8<P1, P2, P3, P4, P5, P6, P7, P8>, handler: NotificationHandler8<P1, P2, P3, P4, P5, P6, P7, P8>): Disposable;
|
| 347 |
+
onNotification<P1, P2, P3, P4, P5, P6, P7, P8, P9>(type: NotificationType9<P1, P2, P3, P4, P5, P6, P7, P8, P9>, handler: NotificationHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9>): Disposable;
|
| 348 |
+
onNotification(method: string, handler: GenericNotificationHandler): Disposable;
|
| 349 |
+
onNotification(handler: StarNotificationHandler): Disposable;
|
| 350 |
+
onUnhandledNotification: Event<NotificationMessage>;
|
| 351 |
+
onProgress<P>(type: ProgressType<P>, token: string | number, handler: NotificationHandler<P>): Disposable;
|
| 352 |
+
sendProgress<P>(type: ProgressType<P>, token: string | number, value: P): Promise<void>;
|
| 353 |
+
onUnhandledProgress: Event<ProgressParams<any>>;
|
| 354 |
+
trace(value: Trace, tracer: Tracer, sendNotification?: boolean): Promise<void>;
|
| 355 |
+
trace(value: Trace, tracer: Tracer, traceOptions?: TraceOptions): Promise<void>;
|
| 356 |
+
onError: Event<[Error, Message | undefined, number | undefined]>;
|
| 357 |
+
onClose: Event<void>;
|
| 358 |
+
listen(): void;
|
| 359 |
+
end(): void;
|
| 360 |
+
onDispose: Event<void>;
|
| 361 |
+
dispose(): void;
|
| 362 |
+
inspect(): void;
|
| 363 |
+
}
|
| 364 |
+
export declare function createMessageConnection(messageReader: MessageReader, messageWriter: MessageWriter, _logger?: Logger, options?: ConnectionOptions): MessageConnection;
|
| 365 |
+
export {};
|
Java开发环境安装/eclipse-jee-2024-06-R-win32-x86_64/eclipse/plugins/org.eclipse.wildwebdeveloper_1.2.2.202405280856/node_modules/vscode-json-languageserver/node_modules/vscode-jsonrpc/lib/common/connection.js
CHANGED
|
@@ -1,3 +1,1220 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/* --------------------------------------------------------------------------------------------
|
| 3 |
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 4 |
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
| 5 |
+
* ------------------------------------------------------------------------------------------ */
|
| 6 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 7 |
+
exports.createMessageConnection = exports.ConnectionOptions = exports.MessageStrategy = exports.CancellationStrategy = exports.CancellationSenderStrategy = exports.CancellationReceiverStrategy = exports.RequestCancellationReceiverStrategy = exports.IdCancellationReceiverStrategy = exports.ConnectionStrategy = exports.ConnectionError = exports.ConnectionErrors = exports.LogTraceNotification = exports.SetTraceNotification = exports.TraceFormat = exports.TraceValues = exports.TraceValue = exports.Trace = exports.NullLogger = exports.ProgressType = exports.ProgressToken = void 0;
|
| 8 |
+
const ral_1 = require("./ral");
|
| 9 |
+
const Is = require("./is");
|
| 10 |
+
const messages_1 = require("./messages");
|
| 11 |
+
const linkedMap_1 = require("./linkedMap");
|
| 12 |
+
const events_1 = require("./events");
|
| 13 |
+
const cancellation_1 = require("./cancellation");
|
| 14 |
+
var CancelNotification;
|
| 15 |
+
(function (CancelNotification) {
|
| 16 |
+
CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
|
| 17 |
+
})(CancelNotification || (CancelNotification = {}));
|
| 18 |
+
var ProgressToken;
|
| 19 |
+
(function (ProgressToken) {
|
| 20 |
+
function is(value) {
|
| 21 |
+
return typeof value === 'string' || typeof value === 'number';
|
| 22 |
+
}
|
| 23 |
+
ProgressToken.is = is;
|
| 24 |
+
})(ProgressToken || (exports.ProgressToken = ProgressToken = {}));
|
| 25 |
+
var ProgressNotification;
|
| 26 |
+
(function (ProgressNotification) {
|
| 27 |
+
ProgressNotification.type = new messages_1.NotificationType('$/progress');
|
| 28 |
+
})(ProgressNotification || (ProgressNotification = {}));
|
| 29 |
+
class ProgressType {
|
| 30 |
+
constructor() {
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
exports.ProgressType = ProgressType;
|
| 34 |
+
var StarRequestHandler;
|
| 35 |
+
(function (StarRequestHandler) {
|
| 36 |
+
function is(value) {
|
| 37 |
+
return Is.func(value);
|
| 38 |
+
}
|
| 39 |
+
StarRequestHandler.is = is;
|
| 40 |
+
})(StarRequestHandler || (StarRequestHandler = {}));
|
| 41 |
+
exports.NullLogger = Object.freeze({
|
| 42 |
+
error: () => { },
|
| 43 |
+
warn: () => { },
|
| 44 |
+
info: () => { },
|
| 45 |
+
log: () => { }
|
| 46 |
+
});
|
| 47 |
+
var Trace;
|
| 48 |
+
(function (Trace) {
|
| 49 |
+
Trace[Trace["Off"] = 0] = "Off";
|
| 50 |
+
Trace[Trace["Messages"] = 1] = "Messages";
|
| 51 |
+
Trace[Trace["Compact"] = 2] = "Compact";
|
| 52 |
+
Trace[Trace["Verbose"] = 3] = "Verbose";
|
| 53 |
+
})(Trace || (exports.Trace = Trace = {}));
|
| 54 |
+
var TraceValue;
|
| 55 |
+
(function (TraceValue) {
|
| 56 |
+
/**
|
| 57 |
+
* Turn tracing off.
|
| 58 |
+
*/
|
| 59 |
+
TraceValue.Off = 'off';
|
| 60 |
+
/**
|
| 61 |
+
* Trace messages only.
|
| 62 |
+
*/
|
| 63 |
+
TraceValue.Messages = 'messages';
|
| 64 |
+
/**
|
| 65 |
+
* Compact message tracing.
|
| 66 |
+
*/
|
| 67 |
+
TraceValue.Compact = 'compact';
|
| 68 |
+
/**
|
| 69 |
+
* Verbose message tracing.
|
| 70 |
+
*/
|
| 71 |
+
TraceValue.Verbose = 'verbose';
|
| 72 |
+
})(TraceValue || (exports.TraceValue = TraceValue = {}));
|
| 73 |
+
/**
|
| 74 |
+
* @deprecated Use TraceValue instead
|
| 75 |
+
*/
|
| 76 |
+
exports.TraceValues = TraceValue;
|
| 77 |
+
(function (Trace) {
|
| 78 |
+
function fromString(value) {
|
| 79 |
+
if (!Is.string(value)) {
|
| 80 |
+
return Trace.Off;
|
| 81 |
+
}
|
| 82 |
+
value = value.toLowerCase();
|
| 83 |
+
switch (value) {
|
| 84 |
+
case 'off':
|
| 85 |
+
return Trace.Off;
|
| 86 |
+
case 'messages':
|
| 87 |
+
return Trace.Messages;
|
| 88 |
+
case 'compact':
|
| 89 |
+
return Trace.Compact;
|
| 90 |
+
case 'verbose':
|
| 91 |
+
return Trace.Verbose;
|
| 92 |
+
default:
|
| 93 |
+
return Trace.Off;
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
Trace.fromString = fromString;
|
| 97 |
+
function toString(value) {
|
| 98 |
+
switch (value) {
|
| 99 |
+
case Trace.Off:
|
| 100 |
+
return 'off';
|
| 101 |
+
case Trace.Messages:
|
| 102 |
+
return 'messages';
|
| 103 |
+
case Trace.Compact:
|
| 104 |
+
return 'compact';
|
| 105 |
+
case Trace.Verbose:
|
| 106 |
+
return 'verbose';
|
| 107 |
+
default:
|
| 108 |
+
return 'off';
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
Trace.toString = toString;
|
| 112 |
+
})(Trace || (exports.Trace = Trace = {}));
|
| 113 |
+
var TraceFormat;
|
| 114 |
+
(function (TraceFormat) {
|
| 115 |
+
TraceFormat["Text"] = "text";
|
| 116 |
+
TraceFormat["JSON"] = "json";
|
| 117 |
+
})(TraceFormat || (exports.TraceFormat = TraceFormat = {}));
|
| 118 |
+
(function (TraceFormat) {
|
| 119 |
+
function fromString(value) {
|
| 120 |
+
if (!Is.string(value)) {
|
| 121 |
+
return TraceFormat.Text;
|
| 122 |
+
}
|
| 123 |
+
value = value.toLowerCase();
|
| 124 |
+
if (value === 'json') {
|
| 125 |
+
return TraceFormat.JSON;
|
| 126 |
+
}
|
| 127 |
+
else {
|
| 128 |
+
return TraceFormat.Text;
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
TraceFormat.fromString = fromString;
|
| 132 |
+
})(TraceFormat || (exports.TraceFormat = TraceFormat = {}));
|
| 133 |
+
var SetTraceNotification;
|
| 134 |
+
(function (SetTraceNotification) {
|
| 135 |
+
SetTraceNotification.type = new messages_1.NotificationType('$/setTrace');
|
| 136 |
+
})(SetTraceNotification || (exports.SetTraceNotification = SetTraceNotification = {}));
|
| 137 |
+
var LogTraceNotification;
|
| 138 |
+
(function (LogTraceNotification) {
|
| 139 |
+
LogTraceNotification.type = new messages_1.NotificationType('$/logTrace');
|
| 140 |
+
})(LogTraceNotification || (exports.LogTraceNotification = LogTraceNotification = {}));
|
| 141 |
+
var ConnectionErrors;
|
| 142 |
+
(function (ConnectionErrors) {
|
| 143 |
+
/**
|
| 144 |
+
* The connection is closed.
|
| 145 |
+
*/
|
| 146 |
+
ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
|
| 147 |
+
/**
|
| 148 |
+
* The connection got disposed.
|
| 149 |
+
*/
|
| 150 |
+
ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
|
| 151 |
+
/**
|
| 152 |
+
* The connection is already in listening mode.
|
| 153 |
+
*/
|
| 154 |
+
ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
|
| 155 |
+
})(ConnectionErrors || (exports.ConnectionErrors = ConnectionErrors = {}));
|
| 156 |
+
class ConnectionError extends Error {
|
| 157 |
+
constructor(code, message) {
|
| 158 |
+
super(message);
|
| 159 |
+
this.code = code;
|
| 160 |
+
Object.setPrototypeOf(this, ConnectionError.prototype);
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
exports.ConnectionError = ConnectionError;
|
| 164 |
+
var ConnectionStrategy;
|
| 165 |
+
(function (ConnectionStrategy) {
|
| 166 |
+
function is(value) {
|
| 167 |
+
const candidate = value;
|
| 168 |
+
return candidate && Is.func(candidate.cancelUndispatched);
|
| 169 |
+
}
|
| 170 |
+
ConnectionStrategy.is = is;
|
| 171 |
+
})(ConnectionStrategy || (exports.ConnectionStrategy = ConnectionStrategy = {}));
|
| 172 |
+
var IdCancellationReceiverStrategy;
|
| 173 |
+
(function (IdCancellationReceiverStrategy) {
|
| 174 |
+
function is(value) {
|
| 175 |
+
const candidate = value;
|
| 176 |
+
return candidate && (candidate.kind === undefined || candidate.kind === 'id') && Is.func(candidate.createCancellationTokenSource) && (candidate.dispose === undefined || Is.func(candidate.dispose));
|
| 177 |
+
}
|
| 178 |
+
IdCancellationReceiverStrategy.is = is;
|
| 179 |
+
})(IdCancellationReceiverStrategy || (exports.IdCancellationReceiverStrategy = IdCancellationReceiverStrategy = {}));
|
| 180 |
+
var RequestCancellationReceiverStrategy;
|
| 181 |
+
(function (RequestCancellationReceiverStrategy) {
|
| 182 |
+
function is(value) {
|
| 183 |
+
const candidate = value;
|
| 184 |
+
return candidate && candidate.kind === 'request' && Is.func(candidate.createCancellationTokenSource) && (candidate.dispose === undefined || Is.func(candidate.dispose));
|
| 185 |
+
}
|
| 186 |
+
RequestCancellationReceiverStrategy.is = is;
|
| 187 |
+
})(RequestCancellationReceiverStrategy || (exports.RequestCancellationReceiverStrategy = RequestCancellationReceiverStrategy = {}));
|
| 188 |
+
var CancellationReceiverStrategy;
|
| 189 |
+
(function (CancellationReceiverStrategy) {
|
| 190 |
+
CancellationReceiverStrategy.Message = Object.freeze({
|
| 191 |
+
createCancellationTokenSource(_) {
|
| 192 |
+
return new cancellation_1.CancellationTokenSource();
|
| 193 |
+
}
|
| 194 |
+
});
|
| 195 |
+
function is(value) {
|
| 196 |
+
return IdCancellationReceiverStrategy.is(value) || RequestCancellationReceiverStrategy.is(value);
|
| 197 |
+
}
|
| 198 |
+
CancellationReceiverStrategy.is = is;
|
| 199 |
+
})(CancellationReceiverStrategy || (exports.CancellationReceiverStrategy = CancellationReceiverStrategy = {}));
|
| 200 |
+
var CancellationSenderStrategy;
|
| 201 |
+
(function (CancellationSenderStrategy) {
|
| 202 |
+
CancellationSenderStrategy.Message = Object.freeze({
|
| 203 |
+
sendCancellation(conn, id) {
|
| 204 |
+
return conn.sendNotification(CancelNotification.type, { id });
|
| 205 |
+
},
|
| 206 |
+
cleanup(_) { }
|
| 207 |
+
});
|
| 208 |
+
function is(value) {
|
| 209 |
+
const candidate = value;
|
| 210 |
+
return candidate && Is.func(candidate.sendCancellation) && Is.func(candidate.cleanup);
|
| 211 |
+
}
|
| 212 |
+
CancellationSenderStrategy.is = is;
|
| 213 |
+
})(CancellationSenderStrategy || (exports.CancellationSenderStrategy = CancellationSenderStrategy = {}));
|
| 214 |
+
var CancellationStrategy;
|
| 215 |
+
(function (CancellationStrategy) {
|
| 216 |
+
CancellationStrategy.Message = Object.freeze({
|
| 217 |
+
receiver: CancellationReceiverStrategy.Message,
|
| 218 |
+
sender: CancellationSenderStrategy.Message
|
| 219 |
+
});
|
| 220 |
+
function is(value) {
|
| 221 |
+
const candidate = value;
|
| 222 |
+
return candidate && CancellationReceiverStrategy.is(candidate.receiver) && CancellationSenderStrategy.is(candidate.sender);
|
| 223 |
+
}
|
| 224 |
+
CancellationStrategy.is = is;
|
| 225 |
+
})(CancellationStrategy || (exports.CancellationStrategy = CancellationStrategy = {}));
|
| 226 |
+
var MessageStrategy;
|
| 227 |
+
(function (MessageStrategy) {
|
| 228 |
+
function is(value) {
|
| 229 |
+
const candidate = value;
|
| 230 |
+
return candidate && Is.func(candidate.handleMessage);
|
| 231 |
+
}
|
| 232 |
+
MessageStrategy.is = is;
|
| 233 |
+
})(MessageStrategy || (exports.MessageStrategy = MessageStrategy = {}));
|
| 234 |
+
var ConnectionOptions;
|
| 235 |
+
(function (ConnectionOptions) {
|
| 236 |
+
function is(value) {
|
| 237 |
+
const candidate = value;
|
| 238 |
+
return candidate
|
| 239 |
+
&& (CancellationStrategy.is(candidate.cancellationStrategy) || ConnectionStrategy.is(candidate.connectionStrategy) || MessageStrategy.is(candidate.messageStrategy) || Is.number(candidate.maxParallelism));
|
| 240 |
+
}
|
| 241 |
+
ConnectionOptions.is = is;
|
| 242 |
+
})(ConnectionOptions || (exports.ConnectionOptions = ConnectionOptions = {}));
|
| 243 |
+
var ConnectionState;
|
| 244 |
+
(function (ConnectionState) {
|
| 245 |
+
ConnectionState[ConnectionState["New"] = 1] = "New";
|
| 246 |
+
ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
|
| 247 |
+
ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
|
| 248 |
+
ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
|
| 249 |
+
})(ConnectionState || (ConnectionState = {}));
|
| 250 |
+
function createMessageConnection(messageReader, messageWriter, _logger, options) {
|
| 251 |
+
const logger = _logger !== undefined ? _logger : exports.NullLogger;
|
| 252 |
+
let sequenceNumber = 0;
|
| 253 |
+
let notificationSequenceNumber = 0;
|
| 254 |
+
let unknownResponseSequenceNumber = 0;
|
| 255 |
+
const version = '2.0';
|
| 256 |
+
const maxParallelism = options?.maxParallelism ?? -1;
|
| 257 |
+
let inFlight = 0;
|
| 258 |
+
let starRequestHandler = undefined;
|
| 259 |
+
const requestHandlers = new Map();
|
| 260 |
+
let starNotificationHandler = undefined;
|
| 261 |
+
const notificationHandlers = new Map();
|
| 262 |
+
const progressHandlers = new Map();
|
| 263 |
+
let timer;
|
| 264 |
+
let messageQueue = new linkedMap_1.LinkedMap();
|
| 265 |
+
let responsePromises = new Map();
|
| 266 |
+
let knownCanceledRequests = new Set();
|
| 267 |
+
let requestTokens = new Map();
|
| 268 |
+
let trace = Trace.Off;
|
| 269 |
+
let traceFormat = TraceFormat.Text;
|
| 270 |
+
let tracer;
|
| 271 |
+
let state = ConnectionState.New;
|
| 272 |
+
const errorEmitter = new events_1.Emitter();
|
| 273 |
+
const closeEmitter = new events_1.Emitter();
|
| 274 |
+
const unhandledNotificationEmitter = new events_1.Emitter();
|
| 275 |
+
const unhandledProgressEmitter = new events_1.Emitter();
|
| 276 |
+
const disposeEmitter = new events_1.Emitter();
|
| 277 |
+
const cancellationStrategy = (options && options.cancellationStrategy) ? options.cancellationStrategy : CancellationStrategy.Message;
|
| 278 |
+
function cancelUndispatched(_message) {
|
| 279 |
+
return undefined;
|
| 280 |
+
}
|
| 281 |
+
function isListening() {
|
| 282 |
+
return state === ConnectionState.Listening;
|
| 283 |
+
}
|
| 284 |
+
function isClosed() {
|
| 285 |
+
return state === ConnectionState.Closed;
|
| 286 |
+
}
|
| 287 |
+
function isDisposed() {
|
| 288 |
+
return state === ConnectionState.Disposed;
|
| 289 |
+
}
|
| 290 |
+
function closeHandler() {
|
| 291 |
+
if (state === ConnectionState.New || state === ConnectionState.Listening) {
|
| 292 |
+
state = ConnectionState.Closed;
|
| 293 |
+
closeEmitter.fire(undefined);
|
| 294 |
+
}
|
| 295 |
+
// If the connection is disposed don't sent close events.
|
| 296 |
+
}
|
| 297 |
+
function readErrorHandler(error) {
|
| 298 |
+
errorEmitter.fire([error, undefined, undefined]);
|
| 299 |
+
}
|
| 300 |
+
function writeErrorHandler(data) {
|
| 301 |
+
errorEmitter.fire(data);
|
| 302 |
+
}
|
| 303 |
+
messageReader.onClose(closeHandler);
|
| 304 |
+
messageReader.onError(readErrorHandler);
|
| 305 |
+
messageWriter.onClose(closeHandler);
|
| 306 |
+
messageWriter.onError(writeErrorHandler);
|
| 307 |
+
function createRequestQueueKey(id) {
|
| 308 |
+
if (id === null) {
|
| 309 |
+
throw new Error(`Can't send requests with id null since the response can't be correlated.`);
|
| 310 |
+
}
|
| 311 |
+
return 'req-' + id.toString();
|
| 312 |
+
}
|
| 313 |
+
function createResponseQueueKey(id) {
|
| 314 |
+
if (id === null) {
|
| 315 |
+
return 'res-unknown-' + (++unknownResponseSequenceNumber).toString();
|
| 316 |
+
}
|
| 317 |
+
else {
|
| 318 |
+
return 'res-' + id.toString();
|
| 319 |
+
}
|
| 320 |
+
}
|
| 321 |
+
function createNotificationQueueKey() {
|
| 322 |
+
return 'not-' + (++notificationSequenceNumber).toString();
|
| 323 |
+
}
|
| 324 |
+
function addMessageToQueue(queue, message) {
|
| 325 |
+
if (messages_1.Message.isRequest(message)) {
|
| 326 |
+
queue.set(createRequestQueueKey(message.id), message);
|
| 327 |
+
}
|
| 328 |
+
else if (messages_1.Message.isResponse(message)) {
|
| 329 |
+
// If we have unlimited parallelism we queue the response to keep
|
| 330 |
+
// the previous semantics.
|
| 331 |
+
if (maxParallelism === -1) {
|
| 332 |
+
queue.set(createResponseQueueKey(message.id), message);
|
| 333 |
+
}
|
| 334 |
+
else {
|
| 335 |
+
// If we have limited parallelism we resolve responses to avoid
|
| 336 |
+
// dead locks.
|
| 337 |
+
handleResponse(message);
|
| 338 |
+
}
|
| 339 |
+
}
|
| 340 |
+
else {
|
| 341 |
+
queue.set(createNotificationQueueKey(), message);
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
function triggerMessageQueue() {
|
| 345 |
+
if (timer || messageQueue.size === 0) {
|
| 346 |
+
return;
|
| 347 |
+
}
|
| 348 |
+
if (maxParallelism !== -1 && inFlight >= maxParallelism) {
|
| 349 |
+
return;
|
| 350 |
+
}
|
| 351 |
+
timer = (0, ral_1.default)().timer.setImmediate(async () => {
|
| 352 |
+
timer = undefined;
|
| 353 |
+
if (messageQueue.size === 0) {
|
| 354 |
+
return;
|
| 355 |
+
}
|
| 356 |
+
if (maxParallelism !== -1 && inFlight >= maxParallelism) {
|
| 357 |
+
return;
|
| 358 |
+
}
|
| 359 |
+
const message = messageQueue.shift();
|
| 360 |
+
let result;
|
| 361 |
+
try {
|
| 362 |
+
inFlight++;
|
| 363 |
+
const messageStrategy = options?.messageStrategy;
|
| 364 |
+
if (MessageStrategy.is(messageStrategy)) {
|
| 365 |
+
result = messageStrategy.handleMessage(message, handleMessage);
|
| 366 |
+
}
|
| 367 |
+
else {
|
| 368 |
+
result = handleMessage(message);
|
| 369 |
+
}
|
| 370 |
+
}
|
| 371 |
+
catch (error) {
|
| 372 |
+
logger.error(`Processing message queue failed: ${error.toString()}`);
|
| 373 |
+
}
|
| 374 |
+
finally {
|
| 375 |
+
if (result instanceof Promise) {
|
| 376 |
+
result.then(() => {
|
| 377 |
+
inFlight--;
|
| 378 |
+
triggerMessageQueue();
|
| 379 |
+
}).catch((error) => {
|
| 380 |
+
logger.error(`Processing message queue failed: ${error.toString()}`);
|
| 381 |
+
});
|
| 382 |
+
}
|
| 383 |
+
else {
|
| 384 |
+
inFlight--;
|
| 385 |
+
}
|
| 386 |
+
triggerMessageQueue();
|
| 387 |
+
}
|
| 388 |
+
});
|
| 389 |
+
}
|
| 390 |
+
async function handleMessage(message) {
|
| 391 |
+
if (messages_1.Message.isRequest(message)) {
|
| 392 |
+
return handleRequest(message);
|
| 393 |
+
}
|
| 394 |
+
else if (messages_1.Message.isNotification(message)) {
|
| 395 |
+
return handleNotification(message);
|
| 396 |
+
}
|
| 397 |
+
else if (messages_1.Message.isResponse(message)) {
|
| 398 |
+
return handleResponse(message);
|
| 399 |
+
}
|
| 400 |
+
else {
|
| 401 |
+
return handleInvalidMessage(message);
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
const callback = (message) => {
|
| 405 |
+
try {
|
| 406 |
+
// We have received a cancellation message. Check if the message is still in the queue
|
| 407 |
+
// and cancel it if allowed to do so.
|
| 408 |
+
if (messages_1.Message.isNotification(message) && message.method === CancelNotification.type.method) {
|
| 409 |
+
const cancelId = message.params.id;
|
| 410 |
+
const key = createRequestQueueKey(cancelId);
|
| 411 |
+
const toCancel = messageQueue.get(key);
|
| 412 |
+
if (messages_1.Message.isRequest(toCancel)) {
|
| 413 |
+
const strategy = options?.connectionStrategy;
|
| 414 |
+
const response = (strategy && strategy.cancelUndispatched) ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
|
| 415 |
+
if (response && (response.error !== undefined || response.result !== undefined)) {
|
| 416 |
+
messageQueue.delete(key);
|
| 417 |
+
requestTokens.delete(cancelId);
|
| 418 |
+
response.id = toCancel.id;
|
| 419 |
+
traceSendingResponse(response, message.method, Date.now());
|
| 420 |
+
messageWriter.write(response).catch(() => logger.error(`Sending response for canceled message failed.`));
|
| 421 |
+
return;
|
| 422 |
+
}
|
| 423 |
+
}
|
| 424 |
+
const cancellationToken = requestTokens.get(cancelId);
|
| 425 |
+
// The request is already running. Cancel the token
|
| 426 |
+
if (cancellationToken !== undefined) {
|
| 427 |
+
cancellationToken.cancel();
|
| 428 |
+
traceReceivedNotification(message);
|
| 429 |
+
return;
|
| 430 |
+
}
|
| 431 |
+
else {
|
| 432 |
+
// Remember the cancel but still queue the message to
|
| 433 |
+
// clean up state in process message.
|
| 434 |
+
knownCanceledRequests.add(cancelId);
|
| 435 |
+
}
|
| 436 |
+
}
|
| 437 |
+
addMessageToQueue(messageQueue, message);
|
| 438 |
+
}
|
| 439 |
+
finally {
|
| 440 |
+
triggerMessageQueue();
|
| 441 |
+
}
|
| 442 |
+
};
|
| 443 |
+
async function handleRequest(requestMessage) {
|
| 444 |
+
if (isDisposed()) {
|
| 445 |
+
// we return here silently since we fired an event when the
|
| 446 |
+
// connection got disposed.
|
| 447 |
+
return Promise.resolve();
|
| 448 |
+
}
|
| 449 |
+
function reply(resultOrError, method, startTime) {
|
| 450 |
+
const message = {
|
| 451 |
+
jsonrpc: version,
|
| 452 |
+
id: requestMessage.id
|
| 453 |
+
};
|
| 454 |
+
if (resultOrError instanceof messages_1.ResponseError) {
|
| 455 |
+
message.error = resultOrError.toJson();
|
| 456 |
+
}
|
| 457 |
+
else {
|
| 458 |
+
message.result = resultOrError === undefined ? null : resultOrError;
|
| 459 |
+
}
|
| 460 |
+
traceSendingResponse(message, method, startTime);
|
| 461 |
+
return messageWriter.write(message);
|
| 462 |
+
}
|
| 463 |
+
function replyError(error, method, startTime) {
|
| 464 |
+
const message = {
|
| 465 |
+
jsonrpc: version,
|
| 466 |
+
id: requestMessage.id,
|
| 467 |
+
error: error.toJson()
|
| 468 |
+
};
|
| 469 |
+
traceSendingResponse(message, method, startTime);
|
| 470 |
+
return messageWriter.write(message);
|
| 471 |
+
}
|
| 472 |
+
traceReceivedRequest(requestMessage);
|
| 473 |
+
const element = requestHandlers.get(requestMessage.method);
|
| 474 |
+
let type;
|
| 475 |
+
let requestHandler;
|
| 476 |
+
if (element) {
|
| 477 |
+
type = element.type;
|
| 478 |
+
requestHandler = element.handler;
|
| 479 |
+
}
|
| 480 |
+
const startTime = Date.now();
|
| 481 |
+
if (requestHandler || starRequestHandler) {
|
| 482 |
+
const tokenKey = requestMessage.id ?? String(Date.now()); //
|
| 483 |
+
const cancellationSource = IdCancellationReceiverStrategy.is(cancellationStrategy.receiver)
|
| 484 |
+
? cancellationStrategy.receiver.createCancellationTokenSource(tokenKey)
|
| 485 |
+
: cancellationStrategy.receiver.createCancellationTokenSource(requestMessage);
|
| 486 |
+
if (requestMessage.id !== null && knownCanceledRequests.has(requestMessage.id)) {
|
| 487 |
+
cancellationSource.cancel();
|
| 488 |
+
}
|
| 489 |
+
if (requestMessage.id !== null) {
|
| 490 |
+
requestTokens.set(tokenKey, cancellationSource);
|
| 491 |
+
}
|
| 492 |
+
try {
|
| 493 |
+
let handlerResult;
|
| 494 |
+
if (requestHandler) {
|
| 495 |
+
if (requestMessage.params === undefined) {
|
| 496 |
+
if (type !== undefined && type.numberOfParams !== 0) {
|
| 497 |
+
return replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines ${type.numberOfParams} params but received none.`), requestMessage.method, startTime);
|
| 498 |
+
}
|
| 499 |
+
handlerResult = requestHandler(cancellationSource.token);
|
| 500 |
+
}
|
| 501 |
+
else if (Array.isArray(requestMessage.params)) {
|
| 502 |
+
if (type !== undefined && type.parameterStructures === messages_1.ParameterStructures.byName) {
|
| 503 |
+
return replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by name but received parameters by position`), requestMessage.method, startTime);
|
| 504 |
+
}
|
| 505 |
+
handlerResult = requestHandler(...requestMessage.params, cancellationSource.token);
|
| 506 |
+
}
|
| 507 |
+
else {
|
| 508 |
+
if (type !== undefined && type.parameterStructures === messages_1.ParameterStructures.byPosition) {
|
| 509 |
+
return replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InvalidParams, `Request ${requestMessage.method} defines parameters by position but received parameters by name`), requestMessage.method, startTime);
|
| 510 |
+
}
|
| 511 |
+
handlerResult = requestHandler(requestMessage.params, cancellationSource.token);
|
| 512 |
+
}
|
| 513 |
+
}
|
| 514 |
+
else if (starRequestHandler) {
|
| 515 |
+
handlerResult = starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
|
| 516 |
+
}
|
| 517 |
+
const resultOrError = await handlerResult;
|
| 518 |
+
await reply(resultOrError, requestMessage.method, startTime);
|
| 519 |
+
}
|
| 520 |
+
catch (error) {
|
| 521 |
+
if (error instanceof messages_1.ResponseError) {
|
| 522 |
+
await reply(error, requestMessage.method, startTime);
|
| 523 |
+
}
|
| 524 |
+
else if (error && Is.string(error.message)) {
|
| 525 |
+
await replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
|
| 526 |
+
}
|
| 527 |
+
else {
|
| 528 |
+
await replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
|
| 529 |
+
}
|
| 530 |
+
}
|
| 531 |
+
finally {
|
| 532 |
+
requestTokens.delete(tokenKey);
|
| 533 |
+
}
|
| 534 |
+
}
|
| 535 |
+
else {
|
| 536 |
+
await replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
|
| 537 |
+
}
|
| 538 |
+
}
|
| 539 |
+
function handleResponse(responseMessage) {
|
| 540 |
+
if (isDisposed()) {
|
| 541 |
+
// See handle request.
|
| 542 |
+
return;
|
| 543 |
+
}
|
| 544 |
+
if (responseMessage.id === null) {
|
| 545 |
+
if (responseMessage.error) {
|
| 546 |
+
logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
|
| 547 |
+
}
|
| 548 |
+
else {
|
| 549 |
+
logger.error(`Received response message without id. No further error information provided.`);
|
| 550 |
+
}
|
| 551 |
+
}
|
| 552 |
+
else {
|
| 553 |
+
const key = responseMessage.id;
|
| 554 |
+
const responsePromise = responsePromises.get(key);
|
| 555 |
+
traceReceivedResponse(responseMessage, responsePromise);
|
| 556 |
+
if (responsePromise !== undefined) {
|
| 557 |
+
responsePromises.delete(key);
|
| 558 |
+
try {
|
| 559 |
+
if (responseMessage.error) {
|
| 560 |
+
const error = responseMessage.error;
|
| 561 |
+
responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
|
| 562 |
+
}
|
| 563 |
+
else if (responseMessage.result !== undefined) {
|
| 564 |
+
responsePromise.resolve(responseMessage.result);
|
| 565 |
+
}
|
| 566 |
+
else {
|
| 567 |
+
throw new Error('Should never happen.');
|
| 568 |
+
}
|
| 569 |
+
}
|
| 570 |
+
catch (error) {
|
| 571 |
+
if (error.message) {
|
| 572 |
+
logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
|
| 573 |
+
}
|
| 574 |
+
else {
|
| 575 |
+
logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
|
| 576 |
+
}
|
| 577 |
+
}
|
| 578 |
+
}
|
| 579 |
+
}
|
| 580 |
+
}
|
| 581 |
+
async function handleNotification(message) {
|
| 582 |
+
if (isDisposed()) {
|
| 583 |
+
// See handle request.
|
| 584 |
+
return;
|
| 585 |
+
}
|
| 586 |
+
let type = undefined;
|
| 587 |
+
let notificationHandler;
|
| 588 |
+
if (message.method === CancelNotification.type.method) {
|
| 589 |
+
const cancelId = message.params.id;
|
| 590 |
+
knownCanceledRequests.delete(cancelId);
|
| 591 |
+
traceReceivedNotification(message);
|
| 592 |
+
return;
|
| 593 |
+
}
|
| 594 |
+
else {
|
| 595 |
+
const element = notificationHandlers.get(message.method);
|
| 596 |
+
if (element) {
|
| 597 |
+
notificationHandler = element.handler;
|
| 598 |
+
type = element.type;
|
| 599 |
+
}
|
| 600 |
+
}
|
| 601 |
+
if (notificationHandler || starNotificationHandler) {
|
| 602 |
+
try {
|
| 603 |
+
traceReceivedNotification(message);
|
| 604 |
+
if (notificationHandler) {
|
| 605 |
+
if (message.params === undefined) {
|
| 606 |
+
if (type !== undefined) {
|
| 607 |
+
if (type.numberOfParams !== 0 && type.parameterStructures !== messages_1.ParameterStructures.byName) {
|
| 608 |
+
logger.error(`Notification ${message.method} defines ${type.numberOfParams} params but received none.`);
|
| 609 |
+
}
|
| 610 |
+
}
|
| 611 |
+
await notificationHandler();
|
| 612 |
+
}
|
| 613 |
+
else if (Array.isArray(message.params)) {
|
| 614 |
+
// There are JSON-RPC libraries that send progress message as positional params although
|
| 615 |
+
// specified as named. So convert them if this is the case.
|
| 616 |
+
const params = message.params;
|
| 617 |
+
if (message.method === ProgressNotification.type.method && params.length === 2 && ProgressToken.is(params[0])) {
|
| 618 |
+
await notificationHandler({ token: params[0], value: params[1] });
|
| 619 |
+
}
|
| 620 |
+
else {
|
| 621 |
+
if (type !== undefined) {
|
| 622 |
+
if (type.parameterStructures === messages_1.ParameterStructures.byName) {
|
| 623 |
+
logger.error(`Notification ${message.method} defines parameters by name but received parameters by position`);
|
| 624 |
+
}
|
| 625 |
+
if (type.numberOfParams !== message.params.length) {
|
| 626 |
+
logger.error(`Notification ${message.method} defines ${type.numberOfParams} params but received ${params.length} arguments`);
|
| 627 |
+
}
|
| 628 |
+
}
|
| 629 |
+
await notificationHandler(...params);
|
| 630 |
+
}
|
| 631 |
+
}
|
| 632 |
+
else {
|
| 633 |
+
if (type !== undefined && type.parameterStructures === messages_1.ParameterStructures.byPosition) {
|
| 634 |
+
logger.error(`Notification ${message.method} defines parameters by position but received parameters by name`);
|
| 635 |
+
}
|
| 636 |
+
await notificationHandler(message.params);
|
| 637 |
+
}
|
| 638 |
+
}
|
| 639 |
+
else if (starNotificationHandler) {
|
| 640 |
+
await starNotificationHandler(message.method, message.params);
|
| 641 |
+
}
|
| 642 |
+
}
|
| 643 |
+
catch (error) {
|
| 644 |
+
if (error.message) {
|
| 645 |
+
logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
|
| 646 |
+
}
|
| 647 |
+
else {
|
| 648 |
+
logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
|
| 649 |
+
}
|
| 650 |
+
}
|
| 651 |
+
}
|
| 652 |
+
else {
|
| 653 |
+
unhandledNotificationEmitter.fire(message);
|
| 654 |
+
}
|
| 655 |
+
}
|
| 656 |
+
function handleInvalidMessage(message) {
|
| 657 |
+
if (!message) {
|
| 658 |
+
logger.error('Received empty message.');
|
| 659 |
+
return;
|
| 660 |
+
}
|
| 661 |
+
logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
|
| 662 |
+
// Test whether we find an id to reject the promise
|
| 663 |
+
const responseMessage = message;
|
| 664 |
+
if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
|
| 665 |
+
const key = responseMessage.id;
|
| 666 |
+
const responseHandler = responsePromises.get(key);
|
| 667 |
+
if (responseHandler) {
|
| 668 |
+
responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
|
| 669 |
+
}
|
| 670 |
+
}
|
| 671 |
+
}
|
| 672 |
+
function stringifyTrace(params) {
|
| 673 |
+
if (params === undefined || params === null) {
|
| 674 |
+
return undefined;
|
| 675 |
+
}
|
| 676 |
+
switch (trace) {
|
| 677 |
+
case Trace.Verbose:
|
| 678 |
+
return JSON.stringify(params, null, 4);
|
| 679 |
+
case Trace.Compact:
|
| 680 |
+
return JSON.stringify(params);
|
| 681 |
+
default:
|
| 682 |
+
return undefined;
|
| 683 |
+
}
|
| 684 |
+
}
|
| 685 |
+
function traceSendingRequest(message) {
|
| 686 |
+
if (trace === Trace.Off || !tracer) {
|
| 687 |
+
return;
|
| 688 |
+
}
|
| 689 |
+
if (traceFormat === TraceFormat.Text) {
|
| 690 |
+
let data = undefined;
|
| 691 |
+
if ((trace === Trace.Verbose || trace === Trace.Compact) && message.params) {
|
| 692 |
+
data = `Params: ${stringifyTrace(message.params)}\n\n`;
|
| 693 |
+
}
|
| 694 |
+
tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
|
| 695 |
+
}
|
| 696 |
+
else {
|
| 697 |
+
logLSPMessage('send-request', message);
|
| 698 |
+
}
|
| 699 |
+
}
|
| 700 |
+
function traceSendingNotification(message) {
|
| 701 |
+
if (trace === Trace.Off || !tracer) {
|
| 702 |
+
return;
|
| 703 |
+
}
|
| 704 |
+
if (traceFormat === TraceFormat.Text) {
|
| 705 |
+
let data = undefined;
|
| 706 |
+
if (trace === Trace.Verbose || trace === Trace.Compact) {
|
| 707 |
+
if (message.params) {
|
| 708 |
+
data = `Params: ${stringifyTrace(message.params)}\n\n`;
|
| 709 |
+
}
|
| 710 |
+
else {
|
| 711 |
+
data = 'No parameters provided.\n\n';
|
| 712 |
+
}
|
| 713 |
+
}
|
| 714 |
+
tracer.log(`Sending notification '${message.method}'.`, data);
|
| 715 |
+
}
|
| 716 |
+
else {
|
| 717 |
+
logLSPMessage('send-notification', message);
|
| 718 |
+
}
|
| 719 |
+
}
|
| 720 |
+
function traceSendingResponse(message, method, startTime) {
|
| 721 |
+
if (trace === Trace.Off || !tracer) {
|
| 722 |
+
return;
|
| 723 |
+
}
|
| 724 |
+
if (traceFormat === TraceFormat.Text) {
|
| 725 |
+
let data = undefined;
|
| 726 |
+
if (trace === Trace.Verbose || trace === Trace.Compact) {
|
| 727 |
+
if (message.error && message.error.data) {
|
| 728 |
+
data = `Error data: ${stringifyTrace(message.error.data)}\n\n`;
|
| 729 |
+
}
|
| 730 |
+
else {
|
| 731 |
+
if (message.result) {
|
| 732 |
+
data = `Result: ${stringifyTrace(message.result)}\n\n`;
|
| 733 |
+
}
|
| 734 |
+
else if (message.error === undefined) {
|
| 735 |
+
data = 'No result returned.\n\n';
|
| 736 |
+
}
|
| 737 |
+
}
|
| 738 |
+
}
|
| 739 |
+
tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
|
| 740 |
+
}
|
| 741 |
+
else {
|
| 742 |
+
logLSPMessage('send-response', message);
|
| 743 |
+
}
|
| 744 |
+
}
|
| 745 |
+
function traceReceivedRequest(message) {
|
| 746 |
+
if (trace === Trace.Off || !tracer) {
|
| 747 |
+
return;
|
| 748 |
+
}
|
| 749 |
+
if (traceFormat === TraceFormat.Text) {
|
| 750 |
+
let data = undefined;
|
| 751 |
+
if ((trace === Trace.Verbose || trace === Trace.Compact) && message.params) {
|
| 752 |
+
data = `Params: ${stringifyTrace(message.params)}\n\n`;
|
| 753 |
+
}
|
| 754 |
+
tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
|
| 755 |
+
}
|
| 756 |
+
else {
|
| 757 |
+
logLSPMessage('receive-request', message);
|
| 758 |
+
}
|
| 759 |
+
}
|
| 760 |
+
function traceReceivedNotification(message) {
|
| 761 |
+
if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
|
| 762 |
+
return;
|
| 763 |
+
}
|
| 764 |
+
if (traceFormat === TraceFormat.Text) {
|
| 765 |
+
let data = undefined;
|
| 766 |
+
if (trace === Trace.Verbose || trace === Trace.Compact) {
|
| 767 |
+
if (message.params) {
|
| 768 |
+
data = `Params: ${stringifyTrace(message.params)}\n\n`;
|
| 769 |
+
}
|
| 770 |
+
else {
|
| 771 |
+
data = 'No parameters provided.\n\n';
|
| 772 |
+
}
|
| 773 |
+
}
|
| 774 |
+
tracer.log(`Received notification '${message.method}'.`, data);
|
| 775 |
+
}
|
| 776 |
+
else {
|
| 777 |
+
logLSPMessage('receive-notification', message);
|
| 778 |
+
}
|
| 779 |
+
}
|
| 780 |
+
function traceReceivedResponse(message, responsePromise) {
|
| 781 |
+
if (trace === Trace.Off || !tracer) {
|
| 782 |
+
return;
|
| 783 |
+
}
|
| 784 |
+
if (traceFormat === TraceFormat.Text) {
|
| 785 |
+
let data = undefined;
|
| 786 |
+
if (trace === Trace.Verbose || trace === Trace.Compact) {
|
| 787 |
+
if (message.error && message.error.data) {
|
| 788 |
+
data = `Error data: ${stringifyTrace(message.error.data)}\n\n`;
|
| 789 |
+
}
|
| 790 |
+
else {
|
| 791 |
+
if (message.result) {
|
| 792 |
+
data = `Result: ${stringifyTrace(message.result)}\n\n`;
|
| 793 |
+
}
|
| 794 |
+
else if (message.error === undefined) {
|
| 795 |
+
data = 'No result returned.\n\n';
|
| 796 |
+
}
|
| 797 |
+
}
|
| 798 |
+
}
|
| 799 |
+
if (responsePromise) {
|
| 800 |
+
const error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
|
| 801 |
+
tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
|
| 802 |
+
}
|
| 803 |
+
else {
|
| 804 |
+
tracer.log(`Received response ${message.id} without active response promise.`, data);
|
| 805 |
+
}
|
| 806 |
+
}
|
| 807 |
+
else {
|
| 808 |
+
logLSPMessage('receive-response', message);
|
| 809 |
+
}
|
| 810 |
+
}
|
| 811 |
+
function logLSPMessage(type, message) {
|
| 812 |
+
if (!tracer || trace === Trace.Off) {
|
| 813 |
+
return;
|
| 814 |
+
}
|
| 815 |
+
const lspMessage = {
|
| 816 |
+
isLSPMessage: true,
|
| 817 |
+
type,
|
| 818 |
+
message,
|
| 819 |
+
timestamp: Date.now()
|
| 820 |
+
};
|
| 821 |
+
tracer.log(lspMessage);
|
| 822 |
+
}
|
| 823 |
+
function throwIfClosedOrDisposed() {
|
| 824 |
+
if (isClosed()) {
|
| 825 |
+
throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
|
| 826 |
+
}
|
| 827 |
+
if (isDisposed()) {
|
| 828 |
+
throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
|
| 829 |
+
}
|
| 830 |
+
}
|
| 831 |
+
function throwIfListening() {
|
| 832 |
+
if (isListening()) {
|
| 833 |
+
throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
|
| 834 |
+
}
|
| 835 |
+
}
|
| 836 |
+
function throwIfNotListening() {
|
| 837 |
+
if (!isListening()) {
|
| 838 |
+
throw new Error('Call listen() first.');
|
| 839 |
+
}
|
| 840 |
+
}
|
| 841 |
+
function undefinedToNull(param) {
|
| 842 |
+
if (param === undefined) {
|
| 843 |
+
return null;
|
| 844 |
+
}
|
| 845 |
+
else {
|
| 846 |
+
return param;
|
| 847 |
+
}
|
| 848 |
+
}
|
| 849 |
+
function nullToUndefined(param) {
|
| 850 |
+
if (param === null) {
|
| 851 |
+
return undefined;
|
| 852 |
+
}
|
| 853 |
+
else {
|
| 854 |
+
return param;
|
| 855 |
+
}
|
| 856 |
+
}
|
| 857 |
+
function isNamedParam(param) {
|
| 858 |
+
return param !== undefined && param !== null && !Array.isArray(param) && typeof param === 'object';
|
| 859 |
+
}
|
| 860 |
+
function computeSingleParam(parameterStructures, param) {
|
| 861 |
+
switch (parameterStructures) {
|
| 862 |
+
case messages_1.ParameterStructures.auto:
|
| 863 |
+
if (isNamedParam(param)) {
|
| 864 |
+
return nullToUndefined(param);
|
| 865 |
+
}
|
| 866 |
+
else {
|
| 867 |
+
return [undefinedToNull(param)];
|
| 868 |
+
}
|
| 869 |
+
case messages_1.ParameterStructures.byName:
|
| 870 |
+
if (!isNamedParam(param)) {
|
| 871 |
+
throw new Error(`Received parameters by name but param is not an object literal.`);
|
| 872 |
+
}
|
| 873 |
+
return nullToUndefined(param);
|
| 874 |
+
case messages_1.ParameterStructures.byPosition:
|
| 875 |
+
return [undefinedToNull(param)];
|
| 876 |
+
default:
|
| 877 |
+
throw new Error(`Unknown parameter structure ${parameterStructures.toString()}`);
|
| 878 |
+
}
|
| 879 |
+
}
|
| 880 |
+
function computeMessageParams(type, params) {
|
| 881 |
+
let result;
|
| 882 |
+
const numberOfParams = type.numberOfParams;
|
| 883 |
+
switch (numberOfParams) {
|
| 884 |
+
case 0:
|
| 885 |
+
result = undefined;
|
| 886 |
+
break;
|
| 887 |
+
case 1:
|
| 888 |
+
result = computeSingleParam(type.parameterStructures, params[0]);
|
| 889 |
+
break;
|
| 890 |
+
default:
|
| 891 |
+
result = [];
|
| 892 |
+
for (let i = 0; i < params.length && i < numberOfParams; i++) {
|
| 893 |
+
result.push(undefinedToNull(params[i]));
|
| 894 |
+
}
|
| 895 |
+
if (params.length < numberOfParams) {
|
| 896 |
+
for (let i = params.length; i < numberOfParams; i++) {
|
| 897 |
+
result.push(null);
|
| 898 |
+
}
|
| 899 |
+
}
|
| 900 |
+
break;
|
| 901 |
+
}
|
| 902 |
+
return result;
|
| 903 |
+
}
|
| 904 |
+
const connection = {
|
| 905 |
+
sendNotification: (type, ...args) => {
|
| 906 |
+
throwIfClosedOrDisposed();
|
| 907 |
+
let method;
|
| 908 |
+
let messageParams;
|
| 909 |
+
if (Is.string(type)) {
|
| 910 |
+
method = type;
|
| 911 |
+
const first = args[0];
|
| 912 |
+
let paramStart = 0;
|
| 913 |
+
let parameterStructures = messages_1.ParameterStructures.auto;
|
| 914 |
+
if (messages_1.ParameterStructures.is(first)) {
|
| 915 |
+
paramStart = 1;
|
| 916 |
+
parameterStructures = first;
|
| 917 |
+
}
|
| 918 |
+
const paramEnd = args.length;
|
| 919 |
+
const numberOfParams = paramEnd - paramStart;
|
| 920 |
+
switch (numberOfParams) {
|
| 921 |
+
case 0:
|
| 922 |
+
messageParams = undefined;
|
| 923 |
+
break;
|
| 924 |
+
case 1:
|
| 925 |
+
messageParams = computeSingleParam(parameterStructures, args[paramStart]);
|
| 926 |
+
break;
|
| 927 |
+
default:
|
| 928 |
+
if (parameterStructures === messages_1.ParameterStructures.byName) {
|
| 929 |
+
throw new Error(`Received ${numberOfParams} parameters for 'by Name' notification parameter structure.`);
|
| 930 |
+
}
|
| 931 |
+
messageParams = args.slice(paramStart, paramEnd).map(value => undefinedToNull(value));
|
| 932 |
+
break;
|
| 933 |
+
}
|
| 934 |
+
}
|
| 935 |
+
else {
|
| 936 |
+
const params = args;
|
| 937 |
+
method = type.method;
|
| 938 |
+
messageParams = computeMessageParams(type, params);
|
| 939 |
+
}
|
| 940 |
+
const notificationMessage = {
|
| 941 |
+
jsonrpc: version,
|
| 942 |
+
method: method,
|
| 943 |
+
params: messageParams
|
| 944 |
+
};
|
| 945 |
+
traceSendingNotification(notificationMessage);
|
| 946 |
+
return messageWriter.write(notificationMessage).catch((error) => {
|
| 947 |
+
logger.error(`Sending notification failed.`);
|
| 948 |
+
throw error;
|
| 949 |
+
});
|
| 950 |
+
},
|
| 951 |
+
onNotification: (type, handler) => {
|
| 952 |
+
throwIfClosedOrDisposed();
|
| 953 |
+
let method;
|
| 954 |
+
if (Is.func(type)) {
|
| 955 |
+
starNotificationHandler = type;
|
| 956 |
+
}
|
| 957 |
+
else if (handler) {
|
| 958 |
+
if (Is.string(type)) {
|
| 959 |
+
method = type;
|
| 960 |
+
notificationHandlers.set(type, { type: undefined, handler });
|
| 961 |
+
}
|
| 962 |
+
else {
|
| 963 |
+
method = type.method;
|
| 964 |
+
notificationHandlers.set(type.method, { type, handler });
|
| 965 |
+
}
|
| 966 |
+
}
|
| 967 |
+
return {
|
| 968 |
+
dispose: () => {
|
| 969 |
+
if (method !== undefined) {
|
| 970 |
+
notificationHandlers.delete(method);
|
| 971 |
+
}
|
| 972 |
+
else {
|
| 973 |
+
starNotificationHandler = undefined;
|
| 974 |
+
}
|
| 975 |
+
}
|
| 976 |
+
};
|
| 977 |
+
},
|
| 978 |
+
onProgress: (_type, token, handler) => {
|
| 979 |
+
if (progressHandlers.has(token)) {
|
| 980 |
+
throw new Error(`Progress handler for token ${token} already registered`);
|
| 981 |
+
}
|
| 982 |
+
progressHandlers.set(token, handler);
|
| 983 |
+
return {
|
| 984 |
+
dispose: () => {
|
| 985 |
+
progressHandlers.delete(token);
|
| 986 |
+
}
|
| 987 |
+
};
|
| 988 |
+
},
|
| 989 |
+
sendProgress: (_type, token, value) => {
|
| 990 |
+
// This should not await but simple return to ensure that we don't have another
|
| 991 |
+
// async scheduling. Otherwise one send could overtake another send.
|
| 992 |
+
return connection.sendNotification(ProgressNotification.type, { token, value });
|
| 993 |
+
},
|
| 994 |
+
onUnhandledProgress: unhandledProgressEmitter.event,
|
| 995 |
+
sendRequest: (type, ...args) => {
|
| 996 |
+
throwIfClosedOrDisposed();
|
| 997 |
+
throwIfNotListening();
|
| 998 |
+
function sendCancellation(connection, id) {
|
| 999 |
+
const p = cancellationStrategy.sender.sendCancellation(connection, id);
|
| 1000 |
+
if (p === undefined) {
|
| 1001 |
+
logger.log(`Received no promise from cancellation strategy when cancelling id ${id}`);
|
| 1002 |
+
}
|
| 1003 |
+
else {
|
| 1004 |
+
p.catch(() => {
|
| 1005 |
+
logger.log(`Sending cancellation messages for id ${id} failed.`);
|
| 1006 |
+
});
|
| 1007 |
+
}
|
| 1008 |
+
}
|
| 1009 |
+
let method;
|
| 1010 |
+
let messageParams;
|
| 1011 |
+
let token = undefined;
|
| 1012 |
+
if (Is.string(type)) {
|
| 1013 |
+
method = type;
|
| 1014 |
+
const first = args[0];
|
| 1015 |
+
const last = args[args.length - 1];
|
| 1016 |
+
let paramStart = 0;
|
| 1017 |
+
let parameterStructures = messages_1.ParameterStructures.auto;
|
| 1018 |
+
if (messages_1.ParameterStructures.is(first)) {
|
| 1019 |
+
paramStart = 1;
|
| 1020 |
+
parameterStructures = first;
|
| 1021 |
+
}
|
| 1022 |
+
let paramEnd = args.length;
|
| 1023 |
+
if (cancellation_1.CancellationToken.is(last)) {
|
| 1024 |
+
paramEnd = paramEnd - 1;
|
| 1025 |
+
token = last;
|
| 1026 |
+
}
|
| 1027 |
+
const numberOfParams = paramEnd - paramStart;
|
| 1028 |
+
switch (numberOfParams) {
|
| 1029 |
+
case 0:
|
| 1030 |
+
messageParams = undefined;
|
| 1031 |
+
break;
|
| 1032 |
+
case 1:
|
| 1033 |
+
messageParams = computeSingleParam(parameterStructures, args[paramStart]);
|
| 1034 |
+
break;
|
| 1035 |
+
default:
|
| 1036 |
+
if (parameterStructures === messages_1.ParameterStructures.byName) {
|
| 1037 |
+
throw new Error(`Received ${numberOfParams} parameters for 'by Name' request parameter structure.`);
|
| 1038 |
+
}
|
| 1039 |
+
messageParams = args.slice(paramStart, paramEnd).map(value => undefinedToNull(value));
|
| 1040 |
+
break;
|
| 1041 |
+
}
|
| 1042 |
+
}
|
| 1043 |
+
else {
|
| 1044 |
+
const params = args;
|
| 1045 |
+
method = type.method;
|
| 1046 |
+
messageParams = computeMessageParams(type, params);
|
| 1047 |
+
const numberOfParams = type.numberOfParams;
|
| 1048 |
+
token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
|
| 1049 |
+
}
|
| 1050 |
+
const id = sequenceNumber++;
|
| 1051 |
+
let disposable;
|
| 1052 |
+
let tokenWasCancelled = false;
|
| 1053 |
+
if (token !== undefined) {
|
| 1054 |
+
if (token.isCancellationRequested) {
|
| 1055 |
+
tokenWasCancelled = true;
|
| 1056 |
+
}
|
| 1057 |
+
else {
|
| 1058 |
+
disposable = token.onCancellationRequested(() => {
|
| 1059 |
+
sendCancellation(connection, id);
|
| 1060 |
+
});
|
| 1061 |
+
}
|
| 1062 |
+
}
|
| 1063 |
+
const requestMessage = {
|
| 1064 |
+
jsonrpc: version,
|
| 1065 |
+
id: id,
|
| 1066 |
+
method: method,
|
| 1067 |
+
params: messageParams
|
| 1068 |
+
};
|
| 1069 |
+
traceSendingRequest(requestMessage);
|
| 1070 |
+
if (typeof cancellationStrategy.sender.enableCancellation === 'function') {
|
| 1071 |
+
cancellationStrategy.sender.enableCancellation(requestMessage);
|
| 1072 |
+
}
|
| 1073 |
+
// eslint-disable-next-line no-async-promise-executor
|
| 1074 |
+
return new Promise(async (resolve, reject) => {
|
| 1075 |
+
const resolveWithCleanup = (r) => {
|
| 1076 |
+
resolve(r);
|
| 1077 |
+
cancellationStrategy.sender.cleanup(id);
|
| 1078 |
+
disposable?.dispose();
|
| 1079 |
+
};
|
| 1080 |
+
const rejectWithCleanup = (r) => {
|
| 1081 |
+
reject(r);
|
| 1082 |
+
cancellationStrategy.sender.cleanup(id);
|
| 1083 |
+
disposable?.dispose();
|
| 1084 |
+
};
|
| 1085 |
+
const responsePromise = { method: method, timerStart: Date.now(), resolve: resolveWithCleanup, reject: rejectWithCleanup };
|
| 1086 |
+
try {
|
| 1087 |
+
await messageWriter.write(requestMessage);
|
| 1088 |
+
responsePromises.set(id, responsePromise);
|
| 1089 |
+
if (tokenWasCancelled) {
|
| 1090 |
+
sendCancellation(connection, id);
|
| 1091 |
+
}
|
| 1092 |
+
}
|
| 1093 |
+
catch (error) {
|
| 1094 |
+
logger.error(`Sending request failed.`);
|
| 1095 |
+
// Writing the message failed. So we need to reject the promise.
|
| 1096 |
+
responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, error.message ? error.message : 'Unknown reason'));
|
| 1097 |
+
throw error;
|
| 1098 |
+
}
|
| 1099 |
+
});
|
| 1100 |
+
},
|
| 1101 |
+
onRequest: (type, handler) => {
|
| 1102 |
+
throwIfClosedOrDisposed();
|
| 1103 |
+
let method = null;
|
| 1104 |
+
if (StarRequestHandler.is(type)) {
|
| 1105 |
+
method = undefined;
|
| 1106 |
+
starRequestHandler = type;
|
| 1107 |
+
}
|
| 1108 |
+
else if (Is.string(type)) {
|
| 1109 |
+
method = null;
|
| 1110 |
+
if (handler !== undefined) {
|
| 1111 |
+
method = type;
|
| 1112 |
+
requestHandlers.set(type, { handler: handler, type: undefined });
|
| 1113 |
+
}
|
| 1114 |
+
}
|
| 1115 |
+
else {
|
| 1116 |
+
if (handler !== undefined) {
|
| 1117 |
+
method = type.method;
|
| 1118 |
+
requestHandlers.set(type.method, { type, handler });
|
| 1119 |
+
}
|
| 1120 |
+
}
|
| 1121 |
+
return {
|
| 1122 |
+
dispose: () => {
|
| 1123 |
+
if (method === null) {
|
| 1124 |
+
return;
|
| 1125 |
+
}
|
| 1126 |
+
if (method !== undefined) {
|
| 1127 |
+
requestHandlers.delete(method);
|
| 1128 |
+
}
|
| 1129 |
+
else {
|
| 1130 |
+
starRequestHandler = undefined;
|
| 1131 |
+
}
|
| 1132 |
+
}
|
| 1133 |
+
};
|
| 1134 |
+
},
|
| 1135 |
+
hasPendingResponse: () => {
|
| 1136 |
+
return responsePromises.size > 0;
|
| 1137 |
+
},
|
| 1138 |
+
trace: async (_value, _tracer, sendNotificationOrTraceOptions) => {
|
| 1139 |
+
let _sendNotification = false;
|
| 1140 |
+
let _traceFormat = TraceFormat.Text;
|
| 1141 |
+
if (sendNotificationOrTraceOptions !== undefined) {
|
| 1142 |
+
if (Is.boolean(sendNotificationOrTraceOptions)) {
|
| 1143 |
+
_sendNotification = sendNotificationOrTraceOptions;
|
| 1144 |
+
}
|
| 1145 |
+
else {
|
| 1146 |
+
_sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
|
| 1147 |
+
_traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
|
| 1148 |
+
}
|
| 1149 |
+
}
|
| 1150 |
+
trace = _value;
|
| 1151 |
+
traceFormat = _traceFormat;
|
| 1152 |
+
if (trace === Trace.Off) {
|
| 1153 |
+
tracer = undefined;
|
| 1154 |
+
}
|
| 1155 |
+
else {
|
| 1156 |
+
tracer = _tracer;
|
| 1157 |
+
}
|
| 1158 |
+
if (_sendNotification && !isClosed() && !isDisposed()) {
|
| 1159 |
+
await connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
|
| 1160 |
+
}
|
| 1161 |
+
},
|
| 1162 |
+
onError: errorEmitter.event,
|
| 1163 |
+
onClose: closeEmitter.event,
|
| 1164 |
+
onUnhandledNotification: unhandledNotificationEmitter.event,
|
| 1165 |
+
onDispose: disposeEmitter.event,
|
| 1166 |
+
end: () => {
|
| 1167 |
+
messageWriter.end();
|
| 1168 |
+
},
|
| 1169 |
+
dispose: () => {
|
| 1170 |
+
if (isDisposed()) {
|
| 1171 |
+
return;
|
| 1172 |
+
}
|
| 1173 |
+
state = ConnectionState.Disposed;
|
| 1174 |
+
disposeEmitter.fire(undefined);
|
| 1175 |
+
const error = new messages_1.ResponseError(messages_1.ErrorCodes.PendingResponseRejected, 'Pending response rejected since connection got disposed');
|
| 1176 |
+
for (const promise of responsePromises.values()) {
|
| 1177 |
+
promise.reject(error);
|
| 1178 |
+
}
|
| 1179 |
+
responsePromises = new Map();
|
| 1180 |
+
requestTokens = new Map();
|
| 1181 |
+
knownCanceledRequests = new Set();
|
| 1182 |
+
messageQueue = new linkedMap_1.LinkedMap();
|
| 1183 |
+
// Test for backwards compatibility
|
| 1184 |
+
if (Is.func(messageWriter.dispose)) {
|
| 1185 |
+
messageWriter.dispose();
|
| 1186 |
+
}
|
| 1187 |
+
if (Is.func(messageReader.dispose)) {
|
| 1188 |
+
messageReader.dispose();
|
| 1189 |
+
}
|
| 1190 |
+
},
|
| 1191 |
+
listen: () => {
|
| 1192 |
+
throwIfClosedOrDisposed();
|
| 1193 |
+
throwIfListening();
|
| 1194 |
+
state = ConnectionState.Listening;
|
| 1195 |
+
messageReader.listen(callback);
|
| 1196 |
+
},
|
| 1197 |
+
inspect: () => {
|
| 1198 |
+
// eslint-disable-next-line no-console
|
| 1199 |
+
(0, ral_1.default)().console.log('inspect');
|
| 1200 |
+
}
|
| 1201 |
+
};
|
| 1202 |
+
connection.onNotification(LogTraceNotification.type, (params) => {
|
| 1203 |
+
if (trace === Trace.Off || !tracer) {
|
| 1204 |
+
return;
|
| 1205 |
+
}
|
| 1206 |
+
const verbose = trace === Trace.Verbose || trace === Trace.Compact;
|
| 1207 |
+
tracer.log(params.message, verbose ? params.verbose : undefined);
|
| 1208 |
+
});
|
| 1209 |
+
connection.onNotification(ProgressNotification.type, async (params) => {
|
| 1210 |
+
const handler = progressHandlers.get(params.token);
|
| 1211 |
+
if (handler) {
|
| 1212 |
+
await handler(params.value);
|
| 1213 |
+
}
|
| 1214 |
+
else {
|
| 1215 |
+
unhandledProgressEmitter.fire(params);
|
| 1216 |
+
}
|
| 1217 |
+
});
|
| 1218 |
+
return connection;
|
| 1219 |
+
}
|
| 1220 |
+
exports.createMessageConnection = createMessageConnection;
|