eclipse-xtext / eclipse-xtext/xtext

Formatter produces garbage

Open
#2,297 0 comments 0 reactions 1 assignee View on GitHub

@szarnekow is already working on this.

Since Aug 14, 2018.

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

Description

When formatting the following code, the Xtend formatter produces garbage:

package com.btc.serviceidl.generator.cpp

import java.util.Collection
import org.eclipse.emf.ecore.EObject

class CodecGenerator 
{    
    Object typeResolver
    
    def generateHeaderFileBody(EObject owner)
    {
        var Collection<EObject> nested_types
        '''
               «FOR type : nested_types»
                   «/* TODO */»
                   «val proto_type_name = typeResolver.toString»
               «ENDFOR»
        '''
    }
    
}

The result is:

package com.btc.serviceidl.generator.cpp

import java.util.Collection
import org.eclipse.emf.ecore.EObject

class CodecGenerator
{
    Object typeResolver

    def generateHeaderFileBody(EObject owner)
    {
        var Collection<EObject> nested_types
        '''
            «FOR type : nested_types»
                «/* TODO */»
                   «val proto_type    e = typeResolver.toString»
            «ENDFOR»
        '''
    }

}

Parts of the name of the proto_type_name variable are replaced by spaces here, and the indentation is also not correct. The comment in the line before seems to confuse the formatter.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.