generated from justjavac/deno_starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: 迷渡 <[email protected]>
- Loading branch information
Showing
9 changed files
with
3,753 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,23 @@ | ||
# deno-starter | ||
# VSCode Language Server - Deno | ||
|
||
[](https://github.com/denomod/deno-starter/releases) | ||
[](https://github.com/denomod/deno-starter/actions) | ||
[](https://github.com/denomod/deno-starter/blob/master/LICENSE) | ||
[](https://github.com/denoland/deno) | ||
[](https://github.com/denodev/deno_vscode_languageserver/releases) | ||
[](https://github.com/denodev/deno_vscode_languageserver/actions) | ||
[](https://github.com/denodev/deno_vscode_languageserver/blob/master/LICENSE) | ||
[](https://github.com/denoland/deno) | ||
|
||
Quickly start a Deno module. | ||
Language server protocol implementation for VSCode. This allows implementing language services in JS/TS running on Deno. | ||
|
||
## 🧐 What's inside? | ||
This repository contains the code for the following Deno modules: | ||
|
||
A quick look at the files and directories you'll see in a Deno project. | ||
- vscode_languageserver: implement a VSCode language server using Deno as a runtime. | ||
- vscode_languageserver_textdocument: implement text documents usable in a LSP server using Deno as a runtime. | ||
- vscode_languageserver_protocol: the actual language server protocol definition in TypeScript. | ||
- vscode_languageserver_types: data types used by the language server client and server. | ||
|
||
. | ||
├─ .github | ||
│ └─ workflows | ||
│ └─ ci.yml | ||
├─ .vscode | ||
├─ .vscode | ||
│ ├─ extensions.json | ||
│ └─ settings.json | ||
├─ .gitignore | ||
├─ CHANGELOG.md | ||
├─ LICENSE | ||
├─ mod_test.ts | ||
├─ mod.ts | ||
└─ README.md | ||
- vscode_jsonrpc: the underlying message protocol to communicate between a client and a server. | ||
|
||
1. **`.github\workflows\ci.yml`**: GitHub Actions. | ||
|
||
1. **`.vscode\extensions.json`**: Workspace recommended extensions for Deno Developers. | ||
|
||
1. **`.gitignore`**: This file tells git which files it should not track / not maintain a version history for. | ||
|
||
1. **`CHANGELOG.md`**: This file contains a curated, chronologically ordered list of notable changes for each version of a project. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
1. **`LICENSE`**: Deno is licensed under the MIT license. | ||
|
||
1. **`mod.ts`**: Deno's default entry point. The filename mod.ts follows Rust’s convention, is shorter than index.ts, and doesn’t come with any preconceived notions about how it might work. Deno does not treat "index.js" or "index.ts" in a special way. By using these filenames, it suggests that they can be left out of the module specifier when they cannot. This is confusing. | ||
|
||
1. **`mod_test.ts`**: Each module should come with its test as a sibling with the name `modulename_test.ts`. For example the module `foo.ts` should come with its sibling `foo_test.ts`. | ||
|
||
1. **`README.md`**: A text file containing useful reference information about your project. | ||
**NOTE**: vscode-languageclient: npm module to talk to a VSCode language server from a VSCode extension | ||
|
||
### License | ||
|
||
[deno-starter](https://github.com/denomod/deno-starter) is released under the MIT License. See the bundled [LICENSE](./LICENSE) file for details. | ||
[deno_vscode_languageserver](https://github.com/denodev/deno_vscode_languageserver) is released under the MIT License. See the bundled [LICENSE](./LICENSE) file for details. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# VSCode Language Server Types | ||
|
||
[](https://github.com/denodev/deno_vscode_languageserver/releases) | ||
[](https://github.com/denodev/deno_vscode_languageserver/actions) | ||
|
||
Deno module containing the types used by the VSCode language client and [Deno](https://deno.land) language server. | ||
|
||
**Modified from [microsoft/vscode-languageserver-node's types @5120691](https://github.com/microsoft/vscode-languageserver-node/blob/5120691bf187dd608ee65efdadc86d25feb45c41/types/src/main.ts)**. | ||
|
||
-------------- | ||
|
||
> Click [here](https://code.visualstudio.com/docs/extensions/example-language-server) for a detailed document on how | ||
> to implement language servers for [VSCode](https://code.visualstudio.com/). | ||
> | ||
> ## History | ||
> | ||
> For the history please see the [main repository](https://github.com/Microsoft/vscode-languageserver-node/blob/master/README.md) | ||
> | ||
> ## License | ||
> [MIT](https://github.com/Microsoft/vscode-languageserver-node/blob/master/License.txt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
import { | ||
assertEquals, | ||
assertThrows, | ||
} from "https://deno.land/std/testing/asserts.ts"; | ||
import { TextDocument, TextEdit, Position, Range } from "./mod.ts"; | ||
|
||
const applyEdits = TextDocument.applyEdits; | ||
|
||
Deno.test(function editsInserts(): void { | ||
let input = TextDocument.create( | ||
"foo://bar/f", | ||
"html", | ||
0, | ||
"012345678901234567890123456789", | ||
); | ||
assertEquals( | ||
applyEdits(input, [TextEdit.insert(Position.create(0, 0), "Hello")]), | ||
"Hello012345678901234567890123456789", | ||
); | ||
assertEquals( | ||
applyEdits(input, [TextEdit.insert(Position.create(0, 1), "Hello")]), | ||
"0Hello12345678901234567890123456789", | ||
); | ||
assertEquals( | ||
applyEdits( | ||
input, | ||
[ | ||
TextEdit.insert(Position.create(0, 1), "Hello"), | ||
TextEdit.insert(Position.create(0, 1), "World"), | ||
], | ||
), | ||
"0HelloWorld12345678901234567890123456789", | ||
); | ||
assertEquals( | ||
applyEdits( | ||
input, | ||
[ | ||
TextEdit.insert(Position.create(0, 2), "One"), | ||
TextEdit.insert(Position.create(0, 1), "Hello"), | ||
TextEdit.insert(Position.create(0, 1), "World"), | ||
TextEdit.insert(Position.create(0, 2), "Two"), | ||
TextEdit.insert(Position.create(0, 2), "Three"), | ||
], | ||
), | ||
"0HelloWorld1OneTwoThree2345678901234567890123456789", | ||
); | ||
}); | ||
|
||
Deno.test(function editsReplace(): void { | ||
let input = TextDocument.create( | ||
"foo://bar/f", | ||
"html", | ||
0, | ||
"012345678901234567890123456789", | ||
); | ||
assertEquals( | ||
applyEdits( | ||
input, | ||
[TextEdit.replace( | ||
Range.create(Position.create(0, 3), Position.create(0, 6)), | ||
"Hello", | ||
)], | ||
), | ||
"012Hello678901234567890123456789", | ||
); | ||
assertEquals( | ||
applyEdits( | ||
input, | ||
[ | ||
TextEdit.replace( | ||
Range.create(Position.create(0, 3), Position.create(0, 6)), | ||
"Hello", | ||
), | ||
TextEdit.replace( | ||
Range.create(Position.create(0, 6), Position.create(0, 9)), | ||
"World", | ||
), | ||
], | ||
), | ||
"012HelloWorld901234567890123456789", | ||
); | ||
assertEquals( | ||
applyEdits( | ||
input, | ||
[ | ||
TextEdit.replace( | ||
Range.create(Position.create(0, 3), Position.create(0, 6)), | ||
"Hello", | ||
), | ||
TextEdit.insert(Position.create(0, 6), "World"), | ||
], | ||
), | ||
"012HelloWorld678901234567890123456789", | ||
); | ||
assertEquals( | ||
applyEdits( | ||
input, | ||
[ | ||
TextEdit.insert(Position.create(0, 6), "World"), | ||
TextEdit.replace( | ||
Range.create(Position.create(0, 3), Position.create(0, 6)), | ||
"Hello", | ||
), | ||
], | ||
), | ||
"012HelloWorld678901234567890123456789", | ||
); | ||
assertEquals( | ||
applyEdits( | ||
input, | ||
[ | ||
TextEdit.insert(Position.create(0, 3), "World"), | ||
TextEdit.replace( | ||
Range.create(Position.create(0, 3), Position.create(0, 6)), | ||
"Hello", | ||
), | ||
], | ||
), | ||
"012WorldHello678901234567890123456789", | ||
); | ||
}); | ||
|
||
Deno.test(function editsOverlap(): void { | ||
let input = TextDocument.create( | ||
"foo://bar/f", | ||
"html", | ||
0, | ||
"012345678901234567890123456789", | ||
); | ||
assertThrows(() => | ||
applyEdits( | ||
input, | ||
[ | ||
TextEdit.replace( | ||
Range.create(Position.create(0, 3), Position.create(0, 6)), | ||
"Hello", | ||
), | ||
TextEdit.insert(Position.create(0, 3), "World"), | ||
], | ||
) | ||
); | ||
assertThrows(() => | ||
applyEdits( | ||
input, | ||
[ | ||
TextEdit.replace( | ||
Range.create(Position.create(0, 3), Position.create(0, 6)), | ||
"Hello", | ||
), | ||
TextEdit.insert(Position.create(0, 4), "World"), | ||
], | ||
) | ||
); | ||
}); | ||
|
||
Deno.test(function editsMultiline(): void { | ||
let input = TextDocument.create("foo://bar/f", "html", 0, "0\n1\n2\n3\n4"); | ||
assertEquals( | ||
applyEdits( | ||
input, | ||
[ | ||
TextEdit.replace( | ||
Range.create(Position.create(2, 0), Position.create(3, 0)), | ||
"Hello", | ||
), | ||
TextEdit.insert(Position.create(1, 1), "World"), | ||
], | ||
), | ||
"0\n1World\nHello3\n4", | ||
); | ||
}); |
Oops, something went wrong.