mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-19 00:03:33 +00:00
* fix(swift): use official prebuilt parser runtime Vendor the official tree-sitter-swift 0.7.1 runtime package so Swift parsing works without source-building, while keeping the repo on the current tree-sitter runtime until the broader upgrade is ready. Also preserves Swift resolver correctness for overloaded owned functions and extension-backed type duplicates now that Swift is available by default. Made-with: Cursor * fix(swift): move duplicate type ordering into provider Keep Swift extension candidate ordering behind the LanguageProvider contract and cover the Swift 0.7 init scanner path so parser runtime changes do not leak language-specific logic into shared resolution. Made-with: Cursor * fix(swift): address parser runtime review Add explicit Swift prebuild checks and vendor guidance so parser runtime packaging remains observable and maintainable.
94 lines
3.2 KiB
TypeScript
94 lines
3.2 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { loadParser, loadLanguage } from '../../src/core/tree-sitter/parser-loader.js';
|
|
import { SupportedLanguages } from '../../src/config/supported-languages.js';
|
|
|
|
describe('parser-loader', () => {
|
|
describe('loadParser', () => {
|
|
it('returns a Parser instance', async () => {
|
|
const parser = await loadParser();
|
|
expect(parser).toBeDefined();
|
|
expect(typeof parser.parse).toBe('function');
|
|
});
|
|
|
|
it('returns the same singleton instance', async () => {
|
|
const parser1 = await loadParser();
|
|
const parser2 = await loadParser();
|
|
expect(parser1).toBe(parser2);
|
|
});
|
|
});
|
|
|
|
describe('loadLanguage', () => {
|
|
it('loads TypeScript language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.TypeScript)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads JavaScript language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.JavaScript)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads Python language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.Python)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads Java language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.Java)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads C language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.C)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads C++ language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.CPlusPlus)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads C# language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.CSharp)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads Go language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.Go)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads Rust language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.Rust)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads PHP language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.PHP)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads TSX grammar for .tsx files', async () => {
|
|
// TSX uses a different grammar (TypeScript.tsx vs TypeScript.typescript)
|
|
await expect(
|
|
loadLanguage(SupportedLanguages.TypeScript, 'Component.tsx'),
|
|
).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads TS grammar for .ts files', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.TypeScript, 'utils.ts')).resolves.not.toThrow();
|
|
});
|
|
|
|
it('loads Ruby language', async () => {
|
|
await expect(loadLanguage(SupportedLanguages.Ruby)).resolves.not.toThrow();
|
|
});
|
|
|
|
it('throws for unsupported language', async () => {
|
|
await expect(loadLanguage('erlang' as SupportedLanguages)).rejects.toThrow(
|
|
'Unsupported language',
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('Swift optional dependency', () => {
|
|
it('loads Swift from the default optional dependency and parses source', async () => {
|
|
const parser = await loadParser();
|
|
await loadLanguage(SupportedLanguages.Swift);
|
|
|
|
const tree = parser.parse('class Foo { func bar() {} }');
|
|
|
|
expect(tree.rootNode.type).toBe('source_file');
|
|
expect(tree.rootNode.namedChildCount).toBe(1);
|
|
});
|
|
});
|
|
});
|