Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting - needs automated tests #696

Closed
ivanz opened this issue Aug 22, 2016 · 6 comments
Closed

Syntax highlighting - needs automated tests #696

ivanz opened this issue Aug 22, 2016 · 6 comments

Comments

@ivanz
Copy link
Contributor

ivanz commented Aug 22, 2016

The syntax highlighting is based on a regex-based grammar and because there aren't any automated tests to validate changes - it is easy to cause regressions without knowing.

@DustinCampbell
Copy link
Member

We're planning to ship 1.4 soon. Once that happens, I'll start working on this. PR #725 integrates mocha for testing.

@DustinCampbell DustinCampbell modified the milestones: 1.5, future Aug 28, 2016
@DustinCampbell DustinCampbell self-assigned this Aug 28, 2016
@ivanz
Copy link
Contributor Author

ivanz commented Aug 28, 2016

I literally started looking into this 10 minutes ago and was just in the process of setting up typings and mocha. I was looking at vscode-textmate and if that can be used to check the token output. :)

@ivanz
Copy link
Contributor Author

ivanz commented Aug 28, 2016

@DustinCampbell I have built something that works well for me, is quite minimal on top of the vscode-textmate and looks like below in practice.

I would create a pull request now, but there will be some plumbing duplication with #725 (mocha, chai and typings set-up). I will wait for once #725 lands in and then create one on top.

import { assert } from 'chai'
import { Tokenizer, Token, Tokens } from './tokenizer'

let input = `
namespace TestNamespace
{
}`;

let tokens: Token[] = new Tokenizer().tokenize(input);

assert.include(Tokens.NamespaceKeyword("namespace"), tokens);
assert.include(Tokens.NamespaceIdentifier("TestNamespace"), tokens);

@DustinCampbell
Copy link
Member

Cool! Looking forward to it!

@ivanz
Copy link
Contributor Author

ivanz commented Aug 29, 2016

@DustinCampbell I have created a temporary repo which captures my current approach here: https://github.com/ivanz/omnisharp-csharp-grammar-test-harness in order to get early feedback. Let me know what your thougths are!

Example tests for "namespace"are here and the interesting implemntation bits are here. You can build and run with npm test if you end up having a play.

The idea is to wrap vscode-textmate in an easy to consume interface and expose an easy way to check if tokens were created correctly without hardcoding token ids in tests, etc.

@ivanz
Copy link
Contributor Author

ivanz commented Sep 2, 2016

I've migrated the above code into a pull request in #742

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants