[hibernate-issues] [Hibernate-JIRA] Commented: (HBX-1030) Mixed eol chars in generated pojos

Dmitry Geraskov (JIRA) noreply at atlassian.com
Wed Mar 12 04:51:35 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HBX-1030?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29770 ] 

Dmitry Geraskov commented on HBX-1030:
--------------------------------------

BTW, IMHO the best solution do not use line delimiters at all!

Look at the example:

------
String contents = "java.lang.String str;System.out.println();System.out.println();";            //generate code without line delimiters

CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(null);		
IDocument doc = new Document(contents);
TextEdit edit = codeFormatter.format(CodeFormatter.K_UNKNOWN, doc.get(), 0, doc.get().length(), 0, null);
		
edit.apply(doc);
String newcontents = doc.get();
-------

Using the code we get fine formatted code with system line delimiter.

I cheked - code formatter replaces all line delimiters to only one (system delimiter), even if you used your own in "contents" string. 

I see only 2 probably disadvantages:
- File contents is not wrote to the file immediately and saved in the memory 
- I do not now productive time of code formatting for big files (I hope time is acceptable)

And there are many advantages, for ex.:
- fix problem with line delimiter
- fine formatted code
- may be it use user preferences(I am not shure)
- better approach

Just an idea, hope to listen you thoughts about it.


> Mixed eol chars in generated pojos
> ----------------------------------
>
>                 Key: HBX-1030
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1030
>             Project: Hibernate Tools
>          Issue Type: Patch
>          Components: hbm2java
>    Affects Versions: 3.2.0.GA
>         Environment: java
>            Reporter: Simon Toens
>            Priority: Minor
>         Attachments: DocExporterpatch.txt, eol.patch, sysEOL.txt
>
>
> org.hibernate.tool.hbm2x.pojo.ImportContextImpl hardcodes "\r\n" as eol characters for import statements.  This is kind of lame, and a problem when using svn with svn:eol-style=native:
> $ svn add revengtest/
> ...
> A         revengtest/src//test/Actor.hbm.xml
> svn: File 'revengtest/src/test/Actor.java' has inconsistent new lines
> svn: Inconsistent line ending style
> Since the rest of the generated pojo uses "\n", why not just use that?
> Attached is the trivial patch.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list