From cabf19e4caa35ae010b1bab19d48ad749a959e06 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sat, 22 Jun 2019 14:11:00 +0200 Subject: Implement new VS Code interface --- src/test/tools/MockEditor.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/tools/MockEditor.ts b/src/test/tools/MockEditor.ts index 5368fb8..b739e6d 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 { TextEditor, Range } 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; -- cgit v1.2.3 From c66cc5c25d8824ade69b91129a842666bf0cf13f Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sat, 22 Jun 2019 14:11:12 +0200 Subject: Fix autogenerated close comment --- src/Lang/Cpp/CppDocGen.ts | 22 ++++++++++++++++++++-- src/Lang/Cpp/CppParser.ts | 18 +++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/Lang/Cpp/CppDocGen.ts b/src/Lang/Cpp/CppDocGen.ts index 75b67af..bc5a355 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; + } + } } -- cgit v1.2.3 From ce440076fd969ef79439bd3e4c36ab3d32ded08a Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sat, 22 Jun 2019 14:15:23 +0200 Subject: Fix linter warning --- src/test/tools/MockEditor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/tools/MockEditor.ts b/src/test/tools/MockEditor.ts index b739e6d..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, Range } from "vscode"; +import { Range, TextEditor } from "vscode"; import MockDocument from "./MockDocument"; import MockSelection from "./MockSelection"; import MockTextEditorEdit from "./MockTextEditorEdit"; -- cgit v1.2.3 From 7ad7fab4de7c8412924d57b6dc93750b3cc895cd Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sat, 22 Jun 2019 14:27:29 +0200 Subject: Node8? --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e8d27fb..8def389 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ os: language: node_js node_js: - - "6" + - "8" matrix: include: diff --git a/appveyor.yml b/appveyor.yml index 58bfd6e..da7c3f5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ environment: - nodejs_version: "6" + nodejs_version: "8" branches: only: -- cgit v1.2.3 From 6aecd0bf004a0ab6e72c93f8b1541dc49db42659 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sat, 22 Jun 2019 14:34:46 +0200 Subject: Revert "Node8?" This reverts commit 2baed1e8d8b60d6b756ea6b9e08904999b099015. --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8def389..e8d27fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ os: language: node_js node_js: - - "8" + - "6" matrix: include: diff --git a/appveyor.yml b/appveyor.yml index da7c3f5..58bfd6e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ environment: - nodejs_version: "8" + nodejs_version: "6" branches: only: -- cgit v1.2.3 From a20fab8fc507b4072434d13e5158c86015d4cb42 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sat, 22 Jun 2019 14:36:44 +0200 Subject: Ignore linux tests --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) 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 -- cgit v1.2.3 From cd5f4ee6d59a16c5fc99c6deb681a325e0995c35 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sat, 22 Jun 2019 15:16:16 +0200 Subject: Add test for stripping trailing `*/` --- src/test/CppTests/Config.test.ts | 5 +++++ 1 file changed, 5 insertions(+) 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); + }); }); -- cgit v1.2.3 From 2d7a744527e469397a6dce6f27d60fac4382ee53 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sat, 22 Jun 2019 15:45:50 +0200 Subject: Release 0.4.3 (#115) * Remove now out of date notification * Set to release 0.4.3 --- CHANGELOG.md | 6 ++++++ LICENSE | 2 +- package.json | 2 +- src/extension.ts | 32 ++------------------------------ 4 files changed, 10 insertions(+), 32 deletions(-) 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 diff --git a/LICENSE b/LICENSE index f100565..b0772e0 100644 --- a/LICENSE +++ b/LICENSE @@ -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 8302a6e..324b067 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/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(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; - const active = context.globalState.get(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"); - } - }); - } } -- cgit v1.2.3