diff --git a/src/commands/ModuleInstantiation.ts b/src/commands/ModuleInstantiation.ts index f93b649..49e6787 100644 --- a/src/commands/ModuleInstantiation.ts +++ b/src/commands/ModuleInstantiation.ts @@ -38,7 +38,7 @@ export async function instantiateModule( let output = await ctags.execCtags(srcpath); await ctags.buildSymbolsList(output); - let modules: Symbol[] = ctags.symbols.filter((tag) => tag.type === 'module'); + let modules: Symbol[] = ctags.symbols.filter((tag) => tag.type === 'module' || tag.type === 'interface'); // No modules found if (modules.length <= 0) { vscode.window.showErrorMessage('Verilog-HDL/SystemVerilog: No modules found in the file'); @@ -73,7 +73,7 @@ export async function moduleFromFile(srcpath: string): Promise tag.type === 'module'); + let modules: Symbol[] = ctags.symbols.filter((tag) => tag.type === 'module' || tag.type === 'interface'); // No modules found if (modules.length <= 0) { vscode.window.showErrorMessage('Verilog-HDL/SystemVerilog: No modules found in the file'); @@ -89,11 +89,11 @@ export async function moduleSnippet(ctags: CtagsParser, module: Symbol, fullModu let scope = module.parentScope !== '' ? module.parentScope + '.' + module.name : module.name; let ports: Symbol[] = ctags.symbols.filter( - (tag) => tag.type === 'port' && tag.parentType === 'module' && tag.parentScope === scope + (tag) => tag.type === 'port' && tag.parentScope === scope ); portsName = ports.map((tag) => tag.name); let params: Symbol[] = ctags.symbols.filter( - (tag) => tag.type === 'parameter' && tag.parentType === 'module' && tag.parentScope === scope + (tag) => tag.type === 'parameter' && tag.parentScope === scope ); parametersName = params.map((tag) => tag.name); logger.info('Module name: ' + module.name); @@ -217,7 +217,7 @@ class ModuleTags extends CtagsParser { return; } // add only modules and ports - if (tag.type === 'module' || tag.type === 'port' || tag.type === 'parameter') { + if (tag.type === 'interface' || tag.type === 'module' || tag.type === 'port' || tag.type === 'parameter') { this.symbols.push(tag); } } diff --git a/src/parsers/ctagsParser.ts b/src/parsers/ctagsParser.ts index 9e27a47..b14a2fe 100644 --- a/src/parsers/ctagsParser.ts +++ b/src/parsers/ctagsParser.ts @@ -6,7 +6,6 @@ import { Logger } from '../logger'; export class Symbol { name: string; type: string; - pattern: string; line: number; // range of identifier idRange: vscode.Range | undefined; @@ -22,7 +21,6 @@ export class Symbol { doc: vscode.TextDocument, name: string, type: string, - pattern: string, startLine: number, parentScope: string, parentType: string, @@ -32,7 +30,6 @@ export class Symbol { this.doc = doc; this.name = name; this.type = type; - this.pattern = pattern; this.line = startLine; this.startPosition = new vscode.Position(startLine, 0); this.parentScope = parentScope; @@ -41,6 +38,17 @@ export class Symbol { this.typeRef = typeRef; } + prettyPrint(): string { + let ret = `${this.name}(${this.type}):${this.line}`; + if (this.parentScope !== '') { + ret += ` parent=${this.parentScope}(${this.parentType})`; + } + if (this.typeRef !== null) { + ret += ` typeref=${this.typeRef}`; + } + return ret; + } + getIdRange(): vscode.Range { if (this.idRange === undefined) { this.idRange = this.doc.getWordRangeAtPosition( @@ -239,7 +247,6 @@ export class CtagsParser { let lineNo: number; let parts: string[] = line.split('\t'); name = parts[0]; - pattern = parts[2]; type = parts[3]; // override "type" for parameters (See #102) if (parts.length === 6) { @@ -266,7 +273,6 @@ export class CtagsParser { this.doc, name, type, - pattern, lineNo, parentScope, parentType, @@ -335,6 +341,10 @@ export class CtagsParser { } catch (e) { this.logger.error((e as Error).toString()); } + // print all syms + // this.symbols.forEach((sym) => { + // this.logger.info(sym.prettyPrint()); + // }); } async index(): Promise {