delet(vscode)

This commit is contained in:
fosslinux 2019-02-10 15:03:47 +11:00
parent f79302b1d7
commit 9b439d4a34
119 changed files with 3 additions and 20043 deletions

View File

@ -61,9 +61,6 @@ vim-install:
vlc-install:
$(STOW_INSTALL) vlc
vscode-install:
$(STOW_INSTALL) vscode
w3m-install:
$(STOW_INSTALL) w3m
@ -146,9 +143,6 @@ vim-remove:
vlc-remove:
$(STOW_REMOVE) vlc
vscode-remove:
$(STOW_REMOVE) vscode
w3m-remove:
$(STOW_REMOVE) w3m
@ -231,9 +225,6 @@ vim-update:
vlc-update:
$(STOW_UPDATE) vlc
vscode-update:
$(STOW_UPDATE) vscode
w3m-update:
$(STOW_UPDATE) w3m
@ -259,7 +250,7 @@ zsh-update:
# = INSTALL TYPES =
# =======================
install-all: bash-install burrow-install gimp-install git-install gnupg-install libreoffice-install links2-install mixxx-install oh-my-zsh-install pavucontrol-install smplayer-install ssh-install thunar-install tmux-install torbrowser-install vim-install vlc-install vscode-install w3m-install weechat-install wget-install xarchiver-install xfce4-install youtube-dl-install zsh-install
install-all: bash-install burrow-install gimp-install git-install gnupg-install libreoffice-install links2-install mixxx-install oh-my-zsh-install pavucontrol-install smplayer-install ssh-install thunar-install tmux-install torbrowser-install vim-install vlc-install w3m-install weechat-install wget-install xarchiver-install xfce4-install youtube-dl-install zsh-install
install-base: bash-install oh-my-zsh-install ssh-install tmux-install vim-install zsh-install
@ -277,9 +268,9 @@ install-streaming: install-base mixxx-install vlc-install youtube-dl-install
# = GENERAL =
# =================
remove: bash-remove burrow-install gimp-install git-install gnupg-install libreoffice-install links2-install mixxx-install oh-my-zsh-install pavucontrol-install smplayer-install ssh-install thunar-install tmux-install torbrowser-install vim-install vlc-install vscode-install w3m-install weechat-install wget-install xarchiver-install xfce4-install youtube-dl-install zsh-install
remove: bash-remove burrow-install gimp-install git-install gnupg-install libreoffice-install links2-install mixxx-install oh-my-zsh-install pavucontrol-install smplayer-install ssh-install thunar-install tmux-install torbrowser-install vim-install vlc-install w3m-install weechat-install wget-install xarchiver-install xfce4-install youtube-dl-install zsh-install
update: bash-remove burrow-install gimp-install git-install gnupg-install libreoffice-install links2-install mixxx-install oh-my-zsh-install pavucontrol-install smplayer-install ssh-install thunar-install tmux-install torbrowser-install vim-install vlc-install vscode-install w3m-install weechat-install wget-install xarchiver-install xfce4-install youtube-dl-install zsh-install
update: bash-remove burrow-install gimp-install git-install gnupg-install libreoffice-install links2-install mixxx-install oh-my-zsh-install pavucontrol-install smplayer-install ssh-install thunar-install tmux-install torbrowser-install vim-install vlc-install w3m-install weechat-install wget-install xarchiver-install xfce4-install youtube-dl-install zsh-install
all: update

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Language="en-US" Id="better-toml" Version="0.3.2" Publisher="bungcip"/>
<DisplayName>Better TOML</DisplayName>
<Description xml:space="preserve">Better TOML Language support</Description>
<Tags>toml,TOML,__ext_toml</Tags>
<Categories>Languages</Categories>
<GalleryFlags>Public</GalleryFlags>
<Badges></Badges>
<Properties>
<Property Id="Microsoft.VisualStudio.Code.Engine" Value="^1.18.0" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionDependencies" Value="" />
<Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="https://github.com/bungcip/better-toml.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.Getstarted" Value="https://github.com/bungcip/better-toml.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.GitHub" Value="https://github.com/bungcip/better-toml.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.Support" Value="https://github.com/bungcip/better-toml/issues" />
<Property Id="Microsoft.VisualStudio.Services.Links.Learn" Value="https://github.com/bungcip/better-toml/blob/master/README.md" />
<Property Id="Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown" Value="true" />
</Properties>
<License>extension/LICENSE.txt</License>
<Icon>extension/icon.png</Icon>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Code"/>
</Installation>
<Dependencies/>
<Assets>
<Asset Type="Microsoft.VisualStudio.Code.Manifest" Path="extension/package.json" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Details" Path="extension/README.md" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Content.Changelog" Path="extension/CHANGELOG.md" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Content.License" Path="extension/LICENSE.txt" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Icons.Default" Path="extension/icon.png" Addressable="true" />
</Assets>
</PackageManifest>

View File

