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

.add templates? #10

Open
vogella opened this issue Nov 17, 2014 · 1 comment
Open

.add templates? #10

vogella opened this issue Nov 17, 2014 · 1 comment

Comments

@vogella
Copy link

vogella commented Nov 17, 2014

See example below, not sure if that would be a good fit for add

public static void main(String[] args) {
List<Task> list = new ArrayList<Task>();
for (int i = 0; i < 20; i++) {
new Task(i, "Test1", "Test2", Task.Status.ASSIGNED, 10).add[HERE I AM]
}
}

@trylimits
Copy link
Owner

Nice idea. Template looks like this:

${collection}.add(${i:inner_expression(java.lang.Object)});

Unfortunately, I don't know why the used collection variable (already implemented by JDT) is not resolving to list in this scenario. I have to do some debugging I guess.
Anyway, it would be great if the existing implementation of the collection variable could be extended to allow the definition of the type of the proposed collections:

${:collection(exp)}.add(${exp:inner_expression(java.lang.Object)});

Then we could also guarantee an error-free state after the template is applied.

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

2 participants