use of org.eclipse.jdt.core.dom.ASTRequestor in project flux by eclipse.
the class CompletionProposalReplacementProvider method getExpectedTypeForGenericParameters.
private ITypeBinding getExpectedTypeForGenericParameters() {
char[][] chKeys = context.getExpectedTypesKeys();
if (chKeys == null || chKeys.length == 0)
return null;
String[] keys = new String[chKeys.length];
for (int i = 0; i < keys.length; i++) {
keys[i] = String.valueOf(chKeys[0]);
}
final ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setProject(compilationUnit.getJavaProject());
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
final Map<String, IBinding> bindings = new HashMap<String, IBinding>();
ASTRequestor requestor = new ASTRequestor() {
@Override
public void acceptBinding(String bindingKey, IBinding binding) {
bindings.put(bindingKey, binding);
}
};
parser.createASTs(new ICompilationUnit[0], keys, requestor, null);
if (bindings.size() > 0)
return (ITypeBinding) bindings.get(keys[0]);
return null;
}
Aggregations