SQL Operations Studio Public Preview 1 (0.23) release source code

This commit is contained in:
Karl Burtram
2017-11-09 14:30:27 -08:00
parent b88ecb8d93
commit 3cdac41339
8829 changed files with 759707 additions and 286 deletions

View File

@@ -0,0 +1,24 @@
{
"rules": {
"indent": [
2,
"tab"
],
"quotes": [
2,
"single"
],
"linebreak-style": [
2,
"windows"
],
"semi": [
2,
"always"
]
},
"env": {
"node": true
},
"extends": "eslint:recommended"
}

View File

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

View File

@@ -0,0 +1,32 @@
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
{
"request": "launch",
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Mocha",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "node_modules/mocha/bin/_mocha",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": ["--timeout", "999999"],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": ".",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Optional arguments passed to the runtime executable.
"runtimeArgs": [],
// Environment variables passed to the program.
"env": { },
// Use JavaScript source maps (if they exist).
"sourceMaps": true,
// If JavaScript source maps are enabled, the generated code is expected in this directory.
"outDir": "lib"
}
]
}

View File

@@ -0,0 +1,11 @@
// Place your settings in this file to overwrite default and user settings.
{
"javascript.validate.enable": false,
"files.trimTrailingWhitespace": true,
"eslint.enable": false,
"editor.insertSpaces": false,
"editor.tabSize": 4,
"tslint.enable": false,
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.tsserver.trace": "off"
}

View File

@@ -0,0 +1,9 @@
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"args": ["run", "watch"],
"showOutput": "silent",
"isWatching": true,
"problemMatcher": "$tsc-watch"
}

View File

@@ -0,0 +1,4 @@
# Microsoft Data Management Protocol - Node
## License
[Source EULA](https://github.com/Microsoft/sqlopsstudio/blob/dev/license.txt)

View File

@@ -0,0 +1,32 @@
{
"name": "dataprotocol-client",
"description": "VSCode Language client implementation",
"version": "2.6.3",
"author": "Microsoft Corporation",
"license": "MIT",
"engines": {
"vscode": "^1.5.0"
},
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-languageserver-node.git"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-languageserver-node/issues"
},
"main": "./lib/main.js",
"typings": "./lib/main",
"devDependencies": {
"typescript": "2.0.3"
},
"dependencies": {
"dataprotocol-jsonrpc": "file:../jsonrpc",
"dataprotocol-languageserver-types": "file:../types"
},
"scripts": {
"prepublish": "tsc -p ./src",
"compile": "tsc -p ./src",
"watch": "tsc -w -p ./src",
"update-vscode": "node ./node_modules/vscode/bin/install"
}
}

View File

