Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: ["main", "dev"]
pull_request:
branches: ["main", "dev"]
# manual run in actions tab - for all branches
workflow_dispatch:

jobs:
Expand Down
25 changes: 22 additions & 3 deletions client/src/lineDirectiveNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,23 @@ const BISON_CANDIDATES = (base: string, dir: string): string[] => [
path.join(dir, base + '.tab.c'),
path.join(dir, base + '.tab.cpp'),
path.join(dir, base + '.tab.cc'),
path.join(dir, base + '.c'),
path.join(dir, base + '.cc'),
path.join(dir, base + '.c++'),
path.join(dir, base + '.cxx'),
path.join(dir, base + '.cpp'),
];

const FLEX_CANDIDATES = (base: string, dir: string): string[] => [
path.join(dir, 'lex.yy.c'),
path.join(dir, 'lex.yy.cc'),
path.join(dir, base + '.yy.c'),
path.join(dir, base + '.yy.cpp'),
path.join(dir, base + '.c'),
path.join(dir, base + '.cc'),
path.join(dir, base + '.c++'),
path.join(dir, base + '.cxx'),
path.join(dir, base + '.cpp'),
];

/** Scan CMakeLists.txt up the directory tree and return a build directory hint. */
Expand Down Expand Up @@ -132,7 +142,7 @@ async function findGeneratedFile(sourceFilePath: string): Promise<string | null>
const sourceDir = path.dirname(sourceFilePath);
const base = path.basename(sourceFilePath, path.extname(sourceFilePath));
const ext = path.extname(sourceFilePath).toLowerCase();
const isBison = ['.y', '.yy', '.ypp', '.bison'].includes(ext);
const isBison = ['.y', '.yy', '.y++', '.ypp', '.yxx', '.bison'].includes(ext);
const candidates = isBison ? BISON_CANDIDATES : FLEX_CANDIDATES;

const dirsToTry: string[] = [];
Expand All @@ -150,8 +160,17 @@ async function findGeneratedFile(sourceFilePath: string): Promise<string | null>
}

// Workspace-wide search as last resort — let user pick if ambiguous
const pattern = isBison ? `**/${base}.tab.{c,cpp,cc}` : `**/lex.yy.{c,cc}`;
const found = await workspace.findFiles(pattern, '**/node_modules/**', 10);
let pattern = isBison ? `**/${base}.tab.{c,cpp,cc}` : `**/lex.yy.{c,cc}`;
let found = await workspace.findFiles(pattern, '**/node_modules/**', 10);

// in case of no results, check for ylwrap names (no tab/lex)
// we only do that after the initial run to not force a picker if
// the tool's default names are available somewhere in the workspace
if (found.length === 0) {
pattern = `**/${base}.{c,cc,c++,cxx,cpp}`;
found = await workspace.findFiles(pattern, '**/node_modules/**', 10);
}

if (found.length === 0) return null;
if (found.length === 1) return found[0].fsPath;

Expand Down
Loading