brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 7119cba Raw
78 lines · typescript
1import * as path from "path";2import * as vscode from "vscode";3 4import { LLDBDapDescriptorFactory } from "./debug-adapter-factory";5import { DisposableContext } from "./disposable-context";6import { LaunchUriHandler } from "./uri-launch-handler";7import { LLDBDapConfigurationProvider } from "./debug-configuration-provider";8import { LLDBDapServer } from "./lldb-dap-server";9import { DebugSessionTracker } from "./debug-session-tracker";10import {11  ModulesDataProvider,12  ModuleProperty,13} from "./ui/modules-data-provider";14import { LogFilePathProvider } from "./logging";15import { SymbolsProvider } from "./ui/symbols-provider";16 17/**18 * This class represents the extension and manages its life cycle. Other extensions19 * using it as as library should use this class as the main entry point.20 */21export class LLDBDapExtension extends DisposableContext {22  constructor(23    context: vscode.ExtensionContext,24    logger: vscode.LogOutputChannel,25    logFilePath: LogFilePathProvider,26    outputChannel: vscode.OutputChannel,27  ) {28    super();29 30    const lldbDapServer = new LLDBDapServer();31    const sessionTracker = new DebugSessionTracker(logger);32 33    this.pushSubscription(34      logger,35      outputChannel,36      lldbDapServer,37      sessionTracker,38      vscode.debug.registerDebugConfigurationProvider(39        "lldb-dap",40        new LLDBDapConfigurationProvider(lldbDapServer, logger, logFilePath),41      ),42      vscode.debug.registerDebugAdapterDescriptorFactory(43        "lldb-dap",44        new LLDBDapDescriptorFactory(logger, logFilePath),45      ),46      vscode.debug.registerDebugAdapterTrackerFactory(47        "lldb-dap",48        sessionTracker,49      ),50      vscode.window.registerTreeDataProvider(51        "lldb-dap.modules",52        new ModulesDataProvider(sessionTracker),53      ),54      vscode.window.registerUriHandler(new LaunchUriHandler()),55    );56 57    this.pushSubscription(vscode.commands.registerCommand(58      "lldb-dap.modules.copyProperty",59      (node: ModuleProperty) => vscode.env.clipboard.writeText(node.value),60    ));61 62    this.pushSubscription(new SymbolsProvider(sessionTracker, context));63  }64}65 66/**67 * This is the entry point when initialized by VS Code.68 */69export async function activate(context: vscode.ExtensionContext) {70  const outputChannel = vscode.window.createOutputChannel("LLDB-DAP", { log: true });71  outputChannel.info("LLDB-DAP extension activating...");72  const logFilePath = new LogFilePathProvider(context, outputChannel);73  context.subscriptions.push(74    new LLDBDapExtension(context, outputChannel, logFilePath, outputChannel),75  );76  outputChannel.info("LLDB-DAP extension activated");77}78