Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger: debug.inlineValues support for case insensitive variable names #101797

Closed
chrisdp opened this issue Jul 6, 2020 · 14 comments
Closed

Debugger: debug.inlineValues support for case insensitive variable names #101797

chrisdp opened this issue Jul 6, 2020 · 14 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality
Milestone

Comments

@chrisdp
Copy link

chrisdp commented Jul 6, 2020

Hey, I am working on a debugger for a case insensitive language. When looking into the source I didn't see any way to define the expressions as case insensitive.

function createInlineValueDecorationsInsideRange(expressions: ReadonlyArray<IExpression>, range: Range, model: ITextModel, wordToLineNumbersMap: Map<string, number[]>): IDecorationOptions[] {

With debug.inlineValues set to true I can’t get camel case vars to work. In the below example you can see we have the value for postdata but it won’t match postData in the code even though they are the same reference.

image

As an extension maintainer and/or author we would like to be able to define ether the language as a whole as case insensitive or the scope/variables themselves.

@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality labels Jul 6, 2020
@weinand weinand added this to the On Deck milestone Jul 6, 2020
@weinand
Copy link
Contributor

weinand commented Jul 6, 2020

Yes, this is a valid feature request.

@isidorn
Copy link
Contributor

isidorn commented Jul 27, 2020

A debug adapter could for example specify this using a capability. Or alternativly we could change the debug.inlineValues to be a string setting so the user or an extension could change it to be case insensitive. I prefer the capability approach.

@weinand
Copy link
Contributor

weinand commented Jul 27, 2020

IMO the debug adapter is not in a good position to know about case sensitivity because it has no syntax knowledge of the source language because it doesn't take transpilation into account (e.g. CoffeeScript, TypeScript -> JavaScript).

Whether a language is case sensitive or not should be knowledge that is kept close to VS Code's notion of a "word definition". @jrieken does such a concept exist?

I'm currently looking into this problem in a broader way: similar to what we did for debug hovers with the EvaluatableExpressionProvider, I'm trying to do design an InlineValueProvider that can be contributed by a language extension.

@isidorn
Copy link
Contributor

isidorn commented Jul 27, 2020

@weinand that sounds like a great approach. However why do we need a separate thing for the Inline values, can we just reuse what you already did for the debug hovers with the EvaluatableExpressionProvider?

@weinand
Copy link
Contributor

weinand commented Jul 27, 2020

@isidorn yes, that's exactly what my protoyping tries to find out: do we need a new abstraction or could we just use a variant for the EvaluatableExpressionProvider. Since the EvaluatableExpressionProvider uses the mouse position, it is not a very efficient way to find all inline expressions by probing for each character position in a line of source. In addition there is no way to figure out whether an evaluatable expression for one position is the same as for the next position...
My current thinking is to have a new method that returns all evaluatable expressions for a source line.

@isidorn
Copy link
Contributor

isidorn commented Jul 27, 2020

@weinand yeah that feels like a way to go here. Just a new method provideEvaluatableExpressionForLine on the EvaluatableExpressionProvider

@weinand
Copy link
Contributor

weinand commented Aug 31, 2020

Since it is a bigger effort to provide extension API for the debugger's "inline values" feature, I've created a new feature request #105690.

@weinand
Copy link
Contributor

weinand commented Feb 17, 2021

@chrisdp I've released a first cut of the "inline values provider" implementation which should make it possible to address this issue.

What you need to do:
implement an InlineValueProvider for your language that locates variables in the given lines of a document and return them from the provider as an array of InlineValueVariableLookup objects. VS Code will match them against the variables in the VARIABLE view to find their values. When creating the InlineValueVariableLookup object you can use the constructor argument caseSensitiveLookup to control how the lookup should be done.

@chrisdp
Copy link
Author

chrisdp commented Feb 17, 2021

@weinand Thanks! Thats great I'll take a look over the next few days.

@weinand
Copy link
Contributor

weinand commented Feb 17, 2021

@chrisdp I will provide more infos and a sample when preparing the release notes next week.

@chrisdp
Copy link
Author

chrisdp commented Feb 17, 2021

@chrisdp I will provide more infos and a sample when preparing the release notes next week.

That is perfect. I'll wait for that to drop then. Thanks!

@weinand
Copy link
Contributor

weinand commented Mar 2, 2021

@chrisdp a sample that shows a case sensitive variable name lookup appears in the release notes of the upcoming 1.54 release. In order to make it case-insensitive you just need to pass the value false as a third argument to the InlineValueVariableLookup constructor.
In addition you will need a regular expression that finds the variables in your language.

@chrisdp
Copy link
Author

chrisdp commented Mar 5, 2021

@weinand Thanks. I saw that and let the other maintainer of the extension we are working on know. Hopefully we will be able to take a look soon ™️ and give some feedback 👍

@weinand
Copy link
Contributor

weinand commented Jul 13, 2021

I'm closing this because we have addressed the problem by introduction of the Inline Values Provider API.

@weinand weinand closed this as completed Jul 13, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

3 participants