@ -1,29 +0,0 @@
# Changelog
## 0.3.2 | 2018-02-18
* TOML frontmatter in markdown. Thanks to @marcobeltempo's contribution. #10
* Added logo in extension. It use official logo from https://github.com/toml-lang/toml. #1
## 0.3.1 | 2017-09-25
### Bug fixes
* fix regression caused by new `toml.tmLanguage`
## 0.3.0 | 2017-09-22
### Bug fixes
* fix wrong color for homogeneous array
* allow keys to be single-quoted strings
## 0.2.0 | 2016-11-01
### Bug fixes
* Add Syntax validation for invalid `.toml` files
## 0.1.0 | 2016-10-30
### Bug fixes
* Initial release of `better toml`

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2018 Gigih Aji Ibrahim
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,17 +0,0 @@
# better-toml README
Better TOML is vs code extension to support TOML file.
## Features
- Syntax Hightlighting for `.toml` files
![Syntax Hightlighting](https://github.com/bungcip/better-toml/raw/master/images/feature_syntax_highlight.png)
- Syntax Validation for invalid input
![Syntax Validation](https://github.com/bungcip/better-toml/raw/master/images/feature_syntax_validation.gif)
- Syntax Hightligting for markdown frontmatter
![Frontmatter](https://github.com/bungcip/better-toml/raw/master/images/feature_frontmatter.gif)

View File

@ -1,33 +0,0 @@
This project incorporates components from the projects listed below.
The original copyright notices and the licenses are reproduced verbatim.
1. https://github.com/microsoft/vscode
===
MIT License
Copyright (c) 2015 - present Microsoft Corporation
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
===

Binary file not shown.

Before

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

View File

@ -1,24 +0,0 @@
{
"comments": {
"lineComment": "#"
},
"brackets": [
["{", "}"],
["[", "]"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}", "notIn": ["string"] },
{ "open": "[", "close": "]", "notIn": ["string"] },
{ "open": "(", "close": ")", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string"] },
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
{ "open": "`", "close": "`", "notIn": ["string", "comment"] }
],
"surroundingPairs": [
[ "(", ")" ],
[ "[", "]" ],
[ "{", "}" ],
[ "\"", "\""],
[ "'", "'"]
]
}

View File

@ -1,18 +0,0 @@
{
"node": true,
"browser": true,
"browserify": true,
"curly": true,
"eqeqeq": true,
"eqnull": false,
"latedef": "nofunc",
"newcap": true,
"noarg": true,
"undef": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"indent": 2,
"quotmark": true,
"laxbreak": true
}

View File

@ -1 +0,0 @@
node_modules/*

View File

@ -1,7 +0,0 @@
language: node_js
sudo: false
node_js:
- "4.1"
- "4.0"
- "0.12"
- "0.10"

View File

@ -1,116 +0,0 @@
2.3.0 - July 13 2015
====================
* Correctly handle quoted keys ([#21](https://github.com/BinaryMuse/toml-node/issues/21))
2.2.3 - June 8 2015
===================
* Support empty inline tables ([#24](https://github.com/BinaryMuse/toml-node/issues/24))
* Do not allow implicit table definitions to replace value ([#23](https://github.com/BinaryMuse/toml-node/issues/23))
* Don't allow tables to replace inline tables ([#25](https://github.com/BinaryMuse/toml-node/issues/25))
2.2.2 - April 3 2015
====================
* Correctly handle newlines at beginning of string ([#22](https://github.com/BinaryMuse/toml-node/issues/22))
2.2.1 - March 17 2015
=====================
* Parse dates generated by Date#toISOString() ([#20](https://github.com/BinaryMuse/toml-node/issues/20))
2.2.0 - Feb 26 2015
===================
* Support TOML spec v0.4.0
2.1.0 - Jan 7 2015
==================
* Support TOML spec v0.3.1
2.0.6 - May 23 2014
===================
### Bug Fixes
* Fix support for empty arrays with newlines ([#13](https://github.com/BinaryMuse/toml-node/issues/13))
2.0.5 - May 5 2014
==================
### Bug Fixes
* Fix loop iteration leak, by [sebmck](https://github.com/sebmck) ([#12](https://github.com/BinaryMuse/toml-node/pull/12))
### Development
* Tests now run JSHint on `lib/compiler.js`
2.0.4 - Mar 9 2014
==================
### Bug Fixes
* Fix failure on duplicate table name inside table array ([#11](https://github.com/BinaryMuse/toml-node/issues/11))
2.0.2 - Feb 23 2014
===================
### Bug Fixes
* Fix absence of errors when table path starts or ends with period
2.0.1 - Feb 23 2014
===================
### Bug Fixes
* Fix incorrect messaging in array type errors
* Fix missing error when overwriting key with table array
2.0.0 - Feb 23 2014
===================
### Features
* Add support for [version 0.2 of the TOML spec](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) ([#9](https://github.com/BinaryMuse/toml-node/issues/9))
### Internals
* Upgrade to PEG.js v0.8 and rewrite compiler; parser is now considerably faster (from ~7000ms to ~1000ms to parse `example.toml` 1000 times on Node.js v0.10)
1.0.4 - Aug 17 2013
===================
### Bug Fixes
* Fix support for empty arrays
1.0.3 - Aug 17 2013
===================
### Bug Fixes
* Fix typo in array type error message
* Fix single-element arrays with no trailing commas
1.0.2 - Aug 17 2013
===================
### Bug Fixes
* Fix errors on lines that contain only whitespace ([#7](https://github.com/BinaryMuse/toml-node/issues/7))
1.0.1 - Aug 17 2013
===================
### Internals
* Remove old code remaining from the remove streaming API
1.0.0 - Aug 17 2013
===================
Initial stable release

View File

@ -1,22 +0,0 @@
Copyright (c) 2012 Michelle Tilley
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,93 +0,0 @@
TOML Parser for Node.js
=======================
[![Build Status](https://travis-ci.org/BinaryMuse/toml-node.png?branch=master)](https://travis-ci.org/BinaryMuse/toml-node)
[![NPM](https://nodei.co/npm/toml.png?downloads=true)](https://nodei.co/npm/toml/)
If you haven't heard of TOML, well you're just missing out. [Go check it out now.](https://github.com/mojombo/toml) Back? Good.
TOML Spec Support
-----------------
toml-node supports version 0.4.0 the TOML spec as specified by [mojombo/toml@v0.4.0](https://github.com/mojombo/toml/blob/master/versions/en/toml-v0.4.0.md)
Installation
------------
toml-node is available via npm.
npm install toml
toml-node also works with browser module bundlers like Browserify and webpack.
Usage
-----
### Standalone
Say you have some awesome TOML in a variable called `someTomlString`. Maybe it came from the web; maybe it came from a file; wherever it came from, it came asynchronously! Let's turn that sucker into a JavaScript object.
```javascript
var toml = require('toml');
var data = toml.parse(someTomlString);
console.dir(data);
```
`toml.parse` throws an exception in the case of a parsing error; such exceptions have a `line` and `column` property on them to help identify the offending text.
```javascript
try {
toml.parse(someCrazyKnuckleHeadedTrblToml);
} catch (e) {
console.error("Parsing error on line " + e.line + ", column " + e.column +
": " + e.message);
}
```
### Streaming
As of toml-node version 1.0, the streaming interface has been removed. Instead, use a module like [concat-stream](https://npmjs.org/package/concat-stream):
```javascript
var toml = require('toml');
var concat = require('concat-stream');
var fs = require('fs');
fs.createReadStream('tomlFile.toml', 'utf8').pipe(concat(function(data) {
var parsed = toml.parse(data);
}));
```
Thanks [@ForbesLindesay](https://github.com/ForbesLindesay) for the suggestion.
### Requiring with Node.js
You can use the [toml-require package](https://github.com/BinaryMuse/toml-require) to `require()` your `.toml` files with Node.js
Live Demo
---------
You can experiment with TOML online at http://binarymuse.github.io/toml-node/, which uses the latest version of this library.
Building & Testing
------------------
toml-node uses [the PEG.js parser generator](http://pegjs.majda.cz/).
npm install
npm run build
npm test
Any changes to `src/toml.peg` requires a regeneration of the parser with `npm run build`.
toml-node is tested on Travis CI and is tested against:
* Node 0.10
* Node 0.12
* Latest stable io.js
License
-------
toml-node is licensed under the MIT license agreement. See the LICENSE file for more information.

View File

@ -1,12 +0,0 @@
var toml = require('./index');
var fs = require('fs');
var data = fs.readFileSync('./test/example.toml', 'utf8');
var iterations = 1000;
var start = new Date();
for(var i = 0; i < iterations; i++) {
toml.parse(data);
}
var end = new Date();
console.log("%s iterations in %sms", iterations, end - start);

View File

@ -1,3 +0,0 @@
declare module 'toml' {
export function parse(input: string): any;
}

View File

@ -1,9 +0,0 @@
var parser = require('./lib/parser');
var compiler = require('./lib/compiler');
module.exports = {
parse: function(input) {
var nodes = parser.parse(input.toString());
return compiler.compile(nodes);
}
};

View File

@ -1,195 +0,0 @@
"use strict";
function compile(nodes) {
var assignedPaths = [];
var valueAssignments = [];
var currentPath = "";
var data = {};
var context = data;
var arrayMode = false;
return reduce(nodes);
function reduce(nodes) {
var node;
for (var i = 0; i < nodes.length; i++) {
node = nodes[i];
switch (node.type) {
case "Assign":
assign(node);
break;
case "ObjectPath":
setPath(node);
break;
case "ArrayPath":
addTableArray(node);
break;
}
}
return data;
}
function genError(err, line, col) {
var ex = new Error(err);
ex.line = line;
ex.column = col;
throw ex;
}
function assign(node) {
var key = node.key;
var value = node.value;
var line = node.line;
var column = node.column;
var fullPath;
if (currentPath) {
fullPath = currentPath + "." + key;
} else {
fullPath = key;
}
if (typeof context[key] !== "undefined") {
genError("Cannot redefine existing key '" + fullPath + "'.", line, column);
}
context[key] = reduceValueNode(value);
if (!pathAssigned(fullPath)) {
assignedPaths.push(fullPath);
valueAssignments.push(fullPath);
}
}
function pathAssigned(path) {
return assignedPaths.indexOf(path) !== -1;
}
function reduceValueNode(node) {
if (node.type === "Array") {
return reduceArrayWithTypeChecking(node.value);
} else if (node.type === "InlineTable") {
return reduceInlineTableNode(node.value);
} else {
return node.value;
}
}
function reduceInlineTableNode(values) {
var obj = {};
for (var i = 0; i < values.length; i++) {
var val = values[i];
if (val.value.type === "InlineTable") {
obj[val.key] = reduceInlineTableNode(val.value.value);
} else if (val.type === "InlineTableValue") {
obj[val.key] = reduceValueNode(val.value);
}
}
return obj;
}
function setPath(node) {
var path = node.value;
var quotedPath = path.map(quoteDottedString).join(".");
var line = node.line;
var column = node.column;
if (pathAssigned(quotedPath)) {
genError("Cannot redefine existing key '" + path + "'.", line, column);
}
assignedPaths.push(quotedPath);
context = deepRef(data, path, {}, line, column);
currentPath = path;
}
function addTableArray(node) {
var path = node.value;
var quotedPath = path.map(quoteDottedString).join(".");
var line = node.line;
var column = node.column;
if (!pathAssigned(quotedPath)) {
assignedPaths.push(quotedPath);
}
assignedPaths = assignedPaths.filter(function(p) {
return p.indexOf(quotedPath) !== 0;
});
assignedPaths.push(quotedPath);
context = deepRef(data, path, [], line, column);
currentPath = quotedPath;
if (context instanceof Array) {
var newObj = {};
context.push(newObj);
context = newObj;
} else {
genError("Cannot redefine existing key '" + path + "'.", line, column);
}
}
// Given a path 'a.b.c', create (as necessary) `start.a`,
// `start.a.b`, and `start.a.b.c`, assigning `value` to `start.a.b.c`.
// If `a` or `b` are arrays and have items in them, the last item in the
// array is used as the context for the next sub-path.
function deepRef(start, keys, value, line, column) {
var traversed = [];
var traversedPath = "";
var path = keys.join(".");
var ctx = start;
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
traversed.push(key);
traversedPath = traversed.join(".");
if (typeof ctx[key] === "undefined") {
if (i === keys.length - 1) {
ctx[key] = value;
} else {
ctx[key] = {};
}
} else if (i !== keys.length - 1 && valueAssignments.indexOf(traversedPath) > -1) {
// already a non-object value at key, can't be used as part of a new path
genError("Cannot redefine existing key '" + traversedPath + "'.", line, column);
}
ctx = ctx[key];
if (ctx instanceof Array && ctx.length && i < keys.length - 1) {
ctx = ctx[ctx.length - 1];
}
}
return ctx;
}
function reduceArrayWithTypeChecking(array) {
// Ensure that all items in the array are of the same type
var firstType = null;
for (var i = 0; i < array.length; i++) {
var node = array[i];
if (firstType === null) {
firstType = node.type;
} else {
if (node.type !== firstType) {
genError("Cannot add value of type " + node.type + " to array of type " +
firstType + ".", node.line, node.column);
}
}
}
// Recursively reduce array of nodes into array of the nodes' values
return array.map(reduceValueNode);
}
function quoteDottedString(str) {
if (str.indexOf(".") > -1) {
return "\"" + str + "\"";
} else {
return str;
}
}
}
module.exports = {
compile: compile
};

File diff suppressed because it is too large Load Diff

View File

@ -1,62 +0,0 @@
{
"_args": [
[
"toml@2.3.3",
"D:\\repo\\better-toml"
]
],
"_from": "toml@2.3.3",
"_id": "toml@2.3.3",
"_inBundle": false,
"_integrity": "sha512-O7L5hhSQHxuufWUdcTRPfuTh3phKfAZ/dqfxZFoxPCj2RYmpaSGLEIs016FCXItQwNr08yefUB5TSjzRYnajTA==",
"_location": "/toml",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "toml@2.3.3",
"name": "toml",
"escapedName": "toml",
"rawSpec": "2.3.3",
"saveSpec": null,
"fetchSpec": "2.3.3"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/toml/-/toml-2.3.3.tgz",
"_spec": "2.3.3",
"_where": "D:\\repo\\better-toml",
"author": {
"name": "Michelle Tilley",
"email": "michelle@michelletilley.net"
},
"bugs": {
"url": "https://github.com/BinaryMuse/toml-node/issues"
},
"description": "TOML parser for Node.js (parses TOML spec v0.4.0)",
"devDependencies": {
"jshint": "*",
"nodeunit": "~0.9.0",
"pegjs": "~0.8.0"
},
"homepage": "https://github.com/BinaryMuse/toml-node#readme",
"keywords": [
"toml",
"parser"
],
"license": "MIT",
"main": "index.js",
"name": "toml",
"repository": {
"type": "git",
"url": "git://github.com/BinaryMuse/toml-node.git"
},
"scripts": {
"build": "pegjs --cache src/toml.pegjs lib/parser.js",
"prepublish": "npm run build",
"test": "jshint lib/compiler.js && nodeunit test/test_*.js"
},
"types": "index.d.ts",
"version": "2.3.3"
}

View File

@ -1,231 +0,0 @@
{
var nodes = [];
function genError(err, line, col) {
var ex = new Error(err);
ex.line = line;
ex.column = col;
throw ex;
}
function addNode(node) {
nodes.push(node);
}
function node(type, value, line, column, key) {
var obj = { type: type, value: value, line: line(), column: column() };
if (key) obj.key = key;
return obj;
}
function convertCodePoint(str, line, col) {
var num = parseInt("0x" + str);
if (
!isFinite(num) ||
Math.floor(num) != num ||
num < 0 ||
num > 0x10FFFF ||
(num > 0xD7FF && num < 0xE000)
) {
genError("Invalid Unicode escape code: " + str, line, col);
} else {
return fromCodePoint(num);
}
}
function fromCodePoint() {
var MAX_SIZE = 0x4000;
var codeUnits = [];
var highSurrogate;
var lowSurrogate;
var index = -1;
var length = arguments.length;
if (!length) {
return '';
}
var result = '';
while (++index < length) {
var codePoint = Number(arguments[index]);
if (codePoint <= 0xFFFF) { // BMP code point
codeUnits.push(codePoint);
} else { // Astral code point; split in surrogate halves
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
codePoint -= 0x10000;
highSurrogate = (codePoint >> 10) + 0xD800;
lowSurrogate = (codePoint % 0x400) + 0xDC00;
codeUnits.push(highSurrogate, lowSurrogate);
}
if (index + 1 == length || codeUnits.length > MAX_SIZE) {
result += String.fromCharCode.apply(null, codeUnits);
codeUnits.length = 0;
}
}
return result;
}
}
start
= line* { return nodes }
line
= S* expr:expression S* comment* (NL+ / EOF)
/ S+ (NL+ / EOF)
/ NL
expression
= comment / path / tablearray / assignment
comment
= '#' (!(NL / EOF) .)*
path
= '[' S* name:table_key S* ']' { addNode(node('ObjectPath', name, line, column)) }
tablearray
= '[' '[' S* name:table_key S* ']' ']' { addNode(node('ArrayPath', name, line, column)) }
table_key
= parts:dot_ended_table_key_part+ name:table_key_part { return parts.concat(name) }
/ name:table_key_part { return [name] }
table_key_part
= S* name:key S* { return name }
/ S* name:quoted_key S* { return name }
dot_ended_table_key_part
= S* name:key S* '.' S* { return name }
/ S* name:quoted_key S* '.' S* { return name }
assignment
= key:key S* '=' S* value:value { addNode(node('Assign', value, line, column, key)) }
/ key:quoted_key S* '=' S* value:value { addNode(node('Assign', value, line, column, key)) }
key
= chars:ASCII_BASIC+ { return chars.join('') }
quoted_key
= node:double_quoted_single_line_string { return node.value }
/ node:single_quoted_single_line_string { return node.value }
value
= string / datetime / float / integer / boolean / array / inline_table
string
= double_quoted_multiline_string
/ double_quoted_single_line_string
/ single_quoted_multiline_string
/ single_quoted_single_line_string
double_quoted_multiline_string
= '"""' NL? chars:multiline_string_char* '"""' { return node('String', chars.join(''), line, column) }
double_quoted_single_line_string
= '"' chars:string_char* '"' { return node('String', chars.join(''), line, column) }
single_quoted_multiline_string
= "'''" NL? chars:multiline_literal_char* "'''" { return node('String', chars.join(''), line, column) }
single_quoted_single_line_string
= "'" chars:literal_char* "'" { return node('String', chars.join(''), line, column) }
string_char
= ESCAPED / (!'"' char:. { return char })
literal_char
= (!"'" char:. { return char })
multiline_string_char
= ESCAPED / multiline_string_delim / (!'"""' char:. { return char})
multiline_string_delim
= '\\' NL NLS* { return '' }
multiline_literal_char
= (!"'''" char:. { return char })
float
= left:(float_text / integer_text) ('e' / 'E') right:integer_text { return node('Float', parseFloat(left + 'e' + right), line, column) }
/ text:float_text { return node('Float', parseFloat(text), line, column) }
float_text
= '+'? digits:(DIGITS '.' DIGITS) { return digits.join('') }
/ '-' digits:(DIGITS '.' DIGITS) { return '-' + digits.join('') }
integer
= text:integer_text { return node('Integer', parseInt(text, 10), line, column) }
integer_text
= '+'? digits:DIGIT+ !'.' { return digits.join('') }
/ '-' digits:DIGIT+ !'.' { return '-' + digits.join('') }
boolean
= 'true' { return node('Boolean', true, line, column) }
/ 'false' { return node('Boolean', false, line, column) }
array
= '[' array_sep* ']' { return node('Array', [], line, column) }
/ '[' value:array_value? ']' { return node('Array', value ? [value] : [], line, column) }
/ '[' values:array_value_list+ ']' { return node('Array', values, line, column) }
/ '[' values:array_value_list+ value:array_value ']' { return node('Array', values.concat(value), line, column) }
array_value
= array_sep* value:value array_sep* { return value }
array_value_list
= array_sep* value:value array_sep* ',' array_sep* { return value }
array_sep
= S / NL / comment
inline_table
= '{' S* values:inline_table_assignment* S* '}' { return node('InlineTable', values, line, column) }
inline_table_assignment
= S* key:key S* '=' S* value:value S* ',' S* { return node('InlineTableValue', value, line, column, key) }
/ S* key:key S* '=' S* value:value { return node('InlineTableValue', value, line, column, key) }
secfragment
= '.' digits:DIGITS { return "." + digits }
date
= date:(
DIGIT DIGIT DIGIT DIGIT
'-'
DIGIT DIGIT
'-'
DIGIT DIGIT
) { return date.join('') }
time
= time:(DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT secfragment?) { return time.join('') }
time_with_offset
= time:(
DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT secfragment?
('-' / '+')
DIGIT DIGIT ':' DIGIT DIGIT
) { return time.join('') }
datetime
= date:date 'T' time:time 'Z' { return node('Date', new Date(date + "T" + time + "Z"), line, column) }
/ date:date 'T' time:time_with_offset { return node('Date', new Date(date + "T" + time), line, column) }
S = [ \t]
NL = "\n" / "\r" "\n"
NLS = NL / S
EOF = !.
HEX = [0-9a-f]i
DIGIT = DIGIT_OR_UNDER
DIGIT_OR_UNDER = [0-9]
/ '_' { return "" }
ASCII_BASIC = [A-Za-z0-9_\-]
DIGITS = d:DIGIT_OR_UNDER+ { return d.join('') }
ESCAPED = '\\"' { return '"' }
/ '\\\\' { return '\\' }
/ '\\b' { return '\b' }
/ '\\t' { return '\t' }
/ '\\n' { return '\n' }
/ '\\f' { return '\f' }
/ '\\r' { return '\r' }
/ ESCAPED_UNICODE
ESCAPED_UNICODE = "\\U" digits:(HEX HEX HEX HEX HEX HEX HEX HEX) { return convertCodePoint(digits.join('')) }
/ "\\u" digits:(HEX HEX HEX HEX) { return convertCodePoint(digits.join('')) }

View File

@ -1,5 +0,0 @@
[something]
awesome = "this is"
[something.awesome]
this = "isn't"

View File

@ -1,32 +0,0 @@
# This is a TOML document. Boom.
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
organization = "GitHub"
bio = "GitHub Cofounder & CEO\n\tLikes \"tater tots\" and beer and backslashes: \\"
dob = 1979-05-27T07:32:00Z # First class dates? Why not?
[database]
server = "192.168.1.1"
ports = [ 8001, 8001, 8003 ]
connection_max = 5000
connection_min = -2 # Don't ask me how
max_temp = 87.1 # It's a float
min_temp = -17.76
enabled = true
[servers]
# You can indent as you please. Tabs or spaces. TOML don't care.
[servers.alpha]
ip = "10.0.0.1"
dc = "eqdc10"
[servers.beta]
ip = "10.0.0.2"
dc = "eqdc10"
[clients]
data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it

View File

@ -1,33 +0,0 @@
# Test file for TOML
# Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate
# This part you'll really hate
[the]
test_string = "You'll hate me after this - #" # " Annoying, isn't it?
[the.hard]
test_array = [ "] ", " # "] # ] There you go, parse this!
test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ]
# You didn't think it'd as easy as chucking out the last #, did you?
another_test_string = " Same thing, but with a string #"
harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too"
# Things will get harder
[the.hard."bit#"]
"what?" = "You don't think some user won't do that?"
multi_line_array = [
"]",
# ] Oh yes I did
]
# Each of the following keygroups/key value pairs should produce an error. Uncomment to them to test
#[error] if you didn't catch this, your parser is broken
#string = "Anything other than tabs, spaces and newline after a keygroup or key value pair has ended should produce an error unless it is a comment" like this
#array = [
# "This might most likely happen in multiline arrays",
# Like here,
# "or here,
# and here"
# ] End of array comment, forgot the #
#number = 3.14 pi <--again forgot the #

View File

@ -1,10 +0,0 @@
name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }
nested = { x = { a = { b = 3 } } }
points = [ { x = 1, y = 2, z = 3 },
{ x = 7, y = 8, z = 9 },
{ x = 2, y = 4, z = 8 } ]
arrays = [ { x = [1, 2, 3], y = [4, 5, 6] },
{ x = [7, 8, 9], y = [0, 1, 2] } ]

View File

@ -1,5 +0,0 @@
# What you see is what you get.
winpath = 'C:\Users\nodejs\templates'
winpath2 = '\\ServerX\admin$\system32\'
quoted = 'Tom "Dubs" Preston-Werner'
regex = '<\i\c*\s*>'

View File

@ -1,15 +0,0 @@
# The following strings are byte-for-byte equivalent:
key1 = "The quick brown fox jumps over the lazy dog."
key2 = """
The quick brown \
fox jumps over \
the lazy dog."""
key3 = """\
The quick brown \
fox jumps over \
the lazy dog.\
"""

View File

@ -1,7 +0,0 @@
regex2 = '''I [dw]on't need \d{2} apples'''
lines = '''
The first newline is
trimmed in raw strings.
All other whitespace
is preserved.
'''

View File

@ -1,6 +0,0 @@
# The following strings are byte-for-byte equivalent:
key1 = "One\nTwo"
key2 = """One\nTwo"""
key3 = """
One
Two"""

View File

@ -1,22 +0,0 @@
var fs = require('fs');
var parser = require('../index');
var codes = [
"# test\n my.key=\"value\"\nother = 101\nthird = -37",
"first = 1.2\nsecond = -56.02\nth = true\nfth = false",
"time = 1979-05-27T07:32:00Z",
"test = [\"one\", ]",
"test = [[1, 2,], [true, false,],]",
"[my.sub.path]\nkey = true\nother = -15.3\n[my.sub]\nkey=false",
"arry = [\"one\", \"two\",\"thr\nee\", \"\\u03EA\"]",
fs.readFileSync(__dirname + '/example.toml', 'utf8'),
fs.readFileSync(__dirname + '/hard_example.toml', 'utf8')
]
console.log("=============================================");
for(i in codes) {
var code = codes[i];
console.log(code + "\n");
console.log(JSON.stringify(parser.parse(code)));
console.log("=============================================");
}

View File

@ -1,10 +0,0 @@
[[products]]
name = "Hammer"
sku = 738594937
[[products]]
[[products]]
name = "Nail"
sku = 284758393
color = "gray"

View File

@ -1,31 +0,0 @@
[[fruit]]
name = "durian"
variety = []
[[fruit]]
name = "apple"
[fruit.physical]
color = "red"
shape = "round"
[[fruit.variety]]
name = "red delicious"
[[fruit.variety]]
name = "granny smith"
[[fruit]]
[[fruit]]
name = "banana"
[[fruit.variety]]
name = "plantain"
[[fruit]]
name = "orange"
[fruit.physical]
color = "orange"
shape = "round"

View File

@ -1,586 +0,0 @@
var toml = require('../');
var fs = require('fs');
var assert = require("nodeunit").assert;
assert.parsesToml = function(tomlStr, expected) {
try {
var actual = toml.parse(tomlStr);
} catch (e) {
var errInfo = "line: " + e.line + ", column: " + e.column;
return assert.fail("TOML parse error: " + e.message, errInfo, null, "at", assert.parsesToml);
}
return assert.deepEqual(actual, expected);
};
var exampleExpected = {
title: "TOML Example",
owner: {
name: "Tom Preston-Werner",
organization: "GitHub",
bio: "GitHub Cofounder & CEO\n\tLikes \"tater tots\" and beer and backslashes: \\",
dob: new Date("1979-05-27T07:32:00Z")
},
database: {
server: "192.168.1.1",
ports: [8001, 8001, 8003],
connection_max: 5000,
connection_min: -2,
max_temp: 87.1,
min_temp: -17.76,
enabled: true
},
servers: {
alpha: {
ip: "10.0.0.1",
dc: "eqdc10"
},
beta: {
ip: "10.0.0.2",
dc: "eqdc10"
}
},
clients: {
data: [ ["gamma", "delta"], [1, 2] ]
}
};
var hardExampleExpected = {
the: {
hard: {
another_test_string: ' Same thing, but with a string #',
'bit#': {
multi_line_array: [']'],
'what?': "You don't think some user won't do that?"
},
harder_test_string: " And when \"'s are in the string, along with # \"",
test_array: ['] ', ' # '],
test_array2: ['Test #11 ]proved that', 'Experiment #9 was a success']
},
test_string: "You'll hate me after this - #"
}
};
var easyTableArrayExpected = {
"products": [
{ "name": "Hammer", "sku": 738594937 },
{ },
{ "name": "Nail", "sku": 284758393, "color": "gray" }
]
};
var hardTableArrayExpected = {
"fruit": [
{
"name": "durian",
"variety": []
},
{
"name": "apple",
"physical": {
"color": "red",
"shape": "round"
},
"variety": [
{ "name": "red delicious" },
{ "name": "granny smith" }
]
},
{},
{
"name": "banana",
"variety": [
{ "name": "plantain" }
]
},
{
"name": "orange",
"physical": {
"color": "orange",
"shape": "round"
}
}
]
}
var badInputs = [
'[error] if you didn\'t catch this, your parser is broken',
'string = "Anything other than tabs, spaces and newline after a table or key value pair has ended should produce an error unless it is a comment" like this',
'array = [\n \"This might most likely happen in multiline arrays\",\n Like here,\n \"or here,\n and here\"\n ] End of array comment, forgot the #',
'number = 3.14 pi <--again forgot the #'
];
exports.testParsesExample = function(test) {
var str = fs.readFileSync(__dirname + "/example.toml", 'utf-8')
test.parsesToml(str, exampleExpected);
test.done();
};
exports.testParsesHardExample = function(test) {
var str = fs.readFileSync(__dirname + "/hard_example.toml", 'utf-8')
test.parsesToml(str, hardExampleExpected);
test.done();
};
exports.testEasyTableArrays = function(test) {
var str = fs.readFileSync(__dirname + "/table_arrays_easy.toml", 'utf8')
test.parsesToml(str, easyTableArrayExpected);
test.done();
};
exports.testHarderTableArrays = function(test) {
var str = fs.readFileSync(__dirname + "/table_arrays_hard.toml", 'utf8')
test.parsesToml(str, hardTableArrayExpected);
test.done();
};
exports.testSupportsTrailingCommasInArrays = function(test) {
var str = 'arr = [1, 2, 3,]';
var expected = { arr: [1, 2, 3] };
test.parsesToml(str, expected);
test.done();
};
exports.testSingleElementArrayWithNoTrailingComma = function(test) {
var str = "a = [1]";
test.parsesToml(str, {
a: [1]
});
test.done();
};
exports.testEmptyArray = function(test) {
var str = "a = []";
test.parsesToml(str, {
a: []
});
test.done();
};
exports.testArrayWithWhitespace = function(test) {
var str = "[versions]\nfiles = [\n 3, \n 5 \n\n ]";
test.parsesToml(str, {
versions: {
files: [3, 5]
}
});
test.done();
};
exports.testEmptyArrayWithWhitespace = function(test) {
var str = "[versions]\nfiles = [\n \n ]";
test.parsesToml(str, {
versions: {
files: []
}
});
test.done();
};
exports.testDefineOnSuperkey = function(test) {
var str = "[a.b]\nc = 1\n\n[a]\nd = 2";
var expected = {
a: {
b: {
c: 1
},
d: 2
}
};
test.parsesToml(str, expected);
test.done();
};
exports.testWhitespace = function(test) {
var str = "a = 1\n \n b = 2 ";
test.parsesToml(str, {
a: 1, b: 2
});
test.done();
};
exports.testUnicode = function(test) {
var str = "str = \"My name is Jos\\u00E9\"";
test.parsesToml(str, {
str: "My name is Jos\u00E9"
});
var str = "str = \"My name is Jos\\U000000E9\"";
test.parsesToml(str, {
str: "My name is Jos\u00E9"
});
test.done();
};
exports.testMultilineStrings = function(test) {
var str = fs.readFileSync(__dirname + "/multiline_strings.toml", 'utf8');
test.parsesToml(str, {
key1: "One\nTwo",
key2: "One\nTwo",
key3: "One\nTwo"
});
test.done();
};
exports.testMultilineEatWhitespace = function(test) {
var str = fs.readFileSync(__dirname + "/multiline_eat_whitespace.toml", 'utf8');
test.parsesToml(str, {
key1: "The quick brown fox jumps over the lazy dog.",
key2: "The quick brown fox jumps over the lazy dog.",
key3: "The quick brown fox jumps over the lazy dog."
});
test.done();
};
exports.testLiteralStrings = function(test) {
var str = fs.readFileSync(__dirname + "/literal_strings.toml", 'utf8');
test.parsesToml(str, {
winpath: "C:\\Users\\nodejs\\templates",
winpath2: "\\\\ServerX\\admin$\\system32\\",
quoted: "Tom \"Dubs\" Preston-Werner",
regex: "<\\i\\c*\\s*>"
});
test.done();
};
exports.testMultilineLiteralStrings = function(test) {
var str = fs.readFileSync(__dirname + "/multiline_literal_strings.toml", 'utf8');
test.parsesToml(str, {
regex2: "I [dw]on't need \\d{2} apples",
lines: "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n"
});
test.done();
};
exports.testIntegerFormats = function(test) {
var str = "a = +99\nb = 42\nc = 0\nd = -17\ne = 1_000_001\nf = 1_2_3_4_5 # why u do dis";
test.parsesToml(str, {
a: 99,
b: 42,
c: 0,
d: -17,
e: 1000001,
f: 12345
});
test.done();
};
exports.testFloatFormats = function(test) {
var str = "a = +1.0\nb = 3.1415\nc = -0.01\n" +
"d = 5e+22\ne = 1e6\nf = -2E-2\n" +
"g = 6.626e-34\n" +
"h = 9_224_617.445_991_228_313\n" +
"i = 1e1_000";
test.parsesToml(str, {
a: 1.0,
b: 3.1415,
c: -0.01,
d: 5e22,
e: 1e6,
f: -2e-2,
g: 6.626e-34,
h: 9224617.445991228313,
i: 1e1000
});
test.done();
};
exports.testDate = function(test) {
var date = new Date("1979-05-27T07:32:00Z");
test.parsesToml("a = 1979-05-27T07:32:00Z", {
a: date
});
test.done();
};
exports.testDateWithOffset = function(test) {
var date1 = new Date("1979-05-27T07:32:00-07:00"),
date2 = new Date("1979-05-27T07:32:00+02:00");
test.parsesToml("a = 1979-05-27T07:32:00-07:00\nb = 1979-05-27T07:32:00+02:00", {
a: date1,
b: date2
});
test.done();
};
exports.testDateWithSecondFraction = function(test) {
var date = new Date("1979-05-27T00:32:00.999999-07:00");
test.parsesToml("a = 1979-05-27T00:32:00.999999-07:00", {
a: date
});
test.done();
};
exports.testDateFromIsoString = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/20
var date = new Date(),
dateStr = date.toISOString(),
tomlStr = "a = " + dateStr;
test.parsesToml(tomlStr, {
a: date
});
test.done();
};
exports.testLeadingNewlines = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/22
var str = "\ntest = \"ing\"";
test.parsesToml(str, {
test: "ing"
});
test.done();
};
exports.testInlineTables = function(test) {
var str = fs.readFileSync(__dirname + "/inline_tables.toml", 'utf8');
test.parsesToml(str, {
name: {
first: "Tom",
last: "Preston-Werner"
},
point: {
x: 1,
y: 2
},
nested: {
x: {
a: {
b: 3
}
}
},
points: [
{ x: 1, y: 2, z: 3 },
{ x: 7, y: 8, z: 9 },
{ x: 2, y: 4, z: 8 }
],
arrays: [
{ x: [1, 2, 3], y: [4, 5, 6] },
{ x: [7, 8, 9], y: [0, 1, 2] }
]
});
test.done();
};
exports.testEmptyInlineTables = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/24
var str = "a = { }";
test.parsesToml(str, {
a: {}
});
test.done();
};
exports.testKeyNamesWithWhitespaceAroundStartAndFinish = function(test) {
var str = "[ a ]\nb = 1";
test.parsesToml(str, {
a: {
b: 1
}
});
test.done();
};
exports.testKeyNamesWithWhitespaceAroundDots = function(test) {
var str = "[ a . b . c]\nd = 1";
test.parsesToml(str, {
a: {
b: {
c: {
d: 1
}
}
}
});
test.done();
};
exports.testSimpleQuotedKeyNames = function(test) {
var str = "[\"ʞ\"]\na = 1";
test.parsesToml(str, {
"ʞ": {
a: 1
}
});
test.done();
};
exports.testComplexQuotedKeyNames = function(test) {
var str = "[ a . \"ʞ\" . c ]\nd = 1";
test.parsesToml(str, {
a: {
"ʞ": {
c: {
d: 1
}
}
}
});
test.done();
};
exports.testEscapedQuotesInQuotedKeyNames = function(test) {
test.parsesToml("[\"the \\\"thing\\\"\"]\na = true", {
'the "thing"': {
a: true
}
});
test.done();
};
exports.testMoreComplexQuotedKeyNames = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/21
test.parsesToml('["the\\ key"]\n\none = "one"\ntwo = 2\nthree = false', {
"the\\ key": {
one: "one",
two: 2,
three: false
}
});
test.parsesToml('[a."the\\ key"]\n\none = "one"\ntwo = 2\nthree = false', {
a: {
"the\\ key": {
one: "one",
two: 2,
three: false
}
}
});
test.parsesToml('[a."the-key"]\n\none = "one"\ntwo = 2\nthree = false', {
a: {
"the-key": {
one: "one",
two: 2,
three: false
}
}
});
test.parsesToml('[a."the.key"]\n\none = "one"\ntwo = 2\nthree = false', {
a: {
"the.key": {
one: "one",
two: 2,
three: false
}
}
});
// https://github.com/BinaryMuse/toml-node/issues/34
test.parsesToml('[table]\n\'a "quoted value"\' = "value"', {
table: {
'a "quoted value"': "value"
}
});
// https://github.com/BinaryMuse/toml-node/issues/33
test.parsesToml('[module]\n"foo=bar" = "zzz"', {
module: {
"foo=bar": "zzz"
}
});
test.done();
};
exports.testErrorOnBadUnicode = function(test) {
var str = "str = \"My name is Jos\\uD800\"";
test.throws(function() {
toml.parse(str);
});
test.done();
};
exports.testErrorOnDotAtStartOfKey = function(test) {
test.throws(function() {
var str = "[.a]\nb = 1";
toml.parse(str);
});
test.done()
};
exports.testErrorOnDotAtEndOfKey = function(test) {
test.throws(function() {
var str = "[.a]\nb = 1";
toml.parse(str);
});
test.done()
};
exports.testErrorOnTableOverride = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\n\n[a]\nc = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnKeyOverride = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\n[a.b]\nc = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnKeyOverrideWithNested = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/23
test.throws(function() {
var str = "[a]\nb = \"a\"\n[a.b.c]";
toml.parse(str);
}, "existing key 'a.b'");
test.done();
};
exports.testErrorOnKeyOverrideWithArrayTable = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\n[[a]]\nc = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnKeyReplace = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\nb = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnInlineTableReplace = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/25
test.throws(function() {
var str = "a = { b = 1 }\n[a]\nc = 2";
toml.parse(str);
}, "existing key 'a'");
test.done();
};
exports.testErrorOnArrayMismatch = function(test) {
test.throws(function() {
var str = 'data = [1, 2, "test"]'
toml.parse(str);
});
test.done();
};
exports.testErrorOnBadInputs = function(test) {
var count = 0;
for (i in badInputs) {
(function(num) {
test.throws(function() {
toml.parse(badInputs[num]);
});
})(i);
}
test.done();
};
exports.testErrorsHaveCorrectLineAndColumn = function(test) {
var str = "[a]\nb = 1\n [a.b]\nc = 2";
try { toml.parse(str); }
catch (e) {
test.equal(e.line, 3);
test.equal(e.column, 2);
test.done();
}
};

View File

@ -1,9 +0,0 @@
.vscode/
lib/test/
lib/*.map
src/
test/
.eslintrc
.gitignore
gulpfile.js
tsd.json

View File

@ -1,11 +0,0 @@
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,46 +0,0 @@
# VSCode JSON RPC
[![NPM Version](https://img.shields.io/npm/v/vscode-jsonrpc.svg)](https://npmjs.org/package/vscode-jsonrpc)
[![NPM Downloads](https://img.shields.io/npm/dm/vscode-jsonrpc.svg)](https://npmjs.org/package/vscode-jsonrpc)
[![Build Status](https://travis-ci.org/Microsoft/vscode-languageserver-node.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-languageserver-node)
This npm module implements the base messaging protocol spoken between a VSCode language server and a VSCode language client.
The npm module can also be used standalone to establish a [JSON-RPC](http://www.jsonrpc.org/) channel between
a client and a server. Below an example how to setup a JSON-RPC connection. First the client side.
```ts
import * as cp from 'child_process';
import * as rpc from 'vscode-jsonrpc';
let childProcess = cp.spawn(...);
// Use stdin and stdout for communication:
let connection = rpc.createClientMessageConnection(
new rpc.StreamMessageReader(childProcess.stdout),
new rpc.StreamMessageWriter(childProcess.stdin));
let notification: rpc.NotificationType<string> = { method: 'testNotification' };
connection.listen();
connection.sendNotification(notification, 'Hello World');
```
The server side looks very symmetrical:
```ts
import * as rpc from 'vscode-jsonrpc';
let connection = rpc.createClientMessageConnection(
new rpc.StreamMessageReader(process.stdin),
new rpc.StreamMessageWriter(process.stdout));
let notification: rpc.NotificationType<string> = { method: 'testNotification' };
connection.onNotification(notification, (param: string) => {
console.log(param); // This prints Hello World
});
connection.listen();
```

View File

@ -1,21 +0,0 @@
import { Event } from './events';
export interface CancellationToken {
/**
* Is `true` when the token has been cancelled, `false` otherwise.
*/
isCancellationRequested: boolean;
/**
* An [event](#Event) which fires upon cancellation.
*/
onCancellationRequested: Event<any>;
}
export declare namespace CancellationToken {
const None: CancellationToken;
const Cancelled: CancellationToken;
}
export declare class CancellationTokenSource {
private _token;
token: CancellationToken;
cancel(): void;
dispose(): void;
}

View File

@ -1,89 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
var events_1 = require('./events');
var CancellationToken;
(function (CancellationToken) {
CancellationToken.None = Object.freeze({
isCancellationRequested: false,
onCancellationRequested: events_1.Event.None
});
CancellationToken.Cancelled = Object.freeze({
isCancellationRequested: true,
onCancellationRequested: events_1.Event.None
});
})(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
var shortcutEvent = Object.freeze(function (callback, context) {
var handle = setTimeout(callback.bind(context), 0);
return { dispose: function () { clearTimeout(handle); } };
});
var MutableToken = (function () {
function MutableToken() {
this._isCancelled = false;
}
MutableToken.prototype.cancel = function () {
if (!this._isCancelled) {
this._isCancelled = true;
if (this._emitter) {
this._emitter.fire(undefined);
this._emitter = undefined;
}
}
};
Object.defineProperty(MutableToken.prototype, "isCancellationRequested", {
get: function () {
return this._isCancelled;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MutableToken.prototype, "onCancellationRequested", {
get: function () {
if (this._isCancelled) {
return shortcutEvent;
}
if (!this._emitter) {
this._emitter = new events_1.Emitter();
}
return this._emitter.event;
},
enumerable: true,
configurable: true
});
return MutableToken;
}());
var CancellationTokenSource = (function () {
function CancellationTokenSource() {
}
Object.defineProperty(CancellationTokenSource.prototype, "token", {
get: function () {
if (!this._token) {
// be lazy and create the token only when
// actually needed
this._token = new MutableToken();
}
return this._token;
},
enumerable: true,
configurable: true
});
CancellationTokenSource.prototype.cancel = function () {
if (!this._token) {
// save an object by returning the default
// cancelled token when cancellation happens
// before someone asks for the token
this._token = CancellationToken.Cancelled;
}
else {
this._token.cancel();
}
};
CancellationTokenSource.prototype.dispose = function () {
this.cancel();
};
return CancellationTokenSource;
}());
exports.CancellationTokenSource = CancellationTokenSource;
//# sourceMappingURL=cancellation.js.map

View File

@ -1,44 +0,0 @@
export interface Disposable {
/**
* Dispose this object.
*/
dispose(): any;
}
/**
* Represents a typed event.
*/
export interface Event<T> {
/**
*
* @param listener The listener function will be call when the event happens.
* @param thisArgs The 'this' which will be used when calling the event listener.
* @param disposables An array to which a {{IDisposable}} will be added. The
* @return
*/
(listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]): Disposable;
}
export declare namespace Event {
const None: Event<any>;
}
export interface EmitterOptions {
onFirstListenerAdd?: Function;
onLastListenerRemove?: Function;
}
export declare class Emitter<T> {
private _options;
private static _noop;
private _event;
private _callbacks;
constructor(_options?: EmitterOptions);
/**
* For the public to allow to subscribe
* to events from this Emitter
*/
event: Event<T>;
/**
* To be kept private to fire an event to
* subscribers
*/
fire(event: T): any;
dispose(): void;
}

View File

@ -1,180 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var Event;
(function (Event) {
var _disposable = { dispose: function () { } };
Event.None = function () { return _disposable; };
})(Event = exports.Event || (exports.Event = {}));
/**
* Represents a type which can release resources, such
* as event listening or a timer.
*/
var DisposableImpl = (function () {
function DisposableImpl(callOnDispose) {
this._callOnDispose = callOnDispose;
}
/**
* Combine many disposable-likes into one. Use this method
* when having objects with a dispose function which are not
* instances of Disposable.
*
* @return Returns a new disposable which, upon dispose, will
* dispose all provides disposable-likes.
*/
DisposableImpl.from = function () {
var disposables = [];
for (var _i = 0; _i < arguments.length; _i++) {
disposables[_i - 0] = arguments[_i];
}
return new DisposableImpl(function () {
if (disposables) {
for (var _i = 0, disposables_1 = disposables; _i < disposables_1.length; _i++) {
var disposable = disposables_1[_i];
disposable.dispose();
}
disposables = undefined;
}
});
};
/**
* Dispose this object.
*/
DisposableImpl.prototype.dispose = function () {
if (typeof this._callOnDispose === 'function') {
this._callOnDispose();
this._callOnDispose = undefined;
}
};
return DisposableImpl;
}());
var CallbackList = (function () {
function CallbackList() {
}
CallbackList.prototype.add = function (callback, context, bucket) {
var _this = this;
if (context === void 0) { context = null; }
if (!this._callbacks) {
this._callbacks = [];
this._contexts = [];
}
this._callbacks.push(callback);
this._contexts.push(context);
if (Array.isArray(bucket)) {
bucket.push({ dispose: function () { return _this.remove(callback, context); } });
}
};
CallbackList.prototype.remove = function (callback, context) {
if (context === void 0) { context = null; }
if (!this._callbacks) {
return;
}
var foundCallbackWithDifferentContext = false;
for (var i = 0, len = this._callbacks.length; i < len; i++) {
if (this._callbacks[i] === callback) {
if (this._contexts[i] === context) {
// callback & context match => remove it
this._callbacks.splice(i, 1);
this._contexts.splice(i, 1);
return;
}
else {
foundCallbackWithDifferentContext = true;
}
}
}
if (foundCallbackWithDifferentContext) {
throw new Error('When adding a listener with a context, you should remove it with the same context');
}
};
CallbackList.prototype.invoke = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
if (!this._callbacks) {
return;
}
var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
for (var i = 0, len = callbacks.length; i < len; i++) {
try {
ret.push(callbacks[i].apply(contexts[i], args));
}
catch (e) {
console.error(e);
}
}
return ret;
};
CallbackList.prototype.isEmpty = function () {
return !this._callbacks || this._callbacks.length === 0;
};
CallbackList.prototype.dispose = function () {
this._callbacks = undefined;
this._contexts = undefined;
};
return CallbackList;
}());
var Emitter = (function () {
function Emitter(_options) {
this._options = _options;
}
Object.defineProperty(Emitter.prototype, "event", {
/**
* For the public to allow to subscribe
* to events from this Emitter
*/
get: function () {
var _this = this;
if (!this._event) {
this._event = function (listener, thisArgs, disposables) {
if (!_this._callbacks) {
_this._callbacks = new CallbackList();
}
if (_this._options && _this._options.onFirstListenerAdd && _this._callbacks.isEmpty()) {
_this._options.onFirstListenerAdd(_this);
}
_this._callbacks.add(listener, thisArgs);
var result;
result = {
dispose: function () {
_this._callbacks.remove(listener, thisArgs);
result.dispose = Emitter._noop;
if (_this._options && _this._options.onLastListenerRemove && _this._callbacks.isEmpty()) {
_this._options.onLastListenerRemove(_this);
}
}
};
if (Array.isArray(disposables)) {
disposables.push(result);
}
return result;
};
}
return this._event;
},
enumerable: true,
configurable: true
});
/**
* To be kept private to fire an event to
* subscribers
*/
Emitter.prototype.fire = function (event) {
if (this._callbacks) {
this._callbacks.invoke.call(this._callbacks, event);
}
};
Emitter.prototype.dispose = function () {
if (this._callbacks) {
this._callbacks.dispose();
this._callbacks = undefined;
}
};
Emitter._noop = function () { };
return Emitter;
}());
exports.Emitter = Emitter;
//# sourceMappingURL=events.js.map

View File

@ -1,10 +0,0 @@
export declare function defined(value: any): boolean;
export declare function undefined(value: any): boolean;
export declare function nil(value: any): boolean;
export declare function boolean(value: any): value is boolean;
export declare function string(value: any): value is string;
export declare function number(value: any): value is number;
export declare function error(value: any): value is Error;
export declare function func(value: any): value is Function;
export declare function array<T>(value: any): value is T[];
export declare function stringArray(value: any): value is string[];

View File

@ -1,47 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var toString = Object.prototype.toString;
function defined(value) {
return typeof value !== 'undefined';
}
exports.defined = defined;
function undefined(value) {
return typeof value === 'undefined';
}
exports.undefined = undefined;
function nil(value) {
return value === null;
}
exports.nil = nil;
function boolean(value) {
return value === true || value === false;
}
exports.boolean = boolean;
function string(value) {
return toString.call(value) === '[object String]';
}
exports.string = string;
function number(value) {
return toString.call(value) === '[object Number]';
}
exports.number = number;
function error(value) {
return toString.call(value) === '[object Error]';
}
exports.error = error;
function func(value) {
return toString.call(value) === '[object Function]';
}
exports.func = func;
function array(value) {
return Array.isArray(value);
}
exports.array = array;
function stringArray(value) {
return array(value) && value.every(function (elem) { return string(elem); });
}
exports.stringArray = stringArray;
//# sourceMappingURL=is.js.map

View File

@ -1,65 +0,0 @@
import { Message, RequestMessage, RequestType, ResponseError, ErrorCodes, NotificationMessage, NotificationType } from './messages';
import { MessageReader, DataCallback, StreamMessageReader, IPCMessageReader } from './messageReader';
import { MessageWriter, StreamMessageWriter, IPCMessageWriter } from './messageWriter';
import { Disposable, Event, Emitter } from './events';
import { CancellationTokenSource, CancellationToken } from './cancellation';
export { Message, ErrorCodes, ResponseError, RequestMessage, RequestType, NotificationMessage, NotificationType, MessageReader, DataCallback, StreamMessageReader, IPCMessageReader, MessageWriter, StreamMessageWriter, IPCMessageWriter, CancellationTokenSource, CancellationToken, Disposable, Event, Emitter };
export interface RequestHandler<P, R, E> {
(params: P, token: CancellationToken): R | ResponseError<E> | Thenable<R | ResponseError<E>>;
}
export interface NotificationHandler<P> {
(params: P): void;
}
export interface Logger {
error(message: string): void;
warn(message: string): void;
info(message: string): void;
log(message: string): void;
}
export declare enum Trace {
Off = 0,
Messages = 1,
Verbose = 2,
}
export declare type TraceValues = 'off' | 'messages' | 'verbose';
export declare namespace Trace {
function fromString(value: string): Trace;
function toString(value: Trace): TraceValues;
}
export interface SetTraceParams {
value: TraceValues;
}
export declare namespace SetTraceNotification {
const type: NotificationType<SetTraceParams>;
}
export interface LogTraceParams {
message: string;
verbose?: string;
}
export declare namespace LogTraceNotification {
const type: NotificationType<LogTraceParams>;
}
export interface Tracer {
log(message: string, data?: string): void;
}
export interface MessageConnection {
sendRequest<P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken): Thenable<R>;
onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): void;
sendNotification<P>(type: NotificationType<P>, params?: P): void;
onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): void;
trace(value: Trace, tracer: Tracer, sendNotification?: boolean): void;
onError: Event<[Error, Message, number]>;
onClose: Event<void>;
onUnhandledNotification: Event<NotificationMessage>;
listen(): any;
onDispose: Event<void>;
dispose(): void;
}
export interface ServerMessageConnection extends MessageConnection {
}
export interface ClientMessageConnection extends MessageConnection {
}
export declare function createServerMessageConnection(reader: MessageReader, writer: MessageWriter, logger: Logger): ServerMessageConnection;
export declare function createServerMessageConnection(inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, logger: Logger): ServerMessageConnection;
export declare function createClientMessageConnection(reader: MessageReader, writer: MessageWriter, logger: Logger): ClientMessageConnection;
export declare function createClientMessageConnection(inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, logger: Logger): ClientMessageConnection;

View File

@ -1,499 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var is = require('./is');
var messages_1 = require('./messages');
exports.ResponseError = messages_1.ResponseError;
exports.ErrorCodes = messages_1.ErrorCodes;
var messageReader_1 = require('./messageReader');
exports.StreamMessageReader = messageReader_1.StreamMessageReader;
exports.IPCMessageReader = messageReader_1.IPCMessageReader;
var messageWriter_1 = require('./messageWriter');
exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;
exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;
var events_1 = require('./events');
exports.Event = events_1.Event;
exports.Emitter = events_1.Emitter;
var cancellation_1 = require('./cancellation');
exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;
exports.CancellationToken = cancellation_1.CancellationToken;
var CancelNotification;
(function (CancelNotification) {
CancelNotification.type = { get method() { return '$/cancelRequest'; } };
})(CancelNotification || (CancelNotification = {}));
(function (Trace) {
Trace[Trace["Off"] = 0] = "Off";
Trace[Trace["Messages"] = 1] = "Messages";
Trace[Trace["Verbose"] = 2] = "Verbose";
})(exports.Trace || (exports.Trace = {}));
var Trace = exports.Trace;
var Trace;
(function (Trace) {
function fromString(value) {
value = value.toLowerCase();
switch (value) {
case 'off':
return Trace.Off;
case 'messages':
return Trace.Messages;
case 'verbose':
return Trace.Verbose;
default:
return Trace.Off;
}
}
Trace.fromString = fromString;
function toString(value) {
switch (value) {
case Trace.Off:
return 'off';
case Trace.Messages:
return 'messages';
case Trace.Verbose:
return 'verbose';
default:
return 'off';
}
}
Trace.toString = toString;
})(Trace = exports.Trace || (exports.Trace = {}));
var SetTraceNotification;
(function (SetTraceNotification) {
SetTraceNotification.type = { get method() { return '$/setTraceNotification'; } };
})(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
var LogTraceNotification;
(function (LogTraceNotification) {
LogTraceNotification.type = { get method() { return '$/logTraceNotification'; } };
})(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
var ConnectionState;
(function (ConnectionState) {
ConnectionState[ConnectionState["New"] = 1] = "New";
ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
})(ConnectionState || (ConnectionState = {}));
function createMessageConnection(messageReader, messageWriter, logger, client) {
if (client === void 0) { client = false; }
var sequenceNumber = 0;
var version = '2.0';
var requestHandlers = Object.create(null);
var eventHandlers = Object.create(null);
var responsePromises = Object.create(null);
var requestTokens = Object.create(null);
var trace = Trace.Off;
var tracer;
var state = ConnectionState.New;
var errorEmitter = new events_1.Emitter();
var closeEmitter = new events_1.Emitter();
var unhandledNotificationEmitter = new events_1.Emitter();
var disposeEmitter = new events_1.Emitter();
function isListening() {
return state === ConnectionState.Listening;
}
function isClosed() {
return state === ConnectionState.Closed;
}
function isDisposed() {
return state === ConnectionState.Disposed;
}
function closeHandler() {
if (state === ConnectionState.New || state === ConnectionState.Listening) {
state = ConnectionState.Closed;
closeEmitter.fire(undefined);
}
// If the connection is disposed don't sent close events.
}
;
function readErrorHandler(error) {
errorEmitter.fire([error, undefined, undefined]);
}
function writeErrorHandler(data) {
errorEmitter.fire(data);
}
messageReader.onClose(closeHandler);
messageReader.onError(readErrorHandler);
messageWriter.onClose(closeHandler);
messageWriter.onError(writeErrorHandler);
function handleRequest(requestMessage) {
if (isDisposed()) {
// we return here silently since we fired an event when the
// connection got disposed.
return;
}
function reply(resultOrError) {
var message = {
jsonrpc: version,
id: requestMessage.id
};
if (resultOrError instanceof messages_1.ResponseError) {
message.error = resultOrError.toJson();
}
else {
message.result = is.undefined(resultOrError) ? null : resultOrError;
}
messageWriter.write(message);
}
function replyError(error) {
var message = {
jsonrpc: version,
id: requestMessage.id,
error: error.toJson()
};
messageWriter.write(message);
}
function replySuccess(result) {
// The JSON RPC defines that a response must either have a result or an error
// So we can't treat undefined as a valid response result.
if (is.undefined(result)) {
result = null;
}
var message = {
jsonrpc: version,
id: requestMessage.id,
result: result
};
messageWriter.write(message);
}
var requestHandler = requestHandlers[requestMessage.method];
if (requestHandler) {
var cancellationSource = new cancellation_1.CancellationTokenSource();
var tokenKey_1 = String(requestMessage.id);
requestTokens[tokenKey_1] = cancellationSource;
try {
var handlerResult = requestHandler(requestMessage.params, cancellationSource.token);
var promise = handlerResult;
if (!handlerResult) {
delete requestTokens[tokenKey_1];
replySuccess(handlerResult);
}
else if (promise.then) {
promise.then(function (resultOrError) {
delete requestTokens[tokenKey_1];
reply(resultOrError);
}, function (error) {
delete requestTokens[tokenKey_1];
if (error instanceof messages_1.ResponseError) {
replyError(error);
}
else if (error && is.string(error.message)) {
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, "Request " + requestMessage.method + " failed with message: " + error.message));
}
else {
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, "Request " + requestMessage.method + " failed unexpectedly without providing any details."));
}
});
}
else {
delete requestTokens[tokenKey_1];
reply(handlerResult);
}
}
catch (error) {
delete requestTokens[tokenKey_1];
if (error instanceof messages_1.ResponseError) {
reply(error);
}
else if (error && is.string(error.message)) {
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, "Request " + requestMessage.method + " failed with message: " + error.message));
}
else {
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, "Request " + requestMessage.method + " failed unexpectedly without providing any details."));
}
}
}
else {
replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, "Unhandled method " + requestMessage.method));
}
}
function handleResponse(responseMessage) {
if (isDisposed()) {
// See handle request.
return;
}
var key = String(responseMessage.id);
var responsePromise = responsePromises[key];
if (trace != Trace.Off && tracer) {
traceResponse(responseMessage, responsePromise);
}
if (responsePromise) {
delete responsePromises[key];
try {
if (is.defined(responseMessage.error)) {
var error = responseMessage.error;
responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
}
else if (is.defined(responseMessage.result)) {
responsePromise.resolve(responseMessage.result);
}
else {
throw new Error('Should never happen.');
}
}
catch (error) {
if (error.message) {
logger.error("Response handler '" + responsePromise.method + "' failed with message: " + error.message);
}
else {
logger.error("Response handler '" + responsePromise.method + "' failed unexpectedly.");
}
}
}
}
function handleNotification(message) {
if (isDisposed()) {
// See handle request.
return;
}
var eventHandler;
if (message.method === CancelNotification.type.method) {
eventHandler = function (params) {
var id = params.id;
var source = requestTokens[String(id)];
if (source) {
source.cancel();
}
};
}
else {
eventHandler = eventHandlers[message.method];
}
if (eventHandler) {
try {
if (trace != Trace.Off && tracer) {
traceReceivedNotification(message);
}
eventHandler(message.params);
}
catch (error) {
if (error.message) {
logger.error("Notification handler '" + message.method + "' failed with message: " + error.message);
}
else {
logger.error("Notification handler '" + message.method + "' failed unexpectedly.");
}
}
}
else {
unhandledNotificationEmitter.fire(message);
}
}
function handleInvalidMessage(message) {
if (!message) {
logger.error('Received empty message.');
return;
}
logger.error("Received message which is neither a response nor a notification message:\n" + JSON.stringify(message, null, 4));
// Test whether we find an id to reject the promise
var responseMessage = message;
if (is.string(responseMessage.id) || is.number(responseMessage.id)) {
var key = String(responseMessage.id);
var responseHandler = responsePromises[key];
if (responseHandler) {
responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
}
}
}
function traceRequest(message) {
var data = undefined;
if (trace === Trace.Verbose && message.params) {
data = "Params: " + JSON.stringify(message.params, null, 4) + "\n\n";
}
tracer.log("Sending request '" + message.method + " - (" + message.id + ")'.", data);
}
function traceSendNotification(message) {
var data = undefined;
if (trace === Trace.Verbose) {
if (message.params) {
data = "Params: " + JSON.stringify(message.params, null, 4) + "\n\n";
}
else {
data = 'No parameters provided.\n\n';
}
}
tracer.log("Sending notification '" + message.method + "'.", data);
}
function traceReceivedNotification(message) {
if (message.method === LogTraceNotification.type.method) {
return;
}
var data = undefined;
if (trace === Trace.Verbose) {
if (message.params) {
data = "Params: " + JSON.stringify(message.params, null, 4) + "\n\n";
}
else {
data = 'No parameters provided.\n\n';
}
}
tracer.log("Received notification '" + message.method + "'.", data);
}
function traceResponse(message, responsePromise) {
var data = undefined;
if (trace === Trace.Verbose) {
if (message.error && message.error.data) {
data = "Error data: " + JSON.stringify(message.error.data, null, 4) + "\n\n";
}
else {
if (message.result) {
data = "Result: " + JSON.stringify(message.result, null, 4) + "\n\n";
}
else if (is.undefined(message.error)) {
data = 'No result returned.\n\n';
}
}
}
if (responsePromise) {
var error = message.error ? " Request failed: " + message.error.message + " (" + message.error.code + ")." : '';
tracer.log("Received response '" + responsePromise.method + " - (" + message.id + ")' in " + (Date.now() - responsePromise.timerStart) + "ms." + error, data);
}
else {
tracer.log("Received response " + message.id + " without active response promise.", data);
}
}
var callback = function (message) {
if (messages_1.isRequestMessage(message)) {
handleRequest(message);
}
else if (messages_1.isReponseMessage(message)) {
handleResponse(message);
}
else if (messages_1.isNotificationMessage(message)) {
handleNotification(message);
}
else {
handleInvalidMessage(message);
}
};
function throwIfClosedOrDisposed() {
if (isClosed()) {
throw new Error('Connection is closed.');
}
if (isDisposed()) {
throw new Error('Connection is disposed.');
}
}
function throwIfListening() {
if (isListening()) {
throw new Error('Connection is already listening');
}
}
var connection = {
sendNotification: function (type, params) {
throwIfClosedOrDisposed();
var notificatioMessage = {
jsonrpc: version,
method: type.method,
params: params
};
if (trace != Trace.Off && tracer) {
traceSendNotification(notificatioMessage);
}
messageWriter.write(notificatioMessage);
},
onNotification: function (type, handler) {
throwIfClosedOrDisposed();
eventHandlers[type.method] = handler;
},
sendRequest: function (type, params, token) {
throwIfClosedOrDisposed();
var id = sequenceNumber++;
var result = new Promise(function (resolve, reject) {
var requestMessage = {
jsonrpc: version,
id: id,
method: type.method,
params: params
};
var responsePromise = { method: type.method, timerStart: Date.now(), resolve: resolve, reject: reject };
if (trace != Trace.Off && tracer) {
traceRequest(requestMessage);
}
try {
messageWriter.write(requestMessage);
}
catch (e) {
// Writing the message failed. So we need to reject the promise.
responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
responsePromise = null;
}
if (responsePromise) {
responsePromises[String(id)] = responsePromise;
}
});
if (token) {
token.onCancellationRequested(function (event) {
connection.sendNotification(CancelNotification.type, { id: id });
});
}
return result;
},
onRequest: function (type, handler) {
throwIfClosedOrDisposed();
requestHandlers[type.method] = handler;
},
trace: function (_value, _tracer, sendNotification) {
if (sendNotification === void 0) { sendNotification = false; }
trace = _value;
if (trace === Trace.Off) {
tracer = null;
}
else {
tracer = _tracer;
}
if (sendNotification && !isClosed() && !isDisposed()) {
connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
}
},
onError: errorEmitter.event,
onClose: closeEmitter.event,
onUnhandledNotification: unhandledNotificationEmitter.event,
onDispose: disposeEmitter.event,
dispose: function () {
if (isDisposed()) {
return;
}
state = ConnectionState.Disposed;
disposeEmitter.fire(undefined);
var error = new Error('Connection got disposed.');
Object.keys(responsePromises).forEach(function (key) {
responsePromises[key].reject(error);
});
responsePromises = Object.create(null);
requestTokens = Object.create(null);
},
listen: function () {
throwIfClosedOrDisposed();
throwIfListening();
state = ConnectionState.Listening;
messageReader.listen(callback);
}
};
connection.onNotification(LogTraceNotification.type, function (params) {
if (trace === Trace.Off) {
return;
}
tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
});
return connection;
}
function isMessageReader(value) {
return is.defined(value.listen) && is.undefined(value.read);
}
function isMessageWriter(value) {
return is.defined(value.write) && is.undefined(value.end);
}
function createServerMessageConnection(input, output, logger) {
var reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
var writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
return createMessageConnection(reader, writer, logger);
}
exports.createServerMessageConnection = createServerMessageConnection;
function createClientMessageConnection(input, output, logger) {
var reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
var writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
return createMessageConnection(reader, writer, logger, true);
}
exports.createClientMessageConnection = createClientMessageConnection;
//# sourceMappingURL=main.js.map

