New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

monaco-languageclient

Package Overview
Dependencies
Maintainers
1
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monaco-languageclient - npm Package Compare versions

Comparing version 0.0.1-alpha.4 to 0.0.1-alpha.5

31

lib/converter.d.ts
import { CodeActionParams, CodeLensParams, DocumentFormattingParams, DocumentOnTypeFormattingParams, DocumentRangeFormattingParams, ReferenceParams, RenameParams, TextDocumentPositionParams, Position, TextDocumentIdentifier, CompletionItem, CompletionList, Range, Diagnostic, Hover, SignatureHelp, SignatureInformation, ParameterInformation, Definition, Location, DocumentHighlight, SymbolInformation, DocumentSymbolParams, CodeActionContext, DiagnosticSeverity, Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit } from 'vscode-base-languageclient/lib/base';
import IReadOnlyModel = monaco.editor.IReadOnlyModel;
import languages = monaco.languages;
export declare type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};
export interface ProtocolCodeLens extends languages.ICodeLensSymbol {

@@ -18,6 +21,15 @@ data?: any;

export declare class MonacoToProtocolConverter {
asPosition(lineNumber: undefined | null, column: undefined | null): {};
asPosition(lineNumber: number, column: undefined | null): Pick<Position, 'line'>;
asPosition(lineNumber: undefined | null, column: number): Pick<Position, 'character'>;
asPosition(lineNumber: number, column: number): Position;
asPosition(lineNumber: number | undefined | null, column: number | undefined | null): Partial<Position>;
asRange(range: null): null;
asRange(range: undefined): undefined;
asRange(range: null): null;
asRange(range: monaco.IRange): Range;
asRange(range: monaco.IRange | undefined): Range | undefined;
asRange(range: monaco.IRange | null): Range | null;
asRange(range: Partial<monaco.IRange>): RecursivePartial<Range>;
asRange(range: Partial<monaco.IRange> | undefined): RecursivePartial<Range> | undefined;
asRange(range: Partial<monaco.IRange> | null): RecursivePartial<Range> | null;
asTextDocumentIdentifier(model: IReadOnlyModel): TextDocumentIdentifier;

@@ -100,3 +112,18 @@ asTextDocumentPositionParams(model: IReadOnlyModel, position: monaco.Position): TextDocumentPositionParams;

} | undefined;
asRange(range: Range | undefined | null): monaco.Range | undefined | null;
asRange(range: null): null;
asRange(range: undefined): undefined;
asRange(range: Range): monaco.Range;
asRange(range: Range | undefined): monaco.Range | undefined;
asRange(range: Range | null): monaco.Range | null;
asRange(range: RecursivePartial<Range>): Partial<monaco.IRange>;
asRange(range: RecursivePartial<Range> | undefined): monaco.Range | Partial<monaco.IRange> | undefined;
asRange(range: RecursivePartial<Range> | null): monaco.Range | Partial<monaco.IRange> | null;
asPosition(position: null): null;
asPosition(position: undefined): undefined;
asPosition(position: Position): monaco.Position;
asPosition(position: Position | undefined): monaco.Position | undefined;
asPosition(position: Position | null): monaco.Position | null;
asPosition(position: Partial<Position>): Partial<monaco.IPosition>;
asPosition(position: Partial<Position> | undefined): monaco.Position | Partial<monaco.IPosition> | undefined;
asPosition(position: Partial<Position> | null): monaco.Position | Partial<monaco.IPosition> | null;
}

@@ -36,3 +36,7 @@ "use strict";

MonacoToProtocolConverter.prototype.asPosition = function (lineNumber, column) {
return base_1.Position.create(lineNumber - 1, column - 1);
var line = lineNumber === undefined || lineNumber === null ? undefined : lineNumber - 1;
var character = column === undefined || column === null ? undefined : column - 1;
return {
line: line, character: character
};
};

@@ -43,6 +47,10 @@ MonacoToProtocolConverter.prototype.asRange = function (range) {

}
if (!range) {
if (range === null) {
return null;
}
return base_1.Range.create(this.asPosition(range.startLineNumber, range.startColumn), this.asPosition(range.endLineNumber, range.endColumn));
var start = this.asPosition(range.startLineNumber, range.startColumn);
var end = this.asPosition(range.endLineNumber, range.endColumn);
return {
start: start, end: end
};
};

