@harmoniclabs/monaco-editor 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.azure-pipelines/publish-nightly.yml +90 -0
- package/.azure-pipelines/publish-stable.yml +89 -0
- package/.devcontainer/devcontainer.json +8 -0
- package/.gitattributes +1 -0
- package/.github/ISSUE_TEMPLATE/1_bug_report.yaml +57 -0
- package/.github/ISSUE_TEMPLATE/2_feature_request.yaml +38 -0
- package/.github/ISSUE_TEMPLATE/3_other.md +4 -0
- package/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.github/publish-failure-issue-template.md +7 -0
- package/.github/workflows/ci.yml +76 -0
- package/.github/workflows/website.yml +66 -0
- package/.husky/pre-commit +4 -0
- package/.mocharc.json +4 -0
- package/.nvmrc +1 -0
- package/.prettierignore +17 -0
- package/.prettierrc +8 -0
- package/.vscode/launch.json +68 -0
- package/.vscode/settings.json +16 -0
- package/.vscode/tasks.json +30 -0
- package/CHANGELOG.md +1655 -0
- package/CONTRIBUTING.md +125 -0
- package/LICENSE.txt +21 -0
- package/MAINTAINING.md +55 -0
- package/README.md +122 -0
- package/SECURITY.md +41 -0
- package/ThirdPartyNotices.txt +392 -0
- package/build/build-languages.ts +212 -0
- package/build/build-monaco-editor.ts +463 -0
- package/build/check-samples.ts +53 -0
- package/build/fillers/vscode-nls.ts +46 -0
- package/build/fs.ts +80 -0
- package/build/importTypescript.ts +192 -0
- package/build/npm/installAll.ts +44 -0
- package/build/npm/removeAll.ts +20 -0
- package/build/postinstall.ts +23 -0
- package/build/releaseMetadata.ts +280 -0
- package/build/simpleserver.ts +69 -0
- package/build/tsconfig.json +8 -0
- package/build/utils.ts +291 -0
- package/docs/code-structure.dio.svg +275 -0
- package/docs/debugging-core.gif +0 -0
- package/docs/debugging-languages.gif +0 -0
- package/docs/integrate-amd.md +28 -0
- package/docs/integrate-esm.md +229 -0
- package/docs/launch config.png +0 -0
- package/docs/out-folders.dio.svg +347 -0
- package/editor.code-workspace +13 -0
- package/gulpfile.js +9 -0
- package/package.json +80 -0
- package/samples/README.md +36 -0
- package/samples/browser-amd-diff-editor/index.html +62 -0
- package/samples/browser-amd-diff-editor/modified.txt +74 -0
- package/samples/browser-amd-diff-editor/original.txt +61 -0
- package/samples/browser-amd-editor/index.html +24 -0
- package/samples/browser-amd-iframe/index.html +70 -0
- package/samples/browser-amd-iframe/inner.html +34 -0
- package/samples/browser-amd-localized/index.html +30 -0
- package/samples/browser-amd-monarch/index.html +105 -0
- package/samples/browser-amd-requirejs/index.html +26 -0
- package/samples/browser-amd-shadow-dom/index.html +50 -0
- package/samples/browser-amd-shared-model/index.html +29 -0
- package/samples/browser-amd-trusted-types/index.html +42 -0
- package/samples/browser-esm-esbuild/build.js +96 -0
- package/samples/browser-esm-esbuild/index.html +18 -0
- package/samples/browser-esm-esbuild/index.js +24 -0
- package/samples/browser-esm-esbuild/package.json +6 -0
- package/samples/browser-esm-parcel/index.html +19 -0
- package/samples/browser-esm-parcel/package-lock.json +3953 -0
- package/samples/browser-esm-parcel/package.json +10 -0
- package/samples/browser-esm-parcel/src/index.html +11 -0
- package/samples/browser-esm-parcel/src/index.js +29 -0
- package/samples/browser-esm-vite-react/index.html +12 -0
- package/samples/browser-esm-vite-react/package-lock.json +2341 -0
- package/samples/browser-esm-vite-react/package.json +20 -0
- package/samples/browser-esm-vite-react/src/components/Editor.module.css +4 -0
- package/samples/browser-esm-vite-react/src/components/Editor.tsx +25 -0
- package/samples/browser-esm-vite-react/src/main.tsx +11 -0
- package/samples/browser-esm-vite-react/src/userWorker.ts +27 -0
- package/samples/browser-esm-vite-react/src/vite-env.d.ts +1 -0
- package/samples/browser-esm-vite-react/tsconfig.json +11 -0
- package/samples/browser-esm-vite-react/vite.config.ts +7 -0
- package/samples/browser-esm-webpack/index.html +20 -0
- package/samples/browser-esm-webpack/index.js +24 -0
- package/samples/browser-esm-webpack/package.json +6 -0
- package/samples/browser-esm-webpack/webpack.config.js +30 -0
- package/samples/browser-esm-webpack-monaco-plugin/index.html +20 -0
- package/samples/browser-esm-webpack-monaco-plugin/index.js +16 -0
- package/samples/browser-esm-webpack-monaco-plugin/package.json +6 -0
- package/samples/browser-esm-webpack-monaco-plugin/webpack.config.js +28 -0
- package/samples/browser-esm-webpack-small/generate-imports.js +140 -0
- package/samples/browser-esm-webpack-small/index.html +26 -0
- package/samples/browser-esm-webpack-small/index.js +168 -0
- package/samples/browser-esm-webpack-small/package.json +7 -0
- package/samples/browser-esm-webpack-small/webpack.config.js +35 -0
- package/samples/browser-esm-webpack-typescript/package.json +7 -0
- package/samples/browser-esm-webpack-typescript/src/index.css +5 -0
- package/samples/browser-esm-webpack-typescript/src/index.ts +26 -0
- package/samples/browser-esm-webpack-typescript/tsconfig.json +16 -0
- package/samples/browser-esm-webpack-typescript/webpack.config.js +44 -0
- package/samples/browser-esm-webpack-typescript-react/package-lock.json +6183 -0
- package/samples/browser-esm-webpack-typescript-react/package.json +21 -0
- package/samples/browser-esm-webpack-typescript-react/src/components/Editor.tsx +38 -0
- package/samples/browser-esm-webpack-typescript-react/src/index.css +5 -0
- package/samples/browser-esm-webpack-typescript-react/src/index.html +10 -0
- package/samples/browser-esm-webpack-typescript-react/src/index.tsx +12 -0
- package/samples/browser-esm-webpack-typescript-react/tsconfig.json +18 -0
- package/samples/browser-esm-webpack-typescript-react/webpack.config.js +59 -0
- package/samples/browser-script-editor/index.html +28 -0
- package/samples/electron-amd/electron-index.html +37 -0
- package/samples/electron-amd/index.html +18 -0
- package/samples/electron-amd/main.js +32 -0
- package/samples/electron-amd/package.json +7 -0
- package/samples/electron-amd-nodeIntegration/electron-index.html +46 -0
- package/samples/electron-amd-nodeIntegration/index.html +18 -0
- package/samples/electron-amd-nodeIntegration/main.js +37 -0
- package/samples/electron-amd-nodeIntegration/package.json +7 -0
- package/samples/electron-esm-webpack/index.js +24 -0
- package/samples/electron-esm-webpack/main.js +32 -0
- package/samples/electron-esm-webpack/package.json +8 -0
- package/samples/electron-esm-webpack/webpack.config.js +29 -0
- package/samples/nwjs-amd/index.html +48 -0
- package/samples/nwjs-amd-v2/index.html +57 -0
- package/samples/package-lock.json +7808 -0
- package/samples/package.json +32 -0
- package/scripts/ci/env.ts +15 -0
- package/scripts/ci/monaco-editor-core-prepare.ts +81 -0
- package/scripts/ci/monaco-editor-core.sh +34 -0
- package/scripts/ci/monaco-editor-prepare.ts +75 -0
- package/scripts/ci/monaco-editor.sh +29 -0
- package/scripts/lib/index.ts +95 -0
- package/src/basic-languages/_.contribution.ts +80 -0
- package/src/basic-languages/abap/abap.contribution.ts +24 -0
- package/src/basic-languages/abap/abap.test.ts +360 -0
- package/src/basic-languages/abap/abap.ts +1390 -0
- package/src/basic-languages/apex/apex.contribution.ts +25 -0
- package/src/basic-languages/apex/apex.test.ts +700 -0
- package/src/basic-languages/apex/apex.ts +355 -0
- package/src/basic-languages/azcli/azcli.contribution.ts +24 -0
- package/src/basic-languages/azcli/azcli.test.ts +172 -0
- package/src/basic-languages/azcli/azcli.ts +77 -0
- package/src/basic-languages/bat/bat.contribution.ts +24 -0
- package/src/basic-languages/bat/bat.test.ts +397 -0
- package/src/basic-languages/bat/bat.ts +121 -0
- package/src/basic-languages/bicep/bicep.contribution.ts +24 -0
- package/src/basic-languages/bicep/bicep.test.ts +1063 -0
- package/src/basic-languages/bicep/bicep.ts +129 -0
- package/src/basic-languages/cameligo/cameligo.contribution.ts +24 -0
- package/src/basic-languages/cameligo/cameligo.test.ts +144 -0
- package/src/basic-languages/cameligo/cameligo.ts +193 -0
- package/src/basic-languages/clojure/clojure.contribution.ts +24 -0
- package/src/basic-languages/clojure/clojure.test.ts +943 -0
- package/src/basic-languages/clojure/clojure.ts +792 -0
- package/src/basic-languages/coffee/coffee.contribution.ts +25 -0
- package/src/basic-languages/coffee/coffee.test.ts +2363 -0
- package/src/basic-languages/coffee/coffee.ts +258 -0
- package/src/basic-languages/cpp/cpp.contribution.ts +38 -0
- package/src/basic-languages/cpp/cpp.test.ts +979 -0
- package/src/basic-languages/cpp/cpp.ts +416 -0
- package/src/basic-languages/csharp/csharp.contribution.ts +24 -0
- package/src/basic-languages/csharp/csharp.test.ts +976 -0
- package/src/basic-languages/csharp/csharp.ts +352 -0
- package/src/basic-languages/csp/csp.contribution.ts +24 -0
- package/src/basic-languages/csp/csp.test.ts +8 -0
- package/src/basic-languages/csp/csp.ts +58 -0
- package/src/basic-languages/css/css.contribution.ts +25 -0
- package/src/basic-languages/css/css.test.ts +591 -0
- package/src/basic-languages/css/css.ts +215 -0
- package/src/basic-languages/cypher/cypher.contribution.ts +24 -0
- package/src/basic-languages/cypher/cypher.test.ts +327 -0
- package/src/basic-languages/cypher/cypher.ts +274 -0
- package/src/basic-languages/dart/dart.contribution.ts +25 -0
- package/src/basic-languages/dart/dart.test.ts +558 -0
- package/src/basic-languages/dart/dart.ts +305 -0
- package/src/basic-languages/dockerfile/dockerfile.contribution.ts +25 -0
- package/src/basic-languages/dockerfile/dockerfile.test.ts +238 -0
- package/src/basic-languages/dockerfile/dockerfile.ts +145 -0
- package/src/basic-languages/ecl/ecl.contribution.ts +24 -0
- package/src/basic-languages/ecl/ecl.test.ts +8 -0
- package/src/basic-languages/ecl/ecl.ts +481 -0
- package/src/basic-languages/elixir/elixir.contribution.ts +24 -0
- package/src/basic-languages/elixir/elixir.test.ts +447 -0
- package/src/basic-languages/elixir/elixir.ts +656 -0
- package/src/basic-languages/flow9/flow9.contribution.ts +24 -0
- package/src/basic-languages/flow9/flow9.test.ts +148 -0
- package/src/basic-languages/flow9/flow9.ts +160 -0
- package/src/basic-languages/freemarker2/freemarker2-angle-bracket.test.ts +3099 -0
- package/src/basic-languages/freemarker2/freemarker2-angle-dollar.test.ts +3099 -0
- package/src/basic-languages/freemarker2/freemarker2-auto-bracket.test.ts +5358 -0
- package/src/basic-languages/freemarker2/freemarker2-auto-dollar.test.ts +5361 -0
- package/src/basic-languages/freemarker2/freemarker2-bracket-bracket.test.ts +3086 -0
- package/src/basic-languages/freemarker2/freemarker2-bracket-dollar.test.ts +3086 -0
- package/src/basic-languages/freemarker2/freemarker2.contribution.ts +111 -0
- package/src/basic-languages/freemarker2/freemarker2.ts +1230 -0
- package/src/basic-languages/fsharp/fsharp.contribution.ts +24 -0
- package/src/basic-languages/fsharp/fsharp.test.ts +491 -0
- package/src/basic-languages/fsharp/fsharp.ts +237 -0
- package/src/basic-languages/go/go.contribution.ts +24 -0
- package/src/basic-languages/go/go.test.ts +1492 -0
- package/src/basic-languages/go/go.ts +238 -0
- package/src/basic-languages/graphql/graphql.contribution.ts +25 -0
- package/src/basic-languages/graphql/graphql.test.ts +138 -0
- package/src/basic-languages/graphql/graphql.ts +174 -0
- package/src/basic-languages/handlebars/handlebars.contribution.ts +25 -0
- package/src/basic-languages/handlebars/handlebars.test.ts +354 -0
- package/src/basic-languages/handlebars/handlebars.ts +432 -0
- package/src/basic-languages/hcl/hcl.contribution.ts +24 -0
- package/src/basic-languages/hcl/hcl.test.ts +1228 -0
- package/src/basic-languages/hcl/hcl.ts +189 -0
- package/src/basic-languages/html/html.contribution.ts +25 -0
- package/src/basic-languages/html/html.test.ts +743 -0
- package/src/basic-languages/html/html.ts +355 -0
- package/src/basic-languages/ini/ini.contribution.ts +25 -0
- package/src/basic-languages/ini/ini.ts +82 -0
- package/src/basic-languages/java/java.contribution.ts +25 -0
- package/src/basic-languages/java/java.test.ts +878 -0
- package/src/basic-languages/java/java.ts +252 -0
- package/src/basic-languages/javascript/javascript.contribution.ts +27 -0
- package/src/basic-languages/javascript/javascript.test.ts +924 -0
- package/src/basic-languages/javascript/javascript.ts +77 -0
- package/src/basic-languages/julia/julia.contribution.ts +24 -0
- package/src/basic-languages/julia/julia.test.ts +38 -0
- package/src/basic-languages/julia/julia.ts +550 -0
- package/src/basic-languages/kotlin/kotlin.contribution.ts +25 -0
- package/src/basic-languages/kotlin/kotlin.test.ts +753 -0
- package/src/basic-languages/kotlin/kotlin.ts +273 -0
- package/src/basic-languages/less/less.contribution.ts +25 -0
- package/src/basic-languages/less/less.test.ts +1560 -0
- package/src/basic-languages/less/less.ts +198 -0
- package/src/basic-languages/lexon/lexon.contribution.ts +24 -0
- package/src/basic-languages/lexon/lexon.test.ts +145 -0
- package/src/basic-languages/lexon/lexon.ts +179 -0
- package/src/basic-languages/liquid/liquid.contribution.ts +25 -0
- package/src/basic-languages/liquid/liquid.test.ts +209 -0
- package/src/basic-languages/liquid/liquid.ts +251 -0
- package/src/basic-languages/lua/lua.contribution.ts +24 -0
- package/src/basic-languages/lua/lua.test.ts +86 -0
- package/src/basic-languages/lua/lua.ts +178 -0
- package/src/basic-languages/m3/m3.contribution.ts +24 -0
- package/src/basic-languages/m3/m3.test.ts +119 -0
- package/src/basic-languages/m3/m3.ts +226 -0
- package/src/basic-languages/markdown/markdown.contribution.ts +24 -0
- package/src/basic-languages/markdown/markdown.test.ts +95 -0
- package/src/basic-languages/markdown/markdown.ts +256 -0
- package/src/basic-languages/mdx/mdx.contribution.ts +24 -0
- package/src/basic-languages/mdx/mdx.test.ts +171 -0
- package/src/basic-languages/mdx/mdx.ts +163 -0
- package/src/basic-languages/mips/mips.contribution.ts +25 -0
- package/src/basic-languages/mips/mips.test.ts +239 -0
- package/src/basic-languages/mips/mips.ts +223 -0
- package/src/basic-languages/monaco.contribution.ts +87 -0
- package/src/basic-languages/msdax/msdax.contribution.ts +24 -0
- package/src/basic-languages/msdax/msdax.test.ts +444 -0
- package/src/basic-languages/msdax/msdax.ts +382 -0
- package/src/basic-languages/mysql/keywords.js +32 -0
- package/src/basic-languages/mysql/keywords.mysql.txt +750 -0
- package/src/basic-languages/mysql/mysql.contribution.ts +24 -0
- package/src/basic-languages/mysql/mysql.test.ts +561 -0
- package/src/basic-languages/mysql/mysql.ts +885 -0
- package/src/basic-languages/objective-c/objective-c.contribution.ts +24 -0
- package/src/basic-languages/objective-c/objective-c.test.ts +368 -0
- package/src/basic-languages/objective-c/objective-c.ts +219 -0
- package/src/basic-languages/pascal/pascal.contribution.ts +25 -0
- package/src/basic-languages/pascal/pascal.test.ts +151 -0
- package/src/basic-languages/pascal/pascal.ts +270 -0
- package/src/basic-languages/pascaligo/pascaligo.contribution.ts +24 -0
- package/src/basic-languages/pascaligo/pascaligo.test.ts +143 -0
- package/src/basic-languages/pascaligo/pascaligo.ts +183 -0
- package/src/basic-languages/pebble/pebble.contribution.ts +24 -0
- package/src/basic-languages/pebble/pebble.test.ts +178 -0
- package/src/basic-languages/pebble/pebble.ts +457 -0
- package/src/basic-languages/perl/perl.contribution.ts +24 -0
- package/src/basic-languages/perl/perl.test.ts +475 -0
- package/src/basic-languages/perl/perl.ts +664 -0
- package/src/basic-languages/pgsql/keywords.js +30 -0
- package/src/basic-languages/pgsql/keywords.postgresql.txt +827 -0
- package/src/basic-languages/pgsql/pgsql.contribution.ts +24 -0
- package/src/basic-languages/pgsql/pgsql.test.ts +595 -0
- package/src/basic-languages/pgsql/pgsql.ts +858 -0
- package/src/basic-languages/php/php.contribution.ts +25 -0
- package/src/basic-languages/php/php.test.ts +2409 -0
- package/src/basic-languages/php/php.ts +636 -0
- package/src/basic-languages/pla/pla.contribution.ts +23 -0
- package/src/basic-languages/pla/pla.test.ts +598 -0
- package/src/basic-languages/pla/pla.ts +157 -0
- package/src/basic-languages/postiats/postiats.contribution.ts +24 -0
- package/src/basic-languages/postiats/postiats.test.ts +1050 -0
- package/src/basic-languages/postiats/postiats.ts +748 -0
- package/src/basic-languages/powerquery/powerquery.contribution.ts +24 -0
- package/src/basic-languages/powerquery/powerquery.test.ts +416 -0
- package/src/basic-languages/powerquery/powerquery.ts +917 -0
- package/src/basic-languages/powershell/powershell.contribution.ts +24 -0
- package/src/basic-languages/powershell/powershell.test.ts +884 -0
- package/src/basic-languages/powershell/powershell.ts +263 -0
- package/src/basic-languages/protobuf/protobuf.contribution.ts +24 -0
- package/src/basic-languages/protobuf/protobuf.test.ts +2073 -0
- package/src/basic-languages/protobuf/protobuf.ts +463 -0
- package/src/basic-languages/pug/pug.contribution.ts +24 -0
- package/src/basic-languages/pug/pug.test.ts +473 -0
- package/src/basic-languages/pug/pug.ts +434 -0
- package/src/basic-languages/python/python.contribution.ts +25 -0
- package/src/basic-languages/python/python.test.ts +257 -0
- package/src/basic-languages/python/python.ts +296 -0
- package/src/basic-languages/qsharp/qsharp.contribution.ts +24 -0
- package/src/basic-languages/qsharp/qsharp.test.ts +186 -0
- package/src/basic-languages/qsharp/qsharp.ts +325 -0
- package/src/basic-languages/r/r.contribution.ts +24 -0
- package/src/basic-languages/r/r.test.ts +600 -0
- package/src/basic-languages/r/r.ts +263 -0
- package/src/basic-languages/razor/razor.contribution.ts +25 -0
- package/src/basic-languages/razor/razor.test.ts +175 -0
- package/src/basic-languages/razor/razor.ts +571 -0
- package/src/basic-languages/redis/redis.contribution.ts +24 -0
- package/src/basic-languages/redis/redis.test.ts +306 -0
- package/src/basic-languages/redis/redis.ts +309 -0
- package/src/basic-languages/redshift/redshift.contribution.ts +24 -0
- package/src/basic-languages/redshift/redshift.test.ts +595 -0
- package/src/basic-languages/redshift/redshift.ts +815 -0
- package/src/basic-languages/restructuredtext/restructuredtext.contribution.ts +24 -0
- package/src/basic-languages/restructuredtext/restructuredtext.test.ts +454 -0
- package/src/basic-languages/restructuredtext/restructuredtext.ts +198 -0
- package/src/basic-languages/ruby/ruby.contribution.ts +25 -0
- package/src/basic-languages/ruby/ruby.test.ts +158 -0
- package/src/basic-languages/ruby/ruby.ts +590 -0
- package/src/basic-languages/rust/rust.contribution.ts +24 -0
- package/src/basic-languages/rust/rust.test.ts +208 -0
- package/src/basic-languages/rust/rust.ts +361 -0
- package/src/basic-languages/sb/sb.contribution.ts +24 -0
- package/src/basic-languages/sb/sb.test.ts +320 -0
- package/src/basic-languages/sb/sb.ts +134 -0
- package/src/basic-languages/scala/scala.contribution.ts +25 -0
- package/src/basic-languages/scala/scala.test.ts +727 -0
- package/src/basic-languages/scala/scala.ts +413 -0
- package/src/basic-languages/scheme/scheme.contribution.ts +24 -0
- package/src/basic-languages/scheme/scheme.test.ts +89 -0
- package/src/basic-languages/scheme/scheme.ts +128 -0
- package/src/basic-languages/scss/scss.contribution.ts +25 -0
- package/src/basic-languages/scss/scss.test.ts +2422 -0
- package/src/basic-languages/scss/scss.ts +284 -0
- package/src/basic-languages/shell/shell.contribution.ts +24 -0
- package/src/basic-languages/shell/shell.test.ts +345 -0
- package/src/basic-languages/shell/shell.ts +246 -0
- package/src/basic-languages/solidity/solidity.contribution.ts +24 -0
- package/src/basic-languages/solidity/solidity.test.ts +272 -0
- package/src/basic-languages/solidity/solidity.ts +1388 -0
- package/src/basic-languages/sophia/sophia.contribution.ts +24 -0
- package/src/basic-languages/sophia/sophia.test.ts +302 -0
- package/src/basic-languages/sophia/sophia.ts +220 -0
- package/src/basic-languages/sparql/sparql.contribution.ts +24 -0
- package/src/basic-languages/sparql/sparql.test.ts +187 -0
- package/src/basic-languages/sparql/sparql.ts +219 -0
- package/src/basic-languages/sql/keywords.js +612 -0
- package/src/basic-languages/sql/sql.contribution.ts +24 -0
- package/src/basic-languages/sql/sql.test.ts +692 -0
- package/src/basic-languages/sql/sql.ts +860 -0
- package/src/basic-languages/st/st.contribution.ts +24 -0
- package/src/basic-languages/st/st.test.ts +139 -0
- package/src/basic-languages/st/st.ts +441 -0
- package/src/basic-languages/swift/swift.contribution.ts +25 -0
- package/src/basic-languages/swift/swift.test.ts +254 -0
- package/src/basic-languages/swift/swift.ts +335 -0
- package/src/basic-languages/systemverilog/systemverilog.contribution.ts +39 -0
- package/src/basic-languages/systemverilog/systemverilog.test.ts +1267 -0
- package/src/basic-languages/systemverilog/systemverilog.ts +606 -0
- package/src/basic-languages/tcl/tcl.contribution.ts +24 -0
- package/src/basic-languages/tcl/tcl.test.ts +107 -0
- package/src/basic-languages/tcl/tcl.ts +259 -0
- package/src/basic-languages/test/testRunner.ts +63 -0
- package/src/basic-languages/twig/twig.contribution.ts +25 -0
- package/src/basic-languages/twig/twig.test.ts +1047 -0
- package/src/basic-languages/twig/twig.ts +417 -0
- package/src/basic-languages/typescript/typescript.contribution.ts +25 -0
- package/src/basic-languages/typescript/typescript.test.ts +973 -0
- package/src/basic-languages/typescript/typescript.ts +364 -0
- package/src/basic-languages/typespec/typespec.contribution.ts +24 -0
- package/src/basic-languages/typespec/typespec.test.ts +500 -0
- package/src/basic-languages/typespec/typespec.ts +130 -0
- package/src/basic-languages/vb/vb.contribution.ts +24 -0
- package/src/basic-languages/vb/vb.test.ts +598 -0
- package/src/basic-languages/vb/vb.ts +394 -0
- package/src/basic-languages/wgsl/wgsl.contribution.ts +24 -0
- package/src/basic-languages/wgsl/wgsl.test.ts +3915 -0
- package/src/basic-languages/wgsl/wgsl.ts +485 -0
- package/src/basic-languages/xml/xml.contribution.ts +44 -0
- package/src/basic-languages/xml/xml.test.ts +706 -0
- package/src/basic-languages/xml/xml.ts +106 -0
- package/src/basic-languages/yaml/yaml.contribution.ts +25 -0
- package/src/basic-languages/yaml/yaml.test.ts +670 -0
- package/src/basic-languages/yaml/yaml.ts +236 -0
- package/src/fillers/editor.api.d.ts +4 -0
- package/src/fillers/monaco-editor-core-amd.ts +11 -0
- package/src/fillers/monaco-editor-core.ts +6 -0
- package/src/language/common/lspLanguageFeatures.ts +1027 -0
- package/src/language/css/css.worker.ts +14 -0
- package/src/language/css/cssMode.ts +145 -0
- package/src/language/css/cssWorker.ts +239 -0
- package/src/language/css/monaco.contribution.ts +362 -0
- package/src/language/css/workerManager.ts +90 -0
- package/src/language/html/html.worker.ts +14 -0
- package/src/language/html/htmlMode.ts +171 -0
- package/src/language/html/htmlWorker.ts +164 -0
- package/src/language/html/monaco.contribution.ts +329 -0
- package/src/language/html/workerManager.ts +90 -0
- package/src/language/json/json.worker.ts +14 -0
- package/src/language/json/jsonMode.ts +185 -0
- package/src/language/json/jsonWorker.ts +235 -0
- package/src/language/json/monaco.contribution.ts +372 -0
- package/src/language/json/tokenization.ts +273 -0
- package/src/language/json/workerManager.ts +91 -0
- package/src/language/typescript/languageFeatures.ts +1269 -0
- package/src/language/typescript/lib/editor.worker.d.ts +8 -0
- package/src/language/typescript/lib/lib.index.ts +97 -0
- package/src/language/typescript/lib/lib.ts +97 -0
- package/src/language/typescript/lib/typescriptServices.d.ts +11717 -0
- package/src/language/typescript/lib/typescriptServices.js +190876 -0
- package/src/language/typescript/lib/typescriptServicesMetadata.ts +5 -0
- package/src/language/typescript/monaco.contribution.ts +815 -0
- package/src/language/typescript/ts.worker.ts +19 -0
- package/src/language/typescript/tsMode.ts +176 -0
- package/src/language/typescript/tsWorker.ts +525 -0
- package/src/language/typescript/workerManager.ts +101 -0
- package/src/nls-fix.js +39 -0
- package/src/tsconfig.json +14 -0
- package/test/manual/cross-origin.html +26 -0
- package/test/manual/dev-setup.js +218 -0
- package/test/manual/diff.html +20 -0
- package/test/manual/diff.js +451 -0
- package/test/manual/iframe-inner.html +29 -0
- package/test/manual/iframe.html +23 -0
- package/test/manual/index.css +14 -0
- package/test/manual/index.html +44 -0
- package/test/manual/index.js +421 -0
- package/test/manual/mouse-fixed.html +31 -0
- package/test/manual/mouse-scrollable-body.html +286 -0
- package/test/manual/mouse-scrollable-element.html +204 -0
- package/test/manual/samples/run-editor-failing-js.txt +44 -0
- package/test/manual/samples/run-editor-intellisense-js.txt +33 -0
- package/test/manual/samples/run-editor-jquery-min-js.txt +30 -0
- package/test/manual/samples/run-editor-korean.txt +10 -0
- package/test/manual/samples/run-editor-sample-big-css.txt +1 -0
- package/test/manual/samples/run-editor-sample-bom-cs.txt +493 -0
- package/test/manual/samples/run-editor-sample-cr-ps1.txt +12 -0
- package/test/manual/samples/run-editor-sample-dynamic.txt +50 -0
- package/test/manual/samples/run-editor-sample-f12-css.txt +31764 -0
- package/test/manual/samples/run-editor-sample-html.txt +23 -0
- package/test/manual/samples/run-editor-sample-js.txt +222 -0
- package/test/manual/samples/run-editor-sample-msn-js.txt +1 -0
- package/test/manual/samples.js +287 -0
- package/test/manual/shadow-dom.html +56 -0
- package/test/manual/transform.html +29 -0
- package/test/manual/typescript/custom-worker.html +210 -0
- package/test/manual/typescript/custom-worker.js +59 -0
- package/test/manual/typescript/index.html +179 -0
- package/test/smoke/amd/index.html +21 -0
- package/test/smoke/common.js +11 -0
- package/test/smoke/esbuild/index.html +11 -0
- package/test/smoke/esbuild/index.js +26 -0
- package/test/smoke/package-esbuild.ts +60 -0
- package/test/smoke/package-vite.ts +19 -0
- package/test/smoke/package-webpack.ts +56 -0
- package/test/smoke/parcel/index.html +11 -0
- package/test/smoke/parcel/index.js +41 -0
- package/test/smoke/parcel/package.json +6 -0
- package/test/smoke/runner.js +94 -0
- package/test/smoke/smoke.test.js +215 -0
- package/test/smoke/vite/index.html +10 -0
- package/test/smoke/vite/index.js +31 -0
- package/test/smoke/webpack/index.html +10 -0
- package/test/smoke/webpack/index.js +4 -0
- package/test/unit/all.js +70 -0
- package/test/unit/setup.js +34 -0
- package/webpack-plugin/LICENSE +21 -0
- package/webpack-plugin/README.md +116 -0
- package/webpack-plugin/package-lock.json +3132 -0
- package/webpack-plugin/package.json +45 -0
- package/webpack-plugin/tsconfig.json +11 -0
- package/website/.prettierrc.json +6 -0
- package/website/index/samples/sample.mdx.txt +92 -0
- package/website/package.json +60 -0
- package/website/scripts/check-playground-samples-js.ts +58 -0
- package/website/src/monaco-loader.ts +111 -0
- package/website/src/runner/debug.ts +75 -0
- package/website/src/runner/index.ts +104 -0
- package/website/src/runner/style.scss +35 -0
- package/website/src/shared.ts +37 -0
- package/website/src/tsconfig.json +19 -0
- package/website/src/types.d.ts +13 -0
- package/website/src/website/bootstrap.scss +6 -0
- package/website/src/website/code-oss.svg +1 -0
- package/website/src/website/components/Loader.tsx +40 -0
- package/website/src/website/components/Nav.tsx +75 -0
- package/website/src/website/components/Page.tsx +11 -0
- package/website/src/website/components/Radio.tsx +23 -0
- package/website/src/website/components/Select.tsx +75 -0
- package/website/src/website/components/TextBox.tsx +21 -0
- package/website/src/website/components/bootstrap.tsx +32 -0
- package/website/src/website/components/monaco/MonacoEditor.tsx +275 -0
- package/website/src/website/components/monaco/MonacoLoader.tsx +39 -0
- package/website/src/website/data/diff-sample/modified.txt +212 -0
- package/website/src/website/data/diff-sample/original.txt +215 -0
- package/website/src/website/data/home-samples/sample.abap.txt +29 -0
- package/website/src/website/data/home-samples/sample.aes.txt +38 -0
- package/website/src/website/data/home-samples/sample.apex.txt +7 -0
- package/website/src/website/data/home-samples/sample.azcli.txt +5 -0
- package/website/src/website/data/home-samples/sample.bat.txt +13 -0
- package/website/src/website/data/home-samples/sample.bicep.txt +29 -0
- package/website/src/website/data/home-samples/sample.c.txt +3463 -0
- package/website/src/website/data/home-samples/sample.cameligo.txt +17 -0
- package/website/src/website/data/home-samples/sample.clojure.txt +54 -0
- package/website/src/website/data/home-samples/sample.coffeescript.txt +28 -0
- package/website/src/website/data/home-samples/sample.cpp.txt +246 -0
- package/website/src/website/data/home-samples/sample.csharp.txt +38 -0
- package/website/src/website/data/home-samples/sample.csp.txt +1 -0
- package/website/src/website/data/home-samples/sample.css.txt +828 -0
- package/website/src/website/data/home-samples/sample.cypher.txt +3 -0
- package/website/src/website/data/home-samples/sample.dart.txt +45 -0
- package/website/src/website/data/home-samples/sample.dockerfile.txt +32 -0
- package/website/src/website/data/home-samples/sample.ecl.txt +7 -0
- package/website/src/website/data/home-samples/sample.elixir.txt +80 -0
- package/website/src/website/data/home-samples/sample.flow9.txt +14 -0
- package/website/src/website/data/home-samples/sample.freemarker2.tag-angle.interpolation-bracket.txt +61 -0
- package/website/src/website/data/home-samples/sample.freemarker2.tag-angle.interpolation-dollar.txt +61 -0
- package/website/src/website/data/home-samples/sample.freemarker2.tag-auto.interpolation-bracket.txt +65 -0
- package/website/src/website/data/home-samples/sample.freemarker2.tag-auto.interpolation-dollar.txt +65 -0
- package/website/src/website/data/home-samples/sample.freemarker2.tag-bracket.interpolation-bracket.txt +61 -0
- package/website/src/website/data/home-samples/sample.freemarker2.tag-bracket.interpolation-dollar.txt +61 -0
- package/website/src/website/data/home-samples/sample.freemarker2.txt +61 -0
- package/website/src/website/data/home-samples/sample.fsharp.txt +8 -0
- package/website/src/website/data/home-samples/sample.go.txt +111 -0
- package/website/src/website/data/home-samples/sample.graphql.txt +263 -0
- package/website/src/website/data/home-samples/sample.handlebars.txt +31 -0
- package/website/src/website/data/home-samples/sample.hcl.txt +48 -0
- package/website/src/website/data/home-samples/sample.html.txt +100 -0
- package/website/src/website/data/home-samples/sample.ini.txt +15 -0
- package/website/src/website/data/home-samples/sample.java.txt +54 -0
- package/website/src/website/data/home-samples/sample.javascript.txt +214 -0
- package/website/src/website/data/home-samples/sample.json.txt +68 -0
- package/website/src/website/data/home-samples/sample.julia.txt +23 -0
- package/website/src/website/data/home-samples/sample.kotlin.txt +28 -0
- package/website/src/website/data/home-samples/sample.less.txt +46 -0
- package/website/src/website/data/home-samples/sample.lex.txt +21 -0
- package/website/src/website/data/home-samples/sample.lexon.txt +17 -0
- package/website/src/website/data/home-samples/sample.liquid.txt +16 -0
- package/website/src/website/data/home-samples/sample.lua.txt +12 -0
- package/website/src/website/data/home-samples/sample.m3.txt +5 -0
- package/website/src/website/data/home-samples/sample.markdown.txt +104 -0
- package/website/src/website/data/home-samples/sample.mdx.txt +91 -0
- package/website/src/website/data/home-samples/sample.mips.txt +13 -0
- package/website/src/website/data/home-samples/sample.msdax.txt +1 -0
- package/website/src/website/data/home-samples/sample.mysql.txt +8 -0
- package/website/src/website/data/home-samples/sample.objective-c.txt +52 -0
- package/website/src/website/data/home-samples/sample.pascal.txt +28 -0
- package/website/src/website/data/home-samples/sample.pascaligo.txt +20 -0
- package/website/src/website/data/home-samples/sample.pebble.txt +54 -0
- package/website/src/website/data/home-samples/sample.perl.txt +18 -0
- package/website/src/website/data/home-samples/sample.pgsql.txt +8 -0
- package/website/src/website/data/home-samples/sample.php.txt +82 -0
- package/website/src/website/data/home-samples/sample.pla.txt +4 -0
- package/website/src/website/data/home-samples/sample.plaintext.txt +9 -0
- package/website/src/website/data/home-samples/sample.postiats.txt +64 -0
- package/website/src/website/data/home-samples/sample.powerquery.txt +12 -0
- package/website/src/website/data/home-samples/sample.powershell.txt +30 -0
- package/website/src/website/data/home-samples/sample.proto.txt +11 -0
- package/website/src/website/data/home-samples/sample.pug.txt +18 -0
- package/website/src/website/data/home-samples/sample.python.txt +13 -0
- package/website/src/website/data/home-samples/sample.qsharp.txt +45 -0
- package/website/src/website/data/home-samples/sample.r.txt +41 -0
- package/website/src/website/data/home-samples/sample.razor.txt +46 -0
- package/website/src/website/data/home-samples/sample.redis.txt +4 -0
- package/website/src/website/data/home-samples/sample.redshift.txt +9 -0
- package/website/src/website/data/home-samples/sample.restructuredtext.txt +26 -0
- package/website/src/website/data/home-samples/sample.ruby.txt +21 -0
- package/website/src/website/data/home-samples/sample.rust.txt +29 -0
- package/website/src/website/data/home-samples/sample.sb.txt +10 -0
- package/website/src/website/data/home-samples/sample.scala.txt +53 -0
- package/website/src/website/data/home-samples/sample.scheme.txt +105 -0
- package/website/src/website/data/home-samples/sample.scss.txt +37 -0
- package/website/src/website/data/home-samples/sample.shell.txt +42 -0
- package/website/src/website/data/home-samples/sample.sol.txt +139 -0
- package/website/src/website/data/home-samples/sample.sparql.txt +7 -0
- package/website/src/website/data/home-samples/sample.sql.txt +52 -0
- package/website/src/website/data/home-samples/sample.st.txt +34 -0
- package/website/src/website/data/home-samples/sample.swift.txt +50 -0
- package/website/src/website/data/home-samples/sample.systemverilog.txt +28 -0
- package/website/src/website/data/home-samples/sample.tcl.txt +18 -0
- package/website/src/website/data/home-samples/sample.twig.txt +12 -0
- package/website/src/website/data/home-samples/sample.typescript.txt +124 -0
- package/website/src/website/data/home-samples/sample.typespec.txt +71 -0
- package/website/src/website/data/home-samples/sample.vb.txt +59 -0
- package/website/src/website/data/home-samples/sample.verilog.txt +35 -0
- package/website/src/website/data/home-samples/sample.wgsl.txt +48 -0
- package/website/src/website/data/home-samples/sample.xml.txt +14 -0
- package/website/src/website/data/home-samples/sample.yaml.txt +14 -0
- package/website/src/website/data/playground-samples/all.js +196 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/chapter.json +3 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/hello-diff-world/sample.css +0 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/hello-diff-world/sample.html +1 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/hello-diff-world/sample.js +20 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/hello-diff-world/sample.json +3 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/inline-diff-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/inline-diff-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/inline-diff-example/sample.js +23 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/inline-diff-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/multi-line-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/multi-line-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/multi-line-example/sample.js +20 -0
- package/website/src/website/data/playground-samples/creating-the-diffeditor/multi-line-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/creating-the-editor/chapter.json +4 -0
- package/website/src/website/data/playground-samples/creating-the-editor/editor-basic-options/sample.css +0 -0
- package/website/src/website/data/playground-samples/creating-the-editor/editor-basic-options/sample.html +1 -0
- package/website/src/website/data/playground-samples/creating-the-editor/editor-basic-options/sample.js +19 -0
- package/website/src/website/data/playground-samples/creating-the-editor/editor-basic-options/sample.json +3 -0
- package/website/src/website/data/playground-samples/creating-the-editor/hard-wrapping/sample.css +0 -0
- package/website/src/website/data/playground-samples/creating-the-editor/hard-wrapping/sample.html +1 -0
- package/website/src/website/data/playground-samples/creating-the-editor/hard-wrapping/sample.js +13 -0
- package/website/src/website/data/playground-samples/creating-the-editor/hard-wrapping/sample.json +3 -0
- package/website/src/website/data/playground-samples/creating-the-editor/hello-world/sample.css +0 -0
- package/website/src/website/data/playground-samples/creating-the-editor/hello-world/sample.html +1 -0
- package/website/src/website/data/playground-samples/creating-the-editor/hello-world/sample.js +10 -0
- package/website/src/website/data/playground-samples/creating-the-editor/hello-world/sample.json +4 -0
- package/website/src/website/data/playground-samples/creating-the-editor/syntax-highlighting-for-html-elements/sample.css +0 -0
- package/website/src/website/data/playground-samples/creating-the-editor/syntax-highlighting-for-html-elements/sample.html +35 -0
- package/website/src/website/data/playground-samples/creating-the-editor/syntax-highlighting-for-html-elements/sample.js +4 -0
- package/website/src/website/data/playground-samples/creating-the-editor/syntax-highlighting-for-html-elements/sample.json +3 -0
- package/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.css +0 -0
- package/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.html +8 -0
- package/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.js +35 -0
- package/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.json +4 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/chapter.json +3 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/exposed-colors/sample.css +0 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/exposed-colors/sample.html +1 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/exposed-colors/sample.js +150 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/exposed-colors/sample.json +3 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/scrollbars/sample.css +13 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/scrollbars/sample.html +1 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/scrollbars/sample.js +32 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/scrollbars/sample.json +3 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/tokens-and-colors/sample.css +0 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/tokens-and-colors/sample.html +1 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/tokens-and-colors/sample.js +40 -0
- package/website/src/website/data/playground-samples/customizing-the-appearence/tokens-and-colors/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/chapter.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/codelens-provider-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/codelens-provider-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/codelens-provider-example/sample.js +39 -0
- package/website/src/website/data/playground-samples/extending-language-services/codelens-provider-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/color-provider-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/color-provider-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/color-provider-example/sample.js +71 -0
- package/website/src/website/data/playground-samples/extending-language-services/color-provider-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/completion-provider-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/completion-provider-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/completion-provider-example/sample.js +69 -0
- package/website/src/website/data/playground-samples/extending-language-services/completion-provider-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/configure-javascript-defaults/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/configure-javascript-defaults/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/configure-javascript-defaults/sample.js +46 -0
- package/website/src/website/data/playground-samples/extending-language-services/configure-javascript-defaults/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/configure-json-defaults/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/configure-json-defaults/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/configure-json-defaults/sample.js +42 -0
- package/website/src/website/data/playground-samples/extending-language-services/configure-json-defaults/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/custom-languages/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/custom-languages/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/custom-languages/sample.js +137 -0
- package/website/src/website/data/playground-samples/extending-language-services/custom-languages/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/folding-provider-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/folding-provider-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/folding-provider-example/sample.js +74 -0
- package/website/src/website/data/playground-samples/extending-language-services/folding-provider-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/hover-provider-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/hover-provider-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/hover-provider-example/sample.js +62 -0
- package/website/src/website/data/playground-samples/extending-language-services/hover-provider-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/inlay-hints-provider-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/inlay-hints-provider-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/inlay-hints-provider-example/sample.js +47 -0
- package/website/src/website/data/playground-samples/extending-language-services/inlay-hints-provider-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/model-markers-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/model-markers-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/model-markers-example/sample.js +50 -0
- package/website/src/website/data/playground-samples/extending-language-services/model-markers-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/semantic-tokens-provider-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/semantic-tokens-provider-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/semantic-tokens-provider-example/sample.js +168 -0
- package/website/src/website/data/playground-samples/extending-language-services/semantic-tokens-provider-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/extending-language-services/symbols-provider-example/sample.css +0 -0
- package/website/src/website/data/playground-samples/extending-language-services/symbols-provider-example/sample.html +1 -0
- package/website/src/website/data/playground-samples/extending-language-services/symbols-provider-example/sample.js +480 -0
- package/website/src/website/data/playground-samples/extending-language-services/symbols-provider-example/sample.json +3 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-a-command-to-an-editor-instance/sample.css +0 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-a-command-to-an-editor-instance/sample.html +1 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-a-command-to-an-editor-instance/sample.js +43 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-a-command-to-an-editor-instance/sample.json +3 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-a-keybinding-to-an-existing-command/sample.css +0 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-a-keybinding-to-an-existing-command/sample.html +1 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-a-keybinding-to-an-existing-command/sample.js +49 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-a-keybinding-to-an-existing-command/sample.json +3 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-an-action-to-an-editor-instance/sample.css +0 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-an-action-to-an-editor-instance/sample.html +1 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-an-action-to-an-editor-instance/sample.js +52 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/adding-an-action-to-an-editor-instance/sample.json +3 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/chapter.json +3 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/customizing-the-line-numbers/sample.css +0 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/customizing-the-line-numbers/sample.html +1 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/customizing-the-line-numbers/sample.js +37 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/customizing-the-line-numbers/sample.json +3 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/line-and-inline-decorations/sample.css +13 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/line-and-inline-decorations/sample.html +1 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/line-and-inline-decorations/sample.js +30 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/line-and-inline-decorations/sample.json +3 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/listening-to-key-events/sample.css +0 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/listening-to-key-events/sample.html +1 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/listening-to-key-events/sample.js +11 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/listening-to-key-events/sample.json +3 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/listening-to-mouse-events/sample.css +6 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/listening-to-mouse-events/sample.html +5 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/listening-to-mouse-events/sample.js +114 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/listening-to-mouse-events/sample.json +3 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/rendering-glyphs-in-the-margin/sample.css +7 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/rendering-glyphs-in-the-margin/sample.html +1 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/rendering-glyphs-in-the-margin/sample.js +30 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/rendering-glyphs-in-the-margin/sample.json +3 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/revealing-a-position/sample.css +0 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/revealing-a-position/sample.html +1 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/revealing-a-position/sample.js +41 -0
- package/website/src/website/data/playground-samples/interacting-with-the-editor/revealing-a-position/sample.json +3 -0
- package/website/src/website/index.tsx +10 -0
- package/website/src/website/monaco-loader-chunk.ts +15 -0
- package/website/src/website/monacoEditorVersion.ts +8 -0
- package/website/src/website/pages/App.tsx +21 -0
- package/website/src/website/pages/DocsPage.tsx +103 -0
- package/website/src/website/pages/MonarchPage.tsx +16 -0
- package/website/src/website/pages/home/Home.tsx +249 -0
- package/website/src/website/pages/playground/BisectModel.ts +161 -0
- package/website/src/website/pages/playground/LocationModel.ts +216 -0
- package/website/src/website/pages/playground/PlaygroundModel.ts +355 -0
- package/website/src/website/pages/playground/PlaygroundPage.tsx +31 -0
- package/website/src/website/pages/playground/PlaygroundPageContent.tsx +587 -0
- package/website/src/website/pages/playground/Preview.tsx +129 -0
- package/website/src/website/pages/playground/SettingsDialog.tsx +412 -0
- package/website/src/website/pages/playground/SettingsModel.ts +198 -0
- package/website/src/website/pages/playground/Source.ts +107 -0
- package/website/src/website/pages/playground/getNpmVersionsSync.ts +450 -0
- package/website/src/website/pages/playground/playgroundExamples.tsx +88 -0
- package/website/src/website/pages/playground/utils.ts +28 -0
- package/website/src/website/pages/routes.ts +28 -0
- package/website/src/website/style.scss +96 -0
- package/website/src/website/utils/Debouncer.ts +28 -0
- package/website/src/website/utils/ObservableHistory.ts +89 -0
- package/website/src/website/utils/ObservablePromise.ts +49 -0
- package/website/src/website/utils/hotComponent.tsx +49 -0
- package/website/src/website/utils/lzmaCompressor.ts +39 -0
- package/website/src/website/utils/ref.ts +39 -0
- package/website/src/website/utils/types.d.ts +28 -0
- package/website/src/website/utils/utils.ts +58 -0
- package/website/static/monarch/monarch-34px.png +0 -0
- package/website/static/monarch/monarch.css +297 -0
- package/website/static/monarch/monarch.js +178 -0
- package/website/static/monarch-static.html +5345 -0
- package/website/tsconfig.json +16 -0
- package/website/tslint.json +6 -0
- package/website/typedoc/tsconfig.json +8 -0
- package/website/typedoc/typedoc.json +11 -0
- package/website/vscode-web-editors.tgz +0 -0
- package/website/webpack.config.ts +151 -0
- package/website/yarn.lock +3612 -0
|
@@ -0,0 +1,1027 @@
|
|
|
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
|
+
import * as lsTypes from 'vscode-languageserver-types';
|
|
7
|
+
import {
|
|
8
|
+
languages,
|
|
9
|
+
editor,
|
|
10
|
+
IMarkdownString,
|
|
11
|
+
Uri,
|
|
12
|
+
Position,
|
|
13
|
+
IRange,
|
|
14
|
+
Range,
|
|
15
|
+
CancellationToken,
|
|
16
|
+
IDisposable,
|
|
17
|
+
MarkerSeverity,
|
|
18
|
+
IEvent
|
|
19
|
+
} from '../../fillers/monaco-editor-core';
|
|
20
|
+
|
|
21
|
+
export interface WorkerAccessor<T> {
|
|
22
|
+
(...more: Uri[]): Promise<T>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#region DiagnosticsAdapter
|
|
26
|
+
|
|
27
|
+
export interface ILanguageWorkerWithDiagnostics {
|
|
28
|
+
doValidation(uri: string): Promise<lsTypes.Diagnostic[]>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class DiagnosticsAdapter<T extends ILanguageWorkerWithDiagnostics> {
|
|
32
|
+
protected readonly _disposables: IDisposable[] = [];
|
|
33
|
+
private readonly _listener: { [uri: string]: IDisposable } = Object.create(null);
|
|
34
|
+
|
|
35
|
+
constructor(
|
|
36
|
+
private readonly _languageId: string,
|
|
37
|
+
protected readonly _worker: WorkerAccessor<T>,
|
|
38
|
+
configChangeEvent: IEvent<any>
|
|
39
|
+
) {
|
|
40
|
+
const onModelAdd = (model: editor.IModel): void => {
|
|
41
|
+
let modeId = model.getLanguageId();
|
|
42
|
+
if (modeId !== this._languageId) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let handle: number;
|
|
47
|
+
this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
|
|
48
|
+
window.clearTimeout(handle);
|
|
49
|
+
handle = window.setTimeout(() => this._doValidate(model.uri, modeId), 500);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
this._doValidate(model.uri, modeId);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const onModelRemoved = (model: editor.IModel): void => {
|
|
56
|
+
editor.setModelMarkers(model, this._languageId, []);
|
|
57
|
+
|
|
58
|
+
let uriStr = model.uri.toString();
|
|
59
|
+
let listener = this._listener[uriStr];
|
|
60
|
+
if (listener) {
|
|
61
|
+
listener.dispose();
|
|
62
|
+
delete this._listener[uriStr];
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
this._disposables.push(editor.onDidCreateModel(onModelAdd));
|
|
67
|
+
this._disposables.push(editor.onWillDisposeModel(onModelRemoved));
|
|
68
|
+
this._disposables.push(
|
|
69
|
+
editor.onDidChangeModelLanguage((event) => {
|
|
70
|
+
onModelRemoved(event.model);
|
|
71
|
+
onModelAdd(event.model);
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
this._disposables.push(
|
|
76
|
+
configChangeEvent((_) => {
|
|
77
|
+
editor.getModels().forEach((model) => {
|
|
78
|
+
if (model.getLanguageId() === this._languageId) {
|
|
79
|
+
onModelRemoved(model);
|
|
80
|
+
onModelAdd(model);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
this._disposables.push({
|
|
87
|
+
dispose: () => {
|
|
88
|
+
editor.getModels().forEach(onModelRemoved);
|
|
89
|
+
for (let key in this._listener) {
|
|
90
|
+
this._listener[key].dispose();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
editor.getModels().forEach(onModelAdd);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public dispose(): void {
|
|
99
|
+
this._disposables.forEach((d) => d && d.dispose());
|
|
100
|
+
this._disposables.length = 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private _doValidate(resource: Uri, languageId: string): void {
|
|
104
|
+
this._worker(resource)
|
|
105
|
+
.then((worker) => {
|
|
106
|
+
return worker.doValidation(resource.toString());
|
|
107
|
+
})
|
|
108
|
+
.then((diagnostics) => {
|
|
109
|
+
const markers = diagnostics.map((d) => toDiagnostics(resource, d));
|
|
110
|
+
let model = editor.getModel(resource);
|
|
111
|
+
if (model && model.getLanguageId() === languageId) {
|
|
112
|
+
editor.setModelMarkers(model, languageId, markers);
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
.then(undefined, (err) => {
|
|
116
|
+
console.error(err);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function toSeverity(lsSeverity: number | undefined): MarkerSeverity {
|
|
122
|
+
switch (lsSeverity) {
|
|
123
|
+
case lsTypes.DiagnosticSeverity.Error:
|
|
124
|
+
return MarkerSeverity.Error;
|
|
125
|
+
case lsTypes.DiagnosticSeverity.Warning:
|
|
126
|
+
return MarkerSeverity.Warning;
|
|
127
|
+
case lsTypes.DiagnosticSeverity.Information:
|
|
128
|
+
return MarkerSeverity.Info;
|
|
129
|
+
case lsTypes.DiagnosticSeverity.Hint:
|
|
130
|
+
return MarkerSeverity.Hint;
|
|
131
|
+
default:
|
|
132
|
+
return MarkerSeverity.Info;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function toDiagnostics(resource: Uri, diag: lsTypes.Diagnostic): editor.IMarkerData {
|
|
137
|
+
let code = typeof diag.code === 'number' ? String(diag.code) : <string>diag.code;
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
severity: toSeverity(diag.severity),
|
|
141
|
+
startLineNumber: diag.range.start.line + 1,
|
|
142
|
+
startColumn: diag.range.start.character + 1,
|
|
143
|
+
endLineNumber: diag.range.end.line + 1,
|
|
144
|
+
endColumn: diag.range.end.character + 1,
|
|
145
|
+
message: diag.message,
|
|
146
|
+
code: code,
|
|
147
|
+
source: diag.source
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
//#endregion
|
|
152
|
+
|
|
153
|
+
//#region CompletionAdapter
|
|
154
|
+
|
|
155
|
+
export interface ILanguageWorkerWithCompletions {
|
|
156
|
+
doComplete(uri: string, position: lsTypes.Position): Promise<lsTypes.CompletionList | null>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export class CompletionAdapter<T extends ILanguageWorkerWithCompletions>
|
|
160
|
+
implements languages.CompletionItemProvider
|
|
161
|
+
{
|
|
162
|
+
constructor(
|
|
163
|
+
private readonly _worker: WorkerAccessor<T>,
|
|
164
|
+
private readonly _triggerCharacters: string[]
|
|
165
|
+
) {}
|
|
166
|
+
|
|
167
|
+
public get triggerCharacters(): string[] {
|
|
168
|
+
return this._triggerCharacters;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
provideCompletionItems(
|
|
172
|
+
model: editor.IReadOnlyModel,
|
|
173
|
+
position: Position,
|
|
174
|
+
context: languages.CompletionContext,
|
|
175
|
+
token: CancellationToken
|
|
176
|
+
): Promise<languages.CompletionList | undefined> {
|
|
177
|
+
const resource = model.uri;
|
|
178
|
+
|
|
179
|
+
return this._worker(resource)
|
|
180
|
+
.then((worker) => {
|
|
181
|
+
return worker.doComplete(resource.toString(), fromPosition(position));
|
|
182
|
+
})
|
|
183
|
+
.then((info) => {
|
|
184
|
+
if (!info) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const wordInfo = model.getWordUntilPosition(position);
|
|
188
|
+
const wordRange = new Range(
|
|
189
|
+
position.lineNumber,
|
|
190
|
+
wordInfo.startColumn,
|
|
191
|
+
position.lineNumber,
|
|
192
|
+
wordInfo.endColumn
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
const items: languages.CompletionItem[] = info.items.map((entry) => {
|
|
196
|
+
const item: languages.CompletionItem = {
|
|
197
|
+
label: entry.label,
|
|
198
|
+
insertText: entry.insertText || entry.label,
|
|
199
|
+
sortText: entry.sortText,
|
|
200
|
+
filterText: entry.filterText,
|
|
201
|
+
documentation: entry.documentation,
|
|
202
|
+
detail: entry.detail,
|
|
203
|
+
command: toCommand(entry.command),
|
|
204
|
+
range: wordRange,
|
|
205
|
+
kind: toCompletionItemKind(entry.kind)
|
|
206
|
+
};
|
|
207
|
+
if (entry.textEdit) {
|
|
208
|
+
if (isInsertReplaceEdit(entry.textEdit)) {
|
|
209
|
+
item.range = {
|
|
210
|
+
insert: toRange(entry.textEdit.insert),
|
|
211
|
+
replace: toRange(entry.textEdit.replace)
|
|
212
|
+
};
|
|
213
|
+
} else {
|
|
214
|
+
item.range = toRange(entry.textEdit.range);
|
|
215
|
+
}
|
|
216
|
+
item.insertText = entry.textEdit.newText;
|
|
217
|
+
}
|
|
218
|
+
if (entry.additionalTextEdits) {
|
|
219
|
+
item.additionalTextEdits =
|
|
220
|
+
entry.additionalTextEdits.map<languages.TextEdit>(toTextEdit);
|
|
221
|
+
}
|
|
222
|
+
if (entry.insertTextFormat === lsTypes.InsertTextFormat.Snippet) {
|
|
223
|
+
item.insertTextRules = languages.CompletionItemInsertTextRule.InsertAsSnippet;
|
|
224
|
+
}
|
|
225
|
+
return item;
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
isIncomplete: info.isIncomplete,
|
|
230
|
+
suggestions: items
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function fromPosition(position: Position): lsTypes.Position;
|
|
237
|
+
export function fromPosition(position: undefined): undefined;
|
|
238
|
+
export function fromPosition(position: Position | undefined): lsTypes.Position | undefined;
|
|
239
|
+
export function fromPosition(position: Position | undefined): lsTypes.Position | undefined {
|
|
240
|
+
if (!position) {
|
|
241
|
+
return void 0;
|
|
242
|
+
}
|
|
243
|
+
return { character: position.column - 1, line: position.lineNumber - 1 };
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function fromRange(range: IRange): lsTypes.Range;
|
|
247
|
+
export function fromRange(range: undefined): undefined;
|
|
248
|
+
export function fromRange(range: IRange | undefined): lsTypes.Range | undefined;
|
|
249
|
+
export function fromRange(range: IRange | undefined): lsTypes.Range | undefined {
|
|
250
|
+
if (!range) {
|
|
251
|
+
return void 0;
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
start: {
|
|
255
|
+
line: range.startLineNumber - 1,
|
|
256
|
+
character: range.startColumn - 1
|
|
257
|
+
},
|
|
258
|
+
end: { line: range.endLineNumber - 1, character: range.endColumn - 1 }
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
export function toRange(range: lsTypes.Range): Range;
|
|
262
|
+
export function toRange(range: undefined): undefined;
|
|
263
|
+
export function toRange(range: lsTypes.Range | undefined): Range | undefined;
|
|
264
|
+
export function toRange(range: lsTypes.Range | undefined): Range | undefined {
|
|
265
|
+
if (!range) {
|
|
266
|
+
return void 0;
|
|
267
|
+
}
|
|
268
|
+
return new Range(
|
|
269
|
+
range.start.line + 1,
|
|
270
|
+
range.start.character + 1,
|
|
271
|
+
range.end.line + 1,
|
|
272
|
+
range.end.character + 1
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function isInsertReplaceEdit(
|
|
277
|
+
edit: lsTypes.TextEdit | lsTypes.InsertReplaceEdit
|
|
278
|
+
): edit is lsTypes.InsertReplaceEdit {
|
|
279
|
+
return (
|
|
280
|
+
typeof (<lsTypes.InsertReplaceEdit>edit).insert !== 'undefined' &&
|
|
281
|
+
typeof (<lsTypes.InsertReplaceEdit>edit).replace !== 'undefined'
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function toCompletionItemKind(kind: number | undefined): languages.CompletionItemKind {
|
|
286
|
+
const mItemKind = languages.CompletionItemKind;
|
|
287
|
+
|
|
288
|
+
switch (kind) {
|
|
289
|
+
case lsTypes.CompletionItemKind.Text:
|
|
290
|
+
return mItemKind.Text;
|
|
291
|
+
case lsTypes.CompletionItemKind.Method:
|
|
292
|
+
return mItemKind.Method;
|
|
293
|
+
case lsTypes.CompletionItemKind.Function:
|
|
294
|
+
return mItemKind.Function;
|
|
295
|
+
case lsTypes.CompletionItemKind.Constructor:
|
|
296
|
+
return mItemKind.Constructor;
|
|
297
|
+
case lsTypes.CompletionItemKind.Field:
|
|
298
|
+
return mItemKind.Field;
|
|
299
|
+
case lsTypes.CompletionItemKind.Variable:
|
|
300
|
+
return mItemKind.Variable;
|
|
301
|
+
case lsTypes.CompletionItemKind.Class:
|
|
302
|
+
return mItemKind.Class;
|
|
303
|
+
case lsTypes.CompletionItemKind.Interface:
|
|
304
|
+
return mItemKind.Interface;
|
|
305
|
+
case lsTypes.CompletionItemKind.Module:
|
|
306
|
+
return mItemKind.Module;
|
|
307
|
+
case lsTypes.CompletionItemKind.Property:
|
|
308
|
+
return mItemKind.Property;
|
|
309
|
+
case lsTypes.CompletionItemKind.Unit:
|
|
310
|
+
return mItemKind.Unit;
|
|
311
|
+
case lsTypes.CompletionItemKind.Value:
|
|
312
|
+
return mItemKind.Value;
|
|
313
|
+
case lsTypes.CompletionItemKind.Enum:
|
|
314
|
+
return mItemKind.Enum;
|
|
315
|
+
case lsTypes.CompletionItemKind.Keyword:
|
|
316
|
+
return mItemKind.Keyword;
|
|
317
|
+
case lsTypes.CompletionItemKind.Snippet:
|
|
318
|
+
return mItemKind.Snippet;
|
|
319
|
+
case lsTypes.CompletionItemKind.Color:
|
|
320
|
+
return mItemKind.Color;
|
|
321
|
+
case lsTypes.CompletionItemKind.File:
|
|
322
|
+
return mItemKind.File;
|
|
323
|
+
case lsTypes.CompletionItemKind.Reference:
|
|
324
|
+
return mItemKind.Reference;
|
|
325
|
+
}
|
|
326
|
+
return mItemKind.Property;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function fromCompletionItemKind(kind: languages.CompletionItemKind): lsTypes.CompletionItemKind {
|
|
330
|
+
const mItemKind = languages.CompletionItemKind;
|
|
331
|
+
|
|
332
|
+
switch (kind) {
|
|
333
|
+
case mItemKind.Text:
|
|
334
|
+
return lsTypes.CompletionItemKind.Text;
|
|
335
|
+
case mItemKind.Method:
|
|
336
|
+
return lsTypes.CompletionItemKind.Method;
|
|
337
|
+
case mItemKind.Function:
|
|
338
|
+
return lsTypes.CompletionItemKind.Function;
|
|
339
|
+
case mItemKind.Constructor:
|
|
340
|
+
return lsTypes.CompletionItemKind.Constructor;
|
|
341
|
+
case mItemKind.Field:
|
|
342
|
+
return lsTypes.CompletionItemKind.Field;
|
|
343
|
+
case mItemKind.Variable:
|
|
344
|
+
return lsTypes.CompletionItemKind.Variable;
|
|
345
|
+
case mItemKind.Class:
|
|
346
|
+
return lsTypes.CompletionItemKind.Class;
|
|
347
|
+
case mItemKind.Interface:
|
|
348
|
+
return lsTypes.CompletionItemKind.Interface;
|
|
349
|
+
case mItemKind.Module:
|
|
350
|
+
return lsTypes.CompletionItemKind.Module;
|
|
351
|
+
case mItemKind.Property:
|
|
352
|
+
return lsTypes.CompletionItemKind.Property;
|
|
353
|
+
case mItemKind.Unit:
|
|
354
|
+
return lsTypes.CompletionItemKind.Unit;
|
|
355
|
+
case mItemKind.Value:
|
|
356
|
+
return lsTypes.CompletionItemKind.Value;
|
|
357
|
+
case mItemKind.Enum:
|
|
358
|
+
return lsTypes.CompletionItemKind.Enum;
|
|
359
|
+
case mItemKind.Keyword:
|
|
360
|
+
return lsTypes.CompletionItemKind.Keyword;
|
|
361
|
+
case mItemKind.Snippet:
|
|
362
|
+
return lsTypes.CompletionItemKind.Snippet;
|
|
363
|
+
case mItemKind.Color:
|
|
364
|
+
return lsTypes.CompletionItemKind.Color;
|
|
365
|
+
case mItemKind.File:
|
|
366
|
+
return lsTypes.CompletionItemKind.File;
|
|
367
|
+
case mItemKind.Reference:
|
|
368
|
+
return lsTypes.CompletionItemKind.Reference;
|
|
369
|
+
}
|
|
370
|
+
return lsTypes.CompletionItemKind.Property;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export function toTextEdit(textEdit: lsTypes.TextEdit): languages.TextEdit;
|
|
374
|
+
export function toTextEdit(textEdit: undefined): undefined;
|
|
375
|
+
export function toTextEdit(textEdit: lsTypes.TextEdit | undefined): languages.TextEdit | undefined;
|
|
376
|
+
export function toTextEdit(textEdit: lsTypes.TextEdit | undefined): languages.TextEdit | undefined {
|
|
377
|
+
if (!textEdit) {
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
range: toRange(textEdit.range),
|
|
382
|
+
text: textEdit.newText
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function toCommand(c: lsTypes.Command | undefined): languages.Command | undefined {
|
|
387
|
+
return c && c.command === 'editor.action.triggerSuggest'
|
|
388
|
+
? { id: c.command, title: c.title, arguments: c.arguments }
|
|
389
|
+
: undefined;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
//#endregion
|
|
393
|
+
|
|
394
|
+
//#region HoverAdapter
|
|
395
|
+
|
|
396
|
+
export interface ILanguageWorkerWithHover {
|
|
397
|
+
doHover(uri: string, position: lsTypes.Position): Promise<lsTypes.Hover | null>;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export class HoverAdapter<T extends ILanguageWorkerWithHover> implements languages.HoverProvider {
|
|
401
|
+
constructor(private readonly _worker: WorkerAccessor<T>) {}
|
|
402
|
+
|
|
403
|
+
provideHover(
|
|
404
|
+
model: editor.IReadOnlyModel,
|
|
405
|
+
position: Position,
|
|
406
|
+
token: CancellationToken
|
|
407
|
+
): Promise<languages.Hover | undefined> {
|
|
408
|
+
let resource = model.uri;
|
|
409
|
+
|
|
410
|
+
return this._worker(resource)
|
|
411
|
+
.then((worker) => {
|
|
412
|
+
return worker.doHover(resource.toString(), fromPosition(position));
|
|
413
|
+
})
|
|
414
|
+
.then((info) => {
|
|
415
|
+
if (!info) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
return <languages.Hover>{
|
|
419
|
+
range: toRange(info.range),
|
|
420
|
+
contents: toMarkedStringArray(info.contents)
|
|
421
|
+
};
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function isMarkupContent(thing: any): thing is lsTypes.MarkupContent {
|
|
427
|
+
return (
|
|
428
|
+
thing && typeof thing === 'object' && typeof (<lsTypes.MarkupContent>thing).kind === 'string'
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function toMarkdownString(entry: lsTypes.MarkupContent | lsTypes.MarkedString): IMarkdownString {
|
|
433
|
+
if (typeof entry === 'string') {
|
|
434
|
+
return {
|
|
435
|
+
value: entry
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
if (isMarkupContent(entry)) {
|
|
439
|
+
if (entry.kind === 'plaintext') {
|
|
440
|
+
return {
|
|
441
|
+
value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&')
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
return {
|
|
445
|
+
value: entry.value
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return { value: '```' + entry.language + '\n' + entry.value + '\n```\n' };
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function toMarkedStringArray(
|
|
453
|
+
contents: lsTypes.MarkupContent | lsTypes.MarkedString | lsTypes.MarkedString[]
|
|
454
|
+
): IMarkdownString[] | undefined {
|
|
455
|
+
if (!contents) {
|
|
456
|
+
return void 0;
|
|
457
|
+
}
|
|
458
|
+
if (Array.isArray(contents)) {
|
|
459
|
+
return contents.map(toMarkdownString);
|
|
460
|
+
}
|
|
461
|
+
return [toMarkdownString(contents)];
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
//#endregion
|
|
465
|
+
|
|
466
|
+
//#region DocumentHighlightAdapter
|
|
467
|
+
|
|
468
|
+
export interface ILanguageWorkerWithDocumentHighlights {
|
|
469
|
+
findDocumentHighlights(
|
|
470
|
+
uri: string,
|
|
471
|
+
position: lsTypes.Position
|
|
472
|
+
): Promise<lsTypes.DocumentHighlight[]>;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export class DocumentHighlightAdapter<T extends ILanguageWorkerWithDocumentHighlights>
|
|
476
|
+
implements languages.DocumentHighlightProvider
|
|
477
|
+
{
|
|
478
|
+
constructor(private readonly _worker: WorkerAccessor<T>) {}
|
|
479
|
+
|
|
480
|
+
public provideDocumentHighlights(
|
|
481
|
+
model: editor.IReadOnlyModel,
|
|
482
|
+
position: Position,
|
|
483
|
+
token: CancellationToken
|
|
484
|
+
): Promise<languages.DocumentHighlight[] | undefined> {
|
|
485
|
+
const resource = model.uri;
|
|
486
|
+
|
|
487
|
+
return this._worker(resource)
|
|
488
|
+
.then((worker) => worker.findDocumentHighlights(resource.toString(), fromPosition(position)))
|
|
489
|
+
.then((entries) => {
|
|
490
|
+
if (!entries) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
return entries.map((entry) => {
|
|
494
|
+
return <languages.DocumentHighlight>{
|
|
495
|
+
range: toRange(entry.range),
|
|
496
|
+
kind: toDocumentHighlightKind(entry.kind)
|
|
497
|
+
};
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function toDocumentHighlightKind(
|
|
504
|
+
kind: lsTypes.DocumentHighlightKind | undefined
|
|
505
|
+
): languages.DocumentHighlightKind {
|
|
506
|
+
switch (kind) {
|
|
507
|
+
case lsTypes.DocumentHighlightKind.Read:
|
|
508
|
+
return languages.DocumentHighlightKind.Read;
|
|
509
|
+
case lsTypes.DocumentHighlightKind.Write:
|
|
510
|
+
return languages.DocumentHighlightKind.Write;
|
|
511
|
+
case lsTypes.DocumentHighlightKind.Text:
|
|
512
|
+
return languages.DocumentHighlightKind.Text;
|
|
513
|
+
}
|
|
514
|
+
return languages.DocumentHighlightKind.Text;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
//#endregion
|
|
518
|
+
|
|
519
|
+
//#region DefinitionAdapter
|
|
520
|
+
|
|
521
|
+
export interface ILanguageWorkerWithDefinitions {
|
|
522
|
+
findDefinition(uri: string, position: lsTypes.Position): Promise<lsTypes.Location | null>;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
export class DefinitionAdapter<T extends ILanguageWorkerWithDefinitions>
|
|
526
|
+
implements languages.DefinitionProvider
|
|
527
|
+
{
|
|
528
|
+
constructor(private readonly _worker: WorkerAccessor<T>) {}
|
|
529
|
+
|
|
530
|
+
public provideDefinition(
|
|
531
|
+
model: editor.IReadOnlyModel,
|
|
532
|
+
position: Position,
|
|
533
|
+
token: CancellationToken
|
|
534
|
+
): Promise<languages.Definition | undefined> {
|
|
535
|
+
const resource = model.uri;
|
|
536
|
+
|
|
537
|
+
return this._worker(resource)
|
|
538
|
+
.then((worker) => {
|
|
539
|
+
return worker.findDefinition(resource.toString(), fromPosition(position));
|
|
540
|
+
})
|
|
541
|
+
.then((definition) => {
|
|
542
|
+
if (!definition) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
return [toLocation(definition)];
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function toLocation(location: lsTypes.Location): languages.Location {
|
|
551
|
+
return {
|
|
552
|
+
uri: Uri.parse(location.uri),
|
|
553
|
+
range: toRange(location.range)
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
//#endregion
|
|
558
|
+
|
|
559
|
+
//#region ReferenceAdapter
|
|
560
|
+
|
|
561
|
+
export interface ILanguageWorkerWithReferences {
|
|
562
|
+
findReferences(uri: string, position: lsTypes.Position): Promise<lsTypes.Location[]>;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export class ReferenceAdapter<T extends ILanguageWorkerWithReferences>
|
|
566
|
+
implements languages.ReferenceProvider
|
|
567
|
+
{
|
|
568
|
+
constructor(private readonly _worker: WorkerAccessor<T>) {}
|
|
569
|
+
|
|
570
|
+
provideReferences(
|
|
571
|
+
model: editor.IReadOnlyModel,
|
|
572
|
+
position: Position,
|
|
573
|
+
context: languages.ReferenceContext,
|
|
574
|
+
token: CancellationToken
|
|
575
|
+
): Promise<languages.Location[] | undefined> {
|
|
576
|
+
const resource = model.uri;
|
|
577
|
+
|
|
578
|
+
return this._worker(resource)
|
|
579
|
+
.then((worker) => {
|
|
580
|
+
return worker.findReferences(resource.toString(), fromPosition(position));
|
|
581
|
+
})
|
|
582
|
+
.then((entries) => {
|
|
583
|
+
if (!entries) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
return entries.map(toLocation);
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
//#endregion
|
|
592
|
+
|
|
593
|
+
//#region RenameAdapter
|
|
594
|
+
|
|
595
|
+
export interface ILanguageWorkerWithRename {
|
|
596
|
+
doRename(
|
|
597
|
+
uri: string,
|
|
598
|
+
position: lsTypes.Position,
|
|
599
|
+
newName: string
|
|
600
|
+
): Promise<lsTypes.WorkspaceEdit | null>;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export class RenameAdapter<T extends ILanguageWorkerWithRename>
|
|
604
|
+
implements languages.RenameProvider
|
|
605
|
+
{
|
|
606
|
+
constructor(private readonly _worker: WorkerAccessor<T>) {}
|
|
607
|
+
|
|
608
|
+
provideRenameEdits(
|
|
609
|
+
model: editor.IReadOnlyModel,
|
|
610
|
+
position: Position,
|
|
611
|
+
newName: string,
|
|
612
|
+
token: CancellationToken
|
|
613
|
+
): Promise<languages.WorkspaceEdit | undefined> {
|
|
614
|
+
const resource = model.uri;
|
|
615
|
+
|
|
616
|
+
return this._worker(resource)
|
|
617
|
+
.then((worker) => {
|
|
618
|
+
return worker.doRename(resource.toString(), fromPosition(position), newName);
|
|
619
|
+
})
|
|
620
|
+
.then((edit) => {
|
|
621
|
+
return toWorkspaceEdit(edit);
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function toWorkspaceEdit(edit: lsTypes.WorkspaceEdit | null): languages.WorkspaceEdit | undefined {
|
|
627
|
+
if (!edit || !edit.changes) {
|
|
628
|
+
return void 0;
|
|
629
|
+
}
|
|
630
|
+
let resourceEdits: languages.IWorkspaceTextEdit[] = [];
|
|
631
|
+
for (let uri in edit.changes) {
|
|
632
|
+
const _uri = Uri.parse(uri);
|
|
633
|
+
for (let e of edit.changes[uri]) {
|
|
634
|
+
resourceEdits.push({
|
|
635
|
+
resource: _uri,
|
|
636
|
+
versionId: undefined,
|
|
637
|
+
textEdit: {
|
|
638
|
+
range: toRange(e.range),
|
|
639
|
+
text: e.newText
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return {
|
|
645
|
+
edits: resourceEdits
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
//#endregion
|
|
650
|
+
|
|
651
|
+
//#region DocumentSymbolAdapter
|
|
652
|
+
|
|
653
|
+
export interface ILanguageWorkerWithDocumentSymbols {
|
|
654
|
+
findDocumentSymbols(uri: string): Promise<lsTypes.SymbolInformation[] | lsTypes.DocumentSymbol[]>;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
export class DocumentSymbolAdapter<T extends ILanguageWorkerWithDocumentSymbols>
|
|
658
|
+
implements languages.DocumentSymbolProvider
|
|
659
|
+
{
|
|
660
|
+
constructor(private readonly _worker: WorkerAccessor<T>) {}
|
|
661
|
+
|
|
662
|
+
public provideDocumentSymbols(
|
|
663
|
+
model: editor.IReadOnlyModel,
|
|
664
|
+
token: CancellationToken
|
|
665
|
+
): Promise<languages.DocumentSymbol[] | undefined> {
|
|
666
|
+
const resource = model.uri;
|
|
667
|
+
|
|
668
|
+
return this._worker(resource)
|
|
669
|
+
.then((worker) => worker.findDocumentSymbols(resource.toString()))
|
|
670
|
+
.then((items) => {
|
|
671
|
+
if (!items) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
return items.map((item) => {
|
|
675
|
+
if (isDocumentSymbol(item)) {
|
|
676
|
+
return toDocumentSymbol(item);
|
|
677
|
+
}
|
|
678
|
+
return {
|
|
679
|
+
name: item.name,
|
|
680
|
+
detail: '',
|
|
681
|
+
containerName: item.containerName,
|
|
682
|
+
kind: toSymbolKind(item.kind),
|
|
683
|
+
range: toRange(item.location.range),
|
|
684
|
+
selectionRange: toRange(item.location.range),
|
|
685
|
+
tags: []
|
|
686
|
+
};
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function isDocumentSymbol(
|
|
693
|
+
symbol: lsTypes.SymbolInformation | lsTypes.DocumentSymbol
|
|
694
|
+
): symbol is lsTypes.DocumentSymbol {
|
|
695
|
+
return 'children' in symbol;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
function toDocumentSymbol(symbol: lsTypes.DocumentSymbol): languages.DocumentSymbol {
|
|
699
|
+
return {
|
|
700
|
+
name: symbol.name,
|
|
701
|
+
detail: symbol.detail ?? '',
|
|
702
|
+
kind: toSymbolKind(symbol.kind),
|
|
703
|
+
range: toRange(symbol.range),
|
|
704
|
+
selectionRange: toRange(symbol.selectionRange),
|
|
705
|
+
tags: symbol.tags ?? [],
|
|
706
|
+
children: (symbol.children ?? []).map((item) => toDocumentSymbol(item))
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function toSymbolKind(kind: lsTypes.SymbolKind): languages.SymbolKind {
|
|
711
|
+
let mKind = languages.SymbolKind;
|
|
712
|
+
|
|
713
|
+
switch (kind) {
|
|
714
|
+
case lsTypes.SymbolKind.File:
|
|
715
|
+
return mKind.File;
|
|
716
|
+
case lsTypes.SymbolKind.Module:
|
|
717
|
+
return mKind.Module;
|
|
718
|
+
case lsTypes.SymbolKind.Namespace:
|
|
719
|
+
return mKind.Namespace;
|
|
720
|
+
case lsTypes.SymbolKind.Package:
|
|
721
|
+
return mKind.Package;
|
|
722
|
+
case lsTypes.SymbolKind.Class:
|
|
723
|
+
return mKind.Class;
|
|
724
|
+
case lsTypes.SymbolKind.Method:
|
|
725
|
+
return mKind.Method;
|
|
726
|
+
case lsTypes.SymbolKind.Property:
|
|
727
|
+
return mKind.Property;
|
|
728
|
+
case lsTypes.SymbolKind.Field:
|
|
729
|
+
return mKind.Field;
|
|
730
|
+
case lsTypes.SymbolKind.Constructor:
|
|
731
|
+
return mKind.Constructor;
|
|
732
|
+
case lsTypes.SymbolKind.Enum:
|
|
733
|
+
return mKind.Enum;
|
|
734
|
+
case lsTypes.SymbolKind.Interface:
|
|
735
|
+
return mKind.Interface;
|
|
736
|
+
case lsTypes.SymbolKind.Function:
|
|
737
|
+
return mKind.Function;
|
|
738
|
+
case lsTypes.SymbolKind.Variable:
|
|
739
|
+
return mKind.Variable;
|
|
740
|
+
case lsTypes.SymbolKind.Constant:
|
|
741
|
+
return mKind.Constant;
|
|
742
|
+
case lsTypes.SymbolKind.String:
|
|
743
|
+
return mKind.String;
|
|
744
|
+
case lsTypes.SymbolKind.Number:
|
|
745
|
+
return mKind.Number;
|
|
746
|
+
case lsTypes.SymbolKind.Boolean:
|
|
747
|
+
return mKind.Boolean;
|
|
748
|
+
case lsTypes.SymbolKind.Array:
|
|
749
|
+
return mKind.Array;
|
|
750
|
+
}
|
|
751
|
+
return mKind.Function;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
//#endregion
|
|
755
|
+
|
|
756
|
+
//#region DocumentLinkAdapter
|
|
757
|
+
|
|
758
|
+
export interface ILanguageWorkerWithDocumentLinks {
|
|
759
|
+
findDocumentLinks(uri: string): Promise<lsTypes.DocumentLink[]>;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
export class DocumentLinkAdapter<T extends ILanguageWorkerWithDocumentLinks>
|
|
763
|
+
implements languages.LinkProvider
|
|
764
|
+
{
|
|
765
|
+
constructor(private _worker: WorkerAccessor<T>) {}
|
|
766
|
+
|
|
767
|
+
public provideLinks(
|
|
768
|
+
model: editor.IReadOnlyModel,
|
|
769
|
+
token: CancellationToken
|
|
770
|
+
): Promise<languages.ILinksList | undefined> {
|
|
771
|
+
const resource = model.uri;
|
|
772
|
+
|
|
773
|
+
return this._worker(resource)
|
|
774
|
+
.then((worker) => worker.findDocumentLinks(resource.toString()))
|
|
775
|
+
.then((items) => {
|
|
776
|
+
if (!items) {
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
return {
|
|
780
|
+
links: items.map((item) => ({
|
|
781
|
+
range: toRange(item.range),
|
|
782
|
+
url: item.target
|
|
783
|
+
}))
|
|
784
|
+
};
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
//#endregion
|
|
790
|
+
|
|
791
|
+
//#region DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider
|
|
792
|
+
|
|
793
|
+
export interface ILanguageWorkerWithFormat {
|
|
794
|
+
format(
|
|
795
|
+
uri: string,
|
|
796
|
+
range: lsTypes.Range | null,
|
|
797
|
+
options: lsTypes.FormattingOptions
|
|
798
|
+
): Promise<lsTypes.TextEdit[]>;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
export class DocumentFormattingEditProvider<T extends ILanguageWorkerWithFormat>
|
|
802
|
+
implements languages.DocumentFormattingEditProvider
|
|
803
|
+
{
|
|
804
|
+
constructor(private _worker: WorkerAccessor<T>) {}
|
|
805
|
+
|
|
806
|
+
public provideDocumentFormattingEdits(
|
|
807
|
+
model: editor.IReadOnlyModel,
|
|
808
|
+
options: languages.FormattingOptions,
|
|
809
|
+
token: CancellationToken
|
|
810
|
+
): Promise<languages.TextEdit[] | undefined> {
|
|
811
|
+
const resource = model.uri;
|
|
812
|
+
|
|
813
|
+
return this._worker(resource).then((worker) => {
|
|
814
|
+
return worker
|
|
815
|
+
.format(resource.toString(), null, fromFormattingOptions(options))
|
|
816
|
+
.then((edits) => {
|
|
817
|
+
if (!edits || edits.length === 0) {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
return edits.map<languages.TextEdit>(toTextEdit);
|
|
821
|
+
});
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
export class DocumentRangeFormattingEditProvider<T extends ILanguageWorkerWithFormat>
|
|
827
|
+
implements languages.DocumentRangeFormattingEditProvider
|
|
828
|
+
{
|
|
829
|
+
readonly canFormatMultipleRanges = false;
|
|
830
|
+
|
|
831
|
+
constructor(private _worker: WorkerAccessor<T>) {}
|
|
832
|
+
|
|
833
|
+
public provideDocumentRangeFormattingEdits(
|
|
834
|
+
model: editor.IReadOnlyModel,
|
|
835
|
+
range: Range,
|
|
836
|
+
options: languages.FormattingOptions,
|
|
837
|
+
token: CancellationToken
|
|
838
|
+
): Promise<languages.TextEdit[] | undefined> {
|
|
839
|
+
const resource = model.uri;
|
|
840
|
+
|
|
841
|
+
return this._worker(resource).then((worker) => {
|
|
842
|
+
return worker
|
|
843
|
+
.format(resource.toString(), fromRange(range), fromFormattingOptions(options))
|
|
844
|
+
.then((edits) => {
|
|
845
|
+
if (!edits || edits.length === 0) {
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
return edits.map<languages.TextEdit>(toTextEdit);
|
|
849
|
+
});
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
function fromFormattingOptions(options: languages.FormattingOptions): lsTypes.FormattingOptions {
|
|
855
|
+
return {
|
|
856
|
+
tabSize: options.tabSize,
|
|
857
|
+
insertSpaces: options.insertSpaces
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
//#endregion
|
|
862
|
+
|
|
863
|
+
//#region DocumentColorAdapter
|
|
864
|
+
|
|
865
|
+
export interface ILanguageWorkerWithDocumentColors {
|
|
866
|
+
findDocumentColors(uri: string): Promise<lsTypes.ColorInformation[]>;
|
|
867
|
+
getColorPresentations(
|
|
868
|
+
uri: string,
|
|
869
|
+
color: lsTypes.Color,
|
|
870
|
+
range: lsTypes.Range
|
|
871
|
+
): Promise<lsTypes.ColorPresentation[]>;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
export class DocumentColorAdapter<T extends ILanguageWorkerWithDocumentColors>
|
|
875
|
+
implements languages.DocumentColorProvider
|
|
876
|
+
{
|
|
877
|
+
constructor(private readonly _worker: WorkerAccessor<T>) {}
|
|
878
|
+
|
|
879
|
+
public provideDocumentColors(
|
|
880
|
+
model: editor.IReadOnlyModel,
|
|
881
|
+
token: CancellationToken
|
|
882
|
+
): Promise<languages.IColorInformation[] | undefined> {
|
|
883
|
+
const resource = model.uri;
|
|
884
|
+
|
|
885
|
+
return this._worker(resource)
|
|
886
|
+
.then((worker) => worker.findDocumentColors(resource.toString()))
|
|
887
|
+
.then((infos) => {
|
|
888
|
+
if (!infos) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
return infos.map((item) => ({
|
|
892
|
+
color: item.color,
|
|
893
|
+
range: toRange(item.range)
|
|
894
|
+
}));
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
public provideColorPresentations(
|
|
899
|
+
model: editor.IReadOnlyModel,
|
|
900
|
+
info: languages.IColorInformation,
|
|
901
|
+
token: CancellationToken
|
|
902
|
+
): Promise<languages.IColorPresentation[] | undefined> {
|
|
903
|
+
const resource = model.uri;
|
|
904
|
+
|
|
905
|
+
return this._worker(resource)
|
|
906
|
+
.then((worker) =>
|
|
907
|
+
worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range))
|
|
908
|
+
)
|
|
909
|
+
.then((presentations) => {
|
|
910
|
+
if (!presentations) {
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
return presentations.map((presentation) => {
|
|
914
|
+
let item: languages.IColorPresentation = {
|
|
915
|
+
label: presentation.label
|
|
916
|
+
};
|
|
917
|
+
if (presentation.textEdit) {
|
|
918
|
+
item.textEdit = toTextEdit(presentation.textEdit);
|
|
919
|
+
}
|
|
920
|
+
if (presentation.additionalTextEdits) {
|
|
921
|
+
item.additionalTextEdits =
|
|
922
|
+
presentation.additionalTextEdits.map<languages.TextEdit>(toTextEdit);
|
|
923
|
+
}
|
|
924
|
+
return item;
|
|
925
|
+
});
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
//#endregion
|
|
931
|
+
|
|
932
|
+
//#region FoldingRangeAdapter
|
|
933
|
+
|
|
934
|
+
export interface ILanguageWorkerWithFoldingRanges {
|
|
935
|
+
getFoldingRanges(uri: string, context?: { rangeLimit?: number }): Promise<lsTypes.FoldingRange[]>;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
export class FoldingRangeAdapter<T extends ILanguageWorkerWithFoldingRanges>
|
|
939
|
+
implements languages.FoldingRangeProvider
|
|
940
|
+
{
|
|
941
|
+
constructor(private _worker: WorkerAccessor<T>) {}
|
|
942
|
+
|
|
943
|
+
public provideFoldingRanges(
|
|
944
|
+
model: editor.IReadOnlyModel,
|
|
945
|
+
context: languages.FoldingContext,
|
|
946
|
+
token: CancellationToken
|
|
947
|
+
): Promise<languages.FoldingRange[] | undefined> {
|
|
948
|
+
const resource = model.uri;
|
|
949
|
+
|
|
950
|
+
return this._worker(resource)
|
|
951
|
+
.then((worker) => worker.getFoldingRanges(resource.toString(), context))
|
|
952
|
+
.then((ranges) => {
|
|
953
|
+
if (!ranges) {
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
return ranges.map((range) => {
|
|
957
|
+
const result: languages.FoldingRange = {
|
|
958
|
+
start: range.startLine + 1,
|
|
959
|
+
end: range.endLine + 1
|
|
960
|
+
};
|
|
961
|
+
if (typeof range.kind !== 'undefined') {
|
|
962
|
+
result.kind = toFoldingRangeKind(<lsTypes.FoldingRangeKind>range.kind);
|
|
963
|
+
}
|
|
964
|
+
return result;
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
function toFoldingRangeKind(
|
|
971
|
+
kind: lsTypes.FoldingRangeKind
|
|
972
|
+
): languages.FoldingRangeKind | undefined {
|
|
973
|
+
switch (kind) {
|
|
974
|
+
case lsTypes.FoldingRangeKind.Comment:
|
|
975
|
+
return languages.FoldingRangeKind.Comment;
|
|
976
|
+
case lsTypes.FoldingRangeKind.Imports:
|
|
977
|
+
return languages.FoldingRangeKind.Imports;
|
|
978
|
+
case lsTypes.FoldingRangeKind.Region:
|
|
979
|
+
return languages.FoldingRangeKind.Region;
|
|
980
|
+
}
|
|
981
|
+
return void 0;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
//#endregion
|
|
985
|
+
|
|
986
|
+
//#region SelectionRangeAdapter
|
|
987
|
+
|
|
988
|
+
export interface ILanguageWorkerWithSelectionRanges {
|
|
989
|
+
getSelectionRanges(uri: string, positions: lsTypes.Position[]): Promise<lsTypes.SelectionRange[]>;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
export class SelectionRangeAdapter<T extends ILanguageWorkerWithSelectionRanges>
|
|
993
|
+
implements languages.SelectionRangeProvider
|
|
994
|
+
{
|
|
995
|
+
constructor(private _worker: WorkerAccessor<T>) {}
|
|
996
|
+
|
|
997
|
+
public provideSelectionRanges(
|
|
998
|
+
model: editor.IReadOnlyModel,
|
|
999
|
+
positions: Position[],
|
|
1000
|
+
token: CancellationToken
|
|
1001
|
+
): Promise<languages.SelectionRange[][] | undefined> {
|
|
1002
|
+
const resource = model.uri;
|
|
1003
|
+
|
|
1004
|
+
return this._worker(resource)
|
|
1005
|
+
.then((worker) =>
|
|
1006
|
+
worker.getSelectionRanges(
|
|
1007
|
+
resource.toString(),
|
|
1008
|
+
positions.map<lsTypes.Position>(fromPosition)
|
|
1009
|
+
)
|
|
1010
|
+
)
|
|
1011
|
+
.then((selectionRanges) => {
|
|
1012
|
+
if (!selectionRanges) {
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
return selectionRanges.map((selectionRange: lsTypes.SelectionRange | undefined) => {
|
|
1016
|
+
const result: languages.SelectionRange[] = [];
|
|
1017
|
+
while (selectionRange) {
|
|
1018
|
+
result.push({ range: toRange(selectionRange.range) });
|
|
1019
|
+
selectionRange = selectionRange.parent;
|
|
1020
|
+
}
|
|
1021
|
+
return result;
|
|
1022
|
+
});
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
//#endregion
|