View File

@ -1,49 +0,0 @@
import { ChildProcess } from 'child_process';
import { Message } from './messages';
import { Event } from './events';
export interface DataCallback {
(data: Message): void;
}
export interface PartialMessageInfo {
messageToken: number;
waitingTime: number;
}
export interface MessageReader {
onError: Event<Error>;
onClose: Event<void>;
onPartialMessage: Event<PartialMessageInfo>;
listen(callback: DataCallback): void;
}
export declare abstract class AbstractMessageReader {
private errorEmitter;
private closeEmitter;
private partialMessageEmitter;
constructor();
onError: Event<Error>;
protected fireError(error: any): void;
onClose: Event<void>;
protected fireClose(): void;
onPartialMessage: Event<PartialMessageInfo>;
protected firePartialMessage(info: PartialMessageInfo): void;
private asError(error);
}
export declare class StreamMessageReader extends AbstractMessageReader implements MessageReader {
private readable;
private callback;
private buffer;
private nextMessageLength;
private messageToken;
private partialMessageTimer;
private _partialMessageTimeout;
constructor(readable: NodeJS.ReadableStream, encoding?: string);
partialMessageTimeout: number;
listen(callback: DataCallback): void;
private onData(data);
private clearPartialMessageTimer();
private setPartialMessageTimer();
}
export declare class IPCMessageReader extends AbstractMessageReader implements MessageReader {
private process;
constructor(process: NodeJS.Process | ChildProcess);
listen(callback: DataCallback): void;
}

View File

@ -1,238 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var events_1 = require('./events');
var is = require('./is');
var DefaultSize = 8192;
var CR = new Buffer('\r', 'ascii')[0];
var LF = new Buffer('\n', 'ascii')[0];
var CRLF = '\r\n';
var MessageBuffer = (function () {
function MessageBuffer(encoding) {
if (encoding === void 0) { encoding = 'utf-8'; }
this.encoding = encoding;
this.index = 0;
this.buffer = new Buffer(DefaultSize);
}
MessageBuffer.prototype.append = function (chunk) {
var toAppend = chunk;
if (typeof (chunk) == 'string') {
var str = chunk;
toAppend = new Buffer(str.length);
toAppend.write(str, 0, str.length, this.encoding);
}
if (this.buffer.length - this.index >= toAppend.length) {
toAppend.copy(this.buffer, this.index, 0, toAppend.length);
}
else {
var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
if (this.index === 0) {
this.buffer = new Buffer(newSize);
toAppend.copy(this.buffer, 0, 0, toAppend.length);
}
else {
this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
}
}
this.index += toAppend.length;
};
MessageBuffer.prototype.tryReadHeaders = function () {
var result = undefined;
var current = 0;
while (current + 3 < this.index && (this.buffer[current] !== CR || this.buffer[current + 1] !== LF || this.buffer[current + 2] !== CR || this.buffer[current + 3] !== LF)) {
current++;
}
// No header / body separator found (e.g CRLFCRLF)
if (current + 3 >= this.index) {
return result;
}
result = Object.create(null);
var headers = this.buffer.toString('ascii', 0, current).split(CRLF);
headers.forEach(function (header) {
var index = header.indexOf(':');
if (index === -1) {
throw new Error('Message header must separate key and value using :');
}
var key = header.substr(0, index);
var value = header.substr(index + 1).trim();
result[key] = value;
});
var nextStart = current + 4;
this.buffer = this.buffer.slice(nextStart);
this.index = this.index - nextStart;
return result;
};
MessageBuffer.prototype.tryReadContent = function (length) {
if (this.index < length) {
return null;
}
var result = this.buffer.toString(this.encoding, 0, length);
var nextStart = length;
this.buffer.copy(this.buffer, 0, nextStart);
this.index = this.index - nextStart;
return result;
};
Object.defineProperty(MessageBuffer.prototype, "numberOfBytes", {
get: function () {
return this.index;
},
enumerable: true,
configurable: true
});
return MessageBuffer;
}());
var AbstractMessageReader = (function () {
function AbstractMessageReader() {
this.errorEmitter = new events_1.Emitter();
this.closeEmitter = new events_1.Emitter();
this.partialMessageEmitter = new events_1.Emitter();
}
Object.defineProperty(AbstractMessageReader.prototype, "onError", {
get: function () {
return this.errorEmitter.event;
},
enumerable: true,
configurable: true
});
AbstractMessageReader.prototype.fireError = function (error) {
this.errorEmitter.fire(this.asError(error));
};
Object.defineProperty(AbstractMessageReader.prototype, "onClose", {
get: function () {
return this.closeEmitter.event;
},
enumerable: true,
configurable: true
});
AbstractMessageReader.prototype.fireClose = function () {
this.closeEmitter.fire(undefined);
};
Object.defineProperty(AbstractMessageReader.prototype, "onPartialMessage", {
get: function () {
return this.partialMessageEmitter.event;
},
enumerable: true,
configurable: true
});
AbstractMessageReader.prototype.firePartialMessage = function (info) {
this.partialMessageEmitter.fire(info);
};
AbstractMessageReader.prototype.asError = function (error) {
if (error instanceof Error) {
return error;
}
else {
return new Error("Reader recevied error. Reason: " + (is.string(error.message) ? error.message : 'unknown'));
}
};
return AbstractMessageReader;
}());
exports.AbstractMessageReader = AbstractMessageReader;
var StreamMessageReader = (function (_super) {
__extends(StreamMessageReader, _super);
function StreamMessageReader(readable, encoding) {
if (encoding === void 0) { encoding = 'utf-8'; }
_super.call(this);
this.readable = readable;
this.buffer = new MessageBuffer(encoding);
this._partialMessageTimeout = 10000;
}
Object.defineProperty(StreamMessageReader.prototype, "partialMessageTimeout", {
get: function () {
return this._partialMessageTimeout;
},
set: function (timeout) {
this._partialMessageTimeout = timeout;
},
enumerable: true,
configurable: true
});
StreamMessageReader.prototype.listen = function (callback) {
var _this = this;
this.nextMessageLength = -1;
this.messageToken = 0;
this.partialMessageTimer = undefined;
this.callback = callback;
this.readable.on('data', function (data) {
_this.onData(data);
});
this.readable.on('error', function (error) { return _this.fireError(error); });
this.readable.on('close', function () { return _this.fireClose(); });
};
StreamMessageReader.prototype.onData = function (data) {
this.buffer.append(data);
while (true) {
if (this.nextMessageLength === -1) {
var headers = this.buffer.tryReadHeaders();
if (!headers) {
return;
}
var contentLength = headers['Content-Length'];
if (!contentLength) {
throw new Error('Header must provide a Content-Length property.');
}
var length_1 = parseInt(contentLength);
if (isNaN(length_1)) {
throw new Error('Content-Length value must be a number.');
}
this.nextMessageLength = length_1;
}
var msg = this.buffer.tryReadContent(this.nextMessageLength);
if (msg === null) {
/** We haven't recevied the full message yet. */
this.setPartialMessageTimer();
return;
}
this.clearPartialMessageTimer();
this.nextMessageLength = -1;
this.messageToken++;
var json = JSON.parse(msg);
this.callback(json);
}
};
StreamMessageReader.prototype.clearPartialMessageTimer = function () {
if (this.partialMessageTimer) {
clearTimeout(this.partialMessageTimer);
this.partialMessageTimer = undefined;
}
};
StreamMessageReader.prototype.setPartialMessageTimer = function () {
var _this = this;
this.clearPartialMessageTimer();
if (this._partialMessageTimeout <= 0) {
return;
}
this.partialMessageTimer = setTimeout(function (token, timeout) {
_this.partialMessageTimer = undefined;
if (token === _this.messageToken) {
_this.firePartialMessage({ messageToken: token, waitingTime: timeout });
_this.setPartialMessageTimer();
}
}, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
};
return StreamMessageReader;
}(AbstractMessageReader));
exports.StreamMessageReader = StreamMessageReader;
var IPCMessageReader = (function (_super) {
__extends(IPCMessageReader, _super);
function IPCMessageReader(process) {
var _this = this;
_super.call(this);
this.process = process;
this.process.on('error', function (error) { return _this.fireError(error); });
this.process.on('close', function () { return _this.fireClose(); });
}
IPCMessageReader.prototype.listen = function (callback) {
this.process.on('message', callback);
};
return IPCMessageReader;
}(AbstractMessageReader));
exports.IPCMessageReader = IPCMessageReader;
//# sourceMappingURL=messageReader.js.map

View File

@ -1,31 +0,0 @@
import { ChildProcess } from 'child_process';
import { Message } from './messages';
import { Event } from './events';
export interface MessageWriter {
onError: Event<[Error, Message, number]>;
onClose: Event<void>;
write(msg: Message): void;
}
export declare abstract class AbstractMessageWriter {
private errorEmitter;
private closeEmitter;
constructor();
onError: Event<[Error, Message, number]>;
protected fireError(error: any, message?: Message, count?: number): void;
onClose: Event<void>;
protected fireClose(): void;
private asError(error);
}
export declare class StreamMessageWriter extends AbstractMessageWriter implements MessageWriter {
private writable;
private encoding;
private errorCount;
constructor(writable: NodeJS.WritableStream, encoding?: string);
write(msg: Message): void;
}
export declare class IPCMessageWriter extends AbstractMessageWriter implements MessageWriter {
private process;
private errorCount;
constructor(process: NodeJS.Process | ChildProcess);
write(msg: Message): void;
}

View File

@ -1,108 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var events_1 = require('./events');
var is = require('./is');
var ContentLength = 'Content-Length: ';
var CRLF = '\r\n';
var AbstractMessageWriter = (function () {
function AbstractMessageWriter() {
this.errorEmitter = new events_1.Emitter();
this.closeEmitter = new events_1.Emitter();
}
Object.defineProperty(AbstractMessageWriter.prototype, "onError", {
get: function () {
return this.errorEmitter.event;
},
enumerable: true,
configurable: true
});
AbstractMessageWriter.prototype.fireError = function (error, message, count) {
this.errorEmitter.fire([this.asError(error), message, count]);
};
Object.defineProperty(AbstractMessageWriter.prototype, "onClose", {
get: function () {
return this.closeEmitter.event;
},
enumerable: true,
configurable: true
});
AbstractMessageWriter.prototype.fireClose = function () {
this.closeEmitter.fire(undefined);
};
AbstractMessageWriter.prototype.asError = function (error) {
if (error instanceof Error) {
return error;
}
else {
return new Error("Writer recevied error. Reason: " + (is.string(error.message) ? error.message : 'unknown'));
}
};
return AbstractMessageWriter;
}());
exports.AbstractMessageWriter = AbstractMessageWriter;
var StreamMessageWriter = (function (_super) {
__extends(StreamMessageWriter, _super);
function StreamMessageWriter(writable, encoding) {
var _this = this;
if (encoding === void 0) { encoding = 'utf8'; }
_super.call(this);
this.writable = writable;
this.encoding = encoding;
this.errorCount = 0;
this.writable.on('error', function (error) { return _this.fireError(error); });
this.writable.on('close', function () { return _this.fireClose(); });
}
StreamMessageWriter.prototype.write = function (msg) {
var json = JSON.stringify(msg);
var contentLength = Buffer.byteLength(json, this.encoding);
var headers = [
ContentLength, contentLength.toString(), CRLF,
CRLF
];
try {
// Header must be written in ASCII encoding
this.writable.write(headers.join(''), 'ascii');
// Now write the content. This can be written in any encoding
this.writable.write(json, this.encoding);
this.errorCount = 0;
}
catch (error) {
this.errorCount++;
this.fireError(error, msg, this.errorCount);
}
};
return StreamMessageWriter;
}(AbstractMessageWriter));
exports.StreamMessageWriter = StreamMessageWriter;
var IPCMessageWriter = (function (_super) {
__extends(IPCMessageWriter, _super);
function IPCMessageWriter(process) {
var _this = this;
_super.call(this);
this.process = process;
this.errorCount = 0;
this.process.on('error', function (error) { return _this.fireError(error); });
this.process.on('close', function () { return _this.fireClose; });
}
IPCMessageWriter.prototype.write = function (msg) {
try {
this.process.send(msg);
this.errorCount = 0;
}
catch (error) {
this.errorCount++;
this.fireError(error, msg, this.errorCount);
}
};
return IPCMessageWriter;
}(AbstractMessageWriter));
exports.IPCMessageWriter = IPCMessageWriter;
//# sourceMappingURL=messageWriter.js.map

View File

@ -1,115 +0,0 @@
/**
* A language server message
*/
export interface Message {
jsonrpc: string;
}
/**
* Request message
*/
export interface RequestMessage extends Message {
/**
* The request id.
*/
id: number | string;
/**
* The method to be invoked.
*/
method: string;
/**
* The method's params.
*/
params?: any;
}
/**
* Predefined error codes.
*/
export declare namespace ErrorCodes {
const ParseError: number;
const InvalidRequest: number;
const MethodNotFound: number;
const InvalidParams: number;
const InternalError: number;
const serverErrorStart: number;
const serverErrorEnd: number;
const MessageWriteError: number;
const MessageReadError: number;
}
export interface ResponseErrorLiteral<D> {
/**
* A number indicating the error type that occured.
*/
code: number;
/**
* A string providing a short decription of the error.
*/
message: string;
/**
* A Primitive or Structured value that contains additional
* information about the error. Can be omitted.
*/
data?: D;
}
/**
* A error object return in a response in case a request
* has failed.
*/
export declare class ResponseError<D> extends Error {
code: number;
message: string;
data: D;
constructor(code: number, message: string, data?: D);
toJson(): ResponseErrorLiteral<D>;
}
/**
* A response message.
*/
export interface ResponseMessage extends Message {
/**
* The request id.
*/
id: number | string;
/**
* The result of a request. This can be omitted in
* the case of an error.
*/
result?: any;
/**
* The error object in case a request fails.
*/
error?: ResponseErrorLiteral<any>;
}
/**
* A interface to type the request parameter / response pair
*/
export interface RequestType<P, R, E> {
method: string;
}
/**
* Notification Message
*/
export interface NotificationMessage extends Message {
/**
* The method to be invoked.
*/
method: string;
/**
* The notification's params.
*/
params?: any;
}
export interface NotificationType<P> {
method: string;
}
/**
* Tests if the given message is a request message
*/
export declare function isRequestMessage(message: Message): message is RequestMessage;
/**
* Tests if the given message is a notification message
*/
export declare function isNotificationMessage(message: Message): message is NotificationMessage;
/**
* Tests if the given message is a response message
*/
export declare function isReponseMessage(message: Message): message is ResponseMessage;

View File

@ -1,81 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var is = require('./is');
/**
* Predefined error codes.
*/
var ErrorCodes;
(function (ErrorCodes) {
// Defined by JSON RPC
ErrorCodes.ParseError = -32700;
ErrorCodes.InvalidRequest = -32600;
ErrorCodes.MethodNotFound = -32601;
ErrorCodes.InvalidParams = -32602;
ErrorCodes.InternalError = -32603;
ErrorCodes.serverErrorStart = -32099;
ErrorCodes.serverErrorEnd = -32000;
// Defined by VSCode.
ErrorCodes.MessageWriteError = 1;
ErrorCodes.MessageReadError = 2;
})(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
/**
* A error object return in a response in case a request
* has failed.
*/
var ResponseError = (function (_super) {
__extends(ResponseError, _super);
function ResponseError(code, message, data) {
_super.call(this, message);
this.code = code;
this.message = message;
if (is.defined(data)) {
this.data = data;
}
}
ResponseError.prototype.toJson = function () {
var result = {
code: this.code,
message: this.message
};
if (is.defined(this.data)) {
result.data = this.data;
}
;
return result;
};
return ResponseError;
}(Error));
exports.ResponseError = ResponseError;
/**
* Tests if the given message is a request message
*/
function isRequestMessage(message) {
var candidate = message;
return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
}
exports.isRequestMessage = isRequestMessage;
/**
* Tests if the given message is a notification message
*/
function isNotificationMessage(message) {
var candidate = message;
return candidate && is.string(candidate.method) && is.undefined(message.id);
}
exports.isNotificationMessage = isNotificationMessage;
/**
* Tests if the given message is a response message
*/
function isReponseMessage(message) {
var candidate = message;
return candidate && (is.defined(candidate.result) || is.defined(candidate.error)) && (is.string(candidate.id) || is.number(candidate.id));
}
exports.isReponseMessage = isReponseMessage;
//# sourceMappingURL=messages.js.map

View File

@ -1,61 +0,0 @@
{
"_args": [
[
"vscode-jsonrpc@2.4.0",
"D:\\repo\\better-toml"
]
],
"_from": "vscode-jsonrpc@2.4.0",
"_id": "vscode-jsonrpc@2.4.0",
"_inBundle": false,
"_integrity": "sha1-UTlgMOExeVVck5t5HClZgFi4+7Q=",
"_location": "/vscode-jsonrpc",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "vscode-jsonrpc@2.4.0",
"name": "vscode-jsonrpc",
"escapedName": "vscode-jsonrpc",
"rawSpec": "2.4.0",
"saveSpec": null,
"fetchSpec": "2.4.0"
},
"_requiredBy": [
"/vscode-languageclient",
"/vscode-languageserver"
],
"_resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-2.4.0.tgz",
"_spec": "2.4.0",
"_where": "D:\\repo\\better-toml",
"author": {
"name": "Microsoft Corporation"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-languageserver-node/issues"
},
"description": "A json rpc implementation over streams",
"devDependencies": {
"mocha": "^3.0.2",
"typescript": "^1.8.10"
},
"engines": {
"node": ">=4.0.0 || >=6.0.0"
},
"homepage": "https://github.com/Microsoft/vscode-languageserver-node#readme",
"license": "MIT",
"main": "./lib/main.js",
"name": "vscode-jsonrpc",
"repository": {
"type": "git",
"url": "git+https://github.com/Microsoft/vscode-languageserver-node.git"
},
"scripts": {
"compile": "tsc -p ./src",
"prepublish": "tsc -p ./src",
"test": "mocha",
"watch": "tsc -w -p ./src"
},
"typings": "./lib/main",
"version": "2.4.0"
}

View File

@ -1,31 +0,0 @@
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
For Microsoft vscode-jsonrpc
This project incorporates material from the project(s) listed below (collectively, “Third Party Code”).
Microsoft is not the original author of the Third Party Code. The original copyright notice and license
under which Microsoft received such Third Party Code are set out below. This Third Party Code is licensed
to you under their original license terms set forth below. Microsoft reserves all other rights not expressly
granted, whether by implication, estoppel or otherwise.
1. DefinitelyTyped version 0.0.1 (https://github.com/borisyankov/DefinitelyTyped)
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,9 +0,0 @@
.vscode/
lib/test/
lib/*.map
src/
test/
.eslintrc
.gitignore
gulpfile.js
tsd.json

View File

@ -1,11 +0,0 @@
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,10 +0,0 @@
# VSCode Language Server - Client Module
[![NPM Version](https://img.shields.io/npm/v/vscode-languageclient.svg)](https://npmjs.org/package/vscode-languageclient)
[![NPM Downloads](https://img.shields.io/npm/dm/vscode-languageclient.svg)](https://npmjs.org/package/vscode-languageclient)
[![Build Status](https://travis-ci.org/Microsoft/vscode-languageserver-node.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-languageserver-node)
This npm module allows VSCode extensions to easily integrate langauge servers adhering to the [language server protocol](https://github.com/Microsoft/vscode-languageserver-protocol)
See [here](https://code.visualstudio.com/docs/extensions/example-language-server) for a detailed documentation on how to
implement language servers for [VSCode](https://code.visualstudio.com/).

View File

@ -1,59 +0,0 @@
import * as code from 'vscode';
import * as ls from 'vscode-languageserver-types';
import * as proto from './protocol';
export interface Converter {
asUri(uri: code.Uri): string;
asTextDocumentIdentifier(textDocument: code.TextDocument): ls.TextDocumentIdentifier;
asOpenTextDocumentParams(textDocument: code.TextDocument): proto.DidOpenTextDocumentParams;
asChangeTextDocumentParams(textDocument: code.TextDocument): proto.DidChangeTextDocumentParams;
asChangeTextDocumentParams(event: code.TextDocumentChangeEvent): proto.DidChangeTextDocumentParams;
asCloseTextDocumentParams(textDocument: code.TextDocument): proto.DidCloseTextDocumentParams;
asSaveTextDocumentParams(textDocument: code.TextDocument): proto.DidSaveTextDocumentParams;
asTextDocumentPositionParams(textDocument: code.TextDocument, position: code.Position): proto.TextDocumentPositionParams;
asWorkerPosition(position: code.Position): ls.Position;
asRange(value: code.Range): ls.Range;
asPosition(value: code.Position): ls.Position;
asDiagnosticSeverity(value: code.DiagnosticSeverity): ls.DiagnosticSeverity;
asDiagnostic(item: code.Diagnostic): ls.Diagnostic;
asDiagnostics(items: code.Diagnostic[]): ls.Diagnostic[];
asCompletionItem(item: code.CompletionItem): ls.CompletionItem;
asTextEdit(edit: code.TextEdit): ls.TextEdit;
asReferenceParams(textDocument: code.TextDocument, position: code.Position, options: {
includeDeclaration: boolean;
}): proto.ReferenceParams;
asCodeActionContext(context: code.CodeActionContext): ls.CodeActionContext;
asCommand(item: code.Command): ls.Command;
asCodeLens(item: code.CodeLens): ls.CodeLens;
asFormattingOptions(item: code.FormattingOptions): ls.FormattingOptions;
asDocumentSymbolParams(textDocument: code.TextDocument): proto.DocumentSymbolParams;
asCodeLensParams(textDocument: code.TextDocument): proto.CodeLensParams;
asDocumentLink(item: code.DocumentLink): ls.DocumentLink;
asDocumentLinkParams(textDocument: code.TextDocument): proto.DocumentLinkParams;
}
export interface URIConverter {
(value: code.Uri): string;
}
export declare function createConverter(uriConverter?: URIConverter): Converter;
export declare const asTextDocumentIdentifier: (textDocument: code.TextDocument) => ls.TextDocumentIdentifier;
export declare const asOpenTextDocumentParams: (textDocument: code.TextDocument) => proto.DidOpenTextDocumentParams;
export declare const asChangeTextDocumentParams: (arg: code.TextDocumentChangeEvent | code.TextDocument) => proto.DidChangeTextDocumentParams;
export declare const asCloseTextDocumentParams: (textDocument: code.TextDocument) => proto.DidCloseTextDocumentParams;
export declare const asSaveTextDocumentParams: (textDocument: code.TextDocument) => proto.DidSaveTextDocumentParams;
export declare const asTextDocumentPositionParams: (textDocument: code.TextDocument, position: code.Position) => proto.TextDocumentPositionParams;
export declare const asWorkerPosition: (position: code.Position) => ls.Position;
export declare const asRange: (value: code.Range) => ls.Range;
export declare const asPosition: (value: code.Position) => ls.Position;
export declare const asDiagnosticSeverity: (value: code.DiagnosticSeverity) => ls.DiagnosticSeverity;
export declare const asDiagnostic: (item: code.Diagnostic) => ls.Diagnostic;
export declare const asDiagnostics: (items: code.Diagnostic[]) => ls.Diagnostic[];
export declare const asCompletionItem: (item: code.CompletionItem) => ls.CompletionItem;
export declare const asTextEdit: (edit: code.TextEdit) => ls.TextEdit;
export declare const asReferenceParams: (textDocument: code.TextDocument, position: code.Position, options: {
includeDeclaration: boolean;
}) => proto.ReferenceParams;
export declare const asCodeActionContext: (context: code.CodeActionContext) => ls.CodeActionContext;
export declare const asCommand: (item: code.Command) => ls.Command;
export declare const asCodeLens: (item: code.CodeLens) => ls.CodeLens;
export declare const asFormattingOptions: (item: code.FormattingOptions) => ls.FormattingOptions;
export declare const asDocumentSymbolParams: (textDocument: code.TextDocument) => proto.DocumentSymbolParams;
export declare const asCodeLensParams: (textDocument: code.TextDocument) => proto.CodeLensParams;

View File

@ -1,272 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var code = require('vscode');
var ls = require('vscode-languageserver-types');
var is = require('./utils/is');
var protocolCompletionItem_1 = require('./protocolCompletionItem');
var protocolCodeLens_1 = require('./protocolCodeLens');
function createConverter(uriConverter) {
var nullConverter = function (value) { return value.toString(); };
var _uriConverter = uriConverter || nullConverter;
function asUri(value) {
return _uriConverter(value);
}
function asTextDocumentIdentifier(textDocument) {
return {
uri: _uriConverter(textDocument.uri)
};
}
function asOpenTextDocumentParams(textDocument) {
return {
textDocument: {
uri: _uriConverter(textDocument.uri),
languageId: textDocument.languageId,
version: textDocument.version,
text: textDocument.getText()
}
};
}
function isTextDocumentChangeEvent(value) {
var candidate = value;
return is.defined(candidate.document) && is.defined(candidate.contentChanges);
}
function isTextDocument(value) {
var candidate = value;
return is.defined(candidate.uri) && is.defined(candidate.version);
}
function asChangeTextDocumentParams(arg) {
if (isTextDocument(arg)) {
var result = {
textDocument: {
uri: _uriConverter(arg.uri),
version: arg.version
},
contentChanges: [{ text: arg.getText() }]
};
return result;
}
else if (isTextDocumentChangeEvent(arg)) {
var document_1 = arg.document;
var result = {
textDocument: {
uri: _uriConverter(document_1.uri),
version: document_1.version
},
contentChanges: arg.contentChanges.map(function (change) {
var range = change.range;
return {
range: {
start: { line: range.start.line, character: range.start.character },
end: { line: range.end.line, character: range.end.character }
},
rangeLength: change.rangeLength,
text: change.text
};
})
};
return result;
}
else {
throw Error('Unsupported text document change parameter');
}
}
function asCloseTextDocumentParams(textDocument) {
return {
textDocument: asTextDocumentIdentifier(textDocument)
};
}
function asSaveTextDocumentParams(textDocument) {
return {
textDocument: asTextDocumentIdentifier(textDocument)
};
}
function asTextDocumentPositionParams(textDocument, position) {
return {
textDocument: asTextDocumentIdentifier(textDocument),
position: asWorkerPosition(position)
};
}
function asWorkerPosition(position) {
return { line: position.line, character: position.character };
}
function asRange(value) {
if (is.undefined(value)) {
return undefined;
}
else if (is.nil(value)) {
return null;
}
return { start: asPosition(value.start), end: asPosition(value.end) };
}
function asPosition(value) {
if (is.undefined(value)) {
return undefined;
}
else if (is.nil(value)) {
return null;
}
return { line: value.line, character: value.character };
}
function set(value, func) {
if (is.defined(value)) {
func();
}
}
function asDiagnosticSeverity(value) {
switch (value) {
case code.DiagnosticSeverity.Error:
return 1 /* Error */;
case code.DiagnosticSeverity.Warning:
return 2 /* Warning */;
case code.DiagnosticSeverity.Information:
return 3 /* Information */;
case code.DiagnosticSeverity.Hint:
return 4 /* Hint */;
}
}
function asDiagnostic(item) {
var result = ls.Diagnostic.create(asRange(item.range), item.message);
set(item.severity, function () { return result.severity = asDiagnosticSeverity(item.severity); });
set(item.code, function () { return result.code = item.code; });
set(item.source, function () { return result.source = item.source; });
return result;
}
function asDiagnostics(items) {
if (is.undefined(items) || is.nil(items)) {
return items;
}
return items.map(asDiagnostic);
}
function asCompletionItem(item) {
var result = { label: item.label };
set(item.detail, function () { return result.detail = item.detail; });
set(item.documentation, function () { return result.documentation = item.documentation; });
set(item.filterText, function () { return result.filterText = item.filterText; });
set(item.insertText, function () { return result.insertText = item.insertText; });
// Protocol item kind is 1 based, codes item kind is zero based.
set(item.kind, function () { return result.kind = item.kind + 1; });
set(item.sortText, function () { return result.sortText = item.sortText; });
set(item.textEdit, function () { return result.textEdit = asTextEdit(item.textEdit); });
set(item.additionalTextEdits, function () { return result.additionalTextEdits = asTextEdits(item.additionalTextEdits); });
set(item.command, function () { return result.command = asCommand(item.command); });
if (item instanceof protocolCompletionItem_1.default) {
set(item.data, function () { return result.data = item.data; });
}
return result;
}
function asTextEdit(edit) {
return { range: asRange(edit.range), newText: edit.newText };
}
function asTextEdits(edits) {
if (is.undefined(edits) || is.nil(edits)) {
return edits;
}
return edits.map(asTextEdit);
}
function asReferenceParams(textDocument, position, options) {
return {
textDocument: asTextDocumentIdentifier(textDocument),
position: asWorkerPosition(position),
context: { includeDeclaration: options.includeDeclaration }
};
}
function asCodeActionContext(context) {
if (is.undefined(context) || is.nil(context)) {
return context;
}
return ls.CodeActionContext.create(asDiagnostics(context.diagnostics));
}
function asCommand(item) {
var result = ls.Command.create(item.title, item.command);
if (is.defined(item.arguments))
result.arguments = item.arguments;
return result;
}
function asCodeLens(item) {
var result = ls.CodeLens.create(asRange(item.range));
if (is.defined(item.command))
result.command = asCommand(item.command);
if (item instanceof protocolCodeLens_1.default) {
if (is.defined(item.data))
result.data = item.data;
}
return result;
}
function asFormattingOptions(item) {
return { tabSize: item.tabSize, insertSpaces: item.insertSpaces };
}
function asDocumentSymbolParams(textDocument) {
return {
textDocument: asTextDocumentIdentifier(textDocument)
};
}
function asCodeLensParams(textDocument) {
return {
textDocument: asTextDocumentIdentifier(textDocument)
};
}
function asDocumentLink(item) {
var result = ls.DocumentLink.create(asRange(item.range));
if (is.defined(item.target))
result.target = asUri(item.target);
return result;
}
function asDocumentLinkParams(textDocument) {
return {
textDocument: asTextDocumentIdentifier(textDocument)
};
}
return {
asUri: asUri,
asTextDocumentIdentifier: asTextDocumentIdentifier,
asOpenTextDocumentParams: asOpenTextDocumentParams,
asChangeTextDocumentParams: asChangeTextDocumentParams,
asCloseTextDocumentParams: asCloseTextDocumentParams,
asSaveTextDocumentParams: asSaveTextDocumentParams,
asTextDocumentPositionParams: asTextDocumentPositionParams,
asWorkerPosition: asWorkerPosition,
asRange: asRange,
asPosition: asPosition,
asDiagnosticSeverity: asDiagnosticSeverity,
asDiagnostic: asDiagnostic,
asDiagnostics: asDiagnostics,
asCompletionItem: asCompletionItem,
asTextEdit: asTextEdit,
asReferenceParams: asReferenceParams,
asCodeActionContext: asCodeActionContext,
asCommand: asCommand,
asCodeLens: asCodeLens,
asFormattingOptions: asFormattingOptions,
asDocumentSymbolParams: asDocumentSymbolParams,
asCodeLensParams: asCodeLensParams,
asDocumentLink: asDocumentLink,
asDocumentLinkParams: asDocumentLinkParams
};
}
exports.createConverter = createConverter;
// This for backward compatibility since we exported the converter functions as API.
var defaultConverter = createConverter();
exports.asTextDocumentIdentifier = defaultConverter.asTextDocumentIdentifier;
exports.asOpenTextDocumentParams = defaultConverter.asOpenTextDocumentParams;
exports.asChangeTextDocumentParams = defaultConverter.asChangeTextDocumentParams;
exports.asCloseTextDocumentParams = defaultConverter.asCloseTextDocumentParams;
exports.asSaveTextDocumentParams = defaultConverter.asSaveTextDocumentParams;
exports.asTextDocumentPositionParams = defaultConverter.asTextDocumentPositionParams;
exports.asWorkerPosition = defaultConverter.asWorkerPosition;
exports.asRange = defaultConverter.asRange;
exports.asPosition = defaultConverter.asPosition;
exports.asDiagnosticSeverity = defaultConverter.asDiagnosticSeverity;
exports.asDiagnostic = defaultConverter.asDiagnostic;
exports.asDiagnostics = defaultConverter.asDiagnostics;
exports.asCompletionItem = defaultConverter.asCompletionItem;
exports.asTextEdit = defaultConverter.asTextEdit;
exports.asReferenceParams = defaultConverter.asReferenceParams;
exports.asCodeActionContext = defaultConverter.asCodeActionContext;
exports.asCommand = defaultConverter.asCommand;
exports.asCodeLens = defaultConverter.asCodeLens;
exports.asFormattingOptions = defaultConverter.asFormattingOptions;
exports.asDocumentSymbolParams = defaultConverter.asDocumentSymbolParams;
exports.asCodeLensParams = defaultConverter.asCodeLensParams;

View File