@@ -432,5 +440,5 @@ MonacoToProtocolConverter.prototype.asTextDocumentIdentifier = function (model) {

var contents = Array.isArray(hover.contents) ? hover.contents : [hover.contents];
var range = this.asRange(hover.range);
return {
contents: contents,
range: this.asRange(hover.range)
contents: contents, range: range
};

@@ -527,9 +535,33 @@ };

}
if (!range) {
if (range === null) {
return null;
}
return new monaco.Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
var start = this.asPosition(range.start);
var end = this.asPosition(range.end);
if (start instanceof monaco.Position && end instanceof monaco.Position) {
return new monaco.Range(start.lineNumber, start.column, end.lineNumber, end.column);
}
var startLineNumber = !start || start.lineNumber === undefined ? undefined : start.lineNumber;
var startColumn = !start || start.column === undefined ? undefined : start.column;
var endLineNumber = !end || end.lineNumber === undefined ? undefined : end.lineNumber;
var endColumn = !end || end.column === undefined ? undefined : end.column;
return { startLineNumber: startLineNumber, startColumn: startColumn, endLineNumber: endLineNumber, endColumn: endColumn };
};
ProtocolToMonacoConverter.prototype.asPosition = function (position) {
if (position === undefined) {
return undefined;
}
if (position === null) {
return null;
}
var line = position.line, character = position.character;
var lineNumber = line === undefined ? undefined : line + 1;
var column = character === undefined ? undefined : character + 1;
if (lineNumber !== undefined && column !== undefined) {
return new monaco.Position(lineNumber, column);
}
return { lineNumber: lineNumber, column: column };
};
return ProtocolToMonacoConverter;
}());
exports.ProtocolToMonacoConverter = ProtocolToMonacoConverter;

2

