Java Code Examples for org.eclipse.jdt.core.dom.ITypeBinding#getDeclaringMethod()

The following examples show how to use org.eclipse.jdt.core.dom.ITypeBinding#getDeclaringMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ASTResolving.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean isVariableDefinedInContext(IBinding binding, ITypeBinding typeVariable) {
	if (binding.getKind() == IBinding.VARIABLE) {
		IVariableBinding var= (IVariableBinding) binding;
		binding= var.getDeclaringMethod();
		if (binding == null) {
			binding= var.getDeclaringClass();
		}
	}
	if (binding instanceof IMethodBinding) {
		if (binding == typeVariable.getDeclaringMethod()) {
			return true;
		}
		binding= ((IMethodBinding) binding).getDeclaringClass();
	}

	while (binding instanceof ITypeBinding) {
		if (binding == typeVariable.getDeclaringClass()) {
			return true;
		}
		if (Modifier.isStatic(binding.getModifiers())) {
			break;
		}
		binding= ((ITypeBinding) binding).getDeclaringClass();
	}
	return false;
}
 
Example 2
Source File: JdtUtils.java    From j2cl with Apache License 2.0 5 votes vote down vote up
private static IBinding getDeclaringMember(ITypeBinding typeBinding) {
  ITypeBinding typeDeclaration = typeBinding.getTypeDeclaration();
  IBinding declaringMember = typeDeclaration.getDeclaringMember();
  if (declaringMember == null) {
    // Work around for b/147690014, in which getDeclaringMember returns null, but there is
    // a declaring member and is returned by getDeclaringMethod.
    declaringMember = typeDeclaration.getDeclaringMethod();
  }
  return declaringMember;
}
 
Example 3
Source File: TypeURIHelper.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void createFragmentForTypeVariable(ITypeBinding typeBinding, StringBuilder uriBuilder) {
	if (typeBinding.getDeclaringMethod() != null) {
		createFragmentForMethod(typeBinding.getDeclaringMethod(), uriBuilder);
	} else {
		createFragment(typeBinding.getDeclaringClass(), uriBuilder);
	}
	uriBuilder.append('/');
	uriBuilder.append(typeBinding.getName());
}