linkComputer.ts ×26

Frontier kind: Code frontier

unlabeled · c_f71d4d025ecb

13 tests · 3792 LOC · 21 files · introduces 0 tests · 209 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
26 ranges209 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
540 ranges3792 lines · 21 files · Browse complete extent
All tests (intent)
13 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.

Introduced files, introduced tests, and structurally relevant concept specializationlinkComputer.ts ×3 · 5 introduced LOClinkComputer.ts ×3linkComputer.ts ×1 · 3 introduced LOClinkComputer.ts ×1linkComputer.ts ×1 · 2 introduced LOClinkComputer.ts ×1linkComputer.ts ×1 · 1 introduced LOClinkComputer.ts ×1linkComputer.ts ×1 · 1 introduced LOClinkComputer.ts ×1linkComputer.ts ×1 · 5 introduced LOClinkComputer.ts ×1linkComputer.ts ×1 · 4 introduced LOClinkComputer.ts ×1linkComputer.ts ×2 · 5 introduced LOClinkComputer.ts ×2linkComputer.ts ×3 · 3 introduced LOClinkComputer.ts ×3linkComputer.test|title=Editor Modes - Link Computer issue #121438: Link detection stops at《...》|occurrence=1, linkComputer.test|title=Editor Modes - Link Computer issue #121438: Link detection stops at【...】|occurrence=1, +2 · 0 introduced LOClinkComputer.test|title=…linkComputer.ts ×1 · 3 introduced LOClinkComputer.ts ×1linkComputer.test|title=Editor Modes - Link Computer issue #86358: URL wrong recognition pattern|occurrence=1, linkComputer.test|title=Editor Modes - Link Computer issue #225513: Cmd-Click doesn't work on JSDoc {@link URL%7CLinkText} format|occurrence=1 · 0 introduced LOClinkComputer.test|title=…linkComputer.ts ×1 · 3 introduced LOClinkComputer.ts ×1linkComputer.ts ×1 · 2 introduced LOClinkComputer.ts ×1linkComputer.ts ×1 · 2 introduced LOClinkComputer.ts ×1linkComputer.ts ×1 · 1 introduced LOClinkComputer.ts ×1linkComputer.ts ×3 · 7 introduced LOClinkComputer.ts ×3linkComputer.ts ×1 · 3 introduced LOClinkComputer.ts ×1linkComputer.ts ×1 · 2 introduced LOClinkComputer.ts ×1linkComputer.ts ×1 · 1 introduced LOClinkComputer.ts ×1linkComputer.ts ×10 · 82 introduced LOClinkComputer.ts ×10characterClassifier.ts ×1 · 2 introduced LOCcharacterClassifier.ts ×…characterClassifier.ts ×2 · 4 introduced LOCcharacterClassifier.ts ×…characterClassifier.ts ×4 · 20 introduced LOCcharacterClassifier.ts ×…characterClassifier.ts ×10 · 51 introduced LOCcharacterClassifier.ts ×…uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1uint.ts ×2 · 43 introduced LOCuint.ts ×2lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uint.ts · 59 LOCcommon/uint.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/editor/common/core/characterClassifier.ts · 86 LOCcore/characterClassifier…src/vs/editor/common/languages/linkComputer.ts · 351 LOClanguages/linkComputer.t…src/vs/nls.ts · 244 LOCvs/nls.tscharCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…linkComputer.test|title=Editor Modes - Link Computer Parsing|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer Parsing|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #100353: Link detection stops at &(double-byte)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #100353: Link detection stops at &(double-byte)|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #121438: Link detection stops at “...”|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #121438: Link detection stops at “...”|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #121438: Link detection stops at《...》|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #121438: Link detection stops at《...》|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #121438: Link detection stops at【...】|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #121438: Link detection stops at【...】|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #150905: Colon after bare hyperlink is treated as its part|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #150905: Colon after bare hyperlink is treated as its part|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #156875: Links include quotes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #156875: Links include quotes|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #225513: Cmd-Click doesn't work on JSDoc {@link URL%7CLinkText} format|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #225513: Cmd-Click doesn't work on JSDoc {@link URL%7CLinkText} format|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #62278: "Ctrl + click to follow link" for IPv6 URLs|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #62278: "Ctrl + click to follow link" for IPv6 URLs|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #67022: Space as end of hyperlink isn't always good idea|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #67022: Space as end of hyperlink isn't always good idea|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #70254: bold links dont open in markdown file using editor mode with ctrl + click|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #70254: bold links dont open in markdown file using editor mode with ctrl + click|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #7855|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #7855|occurrence=1linkComputer.test|title=…linkComputer.test|title=Editor Modes - Link Computer issue #86358: URL wrong recognition pattern|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/linkComputer.test|title=Editor Modes - Link Computer issue #86358: URL wrong recognition pattern|occurrence=1linkComputer.test|title=…Focused concept · linkComputer.ts ×26 · 209 introduced LOClinkComputer.ts ×26

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.