@@ -0,0 +1,526 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import * as code from 'vscode';
import * as data from 'data';
import * as ls from 'dataprotocol-languageserver-types';
import * as proto from './protocol';
import * as is from './utils/is';
import ProtocolCompletionItem from './protocolCompletionItem';
import ProtocolCodeLens from './protocolCodeLens';
import os = require('os');
import path = require('path');
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;
asConnectionParams(connectionUri: string, connectionInfo: data.ConnectionInfo): proto.ConnectParams;
asCapabilitiesParams(client: data.DataProtocolClientCapabilities): proto.CapabiltiesDiscoveryParams;
asMetadataQueryParams(connectionUri: string): ls.MetadataQueryParams;
asListDatabasesParams(connectionUri: string): proto.ListDatabasesParams;
asTableMetadataParams(connectionUri: string, metadata: data.ObjectMetadata): proto.TableMetadataParams;
asScriptingParams(connectionUri: string, operation: ls.ScriptOperation, metadata: data.ObjectMetadata, paramDetails: data.ScriptingParamDetails): ls.ScriptingParams;
asConnectionDetail(connInfo: data.ConnectionInfo): ls.ConnectionDetails;
asExpandInfo(nodeInfo: data.ExpandNodeInfo): ls.ExpandParams;
asCloseSessionInfo(nodeInfo: data.ObjectExplorerCloseSessionInfo): ls.CloseSessionParams;
asExecutionPlanOptions(planOptions: data.ExecutionPlanOptions): proto.ExecutionPlanOptions;
asListTasksParams(params: data.ListTasksParams): ls.ListTasksParams;
asCancelTaskParams(params: data.CancelTaskParams): ls.CancelTaskParams;
asRestoreParams(ownerUri: string, params: data.RestoreInfo): ls.RestoreParams;
asRestoreConfigInfoParams(ownerUri: string): ls.RestoreConfigInfoRequestParams;
}
export interface URIConverter {
(value: code.Uri): string;
}
export function createConverter(uriConverter?: URIConverter): Converter {
const nullConverter = (value: code.Uri) => value.toString();
const _uriConverter: URIConverter = uriConverter || nullConverter;
function asUri(value: code.Uri): string {
return _uriConverter(value);
}
function asTextDocumentIdentifier(textDocument: code.TextDocument): ls.TextDocumentIdentifier {
return {
uri: _uriConverter(textDocument.uri)
};
}
function asOpenTextDocumentParams(textDocument: code.TextDocument): proto.DidOpenTextDocumentParams {
return {
textDocument: {
uri: _uriConverter(textDocument.uri),
languageId: textDocument.languageId,
version: textDocument.version,
text: textDocument.getText()
}
};
}
function isTextDocumentChangeEvent(value: any): value is code.TextDocumentChangeEvent {
let candidate = <code.TextDocumentChangeEvent>value;
return is.defined(candidate.document) && is.defined(candidate.contentChanges);
}
function isTextDocument(value: any): value is code.TextDocument {
let candidate = <code.TextDocument>value;
return is.defined(candidate.uri) && is.defined(candidate.version);
}
function asChangeTextDocumentParams(textDocument: code.TextDocument): proto.DidChangeTextDocumentParams;
function asChangeTextDocumentParams(event: code.TextDocumentChangeEvent): proto.DidChangeTextDocumentParams;
function asChangeTextDocumentParams(arg: code.TextDocumentChangeEvent | code.TextDocument): proto.DidChangeTextDocumentParams {
if (isTextDocument(arg)) {
let result: proto.DidChangeTextDocumentParams = {
textDocument: {
uri: _uriConverter(arg.uri),
version: arg.version
},
contentChanges: [{ text: arg.getText() }]
}
return result;
} else if (isTextDocumentChangeEvent(arg)) {
let document = arg.document;
let result: proto.DidChangeTextDocumentParams = {
textDocument: {
uri: _uriConverter(document.uri),
version: document.version
},
contentChanges: arg.contentChanges.map((change): proto.TextDocumentContentChangeEvent => {
let 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: code.TextDocument): proto.DidCloseTextDocumentParams {
return {
textDocument: asTextDocumentIdentifier(textDocument)
};
}
function asSaveTextDocumentParams(textDocument: code.TextDocument): proto.DidSaveTextDocumentParams {
return {
textDocument: asTextDocumentIdentifier(textDocument)
}
}
function asTextDocumentPositionParams(textDocument: code.TextDocument, position: code.Position): proto.TextDocumentPositionParams {
return {
textDocument: asTextDocumentIdentifier(textDocument),
position: asWorkerPosition(position)
};
}
function asWorkerPosition(position: code.Position): ls.Position {
return { line: position.line, character: position.character };
}
function asRange(value: code.Range): ls.Range {
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: code.Position): ls.Position {
if (is.undefined(value)) {
return undefined;
} else if (is.nil(value)) {
return null;
}
return { line: value.line, character: value.character };
}
function set(value, func: () => void): void {
if (is.defined(value)) {
func();
}
}
function asDiagnosticSeverity(value: code.DiagnosticSeverity): ls.DiagnosticSeverity {
switch (value) {
case code.DiagnosticSeverity.Error:
return ls.DiagnosticSeverity.Error;
case code.DiagnosticSeverity.Warning:
return ls.DiagnosticSeverity.Warning;
case code.DiagnosticSeverity.Information:
return ls.DiagnosticSeverity.Information;
case code.DiagnosticSeverity.Hint:
return ls.DiagnosticSeverity.Hint;
}
}
function asDiagnostic(item: code.Diagnostic): ls.Diagnostic {
let result: ls.Diagnostic = ls.Diagnostic.create(asRange(item.range), item.message);
set(item.severity, () => result.severity = asDiagnosticSeverity(item.severity));
set(item.code, () => result.code = item.code);
set(item.source, () => result.source = item.source);
return result;
}
function asDiagnostics(items: code.Diagnostic[]): ls.Diagnostic[] {
if (is.undefined(items) || is.nil(items)) {
return items;
}
return items.map(asDiagnostic);
}
function asCompletionItem(item: code.CompletionItem): ls.CompletionItem {
let result: ls.CompletionItem = { label: item.label };
set(item.detail, () => result.detail = item.detail);
set(item.documentation, () => result.documentation = item.documentation);
set(item.filterText, () => result.filterText = item.filterText);
set(item.insertText, () => result.insertText = String(item.insertText));
// Protocol item kind is 1 based, codes item kind is zero based.
set(item.kind, () => result.kind = item.kind + 1);
set(item.sortText, () => result.sortText = item.sortText);
set(item.textEdit, () => result.textEdit = asTextEdit(item.textEdit));
set(item.additionalTextEdits, () => result.additionalTextEdits = asTextEdits(item.additionalTextEdits));
set(item.command, () => result.command = asCommand(item.command));
if (item instanceof ProtocolCompletionItem) {
set(item.data, () => result.data = item.data);
}
return result;
}
function asTextEdit(edit: code.TextEdit): ls.TextEdit {
return { range: asRange(edit.range), newText: edit.newText };
}
function asTextEdits(edits: code.TextEdit[]): ls.TextEdit[] {
if (is.undefined(edits) || is.nil(edits)) {
return edits;
}
return edits.map(asTextEdit);
}
function asReferenceParams(textDocument: code.TextDocument, position: code.Position, options: { includeDeclaration: boolean; }): proto.ReferenceParams {
return {
textDocument: asTextDocumentIdentifier(textDocument),
position: asWorkerPosition(position),
context: { includeDeclaration: options.includeDeclaration }
};
}
function asCodeActionContext(context: code.CodeActionContext): ls.CodeActionContext {
if (is.undefined(context) || is.nil(context)) {
return context;
}
return ls.CodeActionContext.create(asDiagnostics(context.diagnostics));
}
function asCommand(item: code.Command): ls.Command {
let result = ls.Command.create(item.title, item.command);
if (is.defined(item.arguments)) result.arguments = item.arguments;
return result;
}
function asCodeLens(item: code.CodeLens): ls.CodeLens {
let result = ls.CodeLens.create(asRange(item.range));
if (is.defined(item.command)) result.command = asCommand(item.command);
if (item instanceof ProtocolCodeLens) {
if (is.defined(item.data)) result.data = item.data;
}
return result;
}
function asFormattingOptions(item: code.FormattingOptions): ls.FormattingOptions {
return { tabSize: item.tabSize, insertSpaces: item.insertSpaces };
}
function asDocumentSymbolParams(textDocument: code.TextDocument): proto.DocumentSymbolParams {
return {
textDocument: asTextDocumentIdentifier(textDocument)
}
}
function asCodeLensParams(textDocument: code.TextDocument): proto.CodeLensParams {
return {
textDocument: asTextDocumentIdentifier(textDocument)
};
}
function asDocumentLink(item: code.DocumentLink): ls.DocumentLink {
let result = ls.DocumentLink.create(asRange(item.range));
if (is.defined(item.target)) result.target = asUri(item.target);
return result;
}
function asDocumentLinkParams(textDocument: code.TextDocument): proto.DocumentLinkParams {
return {
textDocument: asTextDocumentIdentifier(textDocument)
};
}
function asCapabilitiesParams(client: data.DataProtocolClientCapabilities): proto.CapabiltiesDiscoveryParams {
let params: proto.CapabiltiesDiscoveryParams = {
hostName: client.hostName,
hostVersion: client.hostVersion
};
return params;
}
function asConnectionParams(connUri: string, connInfo: data.ConnectionInfo): proto.ConnectParams {
return {
ownerUri: connUri,
connection: {
options: connInfo.options
}
};
}
function asMetadataQueryParams(connectionUri: string): ls.MetadataQueryParams {
return <ls.MetadataQueryParams>{
ownerUri: connectionUri
};
}
function asListDatabasesParams(connectionUri: string): proto.ListDatabasesParams {
return <proto.ListDatabasesParams>{
ownerUri: connectionUri
};
}
function asTableMetadataParams(connectionUri: string, metadata: data.ObjectMetadata): proto.TableMetadataParams {
return <proto.TableMetadataParams>{
ownerUri: connectionUri,
schema: metadata.schema,
objectName: metadata.name
};
}
function asScriptingParams(connectionUri: string, operation: ls.ScriptOperation, metadata: data.ObjectMetadata, paramDetails: data.ScriptingParamDetails): ls.ScriptingParams {
let scriptingObject: ls.ScriptingObject = {
type: metadata.metadataTypeName,
schema: metadata.schema,
name: metadata.name
}
let targetDatabaseEngineEdition = paramDetails.targetDatabaseEngineEdition;
let targetDatabaseEngineType = paramDetails.targetDatabaseEngineType;
let scriptCompatibilityOption = paramDetails.scriptCompatibilityOption;
let options: ls.ScriptOptions = {
scriptCreateDrop: (operation === ls.ScriptOperation.Delete) ? "ScriptDrop" :
(operation === ls.ScriptOperation.Select) ? "ScriptSelect" : "ScriptCreate",
typeOfDataToScript: "SchemaOnly",
scriptStatistics: "ScriptStatsNone",
targetDatabaseEngineEdition: targetDatabaseEngineEdition ? targetDatabaseEngineEdition : "SqlServerEnterpriseEdition",
targetDatabaseEngineType: targetDatabaseEngineType ? targetDatabaseEngineType : "SingleInstance",
scriptCompatibilityOption: scriptCompatibilityOption ? scriptCompatibilityOption : "Script140Compat"
}
return <ls.ScriptingParams> {
connectionString: null,
filePath: paramDetails.filePath,
scriptingObjects: [scriptingObject],
scriptDestination: "ToEditor",
includeObjectCriteria: null,
excludeObjectCriteria: null,
includeSchemas: null,
excludeSchemas: null,
includeTypes: null,
excludeTypes: null,
scriptOptions: options,
connectionDetails: null,
ownerURI: connectionUri,
operation: operation
};
}
function asConnectionDetail(connInfo: data.ConnectionInfo): ls.ConnectionDetails {
return <ls.ConnectionDetails>{
options: connInfo.options
};
}
function asExpandInfo(nodeInfo: data.ExpandNodeInfo): ls.ExpandParams {
return <ls.ExpandParams>{
sessionId: nodeInfo.sessionId,
nodePath: nodeInfo.nodePath
};
}
function asCloseSessionInfo(nodeInfo: data.ObjectExplorerCloseSessionInfo): ls.CloseSessionParams {
return <ls.CloseSessionParams>{
sessionId: nodeInfo.sessionId
};
}
function asExecutionPlanOptions(planOptions: data.ExecutionPlanOptions): proto.ExecutionPlanOptions {
return <proto.ExecutionPlanOptions>{
includeEstimatedExecutionPlanXml: planOptions ? planOptions.displayEstimatedQueryPlan : undefined,
includeActualExecutionPlanXml: planOptions ? planOptions.displayActualQueryPlan : undefined
};
}
function asListTasksParams(params: data.ListTasksParams): ls.ListTasksParams {
return <ls.ListTasksParams>{
listActiveTasksOnly: params.listActiveTasksOnly
};
}
function asCancelTaskParams(params: data.CancelTaskParams): ls.CancelTaskParams {
return <ls.CancelTaskParams>{
taskId: params.taskId
};
}
function asRestoreParams(ownerUri: string, params: data.RestoreInfo): ls.RestoreParams {
return <ls.RestoreParams>{
ownerUri: ownerUri,
options: params.options,
taskExecutionMode: params.taskExecutionMode
};
}
function asRestoreConfigInfoParams(ownerUri: string): ls.RestoreConfigInfoRequestParams {
return <ls.RestoreConfigInfoRequestParams>{
ownerUri: ownerUri
};
}
return {
asUri,
asTextDocumentIdentifier,
asOpenTextDocumentParams,
asChangeTextDocumentParams,
asCloseTextDocumentParams,
asSaveTextDocumentParams,
asTextDocumentPositionParams,
asWorkerPosition,
asRange,
asPosition,
asDiagnosticSeverity,
asDiagnostic,
asDiagnostics,
asCompletionItem,
asTextEdit,
asReferenceParams,
asCodeActionContext,
asCommand,
asCodeLens,
asFormattingOptions,
asDocumentSymbolParams,
asCodeLensParams,
asDocumentLink,
asDocumentLinkParams,
asCapabilitiesParams,
asConnectionParams,
asMetadataQueryParams,
asTableMetadataParams,
asListDatabasesParams,
asScriptingParams,
asConnectionDetail,
asExpandInfo,
asCloseSessionInfo,
asExecutionPlanOptions,
asListTasksParams,
asCancelTaskParams,
asRestoreParams,
asRestoreConfigInfoParams
};
}
// This for backward compatibility since we exported the converter functions as API.
let defaultConverter = createConverter();
export const asTextDocumentIdentifier: (textDocument: code.TextDocument) => ls.TextDocumentIdentifier = defaultConverter.asTextDocumentIdentifier;
export const asOpenTextDocumentParams: (textDocument: code.TextDocument) => proto.DidOpenTextDocumentParams = defaultConverter.asOpenTextDocumentParams;
export const asChangeTextDocumentParams: (arg: code.TextDocumentChangeEvent | code.TextDocument) => proto.DidChangeTextDocumentParams = defaultConverter.asChangeTextDocumentParams;
export const asCloseTextDocumentParams: (textDocument: code.TextDocument) => proto.DidCloseTextDocumentParams = defaultConverter.asCloseTextDocumentParams;
export const asSaveTextDocumentParams: (textDocument: code.TextDocument) => proto.DidSaveTextDocumentParams = defaultConverter.asSaveTextDocumentParams;
export const asTextDocumentPositionParams: (textDocument: code.TextDocument, position: code.Position) => proto.TextDocumentPositionParams = defaultConverter.asTextDocumentPositionParams;
export const asWorkerPosition: (position: code.Position) => ls.Position = defaultConverter.asWorkerPosition;
export const asRange: (value: code.Range) => ls.Range = defaultConverter.asRange;
export const asPosition: (value: code.Position) => ls.Position = defaultConverter.asPosition;
export const asDiagnosticSeverity: (value: code.DiagnosticSeverity) => ls.DiagnosticSeverity = defaultConverter.asDiagnosticSeverity;
export const asDiagnostic: (item: code.Diagnostic) => ls.Diagnostic = defaultConverter.asDiagnostic;
export const asDiagnostics: (items: code.Diagnostic[]) => ls.Diagnostic[] = defaultConverter.asDiagnostics;
export const asCompletionItem: (item: code.CompletionItem) => ls.CompletionItem = defaultConverter.asCompletionItem;
export const asTextEdit: (edit: code.TextEdit) => ls.TextEdit = defaultConverter.asTextEdit;
export const asReferenceParams: (textDocument: code.TextDocument, position: code.Position, options: { includeDeclaration: boolean; }) => proto.ReferenceParams = defaultConverter.asReferenceParams;
export const asCodeActionContext: (context: code.CodeActionContext) => ls.CodeActionContext = defaultConverter.asCodeActionContext;
export const asCommand: (item: code.Command) => ls.Command = defaultConverter.asCommand;
export const asCodeLens: (item: code.CodeLens) => ls.CodeLens = defaultConverter.asCodeLens;
export const asFormattingOptions: (item: code.FormattingOptions) => ls.FormattingOptions = defaultConverter.asFormattingOptions;
export const asDocumentSymbolParams: (textDocument: code.TextDocument) => proto.DocumentSymbolParams = defaultConverter.asDocumentSymbolParams;
export const asCodeLensParams: (textDocument: code.TextDocument) => proto.CodeLensParams = defaultConverter.asCodeLensParams;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import * as code from 'vscode';
export default class ProtocolCodeLens extends code.CodeLens {
public data: any;
constructor(range: code.Range) {
super(range);
}
}

View File

@@ -0,0 +1,16 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import * as code from 'vscode';
export default class ProtocolCompletionItem extends code.CompletionItem {
public data: any;
constructor(label: string) {
super(label);
}
}

View File

@@ -0,0 +1,769 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import * as code from 'vscode';
import * as data from 'data';
import * as ls from 'dataprotocol-languageserver-types';
import * as is from './utils/is';
import ProtocolCompletionItem from './protocolCompletionItem';
import ProtocolCodeLens from './protocolCodeLens';
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[];
asConnectionSummary(params: ls.ConnectionCompleteParams): data.ConnectionInfoSummary;
asServerCapabilities(params: ls.CapabiltiesDiscoveryResult): data.DataProtocolServerCapabilities;
asProviderMetadata(params: ls.MetadataQueryResult): data.ProviderMetadata;
asScriptingResult(params: ls.ScriptingResult): data.ScriptingResult;
asObjectExplorerSession(params: ls.SessionCreatedParameters): data.ObjectExplorerSession;
asObjectExplorerCreateSessionResponse(params: ls.CreateSessionResponse): data.ObjectExplorerSessionResponse;
asObjectExplorerNodeInfo(params: ls.ExpandResponse): data.ObjectExplorerExpandInfo;
asObjectExplorerCloseSessionResponse(params: ls.CloseSessionResponse): data.ObjectExplorerCloseSessionResponse;
asListTasksResponse(response: ls.ListTasksResponse): data.ListTasksResponse;
asTaskInfo(params: ls.TaskInfo): data.TaskInfo;
asRestorePlanResponse(params: ls.RestorePlanResponse): data.RestorePlanResponse;
asRestoreResponse(params: ls.RestoreResponse): data.RestoreResponse;
asRestoreConfigInfo(params: ls.RestoreConfigInfoResponse): data.RestoreConfigInfo;
}
export interface URIConverter {
(value: string): code.Uri;
}
export function createConverter(uriConverter?: URIConverter): Converter {
const nullConverter = (value: string) => code.Uri.parse(value);
const _uriConverter: URIConverter = uriConverter || nullConverter;
function asUri(value: string): code.Uri {
return _uriConverter(value);
}
function asDiagnostics(diagnostics: ls.Diagnostic[]): code.Diagnostic[] {
return diagnostics.map(asDiagnostic);
}
function asDiagnostic(diagnostic: ls.Diagnostic): code.Diagnostic {
let 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: ls.Range): code.Range {
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: ls.Position): code.Position {
if (is.undefined(value)) {
return undefined;
} else if (is.nil(value)) {
return null;
}
return new code.Position(value.line, value.character);
}
function asDiagnosticSeverity(value: number): code.DiagnosticSeverity {
if (is.undefined(value) || is.nil(value)) {
return code.DiagnosticSeverity.Error;
}
switch (value) {
case ls.DiagnosticSeverity.Error:
return code.DiagnosticSeverity.Error;
case ls.DiagnosticSeverity.Warning:
return code.DiagnosticSeverity.Warning;
case ls.DiagnosticSeverity.Information:
return code.DiagnosticSeverity.Information;
case ls.DiagnosticSeverity.Hint:
return code.DiagnosticSeverity.Hint;
}
return code.DiagnosticSeverity.Error;
}
function asHover(hover: ls.Hover): code.Hover {
if (is.undefined(hover)) {
return undefined;
}
if (is.nil(hover)) {
return null;
}
if (is.nil(hover.contents) || is.undefined(hover.contents)) {
// Contents must be defined or hover will throw
return null;
}
return new code.Hover(hover.contents, is.defined(hover.range) ? asRange(hover.range) : undefined);
}
function asCompletionResult(result: ls.CompletionItem[] | ls.CompletionList): code.CompletionItem[] | code.CompletionList {
if (is.undefined(result)) {
return undefined;
} else if (is.nil(result)) {
return null;
}
if (Array.isArray(result)) {
let items = <ls.CompletionItem[]>result;
return items.map(asCompletionItem);
}
let list = <ls.CompletionList>result;
return new code.CompletionList(list.items.map(asCompletionItem), list.isIncomplete);
}
function set<T>(value: T, func: () => void): void {
if (is.defined(value)) {
func();
}
}
function asCompletionItem(item: ls.CompletionItem): ProtocolCompletionItem {
let result = new ProtocolCompletionItem(item.label);
set(item.detail, () => result.detail = item.detail);
set(item.documentation, () => result.documentation = item.documentation);
set(item.filterText, () => result.filterText = item.filterText);
set(item.insertText, () => result.insertText = item.insertText);
// Protocol item kind is 1 based, codes item kind is zero based.
set(item.kind, () => result.kind = item.kind - 1);
set(item.sortText, () => result.sortText = item.sortText);
set(item.textEdit, () => result.textEdit = asTextEdit(item.textEdit));
set(item.additionalTextEdits, () => result.additionalTextEdits = asTextEdits(item.additionalTextEdits));
set(item.command, () => result.command = asCommand(item.command));
set(item.data, () => result.data = item.data);
return result;
}
function asTextEdit(edit: ls.TextEdit): code.TextEdit {
return new code.TextEdit(asRange(edit.range), edit.newText);
}
function asTextEdits(items: ls.TextEdit[]): code.TextEdit[] {
if (is.undefined(items)) {
return undefined;
} else if (is.nil(items)) {
return null;
}
return items.map(asTextEdit);
}
function asSignatureHelp(item: ls.SignatureHelp): code.SignatureHelp {
if (is.undefined(item)) {
return undefined;
} else if (is.nil(item)) {
return null;
}
let result = new code.SignatureHelp();
set(item.activeParameter, () => result.activeParameter = item.activeParameter);
set(item.activeSignature, () => result.activeSignature = item.activeSignature);
set(item.signatures, () => result.signatures = asSignatureInformations(item.signatures));
return result;
}
function asSignatureInformations(items: ls.SignatureInformation[]): code.SignatureInformation[] {
return items ? items.map(asSignatureInformation) : undefined;
}
function asSignatureInformation(item: ls.SignatureInformation): code.SignatureInformation {
if (!item) {
return undefined;
}
let result = new code.SignatureInformation(item.label);
set(item.documentation, () => result.documentation = item.documentation);
set(item.parameters, () => result.parameters = asParameterInformations(item.parameters));
return result;
}
function asParameterInformations(item: ls.ParameterInformation[]): code.ParameterInformation[] {
return item.map(asParameterInformation);
}
function asParameterInformation(item: ls.ParameterInformation): code.ParameterInformation {
let result = new code.ParameterInformation(item.label);
set(item.documentation, () => result.documentation = item.documentation);
return result;
}
function asDefinitionResult(item: ls.Definition): code.Definition {
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: ls.Location): code.Location {
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: ls.Location[]): code.Location[] {
if (is.undefined(values)) {
return undefined;
}
if (is.nil(values)) {
return null;
}
return values.map(asLocation);
}
function asDocumentHighlights(values: ls.DocumentHighlight[]): code.DocumentHighlight[] {
if (is.undefined(values)) {
return undefined;
}
if (is.nil(values)) {
return null;
}
return values.map(asDocumentHighlight);
}
function asDocumentHighlight(item: ls.DocumentHighlight): code.DocumentHighlight {
let result = new code.DocumentHighlight(asRange(item.range));
set(item.kind, () => result.kind = asDocumentHighlightKind(item.kind));
return result;
}
function asDocumentHighlightKind(item: ls.DocumentHighlightKind): code.DocumentHighlightKind {
switch (item) {
case ls.DocumentHighlightKind.Text:
return code.DocumentHighlightKind.Text;
case ls.DocumentHighlightKind.Read:
return code.DocumentHighlightKind.Read;
case ls.DocumentHighlightKind.Write:
return code.DocumentHighlightKind.Write;
}
return code.DocumentHighlightKind.Text;
}
function asSymbolInformations(values: ls.SymbolInformation[], uri?: code.Uri): code.SymbolInformation[] {
if (is.undefined(values)) {
return undefined;
}
if (is.nil(values)) {
return null;
}
return values.map(information => asSymbolInformation(information, uri));
}
function asSymbolInformation(item: ls.SymbolInformation, uri?: code.Uri): code.SymbolInformation {
// Symbol kind is one based in the protocol and zero based in code.
let result = new code.SymbolInformation(
item.name, item.kind - 1,
asRange(item.location.range),
item.location.uri ? _uriConverter(item.location.uri) : uri);
set(item.containerName, () => result.containerName = item.containerName);
return result;
}
function asCommand(item: ls.Command): code.Command {
let result: code.Command = { title: item.title, command: item.command };
set(item.arguments, () => result.arguments = item.arguments);
return result;
}
function asCommands(items: ls.Command[]): code.Command[] {
if (is.undefined(items)) {
return undefined;
}
if (is.nil(items)) {
return null;
}
return items.map(asCommand);
}
function asCodeLens(item: ls.CodeLens): code.CodeLens {
let result: ProtocolCodeLens = new ProtocolCodeLens(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: ls.CodeLens[]): code.CodeLens[] {
if (is.undefined(items)) {
return undefined;
}
if (is.nil(items)) {
return null;
}
return items.map(asCodeLens);
}
function asWorkspaceEdit(item: ls.WorkspaceEdit): code.WorkspaceEdit {
if (is.undefined(item)) {
return undefined;
}
if (is.nil(item)) {
return null;
}
let result = new code.WorkspaceEdit();
let keys = Object.keys(item.changes);
keys.forEach(key => result.set(_uriConverter(key), asTextEdits(item.changes[key])));
return result;
}
function asDocumentLink(item: ls.DocumentLink): code.DocumentLink {
let range = asRange(item.range);
let target = is.defined(item.target) && asUri(item.target);
return new code.DocumentLink(range, target);
}
function asDocumentLinks(items: ls.DocumentLink[]): code.DocumentLink[] {
if (is.undefined(items)) {
return undefined;
}
if (is.nil(items)) {
return null;
}
return items.map(asDocumentLink);
}
function asConnectionSummary(params: ls.ConnectionCompleteParams): data.ConnectionInfoSummary {
let connSummary: data.ConnectionInfoSummary = {
ownerUri: params.ownerUri,
connectionId: params.connectionId,
messages: params.messages,
errorMessage: params.errorMessage,
errorNumber: params.errorNumber,
serverInfo: params.serverInfo,
connectionSummary: params.connectionSummary
};
return connSummary;
}
function asServiceOptionType(val: string): data.ServiceOptionType {
if (val === 'string') {
return data.ServiceOptionType.string;
} else if (val === 'multistring') {
return data.ServiceOptionType.multistring;
} else if (val === 'password') {
return data.ServiceOptionType.password;
} else if (val === 'number') {
return data.ServiceOptionType.number;
} else if (val === 'boolean') {
return data.ServiceOptionType.boolean;
} else if (val === 'category') {
return data.ServiceOptionType.category;
} else if (val === 'object') {
return data.ServiceOptionType.object;
}
// assume string for unknown value types
return data.ServiceOptionType.string;
}
function asServerCapabilities(result: ls.CapabiltiesDiscoveryResult): data.DataProtocolServerCapabilities {
let capabilities: data.DataProtocolServerCapabilities = {
protocolVersion: result.capabilities.protocolVersion,
providerName: result.capabilities.providerName,
providerDisplayName: result.capabilities.providerDisplayName,
connectionProvider: undefined,
adminServicesProvider: undefined,
features: []
};
if (result.capabilities.adminServicesProvider) {
capabilities.adminServicesProvider = <data.AdminServicesOptions>{
databaseInfoOptions: new Array<data.ServiceOption>(),
databaseFileInfoOptions: new Array<data.ServiceOption>(),
fileGroupInfoOptions: new Array<data.ServiceOption>()
};
if (result.capabilities.adminServicesProvider.databaseInfoOptions
&& result.capabilities.adminServicesProvider.databaseInfoOptions.length > 0) {
for (let i = 0; i < result.capabilities.adminServicesProvider.databaseInfoOptions.length; ++i) {
let srcOption: ls.ServiceOption = result.capabilities.adminServicesProvider.databaseInfoOptions[i];
let descOption: data.ServiceOption = buildServiceOption(srcOption);
capabilities.adminServicesProvider.databaseInfoOptions.push(descOption);
}
}
if (result.capabilities.adminServicesProvider.databaseFileInfoOptions
&& result.capabilities.adminServicesProvider.databaseFileInfoOptions.length > 0) {
for (let i = 0; i < result.capabilities.adminServicesProvider.databaseFileInfoOptions.length; ++i) {
let srcOption: ls.ServiceOption = result.capabilities.adminServicesProvider.databaseFileInfoOptions[i];
let descOption: data.ServiceOption = buildServiceOption(srcOption);
capabilities.adminServicesProvider.databaseFileInfoOptions.push(descOption);
}
}
if (result.capabilities.adminServicesProvider.fileGroupInfoOptions
&& result.capabilities.adminServicesProvider.fileGroupInfoOptions.length > 0) {
for (let i = 0; i < result.capabilities.adminServicesProvider.fileGroupInfoOptions.length; ++i) {
let srcOption: ls.ServiceOption = result.capabilities.adminServicesProvider.fileGroupInfoOptions[i];
let descOption: data.ServiceOption = buildServiceOption(srcOption);
capabilities.adminServicesProvider.fileGroupInfoOptions.push(descOption);
}
}
}
if (result.capabilities.connectionProvider
&& result.capabilities.connectionProvider.options
&& result.capabilities.connectionProvider.options.length > 0) {
capabilities.connectionProvider = <data.ConnectionProviderOptions>{
options: new Array<data.ConnectionOption>()
};
for (let i = 0; i < result.capabilities.connectionProvider.options.length; ++i) {
let srcOption: ls.ConnectionOption = result.capabilities.connectionProvider.options[i];
let descOption: data.ConnectionOption = {
name: srcOption.name,
displayName: srcOption.displayName ? srcOption.displayName : srcOption.name,
description: srcOption.description,
groupName: srcOption.groupName,
defaultValue: srcOption.defaultValue,
categoryValues: srcOption.categoryValues,
isIdentity: srcOption.isIdentity,
isRequired: srcOption.isRequired,
valueType: asServiceOptionType(srcOption.valueType),
specialValueType: undefined
};
if (srcOption.specialValueType === 'serverName') {
descOption.specialValueType = data.ConnectionOptionSpecialType.serverName;
} else if (srcOption.specialValueType === 'databaseName') {
descOption.specialValueType = data.ConnectionOptionSpecialType.databaseName;
} else if (srcOption.specialValueType === 'authType') {
descOption.specialValueType = data.ConnectionOptionSpecialType.authType;
} else if (srcOption.specialValueType === 'userName') {
descOption.specialValueType = data.ConnectionOptionSpecialType.userName;
} else if (srcOption.specialValueType === 'password') {
descOption.specialValueType = data.ConnectionOptionSpecialType.password;
} else if (srcOption.specialValueType === 'appName') {
descOption.specialValueType = data.ConnectionOptionSpecialType.appName;
}
capabilities.connectionProvider.options.push(descOption);
}
}
if (result.capabilities.features
&& result.capabilities.features.length > 0) {
result.capabilities.features.forEach(feature => {
let descFeature: data.FeatureMetadataProvider = {
enabled: feature.enabled,
featureName: feature.featureName,
optionsMetadata: []
};
capabilities.features.push(descFeature);
if (feature.optionsMetadata) {
feature.optionsMetadata.forEach(srcOption => {
descFeature.optionsMetadata.push(buildServiceOption(srcOption));
});
}
});
}
return capabilities;
}
function buildServiceOption(srcOption: ls.ServiceOption): data.ServiceOption {
return {
name: srcOption.name,
displayName: srcOption.displayName ? srcOption.displayName : srcOption.name,
description: srcOption.description,
groupName: srcOption.groupName,
defaultValue: srcOption.defaultValue,
categoryValues: srcOption.categoryValues,
isRequired: srcOption.isRequired,
isArray: srcOption.isArray,
objectType: srcOption.objectType,
valueType: asServiceOptionType(srcOption.valueType),
};
}
function asProviderMetadata(params: ls.MetadataQueryResult): data.ProviderMetadata {
let objectMetadata: data.ObjectMetadata[] = [];
if (!params.metadata || !params.metadata.length) {
return {
objectMetadata: objectMetadata
};
}
for (let i = 0; i < params.metadata.length; ++i) {
let metadata: ls.ObjectMetadata = params.metadata[i];
let metadataTypeName: string;
if (metadata.metadataTypeName) {
// Read from the provider since it's defined
metadataTypeName = metadata.metadataTypeName;
} else if (metadata.metadataType === ls.MetadataType.View) {
metadataTypeName = 'View';
} else if (metadata.metadataType === ls.MetadataType.SProc) {
metadataTypeName = 'StoredProcedure';
} else if (metadata.metadataType === ls.MetadataType.Function) {
metadataTypeName = 'Function';
} else {
metadataTypeName = 'Table';
}
objectMetadata.push({
metadataTypeName: metadataTypeName,
metadataType: metadata.metadataType,
name: metadata.name,
schema: metadata.schema,
urn: metadata.urn
});
}
return <data.ProviderMetadata>{
objectMetadata: objectMetadata
};
}
function asObjectExplorerSession(params: ls.SessionCreatedParameters): data.ObjectExplorerSession {
return <data.ObjectExplorerSession>{
success: params.success,
sessionId: params.sessionId,
rootNode: params.rootNode,
errorMessage: params.errorMessage
};
}
function asObjectExplorerCreateSessionResponse(params: ls.CreateSessionResponse): data.ObjectExplorerSessionResponse {
return <data.ObjectExplorerSessionResponse>{
sessionId: params.sessionId
};
}
function asObjectExplorerNodeInfo(params: ls.ExpandResponse): data.ObjectExplorerExpandInfo {
return <data.ObjectExplorerExpandInfo>{
sessionId: params.sessionId,
nodes: params.nodes,
errorMessage: params.errorMessage,
nodePath: params.nodePath
};
}
function asObjectExplorerCloseSessionResponse(params: ls.CloseSessionResponse): data.ObjectExplorerCloseSessionResponse {
return <data.ObjectExplorerCloseSessionResponse>{
sessionId: params.sessionId,
success: params.success
};
}
function asScriptingResult(params: ls.ScriptingResult): data.ScriptingResult {
return <data.ScriptingResult>{
operationId: params.operationId,
script: params.script
};
}
function asListTasksResponse(response: ls.ListTasksResponse): data.ListTasksResponse {
return <data.ListTasksResponse>{
tasks: response.tasks
};
}
function asTaskInfo(params: ls.TaskInfo): data.TaskInfo {
return <data.TaskInfo>{
taskId: params.taskId,
status: params.status,
taskExecutionMode: params.taskExecutionMode,
serverName: params.serverName,
name: params.name,
databaseName: params.databaseName,
description: params.description,
providerName: params.providerName,
isCancelable: params.isCancelable,
};
}
function asRestorePlanResponse(params: ls.RestorePlanResponse): data.RestorePlanResponse {
return <data.RestorePlanResponse>{
backupSetsToRestore: params.backupSetsToRestore,
canRestore: params.canRestore,
databaseNamesFromBackupSets: params.databaseNamesFromBackupSets,
dbFiles: params.dbFiles,
errorMessage: params.errorMessage,
planDetails: params.planDetails,
sessionId: params.sessionId
};
}
function asRestoreResponse(params: ls.RestoreResponse): data.RestoreResponse {
return <data.RestoreResponse>{
result: params.result,
errorMessage: params.errorMessage,
taskId: params.taskId
};
}
function asRestoreConfigInfo(params: ls.RestoreConfigInfoResponse): data.RestoreConfigInfo {
return <data.RestoreConfigInfo>{
configInfo: params.configInfo
};
}
return {
asUri,
asDiagnostics,
asDiagnostic,
asRange,
asPosition,
asDiagnosticSeverity,
asHover,
asCompletionResult,
asCompletionItem,
asTextEdit,
asTextEdits,
asSignatureHelp,
asSignatureInformations,
asSignatureInformation,
asParameterInformations,
asParameterInformation,
asDefinitionResult,
asLocation,
asReferences,
asDocumentHighlights,
asDocumentHighlight,
asDocumentHighlightKind,
asSymbolInformations,
asSymbolInformation,
asCommand,
asCommands,
asCodeLens,
asCodeLenses,
asWorkspaceEdit,
asDocumentLink,
asDocumentLinks,
asConnectionSummary,
asServerCapabilities,
asProviderMetadata,
asScriptingResult,
asObjectExplorerSession,
asObjectExplorerCreateSessionResponse,
asObjectExplorerNodeInfo,
asObjectExplorerCloseSessionResponse,
asListTasksResponse,
asTaskInfo,
asRestorePlanResponse,
asRestoreResponse,
asRestoreConfigInfo
};
}
// This for backward compatibility since we exported the converter functions as API.
const defaultConverter = createConverter();
export const asDiagnostics: (diagnostics: ls.Diagnostic[]) => code.Diagnostic[] = defaultConverter.asDiagnostics;
export const asDiagnostic: (diagnostic: ls.Diagnostic) => code.Diagnostic = defaultConverter.asDiagnostic;
export const asRange: (value: ls.Range) => code.Range = defaultConverter.asRange;
export const asPosition: (value: ls.Position) => code.Position = defaultConverter.asPosition;
export const asDiagnosticSeverity: (value: number) => code.DiagnosticSeverity = defaultConverter.asDiagnosticSeverity;
export const asHover: (hover: ls.Hover) => code.Hover = defaultConverter.asHover;
export const asCompletionResult: (result: ls.CompletionItem[] | ls.CompletionList) => code.CompletionItem[] | code.CompletionList = defaultConverter.asCompletionResult;
export const asCompletionItem: (item: ls.CompletionItem) => ProtocolCompletionItem = defaultConverter.asCompletionItem;
export const asTextEdit: (edit: ls.TextEdit) => code.TextEdit = defaultConverter.asTextEdit;
export const asTextEdits: (items: ls.TextEdit[]) => code.TextEdit[] = defaultConverter.asTextEdits;
export const asSignatureHelp: (item: ls.SignatureHelp) => code.SignatureHelp = defaultConverter.asSignatureHelp;
export const asSignatureInformations: (items: ls.SignatureInformation[]) => code.SignatureInformation[] = defaultConverter.asSignatureInformations;
export const asSignatureInformation: (item: ls.SignatureInformation) => code.SignatureInformation = defaultConverter.asSignatureInformation;
export const asParameterInformations: (item: ls.ParameterInformation[]) => code.ParameterInformation[] = defaultConverter.asParameterInformations;
export const asParameterInformation: (item: ls.ParameterInformation) => code.ParameterInformation = defaultConverter.asParameterInformation;
export const asDefinitionResult: (item: ls.Definition) => code.Definition = defaultConverter.asDefinitionResult;
export const asLocation: (item: ls.Location) => code.Location = defaultConverter.asLocation;
export const asReferences: (values: ls.Location[]) => code.Location[] = defaultConverter.asReferences;
export const asDocumentHighlights: (values: ls.DocumentHighlight[]) => code.DocumentHighlight[] = defaultConverter.asDocumentHighlights;
export const asDocumentHighlight: (item: ls.DocumentHighlight) => code.DocumentHighlight = defaultConverter.asDocumentHighlight;
export const asDocumentHighlightKind: (item: ls.DocumentHighlightKind) => code.DocumentHighlightKind = defaultConverter.asDocumentHighlightKind;
export const asSymbolInformations: (values: ls.SymbolInformation[], uri?: code.Uri) => code.SymbolInformation[] = defaultConverter.asSymbolInformations;
export const asSymbolInformation: (item: ls.SymbolInformation, uri?: code.Uri) => code.SymbolInformation = defaultConverter.asSymbolInformation;
export const asCommand: (item: ls.Command) => code.Command = defaultConverter.asCommand;
export const asCommands: (items: ls.Command[]) => code.Command[] = defaultConverter.asCommands;
export const asCodeLens: (item: ls.CodeLens) => code.CodeLens = defaultConverter.asCodeLens;
export const asCodeLenses: (items: ls.CodeLens[]) => code.CodeLens[] = defaultConverter.asCodeLenses;
export const asWorkspaceEdit: (item: ls.WorkspaceEdit) => code.WorkspaceEdit = defaultConverter.asWorkspaceEdit;
export const asDocumentLink: (item: ls.DocumentLink) => code.DocumentLink = defaultConverter.asDocumentLink;
export const asDocumentLinks: (item: ls.DocumentLink[]) => code.DocumentLink[] = defaultConverter.asDocumentLinks;

View File

@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": false,
"inlineSources": false,
"declaration": true,
"stripInternal": true,
"outDir": "../lib"
}
}

View File

@@ -0,0 +1,84 @@
// Type definitions for es6-promise
// Project: https://github.com/jakearchibald/ES6-Promise
// Definitions by: François de Campredon <https://github.com/fdecampredon/>, vvakame <https://github.com/vvakame>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Thenable<T> {
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
}
declare class Promise<T> implements Thenable<T> {
/**
* If you call resolve in the body of the callback passed to the constructor,
* your promise is fulfilled with result object passed to resolve.
* If you call reject your promise is rejected with the object passed to reject.
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
* Any errors thrown in the constructor callback will be implicitly passed to reject().
*/
constructor(callback: (resolve : (value?: T | Thenable<T>) => void, reject: (error?: any) => void) => void);
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => void): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
*
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
}
declare namespace Promise {
/**
* Make a new promise from the thenable.
* A thenable is promise-like in as far as it has a "then" method.
*/
function resolve<T>(value?: T | Thenable<T>): Promise<T>;
/**
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
*/
function reject(error: any): Promise<any>;
function reject<T>(error: T): Promise<T>;
/**
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
* the array passed to all can be a mixture of promise-like objects and other objects.
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
*/
function all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>, T9 | Thenable<T9>, T10 | Thenable<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
function all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>, T9 | Thenable<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
function all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
function all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
function all<T1, T2, T3, T4, T5, T6>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
function all<T1, T2, T3, T4, T5>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>]): Promise<[T1, T2, T3, T4, T5]>;
function all<T1, T2, T3, T4>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>]): Promise<[T1, T2, T3, T4]>;
function all<T1, T2, T3>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>]): Promise<[T1, T2, T3]>;
function all<T1, T2>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>]): Promise<[T1, T2]>;
function all<T>(values: (T | Thenable<T>)[]): Promise<T[]>;
/**
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
*/
function race<T>(promises: (T | Thenable<T>)[]): Promise<T>;
}
declare module 'es6-promise' {
var foo: typeof Promise; // Temp variable to reference Promise in local context
namespace rsvp {
export var Promise: typeof foo;
export function polyfill(): void;
}
export = rsvp;
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es5",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"es6-promise-tests.ts"
]
}

