use of org.eclipse.jdt.core.dom.IMethodBinding in project che by eclipse.
the class AbstractExceptionAnalyzer method visit.
@Override
public boolean visit(VariableDeclarationExpression node) {
if (node.getLocationInParent() == TryStatement.RESOURCES_PROPERTY) {
Type type = node.getType();
ITypeBinding resourceTypeBinding = type.resolveBinding();
if (resourceTypeBinding != null) {
//$NON-NLS-1$
IMethodBinding methodBinding = Bindings.findMethodInHierarchy(resourceTypeBinding, "close", new ITypeBinding[0]);
if (methodBinding != null) {
addExceptions(methodBinding.getExceptionTypes(), node.getAST());
}
}
}
return super.visit(node);
}
use of org.eclipse.jdt.core.dom.IMethodBinding 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.IMethodBinding 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.IMethodBinding in project che by eclipse.
the class TypeChangeCorrectionProposal method sortTypes.
private void sortTypes(ITypeBinding[] typeProposals) {
ITypeBinding oldType;
if (fBinding instanceof IMethodBinding) {
oldType = ((IMethodBinding) fBinding).getReturnType();
} else {
oldType = ((IVariableBinding) fBinding).getType();
}
if (!oldType.isParameterizedType())
return;
final ITypeBinding oldTypeDeclaration = oldType.getTypeDeclaration();
Arrays.sort(typeProposals, new Comparator<ITypeBinding>() {
public int compare(ITypeBinding o1, ITypeBinding o2) {
return rank(o2) - rank(o1);
}
private int rank(ITypeBinding type) {
if (type.getTypeDeclaration().equals(oldTypeDeclaration))
return 1;
return 0;
}
});
}
use of org.eclipse.jdt.core.dom.IMethodBinding in project che by eclipse.
the class BindingLabelProvider method getAdornmentFlags.
/*extends LabelProvider */
private static int getAdornmentFlags(IBinding binding) {
int adornments = 0;
final int modifiers = binding.getModifiers();
if (Modifier.isAbstract(modifiers))
adornments |= JavaElementImageDescriptor.ABSTRACT;
if (Modifier.isFinal(modifiers))
adornments |= JavaElementImageDescriptor.FINAL;
if (Modifier.isStatic(modifiers))
adornments |= JavaElementImageDescriptor.STATIC;
if (binding.isDeprecated())
adornments |= JavaElementImageDescriptor.DEPRECATED;
if (binding instanceof IMethodBinding) {
if (((IMethodBinding) binding).isConstructor())
adornments |= JavaElementImageDescriptor.CONSTRUCTOR;
if (Modifier.isSynchronized(modifiers))
adornments |= JavaElementImageDescriptor.SYNCHRONIZED;
if (Modifier.isNative(modifiers))
adornments |= JavaElementImageDescriptor.NATIVE;
ITypeBinding type = ((IMethodBinding) binding).getDeclaringClass();
if (type.isInterface() && !Modifier.isAbstract(modifiers) && !Modifier.isStatic(modifiers))
adornments |= JavaElementImageDescriptor.DEFAULT_METHOD;
if (((IMethodBinding) binding).getDefaultValue() != null)
adornments |= JavaElementImageDescriptor.ANNOTATION_DEFAULT;
}
if (binding instanceof IVariableBinding && ((IVariableBinding) binding).isField()) {
if (Modifier.isTransient(modifiers))
adornments |= JavaElementImageDescriptor.TRANSIENT;
if (Modifier.isVolatile(modifiers))
adornments |= JavaElementImageDescriptor.VOLATILE;
}
return adornments;
}
Aggregations