Home / File/ extension.ts — react Source File

extension.ts — react Source File

Architecture documentation for extension.ts, a typescript file in the react codebase. 8 imports, 0 dependents.

File typescript BabelCompiler Validation 8 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  f813a254_53b8_e2e6_c027_4a274369335d["extension.ts"]
  eb31addc_e8f2_e650_2d2e_73b1e6707d3b["mapping.ts"]
  f813a254_53b8_e2e6_c027_4a274369335d --> eb31addc_e8f2_e650_2d2e_73b1e6707d3b
  8b03c84d_93d1_8f5d_1738_d4c92b683f01["positionLiteralToVSCodePosition"]
  f813a254_53b8_e2e6_c027_4a274369335d --> 8b03c84d_93d1_8f5d_1738_d4c92b683f01
  fab4dac4_b1d2_9219_5b57_865f42c56191["autodeps.ts"]
  f813a254_53b8_e2e6_c027_4a274369335d --> fab4dac4_b1d2_9219_5b57_865f42c56191
  9984b01f_cbfd_cf9b_3f19_3fdcd7f3fdb6["getCurrentlyDecoratedAutoDepFnLoc"]
  f813a254_53b8_e2e6_c027_4a274369335d --> 9984b01f_cbfd_cf9b_3f19_3fdcd7f3fdb6
  53a1361f_1c97_6de1_db62_3c0cc543d4ec["requestAutoDepsDecorations"]
  f813a254_53b8_e2e6_c027_4a274369335d --> 53a1361f_1c97_6de1_db62_3c0cc543d4ec
  b402a0fc_00db_e86d_b1ea_ad4f8e9faaca["path"]
  f813a254_53b8_e2e6_c027_4a274369335d --> b402a0fc_00db_e86d_b1ea_ad4f8e9faaca
  7b0819cb_de77_6f97_9611_4fdd26c462b2["vscode"]
  f813a254_53b8_e2e6_c027_4a274369335d --> 7b0819cb_de77_6f97_9611_4fdd26c462b2
  9c9d6ec0_3169_dadc_b536_71d91f7cda8b["node"]
  f813a254_53b8_e2e6_c027_4a274369335d --> 9c9d6ec0_3169_dadc_b536_71d91f7cda8b
  style f813a254_53b8_e2e6_c027_4a274369335d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import * as path from 'path';
import * as vscode from 'vscode';

import {
  LanguageClient,
  LanguageClientOptions,
  type Position,
  ServerOptions,
  TransportKind,
} from 'vscode-languageclient/node';
import {positionLiteralToVSCodePosition} from './mapping';
import {
  getCurrentlyDecoratedAutoDepFnLoc,
  requestAutoDepsDecorations,
} from './autodeps';

let client: LanguageClient;

export function activate(context: vscode.ExtensionContext) {
  const serverModule = context.asAbsolutePath(path.join('dist', 'server.js'));
  const documentSelector = [
    {scheme: 'file', language: 'javascriptreact'},
    {scheme: 'file', language: 'typescriptreact'},
  ];

  // If the extension is launched in debug mode then the debug server options are used
  // Otherwise the run options are used
  const serverOptions: ServerOptions = {
    run: {
      module: serverModule,
      transport: TransportKind.ipc,
    },
    debug: {
      module: serverModule,
      transport: TransportKind.ipc,
    },
  };

  const clientOptions: LanguageClientOptions = {
    documentSelector,
    progressOnInitialization: true,
  };

  // Create the language client and start the client.
  try {
    client = new LanguageClient(
      'react-forgive',
      'React Analyzer',
      serverOptions,
      clientOptions,
    );
  } catch {
    vscode.window.showErrorMessage(
      `React Analyzer couldn't be started. See the output channel for details.`,
    );
    return;
  }

  vscode.languages.registerHoverProvider(documentSelector, {
    provideHover(_document, position, _token) {
      requestAutoDepsDecorations(client, position, {shouldUpdateCurrent: true});
      return null;
    },
  });

  vscode.workspace.onDidChangeTextDocument(async _e => {
    const currentlyDecoratedAutoDepFnLoc = getCurrentlyDecoratedAutoDepFnLoc();
    if (currentlyDecoratedAutoDepFnLoc !== null) {
      requestAutoDepsDecorations(client, currentlyDecoratedAutoDepFnLoc.start, {
        shouldUpdateCurrent: false,
      });
    }
  });

  vscode.commands.registerCommand(
    'react.requestAutoDepsDecorations',
    (position: Position) => {
      requestAutoDepsDecorations(
        client,
        positionLiteralToVSCodePosition(position),
        {shouldUpdateCurrent: true},
      );
    },
  );

  client.registerProposedFeatures();
  client.start();
}

export function deactivate(): Thenable<void> | undefined {
  if (client !== undefined) {
    return client.stop();
  }
  return;
}

Domain

Subdomains

Frequently Asked Questions

What does extension.ts do?
extension.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in extension.ts?
extension.ts defines 2 function(s): activate, deactivate.
What does extension.ts depend on?
extension.ts imports 8 module(s): autodeps.ts, getCurrentlyDecoratedAutoDepFnLoc, mapping.ts, node, path, positionLiteralToVSCodePosition, requestAutoDepsDecorations, vscode.
Where is extension.ts in the architecture?
extension.ts is located at compiler/packages/react-forgive/client/src/extension.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/react-forgive/client/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free