Skip to content

Commit d9d9169

Browse files
brettfocolombod
authored andcommitted
add embeddedLanguages to grammars
1 parent a5105d3 commit d9d9169

File tree

6 files changed

+367
-182
lines changed

6 files changed

+367
-182
lines changed

src/dotnet-interactive-npm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444
"node-fetch": "^2.6.1",
4545
"uuid": "^8.3.2"
4646
}
47-
}
47+
}

src/dotnet-interactive-vscode/common/vscode/notebookContentProvider.ts

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export class DotNetInteractiveNotebookContentProvider implements vscode.Notebook
7272
return notebookData;
7373
}
7474

75+
// soon to be removed; already exists in kernel provider
7576
async resolveNotebook(document: vscode.NotebookDocument, webview: vscode.NotebookCommunication): Promise<void> {
7677
configureWebViewMessaging(webview, document.uri, this.clientMapper);
7778
}

src/dotnet-interactive-vscode/insiders/package.json

+92-11
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
},
113113
"dotnet-interactive.minimumInteractiveToolVersion": {
114114
"type": "string",
115-
"default": "1.0.215801",
115+
"default": "1.0.216815",
116116
"description": "The minimum required version of the .NET Interactive tool."
117117
},
118118
"dotnet-interactive.useDotNetInteractiveExtensionForIpynbFiles": {
@@ -225,47 +225,128 @@
225225
{
226226
"language": "dotnet-interactive",
227227
"scopeName": "source.dotnet-interactive",
228-
"path": "./syntaxes/source.dotnet-interactive.tmGrammar.json"
228+
"path": "./syntaxes/source.dotnet-interactive.tmGrammar.json",
229+
"embeddedLanguages": {
230+
"language.switch.csharp": "dotnet-interactive.csharp",
231+
"language.switch.fsharp": "dotnet-interactive.fsharp",
232+
"language.switch.html": "dotnet-interactive.html",
233+
"language.switch.javascript": "dotnet-interactive.javascript",
234+
"language.switch.markdown": "dotnet-interactive.markdown",
235+
"language.switch.powershell": "dotnet-interactive.pwsh",
236+
"language.switch.sql": "dotnet-interactive.sql"
237+
}
229238
},
230239
{
231240
"language": "dotnet-interactive.csharp",
232241
"scopeName": "source.dotnet-interactive.csharp",
233-
"path": "./syntaxes/source.dotnet-interactive.csharp.tmGrammar.json"
242+
"path": "./syntaxes/source.dotnet-interactive.csharp.tmGrammar.json",
243+
"embeddedLanguages": {
244+
"language.switch.csharp": "dotnet-interactive.csharp",
245+
"language.switch.fsharp": "dotnet-interactive.fsharp",
246+
"language.switch.html": "dotnet-interactive.html",
247+
"language.switch.javascript": "dotnet-interactive.javascript",
248+
"language.switch.markdown": "dotnet-interactive.markdown",
249+
"language.switch.powershell": "dotnet-interactive.pwsh",
250+
"language.switch.sql": "dotnet-interactive.sql"
251+
}
234252
},
235253
{
236254
"language": "dotnet-interactive.fsharp",
237255
"scopeName": "source.dotnet-interactive.fsharp",
238-
"path": "./syntaxes/source.dotnet-interactive.fsharp.tmGrammar.json"
256+
"path": "./syntaxes/source.dotnet-interactive.fsharp.tmGrammar.json",
257+
"embeddedLanguages": {
258+
"language.switch.csharp": "dotnet-interactive.csharp",
259+
"language.switch.fsharp": "dotnet-interactive.fsharp",
260+
"language.switch.html": "dotnet-interactive.html",
261+
"language.switch.javascript": "dotnet-interactive.javascript",
262+
"language.switch.markdown": "dotnet-interactive.markdown",
263+
"language.switch.powershell": "dotnet-interactive.pwsh",
264+
"language.switch.sql": "dotnet-interactive.sql"
265+
}
239266
},
240267
{
241268
"language": "dotnet-interactive.html",
242269
"scopeName": "source.dotnet-interactive.html",
243-
"path": "./syntaxes/source.dotnet-interactive.html.tmGrammar.json"
270+
"path": "./syntaxes/source.dotnet-interactive.html.tmGrammar.json",
271+
"embeddedLanguages": {
272+
"language.switch.csharp": "dotnet-interactive.csharp",
273+
"language.switch.fsharp": "dotnet-interactive.fsharp",
274+
"language.switch.html": "dotnet-interactive.html",
275+
"language.switch.javascript": "dotnet-interactive.javascript",
276+
"language.switch.markdown": "dotnet-interactive.markdown",
277+
"language.switch.powershell": "dotnet-interactive.pwsh",
278+
"language.switch.sql": "dotnet-interactive.sql"
279+
}
244280
},
245281
{
246282
"language": "dotnet-interactive.javascript",
247283
"scopeName": "source.dotnet-interactive.javascript",
248-
"path": "./syntaxes/source.dotnet-interactive.javascript.tmGrammar.json"
284+
"path": "./syntaxes/source.dotnet-interactive.javascript.tmGrammar.json",
285+
"embeddedLanguages": {
286+
"language.switch.csharp": "dotnet-interactive.csharp",
287+
"language.switch.fsharp": "dotnet-interactive.fsharp",
288+
"language.switch.html": "dotnet-interactive.html",
289+
"language.switch.javascript": "dotnet-interactive.javascript",
290+
"language.switch.markdown": "dotnet-interactive.markdown",
291+
"language.switch.powershell": "dotnet-interactive.pwsh",
292+
"language.switch.sql": "dotnet-interactive.sql"
293+
}
249294
},
250295
{
251296
"language": "dotnet-interactive.magic-commands",
252297
"scopeName": "source.dotnet-interactive.magic-commands",
253-
"path": "./syntaxes/source.dotnet-interactive.magic-commands.tmGrammar.json"
298+
"path": "./syntaxes/source.dotnet-interactive.magic-commands.tmGrammar.json",
299+
"embeddedLanguages": {
300+
"language.switch.csharp": "dotnet-interactive.csharp",
301+
"language.switch.fsharp": "dotnet-interactive.fsharp",
302+
"language.switch.html": "dotnet-interactive.html",
303+
"language.switch.javascript": "dotnet-interactive.javascript",
304+
"language.switch.markdown": "dotnet-interactive.markdown",
305+
"language.switch.powershell": "dotnet-interactive.pwsh",
306+
"language.switch.sql": "dotnet-interactive.sql"
307+
}
254308
},
255309
{
256310
"language": "dotnet-interactive.markdown",
257311
"scopeName": "source.dotnet-interactive.markdown",
258-
"path": "./syntaxes/source.dotnet-interactive.markdown.tmGrammar.json"
312+
"path": "./syntaxes/source.dotnet-interactive.markdown.tmGrammar.json",
313+
"embeddedLanguages": {
314+
"language.switch.csharp": "dotnet-interactive.csharp",
315+
"language.switch.fsharp": "dotnet-interactive.fsharp",
316+
"language.switch.html": "dotnet-interactive.html",
317+
"language.switch.javascript": "dotnet-interactive.javascript",
318+
"language.switch.markdown": "dotnet-interactive.markdown",
319+
"language.switch.powershell": "dotnet-interactive.pwsh",
320+
"language.switch.sql": "dotnet-interactive.sql"
321+
}
259322
},
260323
{
261324
"language": "dotnet-interactive.pwsh",
262325
"scopeName": "source.dotnet-interactive.powershell",
263-
"path": "./syntaxes/source.dotnet-interactive.powershell.tmGrammar.json"
326+
"path": "./syntaxes/source.dotnet-interactive.powershell.tmGrammar.json",
327+
"embeddedLanguages": {
328+
"language.switch.csharp": "dotnet-interactive.csharp",
329+
"language.switch.fsharp": "dotnet-interactive.fsharp",
330+
"language.switch.html": "dotnet-interactive.html",
331+
"language.switch.javascript": "dotnet-interactive.javascript",
332+
"language.switch.markdown": "dotnet-interactive.markdown",
333+
"language.switch.powershell": "dotnet-interactive.pwsh",
334+
"language.switch.sql": "dotnet-interactive.sql"
335+
}
264336
},
265337
{
266338
"language": "dotnet-interactive.sql",
267339
"scopeName": "source.dotnet-interactive.sql",
268-
"path": "./syntaxes/source.dotnet-interactive.sql.tmGrammar.json"
340+
"path": "./syntaxes/source.dotnet-interactive.sql.tmGrammar.json",
341+
"embeddedLanguages": {
342+
"language.switch.csharp": "dotnet-interactive.csharp",
343+
"language.switch.fsharp": "dotnet-interactive.fsharp",
344+
"language.switch.html": "dotnet-interactive.html",
345+
"language.switch.javascript": "dotnet-interactive.javascript",
346+
"language.switch.markdown": "dotnet-interactive.markdown",
347+
"language.switch.powershell": "dotnet-interactive.pwsh",
348+
"language.switch.sql": "dotnet-interactive.sql"
349+
}
269350
}
270351
]
271352
},
@@ -314,4 +395,4 @@
314395
"node-fetch": "^2.6.1",
315396
"uuid": "^8.3.2"
316397
}
317-
}
398+
}

