本文整理匯總了TypeScript中vs/editor/common/model/textModel.TextModel.getLineTokens方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TextModel.getLineTokens方法的具體用法?TypeScript TextModel.getLineTokens怎麽用?TypeScript TextModel.getLineTokens使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/model/textModel.TextModel
的用法示例。
在下文中一共展示了TextModel.getLineTokens方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('insertion on empty line', () => {
const model = new TextModel('some text', TextModel.DEFAULT_CREATION_OPTIONS, new LanguageIdentifier('test', 0));
model._tokens._setTokens(0, 0, model.getLineMaxColumn(1) - 1, TestToken.toTokens([new TestToken(0, 1)]));
model.applyEdits([{
range: new Range(1, 1, 1, 10),
text: ''
}]);
model._tokens._setTokens(0, 0, model.getLineMaxColumn(1) - 1, new Uint32Array(0));
model.applyEdits([{
range: new Range(1, 1, 1, 1),
text: 'a'
}]);
const actualTokens = model.getLineTokens(1);
assertLineTokens(actualTokens, [new TestToken(0, 1)]);
});
示例2: testApplyEdits
function testApplyEdits(initial: IBufferLineState[], edits: IEdit[], expected: IBufferLineState[]): void {
const initialText = initial.map(el => el.text).join('\n');
const model = new TextModel(initialText, TextModel.DEFAULT_CREATION_OPTIONS, new LanguageIdentifier('test', 0));
for (let lineIndex = 0; lineIndex < initial.length; lineIndex++) {
const lineTokens = initial[lineIndex].tokens;
const lineTextLength = model.getLineMaxColumn(lineIndex + 1) - 1;
model._tokens._setTokens(0, lineIndex, lineTextLength, TestToken.toTokens(lineTokens));
}
model.applyEdits(edits.map((ed) => ({
identifier: null,
range: ed.range,
text: ed.text,
forceMoveMarkers: false
})));
for (let lineIndex = 0; lineIndex < expected.length; lineIndex++) {
const actualLine = model.getLineContent(lineIndex + 1);
const actualTokens = model.getLineTokens(lineIndex + 1);
assert.equal(actualLine, expected[lineIndex].text);
assertLineTokens(actualTokens, expected[lineIndex].tokens);
}
}