View File

@@ -0,0 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/sql/data.d.ts'/>

View File

@@ -0,0 +1,82 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
export interface ITask<T> {
(): T;
}
export class Delayer<T> {
public defaultDelay: number;
private timeout: NodeJS.Timer;
private completionPromise: Promise<T>;
private onSuccess: (value?: T | Thenable<T>) => void;
private task: ITask<T>;
constructor(defaultDelay: number) {
this.defaultDelay = defaultDelay;
this.timeout = null;
this.completionPromise = null;
this.onSuccess = null;
this.task = null;
}
public trigger(task: ITask<T>, delay: number = this.defaultDelay): Promise<T> {
this.task = task;
if (delay >= 0) {
this.cancelTimeout();
}
if (!this.completionPromise) {
this.completionPromise = new Promise<T>((resolve) => {
this.onSuccess = resolve
}).then(() => {
this.completionPromise = null;
this.onSuccess = null;
var result = this.task();
this.task = null;
return result;
});
}
if (delay >= 0 || this.timeout === null) {
this.timeout = setTimeout(() => {
this.timeout = null;
this.onSuccess(null);
}, delay >= 0 ? delay : this.defaultDelay);
}
return this.completionPromise;
}
public forceDelivery(): T {
if (!this.completionPromise) {
return null;
}
this.cancelTimeout();
let result: T = this.task();
this.completionPromise = null;
this.onSuccess = null;
this.task = null;
return result;
}
public isTriggered(): boolean {
return this.timeout !== null;
}
public cancel(): void {
this.cancelTimeout();
this.completionPromise = null;
}
private cancelTimeout(): void {
if (this.timeout !== null) {
clearTimeout(this.timeout);
this.timeout = null;
}
}
}