src/dotnet-interactive-vscode/insiders/src/vscode.d.ts

+144-1
Original file line numberDiff line numberDiff line change
@@ -2668,6 +2668,134 @@ declare module 'vscode' {
26682668
provideEvaluatableExpression(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<EvaluatableExpression>;
26692669
}
26702670

2671+
/**
2672+
* Provide inline value as text.
2673+
*/
2674+
export class InlineValueText {
2675+
/**
2676+
* The document range for which the inline value applies.
2677+
*/
2678+
readonly range: Range;
2679+
/**
2680+
* The text of the inline value.
2681+
*/
2682+
readonly text: string;
2683+
/**
2684+
* Creates a new InlineValueText object.
2685+
*
2686+
* @param range The document line where to show the inline value.
2687+
* @param text The value to be shown for the line.
2688+
*/
2689+
constructor(range: Range, text: string);
2690+
}
2691+
2692+
/**
2693+
* Provide inline value through a variable lookup.
2694+
* If only a range is specified, the variable name will be extracted from the underlying document.
2695+
* An optional variable name can be used to override the extracted name.
2696+
*/
2697+
export class InlineValueVariableLookup {
2698+
/**
2699+
* The document range for which the inline value applies.
2700+
* The range is used to extract the variable name from the underlying document.
2701+
*/
2702+
readonly range: Range;
2703+
/**
2704+
* If specified the name of the variable to look up.
2705+
*/
2706+
readonly variableName?: string;
2707+
/**
2708+
* How to perform the lookup.
2709+
*/
2710+
readonly caseSensitiveLookup: boolean;
2711+
/**
2712+
* Creates a new InlineValueVariableLookup object.
2713+
*
2714+
* @param range The document line where to show the inline value.
2715+
* @param variableName The name of the variable to look up.
2716+
* @param caseSensitiveLookup How to perform the lookup. If missing lookup is case sensitive.
2717+
*/
2718+
constructor(range: Range, variableName?: string, caseSensitiveLookup?: boolean);
2719+
}
2720+
2721+
/**
2722+
* Provide an inline value through an expression evaluation.
2723+
* If only a range is specified, the expression will be extracted from the underlying document.
2724+
* An optional expression can be used to override the extracted expression.
2725+
*/
2726+
export class InlineValueEvaluatableExpression {
2727+
/**
2728+
* The document range for which the inline value applies.
2729+
* The range is used to extract the evaluatable expression from the underlying document.
2730+
*/
2731+
readonly range: Range;
2732+
/**
2733+
* If specified the expression overrides the extracted expression.
2734+
*/
2735+
readonly expression?: string;
2736+
/**
2737+
* Creates a new InlineValueEvaluatableExpression object.
2738+
*
2739+
* @param range The range in the underlying document from which the evaluatable expression is extracted.
2740+
* @param expression If specified overrides the extracted expression.
2741+
*/
2742+
constructor(range: Range, expression?: string);
2743+
}
2744+
2745+
/**
2746+
* Inline value information can be provided by different means:
2747+
* - directly as a text value (class InlineValueText).
2748+
* - as a name to use for a variable lookup (class InlineValueVariableLookup)
2749+
* - as an evaluatable expression (class InlineValueEvaluatableExpression)
2750+
* The InlineValue types combines all inline value types into one type.
2751+
*/
2752+
export type InlineValue = InlineValueText | InlineValueVariableLookup | InlineValueEvaluatableExpression;
2753+
2754+
/**
2755+
* A value-object that contains contextual information when requesting inline values from a InlineValuesProvider.
2756+
*/
2757+
export interface InlineValueContext {
2758+
2759+
/**
2760+
* The stack frame (as a DAP Id) where the execution has stopped.
2761+
*/
2762+
readonly frameId: number;
2763+
2764+
/**
2765+
* The document range where execution has stopped.
2766+
* Typically the end position of the range denotes the line where the inline values are shown.
2767+
*/
2768+
readonly stoppedLocation: Range;
2769+
}
2770+
2771+
/**
2772+
* The inline values provider interface defines the contract between extensions and the VS Code debugger inline values feature.
2773+
* In this contract the provider returns inline value information for a given document range
2774+
* and VS Code shows this information in the editor at the end of lines.
2775+
*/
2776+
export interface InlineValuesProvider {
2777+
2778+
/**
2779+
* An optional event to signal that inline values have changed.
2780+
* @see [EventEmitter](#EventEmitter)
2781+
*/
2782+
onDidChangeInlineValues?: Event<void> | undefined;
2783+
2784+
/**
2785+
* Provide "inline value" information for a given document and range.
2786+
* VS Code calls this method whenever debugging stops in the given document.
2787+
* The returned inline values information is rendered in the editor at the end of lines.
2788+
*
2789+
* @param document The document for which the inline values information is needed.
2790+
* @param viewPort The visible document range for which inline values should be computed.
2791+
* @param context A bag containing contextual information like the current location.
2792+
* @param token A cancellation token.
2793+
* @return An array of InlineValueDescriptors or a thenable that resolves to such. The lack of a result can be
2794+
* signaled by returning `undefined` or `null`.
2795+
*/
2796+
provideInlineValues(document: TextDocument, viewPort: Range, context: InlineValueContext, token: CancellationToken): ProviderResult<InlineValue[]>;
2797+
}
2798+
26712799
/**
26722800
* A document highlight kind.
26732801
*/
@@ -3236,7 +3364,7 @@ declare module 'vscode' {
32363364
appendPlaceholder(value: string | ((snippet: SnippetString) => any), number?: number): SnippetString;
32373365

32383366
/**
3239-
* Builder-function that appends a choice (`${1|a,b,c}`) to
3367+
* Builder-function that appends a choice (`${1|a,b,c|}`) to
32403368
* the [`value`](#SnippetString.value) of this snippet string.
32413369
*
32423370
* @param values The values for choices - the array of strings
@@ -10787,6 +10915,21 @@ declare module 'vscode' {
1078710915
*/
1078810916
export function registerEvaluatableExpressionProvider(selector: DocumentSelector, provider: EvaluatableExpressionProvider): Disposable;
1078910917

10918+
/**
10919+
* Register a provider that returns data for the debugger's 'inline value' feature.
10920+
* Whenever the generic VS Code debugger has stopped in a source file, providers registered for the language of the file
10921+
* are called to return textual data that will be shown in the editor at the end of lines.
10922+
*
10923+
* Multiple providers can be registered for a language. In that case providers are asked in
10924+
* parallel and the results are merged. A failing provider (rejected promise or exception) will
10925+
* not cause a failure of the whole operation.
10926+
*
10927+
* @param selector A selector that defines the documents this provider is applicable to.
10928+
* @param provider An inline values provider.
10929+
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10930+
*/
10931+
export function registerInlineValuesProvider(selector: DocumentSelector, provider: InlineValuesProvider): Disposable;
10932+
1079010933
/**
1079110934
* Register a document highlight provider.
1079210935
*

0 commit comments

Comments
 (0)