diff options
| author | Christoph Schlosser <christoph@linux.com> | 2018-03-01 18:07:26 +0100 |
|---|---|---|
| committer | Christoph Schlosser <christophschlosser@users.noreply.github.com> | 2018-03-02 20:24:28 +0100 |
| commit | f41d471874c07e78a6541994b09e9f8bf751bfe5 (patch) | |
| tree | 118c2ab8a3ec704742632a9c9c4a35ed5e7904ed /src/Lang/Cpp/CppDocGen.ts | |
| parent | 38e3c4c2cf3feb2a73226a295d039fe907b044af (diff) | |
| download | doxdocgen-f41d471874c07e78a6541994b09e9f8bf751bfe5.tar.gz | |
Make smart text configurable
Diffstat (limited to 'src/Lang/Cpp/CppDocGen.ts')
| -rw-r--r-- | src/Lang/Cpp/CppDocGen.ts | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts index 6f3ecc7..a7994eb 100644 --- a/src/Lang/Cpp/CppDocGen.ts +++ b/src/Lang/Cpp/CppDocGen.ts @@ -29,6 +29,8 @@ export class CppDocGen implements IDocGen { protected specialCase: SpecialCase; protected commentType: CommentType; + protected smartTextLength: number; + /** * @param {TextEditor} actEdit Active editor window * @param {Position} cursorPosition Where the cursor of the user currently is @@ -54,16 +56,17 @@ export class CppDocGen implements IDocGen { this.params = params; this.specialCase = specialCase; this.commentType = commentType; + this.smartTextLength = 0; } /** * @inheritdoc */ public GenerateDoc(rangeToReplace: Range) { - let comment: string; + let comment: string = ""; if (this.commentType === CommentType.file) { comment = this.generateFileDescription(); - } else { + } else if (this.commentType === CommentType.method) { comment = this.generateComment(); } @@ -87,20 +90,30 @@ export class CppDocGen implements IDocGen { } protected getSmartText(): string { - // todo: Make the text customizable + if (!this.cfg.generateSmartText) { + return ""; + } switch (this.specialCase) { case SpecialCase.constructor: { if (this.func.name === null) { return ""; } else { - return "Construct a new " + this.func.name.trim() + " object"; + const str = this.getTemplatedString(this.cfg.nameTemplateReplace, + this.cfg.ctorText, + this.func.name.trim()); + this.smartTextLength = str.length; + return str; } } case SpecialCase.destructor: { if (this.func.name === null) { return ""; } else { - return "Destroy the " + this.func.name.replace("~", "").trim() + " object"; + const str = this.getTemplatedString(this.cfg.nameTemplateReplace, + this.cfg.dtorText, + this.func.name.replace("~", "").trim()); + this.smartTextLength = str.length; + return str; } } // tslint:disable-next-line:no-empty @@ -299,7 +312,8 @@ export class CppDocGen implements IDocGen { character = baseCharacter; } - const moveTo: Position = new Position(line, character); - this.activeEditor.selection = new Selection(moveTo, moveTo); + const from: Position = new Position(line, character - this.smartTextLength - 1); + const to: Position = new Position(line, character); + this.activeEditor.selection = new Selection(from, to); } } |