summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Config.ts6
-rw-r--r--src/Lang/Cpp/CppDocGen.ts28
2 files changed, 27 insertions, 7 deletions
diff --git a/src/Config.ts b/src/Config.ts
index e8d7379..3c589f5 100644
--- a/src/Config.ts
+++ b/src/Config.ts
@@ -25,6 +25,9 @@ export class Config {
values.dateTemplate = cfg.get<string>("dateTemplate", values.dateTemplate);
values.dateFormat = cfg.get<string>("dateFormat", values.dateFormat);
values.fileOrder = cfg.get<string[]>("fileOrder", values.fileOrder);
+ values.ctorText = cfg.get<string>("ctorText", values.ctorText);
+ values.dtorText = cfg.get<string>("dtorText", values.dtorText);
+ values.generateSmartText = cfg.get<boolean>("generateSmartText", values.generateSmartText);
return values;
}
@@ -53,4 +56,7 @@ export class Config {
public dateTemplate: string = "@date {date}";
public dateFormat: string = "YYYY-MM-DD";
public fileOrder: string[] = ["brief", "file", "author", "date"];
+ public ctorText: string = "YYYY-MM-DD";
+ public dtorText: string = "YYYY-MM-DD";
+ public generateSmartText: boolean = true;
}
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);
}
}