Skip to content

Commit 7eb961e

Browse files
authored
Refactoring (mshr-h#363)
* fix * remove unnecessary log output * remove showInformationMessage * update logging * remove verilog.logging.enabled option * typo * format * refactor import
1 parent 923dfc0 commit 7eb961e

21 files changed

+200
-255
lines changed

.vscodeignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ renovate.json
1313
**/*.map
1414
**/*.ts
1515
language_examples/**
16-
.hdl_checker/**
16+
**/.hdl_checker/**
17+
**/svls.log

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
1111
- \[Caution\] Language Server config names has changed!
1212
- Users may have to reset all the configs related to Language Server feature.
1313
- verible-verilog-ls support is temporary dropped because it returns error when stopping.
14+
- Deprecated `verilog.logging.enabled` option.
15+
- Logs are always outputted to the **Verilog** OutputChannel of VS Code in the **Output** pane.
1416

1517
## [1.5.13] - 2022-12-12
1618

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,13 @@ Use the following settings to configure the extension to your needs
110110

111111
Path to your installation of Ctags if it isn't already present in your `PATH` environment variable.
112112

113-
- `verilog.logging.enabled` (Default: `false` )
114-
115-
Enable logging for this extension. Open the **Output** pane in VS Code and choose _Verilog_ in the drop-down menu to view the log.
116-
117113
- `verilog.languageServer.svls.enabled` (Default: `false`)
118114

119115
\[Experimental\] Enable svls Language Server for SystemVerilog.
120116

121117
- `verilog.languageServer.svls.path` (Default: `svls`)
122118

123-
\[Experimental\] A path to the Svls Language Server binary.
119+
\[Experimental\] A path to the svls Language Server binary.
124120

125121
- `verilog.languageServer.veridian.enabled` (Default: `false`)
126122

@@ -181,6 +177,11 @@ If you have tested the linters in new platforms or have issues with them, feel f
181177

182178
## [Guidelines for Contributing](./CONTRIBUTING.md)
183179

180+
## Logging
181+
182+
Logs are outputted to OutputChannel in th VS Code.
183+
Open the **Output** pane in VS Code and choose _Verilog_ in the drop-down menu to view the log.
184+
184185
## Helpful links
185186

186187
- [Verilog in VSCode With Linting (Using Modelsim) - YouTube](https://www.youtube.com/watch?v=-DTGf3Z6v_o)

package.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,6 @@
282282
"default": "none",
283283
"description": "A path to the installation of Universal Ctags."
284284
},
285-
"verilog.logging.enabled": {
286-
"scope": "window",
287-
"type": "boolean",
288-
"default": false,
289-
"description": "Enable logging for this extension."
290-
},
291285
"verilog.languageServer.svls.enabled": {
292286
"scope": "window",
293287
"type": "boolean",
@@ -386,4 +380,4 @@
386380
"publisherDisplayName": "mshr-h",
387381
"publisherId": "fcf32c99-a624-437b-9f47-9333ea128623"
388382
}
389-
}
383+
}

src/BsvProvider.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,13 @@ import {
223223
DocumentSymbol,
224224
TextDocument,
225225
Uri,
226-
window,
227226
workspace,
228227
SymbolKind,
229228
Range,
230229
Position,
231230
Location,
232231
Hover,
233232
extensions,
234-
FileSystem,
235233
CompletionItem,
236234
LocationLink,
237235
} from 'vscode';
@@ -245,6 +243,8 @@ import { extensionID } from './extension';
245243
import { readFileSync } from 'fs';
246244
import { join } from 'path';
247245
import { readdirSync } from 'fs';
246+
import { Logger } from './logger';
247+
let logger: Logger = new Logger();
248248

