use of org.eclipse.jdt.core.dom.IBinding in project che by eclipse.
the class FullConstraintCreator method create.
/* (non-Javadoc)
* @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperFieldAccess)
*/
@Override
public ITypeConstraint[] create(SuperFieldAccess access) {
SimpleName name = access.getName();
IBinding binding = name.resolveBinding();
if (!(binding instanceof IVariableBinding))
return new ITypeConstraint[0];
IVariableBinding vb = (IVariableBinding) binding;
return createConstraintsForAccessToField(vb, null, access);
}
use of org.eclipse.jdt.core.dom.IBinding in project che by eclipse.
the class TypeEnvironment method createStandardType.
private StandardType createStandardType(String fullyQualifiedName, IJavaProject focus) {
try {
IType javaElementType = focus.findType(fullyQualifiedName);
StandardType result = fStandardTypes.get(javaElementType);
if (result != null)
return result;
ASTParser parser = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
parser.setProject(focus);
IBinding[] bindings = parser.createBindings(new IJavaElement[] { javaElementType }, null);
return createStandardType((ITypeBinding) bindings[0]);
} catch (JavaModelException e) {
// fall through
}
return null;
}
use of org.eclipse.jdt.core.dom.IBinding in project che by eclipse.
the class ImportRemover method applyRemoves.
public void applyRemoves(ImportRewrite importRewrite) {
IBinding[] bindings = getImportsToRemove();
for (int i = 0; i < bindings.length; i++) {
if (bindings[i] instanceof ITypeBinding) {
ITypeBinding typeBinding = (ITypeBinding) bindings[i];
importRewrite.removeImport(typeBinding.getTypeDeclaration().getQualifiedName());
} else if (bindings[i] instanceof IMethodBinding) {
IMethodBinding binding = (IMethodBinding) bindings[i];
importRewrite.removeStaticImport(binding.getDeclaringClass().getQualifiedName() + '.' + binding.getName());
} else if (bindings[i] instanceof IVariableBinding) {
IVariableBinding binding = (IVariableBinding) bindings[i];
importRewrite.removeStaticImport(binding.getDeclaringClass().getQualifiedName() + '.' + binding.getName());
}
}
}
use of org.eclipse.jdt.core.dom.IBinding in project che by eclipse.
the class RemoveDeclarationCorrectionProposal method getName.
@Override
public String getName() {
IBinding binding = fName.resolveBinding();
String name = BasicElementLabels.getJavaElementName(fName.getIdentifier());
switch(binding.getKind()) {
case IBinding.TYPE:
return Messages.format(CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedtype_description, name);
case IBinding.METHOD:
if (((IMethodBinding) binding).isConstructor()) {
return Messages.format(CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedconstructor_description, name);
} else {
return Messages.format(CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedmethod_description, name);
}
case IBinding.VARIABLE:
if (((IVariableBinding) binding).isField()) {
return Messages.format(CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedfield_description, name);
} else {
return Messages.format(CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedvar_description, name);
}
default:
return super.getDisplayString();
}
}
use of org.eclipse.jdt.core.dom.IBinding in project che by eclipse.
the class LazyGenericTypeProposal method getExpectedType.
/**
* Returns the type binding of the expected type as it is contained in the
* code completion context.
*
* @return the binding of the expected type
*/
private ITypeBinding getExpectedType() {
char[][] chKeys = fInvocationContext.getCoreContext().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 CheASTParser parser = CheASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
parser.setProject(fCompilationUnit.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