Skip to content

Commit dbdfae9

Browse files
Better logging for ctags exection (#498)
1 parent e87a41d commit dbdfae9

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

CHANGELOG.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,46 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)\
66

7+
## UNRELEASED
8+
9+
### Changed
10+
- Better logging for ctags exection errors
11+
712
## [1.15.0] - 2024-08-26
813

9-
## Added
14+
### Added
1015

1116
- Pass arguments to lsp [#446][https://github.com/mshr-h/vscode-verilog-hdl-support/issues/446]
1217

13-
## Fixed
18+
### Fixed
1419

1520
- Fix #479 by add parameters back into Module instantiation [#496](https://github.com/mshr-h/vscode-verilog-hdl-support/pull/496)
1621

1722
## [1.14.3] - 2024-07-30
1823

19-
## Added
24+
### Added
2025
- Verilator linter stderr passthrough [#489](https://github.com/mshr-h/vscode-verilog-hdl-support/issues/489)
2126
- When linting using Verilator, all detected problems are highlighted (By default it's just current file and it's dependencies. Verilator launch config can be adjusted in linting settings)
2227

23-
## Fixed
28+
### Fixed
2429
- Imroved regex matcher for Verilator output
2530
- Verilator output blocks are correctly tagged with `[error]` or `[warning]`
2631

2732
## [1.14.2] - 2024-07-24
2833

29-
## Fixed
34+
### Fixed
3035

3136
- Show error log when verilator cannot be executed [#489](https://github.com/mshr-h/vscode-verilog-hdl-support/issues/489)
3237

3338
## [1.14.1] - 2024-04-19
3439

35-
## Added
40+
### Added
3641

3742
- Enable verible-verilog-ls for Verilog filetype
3843

3944
## [1.14.0] - 2024-04-19
4045

41-
## Changed
46+
### Changed
4247

4348
- Update SystemVerilog syntax highlighting
4449

src/ctags.ts

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// SPDX-License-Identifier: MIT
22
import * as vscode from 'vscode';
3-
import * as child_process from 'child_process';
3+
import {exec as execNonPromise} from 'child_process';
4+
import * as util from 'util';
45
import { Logger } from './logger';
5-
import { text } from 'stream/consumers';
6+
const exec = util.promisify(execNonPromise);
67

78
// Internal representation of a symbol
89
export class Symbol {
@@ -169,11 +170,21 @@ export class Ctags {
169170
if (binPath !== 'none') {
170171
let command: string = binPath + ' -f - --fields=+K --sort=no --excmd=n --fields-SystemVerilog=+{parameter} "' + filepath + '"';
171172
this.logger.info('Executing Command: ' + command);
172-
return new Promise((resolve, _reject) => {
173-
child_process.exec(command, (_error: Error, stdout: string, _stderr: string) => {
174-
resolve(stdout);
175-
});
176-
});
173+
try {
174+
const {stdout, stderr} = await exec(command);
175+
if(stdout) {
176+
return stdout.toString();
177+
}
178+
if(stderr) {
179+
this.logger.error('stderr> ' + stderr);
180+
}
181+
}
182+
catch (e) {
183+
this.logger.error('Exception caught: ' + e.message + ' ' + e.data);
184+
}
185+
}
186+
else {
187+
this.logger.trace('Ctags binpath not set');
177188
}
178189
// Return empty promise if ctags path is not set to avoid errors when indexing
179190
return Promise.resolve('');
@@ -268,7 +279,7 @@ export class Ctags {
268279
async index(): Promise<void> {
269280
this.logger.info('indexing ', this.doc.uri.fsPath);
270281

271-
let output = await this.execCtags(this.doc.uri.fsPath)
282+
let output = await this.execCtags(this.doc.uri.fsPath);
272283
await this.buildSymbolsList(output);
273284
}
274285
}

0 commit comments

Comments
 (0)