@myagentroam/code-navigation 0.9.98 → 0.9.99
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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/registry.d.ts +7 -0
- package/dist/registry.js +32 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { fileSpecifierParser, navigationLanguageForPath, navigationLanguages } from './registry.js';
|
|
1
|
+
export { fileSpecifierParser, hyphenSeparatesNavigationSymbol, isNavigationSymbol, navigationLanguageForPath, navigationLanguages, navigationSymbolAt } from './registry.js';
|
|
2
2
|
export { rangeAtColumn, type FileReference, type FileReferenceKind, type FileSpecifierParser, type FileSpecifierRange, type NavigationLanguageId, type NavigationSyntaxDefinition } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { fileSpecifierParser, navigationLanguageForPath, navigationLanguages } from './registry.js';
|
|
1
|
+
export { fileSpecifierParser, hyphenSeparatesNavigationSymbol, isNavigationSymbol, navigationLanguageForPath, navigationLanguages, navigationSymbolAt } from './registry.js';
|
|
2
2
|
export { rangeAtColumn } from './types.js';
|
package/dist/registry.d.ts
CHANGED
|
@@ -2,3 +2,10 @@ import type { NavigationSyntaxDefinition } from './types.js';
|
|
|
2
2
|
export declare function navigationLanguageForPath(path: string, source?: string): NavigationSyntaxDefinition | undefined;
|
|
3
3
|
export declare function fileSpecifierParser(path: string, source?: string): import("./types.js").FileSpecifierParser | undefined;
|
|
4
4
|
export declare function navigationLanguages(): readonly NavigationSyntaxDefinition[];
|
|
5
|
+
export declare function navigationSymbolAt(path: string, source: string, position: number): {
|
|
6
|
+
readonly value: string;
|
|
7
|
+
readonly from: number;
|
|
8
|
+
readonly to: number;
|
|
9
|
+
} | undefined;
|
|
10
|
+
export declare function isNavigationSymbol(path: string, value: string): boolean;
|
|
11
|
+
export declare function hyphenSeparatesNavigationSymbol(path: string): boolean;
|
package/dist/registry.js
CHANGED
|
@@ -36,6 +36,19 @@ const languages = [
|
|
|
36
36
|
rustNavigationSyntaxDefinition,
|
|
37
37
|
vueNavigationSyntaxDefinition
|
|
38
38
|
];
|
|
39
|
+
const hyphenSeparatorLanguages = new Set([
|
|
40
|
+
'ecmascript',
|
|
41
|
+
'go',
|
|
42
|
+
'jvm',
|
|
43
|
+
'csharp',
|
|
44
|
+
'python',
|
|
45
|
+
'c',
|
|
46
|
+
'cpp',
|
|
47
|
+
'objective-c',
|
|
48
|
+
'objective-cpp',
|
|
49
|
+
'c-family',
|
|
50
|
+
'rust'
|
|
51
|
+
]);
|
|
39
52
|
export function navigationLanguageForPath(path, source) {
|
|
40
53
|
const normalized = path.toLowerCase();
|
|
41
54
|
const candidates = languages.filter((language) => language.suffixes.some((suffix) => normalized.endsWith(suffix)));
|
|
@@ -52,3 +65,22 @@ export function fileSpecifierParser(path, source) {
|
|
|
52
65
|
export function navigationLanguages() {
|
|
53
66
|
return languages;
|
|
54
67
|
}
|
|
68
|
+
export function navigationSymbolAt(path, source, position) {
|
|
69
|
+
const expression = hyphenSeparatesNavigationSymbol(path)
|
|
70
|
+
? /[\p{L}_$][\p{L}\p{N}_$]*/gu
|
|
71
|
+
: /-*[\p{L}_$][\p{L}\p{N}_$-]*/gu;
|
|
72
|
+
for (const candidate of source.matchAll(expression)) {
|
|
73
|
+
const value = candidate[0];
|
|
74
|
+
const from = candidate.index ?? 0;
|
|
75
|
+
if (position >= from && position < from + value.length)
|
|
76
|
+
return { value, from, to: from + value.length };
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
export function isNavigationSymbol(path, value) {
|
|
81
|
+
return (value.length > 0 && value.length <= 512 && navigationSymbolAt(path, value, 0)?.value === value);
|
|
82
|
+
}
|
|
83
|
+
export function hyphenSeparatesNavigationSymbol(path) {
|
|
84
|
+
const language = navigationLanguageForPath(path);
|
|
85
|
+
return language !== undefined && hyphenSeparatorLanguages.has(language.id);
|
|
86
|
+
}
|