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


Java Signature.getParameterTypes方法代码示例

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


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

示例1: resolveMethodSignature

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Copied from org.eclipse.jdt.internal.debug.ui.actions.ToggleBreakpointAdapter
 * TODO: is there a public API to do this?
 *
 * Returns the resolved signature of the given method
 * @param method method to resolve
 * @return the resolved method signature or <code>null</code> if none
 * @throws JavaModelException
 * @since 3.4
 */
public static String resolveMethodSignature(IMethod method) throws JavaModelException {
	String signature = method.getSignature();
	String[] parameterTypes = Signature.getParameterTypes(signature);
	int length = parameterTypes.length;
	String[] resolvedParameterTypes = new String[length];
	for (int i = 0; i < length; i++) {
		resolvedParameterTypes[i] = resolveTypeSignature(method, parameterTypes[i]);
		if (resolvedParameterTypes[i] == null) {
			return null;
		}
	}
	String resolvedReturnType = resolveTypeSignature(method, Signature.getReturnType(signature));
	if (resolvedReturnType == null) {
		return null;
	}
	return Signature.createMethodSignature(resolvedParameterTypes, resolvedReturnType);
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:28,代码来源:BreakpointLocator.java

示例2: appendUnboundedParameterList

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Appends the parameter list to <code>buffer</code>.
 *
 * @param buffer the buffer to append to
 * @param methodProposal the method proposal
 * @return the modified <code>buffer</code>
 */
private StringBuilder appendUnboundedParameterList(StringBuilder buffer, CompletionProposal methodProposal) {
	// TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
	// gets fixed.
	char[] signature= SignatureUtil.fix83600(methodProposal.getSignature());
	char[][] parameterNames= methodProposal.findParameterNames(null);
	char[][] parameterTypes= Signature.getParameterTypes(signature);

	for (int i= 0; i < parameterTypes.length; i++) {
		parameterTypes[i]= createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i]));
	}

	if (Flags.isVarargs(methodProposal.getFlags())) {
		int index= parameterTypes.length - 1;
		parameterTypes[index]= convertToVararg(parameterTypes[index]);
	}
	return appendParameterSignature(buffer, parameterTypes, parameterNames);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:25,代码来源:CompletionProposalDescriptionProvider.java

示例3: appendUnboundedParameterList

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Appends the parameter list to <code>buffer</code>.
 *
 * @param buffer the buffer to append to
 * @param methodProposal the method proposal
 * @return the modified <code>buffer</code>
 */
private StyledString appendUnboundedParameterList(
    StyledString buffer, CompletionProposal methodProposal) {
  // TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
  // gets fixed.
  char[] signature = SignatureUtil.fix83600(methodProposal.getSignature());
  char[][] parameterNames = methodProposal.findParameterNames(null);
  char[][] parameterTypes = Signature.getParameterTypes(signature);

  for (int i = 0; i < parameterTypes.length; i++)
    parameterTypes[i] = createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i]));

  if (Flags.isVarargs(methodProposal.getFlags())) {
    int index = parameterTypes.length - 1;
    parameterTypes[index] = convertToVararg(parameterTypes[index]);
  }
  return appendParameterSignature(buffer, parameterTypes, parameterNames);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:CompletionProposalLabelProvider.java

示例4: unboundedSignature

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Takes a method signature <code>
 * [&lt; typeVariableName : formalTypeDecl &gt;] ( paramTypeSig1* ) retTypeSig</code> and returns
 * it with any parameter signatures filtered through <code>getLowerBound</code> and the return
 * type filtered through <code>getUpperBound</code>. Any preceding formal type variable
 * declarations are removed.
 *
 * <p>TODO this is a temporary workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=83600
 *
 * @param signature the method signature to convert
 * @return the signature with no bounded types
 */
