Asper Header  1.0.14
The header injector extension
Loading...
Searching...
No Matches
extension.ts File Reference

Main extension entry point for AsperHeader VS Code extension. More...

Go to the source code of this file.

Functions

function getFileInfo (editor:vscode.TextEditor)
 Extracts comprehensive file information from VS Code text editor.
 
function helloWorldCommand ()
 Displays a simple greeting message from the extension.
 
function async sayHelloWorldCommand ()
 Inserts greeting message with current file information.
 
function async updateSaveSafe (document:vscode.TextDocument, comment_generator:CommentGenerator)
 Thread-safe document update handler for save events.
 
function refreshWorkspaceName ()
 Updates cached workspace name from VS Code workspace state.
 
function async toMorseGui ()
 Converts user input to Morse code through interactive GUI dialog.
 
function async fromMorseGui ()
 Converts Morse code input to plain text through interactive GUI dialog.
 
function async activate (context:vscode.ExtensionContext)
 Main extension activation entry point.
 
function export deactivate ()
 Extension cleanup and deactivation handler.
 

Variables

import *as path from path
 
import *as vscode from vscode
 
 import { moduleName } from './constants'
 
const earlyLog = vscode.window.createOutputChannel('AsperHeader-Preboot')
 
const updatingDocuments = new WeakSet<vscode.TextDocument>()
 
const CodeConfiguration
 

Detailed Description

Main extension entry point for AsperHeader VS Code extension.

Author
Henry Letellier
Version
1.0.10
Since
1.0.0
Date
2025

This file serves as the primary activation point for the AsperHeader VS Code extension, providing comprehensive file header management with ASCII art integration, multi-language support, and automated documentation features. The extension orchestrates various modules to deliver a cohesive development experience for file organization and documentation standardization.

Key responsibilities include:

  • Extension lifecycle management (activation/deactivation)
  • Command registration and routing
  • Module initialization and dependency injection
  • Workspace configuration and state management
  • Document save event handling with header refresh

The extension integrates multiple specialized modules:

  • CommentGenerator: Automated header injection and refresh
  • RandomLogo: ASCII art logo selection and display
  • Darling: Easter egg functionality with character display
  • Watermark: Author watermark management
  • MorseTranslator: Text-to-Morse code conversion utilities
  • logger: Dual-channel logging system for development and user feedback

Definition in file extension.ts.

Function Documentation

◆ activate()

function async activate ( context:vscode. ExtensionContext)

Main extension activation entry point.

Parameters
contextVS Code extension context providing access to extension resources

Orchestrates complete extension initialization including:

  • Module dependency injection and configuration
  • Asset path resolution for templates and resources
  • Command registration for user interaction
  • Event handler setup for document management
  • Logger initialization with installation state

Called automatically by VS Code when extension loads or when activation events are triggered.

Definition at line 243 of file extension.ts.

◆ deactivate()

function export deactivate ( )

Extension cleanup and deactivation handler.

Returns
Void - Completes synchronously with no explicit cleanup

Called when extension is deactivated, disabled, or VS Code closes. Currently implements graceful shutdown without explicit cleanup as modules handle their own resource management.

Definition at line 371 of file extension.ts.

◆ fromMorseGui()

function async fromMorseGui ( )

Converts Morse code input to plain text through interactive GUI dialog.

Returns
Promise<void> - Resolves when conversion and display are complete

Presents an input dialog for Morse code entry, converts the input to plain text using MorseTranslator, and displays the result through both console and GUI notification channels.

Definition at line 215 of file extension.ts.

◆ getFileInfo()

function getFileInfo ( editor:vscode. TextEditor)

Extracts comprehensive file information from VS Code text editor.

Parameters
editorActive VS Code text editor instance
Returns
Object containing file path, name, extension, and language ID

Analyzes the active editor's document to extract metadata used for header generation and file processing. Essential for context-aware operations across different file types and languages.

Definition at line 83 of file extension.ts.

◆ helloWorldCommand()

function helloWorldCommand ( )

Displays a simple greeting message from the extension.

Returns
Void - Operation completes synchronously

Basic command implementation showing informational notification to verify extension functionality and user interaction.

Definition at line 104 of file extension.ts.

◆ refreshWorkspaceName()

function refreshWorkspaceName ( )

Updates cached workspace name from VS Code workspace state.

Returns
Void - Updates configuration cache synchronously

Analyzes current workspace configuration to extract and cache the workspace name for use in header generation. Handles both workspace folders and legacy root path configurations.

Definition at line 169 of file extension.ts.

◆ sayHelloWorldCommand()

function async sayHelloWorldCommand ( )

Inserts greeting message with current file information.

Returns
Promise<void> - Resolves when message insertion is complete

Advanced hello command that analyzes the active editor and inserts contextual information including file path, extension, and language type. Demonstrates file analysis capabilities.

Definition at line 118 of file extension.ts.

◆ toMorseGui()

function async toMorseGui ( )

Converts user input to Morse code through interactive GUI dialog.

Returns
Promise<void> - Resolves when conversion and display are complete

Presents an input dialog for text entry, converts the input to Morse code using MorseTranslator, and displays the result through both console and GUI notification channels.

Definition at line 193 of file extension.ts.

◆ updateSaveSafe()

function async updateSaveSafe ( document:vscode. TextDocument,
comment_generator:CommentGenerator )

Thread-safe document update handler for save events.

Parameters
documentVS Code text document being saved
Returns
Promise<void> - Resolves when update operation is complete or skipped

Implements concurrency control to prevent multiple simultaneous header updates during save operations. Uses WeakSet tracking to ensure atomic updates and prevent corruption.

Definition at line 141 of file extension.ts.

Variable Documentation

◆ CodeConfiguration

const CodeConfiguration

Definition at line 68 of file extension.ts.

◆ earlyLog

const earlyLog = vscode.window.createOutputChannel('AsperHeader-Preboot')

Definition at line 59 of file extension.ts.

◆ import

import { moduleName } from './constants'

Definition at line 46 of file extension.ts.

◆ path

import* as path from path

Definition at line 44 of file extension.ts.

◆ updatingDocuments

const updatingDocuments = new WeakSet<vscode.TextDocument>()

Definition at line 65 of file extension.ts.

◆ vscode

import* as vscode from vscode
Examples
Automatic.

Definition at line 45 of file extension.ts.