diff options
| author | Christoph Schlosser <christoph@linux.com> | 2019-06-22 18:07:44 +0200 |
|---|---|---|
| committer | Christoph Schlosser <christoph@linux.com> | 2019-06-22 18:07:44 +0200 |
| commit | 2f358e66df977d696335816876fad7e759efcb8e (patch) | |
| tree | be58dff12f49403206702857f0489d8ff2b1d5f6 | |
| parent | 24f919cccad600fcf32d86ec90edfeec21a372ab (diff) | |
| parent | 2d7a744527e469397a6dce6f27d60fac4382ee53 (diff) | |
| download | doxdocgen-2f358e66df977d696335816876fad7e759efcb8e.tar.gz | |
Merge remote-tracking branch 'origin/master' into indent-option
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | CHANGELOG.md | 6 | ||||
| -rw-r--r-- | LICENSE | 2 | ||||
| -rw-r--r-- | package.json | 2 | ||||
| -rw-r--r-- | src/Lang/Cpp/CppDocGen.ts | 22 | ||||
| -rw-r--r-- | src/Lang/Cpp/CppParser.ts | 18 | ||||
| -rw-r--r-- | src/extension.ts | 32 | ||||
| -rw-r--r-- | src/test/CppTests/Config.test.ts | 5 | ||||
| -rw-r--r-- | src/test/tools/MockEditor.ts | 3 |
9 files changed, 56 insertions, 36 deletions
diff --git a/.travis.yml b/.travis.yml index e8d27fb..b46a0b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,8 @@ matrix: sudo: false - os: osx osx_image: xcode9.1 + allow_failures: + - os: linux # Currently linux tests seem broken stages: - lint diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aa7e35..0c9ed6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## [0.4.3] + +### Fix + +- Trigger Sequence /** causes extra */ to be generated and the comment block isn't fully generated. (#111) + ## [0.4.2] ### Fix @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017-2018 Christoph Schlosser +Copyright (c) 2017-2019 Christoph Schlosser Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/package.json b/package.json index 55f24f3..0e19d96 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "doxdocgen", "displayName": "Doxygen Documentation Generator", "description": "Let me generate Doxygen documentation from your source code for you.", - "version": "0.4.2", + "version": "0.4.3", "publisher": "cschlosser", "engines": { "vscode": "^1.16.0" diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts index 481a349..51a975f 100644 --- a/src/Lang/Cpp/CppDocGen.ts +++ b/src/Lang/Cpp/CppDocGen.ts @@ -45,6 +45,8 @@ export class CppDocGen implements IDocGen { protected smartTextLength: number; + protected vscodeAutoGeneratedComment: boolean; + /** * @param {TextEditor} actEdit Active editor window * @param {Position} cursorPosition Where the cursor of the user currently is @@ -52,6 +54,8 @@ export class CppDocGen implements IDocGen { * @param {CppArgument} func The type and name of the function to generate doxygen. * Doesn't contain anything if it is not a function. * @param {CppArgument[]} params The parameters of the function. Doesn't contain anything if it is not a function. + * @param {boolean} vscodeAutoGeneratedComment Set this to true if VS Code inserted an autogenerated comment closer + * on the next line after the comment. */ public constructor( actEdit: TextEditor, @@ -63,6 +67,7 @@ export class CppDocGen implements IDocGen { specialCase: SpecialCase, commentType: CommentType, casingType: CasingType, + vscodeAutoGeneratedComment: boolean, ) { this.activeEditor = actEdit; this.cfg = cfg; @@ -73,6 +78,7 @@ export class CppDocGen implements IDocGen { this.commentType = commentType; this.smartTextLength = 0; this.casingType = casingType; + this.vscodeAutoGeneratedComment = vscodeAutoGeneratedComment; } /** @@ -86,12 +92,24 @@ export class CppDocGen implements IDocGen { comment = this.generateComment(); } + // overwrite any autogenerated comment closer + let modifiedRangeToReplace = rangeToReplace; + if (this.vscodeAutoGeneratedComment) { + const newPos: Position = new Position( + modifiedRangeToReplace.end.line + 1, + modifiedRangeToReplace.end.character, + ); + modifiedRangeToReplace = new Range(rangeToReplace.start, newPos); + } + this.activeEditor.edit((editBuilder) => { - editBuilder.replace(rangeToReplace, comment); // Insert the comment + editBuilder.replace(modifiedRangeToReplace, comment); // Insert the comment }); // Set cursor to first DoxyGen command. - this.moveCursurToFirstDoxyCommand(comment, rangeToReplace.start.line, rangeToReplace.start.character); + this.moveCursurToFirstDoxyCommand(comment, + modifiedRangeToReplace.start.line, + modifiedRangeToReplace.start.character); } /*************************************************************************** diff --git a/src/Lang/Cpp/CppParser.ts b/src/Lang/Cpp/CppParser.ts index 37c36eb..ca5edbb 100644 --- a/src/Lang/Cpp/CppParser.ts +++ b/src/Lang/Cpp/CppParser.ts @@ -111,6 +111,8 @@ export default class CppParser implements ICodeParser { private casingType: CasingType; + private vscodeAutoGeneratedComment: boolean; + constructor(cfg: Config) { this.cfg = cfg; @@ -301,6 +303,7 @@ export default class CppParser implements ICodeParser { this.specialCase = SpecialCase.none; this.commentType = CommentType.method; + this.vscodeAutoGeneratedComment = false; } /** @@ -369,6 +372,7 @@ export default class CppParser implements ICodeParser { this.specialCase, this.commentType, this.casingType, + this.vscodeAutoGeneratedComment, ); } @@ -421,7 +425,9 @@ export default class CppParser implements ICodeParser { return ""; } - logicalLine += "\n" + nextLineTxt; + if (!this.isVsCodeAutoComplete(nextLineTxt)) { + logicalLine += "\n" + nextLineTxt; + } } throw new Error("More than " + linesToGet + " lines were read from editor and no end of expression was found."); @@ -799,4 +805,14 @@ export default class CppParser implements ICodeParser { return args; } + + private isVsCodeAutoComplete(line: string): boolean { + switch (line) { + case "*/": + this.vscodeAutoGeneratedComment = true; + return true; + default: + return false; + } + } } diff --git a/src/extension.ts b/src/extension.ts index 7a17b52..347b392 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,19 +1,12 @@ "use strict"; // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below -import * as opn from "opn"; import * as vscode from "vscode"; import CodeParserController from "./CodeParserController"; -enum ConfigChangedNotificationOptions { - CHANGED = "What's changed", - HIDE = "Don't show me again", - GLOBAL_STORAGE_KEY = "doxdocgen_hide_config_changed_notification", -} - enum Version { - CURRENT = "0.4.2", - PREVIOUS = "0.4.1", + CURRENT = "0.4.3", + PREVIOUS = "0.4.2", KEY = "doxdocgen_version", } @@ -24,31 +17,10 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(parser); - let change: boolean = false; - const version = context.globalState.get<string>(Version.KEY); if (version === undefined) { context.globalState.update(Version.KEY, Version.CURRENT); } else if (version !== Version.CURRENT) { - change = true; context.globalState.update(Version.KEY, Version.CURRENT); } - - let notificationHideThenable: Thenable<string>; - const active = context.globalState.get<string>(ConfigChangedNotificationOptions.GLOBAL_STORAGE_KEY); - if (change && (active === undefined || active !== "false")) { - // tslint:disable-next-line:max-line-length - notificationHideThenable = vscode.window.showWarningMessage("DoxDocGen: Config keys have changed. Please check your config!", ConfigChangedNotificationOptions.CHANGED, ConfigChangedNotificationOptions.HIDE); - } - - if (notificationHideThenable !== undefined) { - notificationHideThenable.then((action) => { - if (action === ConfigChangedNotificationOptions.CHANGED) { - // tslint:disable-next-line:max-line-length - opn("https://github.com/christophschlosser/doxdocgen/blob/0.3.0/CHANGELOG.md#config-update"); - } else if (action === ConfigChangedNotificationOptions.HIDE) { - context.globalState.update(ConfigChangedNotificationOptions.GLOBAL_STORAGE_KEY, "false"); - } - }); - } } diff --git a/src/test/CppTests/Config.test.ts b/src/test/CppTests/Config.test.ts index a4c96e6..1ef2a4d 100644 --- a/src/test/CppTests/Config.test.ts +++ b/src/test/CppTests/Config.test.ts @@ -153,4 +153,9 @@ suite("C++ - Configuration Tests", () => { const result = testSetup.SetLine("int createFooObject();").GetResult(); assert.equal("/**\n * @brief Test FooObject\n * \n * @return int \n */", result); }); + + test("Remove inserted '*/' from line", () => { + const result = testSetup.SetLines(["*/", "int foo();"]).GetResult(); + assert.equal("/**\n * @brief \n * \n * @return int \n */", result); + }); }); diff --git a/src/test/tools/MockEditor.ts b/src/test/tools/MockEditor.ts index 5368fb8..aa3cf69 100644 --- a/src/test/tools/MockEditor.ts +++ b/src/test/tools/MockEditor.ts @@ -1,5 +1,5 @@ import * as vscode from "vscode"; -import { TextEditor } from "vscode"; +import { Range, TextEditor } from "vscode"; import MockDocument from "./MockDocument"; import MockSelection from "./MockSelection"; import MockTextEditorEdit from "./MockTextEditorEdit"; @@ -11,6 +11,7 @@ export default class MockEditor implements TextEditor { public options: vscode.TextEditorOptions; public viewColumn?: vscode.ViewColumn; public editBuilder: MockTextEditorEdit; + public readonly visibleRanges: Range[]; public constructor(s: MockSelection, d: MockDocument) { this.selection = s; this.document = d; |