wmyywm / eclipse-code-formatter-intellij-plugin

Automatically exported from code.google.com/p/eclipse-code-formatter-intellij-plugin
0 stars 0 forks source link

Failed to format java 7 code #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When you try to use the Eclipse Code formatter with java 7 source code that 
includes declarations of collections using "Type Inference for Generic Instance 
Creation". The formatter don't work and send the error "failed to format with 
Eclipse code formatter. Probably due to syntax error or wrong configuration 
file.".

You just need to include the following line of code:

(java 7)
private Map<Long, String> map = new ConcurrentHashMap<>();

but if you change the declaration to java6:

private Map<Long, String> map = new ConcurrentHashMap<Long, String>();

Original issue reported on code.google.com by pedrocgs...@gmail.com on 27 Sep 2013 at 11:18

GoogleCodeExporter commented 9 years ago
do you have these in config file?
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.source=1.7

Original comment by vojta.kr...@gmail.com on 27 Sep 2013 at 1:42

GoogleCodeExporter commented 9 years ago
No I didn't :(

Now it works.

Thank you very much.

Original comment by pedrocgs...@gmail.com on 27 Sep 2013 at 1:47

GoogleCodeExporter commented 9 years ago
no problem.

Original comment by vojta.kr...@gmail.com on 3 Oct 2013 at 11:41

GoogleCodeExporter commented 9 years ago
You can also refer to this great article by Stefan Franke :

http://www.franke.ms/#eclipse-formatter-commandline.wiki

Original comment by Mistri...@gmail.com on 31 Dec 2013 at 6:15

GoogleCodeExporter commented 9 years ago
I hardcoded org.eclipse.jdt.core.compiler.source=1.7 so it will not happen 
again.

Original comment by vojta.kr...@gmail.com on 31 Dec 2013 at 8:08