提交 a4e3aada 编写于 作者: J Johannes Rieken

allow a Location to be created without a range or position

上级 ad1ec907
...@@ -509,13 +509,15 @@ export class Location { ...@@ -509,13 +509,15 @@ export class Location {
uri: URI; uri: URI;
range: Range; range: Range;
constructor(uri: URI, range: Range | Position) { constructor(uri: URI, rangeOrPosition: Range | Position) {
this.uri = uri; this.uri = uri;
if (range instanceof Range) { if (!rangeOrPosition) {
this.range = range; //that's OK
} else if (range instanceof Position) { } else if (rangeOrPosition instanceof Range) {
this.range = new Range(range, range); this.range = rangeOrPosition;
} else if (rangeOrPosition instanceof Position) {
this.range = new Range(rangeOrPosition, rangeOrPosition);
} else { } else {
throw new Error('Illegal argument'); throw new Error('Illegal argument');
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册