MCPcopy
hub / github.com/microsoft/vscode / createFilepathRegexp

Function createFilepathRegexp

extensions/copilot/src/util/common/markdown.ts:26–41  ·  view source on GitHub ↗
(languageId?: string)

Source from the content-addressed store, hash-verified

24export const filepathCodeBlockMarker = 'filepath:';
25
26export function createFilepathRegexp(languageId?: string): RegExp {
27 const language = getLanguage(languageId);
28 const prefixes: string[] = ['#', '\\/\\/']; // always allow # and // as comment start
29 const suffixes: string[] = [];
30 function add(lineComment: { start: string; end?: string }) {
31 prefixes.push(escapeRegExpCharacters(lineComment.start));
32 if (lineComment.end) {
33 suffixes.push(escapeRegExpCharacters(lineComment.end));
34 }
35 }
36 add(language.lineComment);
37 language.alternativeLineComments?.forEach(add);
38 const startMatch = `(?:${prefixes.join('|')})`;
39 const optionalEndMatch = suffixes.length ? `(?:\\s*${suffixes.join('|')})?` : '';
40 return new RegExp(`^\\s*${startMatch}\\s*${filepathCodeBlockMarker}\\s*(.*?)${optionalEndMatch}\\s*$`);
41}
42
43/**
44 * Create a markdown code block with an optional language id and an optional file path.

Callers 3

markdown.spec.tsFile · 0.90
getFilePathFunction · 0.90
extractResourcesFromTagFunction · 0.90

Calls 4

getLanguageFunction · 0.90
addFunction · 0.70
forEachMethod · 0.65
joinMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…