@myagentroam/code-navigation 0.9.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +2 -0
  5. package/dist/languages/c-family.d.ts +7 -0
  6. package/dist/languages/c-family.js +8 -0
  7. package/dist/languages/c-preprocessor.d.ts +2 -0
  8. package/dist/languages/c-preprocessor.js +30 -0
  9. package/dist/languages/c.d.ts +6 -0
  10. package/dist/languages/c.js +7 -0
  11. package/dist/languages/cpp.d.ts +7 -0
  12. package/dist/languages/cpp.js +9 -0
  13. package/dist/languages/csharp.d.ts +7 -0
  14. package/dist/languages/csharp.js +17 -0
  15. package/dist/languages/css.d.ts +5 -0
  16. package/dist/languages/css.js +6 -0
  17. package/dist/languages/ecmascript.d.ts +7 -0
  18. package/dist/languages/ecmascript.js +40 -0
  19. package/dist/languages/file-target.d.ts +1 -0
  20. package/dist/languages/file-target.js +9 -0
  21. package/dist/languages/go.d.ts +7 -0
  22. package/dist/languages/go.js +31 -0
  23. package/dist/languages/html.d.ts +5 -0
  24. package/dist/languages/html.js +6 -0
  25. package/dist/languages/jvm.d.ts +7 -0
  26. package/dist/languages/jvm.js +16 -0
  27. package/dist/languages/less.d.ts +5 -0
  28. package/dist/languages/less.js +6 -0
  29. package/dist/languages/markdown.d.ts +7 -0
  30. package/dist/languages/markdown.js +112 -0
  31. package/dist/languages/markup-reference.d.ts +3 -0
  32. package/dist/languages/markup-reference.js +27 -0
  33. package/dist/languages/objective-c.d.ts +7 -0
  34. package/dist/languages/objective-c.js +10 -0
  35. package/dist/languages/objective-cpp.d.ts +7 -0
  36. package/dist/languages/objective-cpp.js +9 -0
  37. package/dist/languages/python.d.ts +7 -0
  38. package/dist/languages/python.js +16 -0
  39. package/dist/languages/rust.d.ts +7 -0
  40. package/dist/languages/rust.js +17 -0
  41. package/dist/languages/sass.d.ts +5 -0
  42. package/dist/languages/sass.js +6 -0
  43. package/dist/languages/scss.d.ts +5 -0
  44. package/dist/languages/scss.js +6 -0
  45. package/dist/languages/stylesheet-reference.d.ts +3 -0
  46. package/dist/languages/stylesheet-reference.js +37 -0
  47. package/dist/languages/vue.d.ts +7 -0
  48. package/dist/languages/vue.js +74 -0
  49. package/dist/registry.d.ts +4 -0
  50. package/dist/registry.js +54 -0
  51. package/dist/symbol-navigation-registry.d.ts +4 -0
  52. package/dist/symbol-navigation-registry.js +276 -0
  53. package/dist/symbol-navigation.d.ts +2 -0
  54. package/dist/symbol-navigation.js +1 -0
  55. package/dist/types.d.ts +35 -0
  56. package/dist/types.js +17 -0
  57. package/package.json +32 -0