public static char[] unboundedSignature(char[] signature) {
  if (signature == null || signature.length < 2) return signature;

  final boolean BUG_83600 = true;
  // XXX the signatures from CompletionRequestor contain a superfluous '+'
  // before type parameters to parameter types
  if (BUG_83600) {
    signature = fix83600(signature);
  }

  StringBuffer res = new StringBuffer("("); // $NON-NLS-1$
  char[][] parameters = Signature.getParameterTypes(signature);
  for (int i = 0; i < parameters.length; i++) {
    char[] param = parameters[i];
    res.append(getLowerBound(param));
  }
  res.append(')');
  res.append(getUpperBound(Signature.getReturnType(signature)));
  return res.toString().toCharArray();
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:SignatureUtil.java

示例5: resolveMember

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Resolves the member described by the receiver and returns it if found. Returns <code>null
 * </code> if no corresponding member can be found.
 *
 * @return the resolved member or <code>null</code> if none is found
 * @throws org.eclipse.jdt.core.JavaModelException if accessing the java model fails
 */
@Override
protected IMember resolveMember() throws JavaModelException {
  char[] declarationSignature = fProposal.getDeclarationSignature();
  String typeName = SignatureUtil.stripSignatureToFQN(String.valueOf(declarationSignature));
  IType type = fJavaProject.findType(typeName);
  if (type != null) {
    String name = String.valueOf(fProposal.getName());
    String[] parameters =
        Signature.getParameterTypes(
            String.valueOf(SignatureUtil.fix83600(fProposal.getSignature())));
    for (int i = 0; i < parameters.length; i++) {
      parameters[i] = SignatureUtil.getLowerBound(parameters[i]);
    }
    boolean isConstructor = fProposal.isConstructor();

    return findMethod(name, parameters, isConstructor, type);
  }

  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:MethodProposalInfo.java

示例6: toSignatureInformation

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public SignatureInformation toSignatureInformation(CompletionProposal methodProposal) {
	SignatureInformation $ = new SignatureInformation();
	StringBuilder desription = descriptionProvider.createMethodProposalDescription(methodProposal);
	$.setLabel(desription.toString());
	$.setDocumentation(this.computeJavaDoc(methodProposal));

	char[] signature = SignatureUtil.fix83600(methodProposal.getSignature());
	char[][] parameterNames = methodProposal.findParameterNames(null);
	char[][] parameterTypes = Signature.getParameterTypes(signature);

	for (int i = 0; i < parameterTypes.length; i++) {
		parameterTypes[i] = Signature.getSimpleName(Signature.toCharArray(SignatureUtil.getLowerBound(parameterTypes[i])));
	}

	if (Flags.isVarargs(methodProposal.getFlags())) {
		int index = parameterTypes.length - 1;
		parameterTypes[index] = convertToVararg(parameterTypes[index]);
	}

	List<ParameterInformation> parameterInfos = new LinkedList<>();
	for (int i = 0; i < parameterTypes.length; i++) {
		StringBuilder builder = new StringBuilder();
		builder.append(parameterTypes[i]);
		builder.append(' ');
		builder.append(parameterNames[i]);

		parameterInfos.add(new ParameterInformation(builder.toString(), null));
	}

	$.setParameters(parameterInfos);

	return $;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:34,代码来源:SignatureHelpRequestor.java

示例7: getAssignableElements

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private IJavaElement[][] getAssignableElements() {
  char[] signature = SignatureUtil.fix83600(getProposal().getSignature());
  char[][] types = Signature.getParameterTypes(signature);

  IJavaElement[][] assignableElements = new IJavaElement[types.length][];
  for (int i = 0; i < types.length; i++) {
    assignableElements[i] = fCoreContext.getVisibleElements(new String(types[i]));
  }
  return assignableElements;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:ParameterGuessingProposal.java

示例8: getParameterTypes

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private String[] getParameterTypes() {
  char[] signature = SignatureUtil.fix83600(fProposal.getSignature());
  char[][] types = Signature.getParameterTypes(signature);

  String[] ret = new String[types.length];
  for (int i = 0; i < types.length; i++) {
    ret[i] = new String(Signature.toCharArray(types[i]));
  }
  return ret;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:ParameterGuessingProposal.java

示例9: toAnchor

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
public static char[] toAnchor(
    int startingIndex, char[] methodSignature, char[] methodName, boolean isVargArgs) {
  int firstParen = CharOperation.indexOf(Signature.C_PARAM_START, methodSignature);
  if (firstParen == -1) {
    throw new IllegalArgumentException();
  }

  StringBuffer buffer = new StringBuffer(methodSignature.length + 10);

  // selector
  if (methodName != null) {
    buffer.append(methodName);
  }

  // parameters
  buffer.append('(');
  char[][] pts = Signature.getParameterTypes(methodSignature);
  for (int i = startingIndex, max = pts.length; i < max; i++) {
    if (i == max - 1) {
      appendTypeSignatureForAnchor(pts[i], 0, buffer, isVargArgs);
    } else {
      appendTypeSignatureForAnchor(pts[i], 0, buffer, false);
    }
    if (i != pts.length - 1) {
      buffer.append(',');
      buffer.append(' ');
    }
  }
  buffer.append(')');
  char[] result = new char[buffer.length()];
  buffer.getChars(0, buffer.length(), result, 0);
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:Util.java

示例10: getParamTypesSignature

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private static String getParamTypesSignature(CompletionProposal proposal) {
  String[] paramTypes = Signature.getParameterTypes(new String(
      proposal.getSignature()));

  // JSNI refs must use /'s to separate qualifier segments
  return StringUtilities.join(paramTypes, "").replace('.', '/');
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:8,代码来源:JsniCompletionProposal.java

示例11: isSameMethodSignature

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
 * Tests if a method equals to the given signature. Parameter types are only compared by the
 * simple name, no resolving for the fully qualified type name is done. Constructors are only
 * compared by parameters, not the name.
 *
 * @param name Name of the method
 * @param paramTypes The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
 * @param isConstructor Specifies if the method is a constructor
 * @param method the method to be compared with this info's method
 * @param typeVariables a map from type variables to types
 * @param type the given type that declares the method
 * @return Returns <code>true</code> if the method has the given name and parameter types and
 *     constructor state.
 * @throws org.eclipse.jdt.core.JavaModelException if the method does not exist or if an exception
 *     occurs while accessing its corresponding resource
 */
private boolean isSameMethodSignature(
    String name,
    String[] paramTypes,
    boolean isConstructor,
    IMethod method,
    Map<String, char[]> typeVariables,
    IType type)
    throws JavaModelException {
  if (isConstructor || name.equals(method.getElementName())) {
    if (isConstructor == method.isConstructor()) {
      String[] otherParams = method.getParameterTypes(); // types may be type variables
      boolean isBinaryConstructorForNonStaticMemberClass =
          method.isBinary() && type.isMember() && !Flags.isStatic(type.getFlags());
      int syntheticParameterCorrection =
          isBinaryConstructorForNonStaticMemberClass
                  && paramTypes.length == otherParams.length - 1
              ? 1
              : 0;
      if (paramTypes.length == otherParams.length - syntheticParameterCorrection) {
        fFallbackMatch = method;
        String signature = method.getSignature();
        String[] otherParamsFromSignature =
            Signature.getParameterTypes(signature); // types are resolved / upper-bounded
        // no need to check method type variables since these are
        // not yet bound when proposing a method
        for (int i = 0; i < paramTypes.length; i++) {
          String ourParamName = computeSimpleTypeName(paramTypes[i], typeVariables);
          String otherParamName1 =
              computeSimpleTypeName(otherParams[i + syntheticParameterCorrection], typeVariables);
          String otherParamName2 =
              computeSimpleTypeName(
                  otherParamsFromSignature[i + syntheticParameterCorrection], typeVariables);

          if (!ourParamName.equals(otherParamName1) && !ourParamName.equals(otherParamName2)) {
            return false;
          }
        }
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:60,代码来源:MethodProposalInfo.java

示例12: methodSignaturesEqual

import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
private static boolean methodSignaturesEqual(IType type2, String methodName,
    String[] paramTypes, boolean isConstructor, IMethod method2) {
  try {
    // Method names must match, unless we're comparing constructors
    if (!isConstructor && !method2.getElementName().equals(methodName)) {
      return false;
    }

    // Only compare ctors to ctors and methods to methods
    if (isConstructor != method2.isConstructor()) {
      return false;
    }

    // Parameter count must match
    String signature2 = method2.getSignature();
    String[] paramTypes2 = Signature.getParameterTypes(signature2);
    if (paramTypes.length != paramTypes2.length) {
      return false;
    }

    // Compare each parameter type
    for (int i = 0; i < paramTypes.length; i++) {
      String paramType = paramTypes[i];
      String paramType2 = paramTypes2[i];

      // Compare array nesting depth ([] = 1, [][] = 2, etc.)
      if (Signature.getArrayCount(paramType) != Signature.getArrayCount(paramType2)) {
        return false;
      }

      // Remove any array nesting and generic type parameters
      paramType = getBaseType(paramType);
      paramType2 = getBaseType(paramType2);

      // Extract the full type names from the signatures
      String paramTypeName = getQualifiedTypeName(paramType);
      String paramTypeName2 = getQualifiedTypeName(paramType2);

      if (isTypeParameter(method2, paramTypeName2)) {
        // Skip parameters whose type is a generic type parameter of the
        // method we're comparing against, or the method's containing class
        continue;

        /*
         * TODO: we're currently not checking the bounds of generic type
         * parameters, so sometimes we may return true here even when the
         * caller's method signature doesn't match the method we're comparing
         * against. We could try to add that logic here, or better still, we
         * could integrate TypeOracle and take advantage of its type searching
         * capabilities.
         */
      }

      // If we run into an unresolved parameter type in the method we're
      // searching, we'll need to resolve that before doing the comparison
      if (paramType2.charAt(0) == Signature.C_UNRESOLVED) {
        paramTypeName2 = resolveTypeName(type2, paramTypeName2);
      }

      // Finally, compare the type names
      if (!paramTypeName.equals(paramTypeName2)) {
        return false;
      }
    }

    // We passed all the checks, so the signatures are equal
    return true;

  } catch (JavaModelException e) {
    CorePluginLog.logError(e,
        "Error comparing method signatures of {0} and {1}", methodName,
        method2.getElementName());
    return false;
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:76,代码来源:JavaModelSearch.java


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