langium
langium copied to clipboard
Centralize template string functionality
Story
As a maintainer I want to keep application logic in a central place. The vscode extension should use core template string functionality to calculate indentation of template strings.
Acceptance criteria
- [ ] the entry point of the core package only exports the tagged template
s. - [ ] the core/generator package exports the internal functionality to compute template string indentation
- [ ] the vscode-extension package uses the internal indentation functionality of the sub-module core/generator
I stumbled upon one issue: I need to find strings within strings in order to nested highlight whitespace.
Here is an Xtend example:
Langium example (whitespace = XXX + javascript code other than string contents):
const generated = s```
XXXclass A {
XXXXXX${members.map(member => {
XXXXXXXXXswtichX(member.type)X{
XXXXXXXXXXXXcaseX'method':XreturnXs```
XXXXXXXXXXXXXXXTODO: generate method
XXXXXXXXXXXX```
XXXXXXXXX}
XXXXXX}
XXX}
I do not have access to the AST (because it lives in the language server and the whitespace highlighter extension only has access to the editor contents), so I plan to implement a 'stack' parser that is aware of
- comments (in order to skipt strings within comments)
- strings (in order to find whitespace and align contents)
- template literal substitutions (in order to recurse in javascript code from within a string context)
The changes in #825 break the highlighting provided by our vscode extension. @danieldietrich how shall we proceed with this? Remove the functionality for now, or make it work with the new API?
@spoenemann could you please elaborate on the highlighting error by providing a screenshot? Let's see if there is a quick workaround...
It just doesn't show any whitespace highlighting. I assume it's because the s function has been replaced by two functions expandToString and expandToNode?