package.json
{
"name": "monaco-languageclient",
"version": "0.0.1-alpha.4",
"version": "0.0.1-alpha.5",
"description": "Monaco Language client implementation",

@@ -5,0 +5,0 @@ "author": "TypeFox GmbH (http://www.typefox.io)",

@@ -21,2 +21,6 @@ /* --------------------------------------------------------------------------------------------

export type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};
export interface ProtocolCodeLens extends languages.ICodeLensSymbol {

@@ -44,22 +48,35 @@ data?: any;

export class MonacoToProtocolConverter {
asPosition(lineNumber: number, column: number): Position {
return Position.create(lineNumber - 1, column - 1)
asPosition(lineNumber: undefined | null, column: undefined | null): {};
asPosition(lineNumber: number, column: undefined | null): Pick<Position, 'line'>;
asPosition(lineNumber: undefined | null, column: number): Pick<Position, 'character'>;
asPosition(lineNumber: number, column: number): Position;
asPosition(lineNumber: number | undefined | null, column: number | undefined | null): Partial<Position>;
asPosition(lineNumber: number | undefined | null, column: number | undefined | null): Partial<Position> {
const line = lineNumber === undefined || lineNumber === null ? undefined : lineNumber - 1;
const character = column === undefined || column === null ? undefined : column - 1;
return {
line, character
};
}
asRange(range: null): null;
asRange(range: undefined): undefined;
asRange(range: null): null;
asRange(range: monaco.IRange): Range;
asRange(range: monaco.IRange | undefined | null): Range | undefined | null {
asRange(range: monaco.IRange | undefined): Range | undefined;
asRange(range: monaco.IRange | null): Range | null;
asRange(range: Partial<monaco.IRange>): RecursivePartial<Range>;
asRange(range: Partial<monaco.IRange> | undefined): RecursivePartial<Range> | undefined;
asRange(range: Partial<monaco.IRange> | null): RecursivePartial<Range> | null;
asRange(range: Partial<monaco.IRange> | undefined | null): RecursivePartial<Range> | undefined | null {
if (range === undefined) {
return undefined
return undefined;
}
if (!range) {
return null
if (range === null) {
return null;
}
return Range.create(
this.asPosition(range.startLineNumber, range.startColumn),
this.asPosition(range.endLineNumber, range.endColumn)
)
const start = this.asPosition(range.startLineNumber, range.startColumn);
const end = this.asPosition(range.endLineNumber, range.endColumn);
return {
start, end
};
}

@@ -191,3 +208,3 @@

asCommand(item: languages.Command | undefined |  null): Command | undefined {
asCommand(item: languages.Command | undefined | null): Command | undefined {
if (item) {

@@ -211,3 +228,3 @@ return Command.create(item.title, item.id, item.arguments);

}
asDocumentFormattingParams(model: IReadOnlyModel, options: languages.FormattingOptions): DocumentFormattingParams {

@@ -259,16 +276,16 @@ return {

asWorkspaceEdit(item: WorkspaceEdit): languages.WorkspaceEdit;
asWorkspaceEdit(item: undefined | null): undefined;
asWorkspaceEdit(item: WorkspaceEdit | undefined | null): languages.WorkspaceEdit | undefined;
asWorkspaceEdit(item: WorkspaceEdit | undefined | null): languages.WorkspaceEdit | undefined {
if (!item) {
return undefined;
}
asWorkspaceEdit(item: WorkspaceEdit): languages.WorkspaceEdit;
asWorkspaceEdit(item: undefined | null): undefined;
asWorkspaceEdit(item: WorkspaceEdit | undefined | null): languages.WorkspaceEdit | undefined;
asWorkspaceEdit(item: WorkspaceEdit | undefined | null): languages.WorkspaceEdit | undefined {
if (!item) {
return undefined;
}
const edits: languages.IResourceEdit[] = [];
if (item.documentChanges) {
if (item.documentChanges) {
for (const change of item.documentChanges) {
const resource = monaco.Uri.parse(change.textDocument.uri);
edits.push(...this.asResourceEdits(resource, change.edits));
}
} else if (item.changes) {
}
} else if (item.changes) {
for (const key of Object.keys(item.changes)) {

@@ -278,9 +295,9 @@ const resource = monaco.Uri.parse(key);

}
}
}
return {
edits
};
}
}
asTextEdit(edit: TextEdit): monaco.editor.ISingleEditOperation {
asTextEdit(edit: TextEdit): monaco.editor.ISingleEditOperation {
const range = this.asRange(edit.range)!;

@@ -291,13 +308,13 @@ return {

}
}
}
asTextEdits(items: TextEdit[]): monaco.editor.ISingleEditOperation[];
asTextEdits(items: undefined | null): undefined;
asTextEdits(items: TextEdit[] | undefined | null): monaco.editor.ISingleEditOperation[] | undefined;
asTextEdits(items: TextEdit[] | undefined | null): monaco.editor.ISingleEditOperation[] | undefined {
if (!items) {
return undefined;
}
return items.map(item => this.asTextEdit(item));
}
asTextEdits(items: TextEdit[]): monaco.editor.ISingleEditOperation[];
asTextEdits(items: undefined | null): undefined;
asTextEdits(items: TextEdit[] | undefined | null): monaco.editor.ISingleEditOperation[] | undefined;
asTextEdits(items: TextEdit[] | undefined | null): monaco.editor.ISingleEditOperation[] | undefined {
if (!items) {
return undefined;
}
return items.map(item => this.asTextEdit(item));
}

@@ -486,5 +503,5 @@ asCodeLens(item: CodeLens): languages.ICodeLensSymbol;

const contents = Array.isArray(hover.contents) ? hover.contents : [hover.contents];
const range = this.asRange(hover.range)!;
return {
contents,
range: this.asRange(hover.range)!
contents, range
}

@@ -569,17 +586,53 @@ }

asRange(range: Range | undefined | null): monaco.Range | undefined | null {
asRange(range: null): null;
asRange(range: undefined): undefined;
asRange(range: Range): monaco.Range;
asRange(range: Range | undefined): monaco.Range | undefined;
asRange(range: Range | null): monaco.Range | null;
asRange(range: RecursivePartial<Range>): Partial<monaco.IRange>;
asRange(range: RecursivePartial<Range> | undefined): monaco.Range | Partial<monaco.IRange> | undefined;
asRange(range: RecursivePartial<Range> | null): monaco.Range | Partial<monaco.IRange> | null;
asRange(range: RecursivePartial<Range> | undefined | null): monaco.Range | Partial<monaco.IRange> | undefined | null {
if (range === undefined) {
return undefined;
}
if (!range) {
if (range === null) {
return null;
}
return new monaco.Range(
range.start.line + 1,
range.start.character + 1,
range.end.line + 1,
range.end.character + 1
);
const start = this.asPosition(range.start);
const end = this.asPosition(range.end);
if (start instanceof monaco.Position && end instanceof monaco.Position) {
return new monaco.Range(start.lineNumber, start.column, end.lineNumber, end.column);
}
const startLineNumber = !start || start.lineNumber === undefined ? undefined : start.lineNumber;
const startColumn = !start || start.column === undefined ? undefined : start.column;
const endLineNumber = !end || end.lineNumber === undefined ? undefined : end.lineNumber;
const endColumn = !end || end.column === undefined ? undefined : end.column;
return { startLineNumber, startColumn, endLineNumber, endColumn };
}
asPosition(position: null): null;
asPosition(position: undefined): undefined;
asPosition(position: Position): monaco.Position;
asPosition(position: Position | undefined): monaco.Position | undefined;
asPosition(position: Position | null): monaco.Position | null;
asPosition(position: Partial<Position>): Partial<monaco.IPosition>;
asPosition(position: Partial<Position> | undefined): monaco.Position | Partial<monaco.IPosition> | undefined;
asPosition(position: Partial<Position> | null): monaco.Position | Partial<monaco.IPosition> | null;
asPosition(position: Partial<Position> | undefined | null): monaco.Position | Partial<monaco.IPosition> | undefined | null {
if (position === undefined) {
return undefined;
}
if (position === null) {
return null;
}
const { line, character } = position;
const lineNumber = line === undefined ? undefined : line + 1;
const column = character === undefined ? undefined : character + 1;
if (lineNumber !== undefined && column !== undefined) {
return new monaco.Position(lineNumber, column);
}
return { lineNumber, column };
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc