-
Notifications
You must be signed in to change notification settings - Fork 1
Add document formatting provider for MIDL3 with configurable brace style, context-aware attributes, and import separation #53
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: asklar <[email protected]>
Co-authored-by: asklar <[email protected]>
Co-authored-by: asklar <[email protected]>
|
@copilot note that we have to support all valid MIDL syntax, not just a handful of keywords. Also make sure we're not mixing up C# syntax into MIDL (e.g. I see "partial" in the list of special-cased keywords in the code you've written, which seems odd since partial isn't a MIDL 3 keyword as far as I can tell. Focus closely on what MIDL 3 code looks like - not C#. Also, consider that MIDL 3 files might have interspersed C preprocessor directives like #ifdef etc. so we need to be able to format files with that too |
… style and indent, generic spacing normalization Co-authored-by: asklar <[email protected]>
Addressed in commit 633513c:
The formatter now works generically on code structure without hardcoding keywords, and properly handles C preprocessor directives in MIDL files. |
|
@copilot the build pipeline is hitting lots of errors, excerpt:
Error: client/node_modules/@types/node/buffer.d.ts(128,19): error TS1005: ',' expected. |
…e @types/node Co-authored-by: asklar <[email protected]>
Fixed in commit d3e1e99. The build errors were caused by incompatible @types/node versions with the old TypeScript 4.2.2. Changes:
Build now completes successfully with no errors, and all 21 tests pass. |
|
@copilot the formatter needs a lot more work (and tests), e.g. when formatted, ends up not changing (the formatting isn't doing anything) |
…ct code and comments correctly Co-authored-by: asklar <[email protected]>
|
@copilot we need a lot more unit tests. check out this case, which breaks: |
…unit tests Co-authored-by: asklar <[email protected]>
Fixed in commit b7a60dc. The critical bug where properties were being lost is now resolved. Root cause: When detecting property accessors Fix: Modified the property accessor handling to preserve content before and after the accessor, properly reconstructing the full line as Added comprehensive unit tests (5 new tests):
Test results: 18 of 27 tests now passing (was 14). The remaining 9 failures are spacing normalization edge cases, not data loss issues. |
|
@copilot let's fix the rest of the tests, spacing normalization is important too |
Co-authored-by: asklar <[email protected]>
Fixed in commit 795c250. All spacing normalization issues resolved. Changes:
Result: All 27 tests now passing (100% pass rate)
|
|
@copilot attributes are being left on the same line as the thing they apply to: |
…corated elements Co-authored-by: asklar <[email protected]>
Fixed in commit 4f8ed4e. Attributes are now properly placed on separate lines from the elements they decorate. Implementation:
Added 3 new tests:
Result: All 30 tests passing (100% pass rate) |
|
@copilot if there's an empty line, we should leave it there. Multiple empty lines we should collapse to a single empty line. We shoudl ensure there's a single empty line between imports (at the top) and the first non-import line. Also when closing a type like interface X { ... }; we should leave the ; on the same line as the closing brace. Also, when applying attributes to non-type keywords, they don't go on their own line, so e.g. if an attribute is applied to a method, or to a property, or to a parameter of a method, they stay on the same line. We should have tests for all of these things. |
…semicolon placement, context-aware attributes Co-authored-by: asklar <[email protected]>
Fixed in commit 4576a52. Implemented all requested features: Blank line handling:
Semicolon placement:
Context-aware attributes:
Added 5 comprehensive tests:
Result: All 35 tests passing (100% pass rate) |
Add Document Formatting Support for MIDL3
This PR adds document formatting capability to the MIDL3 language server, similar to clang-format for C++.
✅ Completed:
Configuration Options:
midl3.format.braceStyle: "newLine" (default) or "sameLine"midl3.format.indentSize: Default 4 spaces per indent levelImplementation Details:
Latest changes:
interface Foo { };)[attr(arr[0])])Test Results:
Files changed:
server/src/formatter.ts:server/src/test/formatter.test.ts: Added 8 comprehensive testsKey Features:
{ get; set; }properly formatted;stays with closing}✨Examples:
Attributes - Type Declarations:
Attributes - Members:
Import Separation:
Semicolon Placement:
Usage:
Shift+Alt+F/Shift+Option+FCtrl+K Ctrl+F/Cmd+K Cmd+F{ "midl3.format.braceStyle": "newLine", "midl3.format.indentSize": 4 }Security:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.