Skip to content

Commit 01d8b1b

Browse files
committed
[ADD] additional debug lines to help understand the progress of the code
1 parent 5f83aa3 commit 01d8b1b

File tree

9 files changed

+87
-1
lines changed

9 files changed

+87
-1
lines changed

vscode/asperheader/src/extension.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const RANDOM_LOGO: RandomLogo = new RandomLogo();
8484
* operations across different file types and languages.
8585
*/
8686
function getFileInfo(editor: vscode.TextEditor) {
87+
logger.debug(getMessage("inFunction", "getFileInfo"));
8788
const document = editor.document;
8889
const filePath = document.uri.fsPath;
8990
const fileName = document.uri.path.split('/').pop() || "unknown";
@@ -103,6 +104,7 @@ function getFileInfo(editor: vscode.TextEditor) {
103104
* to verify extension functionality and user interaction.
104105
*/
105106
function helloWorldCommand() {
107+
logger.debug(getMessage("inFunction", "helloWorldCommand"));
106108
vscode.window.showInformationMessage(getMessage("helloWorldGreetingsCommand", moduleName));
107109
}
108110

@@ -115,6 +117,7 @@ function helloWorldCommand() {
115117
* and language type. Demonstrates file analysis capabilities.
116118
*/
117119
async function sayHelloWorldCommand() {
120+
logger.debug(getMessage("inFunction", "sayHelloWorldCommand"));
118121
const editor = vscode.window.activeTextEditor;
119122
if (!editor) {
120123
logger.Gui.error(getMessage("noActiveEditor"));
@@ -140,6 +143,7 @@ async function sayHelloWorldCommand() {
140143
* to ensure atomic updates and prevent corruption.
141144
*/
142145
async function updateSaveSafe(document: vscode.TextDocument) {
146+
logger.debug(getMessage("inFunction", "updateSaveSafe"));
143147
if (updatingDocuments.has(document)) {
144148
return;
145149
}
@@ -166,6 +170,7 @@ async function updateSaveSafe(document: vscode.TextDocument) {
166170
* workspace folders and legacy root path configurations.
167171
*/
168172
function refreshWorkspaceName() {
173+
logger.debug(getMessage("inFunction", "refreshWorkspaceName"));
169174
let workspaceName: string | undefined;
170175

171176
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) {
@@ -188,6 +193,7 @@ function refreshWorkspaceName() {
188193
* and GUI notification channels.
189194
*/
190195
async function toMorseGui() {
196+
logger.debug(getMessage("inFunction", "toMorseGui"));
191197
const usr_input: string | undefined = await query.input(getMessage("toMorseGetInput"));
192198
if (usr_input === undefined) {
193199
logger.Gui.info(getMessage("operationCanceled"));
@@ -208,6 +214,7 @@ async function toMorseGui() {
208214
* and GUI notification channels.
209215
*/
210216
async function fromMorseGui() {
217+
logger.debug(getMessage("inFunction", "fromMorseGui"));
211218
const usr_input: string | undefined = await query.input(getMessage("fromMorseGetInput"));
212219
if (usr_input === undefined) {
213220
logger.Gui.info(getMessage("operationCanceled"));

vscode/asperheader/src/modules/commentGenerator.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,20 +177,24 @@ export class CommentGenerator {
177177
* is undefined, appropriate warnings are logged and defaults are used.
178178
*/
179179
constructor(languageComment: LazyFileLoader | undefined = undefined, editor: vscode.TextEditor | undefined = undefined, randomLogoInstance: RandomLogo | undefined = undefined) {
180+
logger.debug(getMessage("inFunction", "constructor", "CommentGenerator"));
180181
if (languageComment !== undefined) {
181182
this.languageComment = languageComment;
183+
logger.debug(getMessage("foundLanguageComment"));
182184
} else {
183185
logger.warning(getMessage("missingLanguageComment"));
184186
}
185187
if (!editor) {
186188
logger.warning(getMessage("noFocusedEditors"));
187189
} else {
188190
this.updateFileInfo(editor);
191+
logger.debug(getMessage("foundFocusEditor"));
189192
}
190193
if (!randomLogoInstance) {
191194
logger.warning(getMessage("noLogoInstanceProvided"));
192195
} else {
193196
this.randomLogo = randomLogoInstance;
197+
logger.debug(getMessage("foundLogoInstance"));
194198
}
195199
}
196200

@@ -203,9 +207,12 @@ export class CommentGenerator {
203207
* for use in text manipulation operations.
204208
*/
205209
private determineNewLine(eol: vscode.EndOfLine): string {
210+
logger.debug(getMessage("inFunction", "determineNewLine", "CommentGenerator"));
206211
if (eol === vscode.EndOfLine.LF) {
212+
logger.debug(getMessage("foundNewLine", "\\n"));
207213
return "\n";
208214
} else {
215+
logger.debug(getMessage("foundNewLine", "\\r\\n"));
209216
return "\r\n";
210217
}
211218
}
@@ -221,6 +228,7 @@ export class CommentGenerator {
221228
* formatting and project name.
222229
*/
223230
private headerOpener(comment: string, eol: vscode.EndOfLine, projectName: string = this.Config.get("extensionName")): string {
231+
logger.debug(getMessage("inFunction", "headerOpener", "CommentGenerator"));
224232
let final: string = comment + this.Config.get("headerOpenerDecorationOpen");
225233
final += this.Config.get("telegraphBegin") + " ";
226234
final += projectName;
@@ -238,6 +246,7 @@ export class CommentGenerator {
238246
* Supports both language ID matching and file extension fallback.
239247
*/
240248
private async determineCorrectComment(): Promise<CommentStyle> {
249+
logger.debug(getMessage("inFunction", "determineCorrectComment", "CommentGenerator"));
241250
const primaryKey: string = "langs";
242251
let commentStructure: CommentStyle = {
243252
singleLine: [],
@@ -318,6 +327,7 @@ export class CommentGenerator {
318327
* for the current file. The description will be included in the header.
319328
*/
320329
private async determineHeaderDescription(): Promise<string[]> {
330+
logger.debug(getMessage("inFunction", "determineHeaderDescription", "CommentGenerator"));
321331
let final: string[] = [];
322332
const usrResponse: string | undefined = await query.input(getMessage("getHeaderDescription"));
323333
final.push(usrResponse || "");
@@ -332,6 +342,7 @@ export class CommentGenerator {
332342
* for categorizing the current file.
333343
*/
334344
private async determineHeaderTags(): Promise<string[]> {
345+
logger.debug(getMessage("inFunction", "determineHeaderTags", "CommentGenerator"));
335346
let final: string[] = [];
336347
const usrResponse: string | undefined = await query.input(getMessage("getHeaderTags"));
337348
final.push(usrResponse || "");
@@ -346,6 +357,7 @@ export class CommentGenerator {
346357
* purpose or function of the current file.
347358
*/
348359
private async determineHeaderPurpose(): Promise<string[]> {
360+
logger.debug(getMessage("inFunction", "determineHeaderPurpose", "CommentGenerator"));
349361
let final: string[] = [];
350362
const usrResponse: string | undefined = await query.input(getMessage("getHeaderPurpose"));
351363
final.push(usrResponse || "");
@@ -363,6 +375,7 @@ export class CommentGenerator {
363375
* option if only one exists, or the first option if user cancels selection.
364376
*/
365377
private async getSingleCommentOption(commentOptions: string[]): Promise<string> {
378+
logger.debug(getMessage("inFunction", "getSingleCommentOption", "CommentGenerator"));
366379
if (commentOptions.length === 0) {
367380
logger.Gui.error(getMessage("noCommentToShow"));
368381
throw Error(getMessage("noCommentToShow"));
@@ -383,6 +396,7 @@ export class CommentGenerator {
383396
* (like "File:", "Date:") and their corresponding values.
384397
*/
385398
private addKeyDefinitionSeparator(): string {
399+
logger.debug(getMessage("inFunction", "addKeyDefinitionSeparator", "CommentGenerator"));
386400
const userSettingDefinedElement: string = this.Config.get("headerKeyDefinitionSeparator");
387401
return userSettingDefinedElement || this.Config.get("headerKeyDefinitionSeparator");
388402
}
@@ -397,6 +411,7 @@ export class CommentGenerator {
397411
* Uses configured date separators and formatting from the extension settings.
398412
*/
399413
private addCreationDate(comment: string, eol: vscode.EndOfLine) {
414+
logger.debug(getMessage("inFunction", "addCreationDate", "CommentGenerator"));
400415
const now = new Date();
401416
const day = String(now.getDate()).padStart(2, "0");
402417
const month = String(now.getMonth() + 1).padStart(2, "0"); // Months are 0-based
@@ -421,6 +436,7 @@ export class CommentGenerator {
421436
* the date using configured separators.
422437
*/
423438
private addLastModifiedDate(comment: string, eol: vscode.EndOfLine) {
439+
logger.debug(getMessage("inFunction", "addLastModifiedDate", "CommentGenerator"));
424440
const now: Date = new Date();
425441
const day: string = String(now.getDate()).padStart(2, "0");
426442
const month: string = String(now.getMonth() + 1).padStart(2, "0"); // Months are 0-based
@@ -454,6 +470,7 @@ export class CommentGenerator {
454470
* optional blank line based on configuration.
455471
*/
456472
private addMultilineKey(comment: string, eol: vscode.EndOfLine, tagName: string, tagDefinition: string[]): string {
473+
logger.debug(getMessage("inFunction", "addMultilineKey", "CommentGenerator"));
457474
const eolStr: string = this.determineNewLine(eol);
458475
let final: string = comment + tagName + this.addKeyDefinitionSeparator() + eolStr;
459476
for (let i = 0; i < tagDefinition.length; i++) {
@@ -477,6 +494,7 @@ export class CommentGenerator {
477494
* Creates a single-line key-value pair in the header format.
478495
*/
479496
private addSingleLineKey(comment: string, eol: vscode.EndOfLine, tagName: string, tagDefinition: string): string {
497+
logger.debug(getMessage("inFunction", "addSingleLineKey", "CommentGenerator"));
480498
let final: string = comment + tagName + this.addKeyDefinitionSeparator();
481499
final += tagDefinition + this.determineNewLine(eol);
482500
return final;
@@ -492,6 +510,7 @@ export class CommentGenerator {
492510
* before the final header closing line.
493511
*/
494512
private beforeHeaderCloser(comment: string, eol: vscode.EndOfLine): string {
513+
logger.debug(getMessage("inFunction", "beforeHeaderCloser", "CommentGenerator"));
495514
return comment + this.Config.get("telegraphEndOfTransmission") + this.determineNewLine(eol);
496515
}
497516

@@ -506,6 +525,7 @@ export class CommentGenerator {
506525
* formatting and project name, matching the opener format.
507526
*/
508527
private headerCloser(comment: string, eol: vscode.EndOfLine, projectName: string = this.Config.get("extensionName")): string {
528+
logger.debug(getMessage("inFunction", "headerCloser", "CommentGenerator"));
509529
let final: string = comment + this.Config.get("headerOpenerDecorationOpen");
510530
final += this.Config.get("telegraphEnd") + " ";
511531
final += projectName;
@@ -524,6 +544,7 @@ export class CommentGenerator {
524544
* and updates configuration-dependent properties.
525545
*/
526546
private updateFileInfo(editor: vscode.TextEditor, document: vscode.TextDocument | undefined = undefined) {
547+
logger.debug(getMessage("inFunction", "updateFileInfo", "CommentGenerator"));
527548
this.headerInnerEnd = undefined;
528549
this.headerInnerStart = undefined;
529550
if (document === undefined) {
@@ -561,6 +582,7 @@ export class CommentGenerator {
561582
* both multi-line and single-line comment styles with user prompting when needed.
562583
*/
563584
private async getCorrectCommentPrefix(determinedComment: CommentStyle): Promise<string[]> {
585+
logger.debug(getMessage("inFunction", "getCorrectPrefix", "CommentGenerator"));
564586
let commentOpener: string = "";
565587
let commentMiddle: string = "";
566588
let commentCloser: string = "";
@@ -612,6 +634,7 @@ export class CommentGenerator {
612634
* - Closing comment delimiter
613635
*/
614636
private async buildTheHeader(comments: string[]): Promise<string[]> {
637+
logger.debug(getMessage("inFunction", "buildTheHeader", "CommentGenerator"));
615638
const eol: vscode.EndOfLine = this.documentEOL || vscode.EndOfLine.LF;
616639
const unknownTerm: string = getMessage("unknown");
617640
const commentOpener: string = comments[0] || "";
@@ -675,6 +698,7 @@ export class CommentGenerator {
675698
* boundaries have been previously determined by locateIfHeaderPresent().
676699
*/
677700
private async updateEditDate(editor: vscode.TextEditor, comments: string[]) {
701+
logger.debug(getMessage("inFunction", "updateEditDate", "CommentGenerator"));
678702
const commentOpener: string = comments[0] || "";
679703
const commentMiddle: string = comments[1] || "";
680704
const commentCloser: string = comments[2] || "";
@@ -735,6 +759,7 @@ export class CommentGenerator {
735759
* header is found. Detects broken headers (mismatched/missing opener/closer).
736760
*/
737761
protected locateIfHeaderPresent(comments: string[]): boolean | undefined {
762+
logger.debug(getMessage("inFunction", "locateIfHeaderPresent", "CommentGenerator"));
738763
const commentOpener: string = comments[0] || "";
739764
const commentMiddle: string = comments[1] || "";
740765
const commentCloser: string = comments[2] || "";
@@ -790,6 +815,7 @@ export class CommentGenerator {
790815
* top of the document. Handles shebang line detection and offset calculation.
791816
*/
792817
private async writeHeaderToFile(editor: vscode.TextEditor, comments: string[]): Promise<number> {
818+
logger.debug(getMessage("inFunction", "writeHeaderToFile", "CommentGenerator"));
793819
let offset: number = 0;
794820
const headerContent: string[] = await this.buildTheHeader(comments);
795821
// determine if the first line has a shebang like line on the first line, if true, add a new line, and write from that line.
@@ -809,6 +835,7 @@ export class CommentGenerator {
809835
* This method is typically called by user command activation.
810836
*/
811837
async injectHeader() {
838+
logger.debug(getMessage("inFunction", "injectHeader", "CommentGenerator"));
812839
const editor = vscode.window.activeTextEditor;
813840
if (editor === undefined) {
814841
logger.error(getMessage("noFocusedEditors"));
@@ -870,6 +897,7 @@ export class CommentGenerator {
870897
* file name, and full file path against minimatch patterns.
871898
*/
872899
private async allowedToActivate(): Promise<boolean> {
900+
logger.debug(getMessage("inFunction", "allowedToActivate", "CommentGenerator"));
873901
const ignored: string[] = CodeConfig.get("extensionIgnore") ?? [];
874902

875903
for (const pattern of ignored) {
@@ -894,6 +922,7 @@ export class CommentGenerator {
894922
* dependency injection or runtime reconfiguration.
895923
*/
896924
updateLogoInstanceRandomiser(randomLogoInstance: RandomLogo): void {
925+
logger.debug(getMessage("inFunction", "updateLogoInstanceRandomiser", "CommentGenerator"));
897926
this.randomLogo = randomLogoInstance;
898927
}
899928

@@ -908,6 +937,7 @@ export class CommentGenerator {
908937
* 3. Do nothing (if refresh disabled or file excluded)
909938
*/
910939
async refreshHeader(document: vscode.TextDocument | undefined) {
940+
logger.debug(getMessage("inFunction", "refreshHeader", "CommentGenerator"));
911941
const refreshOnSave: boolean = CodeConfig.get("refreshOnSave");
912942
const promptToCreateIfMissing: boolean = CodeConfig.get("promptToCreateIfMissing");
913943
if (!refreshOnSave) {

vscode/asperheader/src/modules/darling.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export class Darling {
144144
* directory configurations. If not provided, default values are used.
145145
*/
146146
constructor(filePath: string | undefined = undefined, cwd: string | undefined = undefined) {
147+
logger.debug(getMessage("inFunction", "constructor", "Darling"));
147148
if (filePath) {
148149
this.fileInstance.updateFilePath(filePath);
149150
}
@@ -161,6 +162,7 @@ export class Darling {
161162
* character data from a different JSON file location.
162163
*/
163164
async updateFilePath(filePath: string): Promise<boolean> {
165+
logger.debug(getMessage("inFunction", "updateFilePath", "Darling"));
164166
return await this.fileInstance.updateFilePath(filePath);
165167
}
166168

@@ -173,6 +175,7 @@ export class Darling {
173175
* resolving relative file paths.
174176
*/
175177
async updateCurrentWorkingDirectory(cwd: string): Promise<boolean> {
178+
logger.debug(getMessage("inFunction", "updateCurrentWorkingDirectory", "Darling"));
176179
return await this.fileInstance.updateCurrentWorkingDirectory(cwd);
177180
}
178181

@@ -185,6 +188,7 @@ export class Darling {
185188
* from the loaded data array.
186189
*/
187190
private getRandomNumber(maxValue: number): number {
191+
logger.debug(getMessage("inFunction", "getRandomNumber", "Darling"));
188192
return Math.floor(Math.random() * maxValue);
189193
}
190194

@@ -198,6 +202,7 @@ export class Darling {
198202
* Person interface format, handling property name transformations.
199203
*/
200204
async getRandomPerson(): Promise<Person> {
205+
logger.debug(getMessage("inFunction", "getRandomPerson", "Darling"));
201206
const fileContent = await this.fileInstance.get();
202207
if (!Array.isArray(fileContent) || fileContent.length === 0) {
203208
const err: string = getMessage("darlingJsonFileInvalid");
@@ -232,6 +237,7 @@ export class Darling {
232237
* Communicates success back to the VS Code extension.
233238
*/
234239
private copyButtonScript(): string {
240+
logger.debug(getMessage("inFunction", "copyButtonScript", "Darling"));
235241
return `
236242
<script>
237243
const vscode = acquireVsCodeApi();
@@ -255,6 +261,7 @@ export class Darling {
255261
* better readability. Maintains minimum font size constraints.
256262
*/
257263
private zoomScript(): string {
264+
logger.debug(getMessage("inFunction", "zoomScript", "Darling"));
258265
return `
259266
<script>
260267
let currentSize = 6;
@@ -297,6 +304,7 @@ export class Darling {
297304
* proper display and readability.
298305
*/
299306
private pageStyle(): string {
307+
logger.debug(getMessage("inFunction", "pageStyle", "Darling"));
300308
return `
301309
<style>
302310
body { font-family: sans-serif; padding: 20px; }
@@ -322,6 +330,7 @@ export class Darling {
322330
* interactive ASCII art with copy and zoom functionality.
323331
*/
324332
async displayRandomPersonInWindow() {
333+
logger.debug(getMessage("inFunction", "displayRandomPersonInWindow", "Darling"));
325334
const randomPerson: Person = await this.getRandomPerson();
326335

327336
const panel = vscode.window.createWebviewPanel(

0 commit comments

Comments
 (0)