Skip to content

Commit 263c277

Browse files
authored
Move from protocol to types (#179)
1 parent 6c16fb1 commit 263c277

File tree

6 files changed

+88
-119
lines changed

6 files changed

+88
-119
lines changed

protocol/package-lock.json

Lines changed: 1 addition & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protocol/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"main": "lib/main.js",
1515
"typings": "lib/main.d.ts",
1616
"dependencies": {
17-
"vscode-languageserver-protocol": "^3.17.5"
17+
"vscode-languageserver-types": "^3.17.5"
1818
},
1919
"scripts": {
2020
"compile": "tsc -b ./tsconfig.json",

protocol/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
* ------------------------------------------------------------------------------------------ */
55

6-
import * as lsp from 'vscode-languageserver-protocol';
7-
export { lsp };
6+
import * as types from 'vscode-languageserver-types';
7+
export { types };
88

99
export * from './protocol';
1010

protocol/src/protocol.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
* ------------------------------------------------------------------------------------------ */
55

6-
import * as lsp from 'vscode-languageserver-protocol';
6+
import * as types from 'vscode-languageserver-types';
77

88
namespace Is {
99
export function boolean(value: any): value is boolean {
@@ -31,11 +31,11 @@ namespace Is {
3131
return typeof value === 'number' || value instanceof Number;
3232
}
3333

34-
export function symbolKind(value: any): value is lsp.SymbolKind {
34+
export function symbolKind(value: any): value is types.SymbolKind {
3535
return typeof value === 'number' || value instanceof Number;
3636
}
3737

38-
export function symbolTag(value: any): value is lsp.SymbolTag {
38+
export function symbolTag(value: any): value is types.SymbolTag {
3939
return typeof value === 'number' || value instanceof Number;
4040
}
4141
}
@@ -512,12 +512,12 @@ export interface DeclarationTag {
512512
/**
513513
* The symbol kind.
514514
*/
515-
kind: lsp.SymbolKind;
515+
kind: types.SymbolKind;
516516

517517
/**
518518
* Additional tags for the definition.
519519
*/
520-
tags?: lsp.SymbolTag[];
520+
tags?: types.SymbolTag[];
521521

522522
/**
523523
* Indicates if this symbol is deprecated.
@@ -530,7 +530,7 @@ export interface DeclarationTag {
530530
* The full range of the declaration not including leading/trailing whitespace but everything else, e.g comments and code.
531531
* The range must be included in fullRange.
532532
*/
533-
fullRange: lsp.Range;
533+
fullRange: types.Range;
534534

535535
/**
536536
* Optional detail information for the declaration.
@@ -545,7 +545,7 @@ export namespace DeclarationTag {
545545
kind: new Property(Is.symbolKind),
546546
tags: new Property(Is.symbolTag, PropertyFlags.optional),
547547
deprecated: new BooleanProperty(PropertyFlags.optional),
548-
fullRange: new Property(lsp.Range.is),
548+
fullRange: new Property(types.Range.is),
549549
detail: new StringProperty(PropertyFlags.optional)
550550
});
551551
export function is(value: any): value is DeclarationTag {
@@ -570,12 +570,12 @@ export interface DefinitionTag {
570570
/**
571571
* The symbol kind.
572572
*/
573-
kind: lsp.SymbolKind;
573+
kind: types.SymbolKind;
574574

575575
/**
576576
* Additional tags for the definition.
577577
*/
578-
tags?: lsp.SymbolTag[];
578+
tags?: types.SymbolTag[];
579579

580580
/**
581581
* Indicates if this symbol is deprecated.
@@ -588,7 +588,7 @@ export interface DefinitionTag {
588588
* The full range of the definition not including leading/trailing whitespace but everything else, e.g comments and code.
589589
* The range must be included in fullRange.
590590
*/
591-
fullRange: lsp.Range;
591+
fullRange: types.Range;
592592

593593
/**
594594
* Optional detail information for the definition.
@@ -603,7 +603,7 @@ export namespace DefinitionTag {
603603
kind: new Property(Is.symbolKind),
604604
tags: new Property(Is.symbolTag, PropertyFlags.optional),
605605
deprecated: new BooleanProperty(PropertyFlags.optional),
606-
fullRange: new Property(lsp.Range.is),
606+
fullRange: new Property(types.Range.is),
607607
detail: new StringProperty(PropertyFlags.optional)
608608
});
609609
export function is(value: any): value is DefinitionTag {
@@ -693,7 +693,7 @@ export namespace RangeTag {
693693
/**
694694
* A vertex representing a range inside a document.
695695
*/
696-
export interface Range extends V, lsp.Range {
696+
export interface Range extends V, types.Range {
697697

698698
label: VertexLabels.range;
699699

@@ -707,8 +707,8 @@ export namespace Range {
707707
export const descriptor = new VertexDescriptor<Required<Range>>(Object.assign({}, V.descriptor.description, {
708708
label: VertexLabels.property(VertexLabels.range),
709709
tag: RangeTag.property(PropertyFlags.optional),
710-
start: new Property(lsp.Position.is),
711-
end: new Property(lsp.Position.is)
710+
start: new Property(types.Position.is),
711+
end: new Property(types.Position.is)
712712
}));
713713
export function is(value: any): value is Range {
714714
return descriptor.validate(value);
@@ -794,13 +794,13 @@ export interface Location extends V {
794794
/**
795795
* The location's range
796796
*/
797-
range: lsp.Range;
797+
range: types.Range;
798798
}
799799

800800
export namespace Location {
801801
export const descriptor = new VertexDescriptor<Required<Location>>(Object.assign({}, V.descriptor.description, {
802802
label: VertexLabels.property(VertexLabels.location),
803-
range: new Property<lsp.Range>(value => lsp.Range.is(value))
803+
range: new Property<types.Range>(value => types.Range.is(value))
804804
}));
805805
export function is(value: any): value is Location {
806806
return descriptor.validate(value);
@@ -1300,13 +1300,13 @@ export interface DocumentSymbolResult extends V {
13001300

13011301
label: VertexLabels.documentSymbolResult;
13021302

1303-
result: lsp.DocumentSymbol[] | RangeBasedDocumentSymbol[];
1303+
result: types.DocumentSymbol[] | RangeBasedDocumentSymbol[];
13041304
}
13051305

13061306
export namespace DocumentSymbolResult {
13071307
export const descriptor = new VertexDescriptor<DocumentSymbolResult>(Object.assign({}, V.descriptor.description, {
13081308
label: VertexLabels.property(VertexLabels.documentSymbolResult),
1309-
result: new Property<lsp.DocumentSymbol[] | RangeBasedDocumentSymbol[]>(value => {
1309+
result: new Property<types.DocumentSymbol[] | RangeBasedDocumentSymbol[]>(value => {
13101310
if (!Array.isArray(value)) {
13111311
return false;
13121312
}
@@ -1316,7 +1316,7 @@ export namespace DocumentSymbolResult {
13161316
const first = value[0];
13171317
const validator = (first as RangeBasedDocumentSymbol).id !== undefined
13181318
? RangeBasedDocumentSymbol.is
1319-
: lsp.DocumentSymbol.is;
1319+
: types.DocumentSymbol.is;
13201320
for (const item of value) {
13211321
if (!validator(item)) {
13221322
return false;
@@ -1343,13 +1343,13 @@ export interface DiagnosticResult extends V {
13431343
/**
13441344
* The diagnostics.
13451345
*/
1346-
result: lsp.Diagnostic[];
1346+
result: types.Diagnostic[];
13471347
}
13481348

13491349
export namespace DiagnosticResult {
13501350
export const descriptor = new VertexDescriptor<DiagnosticResult>(Object.assign({}, V.descriptor.description, {
13511351
label: VertexLabels.property(VertexLabels.diagnosticResult),
1352-
result: new ArrayProperty(lsp.Diagnostic.is)
1352+
result: new ArrayProperty(types.Diagnostic.is)
13531353
}));
13541354
export function is(value: any): value is DiagnosticResult {
13551355
return descriptor.validate(value);
@@ -1369,13 +1369,13 @@ export interface FoldingRangeResult extends V {
13691369
/**
13701370
* The actual folding ranges.
13711371
*/
1372-
result: lsp.FoldingRange[];
1372+
result: types.FoldingRange[];
13731373
}
13741374

13751375
export namespace FoldingRangeResult {
13761376
export const descriptor = new VertexDescriptor<FoldingRangeResult>(Object.assign({}, V.descriptor.description, {
13771377
label: VertexLabels.property(VertexLabels.foldingRangeResult),
1378-
result: new ArrayProperty(lsp.FoldingRange.is)
1378+
result: new ArrayProperty(types.FoldingRange.is)
13791379
}));
13801380
export function is(value: any): value is FoldingRangeResult {
13811381
return descriptor.validate(value);
@@ -1395,13 +1395,13 @@ export interface DocumentLinkResult extends V {
13951395
/**
13961396
* The actual document links.
13971397
*/
1398-
result: lsp.DocumentLink[];
1398+
result: types.DocumentLink[];
13991399
}
14001400

14011401
export namespace DocumentLinkResult {
14021402
export const descriptor = new VertexDescriptor<DocumentLinkResult>(Object.assign({}, V.descriptor.description, {
14031403
label: VertexLabels.property(VertexLabels.documentLinkResult),
1404-
result: new ArrayProperty(lsp.DocumentLink.is)
1404+
result: new ArrayProperty(types.DocumentLink.is)
14051405
}));
14061406
export function is(value: any): value is DocumentLinkResult {
14071407
return descriptor.validate(value);
@@ -1518,13 +1518,13 @@ export interface HoverResult extends V {
15181518
/**
15191519
* The hover result. This is the normal LSP hover result.
15201520
*/
1521-
result: lsp.Hover;
1521+
result: types.Hover;
15221522
}
15231523

15241524
export namespace HoverResult {
15251525
export const descriptor = new VertexDescriptor<HoverResult>(Object.assign({}, V.descriptor.description, {
15261526
label: VertexLabels.property(VertexLabels.hoverResult),
1527-
result: new Property<lsp.Hover>(lsp.Hover.is)
1527+
result: new Property<types.Hover>(types.Hover.is)
15281528
}));
15291529
export function is(value: any): value is HoverResult {
15301530
return descriptor.validate(value);

tsc/src/common/graph.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { URI } from 'vscode-uri';
88

99
import {
10-
lsp, Id, Vertex, E, Edge,
10+
types, Id, Vertex, E, Edge,
1111
Project, Document, HoverResult, ReferenceResult,
1212
contains, textDocument_definition, textDocument_references, textDocument_diagnostic, textDocument_hover, item, DiagnosticResult,
1313
Range, RangeTag, DeclarationRange, ReferenceRange, DocumentSymbolResult, textDocument_documentSymbol, ReferenceTag, DeclarationTag,
@@ -155,11 +155,11 @@ export class VertexBuilder {
155155
return result;
156156
}
157157

158-
public range(range: lsp.Range, tag: UnknownTag): Range;
159-
public range(range: lsp.Range, tag: DeclarationTag): DeclarationRange;
160-
public range(range: lsp.Range, tag: DefinitionTag): DefinitionRange;
161-
public range(range: lsp.Range, tag: ReferenceTag): ReferenceRange;
162-
public range(range: lsp.Range, tag?: RangeTag): Range {
158+
public range(range: types.Range, tag: UnknownTag): Range;
159+
public range(range: types.Range, tag: DeclarationTag): DeclarationRange;
160+
public range(range: types.Range, tag: DefinitionTag): DefinitionRange;
161+
public range(range: types.Range, tag: ReferenceTag): ReferenceRange;
162+
public range(range: types.Range, tag?: RangeTag): Range {
163163
const result: Range = {
164164
id: this.nextId(),
165165
type: ElementTypes.vertex,
@@ -173,7 +173,7 @@ export class VertexBuilder {
173173
return result;
174174
}
175175

176-
public location(range: lsp.Range): Location {
176+
public location(range: types.Range): Location {
177177
return {
178178
id: this.nextId(),
179179
type: ElementTypes.vertex,
@@ -182,7 +182,7 @@ export class VertexBuilder {
182182
};
183183
}
184184

185-
public documentSymbolResult(values: lsp.DocumentSymbol[] | RangeBasedDocumentSymbol[]): DocumentSymbolResult {
185+
public documentSymbolResult(values: types.DocumentSymbol[] | RangeBasedDocumentSymbol[]): DocumentSymbolResult {
186186
return {
187187
id: this.nextId(),
188188
type: ElementTypes.vertex,
@@ -191,7 +191,7 @@ export class VertexBuilder {
191191
};
192192
}
193193

194-
public diagnosticResult(values: lsp.Diagnostic[]): DiagnosticResult {
194+
public diagnosticResult(values: types.Diagnostic[]): DiagnosticResult {
195195
return {
196196
id: this.nextId(),
197197
type: ElementTypes.vertex,
@@ -200,7 +200,7 @@ export class VertexBuilder {
200200
};
201201
}
202202

203-
public foldingRangeResult(values: lsp.FoldingRange[]): FoldingRangeResult {
203+
public foldingRangeResult(values: types.FoldingRange[]): FoldingRangeResult {
204204
return {
205205
id: this.nextId(),
206206
type: ElementTypes.vertex,
@@ -209,10 +209,10 @@ export class VertexBuilder {
209209
};
210210
}
211211

212-
public hoverResult(value: lsp.Hover): HoverResult;
213-
public hoverResult(contents: lsp.MarkupContent | lsp.MarkedString | lsp.MarkedString[]): HoverResult;
214-
public hoverResult(value: lsp.Hover | lsp.MarkupContent | lsp.MarkedString | lsp.MarkedString[]): HoverResult {
215-
if (lsp.Hover.is(value)) {
212+
public hoverResult(value: types.Hover): HoverResult;
213+
public hoverResult(contents: types.MarkupContent | types.MarkedString | types.MarkedString[]): HoverResult;
214+
public hoverResult(value: types.Hover | types.MarkupContent | types.MarkedString | types.MarkedString[]): HoverResult {
215+
if (types.Hover.is(value)) {
216216
return {
217217
id: this.nextId(),
218218
type: ElementTypes.vertex,
@@ -228,7 +228,7 @@ export class VertexBuilder {
228228
type: ElementTypes.vertex,
229229
label: VertexLabels.hoverResult,
230230
result: {
231-
contents: value as (lsp.MarkupContent | lsp.MarkedString | lsp.MarkedString[])
231+
contents: value as (types.MarkupContent | types.MarkedString | types.MarkedString[])
232232
}
233233
};
234234
}

0 commit comments

Comments
 (0)