@ -1,233 +0,0 @@
import * as cp from 'child_process';
import ChildProcess = cp.ChildProcess;
import { TextDocument, Disposable, OutputChannel, FileSystemWatcher, DiagnosticCollection, CancellationToken } from 'vscode';
import { Message, RequestHandler, NotificationHandler, ErrorCodes, ResponseError, RequestType, NotificationType, Trace, Event } from 'vscode-jsonrpc';
import { Range, Position, Location, TextEdit, WorkspaceChange, TextEditChange, TextDocumentIdentifier } from 'vscode-languageserver-types';
import { InitializeError, TextDocumentPositionParams } from './protocol';
import * as c2p from './codeConverter';
import * as p2c from './protocolConverter';
export { RequestType, NotificationType, NotificationHandler, RequestHandler, ResponseError, InitializeError, ErrorCodes, Position, Range, Location, TextDocumentIdentifier, TextDocumentPositionParams, TextEdit, TextEditChange, WorkspaceChange, c2p as Code2Protocol, p2c as Protocol2Code };
export interface StreamInfo {
writer: NodeJS.WritableStream;
reader: NodeJS.ReadableStream;
}
export interface ExecutableOptions {
cwd?: string;
stdio?: string | string[];
env?: any;
detached?: boolean;
}
export interface Executable {
command: string;
args?: string[];
options?: ExecutableOptions;
}
export interface ForkOptions {
cwd?: string;
env?: any;
encoding?: string;
execArgv?: string[];
}
export declare enum TransportKind {
stdio = 0,
ipc = 1,
}
export interface NodeModule {
module: string;
transport?: TransportKind;
args?: string[];
runtime?: string;
options?: ForkOptions;
}
export declare type ServerOptions = Executable | {
run: Executable;
debug: Executable;
} | {
run: NodeModule;
debug: NodeModule;
} | NodeModule | (() => Thenable<ChildProcess | StreamInfo>);
/**
* An action to be performed when the connection is producing errors.
*/
export declare enum ErrorAction {
/**
* Continue running the server.
*/
Continue = 1,
/**
* Shutdown the server.
*/
Shutdown = 2,
}
/**
* An action to be performed when the connection to a server got closed.
*/
export declare enum CloseAction {
/**
* Don't restart the server. The connection stays closed.
*/
DoNotRestart = 1,
/**
* Restart the server.
*/
Restart = 2,
}
/**
* A pluggable error handler that is invoked when the connection is either
* producing errors or got closed.
*/
export interface ErrorHandler {
/**
* An error has occurred while writing or reading from the connection.
*
* @param error - the error received
* @param message - the message to be delivered to the server if know.
* @param count - a count indicating how often an error is received. Will
* be reset if a message got successfully send or received.
*/
error(error: Error, message: Message, count: number): ErrorAction;
/**
* The connection to the server got closed.
*/
closed(): CloseAction;
}
export interface InitializationFailedHandler {
(error: ResponseError<InitializeError> | Error | any): boolean;
}
export interface SynchronizeOptions {
configurationSection?: string | string[];
fileEvents?: FileSystemWatcher | FileSystemWatcher[];
textDocumentFilter?: (textDocument: TextDocument) => boolean;
}
export declare enum RevealOutputChannelOn {
Info = 1,
Warn = 2,
Error = 3,
Never = 4,
}
export interface LanguageClientOptions {
documentSelector?: string | string[];
synchronize?: SynchronizeOptions;
diagnosticCollectionName?: string;
outputChannelName?: string;
revealOutputChannelOn?: RevealOutputChannelOn;
/**
* The encoding use to read stdout and stderr. Defaults
* to 'utf8' if ommitted.
*/
stdioEncoding?: string;
initializationOptions?: any | (() => any);
initializationFailedHandler?: InitializationFailedHandler;
errorHandler?: ErrorHandler;
uriConverters?: {
code2Protocol: c2p.URIConverter;
protocol2Code: p2c.URIConverter;
};
}
export declare enum State {
Stopped = 1,
Running = 2,
}
export interface StateChangeEvent {
oldState: State;
newState: State;
}
export declare class LanguageClient {
private _id;
private _name;
private _serverOptions;
private _clientOptions;
private _forceDebug;
private _state;
private _onReady;
private _onReadyCallbacks;
private _connection;
private _childProcess;
private _outputChannel;
private _capabilites;
private _listeners;
private _providers;
private _diagnostics;
private _syncExpression;
private _documentSyncDelayer;
private _fileEvents;
private _fileEventDelayer;
private _telemetryEmitter;
private _stateChangeEmitter;
private _trace;
private _tracer;
private _c2p;
private _p2c;
constructor(name: string, serverOptions: ServerOptions, clientOptions: LanguageClientOptions, forceDebug?: boolean);
constructor(id: string, name: string, serverOptions: ServerOptions, clientOptions: LanguageClientOptions, forceDebug?: boolean);
private state;
private getPublicState();
private computeSyncExpression();
sendRequest<P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken): Thenable<R>;
private doSendRequest<P, R, E>(connection, type, params, token?);
sendNotification<P>(type: NotificationType<P>, params?: P): void;
onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): void;
onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): void;
onTelemetry: Event<any>;
onDidChangeState: Event<StateChangeEvent>;
outputChannel: OutputChannel;
diagnostics: DiagnosticCollection;
createDefaultErrorHandler(): ErrorHandler;
trace: Trace;
private data2String(data);
info(message: string, data?: any): void;
warn(message: string, data?: any): void;
error(message: string, data?: any): void;
private logTrace(message, data?);
needsStart(): boolean;
needsStop(): boolean;
onReady(): Promise<void>;
private isConnectionActive();
start(): Disposable;
private resolveConnection();
private initialize(connection);
stop(): Thenable<void>;
private cleanUp(diagnostics?);
private notifyConfigurationChanged(settings);
private notifyFileEvent(event);
private onDidOpenTextDoument(connection, textDocument);
private onDidChangeTextDocument(connection, event);
private onDidCloseTextDoument(connection, textDocument);
private onDidSaveTextDocument(conneciton, textDocument);
private forceDocumentSync();
private handleDiagnostics(params);
private createConnection();
private handleConnectionClosed();
private handleConnectionError(error, message, count);
private checkProcessDied(childProcess);
private hookConfigurationChanged(connection);
private refreshTrace(connection, sendNotification?);
private onDidChangeConfiguration(connection);
private extractSettingsInformation(keys);
private hookFileEvents(connection);
private hookCapabilities(connection);
private logFailedRequest(type, error);
private hookCompletionProvider(documentSelector, connection);
private hookHoverProvider(documentSelector, connection);
private hookSignatureHelpProvider(documentSelector, connection);
private hookDefinitionProvider(documentSelector, connection);
private hookReferencesProvider(documentSelector, connection);
private hookDocumentHighlightProvider(documentSelector, connection);
private hookDocumentSymbolProvider(documentSelector, connection);
private hookWorkspaceSymbolProvider(connection);
private hookCodeActionsProvider(documentSelector, connection);
private hookCodeLensProvider(documentSelector, connection);
private hookDocumentFormattingProvider(documentSelector, connection);
private hookDocumentRangeFormattingProvider(documentSelector, connection);
private hookDocumentOnTypeFormattingProvider(documentSelector, connection);
private hookRenameProvider(documentSelector, connection);
private hookDocumentLinkProvider(documentSelector, connection);
}
export declare class SettingMonitor {
private _client;
private _setting;
private _listeners;
constructor(_client: LanguageClient, _setting: string);
start(): Disposable;
private onDidChangeConfiguration();
}

View File

@ -1,758 +0,0 @@
import { RequestType, NotificationType } from 'vscode-jsonrpc';
import { TextDocumentContentChangeEvent, Range, Position, Location, Diagnostic, Command, TextEdit, WorkspaceEdit, TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextDocumentItem, CompletionItem, CompletionList, Hover, SignatureHelp, Definition, ReferenceContext, DocumentHighlight, SymbolInformation, CodeLens, CodeActionContext, FormattingOptions, DocumentLink } from 'vscode-languageserver-types';
/**
* A parameter literal used in requests to pass a text document and a position inside that
* document.
*/
export interface TextDocumentPositionParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
/**
* The position inside the text document.
*/
position: Position;
}
/**
* Defines the capabilities provided by the client.
*/
export interface ClientCapabilities {
}
/**
* Defines how the host (editor) should sync
* document changes to the language server.
*/
export declare enum TextDocumentSyncKind {
/**
* Documents should not be synced at all.
*/
None = 0,
/**
* Documents are synced by always sending the full content
* of the document.
*/
Full = 1,
/**
* Documents are synced by sending the full content on open.
* After that only incremental updates to the document are
* send.
*/
Incremental = 2,
}
/**
* Completion options.
*/
export interface CompletionOptions {
/**
* The server provides support to resolve additional
* information for a completion item.
*/
resolveProvider?: boolean;
/**
* The characters that trigger completion automatically.
*/
triggerCharacters?: string[];
}
/**
* Signature help options.
*/
export interface SignatureHelpOptions {
/**
* The characters that trigger signature help
* automatically.
*/
triggerCharacters?: string[];
}
/**
* Code Lens options.
*/
export interface CodeLensOptions {
/**
* Code lens has a resolve provider as well.
*/
resolveProvider?: boolean;
}
/**
* Format document on type options
*/
export interface DocumentOnTypeFormattingOptions {
/**
* A character on which formatting should be triggered, like `}`.
*/
firstTriggerCharacter: string;
/**
* More trigger characters.
*/
moreTriggerCharacter?: string[];
}
/**
* Document link options
*/
export interface DocumentLinkOptions {
/**
* Document links have a resolve provider as well.
*/
resolveProvider?: boolean;
}
/**
* Defines the capabilities provided by a language
* server.
*/
export interface ServerCapabilities {
/**
* Defines how text documents are synced.
*/
textDocumentSync?: number;
/**
* The server provides hover support.
*/
hoverProvider?: boolean;
/**
* The server provides completion support.
*/
completionProvider?: CompletionOptions;
/**
* The server provides signature help support.
*/
signatureHelpProvider?: SignatureHelpOptions;
/**
* The server provides goto definition support.
*/
definitionProvider?: boolean;
/**
* The server provides find references support.
*/
referencesProvider?: boolean;
/**
* The server provides document highlight support.
*/
documentHighlightProvider?: boolean;
/**
* The server provides document symbol support.
*/
documentSymbolProvider?: boolean;
/**
* The server provides workspace symbol support.
*/
workspaceSymbolProvider?: boolean;
/**
* The server provides code actions.
*/
codeActionProvider?: boolean;
/**
* The server provides code lens.
*/
codeLensProvider?: CodeLensOptions;
/**
* The server provides document formatting.
*/
documentFormattingProvider?: boolean;
/**
* The server provides document range formatting.
*/
documentRangeFormattingProvider?: boolean;
/**
* The server provides document formatting on typing.
*/
documentOnTypeFormattingProvider?: DocumentOnTypeFormattingOptions;
/**
* The server provides rename support.
*/
renameProvider?: boolean;
/**
* The server provides document link support.
*/
documentLinkProvider?: DocumentLinkOptions;
}
/**
* The initialize method is sent from the client to the server.
* It is send once as the first method after starting up the
* worker. The requests parameter is of type [InitializeParams](#InitializeParams)
* the response if of type [InitializeResult](#InitializeResult) of a Thenable that
* resolves to such.
*/
export declare namespace InitializeRequest {
const type: RequestType<InitializeParams, InitializeResult, InitializeError>;
}
/**
* The initialize parameters
*/
export interface InitializeParams {
/**
* The process Id of the parent process that started
* the server.
*/
processId: number;
/**
* The rootPath of the workspace. Is null
* if no folder is open.
*/
rootPath: string;
/**
* The capabilities provided by the client (editor)
*/
capabilities: ClientCapabilities;
/**
* User provided initialization options.
*/
initializationOptions?: any;
/**
* The initial trace setting. If omitted trace is disabled ('off').
*/
trace?: 'off' | 'messages' | 'verbose';
}
/**
* The result returned from an initilize request.
*/
export interface InitializeResult {
/**
* The capabilities the language server provides.
*/
capabilities: ServerCapabilities;
}
/**
* The data type of the ResponseError if the
* initialize request fails.
*/
export interface InitializeError {
/**
* Indicates whether the client should retry to send the
* initilize request after showing the message provided
* in the {@link ResponseError}
*/
retry: boolean;
}
/**
* A shutdown request is sent from the client to the server.
* It is send once when the client descides to shutdown the
* server. The only notification that is sent after a shudown request
* is the exit event.
*/
export declare namespace ShutdownRequest {
const type: RequestType<void, void, void>;
}
/**
* The exit event is sent from the client to the server to
* ask the server to exit its process.
*/
export declare namespace ExitNotification {
const type: NotificationType<void>;
}
/**
* The configuration change notification is sent from the client to the server
* when the client's configuration has changed. The notification contains
* the changed configuration as defined by the language client.
*/
export declare namespace DidChangeConfigurationNotification {
const type: NotificationType<DidChangeConfigurationParams>;
}
/**
* The parameters of a change configuration notification.
*/
export interface DidChangeConfigurationParams {
/**
* The actual changed settings
*/
settings: any;
}
/**
* The message type
*/
export declare enum MessageType {
/**
* An error message.
*/
Error = 1,
/**
* A warning message.
*/
Warning = 2,
/**
* An information message.
*/
Info = 3,
/**
* A log message.
*/
Log = 4,
}
/**
* The parameters of a notification message.
*/
export interface ShowMessageParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
}
/**
* The show message notification is sent from a server to a client to ask
* the client to display a particular message in the user interface.
*/
export declare namespace ShowMessageNotification {
const type: NotificationType<ShowMessageParams>;
}
export interface MessageActionItem {
/**
* A short title like 'Retry', 'Open Log' etc.
*/
title: string;
}
export interface ShowMessageRequestParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
/**
* The message action items to present.
*/
actions?: MessageActionItem[];
}
/**
* The show message request is send from the server to the clinet to show a message
* and a set of options actions to the user.
*/
export declare namespace ShowMessageRequest {
const type: RequestType<ShowMessageRequestParams, MessageActionItem, void>;
}
/**
* The log message notification is send from the server to the client to ask
* the client to log a particular message.
*/
export declare namespace LogMessageNotification {
let type: NotificationType<LogMessageParams>;
}
/**
* The log message parameters.
*/
export interface LogMessageParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
}
/**
* The telemetry event notification is send from the server to the client to ask
* the client to log telemetry data.
*/
export declare namespace TelemetryEventNotification {
let type: NotificationType<any>;
}
/**
* The parameters send in a open text document notification
*/
export interface DidOpenTextDocumentParams {
/**
* The document that was opened.
*/
textDocument: TextDocumentItem;
}
/**
* The document open notification is sent from the client to the server to signal
* newly opened text documents. The document's truth is now managed by the client
* and the server must not try to read the document's truth using the document's
* uri.
*/
export declare namespace DidOpenTextDocumentNotification {
const type: NotificationType<DidOpenTextDocumentParams>;
}
/**
* An event describing a change to a text document. If range and rangeLength are omitted
* the new text is considered to be the full content of the document.
*/
export interface TextDocumentContentChangeEvent {
/**
* The range of the document that changed.
*/
range?: Range;
/**
* The length of the range that got replaced.
*/
rangeLength?: number;
/**
* The new text of the document.
*/
text: string;
}
/**
* The change text document notification's parameters.
*/
export interface DidChangeTextDocumentParams {
/**
* The document that did change. The version number points
* to the version after all provided content changes have
* been applied.
*/
textDocument: VersionedTextDocumentIdentifier;
/**
* The actual content changes.
*/
contentChanges: TextDocumentContentChangeEvent[];
}
/**
* The document change notification is sent from the client to the server to signal
* changes to a text document.
*/
export declare namespace DidChangeTextDocumentNotification {
const type: NotificationType<DidChangeTextDocumentParams>;
}
/**
* The parameters send in a close text document notification
*/
export interface DidCloseTextDocumentParams {
/**
* The document that was closed.
*/
textDocument: TextDocumentIdentifier;
}
/**
* The document close notification is sent from the client to the server when
* the document got closed in the client. The document's truth now exists
* where the document's uri points to (e.g. if the document's uri is a file uri
* the truth now exists on disk).
*/
export declare namespace DidCloseTextDocumentNotification {
const type: NotificationType<DidCloseTextDocumentParams>;
}
/**
* The parameters send in a save text document notification
*/
export interface DidSaveTextDocumentParams {
/**
* The document that was closed.
*/
textDocument: TextDocumentIdentifier;
}
/**
* The document save notification is sent from the client to the server when
* the document got saved in the client.
*/
export declare namespace DidSaveTextDocumentNotification {
const type: NotificationType<DidSaveTextDocumentParams>;
}
/**
* The watched files notification is sent from the client to the server when
* the client detects changes to file watched by the lanaguage client.
*/
export declare namespace DidChangeWatchedFilesNotification {
const type: NotificationType<DidChangeWatchedFilesParams>;
}
/**
* The watched files change notification's parameters.
*/
export interface DidChangeWatchedFilesParams {
/**
* The actual file events.
*/
changes: FileEvent[];
}
/**
* The file event type
*/
export declare enum FileChangeType {
/**
* The file got created.
*/
Created = 1,
/**
* The file got changed.
*/
Changed = 2,
/**
* The file got deleted.
*/
Deleted = 3,
}
/**
* An event describing a file change.
*/
export interface FileEvent {
/**
* The file's uri.
*/
uri: string;
/**
* The change type.
*/
type: number;
}
/**
* Diagnostics notification are sent from the server to the client to signal
* results of validation runs.
*/
export declare namespace PublishDiagnosticsNotification {
const type: NotificationType<PublishDiagnosticsParams>;
}
/**
* The publish diagnostic notification's parameters.
*/
export interface PublishDiagnosticsParams {
/**
* The URI for which diagnostic information is reported.
*/
uri: string;
/**
* An array of diagnostic information items.
*/
diagnostics: Diagnostic[];
}
/**
* Request to request completion at a given text document position. The request's
* parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
* is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
* or a Thenable that resolves to such.
*/
export declare namespace CompletionRequest {
const type: RequestType<TextDocumentPositionParams, CompletionItem[] | CompletionList, void>;
}
/**
* Request to resolve additional information for a given completion item.The request's
* parameter is of type [CompletionItem](#CompletionItem) the response
* is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
*/
export declare namespace CompletionResolveRequest {
const type: RequestType<CompletionItem, CompletionItem, void>;
}
export declare type MarkedString = string | {
language: string;
value: string;
};
/**
* Request to request hover information at a given text document position. The request's
* parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
* type [Hover](#Hover) or a Thenable that resolves to such.
*/
export declare namespace HoverRequest {
const type: RequestType<TextDocumentPositionParams, Hover, void>;
}
export declare namespace SignatureHelpRequest {
const type: RequestType<TextDocumentPositionParams, SignatureHelp, void>;
}
/**
* A request to resolve the defintion location of a symbol at a given text
* document position. The request's parameter is of type [TextDocumentPosition]
* (#TextDocumentPosition) the response is of type [Definition](#Definition) or a
* Thenable that resolves to such.
*/
export declare namespace DefinitionRequest {
const type: RequestType<TextDocumentPositionParams, Definition, void>;
}
/**
* Parameters for a [ReferencesRequest](#ReferencesRequest).
*/
export interface ReferenceParams extends TextDocumentPositionParams {
context: ReferenceContext;
}
/**
* A request to resolve project-wide references for the symbol denoted
* by the given text document position. The request's parameter is of
* type [ReferenceParams](#ReferenceParams) the response is of type
* [Location[]](#Location) or a Thenable that resolves to such.
*/
export declare namespace ReferencesRequest {
const type: RequestType<ReferenceParams, Location[], void>;
}
/**
* Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
* text document position. The request's parameter is of type [TextDocumentPosition]
* (#TextDocumentPosition) the request reponse is of type [DocumentHighlight[]]
* (#DocumentHighlight) or a Thenable that resolves to such.
*/
export declare namespace DocumentHighlightRequest {
const type: RequestType<TextDocumentPositionParams, DocumentHighlight[], void>;
}
/**
* Parameters for a [DocumentSymbolRequest](#DocumentSymbolRequest).
*/
export interface DocumentSymbolParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
}
/**
* A request to list all symbols found in a given text document. The request's
* parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
* response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
* that resolves to such.
*/
export declare namespace DocumentSymbolRequest {
const type: RequestType<DocumentSymbolParams, SymbolInformation[], void>;
}
/**
* The parameters of a [WorkspaceSymbolRequest](#WorkspaceSymbolRequest).
*/
export interface WorkspaceSymbolParams {
/**
* A non-empty query string
*/
query: string;
}
/**
* A request to list project-wide symbols matching the query string given
* by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
* of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
* resolves to such.
*/
export declare namespace WorkspaceSymbolRequest {
const type: RequestType<WorkspaceSymbolParams, SymbolInformation[], void>;
}
/**
* Params for the CodeActionRequest
*/
export interface CodeActionParams {
/**
* The document in which the command was invoked.
*/
textDocument: TextDocumentIdentifier;
/**
* The range for which the command was invoked.
*/
range: Range;
/**
* Context carrying additional information.
*/
context: CodeActionContext;
}
/**
* A request to provide commands for the given text document and range.
*/
export declare namespace CodeActionRequest {
const type: RequestType<CodeActionParams, Command[], void>;
}
/**
* Params for the Code Lens request.
*/
export interface CodeLensParams {
/**
* The document to request code lens for.
*/
textDocument: TextDocumentIdentifier;
}
/**
* A request to provide code lens for the given text document.
*/
export declare namespace CodeLensRequest {
const type: RequestType<CodeLensParams, CodeLens[], void>;
}
/**
* A request to resolve a command for a given code lens.
*/
export declare namespace CodeLensResolveRequest {
const type: RequestType<CodeLens, CodeLens, void>;
}
export interface DocumentFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The format options
*/
options: FormattingOptions;
}
/**
* A request to to format a whole document.
*/
export declare namespace DocumentFormattingRequest {
const type: RequestType<DocumentFormattingParams, TextEdit[], void>;
}
export interface DocumentRangeFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The range to format
*/
range: Range;
/**
* The format options
*/
options: FormattingOptions;
}
/**
* A request to to format a range in a document.
*/
export declare namespace DocumentRangeFormattingRequest {
const type: RequestType<DocumentRangeFormattingParams, TextEdit[], void>;
}
export interface DocumentOnTypeFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The position at which this request was send.
*/
position: Position;
/**
* The character that has been typed.
*/
ch: string;
/**
* The format options.
*/
options: FormattingOptions;
}
/**
* A request to format a document on type.
*/
export declare namespace DocumentOnTypeFormattingRequest {
const type: RequestType<DocumentOnTypeFormattingParams, TextEdit[], void>;
}
export interface RenameParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The position at which this request was send.
*/
position: Position;
/**
* The new name of the symbol. If the given name is not valid the
* request must return a [ResponseError](#ResponseError) with an
* appropriate message set.
*/
newName: string;
}
/**
* A request to rename a symbol.
*/
export declare namespace RenameRequest {
const type: RequestType<RenameParams, WorkspaceEdit, void>;
}
export interface DocumentLinkParams {
/**
* The document to provide document links for.
*/
textDocument: TextDocumentIdentifier;
}
/**
* A request to provide document links
*/
export declare namespace DocumentLinkRequest {
const type: RequestType<DocumentLinkParams, DocumentLink[], void>;
}
/**
* Request to resolve additional information for a given document link. The request's
* parameter is of type [DocumentLink](#DocumentLink) the response
* is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
*/
export declare namespace DocumentLinkResolveRequest {
const type: RequestType<DocumentLink, DocumentLink, void>;
}

View File

@ -1,347 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
/**
* Defines how the host (editor) should sync
* document changes to the language server.
*/
(function (TextDocumentSyncKind) {
/**
* Documents should not be synced at all.
*/
TextDocumentSyncKind[TextDocumentSyncKind["None"] = 0] = "None";
/**
* Documents are synced by always sending the full content
* of the document.
*/
TextDocumentSyncKind[TextDocumentSyncKind["Full"] = 1] = "Full";
/**
* Documents are synced by sending the full content on open.
* After that only incremental updates to the document are
* send.
*/
TextDocumentSyncKind[TextDocumentSyncKind["Incremental"] = 2] = "Incremental";
})(exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
var TextDocumentSyncKind = exports.TextDocumentSyncKind;
/**
* The initialize method is sent from the client to the server.
* It is send once as the first method after starting up the
* worker. The requests parameter is of type [InitializeParams](#InitializeParams)
* the response if of type [InitializeResult](#InitializeResult) of a Thenable that
* resolves to such.
*/
var InitializeRequest;
(function (InitializeRequest) {
InitializeRequest.type = { get method() { return 'initialize'; } };
})(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
//---- Shutdown Method ----
/**
* A shutdown request is sent from the client to the server.
* It is send once when the client descides to shutdown the
* server. The only notification that is sent after a shudown request
* is the exit event.
*/
var ShutdownRequest;
(function (ShutdownRequest) {
ShutdownRequest.type = { get method() { return 'shutdown'; } };
})(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
//---- Exit Notification ----
/**
* The exit event is sent from the client to the server to
* ask the server to exit its process.
*/
var ExitNotification;
(function (ExitNotification) {
ExitNotification.type = { get method() { return 'exit'; } };
})(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
//---- Configuration notification ----
/**
* The configuration change notification is sent from the client to the server
* when the client's configuration has changed. The notification contains
* the changed configuration as defined by the language client.
*/
var DidChangeConfigurationNotification;
(function (DidChangeConfigurationNotification) {
DidChangeConfigurationNotification.type = { get method() { return 'workspace/didChangeConfiguration'; } };
})(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
//---- Message show and log notifications ----
/**
* The message type
*/
(function (MessageType) {
/**
* An error message.
*/
MessageType[MessageType["Error"] = 1] = "Error";
/**
* A warning message.
*/
MessageType[MessageType["Warning"] = 2] = "Warning";
/**
* An information message.
*/
MessageType[MessageType["Info"] = 3] = "Info";
/**
* A log message.
*/
MessageType[MessageType["Log"] = 4] = "Log";
})(exports.MessageType || (exports.MessageType = {}));
var MessageType = exports.MessageType;
/**
* The show message notification is sent from a server to a client to ask
* the client to display a particular message in the user interface.
*/
var ShowMessageNotification;
(function (ShowMessageNotification) {
ShowMessageNotification.type = { get method() { return 'window/showMessage'; } };
})(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
/**
* The show message request is send from the server to the clinet to show a message
* and a set of options actions to the user.
*/
var ShowMessageRequest;
(function (ShowMessageRequest) {
ShowMessageRequest.type = { get method() { return 'window/showMessageRequest'; } };
})(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
/**
* The log message notification is send from the server to the client to ask
* the client to log a particular message.
*/
var LogMessageNotification;
(function (LogMessageNotification) {
LogMessageNotification.type = { get method() { return 'window/logMessage'; } };
})(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
//---- Telemetry notification
/**
* The telemetry event notification is send from the server to the client to ask
* the client to log telemetry data.
*/
var TelemetryEventNotification;
(function (TelemetryEventNotification) {
TelemetryEventNotification.type = { get method() { return 'telemetry/event'; } };
})(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
/**
* The document open notification is sent from the client to the server to signal
* newly opened text documents. The document's truth is now managed by the client
* and the server must not try to read the document's truth using the document's
* uri.
*/
var DidOpenTextDocumentNotification;
(function (DidOpenTextDocumentNotification) {
DidOpenTextDocumentNotification.type = { get method() { return 'textDocument/didOpen'; } };
})(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
/**
* The document change notification is sent from the client to the server to signal
* changes to a text document.
*/
var DidChangeTextDocumentNotification;
(function (DidChangeTextDocumentNotification) {
DidChangeTextDocumentNotification.type = { get method() { return 'textDocument/didChange'; } };
})(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
/**
* The document close notification is sent from the client to the server when
* the document got closed in the client. The document's truth now exists
* where the document's uri points to (e.g. if the document's uri is a file uri
* the truth now exists on disk).
*/
var DidCloseTextDocumentNotification;
(function (DidCloseTextDocumentNotification) {
DidCloseTextDocumentNotification.type = { get method() { return 'textDocument/didClose'; } };
})(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
/**
* The document save notification is sent from the client to the server when
* the document got saved in the client.
*/
var DidSaveTextDocumentNotification;
(function (DidSaveTextDocumentNotification) {
DidSaveTextDocumentNotification.type = { get method() { return 'textDocument/didSave'; } };
})(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
//---- File eventing ----
/**
* The watched files notification is sent from the client to the server when
* the client detects changes to file watched by the lanaguage client.
*/
var DidChangeWatchedFilesNotification;
(function (DidChangeWatchedFilesNotification) {
DidChangeWatchedFilesNotification.type = { get method() { return 'workspace/didChangeWatchedFiles'; } };
})(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
/**
* The file event type
*/
(function (FileChangeType) {
/**
* The file got created.
*/
FileChangeType[FileChangeType["Created"] = 1] = "Created";
/**
* The file got changed.
*/
FileChangeType[FileChangeType["Changed"] = 2] = "Changed";
/**
* The file got deleted.
*/
FileChangeType[FileChangeType["Deleted"] = 3] = "Deleted";
})(exports.FileChangeType || (exports.FileChangeType = {}));
var FileChangeType = exports.FileChangeType;
//---- Diagnostic notification ----
/**
* Diagnostics notification are sent from the server to the client to signal
* results of validation runs.
*/
var PublishDiagnosticsNotification;
(function (PublishDiagnosticsNotification) {
PublishDiagnosticsNotification.type = { get method() { return 'textDocument/publishDiagnostics'; } };
})(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
//---- Completion Support --------------------------
/**
* Request to request completion at a given text document position. The request's
* parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
* is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
* or a Thenable that resolves to such.
*/
var CompletionRequest;
(function (CompletionRequest) {
CompletionRequest.type = { get method() { return 'textDocument/completion'; } };
})(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
/**
* Request to resolve additional information for a given completion item.The request's
* parameter is of type [CompletionItem](#CompletionItem) the response
* is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
*/
var CompletionResolveRequest;
(function (CompletionResolveRequest) {
CompletionResolveRequest.type = { get method() { return 'completionItem/resolve'; } };
})(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
/**
* Request to request hover information at a given text document position. The request's
* parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
* type [Hover](#Hover) or a Thenable that resolves to such.
*/
var HoverRequest;
(function (HoverRequest) {
HoverRequest.type = { get method() { return 'textDocument/hover'; } };
})(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
//---- SignatureHelp ----------------------------------
var SignatureHelpRequest;
(function (SignatureHelpRequest) {
SignatureHelpRequest.type = { get method() { return 'textDocument/signatureHelp'; } };
})(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
//---- Goto Definition -------------------------------------
/**
* A request to resolve the defintion location of a symbol at a given text
* document position. The request's parameter is of type [TextDocumentPosition]
* (#TextDocumentPosition) the response is of type [Definition](#Definition) or a
* Thenable that resolves to such.
*/
var DefinitionRequest;
(function (DefinitionRequest) {
DefinitionRequest.type = { get method() { return 'textDocument/definition'; } };
})(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
/**
* A request to resolve project-wide references for the symbol denoted
* by the given text document position. The request's parameter is of
* type [ReferenceParams](#ReferenceParams) the response is of type
* [Location[]](#Location) or a Thenable that resolves to such.
*/
var ReferencesRequest;
(function (ReferencesRequest) {
ReferencesRequest.type = { get method() { return 'textDocument/references'; } };
})(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
//---- Document Highlight ----------------------------------
/**
* Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
* text document position. The request's parameter is of type [TextDocumentPosition]
* (#TextDocumentPosition) the request reponse is of type [DocumentHighlight[]]
* (#DocumentHighlight) or a Thenable that resolves to such.
*/
var DocumentHighlightRequest;
(function (DocumentHighlightRequest) {
DocumentHighlightRequest.type = { get method() { return 'textDocument/documentHighlight'; } };
})(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
/**
* A request to list all symbols found in a given text document. The request's
* parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
* response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
* that resolves to such.
*/
var DocumentSymbolRequest;
(function (DocumentSymbolRequest) {
DocumentSymbolRequest.type = { get method() { return 'textDocument/documentSymbol'; } };
})(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
/**
* A request to list project-wide symbols matching the query string given
* by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
* of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
* resolves to such.
*/
var WorkspaceSymbolRequest;
(function (WorkspaceSymbolRequest) {
WorkspaceSymbolRequest.type = { get method() { return 'workspace/symbol'; } };
})(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
/**
* A request to provide commands for the given text document and range.
*/
var CodeActionRequest;
(function (CodeActionRequest) {
CodeActionRequest.type = { get method() { return 'textDocument/codeAction'; } };
})(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
/**
* A request to provide code lens for the given text document.
*/
var CodeLensRequest;
(function (CodeLensRequest) {
CodeLensRequest.type = { get method() { return 'textDocument/codeLens'; } };
})(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
/**
* A request to resolve a command for a given code lens.
*/
var CodeLensResolveRequest;
(function (CodeLensResolveRequest) {
CodeLensResolveRequest.type = { get method() { return 'codeLens/resolve'; } };
})(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
/**
* A request to to format a whole document.
*/
var DocumentFormattingRequest;
(function (DocumentFormattingRequest) {
DocumentFormattingRequest.type = { get method() { return 'textDocument/formatting'; } };
})(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
/**
* A request to to format a range in a document.
*/
var DocumentRangeFormattingRequest;
(function (DocumentRangeFormattingRequest) {
DocumentRangeFormattingRequest.type = { get method() { return 'textDocument/rangeFormatting'; } };
})(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
/**
* A request to format a document on type.
*/
var DocumentOnTypeFormattingRequest;
(function (DocumentOnTypeFormattingRequest) {
DocumentOnTypeFormattingRequest.type = { get method() { return 'textDocument/onTypeFormatting'; } };
})(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
/**
* A request to rename a symbol.
*/
var RenameRequest;
(function (RenameRequest) {
RenameRequest.type = { get method() { return 'textDocument/rename'; } };
})(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
/**
* A request to provide document links
*/
var DocumentLinkRequest;
(function (DocumentLinkRequest) {
DocumentLinkRequest.type = { get method() { return 'textDocument/documentLink'; } };
})(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
/**
* Request to resolve additional information for a given document link. The request's
* parameter is of type [DocumentLink](#DocumentLink) the response
* is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
*/
var DocumentLinkResolveRequest;
(function (DocumentLinkResolveRequest) {
DocumentLinkResolveRequest.type = { get method() { return 'documentLink/resolve'; } };
})(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));

View File

@ -1,5 +0,0 @@
import * as code from 'vscode';
export default class ProtocolCodeLens extends code.CodeLens {
data: any;
constructor(range: code.Range);
}

View File

@ -1,20 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var code = require('vscode');
var ProtocolCodeLens = (function (_super) {
__extends(ProtocolCodeLens, _super);
function ProtocolCodeLens(range) {
_super.call(this, range);
}
return ProtocolCodeLens;
}(code.CodeLens));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = ProtocolCodeLens;

View File

@ -1,5 +0,0 @@
import * as code from 'vscode';
export default class ProtocolCompletionItem extends code.CompletionItem {
data: any;
constructor(label: string);
}

View File

@ -1,20 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var code = require('vscode');
var ProtocolCompletionItem = (function (_super) {
__extends(ProtocolCompletionItem, _super);
function ProtocolCompletionItem(label) {
_super.call(this, label);
}
return ProtocolCompletionItem;
}(code.CompletionItem));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = ProtocolCompletionItem;

View File

@ -1,70 +0,0 @@
import * as code from 'vscode';
import * as ls from 'vscode-languageserver-types';
import ProtocolCompletionItem from './protocolCompletionItem';
export interface Converter {
asUri(value: string): code.Uri;
asDiagnostics(diagnostics: ls.Diagnostic[]): code.Diagnostic[];
asDiagnostic(diagnostic: ls.Diagnostic): code.Diagnostic;
asRange(value: ls.Range): code.Range;
asPosition(value: ls.Position): code.Position;
asDiagnosticSeverity(value: number): code.DiagnosticSeverity;
asHover(hover: ls.Hover): code.Hover;
asCompletionResult(result: ls.CompletionItem[] | ls.CompletionList): code.CompletionItem[] | code.CompletionList;
asCompletionItem(item: ls.CompletionItem): ProtocolCompletionItem;
asTextEdit(edit: ls.TextEdit): code.TextEdit;
asTextEdits(items: ls.TextEdit[]): code.TextEdit[];
asSignatureHelp(item: ls.SignatureHelp): code.SignatureHelp;
asSignatureInformations(items: ls.SignatureInformation[]): code.SignatureInformation[];
asSignatureInformation(item: ls.SignatureInformation): code.SignatureInformation;
asParameterInformations(item: ls.ParameterInformation[]): code.ParameterInformation[];
asParameterInformation(item: ls.ParameterInformation): code.ParameterInformation;
asDefinitionResult(item: ls.Definition): code.Definition;
asLocation(item: ls.Location): code.Location;
asReferences(values: ls.Location[]): code.Location[];
asDocumentHighlights(values: ls.DocumentHighlight[]): code.DocumentHighlight[];
asDocumentHighlight(item: ls.DocumentHighlight): code.DocumentHighlight;
asDocumentHighlightKind(item: ls.DocumentHighlightKind): code.DocumentHighlightKind;
asSymbolInformations(values: ls.SymbolInformation[], uri?: code.Uri): code.SymbolInformation[];
asSymbolInformation(item: ls.SymbolInformation, uri?: code.Uri): code.SymbolInformation;
asCommand(item: ls.Command): code.Command;
asCommands(items: ls.Command[]): code.Command[];
asCodeLens(item: ls.CodeLens): code.CodeLens;
asCodeLenses(items: ls.CodeLens[]): code.CodeLens[];
asWorkspaceEdit(item: ls.WorkspaceEdit): code.WorkspaceEdit;
asDocumentLink(item: ls.DocumentLink): code.DocumentLink;
asDocumentLinks(items: ls.DocumentLink[]): code.DocumentLink[];
}
export interface URIConverter {
(value: string): code.Uri;
}
export declare function createConverter(uriConverter?: URIConverter): Converter;
export declare const asDiagnostics: (diagnostics: ls.Diagnostic[]) => code.Diagnostic[];
export declare const asDiagnostic: (diagnostic: ls.Diagnostic) => code.Diagnostic;
export declare const asRange: (value: ls.Range) => code.Range;
export declare const asPosition: (value: ls.Position) => code.Position;
export declare const asDiagnosticSeverity: (value: number) => code.DiagnosticSeverity;
export declare const asHover: (hover: ls.Hover) => code.Hover;
export declare const asCompletionResult: (result: ls.CompletionItem[] | ls.CompletionList) => code.CompletionItem[] | code.CompletionList;
export declare const asCompletionItem: (item: ls.CompletionItem) => ProtocolCompletionItem;
export declare const asTextEdit: (edit: ls.TextEdit) => code.TextEdit;
export declare const asTextEdits: (items: ls.TextEdit[]) => code.TextEdit[];
export declare const asSignatureHelp: (item: ls.SignatureHelp) => code.SignatureHelp;
export declare const asSignatureInformations: (items: ls.SignatureInformation[]) => code.SignatureInformation[];
export declare const asSignatureInformation: (item: ls.SignatureInformation) => code.SignatureInformation;
export declare const asParameterInformations: (item: ls.ParameterInformation[]) => code.ParameterInformation[];
export declare const asParameterInformation: (item: ls.ParameterInformation) => code.ParameterInformation;
export declare const asDefinitionResult: (item: ls.Definition) => code.Definition;
export declare const asLocation: (item: ls.Location) => code.Location;
export declare const asReferences: (values: ls.Location[]) => code.Location[];
export declare const asDocumentHighlights: (values: ls.DocumentHighlight[]) => code.DocumentHighlight[];
export declare const asDocumentHighlight: (item: ls.DocumentHighlight) => code.DocumentHighlight;
export declare const asDocumentHighlightKind: (item: ls.DocumentHighlightKind) => code.DocumentHighlightKind;
export declare const asSymbolInformations: (values: ls.SymbolInformation[], uri?: code.Uri) => code.SymbolInformation[];
export declare const asSymbolInformation: (item: ls.SymbolInformation, uri?: code.Uri) => code.SymbolInformation;
export declare const asCommand: (item: ls.Command) => code.Command;
export declare const asCommands: (items: ls.Command[]) => code.Command[];
export declare const asCodeLens: (item: ls.CodeLens) => code.CodeLens;
export declare const asCodeLenses: (items: ls.CodeLens[]) => code.CodeLens[];
export declare const asWorkspaceEdit: (item: ls.WorkspaceEdit) => code.WorkspaceEdit;
export declare const asDocumentLink: (item: ls.DocumentLink) => code.DocumentLink;
export declare const asDocumentLinks: (item: ls.DocumentLink[]) => code.DocumentLink[];

View File

@ -1,344 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var code = require('vscode');
var ls = require('vscode-languageserver-types');
var is = require('./utils/is');
var protocolCompletionItem_1 = require('./protocolCompletionItem');
var protocolCodeLens_1 = require('./protocolCodeLens');
function createConverter(uriConverter) {
var nullConverter = function (value) { return code.Uri.parse(value); };
var _uriConverter = uriConverter || nullConverter;
function asUri(value) {
return _uriConverter(value);
}
function asDiagnostics(diagnostics) {
return diagnostics.map(asDiagnostic);
}
function asDiagnostic(diagnostic) {
var result = new code.Diagnostic(asRange(diagnostic.range), diagnostic.message, asDiagnosticSeverity(diagnostic.severity));
if (is.defined(diagnostic.code)) {
result.code = diagnostic.code;
}
if (is.defined(diagnostic.source)) {
result.source = diagnostic.source;
}
return result;
}
function asRange(value) {
if (is.undefined(value)) {
return undefined;
}
else if (is.nil(value)) {
return null;
}
return new code.Range(asPosition(value.start), asPosition(value.end));
}
function asPosition(value) {
if (is.undefined(value)) {
return undefined;
}
else if (is.nil(value)) {
return null;
}
return new code.Position(value.line, value.character);
}
function asDiagnosticSeverity(value) {
if (is.undefined(value) || is.nil(value)) {
return code.DiagnosticSeverity.Error;
}
switch (value) {
case 1 /* Error */:
return code.DiagnosticSeverity.Error;
case 2 /* Warning */:
return code.DiagnosticSeverity.Warning;
case 3 /* Information */:
return code.DiagnosticSeverity.Information;
case 4 /* Hint */:
return code.DiagnosticSeverity.Hint;
}
return code.DiagnosticSeverity.Error;
}
function asHover(hover) {
if (is.undefined(hover)) {
return undefined;
}
if (is.nil(hover)) {
return null;
}
return new code.Hover(hover.contents, is.defined(hover.range) ? asRange(hover.range) : undefined);
}
function asCompletionResult(result) {
if (is.undefined(result)) {
return undefined;
}
else if (is.nil(result)) {
return null;
}
if (Array.isArray(result)) {
var items = result;
return items.map(asCompletionItem);
}
var list = result;
return new code.CompletionList(list.items.map(asCompletionItem), list.isIncomplete);
}
function set(value, func) {
if (is.defined(value)) {
func();
}
}
function asCompletionItem(item) {
var result = new protocolCompletionItem_1.default(item.label);
set(item.detail, function () { return result.detail = item.detail; });
set(item.documentation, function () { return result.documentation = item.documentation; });
set(item.filterText, function () { return result.filterText = item.filterText; });
set(item.insertText, function () { return result.insertText = item.insertText; });
// Protocol item kind is 1 based, codes item kind is zero based.
set(item.kind, function () { return result.kind = item.kind - 1; });
set(item.sortText, function () { return result.sortText = item.sortText; });
set(item.textEdit, function () { return result.textEdit = asTextEdit(item.textEdit); });
set(item.additionalTextEdits, function () { return result.additionalTextEdits = asTextEdits(item.additionalTextEdits); });
set(item.command, function () { return result.command = asCommand(item.command); });
set(item.data, function () { return result.data = item.data; });
return result;
}
function asTextEdit(edit) {
return new code.TextEdit(asRange(edit.range), edit.newText);
}
function asTextEdits(items) {
if (is.undefined(items)) {
return undefined;
}
else if (is.nil(items)) {
return null;
}
return items.map(asTextEdit);
}
function asSignatureHelp(item) {
if (is.undefined(item)) {
return undefined;
}
else if (is.nil(item)) {
return null;
}
var result = new code.SignatureHelp();
set(item.activeParameter, function () { return result.activeParameter = item.activeParameter; });
set(item.activeSignature, function () { return result.activeSignature = item.activeSignature; });
set(item.signatures, function () { return result.signatures = asSignatureInformations(item.signatures); });
return result;
}
function asSignatureInformations(items) {
return items.map(asSignatureInformation);
}
function asSignatureInformation(item) {
var result = new code.SignatureInformation(item.label);
set(item.documentation, function () { return result.documentation = item.documentation; });
set(item.parameters, function () { return result.parameters = asParameterInformations(item.parameters); });
return result;
}
function asParameterInformations(item) {
return item.map(asParameterInformation);
}
function asParameterInformation(item) {
var result = new code.ParameterInformation(item.label);
set(item.documentation, function () { return result.documentation = item.documentation; });
return result;
}
function asDefinitionResult(item) {
if (is.undefined(item)) {
return undefined;
}
else if (is.nil(item)) {
return null;
}
if (is.array(item)) {
return item.map(asLocation);
}
else {
return asLocation(item);
}
}
function asLocation(item) {
if (is.undefined(item)) {
return undefined;
}
if (is.nil(item)) {
return null;
}
return new code.Location(_uriConverter(item.uri), asRange(item.range));
}
function asReferences(values) {
if (is.undefined(values)) {
return undefined;
}
if (is.nil(values)) {
return null;
}
return values.map(asLocation);
}
function asDocumentHighlights(values) {
if (is.undefined(values)) {
return undefined;
}
if (is.nil(values)) {
return null;
}
return values.map(asDocumentHighlight);
}
function asDocumentHighlight(item) {
var result = new code.DocumentHighlight(asRange(item.range));
set(item.kind, function () { return result.kind = asDocumentHighlightKind(item.kind); });
return result;
}
function asDocumentHighlightKind(item) {
switch (item) {
case 1 /* Text */:
return code.DocumentHighlightKind.Text;
case 2 /* Read */:
return code.DocumentHighlightKind.Read;
case 3 /* Write */:
return code.DocumentHighlightKind.Write;
}
return code.DocumentHighlightKind.Text;
}
function asSymbolInformations(values, uri) {
if (is.undefined(values)) {
return undefined;
}
if (is.nil(values)) {
return null;
}
return values.map(function (information) { return asSymbolInformation(information, uri); });
}
function asSymbolInformation(item, uri) {
// Symbol kind is one based in the protocol and zero based in code.
var result = new code.SymbolInformation(item.name, item.kind - 1, asRange(item.location.range), item.location.uri ? _uriConverter(item.location.uri) : uri);
set(item.containerName, function () { return result.containerName = item.containerName; });
return result;
}
function asCommand(item) {
var result = { title: item.title, command: item.command };
set(item.arguments, function () { return result.arguments = item.arguments; });
return result;
}
function asCommands(items) {
if (is.undefined(items)) {
return undefined;
}
if (is.nil(items)) {
return null;
}
return items.map(asCommand);
}
function asCodeLens(item) {
var result = new protocolCodeLens_1.default(asRange(item.range));
if (is.defined(item.command))
result.command = asCommand(item.command);
if (is.defined(item.data))
result.data = item.data;
return result;
}
function asCodeLenses(items) {
if (is.undefined(items)) {
return undefined;
}
if (is.nil(items)) {
return null;
}
return items.map(asCodeLens);
}
function asWorkspaceEdit(item) {
if (is.undefined(item)) {
return undefined;
}
if (is.nil(item)) {
return null;
}
var result = new code.WorkspaceEdit();
var keys = Object.keys(item.changes);
keys.forEach(function (key) { return result.set(_uriConverter(key), asTextEdits(item.changes[key])); });
return result;
}
function asDocumentLink(item) {
var range = asRange(item.range);
var target = is.defined(item.target) && asUri(item.target);
return new code.DocumentLink(range, target);
}
function asDocumentLinks(items) {
if (is.undefined(items)) {
return undefined;
}
if (is.nil(items)) {
return null;
}
return items.map(asDocumentLink);
}
return {
asUri: asUri,
asDiagnostics: asDiagnostics,
asDiagnostic: asDiagnostic,
asRange: asRange,
asPosition: asPosition,
asDiagnosticSeverity: asDiagnosticSeverity,
asHover: asHover,
asCompletionResult: asCompletionResult,
asCompletionItem: asCompletionItem,
asTextEdit: asTextEdit,
asTextEdits: asTextEdits,
asSignatureHelp: asSignatureHelp,
asSignatureInformations: asSignatureInformations,
asSignatureInformation: asSignatureInformation,
asParameterInformations: asParameterInformations,
asParameterInformation: asParameterInformation,
asDefinitionResult: asDefinitionResult,
asLocation: asLocation,
asReferences: asReferences,
asDocumentHighlights: asDocumentHighlights,
asDocumentHighlight: asDocumentHighlight,
asDocumentHighlightKind: asDocumentHighlightKind,
asSymbolInformations: asSymbolInformations,
asSymbolInformation: asSymbolInformation,
asCommand: asCommand,
asCommands: asCommands,
asCodeLens: asCodeLens,
asCodeLenses: asCodeLenses,
asWorkspaceEdit: asWorkspaceEdit,
asDocumentLink: asDocumentLink,
asDocumentLinks: asDocumentLinks
};
}
exports.createConverter = createConverter;
// This for backward compatibility since we exported the converter functions as API.
var defaultConverter = createConverter();
exports.asDiagnostics = defaultConverter.asDiagnostics;
exports.asDiagnostic = defaultConverter.asDiagnostic;
exports.asRange = defaultConverter.asRange;
exports.asPosition = defaultConverter.asPosition;
exports.asDiagnosticSeverity = defaultConverter.asDiagnosticSeverity;
exports.asHover = defaultConverter.asHover;
exports.asCompletionResult = defaultConverter.asCompletionResult;
exports.asCompletionItem = defaultConverter.asCompletionItem;
exports.asTextEdit = defaultConverter.asTextEdit;
exports.asTextEdits = defaultConverter.asTextEdits;
exports.asSignatureHelp = defaultConverter.asSignatureHelp;
exports.asSignatureInformations = defaultConverter.asSignatureInformations;
exports.asSignatureInformation = defaultConverter.asSignatureInformation;
exports.asParameterInformations = defaultConverter.asParameterInformations;
exports.asParameterInformation = defaultConverter.asParameterInformation;
exports.asDefinitionResult = defaultConverter.asDefinitionResult;
exports.asLocation = defaultConverter.asLocation;
exports.asReferences = defaultConverter.asReferences;
exports.asDocumentHighlights = defaultConverter.asDocumentHighlights;
exports.asDocumentHighlight = defaultConverter.asDocumentHighlight;
exports.asDocumentHighlightKind = defaultConverter.asDocumentHighlightKind;
exports.asSymbolInformations = defaultConverter.asSymbolInformations;
exports.asSymbolInformation = defaultConverter.asSymbolInformation;
exports.asCommand = defaultConverter.asCommand;
exports.asCommands = defaultConverter.asCommands;
exports.asCodeLens = defaultConverter.asCodeLens;
exports.asCodeLenses = defaultConverter.asCodeLenses;
exports.asWorkspaceEdit = defaultConverter.asWorkspaceEdit;
exports.asDocumentLink = defaultConverter.asDocumentLink;
exports.asDocumentLinks = defaultConverter.asDocumentLinks;

View File

@ -1,16 +0,0 @@
export interface ITask<T> {
(): T;
}
export declare class Delayer<T> {
defaultDelay: number;
private timeout;
private completionPromise;
private onSuccess;
private task;
constructor(defaultDelay: number);
trigger(task: ITask<T>, delay?: number): Promise<T>;
forceDelivery(): T;
isTriggered(): boolean;
cancel(): void;
private cancelTimeout();
}

View File

@ -1,66 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var Delayer = (function () {
function Delayer(defaultDelay) {
this.defaultDelay = defaultDelay;
this.timeout = null;
this.completionPromise = null;
this.onSuccess = null;
this.task = null;
}
Delayer.prototype.trigger = function (task, delay) {
var _this = this;
if (delay === void 0) { delay = this.defaultDelay; }
this.task = task;
if (delay >= 0) {
this.cancelTimeout();
}
if (!this.completionPromise) {
this.completionPromise = new Promise(function (resolve) {
_this.onSuccess = resolve;
}).then(function () {
_this.completionPromise = null;
_this.onSuccess = null;
var result = _this.task();
_this.task = null;
return result;
});
}
if (delay >= 0 || this.timeout === null) {
this.timeout = setTimeout(function () {
_this.timeout = null;
_this.onSuccess(null);
}, delay >= 0 ? delay : this.defaultDelay);
}
return this.completionPromise;
};
Delayer.prototype.forceDelivery = function () {
if (!this.completionPromise) {
return null;
}
this.cancelTimeout();
var result = this.task();
this.completionPromise = null;
this.onSuccess = null;
this.task = null;
return result;
};
Delayer.prototype.isTriggered = function () {
return this.timeout !== null;
};
Delayer.prototype.cancel = function () {
this.cancelTimeout();
this.completionPromise = null;
};
Delayer.prototype.cancelTimeout = function () {
if (this.timeout !== null) {
clearTimeout(this.timeout);
this.timeout = null;
}
};
return Delayer;
}());
exports.Delayer = Delayer;

View File

@ -1,8 +0,0 @@
import cp = require('child_process');
export interface IForkOptions {
cwd?: string;
env?: any;
encoding?: string;
execArgv?: string[];
}
export declare function fork(modulePath: string, args: string[], options: IForkOptions, callback: (error: any, cp: cp.ChildProcess) => void): void;

View File

@ -1,96 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var path = require('path');
var os = require('os');
var net = require('net');
var cp = require('child_process');
function makeRandomHexString(length) {
var chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
var result = '';
for (var i = 0; i < length; i++) {
var idx = Math.floor(chars.length * Math.random());
result += chars[idx];
}
return result;
}
function generatePipeName() {
var randomName = 'vscode-' + makeRandomHexString(40);
if (process.platform === 'win32') {
return '\\\\.\\pipe\\' + randomName + '-sock';
}
// Mac/Unix: use socket file
return path.join(os.tmpdir(), randomName + '.sock');
}
function generatePatchedEnv(env, stdInPipeName, stdOutPipeName) {
// Set the two unique pipe names and the electron flag as process env
var newEnv = {};
for (var key in env) {
newEnv[key] = env[key];
}
newEnv['STDIN_PIPE_NAME'] = stdInPipeName;
newEnv['STDOUT_PIPE_NAME'] = stdOutPipeName;
newEnv['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1';
return newEnv;
}
function fork(modulePath, args, options, callback) {
var callbackCalled = false;
var resolve = function (result) {
if (callbackCalled) {
return;
}
callbackCalled = true;
callback(null, result);
};
var reject = function (err) {
if (callbackCalled) {
return;
}
callbackCalled = true;
callback(err, null);
};
// Generate two unique pipe names
var stdInPipeName = generatePipeName();
var stdOutPipeName = generatePipeName();
var newEnv = generatePatchedEnv(options.env || process.env, stdInPipeName, stdOutPipeName);
var childProcess;
// Begin listening to stdout pipe
var server = net.createServer(function (stream) {
// The child process will write exactly one chunk with content `ready` when it has installed a listener to the stdin pipe
stream.once('data', function (chunk) {
// The child process is sending me the `ready` chunk, time to connect to the stdin pipe
childProcess.stdin = net.connect(stdInPipeName);
// From now on the childProcess.stdout is available for reading
childProcess.stdout = stream;
resolve(childProcess);
});
});
server.listen(stdOutPipeName);
var serverClosed = false;
var closeServer = function () {
if (serverClosed) {
return;
}
serverClosed = true;
server.close();
};
// Create the process
var bootstrapperPath = path.join(__dirname, 'electronForkStart');
childProcess = cp.fork(bootstrapperPath, [modulePath].concat(args), {
silent: true,
cwd: options.cwd,
env: newEnv,
execArgv: options.execArgv
});
childProcess.once('error', function (err) {
closeServer();
reject(err);
});
childProcess.once('exit', function (err) {
closeServer();
reject(err);
});
}
exports.fork = fork;

View File

@ -1,5 +0,0 @@
declare var net: any, fs: any, stream: any, util: any;
declare var ENABLE_LOGGING: boolean;
declare var log: (str: any) => void;
declare var stdInPipeName: any;
declare var stdOutPipeName: any;

View File

@ -1,146 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
var net = require('net'), fs = require('fs'), stream = require('stream'), util = require('util');
var ENABLE_LOGGING = false;
var log = (function () {
if (!ENABLE_LOGGING) {
return function () { };
}
var isFirst = true;
var LOG_LOCATION = 'C:\\stdFork.log';
return function log(str) {
if (isFirst) {
isFirst = false;
fs.writeFileSync(LOG_LOCATION, str + '\n');
return;
}
fs.appendFileSync(LOG_LOCATION, str + '\n');
};
})();
var stdInPipeName = process.env['STDIN_PIPE_NAME'];
var stdOutPipeName = process.env['STDOUT_PIPE_NAME'];
log('STDIN_PIPE_NAME: ' + stdInPipeName);
log('STDOUT_PIPE_NAME: ' + stdOutPipeName);
log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE']);
// stdout redirection to named pipe
(function () {
log('Beginning stdout redirection...');
// Create a writing stream to the stdout pipe
var stdOutStream = net.connect(stdOutPipeName);
// unref stdOutStream to behave like a normal standard out
stdOutStream.unref();
// handle process.stdout
process.__defineGetter__('stdout', function () { return stdOutStream; });
// handle process.stderr
process.__defineGetter__('stderr', function () { return stdOutStream; });
var fsWriteSyncString = function (fd, str, position, encoding) {
// fs.writeSync(fd, string[, position[, encoding]]);
var buf = new Buffer(str, encoding || 'utf8');
return fsWriteSyncBuffer(fd, buf, 0, buf.length);
};
var fsWriteSyncBuffer = function (fd, buffer, off, len) {
off = Math.abs(off | 0);
len = Math.abs(len | 0);
// fs.writeSync(fd, buffer, offset, length[, position]);
var buffer_length = buffer.length;
if (off > buffer_length) {
throw new Error('offset out of bounds');
}
if (len > buffer_length) {
throw new Error('length out of bounds');
}
if (((off + len) | 0) < off) {
throw new Error('off + len overflow');
}
if (buffer_length - off < len) {
// Asking for more than is left over in the buffer
throw new Error('off + len > buffer.length');
}
var slicedBuffer = buffer;
if (off !== 0 || len !== buffer_length) {
slicedBuffer = buffer.slice(off, off + len);
}
stdOutStream.write(slicedBuffer);
return slicedBuffer.length;
};
// handle fs.writeSync(1, ...)
var originalWriteSync = fs.writeSync;
fs.writeSync = function (fd, data, position, encoding) {
if (fd !== 1) {
return originalWriteSync.apply(fs, arguments);
}
// usage:
// fs.writeSync(fd, buffer, offset, length[, position]);
// OR
// fs.writeSync(fd, string[, position[, encoding]]);
if (data instanceof Buffer) {
return fsWriteSyncBuffer.apply(null, arguments);
}
// For compatibility reasons with fs.writeSync, writing null will write "null", etc
if (typeof data !== 'string') {
data += '';
}
return fsWriteSyncString.apply(null, arguments);
};
log('Finished defining process.stdout, process.stderr and fs.writeSync');
})();
// stdin redirection to named pipe
(function () {
// Begin listening to stdin pipe
var server = net.createServer(function (stream) {
// Stop accepting new connections, keep the existing one alive
server.close();
log('Parent process has connected to my stdin. All should be good now.');
// handle process.stdin
process.__defineGetter__('stdin', function () {
return stream;
});
// Remove myself from process.argv
process.argv.splice(1, 1);
// Load the actual program
var program = process.argv[1];
log('Loading program: ' + program);
// Unset the custom environmental variables that should not get inherited
delete process.env['STDIN_PIPE_NAME'];
delete process.env['STDOUT_PIPE_NAME'];
delete process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];
require(program);
log('Finished loading program.');
var stdinIsReferenced = true;
var timer = setInterval(function () {
var listenerCount = (stream.listeners('data').length +
stream.listeners('end').length +
stream.listeners('close').length +
stream.listeners('error').length);
// log('listenerCount: ' + listenerCount);
if (listenerCount <= 1) {
// No more "actual" listeners, only internal node
if (stdinIsReferenced) {
stdinIsReferenced = false;
// log('unreferencing stream!!!');
stream.unref();
}
}
else {
// There are "actual" listeners
if (!stdinIsReferenced) {
stdinIsReferenced = true;
stream.ref();
}
}
// log(
// '' + stream.listeners('data').length +
// ' ' + stream.listeners('end').length +
// ' ' + stream.listeners('close').length +
// ' ' + stream.listeners('error').length
// );
}, 1000);
timer.unref();
});
server.listen(stdInPipeName, function () {
// signal via stdout that the parent process can now begin writing to stdin pipe
process.stdout.write('ready');
});
})();

View File

@ -1,12 +0,0 @@
export declare function defined(value: any): boolean;
export declare function undefined(value: any): boolean;
export declare function nil(value: any): boolean;
export declare function boolean(value: any): value is boolean;
export declare function string(value: any): value is string;
export declare function number(value: any): value is number;
export declare function error(value: any): value is Error;
export declare function func(value: any): value is Function;
export declare function array<T>(value: any): value is T[];
export declare function stringArray(value: any): value is string[];
export declare function typedArray<T>(value: any, check: (value: any) => boolean): value is T[];
export declare function thenable<T>(value: any): value is Thenable<T>;

View File

@ -1,54 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var toString = Object.prototype.toString;
function defined(value) {
return typeof value !== 'undefined';
}
exports.defined = defined;
function undefined(value) {
return typeof value === 'undefined';
}
exports.undefined = undefined;
function nil(value) {
return value === null;
}
exports.nil = nil;
function boolean(value) {
return value === true || value === false;
}
exports.boolean = boolean;
function string(value) {
return toString.call(value) === '[object String]';
}
exports.string = string;
function number(value) {
return toString.call(value) === '[object Number]';
}
exports.number = number;
function error(value) {
return toString.call(value) === '[object Error]';
}
exports.error = error;
function func(value) {
return toString.call(value) === '[object Function]';
}
exports.func = func;
function array(value) {
return Array.isArray(value);
}
exports.array = array;
function stringArray(value) {
return array(value) && value.every(function (elem) { return string(elem); });
}
exports.stringArray = stringArray;
function typedArray(value, check) {
return Array.isArray(value) && value.every(check);
}
exports.typedArray = typedArray;
function thenable(value) {
return value && func(value.then);
}
exports.thenable = thenable;

View File

@ -1,3 +0,0 @@
import * as cp from 'child_process';
import ChildProcess = cp.ChildProcess;
export declare function terminate(process: ChildProcess, cwd?: string): boolean;

View File

@ -1,45 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var cp = require('child_process');
var path_1 = require('path');
var isWindows = (process.platform === 'win32');
var isMacintosh = (process.platform === 'darwin');
var isLinux = (process.platform === 'linux');
function terminate(process, cwd) {
if (isWindows) {
try {
// This we run in Atom execFileSync is available.
// Ignore stderr since this is otherwise piped to parent.stderr
// which might be already closed.
var options = {
stdio: ['pipe', 'pipe', 'ignore']
};
if (cwd) {
options.cwd = cwd;
}
cp.execFileSync('taskkill', ['/T', '/F', '/PID', process.pid.toString()], options);
return true;
}
catch (err) {
return false;
}
}
else if (isLinux || isMacintosh) {
try {
var cmd = path_1.join(__dirname, 'terminateProcess.sh');
var result = cp.spawnSync(cmd, [process.pid.toString()]);
return result.error ? false : true;
}
catch (err) {
return false;
}
}
else {
process.kill('SIGKILL');
return true;
}
}
exports.terminate = terminate;

View File

@ -1,64 +0,0 @@
{
"_args": [
[
"vscode-languageclient@2.6.3",
"D:\\repo\\better-toml"
]
],
"_from": "vscode-languageclient@2.6.3",
"_id": "vscode-languageclient@2.6.3",
"_inBundle": false,
"_integrity": "sha1-mjX1lVRkWI2WaJUxP1FkzpsYTz8=",
"_location": "/vscode-languageclient",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "vscode-languageclient@2.6.3",
"name": "vscode-languageclient",
"escapedName": "vscode-languageclient",
"rawSpec": "2.6.3",
"saveSpec": null,
"fetchSpec": "2.6.3"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-2.6.3.tgz",
"_spec": "2.6.3",
"_where": "D:\\repo\\better-toml",
"author": {
"name": "Microsoft Corporation"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-languageserver-node/issues"
},
"dependencies": {
"vscode-jsonrpc": "^2.4.0",
"vscode-languageserver-types": "^1.0.4"
},
"description": "VSCode Language client implementation",
"devDependencies": {
"typescript": "^1.8.10",
"vscode": "^0.11.10"
},
"engines": {
"vscode": "^1.5.0"
},
"homepage": "https://github.com/Microsoft/vscode-languageserver-node#readme",
"license": "MIT",
"main": "./lib/main.js",
"name": "vscode-languageclient",
"repository": {
"type": "git",
"url": "git+https://github.com/Microsoft/vscode-languageserver-node.git"
},
"scripts": {
"compile": "tsc -p ./src",
"prepublish": "node ./node_modules/vscode/bin/install && tsc -p ./src",
"update-vscode": "node ./node_modules/vscode/bin/install",
"watch": "tsc -w -p ./src"
},
"typings": "./lib/main",
"version": "2.6.3"
}

View File

@ -1,31 +0,0 @@
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
For Microsoft vscode-languageclient
This project incorporates material from the project(s) listed below (collectively, “Third Party Code”).
Microsoft is not the original author of the Third Party Code. The original copyright notice and license
under which Microsoft received such Third Party Code are set out below. This Third Party Code is licensed
to you under their original license terms set forth below. Microsoft reserves all other rights not expressly
granted, whether by implication, estoppel or otherwise.
1. DefinitelyTyped version 0.0.1 (https://github.com/borisyankov/DefinitelyTyped)
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,9 +0,0 @@
.vscode/
lib/test/
lib/*.map
src/
test/
.eslintrc
.gitignore
gulpfile.js
tsd.json

View File

@ -1,11 +0,0 @@
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,10 +0,0 @@
# VSCode Language Server
[![NPM Version](https://img.shields.io/npm/v/vscode-languageserver-types.svg)](https://npmjs.org/package/vscode-languageserver-types)
[![NPM Downloads](https://img.shields.io/npm/dm/vscode-languageserver-types.svg)](https://npmjs.org/package/vscode-languageserver-types)
[![Build Status](https://travis-ci.org/Microsoft/vscode-languageserver-types-node.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-languageserver-types-node)
Npm module containing the types used by the VSCode language client and [Node.js](https://nodejs.org/) language server
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/).

View File

@ -1,965 +0,0 @@
/**
* Position in a text document expressed as zero-based line and character offset.
*/
export interface Position {
/**
* Line position in a document (zero-based).
*/
line: number;
/**
* Character offset on a line in a document (zero-based).
*/
character: number;
}
/**
* The Position namespace provides helper functions to work with
* [Position](#Position) literals.
*/
export declare namespace Position {
/**
* Creates a new Position literal from the given line and character.
* @param line The position's line.
* @param character The position's character.
*/
function create(line: number, character: number): Position;
/**
* Checks whether the given liternal conforms to the [Position](#Position) interface.
*/
function is(value: any): value is Position;
}
/**
* A range in a text document expressed as (zero-based) start and end positions.
*/
export interface Range {
/**
* The range's start position
*/
start: Position;
/**
* The range's end position
*/
end: Position;
}
/**
* The Range namespace provides helper functions to work with
* [Range](#Range) literals.
*/
export declare namespace Range {
/**
* Create a new Range liternal.
* @param start The range's start position.
* @param end The range's end position.
*/
function create(start: Position, end: Position): Range;
/**
* Create a new Range liternal.
* @param startLine The start line number.
* @param startCharacter The start character.
* @param endLine The end line number.
* @param endCharacter The end character.
*/
function create(startLine: number, startCharacter: number, endLine: number, endCharacter: number): Range;
/**
* Checks whether the given literal conforms to the [Range](#Range) interface.
*/
function is(value: any): value is Range;
}
/**
* Represents a location inside a resource, such as a line
* inside a text file.
*/
export interface Location {
uri: string;
range: Range;
}
/**
* The Location namespace provides helper functions to work with
* [Location](#Location) literals.
*/
export declare namespace Location {
/**
* Creates a Location literal.
* @param uri The location's uri.
* @param range The location's range.
*/
function create(uri: string, range: Range): Location;
/**
* Checks whether the given literal conforms to the [Location](#Location) interface.
*/
function is(value: any): value is Location;
}
/**
* The diagnostic's serverity.
*/
export declare const enum DiagnosticSeverity {
/**
* Reports an error.
*/
Error = 1,
/**
* Reports a warning.
*/
Warning = 2,
/**
* Reports an information.
*/
Information = 3,
/**
* Reports a hint.
*/
Hint = 4,
}
/**
* Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
* are only valid in the scope of a resource.
*/
export interface Diagnostic {
/**
* The range at which the message applies
*/
range: Range;
/**
* The diagnostic's severity. Can be omitted. If omitted it is up to the
* client to interpret diagnostics as error, warning, info or hint.
*/
severity?: number;
/**
* The diagnostic's code. Can be omitted.
*/
code?: number | string;
/**
* A human-readable string describing the source of this
* diagnostic, e.g. 'typescript' or 'super lint'.
*/
source?: string;
/**
* The diagnostic's message.
*/
message: string;
}
/**
* The Diagnostic namespace provides helper functions to work with
* [Diagnostic](#Diagnostic) literals.
*/
export declare namespace Diagnostic {
/**
* Creates a new Diagnostic literal.
*/
function create(range: Range, message: string, severity?: number, code?: number | string, source?: string): Diagnostic;
/**
* Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
*/
function is(value: any): value is Diagnostic;
}
/**
* Represents a reference to a command. Provides a title which
* will be used to represent a command in the UI and, optionally,
* an array of arguments which will be passed to the command handler
* function when invoked.
*/
export interface Command {
/**
* Title of the command, like `save`.
*/
title: string;
/**
* The identifier of the actual command handler.
*/
command: string;
/**
* Arguments that the command handler should be
* invoked with.
*/
arguments?: any[];
}
/**
* The Command namespace provides helper functions to work with
* [Command](#Command) literals.
*/
export declare namespace Command {
/**
* Creates a new Command literal.
*/
function create(title: string, command: string, ...args: any[]): Command;
/**
* Checks whether the given literal conforms to the [Command](#Command) interface.
*/
function is(value: any): value is Command;
}
/**
* A text edit applicable to a text document.
*/
export interface TextEdit {
/**
* The range of the text document to be manipulated. To insert
* text into a document create a range where start === end.
*/
range: Range;
/**
* The string to be inserted. For delete operations use an
* empty string.
*/
newText: string;
}
/**
* The TextEdit namespace provides helper function to create replace,
* insert and delete edits more easily.
*/
export declare namespace TextEdit {
/**
* Creates a replace text edit.
* @param range The range of text to be replaced.
* @param newText The new text.
*/
function replace(range: Range, newText: string): TextEdit;
/**
* Creates a insert text edit.
* @param psotion The position to insert the text at.
* @param newText The text to be inserted.
*/
function insert(position: Position, newText: string): TextEdit;
/**
* Creates a delete text edit.
* @param range The range of text to be deleted.
*/
function del(range: Range): TextEdit;
}
/**
* A workspace edit represents changes to many resources managed
* in the workspace.
*/
export interface WorkspaceEdit {
/**
* Holds changes to existing resources.
*/
changes: {
[uri: string]: TextEdit[];
};
}
/**
* A change to capture text edits for existing resources.
*/
export interface TextEditChange {
/**
* Gets all text edits for this change.
*
* @return An array of text edits.
*/
all(): TextEdit[];
/**
* Clears the edits for this change.
*/
clear(): void;
/**
* Insert the given text at the given position.
*
* @param position A position.
* @param newText A string.
*/
insert(position: Position, newText: string): void;
/**
* Replace the given range with given text for the given resource.
*
* @param range A range.
* @param newText A string.
*/
replace(range: Range, newText: string): void;
/**
* Delete the text at the given range.
*
* @param range A range.
*/
delete(range: Range): void;
}
/**
* A workspace change helps constructing changes to a workspace.
*/
export declare class WorkspaceChange {
private workspaceEdit;
private textEditChanges;
constructor();
/**
* Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
* use to be returned from a workspace edit operation like rename.
*/
edit: WorkspaceEdit;
/**
* Returns the [TextEditChange](#TextEditChange) to manage text edits
* for resources.
*/
getTextEditChange(uri: string): TextEditChange;
}
/**
* A literal to identify a text document in the client.
*/
export interface TextDocumentIdentifier {
/**
* The text document's uri.
*/
uri: string;
}
/**
* The TextDocumentIdentifier namespace provides helper functions to work with
* [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
*/
export declare namespace TextDocumentIdentifier {
/**
* Creates a new TextDocumentIdentifier literal.
* @param uri The document's uri.
*/
function create(uri: string): TextDocumentIdentifier;
/**
* Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
*/
function is(value: any): value is TextDocumentIdentifier;
}
/**
* An identifier to denote a specific version of a text document.
*/
export interface VersionedTextDocumentIdentifier extends TextDocumentIdentifier {
/**
* The version number of this document.
*/
version: number;
}
/**
* The VersionedTextDocumentIdentifier namespace provides helper functions to work with
* [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
*/
export declare namespace VersionedTextDocumentIdentifier {
/**
* Creates a new VersionedTextDocumentIdentifier literal.
* @param uri The document's uri.
* @param uri The document's text.
*/
function create(uri: string, version: number): VersionedTextDocumentIdentifier;
/**
* Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
*/
function is(value: any): value is VersionedTextDocumentIdentifier;
}
/**
* An item to transfer a text document from the client to the
* server.
*/
export interface TextDocumentItem {
/**
* The text document's uri.
*/
uri: string;
/**
* The text document's language identifier
*/
languageId: string;
/**
* The version number of this document (it will strictly increase after each
* change, including undo/redo).
*/
version: number;
/**
* The content of the opened text document.
*/
text: string;
}
/**
* The TextDocumentItem namespace provides helper functions to work with
* [TextDocumentItem](#TextDocumentItem) literals.
*/
export declare namespace TextDocumentItem {
/**
* Creates a new TextDocumentItem literal.
* @param uri The document's uri.
* @param uri The document's language identifier.
* @param uri The document's version number.
* @param uri The document's text.
*/
function create(uri: string, languageId: string, version: number, text: string): TextDocumentItem;
/**
* Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
*/
function is(value: any): value is TextDocumentItem;
}
/**
* The kind of a completion entry.
*/
export declare const enum CompletionItemKind {
Text = 1,
Method = 2,
Function = 3,
Constructor = 4,
Field = 5,
Variable = 6,
Class = 7,
Interface = 8,
Module = 9,
Property = 10,
Unit = 11,
Value = 12,
Enum = 13,
Keyword = 14,
Snippet = 15,
Color = 16,
File = 17,
Reference = 18,
}
/**
* A completion item represents a text snippet that is
* proposed to complete text that is being typed.
*/
export interface CompletionItem {
/**
* The label of this completion item. By default
* also the text that is inserted when selecting
* this completion.
*/
label: string;
/**
* The kind of this completion item. Based of the kind
* an icon is chosen by the editor.
*/
kind?: number;
/**
* A human-readable string with additional information
* about this item, like type or symbol information.
*/
detail?: string;
/**
* A human-readable string that represents a doc-comment.
*/
documentation?: string;
/**
* A string that shoud be used when comparing this item
* with other items. When `falsy` the [label](#CompletionItem.label)
* is used.
*/
sortText?: string;
/**
* A string that should be used when filtering a set of
* completion items. When `falsy` the [label](#CompletionItem.label)
* is used.
*/
filterText?: string;
/**
* A string that should be inserted a document when selecting
* this completion. When `falsy` the [label](#CompletionItem.label)
* is used.
*/
insertText?: string;
/**
* An [edit](#TextEdit) which is applied to a document when selecting
* this completion. When an edit is provided the value of
* [insertText](#CompletionItem.insertText) is ignored.
*/
textEdit?: TextEdit;
/**
* An optional array of additional [text edits](#TextEdit) that are applied when
* selecting this completion. Edits must not overlap with the main [edit](#CompletionItem.textEdit)
* nor with themselves.
*/
additionalTextEdits?: TextEdit[];
/**
* An optional [command](#Command) that is executed *after* inserting this completion. *Note* that
* additional modifications to the current document should be described with the
* [additionalTextEdits](#CompletionItem.additionalTextEdits)-property.
*/
command?: Command;
/**
* An data entry field that is preserved on a completion item between
* a [CompletionRequest](#CompletionRequest) and a [CompletionResolveRequest]
* (#CompletionResolveRequest)
*/
data?: any;
}
/**
* The CompletionItem namespace provides functions to deal with
* completion items.
*/
export declare namespace CompletionItem {
/**
* Create a completion item and seed it with a label.
* @param label The completion item's label
*/
function create(label: string): CompletionItem;
}
/**
* Represents a collection of [completion items](#CompletionItem) to be presented
* in the editor.
*/
export interface CompletionList {
/**
* This list it not complete. Further typing should result in recomputing
* this list.
*/
isIncomplete: boolean;
/**
* The completion items.
*/
items: CompletionItem[];
}
/**
* The CompletionList namespace provides functions to deal with
* completion lists.
*/
export declare namespace CompletionList {
/**
* Creates a new completion list.
*
* @param items The completion items.
* @param isIncomplete The list is not complete.
*/
function create(items?: CompletionItem[], isIncomplete?: boolean): CompletionList;
}
/**
* MarkedString can be used to render human readable text. It is either a markdown string
* or a code-block that provides a language and a code snippet. Note that
* markdown strings will be sanitized - that means html will be escaped.
*/
export declare type MarkedString = string | {
language: string;
value: string;
};
export declare namespace MarkedString {
/**
* Creates a marked string from plain text.
*
* @param plainText The plain text.
*/
function fromPlainText(plainText: string): MarkedString;
}
/**
* The result of a hove request.
*/
export interface Hover {
/**
* The hover's content
*/
contents: MarkedString | MarkedString[];
/**
* An optional range
*/
range?: Range;
}
/**
* Represents a parameter of a callable-signature. A parameter can
* have a label and a doc-comment.
*/
export interface ParameterInformation {
/**
* The label of this signature. Will be shown in
* the UI.
*/
label: string;
/**
* The human-readable doc-comment of this signature. Will be shown
* in the UI but can be omitted.
*/
documentation?: string;
}
/**
* The ParameterInformation namespace provides helper functions to work with
* [ParameterInformation](#ParameterInformation) literals.
*/
export declare namespace ParameterInformation {
/**
* Creates a new parameter information literal.
*
* @param label A label string.
* @param documentation A doc string.
*/
function create(label: string, documentation?: string): ParameterInformation;
}
/**
* Represents the signature of something callable. A signature
* can have a label, like a function-name, a doc-comment, and
* a set of parameters.
*/
export interface SignatureInformation {
/**
* The label of this signature. Will be shown in
* the UI.
*/
label: string;
/**
* The human-readable doc-comment of this signature. Will be shown
* in the UI but can be omitted.
*/
documentation?: string;
/**
* The parameters of this signature.
*/
parameters?: ParameterInformation[];
}
/**
* The SignatureInformation namespace provides helper functions to work with
* [SignatureInformation](#SignatureInformation) literals.
*/
export declare namespace SignatureInformation {
function create(label: string, documentation?: string, ...parameters: ParameterInformation[]): SignatureInformation;
}
/**
* Signature help represents the signature of something
* callable. There can be multiple signature but only one
* active and only one active parameter.
*/
export interface SignatureHelp {
/**
* One or more signatures.
*/
signatures: SignatureInformation[];
/**
* The active signature.
*/
activeSignature?: number;
/**
* The active parameter of the active signature.
*/
activeParameter?: number;
}
/**
* The definition of a symbol represented as one or many [locations](#Location).
* For most programming languages there is only one location at which a symbol is
* defined.
*/
export declare type Definition = Location | Location[];
/**
* Value-object that contains additional information when
* requesting references.
*/
export interface ReferenceContext {
/**
* Include the declaration of the current symbol.
*/
includeDeclaration: boolean;
}
/**
* A document highlight kind.
*/
export declare const enum DocumentHighlightKind {
/**
* A textual occurrance.
*/
Text = 1,
/**
* Read-access of a symbol, like reading a variable.
*/
Read = 2,
/**
* Write-access of a symbol, like writing to a variable.
*/
Write = 3,
}
/**
* A document highlight is a range inside a text document which deserves
* special attention. Usually a document highlight is visualized by changing
* the background color of its range.
*/
export interface DocumentHighlight {
/**
* The range this highlight applies to.
*/
range: Range;
/**
* The highlight kind, default is [text](#DocumentHighlightKind.Text).
*/
kind?: number;
}
/**
* DocumentHighlight namespace to provide helper functions to work with
* [DocumentHighlight](#DocumentHighlight) literals.
*/
export declare namespace DocumentHighlight {
/**
* Create a DocumentHighlight object.
* @param range The range the highlight applies to.
*/
function create(range: Range, kind?: number): DocumentHighlight;
}
/**
* A symbol kind.
*/
export declare const enum SymbolKind {
File = 1,
Module = 2,
Namespace = 3,
Package = 4,
Class = 5,
Method = 6,
Property = 7,
Field = 8,
Constructor = 9,
Enum = 10,
Interface = 11,
Function = 12,
Variable = 13,
Constant = 14,
String = 15,
Number = 16,
Boolean = 17,
Array = 18,
}
/**
* Represents information about programming constructs like variables, classes,
* interfaces etc.
*/
export interface SymbolInformation {
/**
* The name of this symbol.
*/
name: string;
/**
* The kind of this symbol.
*/
kind: number;
/**
* The location of this symbol.
*/
location: Location;
/**
* The name of the symbol containing this symbol.
*/
containerName?: string;
}
export declare namespace SymbolInformation {
/**
* Creates a new symbol information literal.
*
* @param name The name of the symbol.
* @param kind The kind of the symbol.
* @param range The range of the location of the symbol.
* @param uri The resource of the location of symbol, defaults to the current document.
* @param containerName The name of the symbol containg the symbol.
*/
function create(name: string, kind: SymbolKind, range: Range, uri?: string, containerName?: string): SymbolInformation;
}
/**
* Parameters for a [DocumentSymbolRequest](#DocumentSymbolRequest).
*/
export interface DocumentSymbolParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
}
/**
* The parameters of a [WorkspaceSymbolRequest](#WorkspaceSymbolRequest).
*/
export interface WorkspaceSymbolParams {
/**
* A non-empty query string
*/
query: string;
}
/**
* Contains additional diagnostic information about the context in which
* a [code action](#CodeActionProvider.provideCodeActions) is run.
*/
export interface CodeActionContext {
/**
* An array of diagnostics.
*/
diagnostics: Diagnostic[];
}
/**
* The CodeActionContext namespace provides helper functions to work with
* [CodeActionContext](#CodeActionContext) literals.
*/
export declare namespace CodeActionContext {
/**
* Creates a new CodeActionContext literal.
*/
function create(diagnostics: Diagnostic[]): CodeActionContext;
/**
* Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
*/
function is(value: any): value is CodeActionContext;
}
/**
* A code lens represents a [command](#Command) that should be shown along with
* source text, like the number of references, a way to run tests, etc.
*
* A code lens is _unresolved_ when no command is associated to it. For performance
* reasons the creation of a code lens and resolving should be done to two stages.
*/
export interface CodeLens {
/**
* The range in which this code lens is valid. Should only span a single line.
*/
range: Range;
/**
* The command this code lens represents.
*/
command?: Command;
/**
* An data entry field that is preserved on a code lens item between
* a [CodeLensRequest](#CodeLensRequest) and a [CodeLensResolveRequest]
* (#CodeLensResolveRequest)
*/
data?: any;
}
/**
* The CodeLens namespace provides helper functions to work with
* [CodeLens](#CodeLens) literals.
*/
export declare namespace CodeLens {
/**
* Creates a new CodeLens literal.
*/
function create(range: Range, data?: any): CodeLens;
/**
* Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
*/
function is(value: any): value is CodeLens;
}
/**
* Value-object describing what options formatting should use.
*/
export interface FormattingOptions {
/**
* Size of a tab in spaces.
*/
tabSize: number;
/**
* Prefer spaces over tabs.
*/
insertSpaces: boolean;
/**
* Signature for further properties.
*/
[key: string]: boolean | number | string;
}
/**
* The FormattingOptions namespace provides helper functions to work with
* [FormattingOptions](#FormattingOptions) literals.
*/
export declare namespace FormattingOptions {
/**
* Creates a new FormattingOptions literal.
*/
function create(tabSize: number, insertSpaces: boolean): FormattingOptions;
/**
* Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
*/
function is(value: any): value is FormattingOptions;
}
/**
* A document link is a range in a text document that links to an internal or external resource, like another
* text document or a web site.
*/
export declare class DocumentLink {
/**
* The range this link applies to.
*/
range: Range;
/**
* The uri this link points to.
*/
target: string;
}
/**
* The DocumentLink namespace provides helper functions to work with
* [DocumentLink](#DocumentLink) literals.
*/
export declare namespace DocumentLink {
/**
* Creates a new DocumentLink literal.
*/
function create(range: Range, target?: string): DocumentLink;
/**
* Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
*/
function is(value: any): value is DocumentLink;
}
/**
* A simple text document. Not to be implemenented.
*/
export interface TextDocument {
/**
* The associated URI for this document. Most documents have the __file__-scheme, indicating that they
* represent files on disk. However, some documents may have other schemes indicating that they are not
* available on disk.
*
* @readonly
*/
uri: string;
/**
* The identifier of the language associated with this document.
*
* @readonly
*/
languageId: string;
/**
* The version number of this document (it will strictly increase after each
* change, including undo/redo).
*
* @readonly
*/
version: number;
/**
* Get the text of this document.
*
* @return The text of this document.
*/
getText(): string;
/**
* Converts a zero-based offset to a position.
*
* @param offset A zero-based offset.
* @return A valid [position](#Position).
*/
positionAt(offset: number): Position;
/**
* Converts the position to a zero-based offset.
*
* The position will be [adjusted](#TextDocument.validatePosition).
*
* @param position A position.
* @return A valid zero-based offset.
*/
offsetAt(position: Position): number;
/**
* The number of lines in this document.
*
* @readonly
*/
lineCount: number;
}
export declare namespace TextDocument {
/**
* Creates a new ITextDocument literal from the given uri and content.
* @param uri The document's uri.
* @param languageId The document's language Id.
* @param content The document's content.
*/
function create(uri: string, languageId: string, version: number, content: string): TextDocument;
/**
* Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
*/
function is(value: any): value is TextDocument;
}
/**
* Event to signal changes to a simple text document.
*/
export interface TextDocumentChangeEvent {
/**
* The document that has changed.
*/
document: TextDocument;
}
/**
* An event describing a change to a text document. If range and rangeLength are omitted
* the new text is considered to be the full content of the document.
*/
export interface TextDocumentContentChangeEvent {
/**
* The range of the document that changed.
*/
range?: Range;
/**
* The length of the range that got replaced.
*/
rangeLength?: number;
/**
* The new text of the document.
*/
text: string;
}

View File

@ -1,708 +0,0 @@
(function (factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
/**
* The Position namespace provides helper functions to work with
* [Position](#Position) literals.
*/
var Position;
(function (Position) {
/**
* Creates a new Position literal from the given line and character.
* @param line The position's line.
* @param character The position's character.
*/
function create(line, character) {
return { line: line, character: character };
}
Position.create = create;
/**
* Checks whether the given liternal conforms to the [Position](#Position) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
}
Position.is = is;
})(Position = exports.Position || (exports.Position = {}));
/**
* The Range namespace provides helper functions to work with
* [Range](#Range) literals.
*/
var Range;
(function (Range) {
function create(one, two, three, four) {
if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
return { start: Position.create(one, two), end: Position.create(three, four) };
}
else if (Position.is(one) && Position.is(two)) {
return { start: one, end: two };
}
else {
throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
}
}
Range.create = create;
/**
* Checks whether the given literal conforms to the [Range](#Range) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
}
Range.is = is;
})(Range = exports.Range || (exports.Range = {}));
/**
* The Location namespace provides helper functions to work with
* [Location](#Location) literals.
*/
var Location;
(function (Location) {
/**
* Creates a Location literal.
* @param uri The location's uri.
* @param range The location's range.
*/
function create(uri, range) {
return { uri: uri, range: range };
}
Location.create = create;
/**
* Checks whether the given literal conforms to the [Location](#Location) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
}
Location.is = is;
})(Location = exports.Location || (exports.Location = {}));
/**
* The Diagnostic namespace provides helper functions to work with
* [Diagnostic](#Diagnostic) literals.
*/
var Diagnostic;
(function (Diagnostic) {
/**
* Creates a new Diagnostic literal.
*/
function create(range, message, severity, code, source) {
var result = { range: range, message: message };
if (Is.defined(severity)) {
result.severity = severity;
}
if (Is.defined(code)) {
result.code = code;
}
if (Is.defined(source)) {
result.source = source;
}
return result;
}
Diagnostic.create = create;
/**
* Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate)
&& Range.is(candidate.range)
&& Is.string(candidate.message)
&& (Is.number(candidate.severity) || Is.undefined(candidate.severity))
&& (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
&& (Is.string(candidate.source) || Is.undefined(candidate.source));
}
Diagnostic.is = is;
})(Diagnostic = exports.Diagnostic || (exports.Diagnostic = {}));
/**
* The Command namespace provides helper functions to work with
* [Command](#Command) literals.
*/
var Command;
(function (Command) {
/**
* Creates a new Command literal.
*/
function create(title, command) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
var result = { title: title, command: command };
if (Is.defined(args) && args.length > 0) {
result.arguments = args;
}
return result;
}
Command.create = create;
/**
* Checks whether the given literal conforms to the [Command](#Command) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.title);
}
Command.is = is;
})(Command = exports.Command || (exports.Command = {}));
/**
* The TextEdit namespace provides helper function to create replace,
* insert and delete edits more easily.
*/
var TextEdit;
(function (TextEdit) {
/**
* Creates a replace text edit.
* @param range The range of text to be replaced.
* @param newText The new text.
*/
function replace(range, newText) {
return { range: range, newText: newText };
}
TextEdit.replace = replace;
/**
* Creates a insert text edit.
* @param psotion The position to insert the text at.
* @param newText The text to be inserted.
*/
function insert(position, newText) {
return { range: { start: position, end: position }, newText: newText };
}
TextEdit.insert = insert;
/**
* Creates a delete text edit.
* @param range The range of text to be deleted.
*/
function del(range) {
return { range: range, newText: '' };
}
TextEdit.del = del;
})(TextEdit = exports.TextEdit || (exports.TextEdit = {}));
/**
* A workspace change helps constructing changes to a workspace.
*/
var WorkspaceChange = (function () {
function WorkspaceChange() {
this.workspaceEdit = {
changes: Object.create(null)
};
this.textEditChanges = Object.create(null);
}
Object.defineProperty(WorkspaceChange.prototype, "edit", {
/**
* Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
* use to be returned from a workspace edit operation like rename.
*/
get: function () {
return this.workspaceEdit;
},
enumerable: true,
configurable: true
});
/**
* Returns the [TextEditChange](#TextEditChange) to manage text edits
* for resources.
*/
WorkspaceChange.prototype.getTextEditChange = function (uri) {
var TextEditChangeImpl = (function () {
function TextEditChangeImpl(edits) {
this.edits = edits;
}
TextEditChangeImpl.prototype.insert = function (position, newText) {
this.edits.push(TextEdit.insert(position, newText));
};
TextEditChangeImpl.prototype.replace = function (range, newText) {
this.edits.push(TextEdit.replace(range, newText));
};
TextEditChangeImpl.prototype.delete = function (range) {
this.edits.push(TextEdit.del(range));
};
TextEditChangeImpl.prototype.all = function () {
return this.edits;
};
TextEditChangeImpl.prototype.clear = function () {
this.edits.splice(0, this.edits.length);
};
return TextEditChangeImpl;
}());
var result = this.textEditChanges[uri];
if (!result) {
var edits = [];
this.workspaceEdit.changes[uri] = edits;
result = new TextEditChangeImpl(edits);
this.textEditChanges[uri] = result;
}
return result;
};
return WorkspaceChange;
}());
exports.WorkspaceChange = WorkspaceChange;
/**
* The TextDocumentIdentifier namespace provides helper functions to work with
* [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
*/
var TextDocumentIdentifier;
(function (TextDocumentIdentifier) {
/**
* Creates a new TextDocumentIdentifier literal.
* @param uri The document's uri.
*/
function create(uri) {
return { uri: uri };
}
TextDocumentIdentifier.create = create;
/**
* Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Is.string(candidate.uri);
}
TextDocumentIdentifier.is = is;
})(TextDocumentIdentifier = exports.TextDocumentIdentifier || (exports.TextDocumentIdentifier = {}));
/**
* The VersionedTextDocumentIdentifier namespace provides helper functions to work with
* [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
*/
var VersionedTextDocumentIdentifier;
(function (VersionedTextDocumentIdentifier) {
/**
* Creates a new VersionedTextDocumentIdentifier literal.
* @param uri The document's uri.
* @param uri The document's text.
*/
function create(uri, version) {
return { uri: uri, version: version };
}
VersionedTextDocumentIdentifier.create = create;
/**
* Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Is.string(candidate.uri) && Is.number(candidate.version);
}
VersionedTextDocumentIdentifier.is = is;
})(VersionedTextDocumentIdentifier = exports.VersionedTextDocumentIdentifier || (exports.VersionedTextDocumentIdentifier = {}));
/**
* The TextDocumentItem namespace provides helper functions to work with
* [TextDocumentItem](#TextDocumentItem) literals.
*/
var TextDocumentItem;
(function (TextDocumentItem) {
/**
* Creates a new TextDocumentItem literal.
* @param uri The document's uri.
* @param uri The document's language identifier.
* @param uri The document's version number.
* @param uri The document's text.
*/
function create(uri, languageId, version, text) {
return { uri: uri, languageId: languageId, version: version, text: text };
}
TextDocumentItem.create = create;
/**
* Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
}
TextDocumentItem.is = is;
})(TextDocumentItem = exports.TextDocumentItem || (exports.TextDocumentItem = {}));
/**
* The CompletionItem namespace provides functions to deal with
* completion items.
*/
var CompletionItem;
(function (CompletionItem) {
/**
* Create a completion item and seed it with a label.
* @param label The completion item's label
*/
function create(label) {
return { label: label };
}
CompletionItem.create = create;
})(CompletionItem = exports.CompletionItem || (exports.CompletionItem = {}));
/**
* The CompletionList namespace provides functions to deal with
* completion lists.
*/
var CompletionList;
(function (CompletionList) {
/**
* Creates a new completion list.
*
* @param items The completion items.
* @param isIncomplete The list is not complete.
*/
function create(items, isIncomplete) {
return { items: items ? items : [], isIncomplete: !!isIncomplete };
}
CompletionList.create = create;
})(CompletionList = exports.CompletionList || (exports.CompletionList = {}));
var MarkedString;
(function (MarkedString) {
/**
* Creates a marked string from plain text.
*
* @param plainText The plain text.
*/
function fromPlainText(plainText) {
return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
}
MarkedString.fromPlainText = fromPlainText;
})(MarkedString = exports.MarkedString || (exports.MarkedString = {}));
/**
* The ParameterInformation namespace provides helper functions to work with
* [ParameterInformation](#ParameterInformation) literals.
*/
var ParameterInformation;
(function (ParameterInformation) {
/**
* Creates a new parameter information literal.
*
* @param label A label string.
* @param documentation A doc string.
*/
function create(label, documentation) {
return documentation ? { label: label, documentation: documentation } : { label: label };
}
ParameterInformation.create = create;
;
})(ParameterInformation = exports.ParameterInformation || (exports.ParameterInformation = {}));
/**
* The SignatureInformation namespace provides helper functions to work with
* [SignatureInformation](#SignatureInformation) literals.
*/
var SignatureInformation;
(function (SignatureInformation) {
function create(label, documentation) {
var parameters = [];
for (var _i = 2; _i < arguments.length; _i++) {
parameters[_i - 2] = arguments[_i];
}
var result = { label: label };
if (Is.defined(documentation)) {
result.documentation = documentation;
}
if (Is.defined(parameters)) {
result.parameters = parameters;
}
else {
result.parameters = [];
}
return result;
}
SignatureInformation.create = create;
})(SignatureInformation = exports.SignatureInformation || (exports.SignatureInformation = {}));
/**
* DocumentHighlight namespace to provide helper functions to work with
* [DocumentHighlight](#DocumentHighlight) literals.
*/
var DocumentHighlight;
(function (DocumentHighlight) {
/**
* Create a DocumentHighlight object.
* @param range The range the highlight applies to.
*/
function create(range, kind) {
var result = { range: range };
if (Is.number(kind)) {
result.kind = kind;
}
return result;
}
DocumentHighlight.create = create;
})(DocumentHighlight = exports.DocumentHighlight || (exports.DocumentHighlight = {}));
var SymbolInformation;
(function (SymbolInformation) {
/**
* Creates a new symbol information literal.
*
* @param name The name of the symbol.
* @param kind The kind of the symbol.
* @param range The range of the location of the symbol.
* @param uri The resource of the location of symbol, defaults to the current document.
* @param containerName The name of the symbol containg the symbol.
*/
function create(name, kind, range, uri, containerName) {
var result = {
name: name,
kind: kind,
location: { uri: uri, range: range }
};
if (containerName) {
result.containerName = containerName;
}
return result;
}
SymbolInformation.create = create;
})(SymbolInformation = exports.SymbolInformation || (exports.SymbolInformation = {}));
/**
* The CodeActionContext namespace provides helper functions to work with
* [CodeActionContext](#CodeActionContext) literals.
*/
var CodeActionContext;
(function (CodeActionContext) {
/**
* Creates a new CodeActionContext literal.
*/
function create(diagnostics) {
return { diagnostics: diagnostics };
}
CodeActionContext.create = create;
/**
* Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is);
}
CodeActionContext.is = is;
})(CodeActionContext = exports.CodeActionContext || (exports.CodeActionContext = {}));
/**
* The CodeLens namespace provides helper functions to work with
* [CodeLens](#CodeLens) literals.
*/
var CodeLens;
(function (CodeLens) {
/**
* Creates a new CodeLens literal.
*/
function create(range, data) {
var result = { range: range };
if (Is.defined(data))
result.data = data;
return result;
}
CodeLens.create = create;
/**
* Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
}
CodeLens.is = is;
})(CodeLens = exports.CodeLens || (exports.CodeLens = {}));
/**
* The FormattingOptions namespace provides helper functions to work with
* [FormattingOptions](#FormattingOptions) literals.
*/
var FormattingOptions;
(function (FormattingOptions) {
/**
* Creates a new FormattingOptions literal.
*/
function create(tabSize, insertSpaces) {
return { tabSize: tabSize, insertSpaces: insertSpaces };
}
FormattingOptions.create = create;
/**
* Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
}
FormattingOptions.is = is;
})(FormattingOptions = exports.FormattingOptions || (exports.FormattingOptions = {}));
/**
* A document link is a range in a text document that links to an internal or external resource, like another
* text document or a web site.
*/
var DocumentLink = (function () {
function DocumentLink() {
}
return DocumentLink;
}());
exports.DocumentLink = DocumentLink;
/**
* The DocumentLink namespace provides helper functions to work with
* [DocumentLink](#DocumentLink) literals.
*/
var DocumentLink;
(function (DocumentLink) {
/**
* Creates a new DocumentLink literal.
*/
function create(range, target) {
return { range: range, target: target };
}
DocumentLink.create = create;
/**
* Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
}
DocumentLink.is = is;
})(DocumentLink = exports.DocumentLink || (exports.DocumentLink = {}));
var TextDocument;
(function (TextDocument) {
/**
* Creates a new ITextDocument literal from the given uri and content.
* @param uri The document's uri.
* @param languageId The document's language Id.
* @param content The document's content.
*/
function create(uri, languageId, version, content) {
return new FullTextDocument(uri, languageId, version, content);
}
TextDocument.create = create;
/**
* Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
*/
function is(value) {
var candidate = value;
return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
&& Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
}
TextDocument.is = is;
})(TextDocument = exports.TextDocument || (exports.TextDocument = {}));
var FullTextDocument = (function () {
function FullTextDocument(uri, languageId, version, content) {
this._uri = uri;
this._languageId = languageId;
this._version = version;
this._content = content;
this._lineOffsets = null;
}
Object.defineProperty(FullTextDocument.prototype, "uri", {
get: function () {
return this._uri;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FullTextDocument.prototype, "languageId", {
get: function () {
return this._languageId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FullTextDocument.prototype, "version", {
get: function () {
return this._version;
},
enumerable: true,
configurable: true
});
FullTextDocument.prototype.getText = function () {
return this._content;
};
FullTextDocument.prototype.update = function (event, version) {
this._content = event.text;
this._version = version;
this._lineOffsets = null;
};
FullTextDocument.prototype.getLineOffsets = function () {
if (this._lineOffsets === null) {
var lineOffsets = [];
var text = this._content;
var isLineStart = true;
for (var i = 0; i < text.length; i++) {
if (isLineStart) {
lineOffsets.push(i);
isLineStart = false;
}
var ch = text.charAt(i);
isLineStart = (ch === '\r' || ch === '\n');
if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
i++;
}
}
if (isLineStart && text.length > 0) {
lineOffsets.push(text.length);
}
this._lineOffsets = lineOffsets;
}
return this._lineOffsets;
};
FullTextDocument.prototype.positionAt = function (offset) {
offset = Math.max(Math.min(offset, this._content.length), 0);
var lineOffsets = this.getLineOffsets();
var low = 0, high = lineOffsets.length;
if (high === 0) {
return Position.create(0, offset);
}
while (low < high) {
var mid = Math.floor((low + high) / 2);
if (lineOffsets[mid] > offset) {
high = mid;
}
else {
low = mid + 1;
}
}
// low is the least x for which the line offset is larger than the current offset
// or array.length if no line offset is larger than the current offset
var line = low - 1;
return Position.create(line, offset - lineOffsets[line]);
};
FullTextDocument.prototype.offsetAt = function (position) {
var lineOffsets = this.getLineOffsets();
if (position.line >= lineOffsets.length) {
return this._content.length;
}
else if (position.line < 0) {
return 0;
}
var lineOffset = lineOffsets[position.line];
var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
};
Object.defineProperty(FullTextDocument.prototype, "lineCount", {
get: function () {
return this.getLineOffsets().length;
},
enumerable: true,
configurable: true
});
return FullTextDocument;
}());
var Is;
(function (Is) {
var toString = Object.prototype.toString;
function defined(value) {
return typeof value !== 'undefined';
}
Is.defined = defined;
function undefined(value) {
return typeof value === 'undefined';
}
Is.undefined = undefined;
function boolean(value) {
return value === true || value === false;
}
Is.boolean = boolean;
function string(value) {
return toString.call(value) === '[object String]';
}
Is.string = string;
function number(value) {
return toString.call(value) === '[object Number]';
}
Is.number = number;
function func(value) {
return toString.call(value) === '[object Function]';
}
Is.func = func;
function typedArray(value, check) {
return Array.isArray(value) && value.every(check);
}
Is.typedArray = typedArray;
})(Is || (Is = {}));
});

View File

@ -1,58 +0,0 @@
{
"_args": [
[
"vscode-languageserver-types@1.0.4",
"D:\\repo\\better-toml"
]
],
"_from": "vscode-languageserver-types@1.0.4",
"_id": "vscode-languageserver-types@1.0.4",
"_inBundle": false,
"_integrity": "sha1-Q5pS8EDInPZZnYjtmhtamr3KEbc=",
"_location": "/vscode-languageserver-types",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "vscode-languageserver-types@1.0.4",
"name": "vscode-languageserver-types",
"escapedName": "vscode-languageserver-types",
"rawSpec": "1.0.4",
"saveSpec": null,
"fetchSpec": "1.0.4"
},
"_requiredBy": [
"/vscode-languageclient",
"/vscode-languageserver"
],
"_resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-1.0.4.tgz",
"_spec": "1.0.4",
"_where": "D:\\repo\\better-toml",
"author": {
"name": "Microsoft Corporation"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-languageserver-node/issues"
},
"description": "Types used by the Language server for node",
"devDependencies": {
"mocha": "^2.4.5",
"typescript": "^1.8.10"
},
"homepage": "https://github.com/Microsoft/vscode-languageserver-node#readme",
"license": "MIT",
"main": "./lib/main.js",
"name": "vscode-languageserver-types",
"repository": {
"type": "git",
"url": "git+https://github.com/Microsoft/vscode-languageserver-node.git"
},
"scripts": {
"compile": "tsc -p ./src",
"prepublish": "tsc -p ./src",
"test": "mocha",
"watch": "tsc -w -p ./src"
},
"typings": "./lib/main",
"version": "1.0.4"
}

View File

@ -1,9 +0,0 @@
.vscode/
lib/test/
lib/*.map
src/
test/
.eslintrc
.gitignore
gulpfile.js
tsd.json

View File

@ -1,11 +0,0 @@
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,10 +0,0 @@
# VSCode Language Server
[![NPM Version](https://img.shields.io/npm/v/vscode-languageserver.svg)](https://npmjs.org/package/vscode-languageserver)
[![NPM Downloads](https://img.shields.io/npm/dm/vscode-languageserver.svg)](https://npmjs.org/package/vscode-languageserver)
[![Build Status](https://travis-ci.org/Microsoft/vscode-languageserver-node.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-languageserver-node)
Npm module to implement a VSCode language server using [Node.js](https://nodejs.org/) as a runtime.
Click [here](https://code.visualstudio.com/docs/extensions/example-language-server) for a detailed document on how to use this npm module
to implement language servers for [VSCode](https://code.visualstudio.com/).

View File

@ -1,119 +0,0 @@
#!/usr/bin/env node
var path = require('path');
var fs = require('fs');
var cp = require('child_process');
var extensionDirectory = process.argv[2];
if (!extensionDirectory) {
console.error('No extension directory provided.');
process.exit(1)
}
extensionDirectory = path.resolve(extensionDirectory)
if (!fs.existsSync(extensionDirectory)) {
console.error('Extension directory ' + extensionDirectory + ' doesn\'t exist on disk.');
process.exit(1);
}
var packageFile = process.argv[3];
if (!packageFile) {
console.error('No package.json file provided.');
process.exit(1);
}
packageFile = path.resolve(packageFile);
if (!fs.existsSync(packageFile)) {
console.error('Package file ' + packageFile + ' doesn\'t exist on disk.');
process.exit(1);
}
var tsconfigFile = process.argv[4];
if (!tsconfigFile) {
console.error('No tsconfig.json file provided');
process.exit(1);
}
tsconfigFile = path.resolve(tsconfigFile);
if (!fs.existsSync(tsconfigFile)) {
console.error('tsconfig file ' + tsconfigFile + ' doesn\'t exist on disk.')
process.exit(1);
}
var extensionServerDirectory = path.join(extensionDirectory, 'server')
json = require(tsconfigFile);
var compilerOptions = json.compilerOptions;
if (compilerOptions) {
var outDir = compilerOptions.outDir;
if (!outDir || path.join(path.dirname(tsconfigFile), outDir) !== extensionServerDirectory) {
console.error('outDir in ' + process.argv[4] + ' must point to ' + extensionServerDirectory + ' but it points to ' + path.join(path.dirname(tsconfigFile), outDir));
console.error('Please change outDir in ' + process.argv[4] + ' to ' + path.relative(path.dirname(tsconfigFile), extensionServerDirectory).replace(/\\/g, '/'));
process.exit(1);
}
}
var launchFile = path.join(path.dirname(packageFile), '.vscode', 'launch.json');
if (fs.existsSync(launchFile)) {
try {
json = JSON.parse(stripComments(fs.readFileSync(launchFile, 'utf8').toString()));
var configurations = json.configurations;
if (configurations) {
configurations.forEach(function(config) {
if (config.request === 'attach' && config.type === 'node') {
var outDir = config.outDir;
var resolvedOutDir = outDir;
if (resolvedOutDir) {
var workspaceRoot = path.dirname(packageFile);
resolvedOutDir = resolvedOutDir.replace(/\$\{workspaceRoot\}/g, workspaceRoot);
if (path.isAbsolute(resolvedOutDir)) {
resolvedOutDir = path.normalize(resolvedOutDir);
} else {
resolvedOutDir = path.join(workspaceRoot, outDir);
}
}
if (!resolvedOutDir || resolvedOutDir !== extensionServerDirectory) {
console.error('outDir in ./.vscode/launch.json must point to ' + extensionServerDirectory + ' but it points to ' + path.join(path.dirname(packageFile), outDir));
console.error('Please change outDir in ./.vscode/launch.json to ' + path.relative(path.dirname(packageFile), extensionServerDirectory).replace(/\\/g, '/'));
process.exit(1);
}
}
})
}
} catch (error) {
console.warn('Couldn\'t check launch.json file. Reading the file failed with: ' + error.message);
}
}
function stripComments(content) {
var regexp = /("(?:[^\\\"]*(?:\\.)?)*")|('(?:[^\\\']*(?:\\.)?)*')|(\/\*(?:\r?\n|.)*?\*\/)|(\/{2,}.*?(?:(?:\r?\n)|$))/g;
var result = content.replace(regexp, function (match, m1, m2, m3, m4) {
// Only one of m1, m2, m3, m4 matches
if (m3) {
// A block comment. Replace with nothing
return "";
}
else if (m4) {
// A line comment. If it ends in \r?\n then keep it.
var length_1 = m4.length;
if (length_1 > 2 && m4[length_1 - 1] === '\n') {
return m4[length_1 - 2] === '\r' ? '\r\n' : '\n';
}
else {
return "";
}
}
else {
// We match a string
return match;
}
});
return result;
}
if (!fs.existsSync(extensionServerDirectory)) {
fs.mkdirSync(extensionServerDirectory);
}
var dest = path.join(extensionServerDirectory, 'package.json');
console.log('Copying package.json to extension\'s server location...');
fs.writeFileSync(dest, fs.readFileSync(packageFile));
console.log('Updating server npm modules into extension\'s server location...');
cp.execSync('npm update --production --prefix ' + extensionServerDirectory);

View File

@ -1,10 +0,0 @@
export declare function uriToFilePath(uri: string): string;
export declare function resolveModule(workspaceRoot: string, moduleName: string): Thenable<any>;
export declare function resolve(moduleName: string, nodePath: string, cwd: string, tracer: (message: string, verbose?: string) => void): Thenable<string>;
export declare function resolveGlobalNodePath(tracer?: (message: string) => void): string;
export declare function resolveModulePath(workspaceRoot: string, moduleName: string, nodePath: string, tracer: (message: string, verbose?: string) => void): Thenable<string>;
/**
* Resolves the given module relative to the given workspace root. In contrast to
* `resolveModule` this method considers the parent chain as well.
*/
export declare function resolveModule2(workspaceRoot: string, moduleName: string, nodePath: string, tracer: (message: string, verbose?: string) => void): Thenable<any>;

View File

@ -1,220 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var url = require('url');
var path = require('path');
var child_process_1 = require('child_process');
function uriToFilePath(uri) {
var parsed = url.parse(uri);
if (parsed.protocol !== 'file:' || !parsed.path) {
return null;
}
var segments = parsed.path.split('/');
for (var i = 0, len = segments.length; i < len; i++) {
segments[i] = decodeURIComponent(segments[i]);
}
if (process.platform === 'win32' && segments.length > 1) {
var first = segments[0];
var second = segments[1];
// Do we have a drive letter and we started with a / which is the
// case if the first segement is empty (see split above)
if (first.length === 0 && second.length > 1 && second[1] === ':') {
// Remove first slash
segments.shift();
}
}
return path.normalize(segments.join('/'));
}
exports.uriToFilePath = uriToFilePath;
function isWindows() {
return process.platform === 'win32';
}
function resolveModule(workspaceRoot, moduleName) {
var nodePathKey = 'NODE_PATH';
return new Promise(function (resolve, reject) {
var result = Object.create(null);
var nodePath = [];
if (workspaceRoot) {
nodePath.push(path.join(workspaceRoot, 'node_modules'));
}
child_process_1.exec('npm config get prefix', function (error, stdout, stderr) {
if (!error) {
var globalPath = stdout.toString().replace(/[\s\r\n]+$/, '');
if (globalPath.length > 0) {
if (isWindows()) {
nodePath.push(path.join(globalPath, 'node_modules'));
}
else {
nodePath.push(path.join(globalPath, 'lib', 'node_modules'));
}
}
}
var separator = isWindows() ? ';' : ':';
var env = process.env;
var newEnv = Object.create(null);
Object.keys(env).forEach(function (key) { return newEnv[key] = env[key]; });
if (newEnv[nodePathKey]) {
newEnv[nodePathKey] = nodePath.join(separator) + separator + newEnv[nodePathKey];
}
else {
newEnv[nodePathKey] = nodePath.join(separator);
}
try {
var cp_1 = child_process_1.fork(path.join(__dirname, 'resolve.js'), [], { env: newEnv, execArgv: [] });
cp_1.on('message', function (message) {
if (message.command === 'resolve') {
var toRequire = moduleName;
if (message.success) {
toRequire = message.result;
}
cp_1.send({ command: 'exit' });
try {
resolve(require(toRequire));
}
catch (error) {
reject(error);
}
}
});
var message = {
command: 'resolve',
args: moduleName
};
cp_1.send(message);
}
catch (error) {
reject(error);
}
});
});
}
exports.resolveModule = resolveModule;
function resolve(moduleName, nodePath, cwd, tracer) {
var nodePathKey = 'NODE_PATH';
var app = [
"var p = process;",
"p.on('message',function(m){",
"if(m.c==='e'){",
"p.exit(0);",
"}",
"else if(m.c==='rs'){",
"try{",
"var r=require.resolve(m.a);",
"p.send({c:'r',s:true,r:r});",
"}",
"catch(err){",
"p.send({c:'r',s:false});",
"}",
"}",
"});"
].join('');
return new Promise(function (resolve, reject) {
var env = process.env;
var newEnv = Object.create(null);
Object.keys(env).forEach(function (key) { return newEnv[key] = env[key]; });
if (nodePath) {
if (newEnv[nodePathKey]) {
newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];
}
else {
newEnv[nodePathKey] = nodePath;
}
if (tracer) {
tracer("NODE_PATH value is: " + newEnv[nodePathKey]);
}
}
newEnv['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1';
try {
var cp_2 = child_process_1.fork('', [], {
cwd: cwd,
env: newEnv,
execArgv: ['-e', app]
});
cp_2.on('error', function (error) {
reject(error);
});
cp_2.on('message', function (message) {
if (message.c === 'r') {
cp_2.send({ c: 'e' });
if (message.s) {
resolve(message.r);
}
else {
reject(new Error("Failed to resolve module: " + moduleName));
}
}
});
var message = {
c: 'rs',
a: moduleName
};
cp_2.send(message);
}
catch (error) {
reject(error);
}
});
}
exports.resolve = resolve;
function resolveGlobalNodePath(tracer) {
var npmCommand = isWindows() ? 'npm.cmd' : 'npm';
var stdout = child_process_1.spawnSync(npmCommand, ['config', 'get', 'prefix'], {
encoding: 'utf8'
}).stdout;
if (!stdout) {
if (tracer) {
tracer("'npm config get prefix' didn't return a value.");
}
return undefined;
}
var prefix = stdout.trim();
if (tracer) {
tracer("'npm config get prefix' value is: " + prefix);
}
if (prefix.length > 0) {
if (isWindows()) {
return path.join(prefix, 'node_modules');
}
else {
return path.join(prefix, 'lib', 'node_modules');
}
}
return undefined;
}
exports.resolveGlobalNodePath = resolveGlobalNodePath;
function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
if (nodePath) {
if (!path.isAbsolute(nodePath)) {
nodePath = path.join(workspaceRoot, nodePath);
}
return resolve(moduleName, nodePath, nodePath, tracer).then(function (value) {
if (value.indexOf(path.normalize(nodePath)) === 0) {
return value;
}
else {
return Promise.reject(new Error("Failed to load " + moduleName + " from node path location."));
}
}).then(null, function (error) {
return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
});
}
else {
return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
}
}
exports.resolveModulePath = resolveModulePath;
/**
* Resolves the given module relative to the given workspace root. In contrast to
* `resolveModule` this method considers the parent chain as well.
*/
function resolveModule2(workspaceRoot, moduleName, nodePath, tracer) {
return resolveModulePath(workspaceRoot, moduleName, nodePath, tracer).then(function (path) {
if (tracer) {
tracer("Module " + moduleName + " got resolved to " + path);
}
return require(path);
});
}
exports.resolveModule2 = resolveModule2;

View File

@ -1,435 +0,0 @@
import { RequestType, RequestHandler, NotificationType, NotificationHandler, ResponseError, ErrorCodes, MessageReader, DataCallback, StreamMessageReader, IPCMessageReader, MessageWriter, StreamMessageWriter, IPCMessageWriter, Event } from 'vscode-jsonrpc';
import { TextDocument, TextDocumentChangeEvent, TextDocumentContentChangeEvent, Range, Position, Location, Diagnostic, DiagnosticSeverity, Command, TextEdit, WorkspaceEdit, WorkspaceChange, TextEditChange, TextDocumentIdentifier, CompletionItemKind, CompletionItem, CompletionList, Hover, MarkedString, SignatureHelp, SignatureInformation, ParameterInformation, Definition, CodeActionContext, DocumentHighlight, DocumentHighlightKind, SymbolInformation, SymbolKind, CodeLens, FormattingOptions, DocumentLink } from 'vscode-languageserver-types';
import { InitializeParams, InitializeResult, InitializeError, ServerCapabilities, MessageActionItem, DidChangeConfigurationParams, DidOpenTextDocumentParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams, DidSaveTextDocumentParams, DidChangeWatchedFilesParams, FileEvent, FileChangeType, PublishDiagnosticsParams, TextDocumentPositionParams, TextDocumentSyncKind, CompletionOptions, ReferenceParams, DocumentSymbolParams, WorkspaceSymbolParams, CodeActionParams, CodeLensOptions, CodeLensRequest, CodeLensParams, CodeLensResolveRequest, DocumentFormattingRequest, DocumentFormattingParams, DocumentRangeFormattingRequest, DocumentRangeFormattingParams, DocumentOnTypeFormattingRequest, DocumentOnTypeFormattingParams, RenameRequest, RenameParams, DocumentLinkRequest, DocumentLinkResolveRequest, DocumentLinkParams } from './protocol';
export { RequestType, RequestHandler, NotificationType, NotificationHandler, ResponseError, ErrorCodes, MessageReader, DataCallback, StreamMessageReader, IPCMessageReader, MessageWriter, StreamMessageWriter, IPCMessageWriter, MessageActionItem, InitializeParams, InitializeResult, InitializeError, ServerCapabilities, DidChangeConfigurationParams, DidChangeWatchedFilesParams, FileEvent, FileChangeType, DidOpenTextDocumentParams, DidChangeTextDocumentParams, TextDocumentContentChangeEvent, DidCloseTextDocumentParams, DidSaveTextDocumentParams, PublishDiagnosticsParams, Diagnostic, DiagnosticSeverity, Range, Position, Location, TextDocumentIdentifier, TextDocumentPositionParams, TextDocumentSyncKind, Hover, MarkedString, CompletionOptions, CompletionItemKind, CompletionItem, CompletionList, TextDocument, TextEdit, WorkspaceEdit, WorkspaceChange, TextEditChange, SignatureHelp, SignatureInformation, ParameterInformation, Definition, ReferenceParams, DocumentHighlight, DocumentHighlightKind, SymbolInformation, SymbolKind, DocumentSymbolParams, WorkspaceSymbolParams, CodeActionParams, CodeActionContext, Command, CodeLensRequest, CodeLensParams, CodeLensResolveRequest, CodeLens, CodeLensOptions, DocumentFormattingRequest, DocumentFormattingParams, DocumentRangeFormattingRequest, DocumentRangeFormattingParams, DocumentOnTypeFormattingRequest, DocumentOnTypeFormattingParams, FormattingOptions, RenameRequest, RenameParams, DocumentLink, DocumentLinkRequest, DocumentLinkResolveRequest };
export { Event };
import * as fm from './files';
export declare namespace Files {
let uriToFilePath: typeof fm.uriToFilePath;
let resolveGlobalNodePath: typeof fm.resolveGlobalNodePath;
let resolve: typeof fm.resolve;
let resolveModule: typeof fm.resolveModule;
let resolveModule2: typeof fm.resolveModule2;
let resolveModulePath: typeof fm.resolveModulePath;
}
/**
* A manager for simple text documents
*/
export declare class TextDocuments {
private _documents;
private _onDidChangeContent;
private _onDidOpen;
private _onDidClose;
private _onDidSave;
/**
* Create a new text document manager.
*/
constructor();
/**
* Returns the [TextDocumentSyncKind](#TextDocumentSyncKind) used by
* this text document manager.
*/
syncKind: TextDocumentSyncKind;
/**
* An event that fires when a text document managed by this manager
* has been opened or the content changes.
*/
onDidChangeContent: Event<TextDocumentChangeEvent>;
/**
* An event that fires when a text document managed by this manager
* has been opened.
*/
onDidOpen: Event<TextDocumentChangeEvent>;
/**
* An event that fires when a text document managed by this manager
* has been closed.
*/
onDidClose: Event<TextDocumentChangeEvent>;
/**
* An event that fires when a text document managed by this manager
* has been closed.
*/
onDidSave: Event<TextDocumentChangeEvent>;
/**
* Returns the document for the given URI. Returns undefined if
* the document is not mananged by this instance.
*
* @param uri The text document's URI to retrieve.
* @return the text document or `undefined`.
*/
get(uri: string): TextDocument;
/**
* Returns all text documents managed by this instance.
*
* @return all text documents.
*/
all(): TextDocument[];
/**
* Returns the URIs of all text documents managed by this instance.
*
* @return the URI's of all text documents.
*/
keys(): string[];
/**
* Listens for `low level` notification on the given connection to
* update the text documents managed by this instance.
*
* @param connection The connection to listen on.
*/
listen(connection: IConnection): void;
}
/**
* Helps tracking error message. Equal occurences of the same
* message are only stored once. This class is for example
* usefull if text documents are validated in a loop and equal
* error message should be folded into one.
*/
export declare class ErrorMessageTracker {
private messages;
constructor();
/**
* Add a message to the tracker.
*
* @param message The message to add.
*/
add(message: string): void;
/**
* Send all tracked messages to the conenction's window.
*
* @param connection The connection establised between client and server.
*/
sendErrors(connection: {
window: RemoteWindow;
}): void;
}
/**
* The RemoteConsole interface contains all functions to interact with
* the developer console of VS Code.
*/
export interface RemoteConsole {
/**
* Show an error message.
*
* @param message The message to show.
*/
error(message: string): any;
/**
* Show a warning message.
*
* @param message The message to show.
*/
warn(message: string): any;
/**
* Show an information message.
*
* @param message The message to show.
*/
info(message: string): any;
/**
* Log a message.
*
* @param message The message to log.
*/
log(message: string): any;
}
/**
* The RemoteWindow interface contains all functions to interact with
* the visual window of VS Code.
*/
export interface RemoteWindow {
/**
* Show an error message.
*
* @param message The message to show.
*/
showErrorMessage(message: string): any;
showErrorMessage<T extends MessageActionItem>(message: string, ...actions: T[]): Thenable<T>;
/**
* Show a warning message.
*
* @param message The message to show.
*/
showWarningMessage(message: string): any;
showWarningMessage<T extends MessageActionItem>(message: string, ...actions: T[]): Thenable<T>;
/**
* Show an information message.
*
* @param message The message to show.
*/
showInformationMessage(message: string): any;
showInformationMessage<T extends MessageActionItem>(message: string, ...actions: T[]): Thenable<T>;
}
/**
* Interface to log telemetry events. The events are actually send to the client
* and the client needs to feed the event into a propert telemetry system.
*/
export interface Telemetry {
/**
* Log the given data to telemetry.
*
* @param data The data to log. Must be a JSON serializable object.
*/
logEvent(data: any): void;
}
/**
* Interface to log traces to the client. The events are sent to the client and the
* client needs to log the trace events.
*/
export interface Tracer {
/**
* Log the given data to the trace Log
*/
log(message: string, verbose?: string): void;
}
/**
* Interface to describe the shape of the server connection.
*/
export interface IConnection {
/**
* Start listening on the input stream for messages to process.
*/
listen(): void;
/**
* Installs a request handler described by the given [RequestType](#RequestType).
*
* @param type The [RequestType](#RequestType) describing the request.
* @param handler The handler to install
*/
onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): void;
/**
* Installs a notification handler described by the given [NotificationType](#NotificationType).
*
* @param type The [NotificationType](#NotificationType) describing the notification.
* @param handler The handler to install
*/
onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): void;
/**
* Send a notification to the client.
*
* @param type The [NotificationType](#NotificationType) describing the notification.
* @param params The notification's parameters.
*/
sendNotification<P>(type: NotificationType<P>, params?: P): void;
/**
* Send a request to the client.
*
* @param type The [RequestType](#RequestType) describing the request.
* @param params The request's parameters.
*/
sendRequest<P, R, E>(type: RequestType<P, R, E>, params?: P): Thenable<R>;
/**
* Installs a handler for the intialize request.
*
* @param handler The initialize handler.
*/
onInitialize(handler: RequestHandler<InitializeParams, InitializeResult, InitializeError>): void;
/**
* Installs a handler for the shutdown request.
*
* @param handler The initialize handler.
*/
onShutdown(handler: RequestHandler<void, void, void>): void;
/**
* Installs a handler for the exit notification.
*
* @param handler The exit handler.
*/
onExit(handler: NotificationHandler<void>): void;
/**
* A proxy for VSCode's development console. See [RemoteConsole](#RemoteConsole)
*/
console: RemoteConsole;
/**
* A proxy for VSCode's window. See [RemoteWindow](#RemoteWindow)
*/
window: RemoteWindow;
/**
* A proxy to send telemetry events to the client.
*/
telemetry: Telemetry;
/**
* A proxy to send trace events to the client.
*/
tracer: Tracer;
/**
* Installs a handler for the `DidChangeConfiguration` notification.
*
* @param handler The corresponding handler.
*/
onDidChangeConfiguration(handler: NotificationHandler<DidChangeConfigurationParams>): void;
/**
* Installs a handler for the `DidChangeWatchedFiles` notification.
*
* @param handler The corresponding handler.
*/
onDidChangeWatchedFiles(handler: NotificationHandler<DidChangeWatchedFilesParams>): void;
/**
* Installs a handler for the `DidOpenTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidOpenTextDocument(handler: NotificationHandler<DidOpenTextDocumentParams>): void;
/**
* Installs a handler for the `DidChangeTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidChangeTextDocument(handler: NotificationHandler<DidChangeTextDocumentParams>): void;
/**
* Installs a handler for the `DidCloseTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidCloseTextDocument(handler: NotificationHandler<DidCloseTextDocumentParams>): void;
/**
* Installs a handler for the `DidSaveTextDocument` notification.
*
* @param handler The corresponding handler.
*/
onDidSaveTextDocument(handler: NotificationHandler<DidSaveTextDocumentParams>): void;
/**
* Sends diagnostics computed for a given document to VSCode to render them in the
* user interface.
*
* @param params The diagnostic parameters.
*/
sendDiagnostics(params: PublishDiagnosticsParams): void;
/**
* Installs a handler for the `Hover` request.
*
* @param handler The corresponding handler.
*/
onHover(handler: RequestHandler<TextDocumentPositionParams, Hover, void>): void;
/**
* Installs a handler for the `Completion` request.
*
* @param handler The corresponding handler.
*/
onCompletion(handler: RequestHandler<TextDocumentPositionParams, CompletionItem[] | CompletionList, void>): void;
/**
* Installs a handler for the `CompletionResolve` request.
*
* @param handler The corresponding handler.
*/
onCompletionResolve(handler: RequestHandler<CompletionItem, CompletionItem, void>): void;
/**
* Installs a handler for the `SignatureHelp` request.
*
* @param handler The corresponding handler.
*/
onSignatureHelp(handler: RequestHandler<TextDocumentPositionParams, SignatureHelp, void>): void;
/**
* Installs a handler for the `Definition` request.
*
* @param handler The corresponding handler.
*/
onDefinition(handler: RequestHandler<TextDocumentPositionParams, Definition, void>): void;
/**
* Installs a handler for the `References` request.
*
* @param handler The corresponding handler.
*/
onReferences(handler: RequestHandler<ReferenceParams, Location[], void>): void;
/**
* Installs a handler for the `DocumentHighlight` request.
*
* @param handler The corresponding handler.
*/
onDocumentHighlight(handler: RequestHandler<TextDocumentPositionParams, DocumentHighlight[], void>): void;
/**
* Installs a handler for the `DocumentSymbol` request.
*
* @param handler The corresponding handler.
*/
onDocumentSymbol(handler: RequestHandler<DocumentSymbolParams, SymbolInformation[], void>): void;
/**
* Installs a handler for the `WorkspaceSymbol` request.
*
* @param handler The corresponding handler.
*/
onWorkspaceSymbol(handler: RequestHandler<WorkspaceSymbolParams, SymbolInformation[], void>): void;
/**
* Installs a handler for the `CodeAction` request.
*
* @param handler The corresponding handler.
*/
onCodeAction(handler: RequestHandler<CodeActionParams, Command[], void>): void;
/**
* Compute a list of [lenses](#CodeLens). This call should return as fast as possible and if
* computing the commands is expensive implementors should only return code lens objects with the
* range set and handle the resolve request.
*
* @param handler The corresponding handler.
*/
onCodeLens(handler: RequestHandler<CodeLensParams, CodeLens[], void>): void;
/**
* This function will be called for each visible code lens, usually when scrolling and after
* the onCodeLens has been called.
*
* @param handler The corresponding handler.
*/
onCodeLensResolve(handler: RequestHandler<CodeLens, CodeLens, void>): void;
/**
* Installs a handler for the document formatting request.
*
* @param handler The corresponding handler.
*/
onDocumentFormatting(handler: RequestHandler<DocumentFormattingParams, TextEdit[], void>): void;
/**
* Installs a handler for the document range formatting request.
*
* @param handler The corresponding handler.
*/
onDocumentRangeFormatting(handler: RequestHandler<DocumentRangeFormattingParams, TextEdit[], void>): void;
/**
* Installs a handler for the document on type formatting request.
*
* @param handler The corresponding handler.
*/
onDocumentOnTypeFormatting(handler: RequestHandler<DocumentOnTypeFormattingParams, TextEdit[], void>): void;
/**
* Installs a handler for the rename request.
*
* @param handler The corresponding handler.
*/
onRenameRequest(handler: RequestHandler<RenameParams, WorkspaceEdit, void>): void;
/**
* Installs a handler for the document links request.
*
* @param handler The corresponding handler.
*/
onDocumentLinks(handler: RequestHandler<DocumentLinkParams, DocumentLink[], void>): void;
/**
* Installs a handler for the document links resolve request.
*
* @param handler The corresponding handler.
*/
onDocumentLinkResolve(handler: RequestHandler<DocumentLink, DocumentLink, void>): void;
/**
* Disposes the connection
*/
dispose(): void;
}
/**
* Creates a new connection using a the given streams.
*
* @param inputStream The stream to read messages from.
* @param outputStream The stream to write messages to.
* @return a [connection](#IConnection)
*/
export declare function createConnection(inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream): IConnection;
/**
* Creates a new connection.
*
* @param reader The message reader to read messages from.
* @param writer The message writer to write message to.
*/
export declare function createConnection(reader: MessageReader, writer: MessageWriter): IConnection;
/**
* Creates a new connection based on the processes command line arguments:
* --ipc : connection using the node process ipc
*
* @param reader The message reader to read messages from.
* @param writer The message writer to write message to.
*/
export declare function createConnection(): IConnection;

View File

@ -1,506 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
var vscode_jsonrpc_1 = require('vscode-jsonrpc');
exports.ResponseError = vscode_jsonrpc_1.ResponseError;
exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
exports.Event = vscode_jsonrpc_1.Event;
var vscode_languageserver_types_1 = require('vscode-languageserver-types');
exports.TextDocument = vscode_languageserver_types_1.TextDocument;
exports.Range = vscode_languageserver_types_1.Range;
exports.Position = vscode_languageserver_types_1.Position;
exports.Location = vscode_languageserver_types_1.Location;
exports.Diagnostic = vscode_languageserver_types_1.Diagnostic;
exports.Command = vscode_languageserver_types_1.Command;
exports.TextEdit = vscode_languageserver_types_1.TextEdit;
exports.WorkspaceChange = vscode_languageserver_types_1.WorkspaceChange;
exports.TextDocumentIdentifier = vscode_languageserver_types_1.TextDocumentIdentifier;
exports.CompletionItem = vscode_languageserver_types_1.CompletionItem;
exports.CompletionList = vscode_languageserver_types_1.CompletionList;
exports.MarkedString = vscode_languageserver_types_1.MarkedString;
exports.SignatureInformation = vscode_languageserver_types_1.SignatureInformation;
exports.ParameterInformation = vscode_languageserver_types_1.ParameterInformation;
exports.CodeActionContext = vscode_languageserver_types_1.CodeActionContext;
exports.DocumentHighlight = vscode_languageserver_types_1.DocumentHighlight;
exports.SymbolInformation = vscode_languageserver_types_1.SymbolInformation;
exports.CodeLens = vscode_languageserver_types_1.CodeLens;
exports.FormattingOptions = vscode_languageserver_types_1.FormattingOptions;
exports.DocumentLink = vscode_languageserver_types_1.DocumentLink;
var protocol_1 = require('./protocol');
exports.FileChangeType = protocol_1.FileChangeType;
exports.TextDocumentSyncKind = protocol_1.TextDocumentSyncKind;
exports.CodeLensRequest = protocol_1.CodeLensRequest;
exports.CodeLensResolveRequest = protocol_1.CodeLensResolveRequest;
exports.DocumentFormattingRequest = protocol_1.DocumentFormattingRequest;
exports.DocumentRangeFormattingRequest = protocol_1.DocumentRangeFormattingRequest;
exports.DocumentOnTypeFormattingRequest = protocol_1.DocumentOnTypeFormattingRequest;
exports.RenameRequest = protocol_1.RenameRequest;
exports.DocumentLinkRequest = protocol_1.DocumentLinkRequest;
exports.DocumentLinkResolveRequest = protocol_1.DocumentLinkResolveRequest;
var Is = require('./utils/is');
// ------------- Reexport the API surface of the language worker API ----------------------
var fm = require('./files');
var net = require('net');
var stream = require('stream');
var Files;
(function (Files) {
Files.uriToFilePath = fm.uriToFilePath;
Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;
Files.resolve = fm.resolve;
Files.resolveModule = fm.resolveModule;
Files.resolveModule2 = fm.resolveModule2;
Files.resolveModulePath = fm.resolveModulePath;
})(Files = exports.Files || (exports.Files = {}));
/**
* A manager for simple text documents
*/
var TextDocuments = (function () {
/**
* Create a new text document manager.
*/
function TextDocuments() {
this._documents = Object.create(null);
this._onDidChangeContent = new vscode_jsonrpc_1.Emitter();
this._onDidOpen = new vscode_jsonrpc_1.Emitter();
this._onDidClose = new vscode_jsonrpc_1.Emitter();
this._onDidSave = new vscode_jsonrpc_1.Emitter();
}
Object.defineProperty(TextDocuments.prototype, "syncKind", {
/**
* Returns the [TextDocumentSyncKind](#TextDocumentSyncKind) used by
* this text document manager.
*/
get: function () {
return protocol_1.TextDocumentSyncKind.Full;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TextDocuments.prototype, "onDidChangeContent", {
/**
* An event that fires when a text document managed by this manager
* has been opened or the content changes.
*/
get: function () {
return this._onDidChangeContent.event;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TextDocuments.prototype, "onDidOpen", {
/**
* An event that fires when a text document managed by this manager
* has been opened.
*/
get: function () {
return this._onDidOpen.event;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TextDocuments.prototype, "onDidClose", {
/**
* An event that fires when a text document managed by this manager
* has been closed.
*/
get: function () {
return this._onDidClose.event;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TextDocuments.prototype, "onDidSave", {
/**
* An event that fires when a text document managed by this manager
* has been closed.
*/
get: function () {
return this._onDidSave.event;
},
enumerable: true,
configurable: true
});
/**
* Returns the document for the given URI. Returns undefined if
* the document is not mananged by this instance.
*
* @param uri The text document's URI to retrieve.
* @return the text document or `undefined`.
*/
TextDocuments.prototype.get = function (uri) {
return this._documents[uri];
};
/**
* Returns all text documents managed by this instance.
*
* @return all text documents.
*/
TextDocuments.prototype.all = function () {
var _this = this;
return Object.keys(this._documents).map(function (key) { return _this._documents[key]; });
};
/**
* Returns the URIs of all text documents managed by this instance.
*
* @return the URI's of all text documents.
*/
TextDocuments.prototype.keys = function () {
return Object.keys(this._documents);
};
/**
* Listens for `low level` notification on the given connection to
* update the text documents managed by this instance.
*
* @param connection The connection to listen on.
*/
TextDocuments.prototype.listen = function (connection) {
var _this = this;
connection.__textDocumentSync = protocol_1.TextDocumentSyncKind.Full;
connection.onDidOpenTextDocument(function (event) {
var td = event.textDocument;
var document = vscode_languageserver_types_1.TextDocument.create(td.uri, td.languageId, td.version, td.text);
_this._documents[td.uri] = document;
_this._onDidOpen.fire({ document: document });
_this._onDidChangeContent.fire({ document: document });
});
connection.onDidChangeTextDocument(function (event) {
var td = event.textDocument;
var changes = event.contentChanges;
var last = changes.length > 0 ? changes[changes.length - 1] : null;
if (last) {
var document_1 = _this._documents[td.uri];
if (document_1 && Is.func(document_1['update'])) {
document_1.update(last, td.version);
_this._onDidChangeContent.fire({ document: document_1 });
}
}
});
connection.onDidCloseTextDocument(function (event) {
var document = _this._documents[event.textDocument.uri];
if (document) {
delete _this._documents[event.textDocument.uri];
_this._onDidClose.fire({ document: document });
}
});
connection.onDidSaveTextDocument(function (event) {
var document = _this._documents[event.textDocument.uri];
if (document) {
_this._onDidSave.fire({ document: document });
}
});
};
return TextDocuments;
}());
exports.TextDocuments = TextDocuments;
// ------------------------- implementation of the language server protocol ---------------------------------------------
/**
* Helps tracking error message. Equal occurences of the same
* message are only stored once. This class is for example
* usefull if text documents are validated in a loop and equal
* error message should be folded into one.
*/
var ErrorMessageTracker = (function () {
function ErrorMessageTracker() {
this.messages = Object.create(null);
}
/**
* Add a message to the tracker.
*
* @param message The message to add.
*/
ErrorMessageTracker.prototype.add = function (message) {
var count = this.messages[message];
if (!count) {
count = 0;
}
count++;
this.messages[message] = count;
};
/**
* Send all tracked messages to the conenction's window.
*
* @param connection The connection establised between client and server.
*/
ErrorMessageTracker.prototype.sendErrors = function (connection) {
Object.keys(this.messages).forEach(function (message) {
connection.window.showErrorMessage(message);
});
};
return ErrorMessageTracker;
}());
exports.ErrorMessageTracker = ErrorMessageTracker;
var ConnectionLogger = (function () {
function ConnectionLogger() {
}
ConnectionLogger.prototype.attach = function (connection) {
this.connection = connection;
};
ConnectionLogger.prototype.error = function (message) {
this.send(protocol_1.MessageType.Error, message);
};
ConnectionLogger.prototype.warn = function (message) {
this.send(protocol_1.MessageType.Warning, message);
};
ConnectionLogger.prototype.info = function (message) {
this.send(protocol_1.MessageType.Info, message);
};
ConnectionLogger.prototype.log = function (message) {
this.send(protocol_1.MessageType.Log, message);
};
ConnectionLogger.prototype.send = function (type, message) {
if (this.connection) {
this.connection.sendNotification(protocol_1.LogMessageNotification.type, { type: type, message: message });
}
};
return ConnectionLogger;
}());
var RemoteWindowImpl = (function () {
function RemoteWindowImpl(connection) {
this.connection = connection;
}
RemoteWindowImpl.prototype.showErrorMessage = function (message) {
var actions = [];
for (var _i = 1; _i < arguments.length; _i++) {
actions[_i - 1] = arguments[_i];
}
return this.connection.sendRequest(protocol_1.ShowMessageRequest.type, { type: protocol_1.MessageType.Error, message: message, actions: actions });
};
RemoteWindowImpl.prototype.showWarningMessage = function (message) {
var actions = [];
for (var _i = 1; _i < arguments.length; _i++) {
actions[_i - 1] = arguments[_i];
}
return this.connection.sendRequest(protocol_1.ShowMessageRequest.type, { type: protocol_1.MessageType.Warning, message: message, actions: actions });
};
RemoteWindowImpl.prototype.showInformationMessage = function (message) {
var actions = [];
for (var _i = 1; _i < arguments.length; _i++) {
actions[_i - 1] = arguments[_i];
}
return this.connection.sendRequest(protocol_1.ShowMessageRequest.type, { type: protocol_1.MessageType.Info, message: message, actions: actions });
};
return RemoteWindowImpl;
}());
var TracerImpl = (function () {
function TracerImpl(connection) {
this.connection = connection;
this._trace = vscode_jsonrpc_1.Trace.Off;
}
Object.defineProperty(TracerImpl.prototype, "trace", {
set: function (value) {
this._trace = value;
},
enumerable: true,
configurable: true
});
TracerImpl.prototype.log = function (message, verbose) {
if (this._trace === vscode_jsonrpc_1.Trace.Off) {
return;
}
this.connection.sendNotification(vscode_jsonrpc_1.LogTraceNotification.type, {
message: message,
verbose: this._trace === vscode_jsonrpc_1.Trace.Verbose ? verbose : null
});
};
return TracerImpl;
}());
var TelemetryImpl = (function () {
function TelemetryImpl(connection) {
this.connection = connection;
}
TelemetryImpl.prototype.logEvent = function (data) {
this.connection.sendNotification(protocol_1.TelemetryEventNotification.type, data);
};
return TelemetryImpl;
}());
function createConnection(input, output) {
if (!input && !output && process.argv.length > 2) {
var port = void 0;
var argv = process.argv.slice(2);
for (var i = 0; i < argv.length; i++) {
var arg = argv[i];
if (arg === '--node-ipc') {
input = new vscode_jsonrpc_1.IPCMessageReader(process);
output = new vscode_jsonrpc_1.IPCMessageWriter(process);
}
else if (arg === '--stdio') {
input = process.stdin;
output = process.stdout;
}
else if (arg === '--socket') {
port = parseInt(argv[i + 1]);
i++;
}
else {
var args = arg.split('=');
if (args[0] === '--socket') {
port = parseInt(args[1]);
}
}
}
if (port) {
output = new stream.PassThrough();
input = new stream.PassThrough();
var server_1 = net.createServer(function (socket) {
server_1.close();
socket.pipe(output);
input.pipe(socket);
}).listen(port);
}
}
var commandLineMessage = "Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}'";
if (!input) {
throw new Error("Connection input stream is not set. " + commandLineMessage);
}
if (!output) {
throw new Error("Connection output stream is not set. " + commandLineMessage);
}
var shutdownReceived;
// Backwards compatibility
if (Is.func(input.read) && Is.func(input.on)) {
var inputStream = input;
inputStream.on('end', function () {
process.exit(shutdownReceived ? 0 : 1);
});
inputStream.on('close', function () {
process.exit(shutdownReceived ? 0 : 1);
});
}
var logger = new ConnectionLogger();
var connection = vscode_jsonrpc_1.createServerMessageConnection(input, output, logger);
logger.attach(connection);
var remoteWindow = new RemoteWindowImpl(connection);
var telemetry = new TelemetryImpl(connection);
var tracer = new TracerImpl(connection);
function asThenable(value) {
if (Is.thenable(value)) {
return value;
}
else {
return Promise.resolve(value);
}
}
var shutdownHandler = null;
var initializeHandler = null;
var exitHandler = null;
var protocolConnection = {
listen: function () { return connection.listen(); },
sendRequest: function (type, params) { return connection.sendRequest(type, params); },
onRequest: function (type, handler) { return connection.onRequest(type, handler); },
sendNotification: function (type, params) { return connection.sendNotification(type, params); },
onNotification: function (type, handler) { return connection.onNotification(type, handler); },
onInitialize: function (handler) { return initializeHandler = handler; },
onShutdown: function (handler) { return shutdownHandler = handler; },
onExit: function (handler) { return exitHandler = handler; },
get console() { return logger; },
get window() { return remoteWindow; },
get telemetry() { return telemetry; },
get tracer() { return tracer; },
onDidChangeConfiguration: function (handler) { return connection.onNotification(protocol_1.DidChangeConfigurationNotification.type, handler); },
onDidChangeWatchedFiles: function (handler) { return connection.onNotification(protocol_1.DidChangeWatchedFilesNotification.type, handler); },
__textDocumentSync: undefined,
onDidOpenTextDocument: function (handler) { return connection.onNotification(protocol_1.DidOpenTextDocumentNotification.type, handler); },
onDidChangeTextDocument: function (handler) { return connection.onNotification(protocol_1.DidChangeTextDocumentNotification.type, handler); },
onDidCloseTextDocument: function (handler) { return connection.onNotification(protocol_1.DidCloseTextDocumentNotification.type, handler); },
onDidSaveTextDocument: function (handler) { return connection.onNotification(protocol_1.DidSaveTextDocumentNotification.type, handler); },
sendDiagnostics: function (params) { return connection.sendNotification(protocol_1.PublishDiagnosticsNotification.type, params); },
onHover: function (handler) { return connection.onRequest(protocol_1.HoverRequest.type, handler); },
onCompletion: function (handler) { return connection.onRequest(protocol_1.CompletionRequest.type, handler); },
onCompletionResolve: function (handler) { return connection.onRequest(protocol_1.CompletionResolveRequest.type, handler); },
onSignatureHelp: function (handler) { return connection.onRequest(protocol_1.SignatureHelpRequest.type, handler); },
onDefinition: function (handler) { return connection.onRequest(protocol_1.DefinitionRequest.type, handler); },
onReferences: function (handler) { return connection.onRequest(protocol_1.ReferencesRequest.type, handler); },
onDocumentHighlight: function (handler) { return connection.onRequest(protocol_1.DocumentHighlightRequest.type, handler); },
onDocumentSymbol: function (handler) { return connection.onRequest(protocol_1.DocumentSymbolRequest.type, handler); },
onWorkspaceSymbol: function (handler) { return connection.onRequest(protocol_1.WorkspaceSymbolRequest.type, handler); },
onCodeAction: function (handler) { return connection.onRequest(protocol_1.CodeActionRequest.type, handler); },
onCodeLens: function (handler) { return connection.onRequest(protocol_1.CodeLensRequest.type, handler); },
onCodeLensResolve: function (handler) { return connection.onRequest(protocol_1.CodeLensResolveRequest.type, handler); },
onDocumentFormatting: function (handler) { return connection.onRequest(protocol_1.DocumentFormattingRequest.type, handler); },
onDocumentRangeFormatting: function (handler) { return connection.onRequest(protocol_1.DocumentRangeFormattingRequest.type, handler); },
onDocumentOnTypeFormatting: function (handler) { return connection.onRequest(protocol_1.DocumentOnTypeFormattingRequest.type, handler); },
onRenameRequest: function (handler) { return connection.onRequest(protocol_1.RenameRequest.type, handler); },
onDocumentLinks: function (handler) { return connection.onRequest(protocol_1.DocumentLinkRequest.type, handler); },
onDocumentLinkResolve: function (handler) { return connection.onRequest(protocol_1.DocumentLinkResolveRequest.type, handler); },
dispose: function () { return connection.dispose(); }
};
connection.onRequest(protocol_1.InitializeRequest.type, function (params) {
if (Is.number(params.processId)) {
// We received a parent process id. Set up a timer to periodically check
// if the parent is still alive.
setInterval(function () {
try {
process.kill(params.processId, 0);
}
catch (ex) {
// Parent process doesn't exist anymore. Exit the server.
process.exit(shutdownReceived ? 0 : 1);
}
}, 3000);
}
if (Is.string(params.trace)) {
tracer.trace = vscode_jsonrpc_1.Trace.fromString(params.trace);
}
if (initializeHandler) {
var result = initializeHandler(params, new vscode_jsonrpc_1.CancellationTokenSource().token);
return asThenable(result).then(function (value) {
if (value instanceof vscode_jsonrpc_1.ResponseError) {
return value;
}
var result = value;
if (!result) {
result = { capabilities: {} };
}
var capabilities = result.capabilities;
if (!capabilities) {
capabilities = {};
result.capabilities = {};
}
if (!Is.number(capabilities.textDocumentSync)) {
capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : protocol_1.TextDocumentSyncKind.None;
}
return result;
});
}
else {
var result = { capabilities: { textDocumentSync: protocol_1.TextDocumentSyncKind.None } };
return result;
}
});
connection.onRequest(protocol_1.ShutdownRequest.type, function (params) {
shutdownReceived = true;
if (shutdownHandler) {
return shutdownHandler(params, new vscode_jsonrpc_1.CancellationTokenSource().token);
}
else {
return undefined;
}
});
connection.onNotification(protocol_1.ExitNotification.type, function (params) {
try {
if (exitHandler) {
exitHandler(params);
}
}
finally {
if (shutdownReceived) {
process.exit(0);
}
else {
process.exit(1);
}
}
});
connection.onNotification(vscode_jsonrpc_1.SetTraceNotification.type, function (params) {
tracer.trace = vscode_jsonrpc_1.Trace.fromString(params.value);
;
});
return protocolConnection;
}
exports.createConnection = createConnection;

View File

@ -1,758 +0,0 @@
import { RequestType, NotificationType } from 'vscode-jsonrpc';
import { TextDocumentContentChangeEvent, Range, Position, Location, Diagnostic, Command, TextEdit, WorkspaceEdit, TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextDocumentItem, CompletionItem, CompletionList, Hover, SignatureHelp, Definition, ReferenceContext, DocumentHighlight, SymbolInformation, CodeLens, CodeActionContext, FormattingOptions, DocumentLink } from 'vscode-languageserver-types';
/**
* A parameter literal used in requests to pass a text document and a position inside that
* document.
*/
export interface TextDocumentPositionParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
/**
* The position inside the text document.
*/
position: Position;
}
/**
* Defines the capabilities provided by the client.
*/
export interface ClientCapabilities {
}
/**
* Defines how the host (editor) should sync
* document changes to the language server.
*/
export declare enum TextDocumentSyncKind {
/**
* Documents should not be synced at all.
*/
None = 0,
/**
* Documents are synced by always sending the full content
* of the document.
*/
Full = 1,
/**
* Documents are synced by sending the full content on open.
* After that only incremental updates to the document are
* send.
*/
Incremental = 2,
}
/**
* Completion options.
*/
export interface CompletionOptions {
/**
* The server provides support to resolve additional
* information for a completion item.
*/
resolveProvider?: boolean;
/**
* The characters that trigger completion automatically.
*/
triggerCharacters?: string[];
}
/**
* Signature help options.
*/
export interface SignatureHelpOptions {
/**
* The characters that trigger signature help
* automatically.
*/
triggerCharacters?: string[];
}
/**
* Code Lens options.
*/
export interface CodeLensOptions {
/**
* Code lens has a resolve provider as well.
*/
resolveProvider?: boolean;
}
/**
* Format document on type options
*/
export interface DocumentOnTypeFormattingOptions {
/**
* A character on which formatting should be triggered, like `}`.
*/
firstTriggerCharacter: string;
/**
* More trigger characters.
*/
moreTriggerCharacter?: string[];
}
/**
* Document link options
*/
export interface DocumentLinkOptions {
/**
* Document links have a resolve provider as well.
*/
resolveProvider?: boolean;
}
/**
* Defines the capabilities provided by a language
* server.
*/
export interface ServerCapabilities {
/**
* Defines how text documents are synced.
*/
textDocumentSync?: number;
/**
* The server provides hover support.
*/
hoverProvider?: boolean;
/**
* The server provides completion support.
*/
completionProvider?: CompletionOptions;
/**
* The server provides signature help support.
*/
signatureHelpProvider?: SignatureHelpOptions;
/**
* The server provides goto definition support.
*/
definitionProvider?: boolean;
/**
* The server provides find references support.
*/
referencesProvider?: boolean;
/**
* The server provides document highlight support.
*/
documentHighlightProvider?: boolean;
/**
* The server provides document symbol support.
*/
documentSymbolProvider?: boolean;
/**
* The server provides workspace symbol support.
*/
workspaceSymbolProvider?: boolean;
/**
* The server provides code actions.
*/
codeActionProvider?: boolean;
/**
* The server provides code lens.
*/
codeLensProvider?: CodeLensOptions;
/**
* The server provides document formatting.
*/
documentFormattingProvider?: boolean;
/**
* The server provides document range formatting.
*/
documentRangeFormattingProvider?: boolean;
/**
* The server provides document formatting on typing.
*/
documentOnTypeFormattingProvider?: DocumentOnTypeFormattingOptions;
/**
* The server provides rename support.
*/
renameProvider?: boolean;
/**
* The server provides document link support.
*/
documentLinkProvider?: DocumentLinkOptions;
}
/**
* The initialize method is sent from the client to the server.
* It is send once as the first method after starting up the
* worker. The requests parameter is of type [InitializeParams](#InitializeParams)
* the response if of type [InitializeResult](#InitializeResult) of a Thenable that
* resolves to such.
*/
export declare namespace InitializeRequest {
const type: RequestType<InitializeParams, InitializeResult, InitializeError>;
}
/**
* The initialize parameters
*/
export interface InitializeParams {
/**
* The process Id of the parent process that started
* the server.
*/
processId: number;
/**
* The rootPath of the workspace. Is null
* if no folder is open.
*/
rootPath: string;
/**
* The capabilities provided by the client (editor)
*/
capabilities: ClientCapabilities;
/**
* User provided initialization options.
*/
initializationOptions?: any;
/**
* The initial trace setting. If omitted trace is disabled ('off').
*/
trace?: 'off' | 'messages' | 'verbose';
}
/**
* The result returned from an initilize request.
*/
export interface InitializeResult {
/**
* The capabilities the language server provides.
*/
capabilities: ServerCapabilities;
}
/**
* The data type of the ResponseError if the
* initialize request fails.
*/
export interface InitializeError {
/**
* Indicates whether the client should retry to send the
* initilize request after showing the message provided
* in the {@link ResponseError}
*/
retry: boolean;
}
/**
* A shutdown request is sent from the client to the server.
* It is send once when the client descides to shutdown the
* server. The only notification that is sent after a shudown request
* is the exit event.
*/
export declare namespace ShutdownRequest {
const type: RequestType<void, void, void>;
}
/**
* The exit event is sent from the client to the server to
* ask the server to exit its process.
*/
export declare namespace ExitNotification {
const type: NotificationType<void>;
}
/**
* The configuration change notification is sent from the client to the server
* when the client's configuration has changed. The notification contains
* the changed configuration as defined by the language client.
*/
export declare namespace DidChangeConfigurationNotification {
const type: NotificationType<DidChangeConfigurationParams>;
}
/**
* The parameters of a change configuration notification.
*/
export interface DidChangeConfigurationParams {
/**
* The actual changed settings
*/
settings: any;
}
/**
* The message type
*/
export declare enum MessageType {
/**
* An error message.
*/
Error = 1,
/**
* A warning message.
*/
Warning = 2,
/**
* An information message.
*/
Info = 3,
/**
* A log message.
*/
Log = 4,
}
/**
* The parameters of a notification message.
*/
export interface ShowMessageParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
}
/**
* The show message notification is sent from a server to a client to ask
* the client to display a particular message in the user interface.
*/
export declare namespace ShowMessageNotification {
const type: NotificationType<ShowMessageParams>;
}
export interface MessageActionItem {
/**
* A short title like 'Retry', 'Open Log' etc.
*/
title: string;
}
export interface ShowMessageRequestParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
/**
* The message action items to present.
*/
actions?: MessageActionItem[];
}
/**
* The show message request is send from the server to the clinet to show a message
* and a set of options actions to the user.
*/
export declare namespace ShowMessageRequest {
const type: RequestType<ShowMessageRequestParams, MessageActionItem, void>;
}
/**
* The log message notification is send from the server to the client to ask
* the client to log a particular message.
*/
export declare namespace LogMessageNotification {
let type: NotificationType<LogMessageParams>;
}
/**
* The log message parameters.
*/
export interface LogMessageParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
}
/**
* The telemetry event notification is send from the server to the client to ask
* the client to log telemetry data.
*/
export declare namespace TelemetryEventNotification {
let type: NotificationType<any>;
}
/**
* The parameters send in a open text document notification
*/
export interface DidOpenTextDocumentParams {
/**
* The document that was opened.
*/
textDocument: TextDocumentItem;
}
/**
* The document open notification is sent from the client to the server to signal
* newly opened text documents. The document's truth is now managed by the client
* and the server must not try to read the document's truth using the document's
* uri.
*/
export declare namespace DidOpenTextDocumentNotification {
const type: NotificationType<DidOpenTextDocumentParams>;
}
/**
* An event describing a change to a text document. If range and rangeLength are omitted
* the new text is considered to be the full content of the document.
*/
export interface TextDocumentContentChangeEvent {
/**
* The range of the document that changed.
*/
range?: Range;
/**
* The length of the range that got replaced.
*/
rangeLength?: number;
/**
* The new text of the document.
*/
text: string;
}
/**
* The change text document notification's parameters.
*/
export interface DidChangeTextDocumentParams {
/**
* The document that did change. The version number points
* to the version after all provided content changes have
* been applied.
*/
textDocument: VersionedTextDocumentIdentifier;
/**
* The actual content changes.
*/
contentChanges: TextDocumentContentChangeEvent[];
}
/**
* The document change notification is sent from the client to the server to signal
* changes to a text document.
*/
export declare namespace DidChangeTextDocumentNotification {
const type: NotificationType<DidChangeTextDocumentParams>;
}
/**
* The parameters send in a close text document notification
*/
export interface DidCloseTextDocumentParams {
/**
* The document that was closed.
*/
textDocument: TextDocumentIdentifier;
}
/**
* The document close notification is sent from the client to the server when
* the document got closed in the client. The document's truth now exists
* where the document's uri points to (e.g. if the document's uri is a file uri
* the truth now exists on disk).
*/
export declare namespace DidCloseTextDocumentNotification {
const type: NotificationType<DidCloseTextDocumentParams>;
}
/**
* The parameters send in a save text document notification
*/
export interface DidSaveTextDocumentParams {
/**
* The document that was closed.
*/
textDocument: TextDocumentIdentifier;
}
/**
* The document save notification is sent from the client to the server when
* the document got saved in the client.
*/
export declare namespace DidSaveTextDocumentNotification {
const type: NotificationType<DidSaveTextDocumentParams>;
}
/**
* The watched files notification is sent from the client to the server when
* the client detects changes to file watched by the lanaguage client.
*/
export declare namespace DidChangeWatchedFilesNotification {
const type: NotificationType<DidChangeWatchedFilesParams>;
}
/**
* The watched files change notification's parameters.
*/
export interface DidChangeWatchedFilesParams {
/**
* The actual file events.
*/
changes: FileEvent[];
}
/**
* The file event type
*/
export declare enum FileChangeType {
/**
* The file got created.
*/
Created = 1,
/**
* The file got changed.
*/
Changed = 2,
/**
* The file got deleted.
*/
Deleted = 3,
}
/**
* An event describing a file change.
*/
export interface FileEvent {
/**
* The file's uri.
*/
uri: string;
/**
* The change type.
*/
type: number;
}
/**
* Diagnostics notification are sent from the server to the client to signal
* results of validation runs.
*/
export declare namespace PublishDiagnosticsNotification {
const type: NotificationType<PublishDiagnosticsParams>;
}
/**
* The publish diagnostic notification's parameters.
*/
export interface PublishDiagnosticsParams {
/**
* The URI for which diagnostic information is reported.
*/
uri: string;
/**
* An array of diagnostic information items.
*/
diagnostics: Diagnostic[];
}
/**
* Request to request completion at a given text document position. The request's
* parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
* is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
* or a Thenable that resolves to such.
*/
export declare namespace CompletionRequest {
const type: RequestType<TextDocumentPositionParams, CompletionItem[] | CompletionList, void>;
}
/**
* Request to resolve additional information for a given completion item.The request's
* parameter is of type [CompletionItem](#CompletionItem) the response
* is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
*/
export declare namespace CompletionResolveRequest {
const type: RequestType<CompletionItem, CompletionItem, void>;
}
export declare type MarkedString = string | {
language: string;
value: string;
};
/**
* Request to request hover information at a given text document position. The request's
* parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
* type [Hover](#Hover) or a Thenable that resolves to such.
*/
export declare namespace HoverRequest {
const type: RequestType<TextDocumentPositionParams, Hover, void>;
}
export declare namespace SignatureHelpRequest {
const type: RequestType<TextDocumentPositionParams, SignatureHelp, void>;
}
/**
* A request to resolve the defintion location of a symbol at a given text
* document position. The request's parameter is of type [TextDocumentPosition]
* (#TextDocumentPosition) the response is of type [Definition](#Definition) or a
* Thenable that resolves to such.
*/
export declare namespace DefinitionRequest {
const type: RequestType<TextDocumentPositionParams, Definition, void>;
}
/**
* Parameters for a [ReferencesRequest](#ReferencesRequest).
*/
export interface ReferenceParams extends TextDocumentPositionParams {
context: ReferenceContext;
}
/**
* A request to resolve project-wide references for the symbol denoted
* by the given text document position. The request's parameter is of
* type [ReferenceParams](#ReferenceParams) the response is of type
* [Location[]](#Location) or a Thenable that resolves to such.
*/
export declare namespace ReferencesRequest {
const type: RequestType<ReferenceParams, Location[], void>;
}
/**
* Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
* text document position. The request's parameter is of type [TextDocumentPosition]
* (#TextDocumentPosition) the request reponse is of type [DocumentHighlight[]]
* (#DocumentHighlight) or a Thenable that resolves to such.
*/
export declare namespace DocumentHighlightRequest {
const type: RequestType<TextDocumentPositionParams, DocumentHighlight[], void>;
}
/**
* Parameters for a [DocumentSymbolRequest](#DocumentSymbolRequest).
*/
export interface DocumentSymbolParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
}
/**
* A request to list all symbols found in a given text document. The request's
* parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
* response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
* that resolves to such.
*/
export declare namespace DocumentSymbolRequest {
const type: RequestType<DocumentSymbolParams, SymbolInformation[], void>;
}
/**
* The parameters of a [WorkspaceSymbolRequest](#WorkspaceSymbolRequest).
*/
export interface WorkspaceSymbolParams {
/**
* A non-empty query string
*/
query: string;
}
/**
* A request to list project-wide symbols matching the query string given
* by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
* of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
* resolves to such.
*/
export declare namespace WorkspaceSymbolRequest {
const type: RequestType<WorkspaceSymbolParams, SymbolInformation[], void>;
}
/**
* Params for the CodeActionRequest
*/
export interface CodeActionParams {
/**
* The document in which the command was invoked.
*/
textDocument: TextDocumentIdentifier;
/**
* The range for which the command was invoked.
*/
range: Range;
/**
* Context carrying additional information.
*/
context: CodeActionContext;
}
/**
* A request to provide commands for the given text document and range.
*/
export declare namespace CodeActionRequest {
const type: RequestType<CodeActionParams, Command[], void>;
}
/**
* Params for the Code Lens request.
*/
export interface CodeLensParams {
/**
* The document to request code lens for.
*/
textDocument: TextDocumentIdentifier;
}
/**
* A request to provide code lens for the given text document.
*/
export declare namespace CodeLensRequest {
const type: RequestType<CodeLensParams, CodeLens[], void>;
}
/**
* A request to resolve a command for a given code lens.
*/
export declare namespace CodeLensResolveRequest {
const type: RequestType<CodeLens, CodeLens, void>;
}
export interface DocumentFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The format options
*/
options: FormattingOptions;
}
/**
* A request to to format a whole document.
*/
export declare namespace DocumentFormattingRequest {
const type: RequestType<DocumentFormattingParams, TextEdit[], void>;
}
export interface DocumentRangeFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The range to format
*/
range: Range;
/**
* The format options
*/
options: FormattingOptions;
}
/**
* A request to to format a range in a document.
*/
export declare namespace DocumentRangeFormattingRequest {
const type: RequestType<DocumentRangeFormattingParams, TextEdit[], void>;
}
export interface DocumentOnTypeFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The position at which this request was send.
*/
position: Position;
/**
* The character that has been typed.
*/
ch: string;
/**
* The format options.
*/
options: FormattingOptions;
}
/**
* A request to format a document on type.
*/
export declare namespace DocumentOnTypeFormattingRequest {
const type: RequestType<DocumentOnTypeFormattingParams, TextEdit[], void>;
}
export interface RenameParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The position at which this request was send.
*/
position: Position;
/**
* The new name of the symbol. If the given name is not valid the
* request must return a [ResponseError](#ResponseError) with an
* appropriate message set.
*/
newName: string;
}
/**
* A request to rename a symbol.
*/
export declare namespace RenameRequest {
const type: RequestType<RenameParams, WorkspaceEdit, void>;
}
export interface DocumentLinkParams {
/**
* The document to provide document links for.
*/
textDocument: TextDocumentIdentifier;
}
/**
* A request to provide document links
*/
export declare namespace DocumentLinkRequest {
const type: RequestType<DocumentLinkParams, DocumentLink[], void>;
}
/**
* Request to resolve additional information for a given document link. The request's
* parameter is of type [DocumentLink](#DocumentLink) the response
* is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
*/
export declare namespace DocumentLinkResolveRequest {
const type: RequestType<DocumentLink, DocumentLink, void>;
}

View File

@ -1,347 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
/**
* Defines how the host (editor) should sync
* document changes to the language server.
*/
(function (TextDocumentSyncKind) {
/**
* Documents should not be synced at all.
*/
TextDocumentSyncKind[TextDocumentSyncKind["None"] = 0] = "None";
/**
* Documents are synced by always sending the full content
* of the document.
*/
TextDocumentSyncKind[TextDocumentSyncKind["Full"] = 1] = "Full";
/**
* Documents are synced by sending the full content on open.
* After that only incremental updates to the document are
* send.
*/
TextDocumentSyncKind[TextDocumentSyncKind["Incremental"] = 2] = "Incremental";
})(exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
var TextDocumentSyncKind = exports.TextDocumentSyncKind;
/**
* The initialize method is sent from the client to the server.
* It is send once as the first method after starting up the
* worker. The requests parameter is of type [InitializeParams](#InitializeParams)
* the response if of type [InitializeResult](#InitializeResult) of a Thenable that
* resolves to such.
*/
var InitializeRequest;
(function (InitializeRequest) {
InitializeRequest.type = { get method() { return 'initialize'; } };
})(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
//---- Shutdown Method ----
/**
* A shutdown request is sent from the client to the server.
* It is send once when the client descides to shutdown the
* server. The only notification that is sent after a shudown request
* is the exit event.
*/
var ShutdownRequest;
(function (ShutdownRequest) {
ShutdownRequest.type = { get method() { return 'shutdown'; } };
})(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
//---- Exit Notification ----
/**
* The exit event is sent from the client to the server to
* ask the server to exit its process.
*/
var ExitNotification;
(function (ExitNotification) {
ExitNotification.type = { get method() { return 'exit'; } };
})(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
//---- Configuration notification ----
/**
* The configuration change notification is sent from the client to the server
* when the client's configuration has changed. The notification contains
* the changed configuration as defined by the language client.
*/
var DidChangeConfigurationNotification;
(function (DidChangeConfigurationNotification) {
DidChangeConfigurationNotification.type = { get method() { return 'workspace/didChangeConfiguration'; } };
})(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
//---- Message show and log notifications ----
/**
* The message type
*/
(function (MessageType) {
/**
* An error message.
*/
MessageType[MessageType["Error"] = 1] = "Error";
/**
* A warning message.
*/
MessageType[MessageType["Warning"] = 2] = "Warning";
/**
* An information message.
*/
MessageType[MessageType["Info"] = 3] = "Info";
/**
* A log message.
*/
MessageType[MessageType["Log"] = 4] = "Log";
})(exports.MessageType || (exports.MessageType = {}));
var MessageType = exports.MessageType;
/**
* The show message notification is sent from a server to a client to ask
* the client to display a particular message in the user interface.
*/
var ShowMessageNotification;
(function (ShowMessageNotification) {
ShowMessageNotification.type = { get method() { return 'window/showMessage'; } };
})(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
/**
* The show message request is send from the server to the clinet to show a message
* and a set of options actions to the user.
*/
var ShowMessageRequest;
(function (ShowMessageRequest) {
ShowMessageRequest.type = { get method() { return 'window/showMessageRequest'; } };
})(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
/**
* The log message notification is send from the server to the client to ask
* the client to log a particular message.
*/
var LogMessageNotification;
(function (LogMessageNotification) {
LogMessageNotification.type = { get method() { return 'window/logMessage'; } };
})(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
//---- Telemetry notification
/**
* The telemetry event notification is send from the server to the client to ask
* the client to log telemetry data.
*/
var TelemetryEventNotification;
(function (TelemetryEventNotification) {
TelemetryEventNotification.type = { get method() { return 'telemetry/event'; } };
})(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
/**
* The document open notification is sent from the client to the server to signal
* newly opened text documents. The document's truth is now managed by the client
* and the server must not try to read the document's truth using the document's
* uri.
*/
var DidOpenTextDocumentNotification;
(function (DidOpenTextDocumentNotification) {
DidOpenTextDocumentNotification.type = { get method() { return 'textDocument/didOpen'; } };
})(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
/**
* The document change notification is sent from the client to the server to signal
* changes to a text document.
*/
var DidChangeTextDocumentNotification;
(function (DidChangeTextDocumentNotification) {
DidChangeTextDocumentNotification.type = { get method() { return 'textDocument/didChange'; } };
})(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
/**
* The document close notification is sent from the client to the server when
* the document got closed in the client. The document's truth now exists
* where the document's uri points to (e.g. if the document's uri is a file uri
* the truth now exists on disk).
*/
var DidCloseTextDocumentNotification;
(function (DidCloseTextDocumentNotification) {
DidCloseTextDocumentNotification.type = { get method() { return 'textDocument/didClose'; } };
})(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
/**
* The document save notification is sent from the client to the server when
* the document got saved in the client.
*/
var DidSaveTextDocumentNotification;
(function (DidSaveTextDocumentNotification) {
DidSaveTextDocumentNotification.type = { get method() { return 'textDocument/didSave'; } };
})(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
//---- File eventing ----
/**
* The watched files notification is sent from the client to the server when
* the client detects changes to file watched by the lanaguage client.
*/
var DidChangeWatchedFilesNotification;
(function (DidChangeWatchedFilesNotification) {
DidChangeWatchedFilesNotification.type = { get method() { return 'workspace/didChangeWatchedFiles'; } };
})(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
/**
* The file event type
*/
(function (FileChangeType) {
/**
* The file got created.
*/
FileChangeType[FileChangeType["Created"] = 1] = "Created";
/**
* The file got changed.
*/
FileChangeType[FileChangeType["Changed"] = 2] = "Changed";
/**
* The file got deleted.
*/
FileChangeType[FileChangeType["Deleted"] = 3] = "Deleted";
})(exports.FileChangeType || (exports.FileChangeType = {}));
var FileChangeType = exports.FileChangeType;
//---- Diagnostic notification ----
/**
* Diagnostics notification are sent from the server to the client to signal
* results of validation runs.
*/
var PublishDiagnosticsNotification;
(function (PublishDiagnosticsNotification) {
PublishDiagnosticsNotification.type = { get method() { return 'textDocument/publishDiagnostics'; } };
})(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
//---- Completion Support --------------------------
/**
* Request to request completion at a given text document position. The request's
* parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
* is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
* or a Thenable that resolves to such.
*/
var CompletionRequest;
(function (CompletionRequest) {
CompletionRequest.type = { get method() { return 'textDocument/completion'; } };
})(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
/**
* Request to resolve additional information for a given completion item.The request's
* parameter is of type [CompletionItem](#CompletionItem) the response
* is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
*/
var CompletionResolveRequest;
(function (CompletionResolveRequest) {
CompletionResolveRequest.type = { get method() { return 'completionItem/resolve'; } };
})(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
/**
* Request to request hover information at a given text document position. The request's
* parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
* type [Hover](#Hover) or a Thenable that resolves to such.
*/
var HoverRequest;
(function (HoverRequest) {
HoverRequest.type = { get method() { return 'textDocument/hover'; } };
})(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
//---- SignatureHelp ----------------------------------
var SignatureHelpRequest;
(function (SignatureHelpRequest) {
SignatureHelpRequest.type = { get method() { return 'textDocument/signatureHelp'; } };
})(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
//---- Goto Definition -------------------------------------
/**
* A request to resolve the defintion location of a symbol at a given text
* document position. The request's parameter is of type [TextDocumentPosition]
* (#TextDocumentPosition) the response is of type [Definition](#Definition) or a
* Thenable that resolves to such.
*/
var DefinitionRequest;
(function (DefinitionRequest) {
DefinitionRequest.type = { get method() { return 'textDocument/definition'; } };
})(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
/**
* A request to resolve project-wide references for the symbol denoted
* by the given text document position. The request's parameter is of
* type [ReferenceParams](#ReferenceParams) the response is of type
* [Location[]](#Location) or a Thenable that resolves to such.
*/
var ReferencesRequest;
(function (ReferencesRequest) {
ReferencesRequest.type = { get method() { return 'textDocument/references'; } };
})(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
//---- Document Highlight ----------------------------------
/**
* Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
* text document position. The request's parameter is of type [TextDocumentPosition]
* (#TextDocumentPosition) the request reponse is of type [DocumentHighlight[]]
* (#DocumentHighlight) or a Thenable that resolves to such.
*/
var DocumentHighlightRequest;
(function (DocumentHighlightRequest) {
DocumentHighlightRequest.type = { get method() { return 'textDocument/documentHighlight'; } };
})(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
/**
* A request to list all symbols found in a given text document. The request's
* parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
* response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
* that resolves to such.
*/
var DocumentSymbolRequest;
(function (DocumentSymbolRequest) {
DocumentSymbolRequest.type = { get method() { return 'textDocument/documentSymbol'; } };
})(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
/**
* A request to list project-wide symbols matching the query string given
* by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
* of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
* resolves to such.
*/
var WorkspaceSymbolRequest;
(function (WorkspaceSymbolRequest) {
WorkspaceSymbolRequest.type = { get method() { return 'workspace/symbol'; } };
})(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
/**
* A request to provide commands for the given text document and range.
*/
var CodeActionRequest;
(function (CodeActionRequest) {
CodeActionRequest.type = { get method() { return 'textDocument/codeAction'; } };
})(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
/**
* A request to provide code lens for the given text document.
*/
var CodeLensRequest;
(function (CodeLensRequest) {
CodeLensRequest.type = { get method() { return 'textDocument/codeLens'; } };
})(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
/**
* A request to resolve a command for a given code lens.
*/
var CodeLensResolveRequest;
(function (CodeLensResolveRequest) {
CodeLensResolveRequest.type = { get method() { return 'codeLens/resolve'; } };
})(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
/**
* A request to to format a whole document.
*/
var DocumentFormattingRequest;
(function (DocumentFormattingRequest) {
DocumentFormattingRequest.type = { get method() { return 'textDocument/formatting'; } };
})(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
/**
* A request to to format a range in a document.
*/
var DocumentRangeFormattingRequest;
(function (DocumentRangeFormattingRequest) {
DocumentRangeFormattingRequest.type = { get method() { return 'textDocument/rangeFormatting'; } };
})(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
/**
* A request to format a document on type.
*/
var DocumentOnTypeFormattingRequest;
(function (DocumentOnTypeFormattingRequest) {
DocumentOnTypeFormattingRequest.type = { get method() { return 'textDocument/onTypeFormatting'; } };
})(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
/**
* A request to rename a symbol.
*/
var RenameRequest;
(function (RenameRequest) {
RenameRequest.type = { get method() { return 'textDocument/rename'; } };
})(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
/**
* A request to provide document links
*/
var DocumentLinkRequest;
(function (DocumentLinkRequest) {
DocumentLinkRequest.type = { get method() { return 'textDocument/documentLink'; } };
})(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
/**
* Request to resolve additional information for a given document link. The request's
* parameter is of type [DocumentLink](#DocumentLink) the response
* is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
*/
var DocumentLinkResolveRequest;
(function (DocumentLinkResolveRequest) {
DocumentLinkResolveRequest.type = { get method() { return 'documentLink/resolve'; } };
})(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));

View File

@ -1,6 +0,0 @@
interface Message {
command: string;
success?: boolean;
args?: any;
result?: any;
}

View File

@ -1,19 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
process.on('message', function (message) {
if (message.command === 'exit') {
process.exit(0);
}
else if (message.command === 'resolve') {
try {
var result = require.resolve(message.args);
process.send({ command: 'resolve', success: true, result: result });
}
catch (err) {
process.send({ command: 'resolve', success: false });
}
}
});

Some files were not shown because too many files have changed in this diff Show More