danipen / TextMateSharp

A port of tm4e to bring TextMate grammars to dotnet ecosystem
MIT License
87 stars 15 forks source link

Feature request - add rule name to ParsedThemeRule and language-configuration classes #48

Closed dmitry-medvedev closed 1 year ago

dmitry-medvedev commented 1 year ago

Hi,

We use TextMateSharp in our new generic parser.

There are a few features that we'd like to see in the next version of TextMateSharp

Please consider adding the name of the matched token to the ParsedThemeRule, so it's possible to match the token name from the tokens (right now, we can only get colors from the token). Here's a code snippet

            foreach (var themeRule in theme.Match(token.Scopes))
            {
                name = themeRule.name;
            }

We use the name of the matched token for our lexical styles collection.

Please also consider parsing language-configuration.json into C# classes. We use language configuration to get code snippets, code folding, indentation rules, etc.

Another small issue - IStateStack does not uniquely identifies the stack object; please add RuleId (at least) to this interface. BTW, StateStack.GetHashCode throws exceptions most of the time.

Finally, please consider signing TextMateSharp assemblies with strong names, as we're getting errors when adding the package to our strong-name signed assemblies.

We were able to work around most of these issues (except for the last one), by porting/changing some code from TextMateSharp. Happy to send you our modifications if needed.

I'm attaching a screenshot for your reference. image

Kind regards, Dmitry dmitry.medvedev@alternetsoft.com

danipen commented 1 year ago

Happy to send you our modifications if needed.

@dmitry-medvedev sure! PRs are more than welcome.

danipen commented 1 year ago

If you submit changes please separate them into different PRs for simplicity. Thanks!

danipen commented 1 year ago

About the last one a PR is coming: https://github.com/danipen/TextMateSharp/pull/49

danipen commented 1 year ago

A new version of TextMateSharp with strong names has been published. Check it out here https://www.nuget.org/packages/TextMateSharp/1.0.53

dmitry-medvedev commented 1 year ago

Many thanks for your reply, here are our modifications related to getting the token name from matched rules (based n 1.0.51 codebase)

ThemeWithNames.zip

dmitry-medvedev commented 1 year ago

I've attached helper classes for loading language configuration.

LanguageConfiguration.zip

danipen commented 1 year ago

Would be possible to create pull request for those? Thanks!

dmitry-medvedev commented 1 year ago

Will do that, but we will need to re-implement json serialization of the Language configuration using System.Json (as it was changed in 1.0.52)

danipen commented 1 year ago

Fixed by #50.