Project: JDT
Bug 153252 [templates] Allow templates to add an explicit import
Reported: 2006-08-09 05:21:08 | Status: resolved fixed

I20060807-2000 With the current support, I found no way to rewrite the "Test - test method (JUnit 4)" template to automatically add an import org.junit.Test when the template is applied. A variable ${type(org.junit.Test)} would be a way to solve this. It should not be a tab stop in linked mode and it should use an ImportRewrite to add the type. The solution should also be used in the "for - iterate over collection" default template, which currently causes a compile error when another type named "Iterator" is already visible in scope.

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContext.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/TypeResolver.java