Skip to content

Commit f2a502f

Browse files
committed
Add Feature Highlighter Visual Studio extension
Implement a lightweight VSIX extension for syntax highlighting Gherkin/Cucumber .feature files. Key Features: - Syntax highlighting for all Gherkin elements (keywords, comments, tags, parameters, doc strings, tables) - Multi-language support (English, German, French, Spanish, etc.) via Reqnroll Gherkin parser - Optimized colors for Visual Studio 2022 Dark Theme - Minimal, focused extension - ONLY syntax highlighting, no test execution or IntelliSense Project Structure: - Classification: Content type, classifier, and format definitions - Parser: Reqnroll Gherkin parser wrapper for tokenization - Resources: Icon and preview image placeholders Components: - GherkinContentTypeDefinition.cs: Registers .feature files with gherkin content type - GherkinClassificationDefinitions.cs: Defines token types (keyword, comment, tag, etc.) - GherkinFormatDefinitions.cs: Defines colors and styles for each token type - GherkinClassifier.cs: Main classification logic using the parser - GherkinClassifierProvider.cs: MEF provider for the classifier - ReqnrollGherkinParserWrapper.cs: Wraps Reqnroll parser for tokenization Documentation: - README.md: Comprehensive user documentation - CONTRIBUTING.md: Contribution guidelines - TestFiles/sample.feature: Sample test file demonstrating all syntax elements Dependencies: - Reqnroll (BSD-3-Clause) for Gherkin parsing - Gherkin parser library - Visual Studio SDK 17.0+ Target: Visual Studio 2022+ (17.0+) License: MIT
1 parent 5770c26 commit f2a502f

15 files changed

Lines changed: 1613 additions & 0 deletions

