Highlighting rule not fully applied #223
Labels
No labels
Area-Accessibility
Area-Build
Area-CodeCompletion
Area-Document
Area-Documentation
Area-Editing
Area-Folding
Area-Highlighting
Area-i18n
Area-Indentation
Area-NetFx
Area-Rendering
Area-Search
Area-Snippets
dependencies
duplicate
Feedback Needed
help wanted
invalid
Issue-Bug
Issue-Discussion
Issue-Enhancement
Issue-Performance
Issue-Question
on-hold
Resolution-Answered
Resolution-By Design
Resolution-Duplicate
Resolution-Fixed
Resolution-Won't Fix
Up-for-Grabs
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-icsharpcode/AvalonEdit#223
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello, I'm editing your
xshdfor C# https://github.com/icsharpcode/AvalonEdit/blob/master/ICSharpCode.AvalonEdit/Highlighting/Resources/CSharp-Mode.xshd in order to make it look like Visual Studio, and this is what I have by now:https://pastebin.com/xN9yx0Yj
And using this code to test it https://pastebin.com/J5CTpNCu
Currently it is displayed in this way:

As I wrote in the image there are some things that I expected to be colorized and it doesn't.
I have tested this rule here https://bit.ly/2SYf9EG and seems to work as I expect, but in the editor it is like is stoping the highlighting in the first match (
Attributein this case).And again in the test https://bit.ly/3a86xBm seems to be working as I would expect, and I thing the problem is the same than the previous one, it is stopping at the first occurrence.
The fundamental problem you are hitting here is that you try to implement semantic highlighting through the use of regular expressions. This is generally not possible and Visual Studio and any other decent editor uses a parser and semantic analysis to detect whether an identifier in the editor refers to a type or member of a type. You will have to implement a custom
DocumentColorizingTransformerwhich uses data provided by a parser etc. I recommend taking a look at Roslyn https://github.com/dotnet/roslyn, which provides a parser and type system. Hope this helps!Thank you for your advice, but without having read too much about Roslyn I always thought that in order to make it work I need to pass the entire project to evaluate or parse all types and methods, and that's probably a lot of processing work that I would prefer to avoid for the use I am going to give it (only display a piece of code from time to time), I don't need the highlighting to be perfect neither exactly equal as Visual Studio but I don't mind to spend some time thinking about some semantic rules that are projectable as regular expressions.
When I wrote the issue I was wondering that since the regular expression seems to be correct (in the tester recognizes what I want), if maybe there is a bug or a property incorrectly set that it is preventing the highlight to work as I want.
Thanks again.