### Get Library Entry Points Function Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/utils/package-json.md Gets the entry points for a library from its package.json. ```APIDOC ## Function: getLibraryEntryPoints ### Description Gets the entry points for a library from its `package.json`. ### Method `getLibraryEntryPoints` ### Parameters #### Request Body - **library** (AngularDependency) - Required - Information about the library. ### Returns `Promise>` - A map where the key is the import path and the value is the absolute path to the `.d.ts` file. ### Request Example ```javascript const angularDependency = { "name": "@angular/core", "path": "/path/to/node_modules/@angular/core" }; getLibraryEntryPoints(angularDependency); ``` ### Response Example ```json { "@angular/core": "/path/to/node_modules/@angular/core/fesm2020/core.mjs", "@angular/core/testing": "/path/to/node_modules/@angular/core/fesm2020/testing.mjs" } ``` ``` -------------------------------- ### Install Dependencies with pnpm Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/CLAUDE.md Installs project dependencies using the pnpm package manager. This is a fundamental step before running any development or build commands. ```bash pnpm install ``` -------------------------------- ### Logger Instance Management Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/logger/logger-1.md Provides methods to get the logger instance and initialize it with the extension context. ```APIDOC ## Logger Management ### initialize() #### Description Initializes the logger with the extension context. #### Method `void initialize(context: ExtensionContext)` #### Parameters - **context** (ExtensionContext) - The VS Code extension context. ### getInstance() #### Description Gets the singleton instance of the logger. #### Method `static Logger getInstance(): Logger` #### Returns - **Logger** - The logger instance. ``` -------------------------------- ### Create VSIX Package Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/CLAUDE.md Generates a .vsix package for the VS Code extension, which can be used for manual installation or distribution. This command is part of the publishing workflow. ```bash pnpm run vsce:package ``` -------------------------------- ### ExtensionConfig Interface Example - TypeScript Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/config/settings.md Demonstrates how to define and use the ExtensionConfig interface for Angular Auto-Import extension settings. This interface outlines all configurable options for the extension. ```typescript const config: ExtensionConfig = { projectPath: '/path/to/project', indexRefreshInterval: 60, diagnosticsEnabled: true, diagnosticsSeverity: 'warning' }; ``` -------------------------------- ### Development Build with Watch Mode Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/CLAUDE.md Starts a development build process that watches for file changes and automatically recompiles the project. This command is essential for active development. ```bash pnpm run watch ``` -------------------------------- ### Get Project Context for Document Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/Main-extension-entry-point-for-Angular-Auto-Import.md Retrieves the project context for a given VS Code document. It identifies which Angular project the document belongs to and returns its associated indexer and TypeScript configuration. Returns undefined if no context is found. ```typescript import { TextDocument } from "vscode"; import { getProjectContextForDocument } from "./extension"; function processDocument(document: TextDocument) { const context = getProjectContextForDocument(document); if (context) { const { projectRootPath, indexer, tsConfig } = context; // Use indexer to find Angular elements console.log(`Processing document in project: ${projectRootPath}`); } else { console.log('Document does not belong to a known Angular project.'); } } ``` -------------------------------- ### Get TypeScript Document - VS Code Helper Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/utils/vscode-helpers.md Opens a TypeScript document by its path. If the provided component path matches the current document's path, it returns the current document. Otherwise, it attempts to open the document by the specified path. This function is useful for accessing and manipulating code within different TypeScript files in the VS Code environment. ```typescript /** * Opens a TypeScript document by path, or returns the current document if paths match * @param currentDocument The currently active document * @param componentPath The path to the TypeScript file to open * @returns The opened TextDocument or null if it couldn't be opened */ async getTsDocument(currentDocument: TextDocument, componentPath: string): Promise ``` -------------------------------- ### Get Extension Configuration - TypeScript Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/config/settings.md Retrieves the current configuration for the Angular Auto-Import extension from VS Code settings. This function reads all relevant settings and returns them as a structured ExtensionConfig object. ```typescript const config = getConfiguration(); if (config.diagnosticsEnabled) { // Enable diagnostics features } ``` -------------------------------- ### Implement LRUCache in TypeScript Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/utils/cache.md This TypeScript code defines a generic LRUCache class that implements a Least Recently Used caching strategy. It uses a Map internally to store key-value pairs and manages the cache based on a defined capacity. The class provides methods for setting, getting, deleting, and clearing cache entries, as well as retrieving the current size of the cache. ```typescript class LruCache { private cache: Map; private capacity: number; constructor(capacity: number) { this.capacity = capacity; this.cache = new Map(); } get(key: K): undefined | V { const value = this.cache.get(key); if (value !== undefined) { this.cache.delete(key); this.cache.set(key, value); } return value; } set(key: K, value: V): void { if (this.cache.has(key)) { this.cache.delete(key); } else if (this.cache.size >= this.capacity) { const firstKey = this.cache.keys().next().value; this.cache.delete(firstKey); } this.cache.set(key, value); } delete(key: K): void { this.cache.delete(key); } clear(): void { this.cache.clear(); } get size(): number { return this.cache.size; } } ``` -------------------------------- ### Performance and Configuration Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/logger/logger-1.md Methods for managing performance metrics and internal configuration. ```APIDOC ## Performance and Configuration ### startTimer() #### Description Starts a performance timer. #### Method `void startTimer(name: string)` #### Parameters - **name** (string) - The name of the timer to start. ### stopTimer() #### Description Stops a performance timer and returns its duration. #### Method `void stopTimer(name: string)` #### Parameters - **name** (string) - The name of the timer to stop. ### getPerformanceMetrics() #### Description Retrieves performance metrics. #### Method `PerformanceMetrics getPerformanceMetrics(): PerformanceMetrics` #### Returns - **PerformanceMetrics** - An object containing performance data. ### setupTransports() #### Description Sets up the logging transports. #### Method `private void setupTransports()` ### updateConfig() #### Description Updates the logger configuration. #### Method `private void updateConfig()` ``` -------------------------------- ### Activate Angular Auto-Import Extension Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/Main-extension-entry-point-for-Angular-Auto-Import.md Activates the Angular Auto-Import extension upon VS Code startup. This asynchronous function handles configuration loading, project discovery, and the registration of necessary providers and commands. ```typescript import { activate } from "./extension"; import { ExtensionContext } from "vscode"; // Called automatically by VS Code when extension activates export async function activate(context: ExtensionContext) { await activate(context); } ``` -------------------------------- ### Production Build for Packaging Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/CLAUDE.md Creates a production-ready build of the extension, optimized for packaging and distribution. This command should be used before publishing or creating a distributable package. ```bash pnpm run package ``` -------------------------------- ### CompletionProvider: createDocumentationString (TypeScript) Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/providers/completion.md This private method generates a documentation string for a completion item. It uses the provided prefix, element data, and the original best selector to create informative documentation. ```typescript private createDocumentationString(prefix: string, element: AngularElementData, originalBestSelector: string): string ``` -------------------------------- ### Project Context and Root Determination Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/Main-extension-entry-point-for-Angular-Auto-Import.md Functions for determining project root directories and retrieving project context for specific documents within the workspace. ```APIDOC ## determineProjectRoots() ### Description Determines the project root directories for Angular Auto-Import to operate on. Uses configured `projectPath` setting if provided and valid, otherwise falls back to workspace folders. Returns an empty array if neither is available or valid. This function is exported for testing purposes only. ### Method `determineProjectRoots` ### Parameters #### Query Parameters - **config** ([`ExtensionConfig`](config/settings.md#extensionconfig)) - Optional - Extension configuration (uses current config if not provided) #### Returns `Promise` - Promise resolving to an array of absolute project root paths. #### Throws When configured project path is invalid or inaccessible. ### Request Example ```typescript const roots = await determineProjectRoots(); logger.info('Found project roots:', roots); // Output: ['C:\workspace\my-angular-app\src'] (if projectPath configured to src/) ``` ## getProjectContextForDocument() ### Description Retrieves the project context for a given VS Code document. Determines which project a document belongs to and returns the associated indexer and TypeScript configuration. The lookup follows direct workspace folder membership or fallback to path-based matching against known project roots. ### Method `getProjectContextForDocument` ### Parameters #### Path Parameters - **document** (`TextDocument`) - Required - The VS Code text document to find context for. #### Returns `undefined | [ProjectContext](types/angular.md#projectcontext)` - Project context containing indexer and tsconfig, or undefined if not found. ### Request Example ```typescript const context = getProjectContextForDocument(document); if (context) { const { projectRootPath, indexer, tsConfig } = context; // Use indexer to find Angular elements } ``` ``` -------------------------------- ### Indexer Service Methods Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/services/indexer.md This section details the various methods provided by the indexer service, including those for managing project data, resolving imports, and searching for selectors. ```APIDOC ## Private Methods ### `removeOldSelectorsFromIndex(cachedFile)` #### Description Removes old selectors from the index. (Exact functionality not fully described in source). #### Method `private removeOldSelectorsFromIndex` #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body N/A #### Request Example ```json { "cachedFile": null or "FileElementsInfo" } ``` #### Response ##### Success Response (200) Type: `Promise` ##### Response Example ```json // No response body for void return type ``` ### `removeSourceFileFromProject(filePath)` #### Description Safely removes a source file from the ts-morph project. #### Method `private removeSourceFileFromProject` #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body - **filePath** (string) - Required - The path to the file to remove. #### Request Example ```json { "filePath": "/path/to/your/angular/component.ts" } ``` #### Response ##### Success Response (200) Type: `void` ##### Response Example ```json // No response body for void return type ``` ### `resolveElementImportInfo(parsed)` #### Description Resolves import information for a given parsed component. #### Method `private resolveElementImportInfo` #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body - **parsed** (ComponentInfo) - Required - The parsed component information. #### Request Example ```json { "parsed": { "componentName": "MyComponent", "templateUrl": "./my-component.html", "styleUrls": ["./my-component.scss"], "directives": [], "pipes": [], "standalone": false, "imports": [] } } ``` #### Response ##### Success Response (200) - **importName** (string) - The name to import. - **importPath** (string) - The path from which to import. - **moduleToImport** (undefined | string) - The specific module to import from, if applicable. ##### Response Example ```json { "importName": "MyComponent", "importPath": "../components/my-component", "moduleToImport": "../components" } ``` ### `retrieveWorkspaceData(context)` #### Description Retrieves workspace data, including cached files, external modules, and the index. #### Method `private retrieveWorkspaceData` #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body - **context** (ExtensionContext) - Required - The extension context. #### Request Example ```json { "context": { "workspaceState": {}, "globalState": {}, "extensionPath": "/path/to/extension" // ... other ExtensionContext properties } } ``` #### Response ##### Success Response (200) - **storedCache** (undefined | Record) - Cached file information. - **storedExternalModulesExports** (undefined | Record) - Exports from external modules. - **storedIndex** (undefined | Record) - The main index of Angular elements. - **storedModules** (undefined | Record) - Information about modules. ##### Response Example ```json { "storedCache": { "/path/to/file1.ts": { "componentName": "ComponentA", "templateUrl": "./file1.html" // ... other FileElementsInfo properties } }, "storedExternalModulesExports": { "@angular/core": ["Component", "NgModule"] }, "storedIndex": { "button": { "name": "button", "type": "element", "path": "/path/to/angular-element.ts" // ... other AngularElementData properties } }, "storedModules": { "@angular/forms": { "importPath": "@angular/forms", "moduleName": "FormsModule", "exportCount": 5 } } } ``` ### `saveIndexToWorkspace(context)` #### Description Saves the current index to the workspace state. #### Method `private saveIndexToWorkspace` #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body - **context** (ExtensionContext) - Required - The extension context. #### Request Example ```json { "context": { "workspaceState": {}, "globalState": {}, "extensionPath": "/path/to/extension" // ... other ExtensionContext properties } } ``` #### Response ##### Success Response (200) Type: `Promise` ##### Response Example ```json // No response body for void return type ``` ## Public Methods ### `searchWithSelectors(prefix)` #### Description Searches for selectors within the indexed data that start with the given prefix. #### Method `searchWithSelectors` #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body - **prefix** (string) - Required - The prefix to search for (e.g., "my-app-"). #### Request Example ```json { "prefix": "mat-" } ``` #### Response ##### Success Response (200) - **object[]** - An array of objects, where each object contains: - **selector** (string) - The matching selector. - **data** (AngularElementData) - The associated Angular element data. ##### Response Example ```json [ { "selector": "mat-button", "data": { "name": "mat-button", "type": "element", "path": "/node_modules/@angular/material/button/button.d.ts" // ... other AngularElementData properties } }, { "selector": "mat-card", "data": { "name": "mat-card", "type": "element", "path": "/node_modules/@angular/material/card/card.d.ts" // ... other AngularElementData properties } } ] ``` ### `setProjectRoot(projectPath)` #### Description Sets the root path of the Angular project that the indexer should operate on. #### Method `setProjectRoot` #### Parameters ##### Path Parameters N/A ##### Query Parameters N/A ##### Request Body - **projectPath** (string) - Required - The absolute path to the root directory of the Angular project. #### Request Example ```json { "projectPath": "/Users/username/projects/my-angular-app" } ``` #### Response ##### Success Response (200) Type: `void` ##### Response Example ```json // No response body for void return type ``` ``` -------------------------------- ### Code Actions API Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/providers/quickfix.md Provides code actions for a given range in a document. It returns relevant code actions for the user, suitable for display in the UI. ```APIDOC ## POST /_extensions/angular-auto-import/code-actions ### Description Provides code actions for a given range in a document. It returns relevant code actions for the user, suitable for display in the UI. ### Method POST ### Endpoint /_extensions/angular-auto-import/code-actions ### Parameters #### Request Body - **document** (TextDocument) - Required - The document in which the command was invoked. - **range** (Range | Selection) - Required - The selector or range for which the command was invoked. - **context** (CodeActionContext) - Required - Provides additional information about what code actions are being requested. - **token** (CancellationToken) - Required - A cancellation token. ### Request Example ```json { "document": { /* ... TextDocument object ... */ }, "range": { "start": { "line": 0, "character": 0 }, "end": { "line": 1, "character": 0 } }, "context": { /* ... CodeActionContext object ... */ }, "token": { /* ... CancellationToken object ... */ } } ``` ### Response #### Success Response (200) - **actions** (Array) - An array of code actions, such as quick fixes or refactorings. #### Response Example ```json [ { "title": "Add import statement", "command": "angular-auto-import.addImport", "arguments": [ /* ... arguments ... */ ] } ] ``` ``` -------------------------------- ### Project Context API Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/providers/quickfix.md Retrieves the project context for a given document, including the Angular indexer, project root path, and processed TypeScript configuration. ```APIDOC ## GET /_extensions/angular-auto-import/project-context ### Description Retrieves the project context for a given document, including the Angular indexer, project root path, and processed TypeScript configuration. ### Method GET ### Endpoint /_extensions/angular-auto-import/project-context ### Parameters #### Query Parameters - **documentPath** (string) - Required - The path of the document for which to retrieve the project context. ### Request Example ``` GET /_extensions/angular-auto-import/project-context?documentPath=src/app/app.component.ts ``` ### Response #### Success Response (200) - **indexer** (AngularIndexer) - The Angular indexer instance. - **projectRootPath** (string) - The root path of the Angular project. - **tsConfig** (ProcessedTsConfig | null | undefined) - The processed TypeScript configuration. #### Response Example ```json { "indexer": { /* ... AngularIndexer object ... */ }, "projectRootPath": "/path/to/angular/project", "tsConfig": { /* ... ProcessedTsConfig object ... */ } } ``` ``` -------------------------------- ### Logger Class API Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/logger/logger-1.md Documentation for the Logger class, including its constructor, properties, and methods. ```APIDOC ## Logger Class ### Description Represents a logger for the Angular Auto Import Extension. ### Constructor * **new Logger**(): Initializes a new instance of the Logger class. * Returns: `Logger` ### Properties * `config` (private LoggerConfig): Configuration for the logger. * `context` (private null | ExtensionContext): VS Code extension context. * `extensionVersion` (private string): Version of the extension. * `logPoints` (private Map): Map of log points. * `sessionId` (private string): Session ID for logging. * `transports` (private Transport[]): Array of log transports. * `instance` (private Logger): Singleton instance of the Logger. ### Methods #### `anonymizeFilePath(filePath: string): string` * **Description**: Anonymizes a given file path. * **Parameters**: * `filePath` (string) - The file path to anonymize. * **Returns**: `string` - The anonymized file path. #### `buildErrorContext(error?: Error, context?: Record): Record` * **Description**: Builds a context object for error logging. * **Parameters**: * `error` (undefined | Error) - The error object. * `context?` (Record) - Additional context. * **Returns**: `Record` - The error context. #### `debug(message: string, context?: Record): void` * **Description**: Logs a debug message. * **Parameters**: * `message` (string) - The message to log. * `context?` (Record) - Additional context. * **Returns**: `void` #### `dispose(): void` * **Description**: Disposes of the logger resources. * **Returns**: `void` #### `error(message: string, error?: Error, context?: Record): void` * **Description**: Logs an error message. * **Parameters**: * `message` (string) - The error message. * `error?` (Error) - The error object. * `context?` (Record) - Additional context. * **Returns**: `void` #### `fatal(message: string, error?: Error, context?: Record): void` * **Description**: Logs a fatal error message. * **Parameters**: * `message` (string) - The fatal error message. * `error?` (Error) - The error object. * `context?` (Record) - Additional context. * **Returns**: `void` #### `getCallerLocation(): object` * **Description**: Gets the location of the caller. * **Returns**: `object` - An object containing `fileName` and `lineNumber`. #### `getLogLevelValue(level: string): number` * **Description**: Gets the numerical value of a log level. * **Parameters**: * `level` (string) - The log level (e.g., 'debug', 'info', 'error'). * **Returns**: `number` - The numerical log level value. ``` -------------------------------- ### Compile Tests and Fixtures Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/CLAUDE.md Compiles test files and fixtures necessary for running the extension's test suite. This command is typically run before executing the main test command. ```bash pnpm run pretest ``` -------------------------------- ### Show Logs Command Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/CLAUDE.md Displays the extension's output channel, which contains logs and diagnostic information. This command is helpful for debugging and understanding the extension's behavior. ```typescript import { commands } from 'vscode'; function showExtensionLogs() { commands.executeCommand('angular-auto-import.showLogs'); } ``` -------------------------------- ### Show Performance Metrics Command Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/CLAUDE.md Displays performance metrics for the Angular auto-import extension, providing insights into indexing times and other performance-related data. Useful for optimization and performance analysis. ```typescript import { commands } from 'vscode'; function showPerformanceMetrics() { commands.executeCommand('angular-auto-import.showPerformanceMetrics'); } ``` -------------------------------- ### Publish to Marketplace Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/CLAUDE.md Publishes the VS Code extension to the Visual Studio Code Marketplace. This command requires prior packaging and proper authentication. ```bash pnpm run vsce:publish ``` -------------------------------- ### Logging Methods Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/logger/logger-1.md Methods for logging different types of messages and exceptions. ```APIDOC ## Logging ### info() #### Description Logs an informational message. #### Method `void info(message: string, context?: Record)` #### Parameters - **message** (string) - The informational message to log. - **context** (Record, optional) - Additional context to log with the message. ### warn() #### Description Logs a warning message. #### Method `void warn(message: string, context?: Record)` #### Parameters - **message** (string) - The warning message to log. - **context** (Record, optional) - Additional context to log with the message. ### logException() #### Description Logs an exception. #### Method `void logException(error: Error, context?: Record)` #### Parameters - **error** (Error) - The error object to log. - **context** (Record, optional) - Additional context to log with the exception. ``` -------------------------------- ### Source File Indexing API Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/services/indexer.md APIs for extracting Angular elements from source files and generating project indexes. ```APIDOC ## extractElementsFromSourceFile() ### Description Extracts Angular elements (components, directives, pipes) from a given source file. ### Method (Internal Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **sourceFile** (SourceFile) - The source file object to parse. - **filePath** (string) - The path to the source file. - **content** (string) - The content of the source file. ### Request Example ```json { "sourceFile": "", "filePath": "src/app/app.component.ts", "content": "import { Component } from '@angular/core';\n@Component({...})\nexport class AppComponent { }" } ``` ### Response #### Success Response (200) - **ComponentInfo[]** - An array of objects, each containing information about an Angular element found in the file. #### Response Example ```json [ { "selector": "app-root", "type": "Component", "name": "AppComponent", "filePath": "src/app/app.component.ts" } ] ``` ``` ```APIDOC ## generateFullIndex() ### Description Generates a comprehensive index of all Angular elements within the project. ### Method Asynchronous Function ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **context** (ExtensionContext) - The VS Code extension context. - **progress** (Progress) - Optional progress callback for UI updates. ### Request Example ```json { "context": "", "progress": "" } ``` ### Response #### Success Response (200) - **Promise>** - A promise that resolves to a Map where keys are selectors and values are `AngularElementData` objects. #### Response Example ```json { "Map": [ ["app-root", {"selector": "app-root", "type": "Component", "name": "AppComponent", "filePath": "src/app/app.component.ts"}], ["[appHighlight]", {"selector": "[appHighlight]", "type": "Directive", "name": "HighlightDirective", "filePath": "src/app/highlight.directive.ts"}] ] } ``` ``` -------------------------------- ### Extension Activation and Deactivation Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/Main-extension-entry-point-for-Angular-Auto-Import.md Functions to activate and deactivate the Angular Auto Import extension, managing its lifecycle and resource cleanup. ```APIDOC ## activate() ### Description Activates the Angular Auto-Import extension. This is the main entry point called by VS Code when the extension is activated. Handles the complete initialization process including configuration loading, project discovery and setup, provider and command registration, and file system watcher setup. ### Method `activate` ### Parameters #### Path Parameters - **context** (`ExtensionContext`) - Required - The VS Code extension context providing access to extension APIs #### Returns `Promise` - Resolves when extension activation is complete. #### Throws When extension activation fails due to configuration or initialization issues. ### Request Example ```typescript // Called automatically by VS Code when extension activates await activate(context); ``` ## deactivate() ### Description Deactivates the Angular Auto-Import extension and cleans up all resources. This function is called when the extension is being disabled or VS Code is shutting down. It ensures proper cleanup of active reindexing intervals, Angular indexer instances, TypeScript configuration caches, and template detection caches. ### Method `deactivate` ### Returns `void` ### Request Example ```typescript // Called automatically by VS Code when extension deactivates deactivate(); ``` ``` -------------------------------- ### Run VS Code Extension Tests Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/CLAUDE.md Executes the test suite for the VS Code extension using the integrated testing framework. This command is crucial for ensuring the extension's stability and functionality. ```bash pnpm run test ``` -------------------------------- ### Linting and Formatting with Biome, Knip, and Types Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/CLAUDE.md Executes a comprehensive lint check, including code style enforcement (Biome), dead code detection (Knip), and type checking. This command ensures code quality and consistency. ```bash pnpm run lint ``` -------------------------------- ### TypeScript Configuration Helper Service Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/services/tsconfig.md This service handles tsconfig.json operations, including finding, parsing, and resolving import paths with alias support. ```APIDOC ## services/tsconfig ### Description TypeScript Configuration Helper Service. Responsible for handling tsconfig.json and resolving path aliases. ### Functions #### clearCache() ##### Description Clears the tsconfig and trie caches. ##### Method `void` (synchronous function call, no HTTP method applicable) ##### Parameters ###### Path Parameters None ###### Query Parameters None ###### Request Body None ###### Other Parameters - **projectRoot** (`string`) - Optional - If provided, only clears the cache for that project. ### findAndParseTsConfig(projectRoot) ##### Description Finds and parses the `tsconfig.json` or `tsconfig.base.json` file for a given project. ##### Method `Promise` (asynchronous function call, no HTTP method applicable) ##### Parameters ###### Path Parameters None ###### Query Parameters None ###### Request Body None ###### Other Parameters - **projectRoot** (`string`) - Required - The root directory of the project. ##### Returns A processed tsconfig object or `null` if not found. ### resolveImportPath(absoluteTargetModulePathNoExt, absoluteCurrentFilePath, projectRoot) ##### Description Resolves an absolute module path to an import path, using a tsconfig alias (via the Trie) or falling back to a relative path. ##### Method `Promise` (asynchronous function call, no HTTP method applicable) ##### Parameters ###### Path Parameters None ###### Query Parameters None ###### Request Body None ###### Other Parameters - **absoluteTargetModulePathNoExt** (`string`) - Required - Absolute path to the file to be imported, without extension. - **absoluteCurrentFilePath** (`string`) - Required - Absolute path to the file where the import will be added. - **projectRoot** (`string`) - Required - The root directory of the current project. ##### Returns A string for the import statement (e.g., '@app/components/my-comp' or '../../my-comp'). ``` -------------------------------- ### Internal Logging Methods Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/logger/logger-1.md Internal methods for more granular logging control. ```APIDOC ## Internal Logging ### log() #### Description Logs a message with a specific log level. #### Method `private void log(level: LogLevel, message: string, context?: Record)` #### Parameters - **level** (LogLevel) - The log level (e.g., `LogLevel.Info`, `LogLevel.Warn`). - **message** (string) - The message to log. - **context** (Record, optional) - Additional context to log with the message. ### getMetadata() #### Description Retrieves metadata for logging purposes. #### Method `private object getMetadata(isDev: boolean)` #### Parameters - **isDev** (boolean) - Flag indicating if the environment is development. #### Returns - **object** - An object containing metadata like `extensionVersion`, `nodeVersion`, `platform`, `vscodeVersion`, `sessionId`, and optionally `fileName`, `lineNumber`. ``` -------------------------------- ### CompletionProvider Class Definition (TypeScript) Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/providers/completion.md Defines the CompletionProvider class, responsible for providing autocompletion suggestions for Angular elements within a VS Code environment. It implements the CompletionItemProvider and Disposable interfaces. The constructor initializes the provider with context data. Dependencies include ProviderContext and LruCache. ```typescript class CompletionProvider implements CompletionItemProvider, Disposable { private disposables: Disposable[] = []; private standaloneCache?: LruCache; private context: ProviderContext; constructor(context: ProviderContext) { this.context = context; } } ``` -------------------------------- ### Template Detection Utilities Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/utils/template-detection.md This section details the functions for managing and querying Angular template strings within documents. ```APIDOC ## clearAllTemplateCache ### Description Clears all cached template information. This is useful for global cleanup operations. ### Method `clearAllTemplateCache()` ### Endpoint N/A (Local function call) ### Parameters None ### Request Example ```javascript clearAllTemplateCache(); ``` ### Response #### Success Response (void) This function does not return any value. #### Response Example None ``` ```APIDOC ## clearTemplateCache ### Description Clears the cache for a specific document. This is particularly useful when a document is closed or its content changes. ### Method `clearTemplateCache(documentUri)` ### Endpoint N/A (Local function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Parameters - **documentUri** (string) - Required - The URI of the document to clear from the cache. ### Request Example ```javascript clearTemplateCache('file:///path/to/your/component.ts'); ``` ### Response #### Success Response (void) This function does not return any value. #### Response Example None ``` ```APIDOC ## isInsideTemplateString ### Description Optimized function to determine if a given cursor position falls within an Angular component's template string. It utilizes regex-based parsing for enhanced performance compared to AST parsing. ### Method `isInsideTemplateString(document, position)` ### Endpoint N/A (Local function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Parameters - **document** (TextDocument) - Required - The VS Code text document object. - **position** (Position) - Required - The cursor position to check within the document. ### Request Example ```javascript // Assuming 'document' and 'position' are valid VS Code objects const insideTemplate = isInsideTemplateString(document, position); console.log(insideTemplate); // true or false ``` ### Response #### Success Response (boolean) Returns `true` if the position is within an Angular template string, otherwise returns `false`. #### Response Example ```json { "result": true } ``` ```json { "result": false } ``` ``` -------------------------------- ### CompletionProvider: convertPotentialSuggestionsToCompletionItems (TypeScript) Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/providers/completion.md This private method converts an array of potential suggestions into VS Code CompletionItem objects. It takes into account context data and a set of already seen elements to avoid duplicates and format the suggestions correctly. ```typescript private convertPotentialSuggestionsToCompletionItems(potentialSuggestions: PotentialSuggestion[], contextData: CompletionContextData, seenElements: Set): CompletionItem[] ``` -------------------------------- ### Determine Angular Project Roots Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/Main-extension-entry-point-for-Angular-Auto-Import.md Determines the root directories of Angular projects for the extension to operate on. It prioritizes configured 'projectPath' settings and falls back to workspace folders. Returns an array of project root paths. ```typescript import { determineProjectRoots, logger } from "./extension"; async function initializeExtension() { const roots = await determineProjectRoots(); logger.info('Found project roots:', roots); // Output: ['C:\workspace\my-angular-app\src'] (if projectPath configured to src/) } ``` -------------------------------- ### FileElementsInfo Interface Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/types/angular.md Information about Angular elements found in a single file. ```APIDOC ## Interface: FileElementsInfo ### Description Information about Angular elements found in a single file. ### Properties *This interface appears to be a container for multiple Angular elements within a file. Specific properties are not detailed in the provided text.* ``` -------------------------------- ### Angular Auto Import Extension API - utils/angular Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/utils/angular.md Utility functions for working with Angular elements and selectors. ```APIDOC ## createElementComparator() ### Description Comparator function for sorting Angular elements by priority. ### Method `createElementComparator` ### Parameters #### Path Parameters - `selector` (string) - Optional - The selector to match against (for PascalCase matching) ### Returns - A comparator function for use with Array.sort - Parameters: - `a` (AngularElementData) - The first element to compare. - `b` (AngularElementData) - The second element to compare. - Returns: `number` ### Example ```javascript const comparator = createElementComparator('MyComponent'); // sort elements using the comparator ``` ```APIDOC ## generateImportStatement() ### Description Generates an import statement for a given symbol and path. ### Method `generateImportStatement` ### Parameters #### Path Parameters - `name` (string) - Required - The name of the symbol to import (e.g., 'MyComponent'). - `path` (string) - Required - The path to import from (e.g., './my-component'). ### Returns - `string` - The generated import statement. ### Example ```javascript const importStatement = generateImportStatement('MyService', './services/my.service'); // importStatement will be "import { MyService } from './services/my.service';" ``` ```APIDOC ## getAngularElementAsync() ### Description Asynchronously gets the best matching Angular element for a given selector. This function uses the Angular `SelectorMatcher` for precise matching. ### Method `getAngularElementAsync` ### Parameters #### Path Parameters - `selector` (string) - Required - The selector to find the best match for. - `indexer` (AngularIndexer) - Required - An instance of the AngularIndexer to search for elements. ### Returns - `Promise` - A promise that resolves to the best matching `AngularElementData` or `undefined` if no match is found. ### Example ```javascript async function findElement(selector, indexer) { const elementData = await getAngularElementAsync(selector, indexer); if (elementData) { console.log('Found element:', elementData); } else { console.log('Element not found.'); } } ``` ```APIDOC ## getAngularElements() ### Description Retrieves Angular elements that match a given selector. ### Method `getAngularElements` ### Parameters #### Path Parameters - `selector` (string) - Required - The selector to search for. - `indexer` (AngularIndexer) - Required - An instance of the AngularIndexer to search for elements. ### Returns - `AngularElementData[]` - An array of `AngularElementData` that match the selector. ### Example ```javascript const elements = getAngularElements('app-my-component', angularIndexerInstance); console.log('Matching elements:', elements); ``` ```APIDOC ## isAngularFile() ### Description Checks if a file path corresponds to an Angular file type (component, directive, or pipe). ### Method `isAngularFile` ### Parameters #### Path Parameters - `filePath` (string) - Required - The path of the file to check. ### Returns - `boolean` - `true` if the file is an Angular file, `false` otherwise. ### Example ```javascript const isCompFile = isAngularFile('/path/to/my.component.ts'); console.log('Is Angular component file:', isCompFile); ``` ```APIDOC ## isStandalone() ### Description Checks if an Angular component, directive, or pipe class is standalone. Applies Angular v19+ default: if `standalone` flag is omitted, treats as standalone for Angular >= 19, and as non-standalone for Angular < 19. ### Method `isStandalone` ### Parameters #### Path Parameters - `classDeclaration` (ClassDeclaration) - Required - The ts-morph ClassDeclaration to check. ### Returns - `boolean` - `true` if the class is standalone, `false` otherwise. ### Example ```javascript // Assuming 'classDec' is a ts-morph ClassDeclaration const standalone = isStandalone(classDec); console.log('Is standalone:', standalone); ``` ```APIDOC ## parseAngularSelector() ### Description Parses a complex Angular selector and returns an array of individual selectors. This function uses the Angular compiler's `CssSelector.parse` for reliable parsing. ### Method `parseAngularSelector` ### Parameters #### Path Parameters - `selectorString` (string) - Required - The complex selector string to parse. ### Returns - `Promise` - A promise that resolves to an array of individual selectors. ### Example ```javascript async function getSelectors(complexSelector) { const individualSelectors = await parseAngularSelector(complexSelector); console.log('Individual selectors:', individualSelectors); } getSelectors('my-app, div[appMyDirective]'); // Output: ['my-app', 'div[appMyDirective]'] ``` -------------------------------- ### Utility Functions API Source: https://github.com/ngx-rock/vscode-angular-auto-import/blob/main/docs/services/indexer.md Internal utility functions for hashing and retrieving indexed selectors. ```APIDOC ## generateHash() ### Description Generates a unique hash for a given string content. ### Method (Internal Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **content** (string) - The string content to generate a hash for. ### Request Example ```json { "content": "import { Component } from '@angular/core';" } ``` ### Response #### Success Response (200) - **string** - The generated hash string. #### Response Example ```json { "hash": "a1b2c3d4e5f67890" } ``` ``` ```APIDOC ## getAllSelectors() ### Description Retrieves an array of all selectors that have been indexed by the extension. ### Method (Internal Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **string[]** - An array containing all indexed selectors. #### Response Example ```json { "selectors": [ "app-root", "[appHighlight]", "app-custom-pipe" ] } ``` ```