reactCompilerMonacoDiagnostics.ts — react Source File
Architecture documentation for reactCompilerMonacoDiagnostics.ts, a typescript file in the react codebase. 3 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 39c8dc04_8ac1_438b_0e3a_3111834a5732["reactCompilerMonacoDiagnostics.ts"] 614e952b_3d61_c4d4_c772_736b3ce12512["react"] 39c8dc04_8ac1_438b_0e3a_3111834a5732 --> 614e952b_3d61_c4d4_c772_736b3ce12512 33e3aca7_66ee_ce27_72ad_b6d7fb17e06c["babel-plugin-react-compiler"] 39c8dc04_8ac1_438b_0e3a_3111834a5732 --> 33e3aca7_66ee_ce27_72ad_b6d7fb17e06c be60078a_fa8c_61df_2166_fcc9d56cb30b["monaco-editor"] 39c8dc04_8ac1_438b_0e3a_3111834a5732 --> be60078a_fa8c_61df_2166_fcc9d56cb30b e75ba65e_505f_abf4_2928_6f0aefb2fc72["Input.tsx"] e75ba65e_505f_abf4_2928_6f0aefb2fc72 --> 39c8dc04_8ac1_438b_0e3a_3111834a5732 style 39c8dc04_8ac1_438b_0e3a_3111834a5732 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 {Monaco} from '@monaco-editor/react';
import {
CompilerDiagnostic,
CompilerErrorDetail,
ErrorSeverity,
} from 'babel-plugin-react-compiler';
import {MarkerSeverity, type editor} from 'monaco-editor';
function mapReactCompilerSeverityToMonaco(
level: ErrorSeverity,
monaco: Monaco,
): MarkerSeverity {
switch (level) {
case ErrorSeverity.Todo:
return monaco.MarkerSeverity.Warning;
default:
return monaco.MarkerSeverity.Error;
}
}
function mapReactCompilerDiagnosticToMonacoMarker(
detail: CompilerErrorDetail | CompilerDiagnostic,
monaco: Monaco,
source: string,
): editor.IMarkerData | null {
const loc = detail.primaryLocation();
if (loc == null || typeof loc === 'symbol') {
return null;
}
const severity = mapReactCompilerSeverityToMonaco(detail.severity, monaco);
let message = detail.printErrorMessage(source, {eslint: true});
return {
severity,
message,
startLineNumber: loc.start.line,
startColumn: loc.start.column + 1,
endLineNumber: loc.end.line,
endColumn: loc.end.column + 1,
};
}
type ReactCompilerMarkerConfig = {
monaco: Monaco;
model: editor.ITextModel;
details: Array<CompilerErrorDetail | CompilerDiagnostic>;
source: string;
};
let decorations: Array<string> = [];
export function renderReactCompilerMarkers({
monaco,
model,
details,
source,
}: ReactCompilerMarkerConfig): void {
const markers: Array<editor.IMarkerData> = [];
for (const detail of details) {
const marker = mapReactCompilerDiagnosticToMonacoMarker(
detail,
monaco,
source,
);
if (marker == null) {
continue;
}
markers.push(marker);
}
if (markers.length > 0) {
monaco.editor.setModelMarkers(model, 'owner', markers);
const newDecorations = markers.map(marker => {
return {
range: new monaco.Range(
marker.startLineNumber,
marker.startColumn,
marker.endLineNumber,
marker.endColumn,
),
options: {
isWholeLine: true,
glyphMarginClassName: 'bg-red-300',
},
};
});
decorations = model.deltaDecorations(decorations, newDecorations);
} else {
monaco.editor.setModelMarkers(model, 'owner', []);
decorations = model.deltaDecorations(
model.getAllDecorations().map(d => d.id),
[],
);
}
}
Domain
Subdomains
Functions
Dependencies
- babel-plugin-react-compiler
- monaco-editor
- react
Source
Frequently Asked Questions
What does reactCompilerMonacoDiagnostics.ts do?
reactCompilerMonacoDiagnostics.ts is a source file in the react codebase, written in typescript. It belongs to the PlaygroundApp domain, Stores subdomain.
What functions are defined in reactCompilerMonacoDiagnostics.ts?
reactCompilerMonacoDiagnostics.ts defines 3 function(s): mapReactCompilerDiagnosticToMonacoMarker, mapReactCompilerSeverityToMonaco, renderReactCompilerMarkers.
What does reactCompilerMonacoDiagnostics.ts depend on?
reactCompilerMonacoDiagnostics.ts imports 3 module(s): babel-plugin-react-compiler, monaco-editor, react.
What files import reactCompilerMonacoDiagnostics.ts?
reactCompilerMonacoDiagnostics.ts is imported by 1 file(s): Input.tsx.
Where is reactCompilerMonacoDiagnostics.ts in the architecture?
reactCompilerMonacoDiagnostics.ts is located at compiler/apps/playground/lib/reactCompilerMonacoDiagnostics.ts (domain: PlaygroundApp, subdomain: Stores, directory: compiler/apps/playground/lib).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free