com.intellij.psi.PsiArrayType源码实例Demo

类com.intellij.psi.PsiArrayType源码实例Demo

下面列出了com.intellij.psi.PsiArrayType 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: litho   文件: PsiTypeUtils.java
static TypeName getTypeName(PsiType type) {
  if (type instanceof PsiPrimitiveType) {
    // float
    return getPrimitiveTypeName((PsiPrimitiveType) type);
  } else if (type instanceof PsiClassType && ((PsiClassType) type).getParameterCount() > 0) {
    // Set<Integer>
    PsiClassType classType = (PsiClassType) type;
    return ParameterizedTypeName.get(
        guessClassName(classType.rawType().getCanonicalText()),
        getTypeNameArray(classType.getParameters()));
  } else if (type instanceof PsiArrayType) {
    // int[]
    PsiType componentType = ((PsiArrayType) type).getComponentType();
    return ArrayTypeName.of(getTypeName(componentType));
  } else if (type.getCanonicalText().contains("?")) {
    // ? extends Type
    return getWildcardTypeName(type.getCanonicalText());
  } else {
    return guessClassName(type.getCanonicalText());
  }
}
 
源代码2 项目: intellij-spring-assistant   文件: PsiCustomUtil.java
@Nullable
public static PsiType safeGetValidType(@NotNull Module module, @NotNull String fqn) {
  try {
    // Intellij expects inner classes to be referred via `.` instead of `$`
    PsiType type = JavaPsiFacade.getInstance(module.getProject()).getParserFacade()
        .createTypeFromText(fqn.replaceAll("\\$", "."), null);
    boolean typeValid = isValidType(type);
    if (typeValid) {
      if (type instanceof PsiClassType) {
        return PsiClassType.class.cast(type);
      } else if (type instanceof PsiArrayType) {
        return PsiArrayType.class.cast(type);
      }
    }
    return null;
  } catch (IncorrectOperationException e) {
    debug(() -> log.debug("Unable to find class fqn " + fqn));
    return null;
  }
}
 
源代码3 项目: intellij-spring-assistant   文件: PsiCustomUtil.java
public static boolean isValidType(@NotNull PsiType type) {
  if (!type.isValid()) {
    TimeoutUtil.sleep(
        1); // to see if processing in another thread suddenly makes the type valid again (which is a bug)
    if (!type.isValid()) {
      return false;
    }
  }
  if (type instanceof PsiArrayType) {
    return isValidType(PsiArrayType.class.cast(type).getComponentType());
  } else if (type instanceof PsiWildcardType) {
    PsiType bound = ((PsiWildcardType) type).getBound();
    return bound != null && isValidType(bound);
  } else if (type instanceof PsiCapturedWildcardType) {
    PsiType lowerBound = ((PsiCapturedWildcardType) type).getLowerBound();
    type = (lowerBound != NULL ? lowerBound : ((PsiCapturedWildcardType) type).getUpperBound());
    return type != NULL && isValidType(type);
  } else if (type instanceof PsiClassType) {
    PsiClassType.ClassResolveResult classResolveResult = ((PsiClassType) type).resolveGenerics();
    return classResolveResult.isValidResult() && isValidElement(
        requireNonNull(classResolveResult.getElement())) && !hasUnresolvedComponents(type);
  }
  return true;
}
 
@NotNull
public static MetadataProxy newMetadataProxy(Module module, @NotNull PsiType type) {
  if (type instanceof PsiArrayType) {
    return new ArrayMetadataProxy(module, (PsiArrayType) type);
  } else if (type instanceof PsiPrimitiveType) {
    PsiPrimitiveType primitiveType = (PsiPrimitiveType) type;
    type = getBoxedTypeFromPrimitiveType(module, primitiveType);
  }

  if (type instanceof PsiClassType) {
    SuggestionNodeType suggestionNodeType = getSuggestionNodeType(type);
    if (suggestionNodeType == SuggestionNodeType.MAP) {
      return new MapClassMetadataProxy((PsiClassType) type);
    } else {
      return new ClassMetadataProxy((PsiClassType) type);
    }
  }

  throw new IllegalAccessError(
      "Supports only PsiArrayType, PsiPrimitiveType & PsiClassType types");
}
 
源代码5 项目: intellij-quarkus   文件: PsiTypeUtils.java
public static String getResolvedResultTypeName(PsiMethod method) {
    //return method.getReturnType().getCanonicalText();
    PsiType type = method.getReturnType();
    while (type instanceof PsiArrayType) {
        type = ((PsiArrayType)type).getComponentType();
    }
    return type.getCanonicalText();
}
 
源代码6 项目: intellij-spring-assistant   文件: PsiCustomUtil.java
@Nullable
public static Map<PsiTypeParameter, PsiType> getTypeParameters(PsiType type) {
  if (type instanceof PsiArrayType) {
    return getTypeParameters(((PsiArrayType) type).getComponentType());
  } else if (type instanceof PsiPrimitiveType) {
    return null;
  } else if (type instanceof PsiClassType) {
    PsiClassType.ClassResolveResult resolveResult =
        PsiClassType.class.cast(type).resolveGenerics();
    if (resolveResult.isValidResult()) {
      return resolveResult.getSubstitutor().getSubstitutionMap();
    }
  }
  return null;
}
 
源代码7 项目: intellij-spring-assistant   文件: PsiCustomUtil.java
@Nullable
public static String toClassFqn(@NotNull PsiType type) {
  if (type instanceof PsiArrayType) {
    String componentLongName = toClassFqn(PsiArrayType.class.cast(type).getComponentType());
    if (componentLongName != null) {
      return componentLongName + "[]";
    }
  } else if (type instanceof PsiPrimitiveType) {
    return type.getPresentableText();
  } else if (type instanceof PsiClassType) {
    return type.getCanonicalText();
  }
  return null;
}
 
源代码8 项目: intellij-spring-assistant   文件: PsiCustomUtil.java
@Nullable
public static String toClassNonQualifiedName(@NotNull PsiType type) {
  if (type instanceof PsiArrayType) {
    String componentLongName =
        toClassNonQualifiedName(PsiArrayType.class.cast(type).getComponentType());
    if (componentLongName != null) {
      return componentLongName + "[]";
    }
  } else if (type instanceof PsiPrimitiveType) {
    return type.getPresentableText();
  } else if (type instanceof PsiClassType) {
    return ((PsiClassType) type).getClassName();
  }
  return null;
}
 
源代码9 项目: intellij-spring-assistant   文件: PsiCustomUtil.java
@Nullable
public static String typeToFqn(Module module, @NotNull PsiType type) {
  if (isValidType(type)) {
    if (type instanceof PsiArrayType) {
      type = PsiArrayType.class.cast(type).getComponentType();
      return type.getCanonicalText();
    } else if (type instanceof PsiPrimitiveType) {
      return getBoxedTypeFromPrimitiveType(module, (PsiPrimitiveType) type).getCanonicalText();
    } else if (type instanceof PsiClassType) {
      return type.getCanonicalText();
    }
  }
  return null;
}
 
源代码10 项目: intellij-spring-assistant   文件: PsiCustomUtil.java
@Nullable
public static PsiType getComponentType(@NotNull PsiType type) {
  if (type instanceof PsiArrayType) {
    return ((PsiArrayType) type).getComponentType();
  }
  return extractIterableTypeParameter(type, true);
}
 
ArrayMetadataProxy(Module module, @NotNull PsiArrayType type) {
  this.type = type;
  delegate = newMetadataProxy(module, type.getComponentType());
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 类所在包
 类方法
 同包方法