Skip to content

Commit

Permalink
[Console] Address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yuliacech committed Apr 15, 2024
1 parent e5d9229 commit 5efc013
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/kbn-monaco/src/console/console_errors_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import { ConsoleWorkerProxyService } from './console_worker_proxy';
import { CONSOLE_LANG_ID } from './constants';
import { monaco } from '../monaco_imports';

/*
* This setup function runs when the Console language is registered into the Monaco editor.
* It adds a listener that is attached to the editor input when the Monaco editor is used
* with the Console language.
* The Console parser that runs in a web worker analyzes the editor input when it changes and
* if any errors are found, they are added as "error markers" to the Monaco editor.
*/
export const setupConsoleErrorsProvider = (workerProxyService: ConsoleWorkerProxyService) => {
const updateErrorMarkers = async (model: monaco.editor.IModel): Promise<void> => {
if (model.isDisposed()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import { ConsoleWorkerProxyService } from './console_worker_proxy';
import { ParsedRequest } from './types';
import { monaco } from '../monaco_imports';

/*
* This class is a helper interface that is used in the Console plugin.
* The provider access the Console parser that runs in a web worker and analyzes the editor input
* when it changes.
* The parsed result contains the requests and errors which are used in the Console plugin.
*/
export class ConsoleParsedRequestsProvider {
constructor(
private workerProxyService: ConsoleWorkerProxyService,
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-monaco/src/console/console_worker_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import { monaco } from '../monaco_imports';
import { CONSOLE_LANG_ID } from './constants';
import { ConsoleParserResult, ConsoleWorkerDefinition } from './types';

/*
* This class contains logic to create a web worker where the code for the Console parser can
* execute without blocking the main thread. The parser only runs when the Monaco editor
* is used with the Console language. The parser can only be accessed via this proxy service class.
*/
export class ConsoleWorkerProxyService {
private worker: monaco.editor.MonacoWebWorker<ConsoleWorkerDefinition> | undefined;

Expand Down

0 comments on commit 5efc013

Please sign in to comment.