From 0ebfa5bd12e529d8febe73c85d3bf48c4d4997e8 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Sat, 14 Oct 2017 22:29:02 +0200 Subject: -- Added extensive templating the be able to generated different types of doxygen comment. --- src/CodeParser/CParser.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/CodeParser/CParser.ts') diff --git a/src/CodeParser/CParser.ts b/src/CodeParser/CParser.ts index 4889de6..12ed169 100644 --- a/src/CodeParser/CParser.ts +++ b/src/CodeParser/CParser.ts @@ -35,8 +35,9 @@ export default class CParser implements ICodeParser { const returnValue: string[] = this.getReturn(method); const params: string[] = this.getParams(method); + const tparams: string[] = this.getTemplateParams(method); - const cppGenerator: IDocGen = new Generator(this.activeEditor, this.activeSelection, params, returnValue); + const cppGenerator: IDocGen = new Generator(this.activeEditor, this.activeSelection, params, tparams, returnValue); return cppGenerator; } @@ -84,7 +85,7 @@ export default class CParser implements ICodeParser { const retVals: string[] = []; // Remove the compiler keywords from the signature - const sign: string = method.replace(/(static)|(inline)|(friend)|(virtual)|(extern)|(explicit)/g, ""); + const sign: string = method.replace(/(static)|(inline)|(friend)|(virtual)|(extern)|(explicit)|(const)/g, ""); // Remove the parameters from the signature const returnSignature = sign.slice(0, sign.indexOf("(")).trim(); @@ -106,14 +107,6 @@ export default class CParser implements ICodeParser { break; } - // Don't generate return type if the user doesn't wish to do it - if (!workspace.getConfiguration(ConfigType.generic).get(Config.generateReturnType, true) && - retVals.length > 0) { - retVals.length = 0; - retVals.push(" "); - return retVals; - } - return retVals; } @@ -139,4 +132,10 @@ export default class CParser implements ICodeParser { return paramArr; } + + protected getTemplateParams(method: string): string[] { + // Todo implement parsing of template parameters. + const tparams: string[] = []; + return tparams; + } } -- cgit v1.2.3 From cc0d69edcd362c1abde9d0005c70d8e3692395bc Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Sun, 15 Oct 2017 02:26:22 +0200 Subject: -- Fixed tslint issues. -- Added config parameter to add type information to return DoxyGen parameter. --- src/CodeParser/CParser.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/CodeParser/CParser.ts') diff --git a/src/CodeParser/CParser.ts b/src/CodeParser/CParser.ts index 12ed169..77b01eb 100644 --- a/src/CodeParser/CParser.ts +++ b/src/CodeParser/CParser.ts @@ -25,28 +25,33 @@ export default class CParser implements ICodeParser { const activeLine: TextLine = this.activeEditor.document.lineAt(this.activeEditor.selection.active.line); - const method: string = this.getMethodText(); + const line: string = this.getLogicalLine(); // Not a method - if (method.length === 0) { + if (line.length === 0) { return null; } - const returnValue: string[] = this.getReturn(method); + const returnValue: string[] = this.getReturn(line); - const params: string[] = this.getParams(method); - const tparams: string[] = this.getTemplateParams(method); + const params: string[] = this.getParams(line); + const tparams: string[] = this.getTemplateParams(line); - const cppGenerator: IDocGen = new Generator(this.activeEditor, this.activeSelection, params, tparams, returnValue); + const cppGenerator: IDocGen = new Generator( + this.activeEditor, + this.activeSelection, + params, + tparams, + returnValue + ); return cppGenerator; } /*************************************************************************** Implementation ***************************************************************************/ - - protected getMethodText(): string { - let method: string = ""; + protected getLogicalLine(): string { + let logicalLine: string = ""; let nextLine: Position = new Position(this.activeSelection.line + 1, this.activeSelection.character); @@ -62,7 +67,7 @@ export default class CParser implements ICodeParser { nextLineTxt = this.activeEditor.document.lineAt(nextLine.line).text.trim(); } - method += nextLineTxt; + logicalLine += nextLineTxt; // Get method end line while (nextLineTxt.indexOf(")") === -1 && @@ -70,15 +75,15 @@ export default class CParser implements ICodeParser { nextLine = new Position(nextLine.line + 1, nextLine.character); nextLineTxt = this.activeEditor.document.lineAt(nextLine.line).text.trim(); - method += " " + nextLineTxt; + logicalLine += " " + nextLineTxt; } // Not a method but some code in the file - if (method.indexOf(")") === -1) { + if (logicalLine.indexOf(")") === -1) { return ""; } - return method; + return logicalLine; } protected getReturn(method: string): string[] { -- cgit v1.2.3 From df8f38308b7871f2790b5b2cc466f7ce2add4362 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Sun, 15 Oct 2017 02:32:52 +0200 Subject: -- Fixed tslint issues v2 --- src/CodeParser/CParser.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/CodeParser/CParser.ts') diff --git a/src/CodeParser/CParser.ts b/src/CodeParser/CParser.ts index 77b01eb..8b0bfe1 100644 --- a/src/CodeParser/CParser.ts +++ b/src/CodeParser/CParser.ts @@ -38,11 +38,11 @@ export default class CParser implements ICodeParser { const tparams: string[] = this.getTemplateParams(line); const cppGenerator: IDocGen = new Generator( - this.activeEditor, - this.activeSelection, - params, - tparams, - returnValue + this.activeEditor, + this.activeSelection, + params, + tparams, + returnValue, ); return cppGenerator; } -- cgit v1.2.3