diff options
| author | Rowan Goemans <RB.Goemans@student.han.nl> | 2017-10-15 02:26:22 +0200 |
|---|---|---|
| committer | Rowan Goemans <RB.Goemans@student.han.nl> | 2017-10-15 02:26:22 +0200 |
| commit | cc0d69edcd362c1abde9d0005c70d8e3692395bc (patch) | |
| tree | 2d991729ec43b411dcbde82a4dd0424cdd0b9771 /src/CodeParser | |
| parent | 0ebfa5bd12e529d8febe73c85d3bf48c4d4997e8 (diff) | |
| download | doxdocgen-cc0d69edcd362c1abde9d0005c70d8e3692395bc.tar.gz | |
-- Fixed tslint issues.
-- Added config parameter to add type information to return DoxyGen parameter.
Diffstat (limited to 'src/CodeParser')
| -rw-r--r-- | src/CodeParser/CParser.ts | 31 | ||||
| -rw-r--r-- | src/CodeParser/CodeParserController.ts | 25 |
2 files changed, 37 insertions, 19 deletions
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[] { diff --git a/src/CodeParser/CodeParserController.ts b/src/CodeParser/CodeParserController.ts index 0a80e77..054aa38 100644 --- a/src/CodeParser/CodeParserController.ts +++ b/src/CodeParser/CodeParserController.ts @@ -1,4 +1,13 @@ -import { Disposable, Position, Range, TextDocumentContentChangeEvent, TextEditor, TextLine, window, workspace } from "vscode"; +import { + Disposable, + Position, + Range, + TextDocumentContentChangeEvent, + TextEditor, + TextLine, + window, + workspace +} from "vscode"; import { Config, ConfigType } from "../Config"; import CodeParser from "./CodeParser"; import CParser from "./CParser"; @@ -51,7 +60,9 @@ export default class CodeParserController { ***************************************************************************/ private readConfig() { - this.triggerSequence = workspace.getConfiguration(ConfigType.generic).get<string>(Config.triggerSequence, "/**"); + this.triggerSequence = workspace + .getConfiguration(ConfigType.generic) + .get<string>(Config.triggerSequence, "/**"); } private check(activeEditor: TextEditor, event: TextDocumentContentChangeEvent): boolean { @@ -63,13 +74,12 @@ export default class CodeParserController { const activeChar: string = activeLine.text.charAt(activeSelection.character); const startsWith: boolean = event.text.startsWith("\n") || event.text.startsWith("\r\n"); - // Check if enter was pressed. Note the ! + // Check if enter was pressed. Note the ! if (!((activeChar === "") && startsWith)) { return false; } const cont: string = activeLine.text.trim(); - let found: boolean = false; return this.triggerSequence === cont; } @@ -96,10 +106,13 @@ export default class CodeParserController { } const currentPos: Position = window.activeTextEditor.selection.active; - const startReplace: Position = new Position(currentPos.line, currentPos.character - this.triggerSequence.length); + const startReplace: Position = new Position( + currentPos.line, + currentPos.character - this.triggerSequence.length + ); let endReplace: Position = new Position(currentPos.line, currentPos.character); - const nextLineText: String = window.activeTextEditor.document.lineAt(endReplace.line + 1).text; + const nextLineText: string = window.activeTextEditor.document.lineAt(endReplace.line + 1).text; // VSCode may enter a * on itself, we don't want that in our comment. if (nextLineText.trim() === "*") { endReplace = new Position(currentPos.line + 1, nextLineText.length); |