CONTRIBUTING.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Contributing to Feature Highlighter
2+
3+
Thank you for your interest in contributing to Feature Highlighter! This document provides guidelines and instructions for contributing to this project.
4+
5+
## Code of Conduct
6+
7+
Please be respectful and constructive in all interactions. We want to maintain a welcoming environment for everyone.
8+
9+
## How to Contribute
10+
11+
### Reporting Issues
12+
13+
If you find a bug or have a feature suggestion:
14+
15+
1. Check the [existing issues](https://github.com/markdav-is/Feature-Highlighter/issues) to avoid duplicates
16+
2. Create a new issue with a clear title and description
17+
3. Include:
18+
- Steps to reproduce (for bugs)
19+
- Expected behavior
20+
- Actual behavior
21+
- Visual Studio version
22+
- Sample .feature file (if applicable)
23+
- Screenshots (if helpful)
24+
25+
### Submitting Pull Requests
26+
27+
1. **Fork the repository** and create a new branch from `main`
28+
2. **Make your changes** following our guidelines below
29+
3. **Test thoroughly** in Visual Studio 2022
30+
4. **Commit with clear messages** describing what and why
31+
5. **Push to your fork** and submit a pull request
32+
33+
## Development Guidelines
34+
35+
### Project Scope
36+
37+
**Remember:** This extension is focused **only on syntax highlighting**. Do not add features like:
38+
- Test generation or execution
39+
- IntelliSense or autocomplete
40+
- Step definition navigation
41+
- Step binding detection
42+
- Refactoring tools
43+
- Code actions or quick fixes
44+
45+
If you want these features, contribute to SpecFlow or Reqnroll extensions instead.
46+
47+
### Code Style
48+
49+
- Use C# naming conventions (PascalCase for public members, _camelCase for private fields)
50+
- Add XML documentation comments for public APIs
51+
- Keep methods focused and reasonably sized
52+
- Use nullable reference types appropriately
53+
- Follow existing code patterns in the project
54+
55+
### Testing
56+
57+
Before submitting a PR, test your changes:
58+
59+
1. **Launch Experimental Instance**
60+
- Press F5 in Visual Studio 2022
61+
- This launches a separate VS instance with your extension loaded
62+
63+
2. **Test with Various Feature Files**
64+
- Test with `TestFiles/sample.feature`
65+
- Create feature files with edge cases
66+
- Test with different Gherkin languages (English, German, French, etc.)
67+
68+
3. **Verify All Syntax Elements**
69+
- Keywords (Feature, Scenario, Given, When, Then, etc.)
70+
- Comments (lines starting with #)
71+
- Tags (@tagname)
72+
- Parameters (<param>, {param}, "string", 'string')
73+
- Doc strings (""" content """)
74+
- Tables (| cell | cell |)
75+
76+
4. **Performance Testing**
77+
- Test with large feature files (1000+ lines)
78+
- Ensure no noticeable lag when scrolling or editing
79+
- Monitor CPU usage
80+
81+
### Multi-Language Support
82+
83+
When adding or modifying keyword detection:
84+
85+
- Support English, German, French, and Spanish at minimum
86+
- Use the Reqnroll Gherkin parser's built-in language support
87+
- Test with feature files in multiple languages
88+
- Don't hardcode language-specific keywords unnecessarily
89+
90+
### Color Schemes
91+
92+
Default colors are optimized for VS Dark Theme:
93+
- Keywords: #569CD6 (Blue, Bold)
94+
- Comments: #57A64A (Green, Italic)
95+
- Tags: #9CDCFE (Light Blue)
96+
- Parameters: #B8D7A3 (Light Green)
97+
- Doc Strings: #CE9178 (Tan/Brown)
98+
- Table Cells: #DCDCAA (Yellow)
99+
- Table Pipes: #B0B0B0 (Gray)
100+
101+
If proposing color changes:
102+
- Test with both Dark and Light themes
103+
- Ensure good contrast and readability
104+
- Provide screenshots
105+
- Consider colorblind users
106+
107+
## Project Structure
108+
109+
```
110+
FeatureHighlighter/
111+
├── Classification/
112+
│ ├── GherkinContentTypeDefinition.cs # Registers .feature content type
113+
│ ├── GherkinClassificationDefinitions.cs # Defines token types
114+
│ ├── GherkinFormatDefinitions.cs # Defines colors/styles
115+
│ ├── GherkinClassifier.cs # Main classification logic
116+
│ └── GherkinClassifierProvider.cs # MEF provider
117+
├── Parser/
118+
│ └── ReqnrollGherkinParserWrapper.cs # Wraps Gherkin parser
119+
└── Resources/
120+
├── icon.png # Extension icon
121+
└── preview.png # Preview screenshot
122+
```
123+
124+
### Key Components
125+
126+
- **Content Type Definition**: Associates .feature files with "gherkin" content type
127+
- **Classification Definitions**: Logical token categories (keyword, comment, etc.)
128+
- **Format Definitions**: Visual styles for each token type
129+
- **Classifier**: Analyzes text and assigns classifications
130+
- **Parser Wrapper**: Uses Reqnroll parser to tokenize Gherkin syntax
131+
132+
## Building the Project
133+
134+
### Prerequisites
135+
136+
- Visual Studio 2022 (17.0 or higher)
137+
- .NET Framework 4.8
138+
- Visual Studio SDK installed
139+
140+
### Build Steps
141+
142+
```bash
143+
# Clone your fork
144+
git clone https://github.com/YOUR-USERNAME/Feature-Highlighter.git
145+
cd Feature-Highlighter
146+
147+
# Open in Visual Studio
148+
start FeatureHighlighter.sln
149+
150+
# Or build from command line
151+
msbuild FeatureHighlighter.sln /p:Configuration=Debug
152+
```
153+
154+
### Debugging
155+
156+
1. Set `FeatureHighlighter` as the startup project
157+
2. Press F5 to launch Experimental Instance
158+
3. Open a .feature file in the Experimental Instance
159+
4. Set breakpoints in your code to debug
160+
161+
## Pull Request Checklist
162+
163+
Before submitting your PR, ensure:
164+
165+
- [ ] Code builds without errors or warnings
166+
- [ ] Extension loads in VS 2022 Experimental Instance
167+
- [ ] Syntax highlighting works for all Gherkin elements
168+
- [ ] Tested with multiple language variants
169+
- [ ] Tested with large files (performance)
170+
- [ ] No breaking changes to existing functionality
171+
- [ ] Code follows project style guidelines
172+
- [ ] XML documentation added for new public APIs
173+
- [ ] Commits have clear, descriptive messages
174+
- [ ] PR description explains the change and why it's needed
175+
176+
## Questions?
177+
178+
If you have questions about contributing:
179+
- Open a [Discussion](https://github.com/markdav-is/Feature-Highlighter/discussions)
180+
- Comment on a relevant issue
181+
- Review existing PRs to see how others have contributed
182+
183+
## License
184+
185+
By contributing, you agree that your contributions will be licensed under the MIT License.
186+
187+
---
188+
189+
Thank you for contributing to Feature Highlighter! 🎉

FeatureHighlighter.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FeatureHighlighter", "FeatureHighlighter\FeatureHighlighter.csproj", "{A7E8F2C3-1234-5678-90AB-CDEF12345678}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{A7E8F2C3-1234-5678-90AB-CDEF12345678}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A7E8F2C3-1234-5678-90AB-CDEF12345678}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A7E8F2C3-1234-5678-90AB-CDEF12345678}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A7E8F2C3-1234-5678-90AB-CDEF12345678}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {B9C5A1E2-3456-7890-BCDE-F123456789AB}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System.ComponentModel.Composition;
2+
using Microsoft.VisualStudio.Text.Classification;
3+
using Microsoft.VisualStudio.Utilities;
4+
5+
namespace FeatureHighlighter.Classification
6+
{
7+
/// <summary>
8+
/// Defines classification types for Gherkin syntax elements.
9+
/// These are the logical categories that the classifier will use to tag text spans.
10+
/// </summary>
11+
internal static class GherkinClassificationDefinitions
12+
{
13+
/// <summary>
14+
/// Classification for Gherkin keywords (Feature, Scenario, Given, When, Then, etc.)
15+
/// </summary>
16+
[Export]
17+
[Name("gherkin.keyword")]
18+
[BaseDefinition("keyword")]
19+
public static ClassificationTypeDefinition? GherkinKeyword { get; set; }
20+
21+
/// <summary>
22+
/// Classification for Gherkin comments (lines starting with #)
23+
/// </summary>
24+
[Export]
25+
[Name("gherkin.comment")]
26+
[BaseDefinition("comment")]
27+
public static ClassificationTypeDefinition? GherkinComment { get; set; }
28+
29+
/// <summary>
30+
/// Classification for Gherkin tags (@tagname)
31+
/// </summary>
32+
[Export]
33+
[Name("gherkin.tag")]
34+
[BaseDefinition("identifier")]
35+
public static ClassificationTypeDefinition? GherkinTag { get; set; }
36+
37+
/// <summary>
38+
/// Classification for Gherkin step parameters (<param>, {param}, "string")
39+
/// </summary>
40+
[Export]
41+
[Name("gherkin.parameter")]
42+
[BaseDefinition("string")]
43+
public static ClassificationTypeDefinition? GherkinParameter { get; set; }
44+
45+
/// <summary>
46+
/// Classification for Gherkin doc strings (triple quotes)
47+
/// </summary>
48+
[Export]
49+
[Name("gherkin.docstring")]
50+
[BaseDefinition("string")]
51+
public static ClassificationTypeDefinition? GherkinDocString { get; set; }
52+
53+
/// <summary>
54+
/// Classification for Gherkin table cell content
55+
/// </summary>
56+
[Export]
57+
[Name("gherkin.table.cell")]
58+
[BaseDefinition("text")]
59+
public static ClassificationTypeDefinition? GherkinTableCell { get; set; }
60+
61+
/// <summary>
62+
/// Classification for Gherkin table pipe delimiters
63+
/// </summary>
64+
[Export]
65+
[Name("gherkin.table.pipe")]
66+
[BaseDefinition("operator")]
67+
public static ClassificationTypeDefinition? GherkinTablePipe { get; set; }
68+
}
69+
}

0 commit comments

Comments
 (0)