Skip to content

Commit

Permalink
Improve Display of Log Point Suggestions (#103)
Browse files Browse the repository at this point in the history
- The icon for recommended/enabled operator log points is displayed at the very beginning of the line of the respective operator. This icon knows three states:
   - Log point recommended (gray outline)
   - Log point enabled (filled red)
   - Some log points enabled (filled gray; in case of multiple log points on one line, but not all of them enabled)
- Try out: The log point indicator icon resembles a miniature version of Archie
- Managing operator log points still works via the hover message of the actual operator

Closes #64
  • Loading branch information
swissmanu committed Nov 7, 2021
1 parent 62ccc0e commit 2da72e2
Show file tree
Hide file tree
Showing 39 changed files with 1,009 additions and 444 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",

"jest.disabledWorkspaceFolders": ["packages/extension-integrationtest"]
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Before you submit a pull request, please discuss potential changes with the main
To get started with development, follow these four steps:

1. Clone the repo and run `yarn` to install all dependencies.
2. Open the repo in Visual Studio Code.
2. Open `workspace.code-workspace` with Visual Studio Code.
3. Run the "extension: Build and Watch" task, which will continuously (re-)build the extension.
4. Run the "Testbench: NodeJS" launch configuration to open a new Visual Studio Code window, which:
- loads the RxJS debugging extension in development mode, so you can use the debugger in the original Visual Studio Code window.
Expand Down
28 changes: 21 additions & 7 deletions packages/extension-integrationtest/src/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Commands, executeCommand, TestCommands } from 'rxjs-debugging-for-vs-code/out/integrationTest';
import {
Commands,
executeCommand,
TestCommands,
OperatorLogPoint,
} from 'rxjs-debugging-for-vs-code/out/integrationTest';
import * as vscode from 'vscode';
import openAndShowTextDocument from './util/openAndShowTextDocument';
import waitForExtension from './util/waitForExtension';
Expand All @@ -9,12 +14,21 @@ describe('RxJS Debugging for vscode', () => {
await waitForExtension();

// Enable Operator Log Point for the first operator, take.
await executeCommand(vscode.commands, Commands.EnableOperatorLogPoint, document.uri, new vscode.Position(5, 4), {
fileName: document.uri.fsPath,
line: 5,
character: 25,
operatorIndex: 0,
});
await executeCommand(
vscode.commands,
Commands.EnableOperatorLogPoint,
new OperatorLogPoint(
document.uri,
new vscode.Position(5, 4),
{
fileName: document.uri.fsPath,
line: 5,
character: 25,
operatorIndex: 0,
},
'take'
)
);

const debuggingDone = new Promise<void>((resolve) => {
vscode.debug.onDidTerminateDebugSession(() => resolve());
Expand Down
11 changes: 6 additions & 5 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
"commands": [
{
"category": "RxJS",
"command": "rxjs-debugging-for-vs-code.command.toggleOperatorLogPointRecommendations",
"title": "%rxjs-debugging.command.toggleOperatorLogPointRecommendations%"
"command": "rxjs-debugging-for-vs-code.command.toggleOperatorLogPointGutterIcon",
"title": "%rxjs-debugging.command.toggleOperatorLogPointGutterIcon%"
}
],
"configuration": {
"title": "%rxjs-debugging.config.title%",
"properties": {
"debug.rxjs.showOperatorLogPointRecommendations": {
"description": "%rxjs-debugging.config.showOperatorLogPointRecommendations%",
"debug.rxjs.recommendOperatorLogPointsWithAnIcon": {
"description": "%rxjs-debugging.config.recommendOperatorLogPointsWithAnIcon%",
"type": "boolean",
"default": true
},
Expand Down Expand Up @@ -97,9 +97,9 @@
"@types/webpack": "5.28.0",
"@types/ws": "8.2.0",
"jest": "27.3.1",
"rollup": "2.59.0",
"rollup-plugin-copy": "3.4.0",
"rollup-plugin-terser": "7.0.2",
"rollup": "2.59.0",
"ts-jest": "27.0.7",
"tslib": "2.3.1",
"typescript": "4.4.4",
Expand All @@ -111,6 +111,7 @@
"@rxjs-debugging/telemetry": "0.0.0",
"inversify": "5.1.1",
"reflect-metadata": "0.1.13",
"spicery": "2.1.2",
"typescript": "4.4.4",
"vscode-nls": "5.0.0",
"ws": "8.2.3"
Expand Down
5 changes: 3 additions & 2 deletions packages/extension/package.nls.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"rxjs-debugging.config.title": "RxJS Debugging",
"rxjs-debugging.config.hideLiveLogWhenStoppingDebugger": "When enabled, live log values are hidden automatically after stopping the debugger.",
"rxjs-debugging.config.showOperatorLogPointRecommendations": "When enabled, recommended operator log points will be shown automatically. Hint: You can toggle this setting using the related command in the command palette as well.",
"rxjs-debugging.config.recommendOperatorLogPointsWithAnIcon": "When enabled, recommended operator log points will be indicated using an icon at the beginning of the line. Hint: You can toggle this setting using the related command in the command palette as well.",
"rxjs-debugging.config.logLevel": "Internal log level for the extension. (reload required)",
"rxjs-debugging.command.toggleOperatorLogPointRecommendations": "Toggle Display of Operator Log Point Recommendations"

"rxjs-debugging.command.toggleOperatorLogPointGutterIcon": "Toggle gutter icon for recommended operator log points"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions packages/extension/resources/rxjs-operator-log-point-disabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 37 additions & 7 deletions packages/extension/src/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,31 @@ export class Disposable {

export class Uri implements UriType {
static parse(value: string, strict?: boolean): Uri {
return new Uri('', '', '', '', '');
return new Uri('', '', value, '', '');
}

static file(path: string): Uri {
return new Uri('', '', '', '', '');
return new Uri('', '', path, '', '');
}

static joinPath(base: Uri, ...pathSegments: string[]): Uri {
return new Uri('', '', '', '', '');
}

static from(components: {
static from({
scheme,
authority = '',
path = '',
query = '',
fragment = '',
}: {
scheme: string;
authority?: string;
path?: string;
query?: string;
fragment?: string;
}): Uri {
return new Uri('', '', '', '', '');
return new Uri(scheme, authority, path, query, fragment);
}

private constructor(
Expand All @@ -100,15 +106,39 @@ export class Uri implements UriType {

readonly fsPath: string = '';

with(change: { scheme?: string; authority?: string; path?: string; query?: string; fragment?: string }): Uri {
return this;
with({
scheme,
authority,
path,
query,
fragment,
}: {
scheme?: string;
authority?: string;
path?: string;
query?: string;
fragment?: string;
}): Uri {
return new Uri(
scheme || this.scheme,
authority || this.authority,
path || this.path,
query || this.query,
fragment || this.fragment
);
}

toString(skipEncoding?: boolean): string {
return '';
}

toJSON(): any {
return {};
return {
scheme: this.scheme,
authority: this.authority,
path: this.path,
query: this.query,
fragment: this.fragment,
};
}
}
11 changes: 5 additions & 6 deletions packages/extension/src/commands/commands.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { IOperatorIdentifier } from '@rxjs-debugging/telemetry/out/operatorIdentifier';
import { Position, Uri } from 'vscode';
import OperatorLogPoint from '../operatorLogPoint';

export const enum Commands {
EnableOperatorLogPoint = 'rxjs-debugging-for-vs-code.command.enableOperatorLogPoint',
DisableOperatorLogPoint = 'rxjs-debugging-for-vs-code.command.disableOperatorLogPoint',
ToggleOperatorLogPointRecommendations = 'rxjs-debugging-for-vs-code.command.toggleOperatorLogPointRecommendations',
ToggleOperatorLogPointGutterIcon = 'rxjs-debugging-for-vs-code.command.toggleOperatorLogPointGutterIcon',
}

export interface ICommandTypes {
[Commands.EnableOperatorLogPoint]: (uri: Uri, position: Position, operatorIdentifier: IOperatorIdentifier) => void;
[Commands.DisableOperatorLogPoint]: (uri: Uri, position: Position, operatorIdentifier: IOperatorIdentifier) => void;
[Commands.ToggleOperatorLogPointRecommendations]: () => void;
[Commands.EnableOperatorLogPoint]: (operatorLogPoint: OperatorLogPoint | string) => void;
[Commands.DisableOperatorLogPoint]: (operatorLogPoint: OperatorLogPoint | string) => void;
[Commands.ToggleOperatorLogPointGutterIcon]: () => void;
}
5 changes: 3 additions & 2 deletions packages/extension/src/commands/getMarkdownCommandWithArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { ICommandTypes } from './commands';

export default function getMarkdownCommandWithArgs<K extends keyof ICommandTypes>(
key: K,
args: Parameters<ICommandTypes[K]>
args: Parameters<ICommandTypes[K]>,
serialize: (args: Parameters<ICommandTypes[K]>) => [string] = (args) => [JSON.stringify(args)]
): string {
return `command:${key}?${encodeURIComponent(JSON.stringify(args))}`;
return `command:${key}?${encodeURIComponent(JSON.stringify(serialize(args)))}`;
}
Loading

0 comments on commit 2da72e2

Please sign in to comment.