tokenizationTextModelPart.ts ×6

Frontier kind: Code frontier

unlabeled · c_d6018bba0c5d

4 tests · 40912 LOC · 238 files · introduces 0 tests · 47 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges47 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5027 ranges40912 lines · 238 files · Browse complete extent
All tests (intent)
4 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 47 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/model/tokens/tokenizationTextModelPart.ts 43 introduced LOC · 6 ranges

Open complete file

264
265 public getWordAtPosition(_position: IPosition): IWordAtPosition | null {
266 > this.assertNotDisposed(); tokenizationTextModelPart.ts
267 >
268 > const position = this._textModel.validatePosition(_position);
269 > const lineContent = this._textModel.getLineContent(position.lineNumber);
270 > const lineTokens = this.getLineTokens(position.lineNumber);
271 > const tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
272 >
273 > // (1). First try checking right biased word
274 > const [rbStartOffset, rbEndOffset] = TokenizationTextModelPart._findLanguageBoundaries(lineTokens, tokenIndex);
275 > const rightBiasedWord = getWordAtText(
276 > position.column,
277 > this.getLanguageConfiguration(lineTokens.getLanguageId(tokenIndex)).getWordDefinition(),
278 > lineContent.substring(rbStartOffset, rbEndOffset),
279 > rbStartOffset
280 > );
281 > // Make sure the result touches the original passed in position
282 > if (
283 > rightBiasedWord &&
284 rightBiasedWord.startColumn <= _position.column &&
285 _position.column <= rightBiasedWord.endColumn
287 return rightBiasedWord;
288 }
289
290 // (2). Else, if we were at a language boundary, check the left biased word
291 > if (tokenIndex > 0 && rbStartOffset === position.column - 1) { tokenizationTextModelPart.ts
292 // edge case, where `position` sits between two tokens belonging to two different languages
293 const [lbStartOffset, lbEndOffset] = TokenizationTextModelPart._findLanguageBoundaries(
312
313 return null;
315
316 private getLanguageConfiguration(languageId: string): ResolvedLanguageConfiguration {
317 > return this._languageConfigurationService.getLanguageConfiguration(languageId); tokenizationTextModelPart.ts
318 > }
319
320 private static _findLanguageBoundaries(lineTokens: LineTokens, tokenIndex: number): [number, number] {
321 > const languageId = lineTokens.getLanguageId(tokenIndex); tokenizationTextModelPart.ts
322 >
323 > // go left until a different language is hit
324 > let startOffset = 0;
325 > for (let i = tokenIndex; i >= 0 && lineTokens.getLanguageId(i) === languageId; i--) {
326 > startOffset = lineTokens.getStartOffset(i);
327 > }
328 >
329 > // go right until a different language is hit
330 > let endOffset = lineTokens.getLineContent().length;
331 > for (
332 > let i = tokenIndex, tokenCount = lineTokens.getCount();
333 > i < tokenCount && lineTokens.getLanguageId(i) === languageId;
334 > i++
335 > ) {
336 > endOffset = lineTokens.getEndOffset(i);
337 > }
338 >
339 > return [startOffset, endOffset];
340 > }
341
342 public getWordUntilPosition(position: IPosition): IWordAtPosition {
src/vs/editor/common/languages/languageConfigurationRegistry.ts 2 introduced LOC · 1 range

Open complete file

395
396 public getWordDefinition(): RegExp {
397 > return ensureValidWordDefinition(this.wordDefinition); languageConfigurationRegistry.ts
398 > }
399
400 public get brackets(): RichEditBrackets | null {
src/vs/editor/common/model/textModel.ts 2 introduced LOC · 1 range

Open complete file

2107
2108 public getWordAtPosition(position: IPosition): IWordAtPosition | null {
2109 > return this._tokenizationTextModelPart.getWordAtPosition(position); textModel.ts
2110 > }
2111
2112 public getWordUntilPosition(position: IPosition): IWordAtPosition {