org.eclipse.jdt.core.Signature.getTypeErasure()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中org.eclipse.jdt.core.Signature.getTypeErasure()方法的一些代码示例,展示了Signature.getTypeErasure()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Signature.getTypeErasure()方法的具体详情如下:
包路径:org.eclipse.jdt.core.Signature
类名称:Signature
方法名:getTypeErasure

Signature.getTypeErasure介绍

[英]Extracts the type erasure signature from the given parameterized type signature. Returns the given type signature if it is not parameterized.
[中]从给定的参数化类型签名中提取类型擦除签名。如果未参数化,则返回给定的类型签名。

代码示例

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

private String [] getErasedParameterTypes() {
  if (this.erasedParamaterTypes == null) {
    int paramCount = this.parameterTypes.length;
    String [] erasedTypes = new String [paramCount];
    boolean erasureNeeded = false;
    for (int i = 0; i < paramCount; i++) {
      String parameterType = this.parameterTypes[i];
      if ((erasedTypes[i] = Signature.getTypeErasure(parameterType)) != parameterType)
        erasureNeeded = true;
    }
    this.erasedParamaterTypes = erasureNeeded ? erasedTypes : this.parameterTypes;
  }
  return this.erasedParamaterTypes;
}
private String getErasedParameterType(int index) {

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

private String [] getErasedParameterTypes() {
  if (this.erasedParamaterTypes == null) {
    int paramCount = this.parameterTypes.length;
    String [] erasedTypes = new String [paramCount];
    boolean erasureNeeded = false;
    for (int i = 0; i < paramCount; i++) {
      String parameterType = this.parameterTypes[i];
      if ((erasedTypes[i] = Signature.getTypeErasure(parameterType)) != parameterType)
        erasureNeeded = true;
    }
    this.erasedParamaterTypes = erasureNeeded ? erasedTypes : this.parameterTypes;
  }
  return this.erasedParamaterTypes;
}
private String getErasedParameterType(int index) {

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

private String [] getErasedParameterTypes() {
  if (this.erasedParamaterTypes == null) {
    int paramCount = this.parameterTypes.length;
    String [] erasedTypes = new String [paramCount];
    boolean erasureNeeded = false;
    for (int i = 0; i < paramCount; i++) {
      String parameterType = this.parameterTypes[i];
      if ((erasedTypes[i] = Signature.getTypeErasure(parameterType)) != parameterType)
        erasureNeeded = true;
    }
    this.erasedParamaterTypes = erasureNeeded ? erasedTypes : this.parameterTypes;
  }
  return this.erasedParamaterTypes;
}
private String getErasedParameterType(int index) {

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

private String [] getErasedParameterTypes() {
  if (this.erasedParamaterTypes == null) {
    int paramCount = this.parameterTypes.length;
    String [] erasedTypes = new String [paramCount];
    boolean erasureNeeded = false;
    for (int i = 0; i < paramCount; i++) {
      String parameterType = this.parameterTypes[i];
      if ((erasedTypes[i] = Signature.getTypeErasure(parameterType)) != parameterType)
        erasureNeeded = true;
    }
    this.erasedParamaterTypes = erasureNeeded ? erasedTypes : this.parameterTypes;
  }
  return this.erasedParamaterTypes;
}
private String getErasedParameterType(int index) {

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

public final String getQualifiedTypeName() {
  if (fQualifiedName == null)
    fQualifiedName= String.valueOf(Signature.toCharArray(Signature.getTypeErasure(fProposal.getSignature())));
  return fQualifiedName;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

public final String getQualifiedTypeName() {
  if (fQualifiedName == null)
    fQualifiedName= String.valueOf(Signature.toCharArray(Signature.getTypeErasure(fProposal.getSignature())));
  return fQualifiedName;
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

public final String getQualifiedTypeName() {
  if (fQualifiedName == null)
    fQualifiedName= String.valueOf(Signature.toCharArray(Signature.getTypeErasure(fProposal.getSignature())));
  return fQualifiedName;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation

public static String getQualifiedTypeName(CompletionProposal proposal) {
  return String.valueOf(Signature.toCharArray(Signature
      .getTypeErasure(proposal.getSignature())));
}

代码示例来源:origin: org.eclipse/org.eclipse.jst.j2ee

private void getImportStatements(String signature, IType declaringType) throws JavaModelException{
  String erasure = Signature.getTypeErasure(signature);
  String resolvedTypeName = JavaModelUtil.getResolvedTypeName(erasure, declaringType);
  if (resolvedTypeName != null && !importStatements.contains(resolvedTypeName) && !resolvedTypeName.startsWith("java.lang")) { //$NON-NLS-1$
    importStatements.add(resolvedTypeName);
  }
  String [] params = Signature.getTypeArguments(signature);
  for(int i=0;i<params.length; i++){
    getImportStatements(params[i], declaringType);
  }
}

代码示例来源:origin: eclipse/eclipse.jdt.ls

/**
 * Returns the simple name of the given type signature.
 *
 * @param enclosingElement the enclosing element in which to resolve the signature
 * @param typeSig a {@link Signature#CLASS_TYPE_SIGNATURE} or {@link Signature#TYPE_VARIABLE_SIGNATURE}
 * @return the simple name of the given type signature
 */
protected String getSimpleTypeName(IJavaElement enclosingElement, String typeSig) {
  return Signature.getSimpleName(Signature.toString(Signature.getTypeErasure(typeSig)));
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

/**
 * Extracts the fully qualified name of the declaring type of a method
 * reference.
 *
 * @param methodProposal a proposed method
 * @return the qualified name of the declaring type
 */
private String extractDeclaringTypeFQN(CompletionProposal methodProposal) {
  char[] declaringTypeSignature= methodProposal.getDeclarationSignature();
  // special methods may not have a declaring type: methods defined on arrays etc.
  // TODO remove when bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690 gets fixed
  if (declaringTypeSignature == null)
    return "java.lang.Object"; //$NON-NLS-1$
  return Signature.toString(Signature.getTypeErasure(String.valueOf(declaringTypeSignature)));
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

/**
 * Returns the fully qualified type name of the given signature, with any
 * type parameters and arrays erased.
 * 
 * @param signature the signature
 * @return the fully qualified type name of the signature
 */
public static String stripSignatureToFQN(String signature) throws IllegalArgumentException {
  signature= Signature.getTypeErasure(signature);
  signature= Signature.getElementType(signature);
  return Signature.toString(signature);
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation

/**
 * Returns the simple name of the given type signature.
 *
 * @param enclosingElement the enclosing element in which to resolve the signature
 * @param typeSig a {@link Signature#CLASS_TYPE_SIGNATURE} or {@link Signature#TYPE_VARIABLE_SIGNATURE}
 * @return the simple name of the given type signature
 */
protected String getSimpleTypeName(IJavaElement enclosingElement, String typeSig) {
  return Signature.getSimpleName(Signature.toString(Signature.getTypeErasure(typeSig)));
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

/**
 * Returns the simple name of the given type signature.
 *
 * @param enclosingElement the enclosing element in which to resolve the signature
 * @param typeSig a {@link Signature#CLASS_TYPE_SIGNATURE} or {@link Signature#TYPE_VARIABLE_SIGNATURE}
 * @return the simple name of the given type signature
 */
protected String getSimpleTypeName(IJavaElement enclosingElement, String typeSig) {
  return Signature.getSimpleName(Signature.toString(Signature.getTypeErasure(typeSig)));
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation

/**
 * Returns the fully qualified type name of the given signature, with any
 * type parameters and arrays erased.
 *
 * @param signature the signature
 * @return the fully qualified type name of the signature
 * @throws IllegalArgumentException if the signature is syntactically incorrect
 */
public static String stripSignatureToFQN(String signature) throws IllegalArgumentException {
  signature= Signature.getTypeErasure(signature);
  signature= Signature.getElementType(signature);
  return Signature.toString(signature);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

/**
 * Returns the fully qualified type name of the given signature, with any
 * type parameters and arrays erased.
 *
 * @param signature the signature
 * @return the fully qualified type name of the signature
 * @throws IllegalArgumentException if the signature is syntactically incorrect
 */
public static String stripSignatureToFQN(String signature) throws IllegalArgumentException {
  signature= Signature.getTypeErasure(signature);
  signature= Signature.getElementType(signature);
  return Signature.toString(signature);
}

代码示例来源:origin: eclipse/eclipse.jdt.ls

private void addType(char[] typeNameSig, int flags, int relevance) {
  int kind= getKind(flags, typeNameSig);
  if (!isKind(kind)) {
    return;
  }
  String fullName= new String(Signature.toCharArray(Signature.getTypeErasure(typeNameSig)));
  //		if (TypeFilter.isFiltered(fullName)) {  // requires jdt.ui preferences
  //			return;
  //		}
  if (NameMatcher.isSimilarName(fName, Signature.getSimpleName(fullName))) {
    addResult(new SimilarElement(kind, fullName, relevance));
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

private void addType(char[] typeNameSig, int flags, int relevance) {
  int kind= getKind(flags, typeNameSig);
  if (!isKind(kind)) {
    return;
  }
  String fullName= new String(Signature.toCharArray(Signature.getTypeErasure(typeNameSig)));
  if (TypeFilter.isFiltered(fullName)) {
    return;
  }
  if (NameMatcher.isSimilarName(fName, Signature.getSimpleName(fullName))) {
    addResult(new SimilarElement(kind, fullName, relevance));
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

private void addType(char[] typeNameSig, int flags, int relevance) {
  int kind= getKind(flags, typeNameSig);
  if (!isKind(kind)) {
    return;
  }
  String fullName= new String(Signature.toCharArray(Signature.getTypeErasure(typeNameSig)));
  if (TypeFilter.isFiltered(fullName)) {
    return;
  }
  if (NameMatcher.isSimilarName(fName, Signature.getSimpleName(fullName))) {
    addResult(new SimilarElement(kind, fullName, relevance));
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

private void addType(char[] typeNameSig, int flags, int relevance) {
  int kind= getKind(flags, typeNameSig);
  if (!isKind(kind)) {
    return;
  }
  String fullName= new String(Signature.toCharArray(Signature.getTypeErasure(typeNameSig)));
  if (TypeFilter.isFiltered(fullName)) {
    return;
  }
  if (NameMatcher.isSimilarName(fName, Signature.getSimpleName(fullName))) {
    addResult(new SimilarElement(kind, fullName, relevance));
  }
}

相关文章