autodeps.ts — react Source File
Architecture documentation for autodeps.ts, a typescript file in the react codebase. 5 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR fab4dac4_b1d2_9219_5b57_865f42c56191["autodeps.ts"] eb31addc_e8f2_e650_2d2e_73b1e6707d3b["mapping.ts"] fab4dac4_b1d2_9219_5b57_865f42c56191 --> eb31addc_e8f2_e650_2d2e_73b1e6707d3b 8b03c84d_93d1_8f5d_1738_d4c92b683f01["positionLiteralToVSCodePosition"] fab4dac4_b1d2_9219_5b57_865f42c56191 --> 8b03c84d_93d1_8f5d_1738_d4c92b683f01 019d81e6_8b49_263c_d537_63ee2b44c137["positionsToRange"] fab4dac4_b1d2_9219_5b57_865f42c56191 --> 019d81e6_8b49_263c_d537_63ee2b44c137 7b0819cb_de77_6f97_9611_4fdd26c462b2["vscode"] fab4dac4_b1d2_9219_5b57_865f42c56191 --> 7b0819cb_de77_6f97_9611_4fdd26c462b2 9c9d6ec0_3169_dadc_b536_71d91f7cda8b["node"] fab4dac4_b1d2_9219_5b57_865f42c56191 --> 9c9d6ec0_3169_dadc_b536_71d91f7cda8b f813a254_53b8_e2e6_c027_4a274369335d["extension.ts"] f813a254_53b8_e2e6_c027_4a274369335d --> fab4dac4_b1d2_9219_5b57_865f42c56191 style fab4dac4_b1d2_9219_5b57_865f42c56191 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 vscode from 'vscode';
import {
LanguageClient,
RequestType,
type Position,
} from 'vscode-languageclient/node';
import {positionLiteralToVSCodePosition, positionsToRange} from './mapping';
export type AutoDepsDecorationsLSPEvent = {
useEffectCallExpr: [Position, Position];
decorations: Array<[Position, Position]>;
};
export interface AutoDepsDecorationsParams {
position: Position;
}
export namespace AutoDepsDecorationsRequest {
export const type = new RequestType<
AutoDepsDecorationsParams,
AutoDepsDecorationsLSPEvent | null,
void
>('react/autodeps_decorations');
}
const inferredEffectDepDecoration =
vscode.window.createTextEditorDecorationType({
// TODO: make configurable?
borderColor: new vscode.ThemeColor('diffEditor.move.border'),
borderStyle: 'solid',
borderWidth: '0 0 4px 0',
});
let currentlyDecoratedAutoDepFnLoc: vscode.Range | null = null;
export function getCurrentlyDecoratedAutoDepFnLoc(): vscode.Range | null {
return currentlyDecoratedAutoDepFnLoc;
}
export function setCurrentlyDecoratedAutoDepFnLoc(range: vscode.Range): void {
currentlyDecoratedAutoDepFnLoc = range;
}
export function clearCurrentlyDecoratedAutoDepFnLoc(): void {
currentlyDecoratedAutoDepFnLoc = null;
}
let decorationRequestId = 0;
export type AutoDepsDecorationsOptions = {
shouldUpdateCurrent: boolean;
};
export function requestAutoDepsDecorations(
client: LanguageClient,
position: vscode.Position,
options: AutoDepsDecorationsOptions,
) {
const id = ++decorationRequestId;
client
.sendRequest(AutoDepsDecorationsRequest.type, {position})
.then(response => {
if (response !== null) {
const {
decorations,
useEffectCallExpr: [start, end],
} = response;
// Maintain ordering
if (decorationRequestId === id) {
if (options.shouldUpdateCurrent) {
setCurrentlyDecoratedAutoDepFnLoc(positionsToRange(start, end));
}
drawInferredEffectDepDecorations(decorations);
}
} else {
clearCurrentlyDecoratedAutoDepFnLoc();
clearDecorations(inferredEffectDepDecoration);
}
});
}
export function drawInferredEffectDepDecorations(
decorations: Array<[Position, Position]>,
): void {
const decorationOptions = decorations.map(([start, end]) => {
return {
range: new vscode.Range(
positionLiteralToVSCodePosition(start),
positionLiteralToVSCodePosition(end),
),
hoverMessage: 'Inferred as an effect dependency',
};
});
vscode.window.activeTextEditor?.setDecorations(
inferredEffectDepDecoration,
decorationOptions,
);
}
export function clearDecorations(
decorationType: vscode.TextEditorDecorationType,
) {
vscode.window.activeTextEditor?.setDecorations(decorationType, []);
}
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does autodeps.ts do?
autodeps.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 autodeps.ts?
autodeps.ts defines 6 function(s): clearCurrentlyDecoratedAutoDepFnLoc, clearDecorations, drawInferredEffectDepDecorations, getCurrentlyDecoratedAutoDepFnLoc, requestAutoDepsDecorations, setCurrentlyDecoratedAutoDepFnLoc.
What does autodeps.ts depend on?
autodeps.ts imports 5 module(s): mapping.ts, node, positionLiteralToVSCodePosition, positionsToRange, vscode.
What files import autodeps.ts?
autodeps.ts is imported by 1 file(s): extension.ts.
Where is autodeps.ts in the architecture?
autodeps.ts is located at compiler/packages/react-forgive/client/src/autodeps.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