mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
fix #60449
This commit is contained in:
parent
329731090c
commit
5e8d5af6a1
|
@ -906,6 +906,12 @@ export enum SymbolKind {
|
|||
|
||||
export class SymbolInformation {
|
||||
|
||||
static validate(candidate: SymbolInformation): void {
|
||||
if (!candidate.name) {
|
||||
throw new Error('name must not be falsy');
|
||||
}
|
||||
}
|
||||
|
||||
name: string;
|
||||
location: Location;
|
||||
kind: SymbolKind;
|
||||
|
@ -927,6 +933,8 @@ export class SymbolInformation {
|
|||
} else if (rangeOrContainer instanceof Range) {
|
||||
this.location = new Location(locationOrUri, rangeOrContainer);
|
||||
}
|
||||
|
||||
SymbolInformation.validate(this);
|
||||
}
|
||||
|
||||
toJSON(): any {
|
||||
|
@ -940,6 +948,19 @@ export class SymbolInformation {
|
|||
}
|
||||
|
||||
export class DocumentSymbol {
|
||||
|
||||
static validate(candidate: DocumentSymbol): void {
|
||||
if (!candidate.name) {
|
||||
throw new Error('name must not be falsy');
|
||||
}
|
||||
if (!candidate.range.contains(candidate.selectionRange)) {
|
||||
throw new Error('selectionRange must be contained in fullRange');
|
||||
}
|
||||
if (candidate.children) {
|
||||
candidate.children.forEach(DocumentSymbol.validate);
|
||||
}
|
||||
}
|
||||
|
||||
name: string;
|
||||
detail: string;
|
||||
kind: SymbolKind;
|
||||
|
@ -955,9 +976,7 @@ export class DocumentSymbol {
|
|||
this.selectionRange = selectionRange;
|
||||
this.children = [];
|
||||
|
||||
if (!this.range.contains(this.selectionRange)) {
|
||||
throw new Error('selectionRange must be contained in fullRange');
|
||||
}
|
||||
DocumentSymbol.validate(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue