diff options
| author | Christoph Schlosser <christophschlosser@users.noreply.github.com> | 2017-10-15 20:12:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-15 20:12:01 +0200 |
| commit | c7ebe707bbfbe52c75646a111600986d6c584d03 (patch) | |
| tree | f5435eda43b5d9bd22348f4400028c07b4a446c8 /src/CodeParser/CParser.ts | |
| parent | 140229888a0e4a120c11ecaae81132d07cc69e5b (diff) | |
| parent | 32baa67d95609fc2b0f20c582fe152eeee98ff35 (diff) | |
| download | doxdocgen-c7ebe707bbfbe52c75646a111600986d6c584d03.tar.gz | |
Merge pull request #16 from rowanG077/master
-- Added extensive templating the be able to generated different type…
Diffstat (limited to 'src/CodeParser/CParser.ts')
| -rw-r--r-- | src/CodeParser/CParser.ts | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/src/CodeParser/CParser.ts b/src/CodeParser/CParser.ts index 4889de6..8b0bfe1 100644 --- a/src/CodeParser/CParser.ts +++ b/src/CodeParser/CParser.ts @@ -25,27 +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 params: string[] = this.getParams(line); + const tparams: string[] = this.getTemplateParams(line); - 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; } /*************************************************************************** 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); @@ -61,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 && @@ -69,22 +75,22 @@ 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[] { 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 +112,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<boolean>(Config.generateReturnType, true) && - retVals.length > 0) { - retVals.length = 0; - retVals.push(" "); - return retVals; - } - return retVals; } @@ -139,4 +137,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; + } } |