Language Features for Ungrammar files
September 22, 2024 · View on GitHub
Ungrammar is a novel data format
for defining concrete syntax trees. This project aims to integrate Ungrammar
language support into VS Code, providing features to streamline the creation
and modification of .ungram files. By offering a dedicated language
experience within the editor, we aim to simplify the development process for
users working with this syntax definition format.
Features
IntelliSense and Validation
We offer up node name suggestions as you type with IntelliSense. You can also
manually see suggestions with the Trigger Suggestions command (Ctrl+Space).
We also perform structural and value verification giving you red squiggles.
To disable validation, use the ungrammar.validate.enable
setting.
Quick Navigation
Ungrammar files can get large and we support quick navigation to properties
using the Go to Symbol command (Ctrl+Shift+O).
Hovers
When hovering over nodes within an Ungrammar data structure, detailed context-specific information is displayed, aiding in understanding the code's structure and relationships.
Formatting
You can format your Ungrammar document using Shift+Alt+F or Format Document
from the context menu. To disable validation, use the
ungrammar.format.enable
setting.
Before formatting:
After formatting:
Folding
You can fold regions of source code using the folding icons on the gutter between line numbers and line start. Folding regions are available for all object and array elements.
Before folding:
After folding:
Annotations
We provide informative annotations displayed above code elements to aid in code comprehension. These annotations offer quick access to references, implementation details, and other relevant context, enhancing code navigability and understanding.
Expand and Shrink Selection
You can extend (Alt+Shift+→) or shrink (Alt+Shift+←) the current selection
to the encompassing syntactic construct (node, alternative, sequence, group,
etc). It works with multiple cursors.
Find All References
You can find all references using Shift+Alt+F12 to show all references of the
item at the cursor location.
Go to Definition
You can navigate to the definition of an node using F12.
Before Go to Definition, we are at line 657:
After Go to Definition, we are at line 588:
Highlight Related
You can highlight related constructs upon hovering over a node. This feature displays all references to the selected node within the current file, enhancing code navigation and understanding.
Rename
You can efficiently rename symbols across your codebase using the F2.
This powerful feature automatically updates all references to the selected
symbol, ensuring consistency and reducing the potential for errors.
Code Actions
You can enhance your code formatting with our powerful code actions. Quickly
and easily rename nodes to specific casing styles including snake_case,
CONSTANT_CASE, camelCase, and PascalCase, ensuring consistent naming
conventions throughout your project.
Semantic Syntax Highlighting
We highlight the code semantically. For example, "Rule" might be colored
differently depending on whether "Rule" is an Definition or a Identifier. We
does not specify colors directly, instead it assigns a tag (like variable) and
a set of modifiers (like definition) to each token. It's up to the client to
map those to specific colors.