|
1 | 1 | // SPDX-License-Identifier: MIT
|
2 | 2 | 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'; |
4 | 5 | import { Logger } from './logger';
|
5 |
| -import { text } from 'stream/consumers'; |
| 6 | +const exec = util.promisify(execNonPromise); |
6 | 7 |
|
7 | 8 | // Internal representation of a symbol
|
8 | 9 | export class Symbol {
|
@@ -169,11 +170,21 @@ export class Ctags {
|
169 | 170 | if (binPath !== 'none') {
|
170 | 171 | let command: string = binPath + ' -f - --fields=+K --sort=no --excmd=n --fields-SystemVerilog=+{parameter} "' + filepath + '"';
|
171 | 172 | 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'); |
177 | 188 | }
|
178 | 189 | // Return empty promise if ctags path is not set to avoid errors when indexing
|
179 | 190 | return Promise.resolve('');
|
@@ -268,7 +279,7 @@ export class Ctags {
|
268 | 279 | async index(): Promise<void> {
|
269 | 280 | this.logger.info('indexing ', this.doc.uri.fsPath);
|
270 | 281 |
|
271 |
| - let output = await this.execCtags(this.doc.uri.fsPath) |
| 282 | + let output = await this.execCtags(this.doc.uri.fsPath); |
272 | 283 | await this.buildSymbolsList(output);
|
273 | 284 | }
|
274 | 285 | }
|
|
0 commit comments