Closed srnanikolic closed 3 years ago
I don't think you can fold on the json parameters
with regex. But you fold the xslt with:
"folding": {
"xsl": [
{
"begin": "<xsl:for-each",
"end": "</xsl:for-each"
},
{
"begin": "<xsl:if",
"end": "</xsl:if"
}
]
}
I'm assuming your file is an .xslt
.
Another way is to correctly format the file to use the indentation provider:
<xsl:template match="/">
{
"$schema": "****",
"contentVersion": "*******",
"functions": [
],
"parameters": {
"par1": {
"type": "string"
},
"par2": {
"type": "string"
},
<xsl:for-each select="Project/Somethnig1/Something2">
"par3<xsl:value-of select="@Include" />": {
"type": "string",
"defaultValue": "7"
},
</xsl:for-each>
"par4": {
"type": "string"
},
<xsl:if test="not(/Project/Somethnig1/Something2/Name='a1))">
"par5": {
"type": "string"
}
</xsl:if>
}
}
</xsl:template>
with
"folding": {
"xsl": [
{
"indentation": true
}
]
}
It's also help to identify a missing }
at the end.
I would write an extension without regex that would have a recursive function (every time she came across an open parenthesis or the beginning of a XSLT she would call herself again to find the end) or somethnig like for loop which is going line by line and looking for parenthesis or XSLT. I am asking which part of code is going to delete default fold and which part of code is going to set fold in some range?
Thanks, Srna
Od: Baptiste Augrainmailto:notifications@github.com Poslato: utorak, 09. mart 2021. 11:59 Za: zokugun/vscode-explicit-foldingmailto:vscode-explicit-folding@noreply.github.com Cc: Srnamailto:srnanikolic@hotmail.com; Authormailto:author@noreply.github.com Tema: Re: [zokugun/vscode-explicit-folding] Extension for mix of JSON and XSLT (#37)
Another way is to correctly format the file to use the indentation provider:
You would need a provider with the method public provideFoldingRanges(document: TextDocument): ProviderResult<FoldingRange[]>
.
The folding ranges are built like new FoldingRange(begin, end)
where begin
is the first line of the range and end
the last line.
@srnanikolic Have you been able to advance on your project?
Describe the issue
Hi, I am writing an extension for VSCode for college. I am a beginner in writing extensions and I need your help. My document is mix of JSON and XSLT. I don't know how to delete and to set folding on the places where I want to be. I am asking you which part of code can I use to delete default folds and then to set my own folds. Example is in Code Example.
To reproduce
Code Example
I have sometninh like this
And want to tranfsorm it like this
Or this
Settings
Expected behavior
Screenshots
Additional context