当前位置: 首页>>代码示例>>Java>>正文


Java ASTResolving.getParameterTypeBinding方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.ui.text.correction.ASTResolving.getParameterTypeBinding方法的典型用法代码示例。如果您正苦于以下问题:Java ASTResolving.getParameterTypeBinding方法的具体用法?Java ASTResolving.getParameterTypeBinding怎么用?Java ASTResolving.getParameterTypeBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.ui.text.correction.ASTResolving的用法示例。


在下文中一共展示了ASTResolving.getParameterTypeBinding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public boolean visit(ITypeBinding type) {
  IMethodBinding[] methods = type.getDeclaredMethods();
  for (int i = 0; i < methods.length; i++) {
    IMethodBinding candidate = methods[i];
    if (candidate.getMethodDeclaration() == fOriginalMethod.getMethodDeclaration()) {
      continue;
    }
    ITypeBinding candidateDeclaringType = candidate.getDeclaringClass();
    if (fDeclaringType != candidateDeclaringType) {
      int modifiers = candidate.getModifiers();
      if (candidateDeclaringType.isInterface() && Modifier.isStatic(modifiers)) {
        continue;
      }
      if (Modifier.isPrivate(modifiers)) {
        continue;
      }
    }
    if (fOriginalMethod.getName().equals(candidate.getName())
        && !fOriginalMethod.overrides(candidate)) {
      ITypeBinding[] originalParameterTypes = fOriginalMethod.getParameterTypes();
      ITypeBinding[] candidateParameterTypes = candidate.getParameterTypes();

      boolean couldBeAmbiguous;
      if (originalParameterTypes.length == candidateParameterTypes.length) {
        couldBeAmbiguous = true;
      } else if (fOriginalMethod.isVarargs() || candidate.isVarargs()) {
        int candidateMinArgumentCount = candidateParameterTypes.length;
        if (candidate.isVarargs()) candidateMinArgumentCount--;
        couldBeAmbiguous = fArgumentCount >= candidateMinArgumentCount;
      } else {
        couldBeAmbiguous = false;
      }
      if (couldBeAmbiguous) {
        ITypeBinding parameterType = ASTResolving.getParameterTypeBinding(candidate, fArgIndex);
        if (parameterType != null && parameterType.getFunctionalInterfaceMethod() != null) {
          if (!fExpressionIsExplicitlyTyped) {
            /* According to JLS8 15.12.2.2, implicitly typed lambda expressions are not "pertinent to applicability"
             * and hence potentially applicable methods are always "applicable by strict invocation",
             * regardless of whether argument expressions are compatible with the method's parameter types or not.
             * If there are multiple such methods, 15.12.2.5 results in an ambiguous method invocation.
             */
            return false;
          }
          /* Explicitly typed lambda expressions are pertinent to applicability, and hence
           * compatibility with the corresponding method parameter type is checked. And since this check
           * separates functional interface methods by their void-compatibility state, functional interfaces
           * with a different void compatibility are not applicable any more and hence can't cause
           * an ambiguous method invocation.
           */
          ITypeBinding origParamType =
              ASTResolving.getParameterTypeBinding(fOriginalMethod, fArgIndex);
          boolean originalIsVoidCompatible =
              Bindings.isVoidType(origParamType.getFunctionalInterfaceMethod().getReturnType());
          boolean candidateIsVoidCompatible =
              Bindings.isVoidType(parameterType.getFunctionalInterfaceMethod().getReturnType());
          if (originalIsVoidCompatible == candidateIsVoidCompatible) {
            return false;
          }
        }
      }
    }
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:65,代码来源:ASTNodes.java

示例2: getParameterTypeBinding

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private static ITypeBinding getParameterTypeBinding(
    Expression expression, List<Expression> arguments, IMethodBinding methodBinding) {
  int index = arguments.indexOf(expression);
  return ASTResolving.getParameterTypeBinding(methodBinding, index);
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:ASTNodes.java

示例3: visit

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public boolean visit(ITypeBinding type) {
	IMethodBinding[] methods= type.getDeclaredMethods();
	for (int i= 0; i < methods.length; i++) {
		IMethodBinding candidate= methods[i];
		if (candidate.getMethodDeclaration() == fOriginalMethod.getMethodDeclaration()) {
			continue;
		}
		ITypeBinding candidateDeclaringType= candidate.getDeclaringClass();
		if (fDeclaringType != candidateDeclaringType) {
			int modifiers= candidate.getModifiers();
			if (candidateDeclaringType.isInterface() && Modifier.isStatic(modifiers)) {
				continue;
			}
			if (Modifier.isPrivate(modifiers)) {
				continue;
			}
		}
		if (fOriginalMethod.getName().equals(candidate.getName()) && !fOriginalMethod.overrides(candidate)) {
			ITypeBinding[] originalParameterTypes= fOriginalMethod.getParameterTypes();
			ITypeBinding[] candidateParameterTypes= candidate.getParameterTypes();
			
			boolean couldBeAmbiguous;
			if (originalParameterTypes.length == candidateParameterTypes.length) {
				couldBeAmbiguous= true;
			} else if (fOriginalMethod.isVarargs() || candidate.isVarargs() ) {
				int candidateMinArgumentCount= candidateParameterTypes.length;
				if (candidate.isVarargs())
					candidateMinArgumentCount--;
				couldBeAmbiguous= fArgumentCount >= candidateMinArgumentCount;
			} else {
				couldBeAmbiguous= false;
			}
			if (couldBeAmbiguous) {
				ITypeBinding parameterType= ASTResolving.getParameterTypeBinding(candidate, fArgIndex);
				if (parameterType != null && parameterType.getFunctionalInterfaceMethod() != null) {
					if (!fExpressionIsExplicitlyTyped) {
						/* According to JLS8 15.12.2.2, implicitly typed lambda expressions are not "pertinent to applicability"
						 * and hence potentially applicable methods are always "applicable by strict invocation",
						 * regardless of whether argument expressions are compatible with the method's parameter types or not.
						 * If there are multiple such methods, 15.12.2.5 results in an ambiguous method invocation.
						 */
						return false;
					}
					/* Explicitly typed lambda expressions are pertinent to applicability, and hence
					 * compatibility with the corresponding method parameter type is checked. And since this check
					 * separates functional interface methods by their void-compatibility state, functional interfaces
					 * with a different void compatibility are not applicable any more and hence can't cause
					 * an ambiguous method invocation.
					 */
					ITypeBinding origParamType= ASTResolving.getParameterTypeBinding(fOriginalMethod, fArgIndex);
					boolean originalIsVoidCompatible=  Bindings.isVoidType(origParamType.getFunctionalInterfaceMethod().getReturnType());
					boolean candidateIsVoidCompatible= Bindings.isVoidType(parameterType.getFunctionalInterfaceMethod().getReturnType());
					if (originalIsVoidCompatible == candidateIsVoidCompatible) {
						return false;
					}
				}
			}
		}
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:62,代码来源:ASTNodes.java

示例4: getParameterTypeBinding

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
private static ITypeBinding getParameterTypeBinding(Expression expression, List<Expression> arguments, IMethodBinding methodBinding) {
	int index= arguments.indexOf(expression);
	return ASTResolving.getParameterTypeBinding(methodBinding, index);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:5,代码来源:ASTNodes.java


注:本文中的org.eclipse.jdt.internal.ui.text.correction.ASTResolving.getParameterTypeBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。