Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 7: pretty-print diamond syntax #96

Closed
GerardPaligot opened this issue Nov 12, 2014 · 2 comments
Closed

Java 7: pretty-print diamond syntax #96

GerardPaligot opened this issue Nov 12, 2014 · 2 comments

Comments

@GerardPaligot
Copy link
Contributor

For the support of java 7, spoon must support diamond syntax. It support already (yeah!) but not totally. Here is an example to illustrate the "problem":

DiamondExample is a class ready to be spooned.

public class DiamondExample {
    public void col() {
        Collection<String> coll = new ArrayList<>();

        Collection<String> coll2 = new ArrayList();

        Collection<String> coll3 = new ArrayList<String>();
    }
}

The output of spoon is:

public class DiamondExample {
    public void col() {
        java.util.Collection<java.lang.String> coll = new java.util.ArrayList<java.lang.String>();
        java.util.Collection<java.lang.String> coll2 = new java.util.ArrayList();
        java.util.Collection<java.lang.String> coll3 = new java.util.ArrayList<java.lang.String>();
    }
}

So, when spoon detects a diamond syntax, it replaces with the right implementation. So the result is valid and support java 7 but the output isn't java 7.

Good thing or not? I would like reviews about this from the community. :)

@seintur
Copy link
Contributor

seintur commented Nov 12, 2014

Same remark as for Issue #97. I would prefer to stay as close as possible to Java 7.

Lionel.

@monperrus monperrus changed the title Java 7: support diamond syntax Java 7: pretty-print diamond syntax Nov 17, 2014
@GerardPaligot
Copy link
Contributor Author

Well, this issue was discussed internal. We think we don't want to have the correct java 7 syntax for the diamond syntax. Unlike of multi catch, diamond is syntactic sugar, not really a new feature. Maybe, this can be a feature interesting when we will refactors the DefaultJavaPrettyPrinter but, for now, we will keep this current result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants