ionide / ionide/FsAutoComplete
Language-specific syntax highlighting
- Dominant language
- F#
- Stars
- 486
- Forks
- 169
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 5
Description
everything you're saying about the XML doc comments is correct, and that's why I mentioned it only as a nitpick. I think in this case optimizing for FSAC-based editors is ok, whereas in a more general library it would not be :)
regarding your suggestion for tagging - an attribute-based suggestion makes this much harder to do from an editor perspective IMO. As Alfonso mentioned there are two parts to this:
* tagging the text spans with the correct language identifier
* formulating virtual documents that can be generated for the interpolated strings
with a function-call based approach, it's very easy to do both of these at a layer higher than that of FSAC itself (as Alfonso's extension has shown). You can detect specfic call patterns by regex and annotate the regions based on that tag.
with a parameter-attribute based approach, you start to rely much more on FSAC to power the experience - you'd need to
* identify interpolated strings (easy)
* identify the name of the function that the interpolated string is being passed to (less easy but still doable)
* identify the FSharpMemberOrFunctionOrValue associated with the name of the function being called (easy but potentially CPU-expensive?)
* identify the parameter on the function that matches the interpolated string, and check it for the attribute (easy-ish)
once you have this data, you need to do two things with it:
* change the structural tagging of the interpolated string to that of the language desired,
* send those text ranges to the hosting editor, so that the hosting editor can make virtual documents (maybe we could do this in-editor?)
it's worth exploring for sure, just seems like a good chunk more work
_Originally posted by @baronfel in https://github.com/fsharp/FsAutoComplete/issues/911#issuecomment-1091795324_
Special Note - the 'tagging' part of this for a function becomes easier in .NET 7. The runtime is adding `StringSyntaxAttribute` specifically for this use case: https://github.com/dotnet/runtime/pull/62995.
The attribute can be manually added to your code in an #if` block to light up 'downlevel' support, so we could start preaching this. @alfonsogarciacaro/@zaid-ajaj, you may want to consider this for your libraries!
Contributor guide
Assessment
This issue has not been assessed yet.