Formatting of conditional expressions

Open
#2,307 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Use the issue's multiline conditional-expression examples as the expected behavior, then locate the formatter entry point for conditional expressions in the Xtext codebase. Add regression coverage for the reported alignment and verify the formatter output against the chosen expected layout.

Written by the indexing model from the issue text.

Description

The formatting of conditional expressions produces confusing results when the expression is broken into multiple lines.

One example:

                    return resolve(element.referenceType, if (project_type != ProjectType.PROTOBUF)
                        element.referenceType.mainProjectType
                    else
                        project_type)

Here, it is confusing that the else is aligned with the return rather than the if.

I would expect something like:

                    return resolve(element.referenceType, if (project_type != ProjectType.PROTOBUF)
                                                              element.referenceType.mainProjectType
                                                          else
                                                              project_type)

or, in this case maybe even better:

                    return resolve(element.referenceType, 
                                   if (project_type != ProjectType.PROTOBUF)
                                       element.referenceType.mainProjectType
                                   else
                                       project_type
                                  )
Dominant language
Java
Stars
831
Forks
330
Avg merge
3d 7h
Merged PRs (30d)
12

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.

More from eclipse-xtext/xtext

All issues in eclipse-xtext/xtext

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.