1 file ranked by introduced lines: 209 introduced LOC across 26 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/languages/linkComputer.ts 209 introduced LOC · 26 ranges

Open complete file

40
41 constructor(rows: number, cols: number, defaultValue: number) {
42 > const data = new Uint8Array(rows * cols); linkComputer.ts
43 > for (let i = 0, len = rows * cols; i < len; i++) {
44 > data[i] = defaultValue;
45 > }
46 >
47 > this._data = data;
48 > this.rows = rows;
49 > this.cols = cols;
50 > }
51
52 public get(row: number, col: number): number {
53 > return this._data[row * this.cols + col]; linkComputer.ts
54 > }
55
56 public set(row: number, col: number, value: number): void {
57 > this._data[row * this.cols + col] = value; linkComputer.ts
58 > }
59 }
60
65
66 constructor(edges: Edge[]) {
67 > let maxCharCode = 0; linkComputer.ts
68 > let maxState = State.Invalid;
69 > for (let i = 0, len = edges.length; i < len; i++) {
70 > const [from, chCode, to] = edges[i];
71 > if (chCode > maxCharCode) {
72 > maxCharCode = chCode;
73 > }
74 > if (from > maxState) {
75 > maxState = from;
76 > }
77 > if (to > maxState) {
78 > maxState = to;
79 > }
80 > }
81 >
82 > maxCharCode++;
83 > maxState++;
84 >
85 > const states = new Uint8Matrix(maxState, maxCharCode, State.Invalid);
86 > for (let i = 0, len = edges.length; i < len; i++) {
87 > const [from, chCode, to] = edges[i];
88 > states.set(from, chCode, to);
89 > }
90 >
91 > this._states = states;
92 > this._maxCharCode = maxCharCode;
93 > }
94
95 public nextState(currentState: State, chCode: number): State {
96 > if (chCode < 0 || chCode >= this._maxCharCode) { linkComputer.ts
97 return State.Invalid;
98 }
99 > return this._states.get(currentState, chCode); linkComputer.ts
100 > }
101 }
102
103 // State machine for http:// or https:// or file://
104 let _stateMachine: StateMachine | null = null;
105 > function getStateMachine(): StateMachine { linkComputer.ts
106 > if (_stateMachine === null) {
107 > _stateMachine = new StateMachine([
108 > [State.Start, CharCode.h, State.H],
109 > [State.Start, CharCode.H, State.H],
110 > [State.Start, CharCode.f, State.F],
111 > [State.Start, CharCode.F, State.F],
112 >
113 > [State.H, CharCode.t, State.HT],
114 > [State.H, CharCode.T, State.HT],
115 >
116 > [State.HT, CharCode.t, State.HTT],
117 > [State.HT, CharCode.T, State.HTT],
118 >
119 > [State.HTT, CharCode.p, State.HTTP],
120 > [State.HTT, CharCode.P, State.HTTP],
121 >
122 > [State.HTTP, CharCode.s, State.BeforeColon],
123 > [State.HTTP, CharCode.S, State.BeforeColon],
124 > [State.HTTP, CharCode.Colon, State.AfterColon],
125 >
126 > [State.F, CharCode.i, State.FI],
127 > [State.F, CharCode.I, State.FI],
128 >
129 > [State.FI, CharCode.l, State.FIL],
130 > [State.FI, CharCode.L, State.FIL],
131 >
132 > [State.FIL, CharCode.e, State.BeforeColon],
133 > [State.FIL, CharCode.E, State.BeforeColon],
134 >
135 > [State.BeforeColon, CharCode.Colon, State.AfterColon],
136 >
137 > [State.AfterColon, CharCode.Slash, State.AlmostThere],
138 >
139 > [State.AlmostThere, CharCode.Slash, State.End],
140 > ]);
141 > }
142 > return _stateMachine;
143 > }
144
145
151
152 let _classifier: CharacterClassifier<CharacterClass> | null = null;
153 > function getClassifier(): CharacterClassifier<CharacterClass> { linkComputer.ts
154 > if (_classifier === null) {
155 > _classifier = new CharacterClassifier<CharacterClass>(CharacterClass.None);
156 >
157 > // allow-any-unicode-next-line
158 > const FORCE_TERMINATION_CHARACTERS = ' \t<>\'\"、。。、,.:;‘〈「『〔([{「」}])〕』」〉’`~…|';
159 > for (let i = 0; i < FORCE_TERMINATION_CHARACTERS.length; i++) {
160 > _classifier.set(FORCE_TERMINATION_CHARACTERS.charCodeAt(i), CharacterClass.ForceTermination);
161 > }
162 >
163 > const CANNOT_END_WITH_CHARACTERS = '.,;:';
164 > for (let i = 0; i < CANNOT_END_WITH_CHARACTERS.length; i++) {
165 > _classifier.set(CANNOT_END_WITH_CHARACTERS.charCodeAt(i), CharacterClass.CannotEndIn);
166 > }
167 > }
168 > return _classifier;
169 > }
170
171 export class LinkComputer {
172
173 private static _createLink(classifier: CharacterClassifier<CharacterClass>, line: string, lineNumber: number, linkBeginIndex: number, linkEndIndex: number): ILink {
174 > // Do not allow to end link in certain characters... linkComputer.ts
175 > let lastIncludedCharIndex = linkEndIndex - 1;
176 > do {
177 > const chCode = line.charCodeAt(lastIncludedCharIndex);
178 > const chClass = classifier.get(chCode);
179 > if (chClass !== CharacterClass.CannotEndIn) {
180 > break;
181 > }
182 lastIncludedCharIndex--;
183 > } while (lastIncludedCharIndex > linkBeginIndex); linkComputer.ts
184 >
185 > // Handle links enclosed in parens, square brackets and curlys.
186 > if (linkBeginIndex > 0) {
187 const charCodeBeforeLink = line.charCodeAt(linkBeginIndex - 1);
188 const lastCharCodeInLink = line.charCodeAt(lastIncludedCharIndex);
199 }
200 }
202 > return {
203 > range: {
204 > startLineNumber: lineNumber,
205 > startColumn: linkBeginIndex + 1,
206 > endLineNumber: lineNumber,
207 > endColumn: lastIncludedCharIndex + 2
208 > },
209 > url: line.substring(linkBeginIndex, lastIncludedCharIndex + 1)
210 > };
211 > }
212
213 public static computeLinks(model: ILinkComputerTarget, stateMachine: StateMachine = getStateMachine()): ILink[] {
214 > const classifier = getClassifier(); linkComputer.ts
215 >
216 > const result: ILink[] = [];
217 > for (let i = 1, lineCount = model.getLineCount(); i <= lineCount; i++) {
218 > const line = model.getLineContent(i);
219 > const len = line.length;
220 >
221 > let j = 0;
222 > let linkBeginIndex = 0;
223 > let linkBeginChCode = 0;
224 > let state = State.Start;
225 > let hasOpenParens = false;
226 > let hasOpenSquareBracket = false;
227 > let inSquareBrackets = false;
228 > let hasOpenCurlyBracket = false;
229 >
230 > while (j < len) {
231 >
232 > let resetStateMachine = false;
233 > const chCode = line.charCodeAt(j);
234 >
235 > if (state === State.Accept) {
236 > let chClass: CharacterClass;
237 > switch (chCode) {
238 > case CharCode.OpenParen:
239 hasOpenParens = true;
240 chClass = CharacterClass.None;
241 break;
242 > case CharCode.CloseParen: linkComputer.ts
243 chClass = (hasOpenParens ? CharacterClass.None : CharacterClass.ForceTermination);
244 break;
245 > case CharCode.OpenSquareBracket: linkComputer.ts
246 inSquareBrackets = true;
247 hasOpenSquareBracket = true;
248 chClass = CharacterClass.None;
249 break;
250 > case CharCode.CloseSquareBracket: linkComputer.ts
251 inSquareBrackets = false;
252 chClass = (hasOpenSquareBracket ? CharacterClass.None : CharacterClass.ForceTermination);
253 break;
254 > case CharCode.OpenCurlyBrace: linkComputer.ts
255 hasOpenCurlyBracket = true;
256 chClass = CharacterClass.None;
257 break;
258 > case CharCode.CloseCurlyBrace: linkComputer.ts
259 chClass = (hasOpenCurlyBracket ? CharacterClass.None : CharacterClass.ForceTermination);
260 break;
262 > // The following three rules make it that ' or " or ` are allowed inside links
263 > // only if the link is wrapped by some other quote character
264 > case CharCode.SingleQuote:
265 > case CharCode.DoubleQuote:
266 > case CharCode.BackTick:
267 if (linkBeginChCode === chCode) {
268 chClass = CharacterClass.ForceTermination;
273 }
274 break;
275 > case CharCode.Asterisk: linkComputer.ts
276 // `*` terminates a link if the link began with `*`
277 chClass = (linkBeginChCode === CharCode.Asterisk) ? CharacterClass.ForceTermination : CharacterClass.None;
278 break;
279 > case CharCode.Space: linkComputer.ts
280 // ` ` allow space in between [ and ]
281 chClass = (inSquareBrackets ? CharacterClass.None : CharacterClass.ForceTermination);
282 break;
283 > default: linkComputer.ts
284 > chClass = classifier.get(chCode);
285 > }
286 >
287 > // Check if character terminates link
288 > if (chClass === CharacterClass.ForceTermination) {
289 > result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, j));
290 > resetStateMachine = true;
291 > }
292 > } else if (state === State.End) {
293 >
294 > let chClass: CharacterClass;
295 > if (chCode === CharCode.OpenSquareBracket) {
296 // Allow for the authority part to contain ipv6 addresses which contain [ and ]
297 hasOpenSquareBracket = true;
298 chClass = CharacterClass.None;
299 > } else { linkComputer.ts
300 chClass = classifier.get(chCode);
301 }
303 > // Check if character terminates link
304 > if (chClass === CharacterClass.ForceTermination) {
305 resetStateMachine = true;
306 > } else { linkComputer.ts
307 > state = State.Accept;
308 > }
309 > } else {
310 > state = stateMachine.nextState(state, chCode);
311 > if (state === State.Invalid) {
312 > resetStateMachine = true;
313 > }
314 > }
315 >
316 > if (resetStateMachine) {
317 > state = State.Start;
318 > hasOpenParens = false;
319 > hasOpenSquareBracket = false;
320 > hasOpenCurlyBracket = false;
321 >
322 > // Record where the link started
323 > linkBeginIndex = j + 1;
324 > linkBeginChCode = chCode;
325 > }
326 >
327 > j++;
328 > }
329 >
330 > if (state === State.Accept) {
331 result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, len));
332 }
334 > }
335 >
336 > return result;
337 > }
338 }
339
348 return [];
349 }
350 > return LinkComputer.computeLinks(model); linkComputer.ts
351 > }