@@ -0,0 +1,27 @@
1
+ import { localWorkspaceFileTarget } from './file-target.js';
2
+ const markupAttribute = /(?:^|[\s<])(?:src|href)\s*=\s*(["'])([^"'\r\n]+)\1/giu;
3
+ export function createMarkupFileSpecifierParser(languageId) {
4
+ return {
5
+ find: (source, position) => findMarkupReference(source, position, languageId)
6
+ };
7
+ }
8
+ export function findMarkupReference(source, position, languageId) {
9
+ for (const match of source.matchAll(markupAttribute)) {
10
+ const value = match[2];
11
+ if (value === undefined)
12
+ continue;
13
+ const target = localWorkspaceFileTarget(value);
14
+ const from = (match.index ?? 0) + match[0].indexOf(value);
15
+ if (target === undefined || position < from || position >= from + value.length)
16
+ continue;
17
+ return {
18
+ value: target,
19
+ from,
20
+ to: from + value.length,
21
+ languageId,
22
+ extractorId: `${languageId}.attribute`,
23
+ kind: 'relative-file'
24
+ };
25
+ }
26
+ return undefined;
27
+ }
@@ -0,0 +1,7 @@
1
+ export declare const objectiveCFileSpecifierParser: import("../types.js").FileSpecifierParser;
2
+ export declare const objectiveCNavigationSyntaxDefinition: {
3
+ id: "objective-c";
4
+ parser: import("../types.js").FileSpecifierParser;
5
+ suffixes: string[];
6
+ probe: (source: string) => boolean;
7
+ };
@@ -0,0 +1,10 @@
1
+ import { createCPreprocessorFileSpecifierParser } from './c-preprocessor.js';
2
+ const objectiveCSyntax = /(?:@\s*(?:interface|implementation|protocol|class|import)\b|#\s*import\b)/u;
3
+ export const objectiveCFileSpecifierParser = createCPreprocessorFileSpecifierParser('objective-c');
4
+ export const objectiveCNavigationSyntaxDefinition = {
5
+ id: 'objective-c',
6
+ parser: objectiveCFileSpecifierParser,
7
+ suffixes: ['.m', '.h'],
8
+ probe: (source) => objectiveCSyntax.test(source) &&
9
+ !/(?:\b(?:namespace|template)\b|\bstd\s*::|(?<!@)\bclass\s+\w+)/u.test(source)
10
+ };
@@ -0,0 +1,7 @@
1
+ export declare const objectiveCppFileSpecifierParser: import("../types.js").FileSpecifierParser;
2
+ export declare const objectiveCppNavigationSyntaxDefinition: {
3
+ id: "objective-cpp";
4
+ parser: import("../types.js").FileSpecifierParser;
5
+ suffixes: string[];
6
+ probe: (source: string) => boolean;
7
+ };
@@ -0,0 +1,9 @@
1
+ import { createCPreprocessorFileSpecifierParser } from './c-preprocessor.js';
2
+ export const objectiveCppFileSpecifierParser = createCPreprocessorFileSpecifierParser('objective-cpp');
3
+ export const objectiveCppNavigationSyntaxDefinition = {
4
+ id: 'objective-cpp',
5
+ parser: objectiveCppFileSpecifierParser,
6
+ suffixes: ['.mm', '.h'],
7
+ probe: (source) => /(?:@\s*(?:interface|implementation|protocol|class|import)\b|#\s*import\b)/u.test(source) &&
8
+ /(?:\b(?:namespace|template)\b|\bstd\s*::|(?<!@)\bclass\s+\w+)/u.test(source)
9
+ };
@@ -0,0 +1,7 @@
1
+ import { type FileSpecifierParser } from '../types.js';
2
+ export declare const pythonFileSpecifierParser: FileSpecifierParser;
3
+ export declare const pythonNavigationSyntaxDefinition: {
4
+ id: "python";
5
+ parser: FileSpecifierParser;
6
+ suffixes: string[];
7
+ };
@@ -0,0 +1,16 @@
1
+ import { rangeAtColumn, sourceLineAt } from '../types.js';
2
+ function find(source, position) {
3
+ const line = sourceLineAt(source, position);
4
+ const match = /^\s*(?:from\s+((?:(?:\.+)?[\p{L}_$][\p{L}\p{N}_$]*(?:\.[\p{L}_$][\p{L}\p{N}_$]*)*)|\.+)\s+import\b|import\s+([\p{L}_$][\p{L}\p{N}_$]*(?:\.[\p{L}_$][\p{L}\p{N}_$]*)*))/u.exec(line.text);
5
+ return rangeAtColumn(line.text, line.column, match, match?.[1] ?? match?.[2], {
6
+ languageId: 'python',
7
+ extractorId: 'python.import',
8
+ kind: (match?.[1] ?? match?.[2] ?? '').startsWith('.') ? 'relative-file' : 'namespace'
9
+ }, line.from);
10
+ }
11
+ export const pythonFileSpecifierParser = { find };
12
+ export const pythonNavigationSyntaxDefinition = {
13
+ id: 'python',
14
+ parser: pythonFileSpecifierParser,
15
+ suffixes: ['.py', '.pyw']
16
+ };
@@ -0,0 +1,7 @@
1
+ import { type FileSpecifierParser } from '../types.js';
2
+ export declare const rustFileSpecifierParser: FileSpecifierParser;
3
+ export declare const rustNavigationSyntaxDefinition: {
4
+ id: "rust";
5
+ parser: FileSpecifierParser;
6
+ suffixes: string[];
7
+ };
@@ -0,0 +1,17 @@
1
+ import { rangeAtColumn, sourceLineAt } from '../types.js';
2
+ function find(source, position) {
3
+ const line = sourceLineAt(source, position);
4
+ const match = /^\s*(?:#\s*\[\s*path\s*=\s*["']([^"']+)["']\s*\]\s*)?(?:pub(?:\([^)]*\))?\s+)?mod\s+([A-Za-z_][A-Za-z0-9_]*)\s*;/u.exec(line.text);
5
+ const value = match?.[1] ?? match?.[2];
6
+ return rangeAtColumn(line.text, line.column, match, value, {
7
+ languageId: 'rust',
8
+ extractorId: match?.[1] === undefined ? 'rust.module' : 'rust.path-module',
9
+ kind: match?.[1] === undefined ? 'module' : 'relative-file'
10
+ }, line.from);
11
+ }
12
+ export const rustFileSpecifierParser = { find };
13
+ export const rustNavigationSyntaxDefinition = {
14
+ id: 'rust',
15
+ parser: rustFileSpecifierParser,
16
+ suffixes: ['.rs']
17
+ };
@@ -0,0 +1,5 @@
1
+ export declare const sassNavigationSyntaxDefinition: {
2
+ id: "sass";
3
+ parser: import("../types.js").FileSpecifierParser;
4
+ suffixes: string[];
5
+ };
@@ -0,0 +1,6 @@
1
+ import { createStylesheetFileSpecifierParser } from './stylesheet-reference.js';
2
+ export const sassNavigationSyntaxDefinition = {
3
+ id: 'sass',
4
+ parser: createStylesheetFileSpecifierParser('sass'),
5
+ suffixes: ['.sass']
6
+ };
@@ -0,0 +1,5 @@
1
+ export declare const scssNavigationSyntaxDefinition: {
2
+ id: "scss";
3
+ parser: import("../types.js").FileSpecifierParser;
4
+ suffixes: string[];
5
+ };
@@ -0,0 +1,6 @@
1
+ import { createStylesheetFileSpecifierParser } from './stylesheet-reference.js';
2
+ export const scssNavigationSyntaxDefinition = {
3
+ id: 'scss',
4
+ parser: createStylesheetFileSpecifierParser('scss'),
5
+ suffixes: ['.scss']
6
+ };
@@ -0,0 +1,3 @@
1
+ import type { FileReference, FileSpecifierParser, NavigationLanguageId } from '../types.js';
2
+ export declare function createStylesheetFileSpecifierParser(languageId: Extract<NavigationLanguageId, 'css' | 'scss' | 'sass' | 'less'>): FileSpecifierParser;
3
+ export declare function findStylesheetReference(source: string, position: number, languageId: Extract<NavigationLanguageId, 'css' | 'scss' | 'sass' | 'less' | 'vue'>): FileReference | undefined;
@@ -0,0 +1,37 @@
1
+ import { localWorkspaceFileTarget } from './file-target.js';
2
+ const stylesheetImport = /@(?:import|use|forward)\b(?:\s+\([^)]*\))?\s+(?:url\(\s*)?(["'])([^"'\r\n]+)\1\s*\)?/giu;
3
+ const stylesheetUrl = /\burl\(\s*(["']?)([^"'()\s\r\n]+)\1\s*\)/giu;
4
+ export function createStylesheetFileSpecifierParser(languageId) {
5
+ return {
6
+ find: (source, position) => findStylesheetReference(source, position, languageId)
7
+ };
8
+ }
9
+ export function findStylesheetReference(source, position, languageId) {
10
+ for (const [expression, extractor] of [
11
+ [stylesheetImport, 'import'],
12
+ [stylesheetUrl, 'url']
13
+ ]) {
14
+ expression.lastIndex = 0;
15
+ for (const match of source.matchAll(expression)) {
16
+ const value = match[2];
17
+ if (value === undefined)
18
+ continue;
19
+ const target = localWorkspaceFileTarget(value);
20
+ const from = (match.index ?? 0) + match[0].indexOf(value);
21
+ if (target === undefined ||
22
+ position < from ||
23
+ position >= from + value.length ||
24
+ (extractor === 'url' && /^\s*@(?:import|use|forward)\b/iu.test(match[0])))
25
+ continue;
26
+ return {
27
+ value: target,
28
+ from,
29
+ to: from + value.length,
30
+ languageId,
31
+ extractorId: `${languageId}.${extractor}`,
32
+ kind: 'relative-file'
33
+ };
34
+ }
35
+ }
36
+ return undefined;
37
+ }
@@ -0,0 +1,7 @@
1
+ import type { FileSpecifierParser } from '../types.js';
2
+ export declare const vueFileSpecifierParser: FileSpecifierParser;
3
+ export declare const vueNavigationSyntaxDefinition: {
4
+ id: "vue";
5
+ parser: FileSpecifierParser;
6
+ suffixes: string[];
7
+ };
@@ -0,0 +1,74 @@
1
+ import { ecmascriptFileSpecifierParser } from './ecmascript.js';
2
+ import { findMarkupReference } from './markup-reference.js';
3
+ import { findStylesheetReference } from './stylesheet-reference.js';
4
+ const scriptBlock = /<script\b[^>]*>([\s\S]*?)<\/script\s*>/giu;
5
+ const styleBlock = /<style\b[^>]*>([\s\S]*?)<\/style\s*>/giu;
6
+ const styleLanguage = /\blang\s*=\s*(["'])([^"'\r\n]+)\1/iu;
7
+ function find(source, position) {
8
+ return (findMarkupReference(source, position, 'vue') ??
9
+ findEmbeddedReference(source, position, scriptBlock, ecmascriptFileSpecifierParser) ??
10
+ findStyleReference(source, position) ??
11
+ findReferenceWithoutBlockBoundary(source, position));
12
+ }
13
+ function findReferenceWithoutBlockBoundary(source, position) {
14
+ const ecmascript = ecmascriptFileSpecifierParser.find(source, position);
15
+ if (ecmascript !== undefined)
16
+ return ecmascript;
17
+ const lineFrom = source.lastIndexOf('\n', Math.max(0, position - 1)) + 1;
18
+ const stylesheetLanguage = /^[ \t]*@(?:use|forward)\b/iu.test(source.slice(lineFrom, position))
19
+ ? 'scss'
20
+ : 'vue';
21
+ return findStylesheetReference(source, position, stylesheetLanguage);
22
+ }
23
+ function findEmbeddedReference(source, position, expression, parser) {
24
+ expression.lastIndex = 0;
25
+ for (const block of source.matchAll(expression)) {
26
+ const content = block[1] ?? '';
27
+ const contentFrom = (block.index ?? 0) + block[0].indexOf(content);
28
+ if (position < contentFrom || position >= contentFrom + content.length)
29
+ continue;
30
+ const reference = parser.find(content, position - contentFrom);
31
+ if (reference === undefined)
32
+ continue;
33
+ return {
34
+ ...reference,
35
+ from: contentFrom + reference.from,
36
+ to: contentFrom + reference.to
37
+ };
38
+ }
39
+ return undefined;
40
+ }
41
+ function findStyleReference(source, position) {
42
+ styleBlock.lastIndex = 0;
43
+ for (const block of source.matchAll(styleBlock)) {
44
+ const content = block[1] ?? '';
45
+ const contentFrom = (block.index ?? 0) + block[0].indexOf(content);
46
+ if (position < contentFrom || position >= contentFrom + content.length)
47
+ continue;
48
+ const languageId = styleBlockLanguage(block[0]);
49
+ if (languageId === undefined)
50
+ continue;
51
+ const reference = findStylesheetReference(content, position - contentFrom, languageId);
52
+ if (reference === undefined)
53
+ continue;
54
+ return {
55
+ ...reference,
56
+ from: contentFrom + reference.from,
57
+ to: contentFrom + reference.to
58
+ };
59
+ }
60
+ return undefined;
61
+ }
62
+ function styleBlockLanguage(block) {
63
+ const openingTag = block.slice(0, block.indexOf('>') + 1);
64
+ const value = styleLanguage.exec(openingTag)?.[2]?.toLowerCase();
65
+ if (value === undefined || value === 'css')
66
+ return 'css';
67
+ return value === 'scss' || value === 'sass' || value === 'less' ? value : undefined;
68
+ }
69
+ export const vueFileSpecifierParser = { find };
70
+ export const vueNavigationSyntaxDefinition = {
71
+ id: 'vue',
72
+ parser: vueFileSpecifierParser,
73
+ suffixes: ['.vue']
74
+ };
@@ -0,0 +1,4 @@
1
+ import type { NavigationSyntaxDefinition } from './types.js';
2
+ export declare function navigationLanguageForPath(path: string, source?: string): NavigationSyntaxDefinition | undefined;
3
+ export declare function fileSpecifierParser(path: string, source?: string): import("./types.js").FileSpecifierParser | undefined;
4
+ export declare function navigationLanguages(): readonly NavigationSyntaxDefinition[];
@@ -0,0 +1,54 @@
1
+ import { cNavigationSyntaxDefinition } from './languages/c.js';
2
+ import { cFamilyNavigationSyntaxDefinition } from './languages/c-family.js';
3
+ import { cppNavigationSyntaxDefinition } from './languages/cpp.js';
4
+ import { csharpNavigationSyntaxDefinition } from './languages/csharp.js';
5
+ import { cssNavigationSyntaxDefinition } from './languages/css.js';
6
+ import { ecmascriptNavigationSyntaxDefinition } from './languages/ecmascript.js';
7
+ import { goNavigationSyntaxDefinition } from './languages/go.js';
8
+ import { htmlNavigationSyntaxDefinition } from './languages/html.js';
9
+ import { jvmNavigationSyntaxDefinition } from './languages/jvm.js';
10
+ import { lessNavigationSyntaxDefinition } from './languages/less.js';
11
+ import { markdownNavigationSyntaxDefinition } from './languages/markdown.js';
12
+ import { objectiveCNavigationSyntaxDefinition } from './languages/objective-c.js';
13
+ import { objectiveCppNavigationSyntaxDefinition } from './languages/objective-cpp.js';
14
+ import { pythonNavigationSyntaxDefinition } from './languages/python.js';
15
+ import { rustNavigationSyntaxDefinition } from './languages/rust.js';
16
+ import { sassNavigationSyntaxDefinition } from './languages/sass.js';
17
+ import { scssNavigationSyntaxDefinition } from './languages/scss.js';
18
+ import { vueNavigationSyntaxDefinition } from './languages/vue.js';
19
+ const languages = [
20
+ cssNavigationSyntaxDefinition,
21
+ ecmascriptNavigationSyntaxDefinition,
22
+ goNavigationSyntaxDefinition,
23
+ htmlNavigationSyntaxDefinition,
24
+ jvmNavigationSyntaxDefinition,
25
+ csharpNavigationSyntaxDefinition,
26
+ lessNavigationSyntaxDefinition,
27
+ markdownNavigationSyntaxDefinition,
28
+ pythonNavigationSyntaxDefinition,
29
+ sassNavigationSyntaxDefinition,
30
+ scssNavigationSyntaxDefinition,
31
+ cNavigationSyntaxDefinition,
32
+ cppNavigationSyntaxDefinition,
33
+ objectiveCNavigationSyntaxDefinition,
34
+ objectiveCppNavigationSyntaxDefinition,
35
+ cFamilyNavigationSyntaxDefinition,
36
+ rustNavigationSyntaxDefinition,
37
+ vueNavigationSyntaxDefinition
38
+ ];
39
+ export function navigationLanguageForPath(path, source) {
40
+ const normalized = path.toLowerCase();
41
+ const candidates = languages.filter((language) => language.suffixes.some((suffix) => normalized.endsWith(suffix)));
42
+ if (candidates.length <= 1)
43
+ return candidates[0];
44
+ const probed = source === undefined ? [] : candidates.filter((candidate) => candidate.probe?.(source));
45
+ if (probed.length === 1)
46
+ return probed[0];
47
+ return candidates.find((candidate) => candidate.fallbackForAmbiguousSuffix);
48
+ }
49
+ export function fileSpecifierParser(path, source) {
50
+ return navigationLanguageForPath(path, source)?.parser;
51
+ }
52
+ export function navigationLanguages() {
53
+ return languages;
54
+ }
@@ -0,0 +1,4 @@
1
+ import type { SymbolNavigationLanguageDefinition } from './types.js';
2
+ export declare function symbolNavigationLanguageForPath(path: string): SymbolNavigationLanguageDefinition | undefined;
3
+ export declare function supportsSymbolNavigationPath(path: string): boolean;
4
+ export declare function symbolNavigationLanguages(): readonly SymbolNavigationLanguageDefinition[];
@@ -0,0 +1,276 @@
1
+ /**
2
+ * Fixed source maps generated from `Universal Ctags 6.2.1 --list-maps`.
3
+ * This remains pure metadata: Node owns the executable and index lifecycle.
4
+ */
5
+ const languages = [
6
+ { id: 'Abaqus', fileNamePatterns: ['*.inp'] },
7
+ { id: 'Abc', fileNamePatterns: ['*.abc', '*.abc'] },
8
+ { id: 'Ada', fileNamePatterns: ['*.adb', '*.ads', '*.Ada', '*.ada'] },
9
+ { id: 'Ant', fileNamePatterns: ['build.xml', '*.build.xml', '*.ant'] },
10
+ {
11
+ id: 'Asciidoc',
12
+ fileNamePatterns: ['*.asc', '*.adoc', '*.asciidoc', '*.asc', '*.adoc', '*.asciidoc']
13
+ },
14
+ {
15
+ id: 'Asm',
16
+ fileNamePatterns: [
17
+ '*.A51',
18
+ '*.29[kK]',
19
+ '*.[68][68][kKsSxX]',
20
+ '*.[xX][68][68]',
21
+ '*.asm',
22
+ '*.ASM',
23
+ '*.s',
24
+ '*.S'
25
+ ]
26
+ },
27
+ { id: 'Asp', fileNamePatterns: ['*.asp', '*.asa'] },
28
+ { id: 'Autoconf', fileNamePatterns: ['configure.in', '*.ac'] },
29
+ { id: 'AutoIt', fileNamePatterns: ['*.au3', '*.AU3', '*.aU3', '*.Au3'] },
30
+ { id: 'Automake', fileNamePatterns: ['Makefile.am', 'GNUmakefile.am', '*.am'] },
31
+ { id: 'Awk', fileNamePatterns: ['*.awk', '*.gawk', '*.mawk'] },
32
+ { id: 'Basic', fileNamePatterns: ['*.bas', '*.bi', '*.bm', '*.bb', '*.pb'] },
33
+ { id: 'Bats', fileNamePatterns: ['*.bats'] },
34
+ { id: 'BETA', fileNamePatterns: ['*.bet'] },
35
+ { id: 'BibTeX', fileNamePatterns: ['*.bib'] },
36
+ { id: 'Clojure', fileNamePatterns: ['*.clj', '*.cljs', '*.cljc'] },
37
+ { id: 'CMake', fileNamePatterns: ['CMakeLists.txt', '*.cmake'] },
38
+ { id: 'C', fileNamePatterns: ['*.c'] },
39
+ { id: 'Cargo', fileNamePatterns: ['Cargo.toml'] },
40
+ {
41
+ id: 'C++',
42
+ fileNamePatterns: [
43
+ '*.c++',
44
+ '*.cc',
45
+ '*.cp',
46
+ '*.cpp',
47
+ '*.cxx',
48
+ '*.h',
49
+ '*.h++',
50
+ '*.hh',
51
+ '*.hp',
52
+ '*.hpp',
53
+ '*.hxx',
54
+ '*.inl',
55
+ '*.C',
56
+ '*.H',
57
+ '*.CPP',
58
+ '*.CXX'
59
+ ]
60
+ },
61
+ { id: 'CSS', fileNamePatterns: ['*.css'] },
62
+ { id: 'C#', fileNamePatterns: ['*.cs'] },
63
+ { id: 'Ctags', fileNamePatterns: ['*.ctags'] },
64
+ { id: 'Cobol', fileNamePatterns: ['*.cbl', '*.cob', '*.CBL', '*.COB'] },
65
+ { id: 'CUDA', fileNamePatterns: ['*.cu', '*.cuh'] },
66
+ { id: 'D', fileNamePatterns: ['*.d', '*.di'] },
67
+ { id: 'Diff', fileNamePatterns: ['*.diff', '*.patch'] },
68
+ { id: 'DTD', fileNamePatterns: ['*.dtd', '*.mod'] },
69
+ { id: 'DTS', fileNamePatterns: ['*.dts', '*.dtsi'] },
70
+ { id: 'DosBatch', fileNamePatterns: ['*.bat', '*.cmd'] },
71
+ { id: 'Eiffel', fileNamePatterns: ['*.e'] },
72
+ { id: 'Elixir', fileNamePatterns: ['*.ex', '*.exs'] },
73
+ { id: 'EmacsLisp', fileNamePatterns: ['*.el'] },
74
+ { id: 'Erlang', fileNamePatterns: ['*.erl', '*.ERL', '*.hrl', '*.HRL'] },
75
+ { id: 'Falcon', fileNamePatterns: ['*.fal', '*.ftd'] },
76
+ { id: 'Flex', fileNamePatterns: ['*.as', '*.mxml'] },
77
+ { id: 'Forth', fileNamePatterns: ['*.fth', '*.forth', '*.fs', '*.4th', '*.f'] },
78
+ {
79
+ id: 'Fortran',
80
+ fileNamePatterns: [
81
+ '*.f',
82
+ '*.for',
83
+ '*.ftn',
84
+ '*.f77',
85
+ '*.f90',
86
+ '*.f95',
87
+ '*.f03',
88
+ '*.f08',
89
+ '*.f15',
90
+ '*.F',
91
+ '*.FOR',
92
+ '*.FTN',
93
+ '*.F77',
94
+ '*.F90',
95
+ '*.F95',
96
+ '*.F03',
97
+ '*.F08',
98
+ '*.F15'
99
+ ]
100
+ },
101
+ { id: 'Fypp', fileNamePatterns: ['*.fy'] },
102
+ { id: 'Gdbinit', fileNamePatterns: ['.gdbinit', '*.gdb'] },
103
+ { id: 'GDScript', fileNamePatterns: ['*.gd'] },
104
+ { id: 'GemSpec', fileNamePatterns: ['*.gemspec'] },
105
+ { id: 'Go', fileNamePatterns: ['*.go'] },
106
+ { id: 'GPerf', fileNamePatterns: ['*.perf', '*.gperf'] },
107
+ { id: 'Haskell', fileNamePatterns: ['*.hs'] },
108
+ { id: 'Haxe', fileNamePatterns: ['*.hx'] },
109
+ { id: 'HTML', fileNamePatterns: ['*.htm', '*.html'] },
110
+ { id: 'Iniconf', fileNamePatterns: ['*.ini', '*.conf'] },
111
+ { id: 'Inko', fileNamePatterns: ['*.inko'] },
112
+ { id: 'ITcl', fileNamePatterns: ['*.itcl'] },
113
+ { id: 'Java', fileNamePatterns: ['*.java'] },
114
+ { id: 'JavaProperties', fileNamePatterns: ['*.properties'] },
115
+ { id: 'JavaScript', fileNamePatterns: ['*.js', '*.jsx', '*.mjs'] },
116
+ { id: 'JSON', fileNamePatterns: ['*.json'] },
117
+ { id: 'Julia', fileNamePatterns: ['*.jl'] },
118
+ { id: 'Kconfig', fileNamePatterns: ['Kconfig*'] },
119
+ { id: 'LdScript', fileNamePatterns: ['*.lds.S', 'ld.script', '*.lds', '*.scr', '*.ld', '*.ldi'] },
120
+ { id: 'LEX', fileNamePatterns: ['*.lex', '*.l'] },
121
+ { id: 'Lisp', fileNamePatterns: ['*.cl', '*.clisp', '*.l', '*.lisp', '*.lsp'] },
122
+ { id: 'LiterateHaskell', fileNamePatterns: ['*.lhs'] },
123
+ { id: 'Lua', fileNamePatterns: ['*.lua'] },
124
+ { id: 'M4', fileNamePatterns: ['*.m4', '*.spt'] },
125
+ {
126
+ id: 'Man',
127
+ fileNamePatterns: [
128
+ '*.man',
129
+ '*.1',
130
+ '*.2',
131
+ '*.3',
132
+ '*.4',
133
+ '*.5',
134
+ '*.6',
135
+ '*.7',
136
+ '*.8',
137
+ '*.9',
138
+ '*.3pm',
139
+ '*.3stap',
140
+ '*.7stap'
141
+ ]
142
+ },
143
+ { id: 'Make', fileNamePatterns: ['[Mm]akefile', 'GNUmakefile', '*.mak', '*.mk'] },
144
+ { id: 'Markdown', fileNamePatterns: ['*.md', '*.markdown'] },
145
+ { id: 'MatLab', fileNamePatterns: ['*.m'] },
146
+ { id: 'Meson', fileNamePatterns: ['meson.build'] },
147
+ { id: 'MesonOptions', fileNamePatterns: ['meson_options.txt'] },
148
+ { id: 'Myrddin', fileNamePatterns: ['*.myr'] },
149
+ { id: 'NSIS', fileNamePatterns: ['*.nsi', '*.nsh'] },
150
+ { id: 'ObjectiveC', fileNamePatterns: ['*.mm', '*.m', '*.h'] },
151
+ { id: 'OCaml', fileNamePatterns: ['*.ml', '*.mli', '*.aug'] },
152
+ { id: 'Org', fileNamePatterns: ['*.org'] },
153
+ { id: 'Passwd', fileNamePatterns: ['passwd'] },
154
+ { id: 'Pascal', fileNamePatterns: ['*.p', '*.pas'] },
155
+ { id: 'Perl', fileNamePatterns: ['*.pl', '*.pm', '*.ph', '*.plx', '*.perl'] },
156
+ { id: 'Perl6', fileNamePatterns: ['*.p6', '*.pm6', '*.pm', '*.pl6', '*.t6'] },
157
+ { id: 'PHP', fileNamePatterns: ['*.php', '*.php3', '*.php4', '*.php5', '*.php7', '*.phtml'] },
158
+ { id: 'PkgConfig', fileNamePatterns: ['*.pc'] },
159
+ { id: 'Pod', fileNamePatterns: ['*.pod'] },
160
+ { id: 'PowerShell', fileNamePatterns: ['*.ps1', '*.psm1'] },
161
+ { id: 'Protobuf', fileNamePatterns: ['*.proto'] },
162
+ { id: 'PuppetManifest', fileNamePatterns: ['*.pp'] },
163
+ {
164
+ id: 'Python',
165
+ fileNamePatterns: ['*.py', '*.pyx', '*.pxd', '*.pxi', '*.scons', '*.wsgi']
166
+ },
167
+ { id: 'PythonEntryPoints', fileNamePatterns: ['entry_points.txt'] },
168
+ { id: 'QemuHX', fileNamePatterns: ['*.hx'] },
169
+ { id: 'Quarto', fileNamePatterns: ['*.qmd'] },
170
+ { id: 'RMarkdown', fileNamePatterns: ['*.rmd'] },
171
+ { id: 'R', fileNamePatterns: ['*.r', '*.R', '*.s', '*.q'] },
172
+ { id: 'Rake', fileNamePatterns: ['Rakefile', '*.rake'] },
173
+ { id: 'Raku', fileNamePatterns: ['*.raku', '*.rakumod', '*.rakutest', '*.rakudoc'] },
174
+ { id: 'REXX', fileNamePatterns: ['*.cmd', '*.rexx', '*.rx'] },
175
+ { id: 'Robot', fileNamePatterns: ['*.robot'] },
176
+ { id: 'RpmSpec', fileNamePatterns: ['*.spec'] },
177
+ { id: 'ReStructuredText', fileNamePatterns: ['*.rest', '*.reST', '*.rst'] },
178
+ { id: 'Ruby', fileNamePatterns: ['*.rb', '*.ruby'] },
179
+ { id: 'Rust', fileNamePatterns: ['*.rs'] },
180
+ {
181
+ id: 'Scheme',
182
+ fileNamePatterns: ['*.SCM', '*.SM', '*.sch', '*.scheme', '*.scm', '*.sm', '*.rkt']
183
+ },
184
+ { id: 'SCSS', fileNamePatterns: ['*.scss'] },
185
+ { id: 'SELinuxInterface', fileNamePatterns: ['*.if'] },
186
+ { id: 'SELinuxTypeEnforcement', fileNamePatterns: ['*.te'] },
187
+ { id: 'Sh', fileNamePatterns: ['*.sh', '*.SH', '*.bsh', '*.bash', '*.ksh', '*.ash'] },
188
+ { id: 'SLang', fileNamePatterns: ['*.sl'] },
189
+ { id: 'SML', fileNamePatterns: ['*.sml', '*.sig'] },
190
+ { id: 'Scdoc', fileNamePatterns: ['*.scd'] },
191
+ { id: 'SQL', fileNamePatterns: ['*.sql'] },
192
+ {
193
+ id: 'SystemdUnit',
194
+ fileNamePatterns: [
195
+ '*.service',
196
+ '*.socket',
197
+ '*.device',
198
+ '*.mount',
199
+ '*.automount',
200
+ '*.swap',
201
+ '*.target',
202
+ '*.path',
203
+ '*.timer',
204
+ '*.snapshot',
205
+ '*.slice'
206
+ ]
207
+ },
208
+ { id: 'SystemTap', fileNamePatterns: ['*.stp', '*.stpm'] },
209
+ { id: 'Tcl', fileNamePatterns: ['*.tcl', '*.tk', '*.wish', '*.exp'] },
210
+ { id: 'Terraform', fileNamePatterns: ['*.tf'] },
211
+ { id: 'TerraformVariables', fileNamePatterns: ['*.tfvars'] },
212
+ { id: 'Tex', fileNamePatterns: ['*.tex'] },
213
+ { id: 'TTCN', fileNamePatterns: ['*.ttcn', '*.ttcn3'] },
214
+ { id: 'Txt2tags', fileNamePatterns: ['*.t2t', '*.t2t'] },
215
+ { id: 'TypeScript', fileNamePatterns: ['*.ts'] },
216
+ { id: 'TypeSpec', fileNamePatterns: ['*.tsp'] },
217
+ { id: 'V', fileNamePatterns: ['*.v'] },
218
+ { id: 'Vera', fileNamePatterns: ['*.vr', '*.vri', '*.vrh'] },
219
+ { id: 'Verilog', fileNamePatterns: ['*.v'] },
220
+ { id: 'SystemVerilog', fileNamePatterns: ['*.sv', '*.svh', '*.svi'] },
221
+ { id: 'VHDL', fileNamePatterns: ['*.vhdl', '*.vhd'] },
222
+ { id: 'Vim', fileNamePatterns: ['vimrc', '[._]vimrc', 'gvimrc', '[._]gvimrc', '*.vim', '*.vba'] },
223
+ { id: 'WindRes', fileNamePatterns: ['*.rc'] },
224
+ { id: 'YACC', fileNamePatterns: ['*.y'] },
225
+ { id: 'YumRepo', fileNamePatterns: ['*.repo'] },
226
+ { id: 'Zephir', fileNamePatterns: ['*.zep'] },
227
+ { id: 'Zsh', fileNamePatterns: ['*.zsh'] },
228
+ { id: 'Varlink', fileNamePatterns: ['*.varlink'] },
229
+ { id: 'Kotlin', fileNamePatterns: ['*.kt', '*.kts'] },
230
+ { id: 'Thrift', fileNamePatterns: ['*.thrift'] },
231
+ { id: 'Elm', fileNamePatterns: ['*.elm'] },
232
+ { id: 'TOML', fileNamePatterns: ['*.toml'] }
233
+ ];
234
+ let compiled;
235
+ export function symbolNavigationLanguageForPath(path) {
236
+ const name = path.replaceAll('\\', '/').slice(path.lastIndexOf('/') + 1);
237
+ return compiledLanguages().find((entry) => entry.patterns.some((pattern) => pattern.test(name)))
238
+ ?.language;
239
+ }
240
+ export function supportsSymbolNavigationPath(path) {
241
+ const name = path.replaceAll('\\', '/').slice(path.lastIndexOf('/') + 1);
242
+ return compiledLanguages().some((entry) => entry.patterns.some((pattern) => pattern.test(name)));
243
+ }
244
+ export function symbolNavigationLanguages() {
245
+ return languages;
246
+ }
247
+ function compiledLanguages() {
248
+ return (compiled ??= languages.map((language) => ({
249
+ language,
250
+ patterns: language.fileNamePatterns.map((pattern) => globPattern(pattern))
251
+ })));
252
+ }
253
+ function globPattern(value) {
254
+ let expression = '';
255
+ for (let index = 0; index < value.length; index += 1) {
256
+ const character = value[index];
257
+ if (character === '*') {
258
+ expression += '.*';
259
+ continue;
260
+ }
261
+ if (character === '?') {
262
+ expression += '.';
263
+ continue;
264
+ }
265
+ if (character === '[') {
266
+ const close = value.indexOf(']', index + 1);
267
+ if (close >= 0) {
268
+ expression += value.slice(index, close + 1);
269
+ index = close;
270
+ continue;
271
+ }
272
+ }
273
+ expression += character.replace(/[\\^$.*+?()[\]{}|]/gu, '\\$&');
274
+ }
275
+ return new RegExp(`^${expression}$`, 'iu');
276
+ }
@@ -0,0 +1,2 @@
1
+ export { supportsSymbolNavigationPath, symbolNavigationLanguageForPath, symbolNavigationLanguages } from './symbol-navigation-registry.js';
2
+ export type { SymbolNavigationLanguageDefinition } from './types.js';
@@ -0,0 +1 @@
1
+ export { supportsSymbolNavigationPath, symbolNavigationLanguageForPath, symbolNavigationLanguages } from './symbol-navigation-registry.js';