Skip to content
Snippets Groups Projects

Refactor doc comment generation feature implementation (issue #11)

Merged Csilla Farkas requested to merge csilla/titan.vs-code-extension:generateDocComment into main
2 files
+ 78
20
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -16,6 +16,7 @@ import { mainExclusionManager } from "../file-exclusion/MainExclusionManager";
import { clientManager } from "../client/ClientManager";
import { catchError } from "../common/Errors";
import { Command, CommandManager } from "./CommandManager";
import { DocCommentGenerator } from "../document-comment-generation/DocCommentGenerator";
class ExcludeByTpdCommand implements Command {
@@ -113,26 +114,8 @@ class GenerateDocumentCommentCommand implements Command {
@catchError
public async execute(file: Uri) {
const editor = window.activeTextEditor;
if(editor) {
const { selection, document } = editor;
const firstNonWhitespaceCharIdx = document.lineAt(selection.active.line).firstNonWhitespaceCharacterIndex;
const indentation = ' '.repeat(firstNonWhitespaceCharIdx);
const requestParams = {
identifier: { uri: document.uri.toString() },
indentation,
position: selection.active
};
const docComment = await clientManager.generateDocComment(requestParams);
if(docComment) {
const lineAbove = selection.active.line - 1;
editor.edit(editBuilder => {
editBuilder.insert(new Position(lineAbove, 0), indentation + docComment.trim());
});
}
}
const docCommentGenerator = new DocCommentGenerator();
await docCommentGenerator.insertDocComment();
}
}
Loading