eclipse-xtext / eclipse-xtext/xtext

Add a FoldingRegionProvider that folds on each { and } pairs

Open
#3,795 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
831
Forks
330
Avg merge
3d 7h
Merged PRs (30d)
12

Description

The DefaultFoldingRegionProvider creates folding regions based on the AST structure.

It should be useful to create a new FoldingRegionProvider that creates folding regions considering the opening and closing curly braces.

Steps to reproduce:

  1. Create a new Xtext project with the following grammar:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
	greetings+=Greeting*;

Greeting:
	'Hello' '{'
		'from' sender=ID 'to'
		'{' receivers += ID+ '}'
	'}';
  1. Start runtime Eclipse and create a test.mydsl file with the following content:
Hello {
	from Tamas to {
		Eclipse
		Xtext
	}
}
  1. Xtext calculates only one folding region on default (left side). Using the improved FoldingRegionProvider, two folding regions should be calculated (right side)
Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with org.eclipse.xtext.ui/src/org/eclipse/xtext/ui/editor/folding/DefaultFoldingRegionProvider.java and compare its AST-based folding behavior with the brace pairs in the issue's MyDsl grammar. Reproduce the example in a runtime Eclipse instance, then verify that the nested grammar produces two folding regions on the right side.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.