本文整理匯總了TypeScript中vs/workbench/api/common/extHostTypes.Range.intersection方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Range.intersection方法的具體用法?TypeScript Range.intersection怎麽用?TypeScript Range.intersection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/workbench/api/common/extHostTypes.Range
的用法示例。
在下文中一共展示了Range.intersection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('Range, intersection', function () {
let range = new types.Range(1, 1, 2, 11);
let res: types.Range;
res = range.intersection(range)!;
assert.equal(res.start.line, 1);
assert.equal(res.start.character, 1);
assert.equal(res.end.line, 2);
assert.equal(res.end.character, 11);
res = range.intersection(new types.Range(2, 12, 4, 0))!;
assert.equal(res, undefined);
res = range.intersection(new types.Range(0, 0, 1, 0))!;
assert.equal(res, undefined);
res = range.intersection(new types.Range(0, 0, 1, 1))!;
assert.ok(res.isEmpty);
assert.equal(res.start.line, 1);
assert.equal(res.start.character, 1);
res = range.intersection(new types.Range(2, 11, 61, 1))!;
assert.ok(res.isEmpty);
assert.equal(res.start.line, 2);
assert.equal(res.start.character, 11);
assert.throws(() => range.intersection(null!));
assert.throws(() => range.intersection(undefined!));
});
示例2:
assert.throws(() => range.intersection(undefined!));