249249
export interface BsvInfoProvider {
250250
getSymbol(
@@ -3477,7 +3477,7 @@ class BsvStdLibProvider {
34773477
if (Object.prototype.hasOwnProperty.call(internalInfo, key)) {
34783478
const element = internalInfo[key];
34793479
const pp: String = element.package;
3480-
if (element.package != p) {continue;}
3480+
if (element.package != p) { continue; }
34813481
const type: String = element.type;
34823482
switch (type) {
34833483
case 'typeclass':
@@ -3591,7 +3591,7 @@ class BsvBaseInfoProvider {
35913591
this.parserCache.set(uri, tree);
35923592
this.updateSymbol(uri);
35933593

3594-
console.log('cache ' + uri);
3594+
logger.log('cache ' + uri);
35953595
} catch (error) { }
35963596
}
35973597

@@ -3861,7 +3861,7 @@ export class BsvInfoProviderManger {
38613861
workspace.workspaceFolders[0].uri
38623862
);
38633863
} else {
3864-
console.log('bsv only support one opened workspace now');
3864+
logger.log('bsv only support one opened workspace now');
38653865
}
38663866
}
38673867
}

src/Logger.ts

-39
This file was deleted.

src/commands/ModuleInstantiation.ts

+8-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as fs from 'fs';
22
import * as path from 'path';
33
import { Ctags, Symbol } from '../ctags';
44
import { window, QuickPickItem, workspace, SnippetString } from 'vscode';
5-
import { Logger } from '../Logger';
5+
import { Logger } from '../logger';
66

77
export function instantiateModuleInteract() {
88
let filePath = path.dirname(window.activeTextEditor.document.fileName);
@@ -21,7 +21,7 @@ function instantiateModule(srcpath: string): Thenable<SnippetString> {
2121
let parametersName: string[] = [];
2222
let logger: Logger = new Logger();
2323
let ctags: ModuleTags = new ModuleTags(logger);
24-
console.log('Executing ctags for module instantiation');
24+
this.logger.log('Executing ctags for module instantiation');
2525
ctags
2626
.execCtags(srcpath)
2727
.then((output) => {
@@ -40,7 +40,7 @@ function instantiateModule(srcpath: string): Thenable<SnippetString> {
4040
return;
4141
}
4242
// Only one module found
43-
else if (modules.length == 1) {module = modules[0];}
43+
else if (modules.length === 1) { module = modules[0]; }
4444
// many modules found
4545
else if (modules.length > 1) {
4646
moduleName = await window.showQuickPick(
@@ -51,7 +51,7 @@ function instantiateModule(srcpath: string): Thenable<SnippetString> {
5151
placeHolder: 'Choose a module to instantiate',
5252
}
5353
);
54-
if (moduleName === undefined) {return;}
54+
if (moduleName === undefined) { return; }
5555
module = modules.filter(
5656
(tag) => tag.name === moduleName
5757
)[0];
@@ -74,12 +74,12 @@ function instantiateModule(srcpath: string): Thenable<SnippetString> {
7474
tag.parentScope === scope
7575
);
7676
parametersName = params.map((tag) => tag.name);
77-
console.log(module);
77+
this.logger.log(module.name);
7878
let paramString = ``;
7979
if (parametersName.length > 0) {
8080
paramString = `\n#(\n${instantiatePort(parametersName)})\n`;
8181
}
82-
console.log(portsName);
82+
this.logger.log(portsName.toString());
8383
resolve(
8484
new SnippetString()
8585
.appendText(module.name + ' ')
@@ -97,7 +97,7 @@ function instantiatePort(ports: string[]): string {
9797
let port = '';
9898
let maxLen = 0;
9999
for (let i = 0; i < ports.length; i++) {
100-
if (ports[i].length > maxLen) {maxLen = ports[i].length;}
100+
if (ports[i].length > maxLen) { maxLen = ports[i].length; }
101101
}
102102
// .NAME(NAME)
103103
for (let i = 0; i < ports.length; i++) {
@@ -175,9 +175,7 @@ function getFiles(srcpath: string): string[] {
175175

176176
class ModuleTags extends Ctags {
177177
buildSymbolsList(tags: string): Thenable<void> {
178-
console.log('building symbols');
179178
if (tags === '') {
180-
console.log('No output from ctags');
181179
return undefined;
182180
}
183181
// Parse ctags output
@@ -190,12 +188,10 @@ class ModuleTags extends Ctags {
190188
tag.type === 'module' ||
191189
tag.type === 'port' ||
192190
tag.type === 'constant'
193-
)
194-
{this.symbols.push(tag);}
191+
) { this.symbols.push(tag); }
195192
}
196193
});
197194
// skip finding end tags
198-
console.log(this.symbols);
199195
return undefined;
200196
}
201197
}

0 commit comments

Comments
 (0)