View File

@@ -0,0 +1,123 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import path = require('path');
import os = require('os');
import net = require('net');
import cp = require('child_process');
export interface IForkOptions {
cwd?: string;
env?: any;
encoding?: string;
execArgv?: string[];
}
function makeRandomHexString(length: number): string {
let chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
let result = '';
for (let i = 0; i < length; i++) {
let idx = Math.floor(chars.length * Math.random());
result += chars[idx];
}
return result;
}
function generatePipeName(): string {
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: any, stdInPipeName: string, stdOutPipeName: string): any {
// Set the two unique pipe names and the electron flag as process env
var newEnv: any = {};
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;
}
export function fork(modulePath: string, args: string[], options: IForkOptions, callback: (error: any, cp: cp.ChildProcess) => void): void {
var callbackCalled = false;
var resolve = (result: cp.ChildProcess) => {
if (callbackCalled) {
return;
}
callbackCalled = true;
callback(null, result);
};
var reject = (err: any) => {
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: cp.ChildProcess;
// Begin listening to stdout pipe
var server = net.createServer((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', (chunk: Buffer) => {
// The child process is sending me the `ready` chunk, time to connect to the stdin pipe
childProcess.stdin = <any>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 = () => {
if (serverClosed) {
return;
}
serverClosed = true;
server.close();
}
// Create the process
let bootstrapperPath = path.join(__dirname, 'electronForkStart');
childProcess = cp.fork(bootstrapperPath, [modulePath].concat(args), <any>{
silent: true,
cwd: options.cwd,
env: newEnv,
execArgv: options.execArgv
});
childProcess.once('error', (err: Error) => {
closeServer();
reject(err);
});
childProcess.once('exit', (err: Error) => {
closeServer();
reject(err);
});
}

View File

@@ -0,0 +1,183 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. 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
(<any>process).__defineGetter__('stdout', function () { return stdOutStream; });
// handle process.stderr
(<any>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
(<any>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

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

View File

@@ -0,0 +1,44 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import * as cp from 'child_process';
import ChildProcess = cp.ChildProcess;
import { join } from 'path';
const isWindows = (process.platform === 'win32');
const isMacintosh = (process.platform === 'darwin');
const isLinux = (process.platform === 'linux');
export function terminate(process: ChildProcess, cwd?: string): boolean {
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.
let options: any = {
stdio: ['pipe', 'pipe', 'ignore']
};
if (cwd) {
options.cwd = cwd
}
(<any>cp).execFileSync('taskkill', ['/T', '/F', '/PID', process.pid.toString()], options);
return true;
} catch (err) {
return false;
}
} else if (isLinux || isMacintosh) {
try {
var cmd = join(__dirname, 'terminateProcess.sh');
var result = (<any>cp).spawnSync(cmd, [process.pid.toString()]);
return result.error ? false : true;
} catch (err) {
return false;
}
} else {
process.kill('SIGKILL');
return true;
}
}

View File

@@ -0,0 +1,16 @@
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Source EULA. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
terminateTree() {
for cpid in $(pgrep -P $1); do
terminateTree $cpid
done
kill -9 $1 > /dev/null 2>&1
}
for pid in $*; do
terminateTree $pid
done

View File

@@ -0,0 +1,31 @@
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 Source EULA 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.