feat(impact): cross-language blast-radius coverage (22 languages + 14 frameworks) (#708)
Completes the cross-file dependency graph behind impact / affected / explore across all 22 supported languages and 14 web frameworks, validated on real-world repos (measured fair-coverage table added to the README). Per-language resolution + framework resolvers/synthesizers (Lua/Luau require, Shopify OS 2.0 Liquid sections, Delphi forms, Rust cross-module + Rocket macros, Swift Fluent, SvelteKit/Nuxt loader/component conventions, RN/Expo bridges). 0 cross-family false edges, full suite green (1187 passed). See #708. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
bfa84d32b8
commit
07af3db6c7
@@ -10,7 +10,7 @@ import * as path from 'path';
|
||||
import { Parser, Language as WasmLanguage } from 'web-tree-sitter';
|
||||
import { Language } from '../types';
|
||||
|
||||
export type GrammarLanguage = Exclude<Language, 'svelte' | 'vue' | 'liquid' | 'yaml' | 'twig' | 'xml' | 'properties' | 'unknown'>;
|
||||
export type GrammarLanguage = Exclude<Language, 'svelte' | 'vue' | 'liquid' | 'razor' | 'yaml' | 'twig' | 'xml' | 'properties' | 'unknown'>;
|
||||
|
||||
/**
|
||||
* WASM filename map — maps each language to its .wasm grammar file
|
||||
@@ -69,6 +69,10 @@ export const EXTENSION_MAP: Record<string, Language> = {
|
||||
'.hpp': 'cpp',
|
||||
'.hxx': 'cpp',
|
||||
'.cs': 'csharp',
|
||||
// ASP.NET Razor / Blazor markup — custom RazorExtractor (links @model/@inject/
|
||||
// component tags to their C# types; markup isn't a tree-sitter grammar).
|
||||
'.cshtml': 'razor',
|
||||
'.razor': 'razor',
|
||||
'.php': 'php',
|
||||
// Drupal-specific PHP file extensions
|
||||
'.module': 'php',
|
||||
@@ -117,11 +121,23 @@ export const EXTENSION_MAP: Record<string, Language> = {
|
||||
*/
|
||||
export function isSourceFile(filePath: string): boolean {
|
||||
if (isPlayRoutesFile(filePath)) return true; // Play `conf/routes` is extensionless
|
||||
if (isShopifyLiquidJson(filePath)) return true; // Shopify OS 2.0 JSON templates / section groups
|
||||
const dot = filePath.lastIndexOf('.');
|
||||
if (dot < 0) return false;
|
||||
return filePath.slice(dot).toLowerCase() in EXTENSION_MAP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shopify OS 2.0 JSON template (`templates/*.json`) or section group
|
||||
* (`sections/*.json`) — these reference sections by `"type"`, so the Liquid
|
||||
* extractor links them. (config/ + locales/ JSON have no section refs.)
|
||||
*/
|
||||
export function isShopifyLiquidJson(filePath: string): boolean {
|
||||
// Allow nested template dirs (`templates/customers/login.json`), not just
|
||||
// top-level (`templates/product.json`).
|
||||
return /(^|\/)(templates|sections)\/.+\.json$/i.test(filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Play Framework routes file: the extensionless `conf/routes` (and included
|
||||
* `conf/*.routes`). No grammar — route extraction is done by the Play framework
|
||||
@@ -242,6 +258,9 @@ export function detectLanguage(filePath: string, source?: string): Language {
|
||||
// Play framework resolver extracts route nodes from it.
|
||||
if (isPlayRoutesFile(filePath)) return 'yaml';
|
||||
const ext = filePath.substring(filePath.lastIndexOf('.')).toLowerCase();
|
||||
// Shopify OS 2.0 JSON templates / section groups → the Liquid extractor (it
|
||||
// links each section `"type"` to its `sections/<type>.liquid`).
|
||||
if (isShopifyLiquidJson(filePath)) return 'liquid';
|
||||
const lang = EXTENSION_MAP[ext] || 'unknown';
|
||||
|
||||
// .h files could be C, C++, or Objective-C — check source content
|
||||
@@ -278,6 +297,7 @@ export function isLanguageSupported(language: Language): boolean {
|
||||
if (language === 'svelte') return true; // custom extractor (script block delegation)
|
||||
if (language === 'vue') return true; // custom extractor (script block delegation)
|
||||
if (language === 'liquid') return true; // custom regex extractor
|
||||
if (language === 'razor') return true; // custom RazorExtractor (.cshtml/.razor markup)
|
||||
if (language === 'yaml') return true; // file-level tracking only; Drupal routing extraction via framework resolver
|
||||
if (language === 'twig') return true; // file-level tracking only
|
||||
if (language === 'xml') return true; // MyBatis mapper extractor
|
||||
@@ -290,7 +310,7 @@ export function isLanguageSupported(language: Language): boolean {
|
||||
* Check if a grammar has been loaded and is ready for parsing.
|
||||
*/
|
||||
export function isGrammarLoaded(language: Language): boolean {
|
||||
if (language === 'svelte' || language === 'vue' || language === 'liquid') return true;
|
||||
if (language === 'svelte' || language === 'vue' || language === 'liquid' || language === 'razor') return true;
|
||||
if (language === 'yaml' || language === 'twig') return true; // no WASM grammar needed
|
||||
if (language === 'xml' || language === 'properties') return true; // no WASM grammar needed
|
||||
return languageCache.has(language);
|
||||
@@ -371,6 +391,7 @@ export function getLanguageDisplayName(language: Language): string {
|
||||
c: 'C',
|
||||
cpp: 'C++',
|
||||
csharp: 'C#',
|
||||
razor: 'Razor/Blazor',
|
||||
php: 'PHP',
|
||||
ruby: 'Ruby',
|
||||
swift: 'Swift',
|
||||
|
||||
Reference in New Issue
Block a user