Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-core-dev] Strange formatting when using JDT core DOM infrastructure

Hi,

You can add the annotation in the first position inside the modifiers. You can format the code at the end once you get the source from the document.

Olivier


From: "Ivan St. Ivanov" <ivan.st.ivanov@xxxxxxxxx>
To: jdt-core-dev@xxxxxxxxxxx
Date: 2012-03-26 18:27
Subject: [jdt-core-dev] Strange formatting when using JDT core DOM        infrastructure
Sent by: jdt-core-dev-bounces@xxxxxxxxxxx





Hi folks!

I'm working on the JBoss Forge tool (https://docs.jboss.org/author/display/FORGE/Home). For some of its features it uses JDT core tooling to generate or modify Java classes. For example, it may create JPA entities. However, the final format is quite weird:

package com.example.test;

import javax.persistence.Entity;public @Entity class Employee {}

I would expect something like that:

package com.example.test;

import javax.persistence.Entity;

@Entity
public class Employee {}

You noticed how in the generated input the import, the annotation and the class declaration are on a single line? And @Entity is placed between the public and class words?

I have attached here a sample class, which demonstrates how we use the JDT parser API. Could you please tell me what I am doing wrong? And is it possible to have more beautiful formatting?

Thanks and regards,
Ivan[attachment "JdtFormatterTest.java" deleted by Olivier Thomann/Ottawa/IBM] _______________________________________________
jdt-core-dev mailing list
jdt-core-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jdt-core-dev



Back to the top