Skip to content

Commit 670fb74

Browse files
authored
Merge pull request #45 from GitMensch/patch-1
lookup for generated files: support file names used by automake
2 parents 59b40ce + daa7480 commit 670fb74

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: ["main", "dev"]
66
pull_request:
77
branches: ["main", "dev"]
8+
# manual run in actions tab - for all branches
89
workflow_dispatch:
910

1011
jobs:

client/src/lineDirectiveNavigation.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,23 @@ const BISON_CANDIDATES = (base: string, dir: string): string[] => [
5757
path.join(dir, base + '.tab.c'),
5858
path.join(dir, base + '.tab.cpp'),
5959
path.join(dir, base + '.tab.cc'),
60+
path.join(dir, base + '.c'),
61+
path.join(dir, base + '.cc'),
62+
path.join(dir, base + '.c++'),
63+
path.join(dir, base + '.cxx'),
64+
path.join(dir, base + '.cpp'),
6065
];
6166

6267
const FLEX_CANDIDATES = (base: string, dir: string): string[] => [
6368
path.join(dir, 'lex.yy.c'),
6469
path.join(dir, 'lex.yy.cc'),
6570
path.join(dir, base + '.yy.c'),
6671
path.join(dir, base + '.yy.cpp'),
72+
path.join(dir, base + '.c'),
73+
path.join(dir, base + '.cc'),
74+
path.join(dir, base + '.c++'),
75+
path.join(dir, base + '.cxx'),
76+
path.join(dir, base + '.cpp'),
6777
];
6878

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

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

152162
// Workspace-wide search as last resort — let user pick if ambiguous
153-
const pattern = isBison ? `**/${base}.tab.{c,cpp,cc}` : `**/lex.yy.{c,cc}`;
154-
const found = await workspace.findFiles(pattern, '**/node_modules/**', 10);
163+
let pattern = isBison ? `**/${base}.tab.{c,cpp,cc}` : `**/lex.yy.{c,cc}`;
164+
let found = await workspace.findFiles(pattern, '**/node_modules/**', 10);
165+
166+
// in case of no results, check for ylwrap names (no tab/lex)
167+
// we only do that after the initial run to not force a picker if
168+
// the tool's default names are available somewhere in the workspace
169+
if (found.length === 0) {
170+
pattern = `**/${base}.{c,cc,c++,cxx,cpp}`;
171+
found = await workspace.findFiles(pattern, '**/node_modules/**', 10);
172+
}
173+
155174
if (found.length === 0) return null;
156175
if (found.length === 1) return found[0].fsPath;
157176

0 commit comments

Comments
 (0)