|
49 | 49 | import org.eclipse.jdt.core.dom.Type; |
50 | 50 | import org.eclipse.jdt.core.dom.TypeDeclaration; |
51 | 51 | import org.eclipse.jdt.core.dom.rewrite.ImportRewrite; |
| 52 | +import org.eclipse.jdt.internal.corext.dom.ASTNodes; |
52 | 53 | import org.eclipse.jdt.internal.corext.dom.TypeBindingVisitor; |
53 | 54 | import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; |
54 | 55 |
|
@@ -122,6 +123,7 @@ public static boolean containsTypeVariable(Type type) { |
122 | 123 | final boolean[] containsTypeVariable = {false}; |
123 | 124 |
|
124 | 125 | ASTResolving.visitAllBindings(type, new TypeBindingVisitor() { |
| 126 | + @Override |
125 | 127 | public boolean visit(ITypeBinding visitedBinding) { |
126 | 128 | if (visitedBinding.isTypeVariable()) { |
127 | 129 | containsTypeVariable[0] = true; |
@@ -262,6 +264,15 @@ public static TypeDeclaration findTypeDeclaration(IJavaProject javaProject, |
262 | 264 | return null; |
263 | 265 | } |
264 | 266 |
|
| 267 | + public static ITypeBinding findTypeBinding(IType currentType) throws JavaModelException{ |
| 268 | + final ASTParser parser = ASTParser.newParser(AST.JLS3); |
| 269 | + parser.setKind(ASTParser.K_COMPILATION_UNIT); |
| 270 | + parser.setSource(currentType.getCompilationUnit()); |
| 271 | + parser.setResolveBindings(true); |
| 272 | + CompilationUnit unit = (CompilationUnit) parser.createAST(null); |
| 273 | + return ASTNodes.getTypeBinding(unit, currentType); |
| 274 | + } |
| 275 | + |
265 | 276 | /** |
266 | 277 | * Identical to |
267 | 278 | * {@link org.eclipse.jdt.internal.corext.dom.Bindings#findTypeInHierarchy(ITypeBinding, String)} |
|
0 commit comments