Java Code Examples for com.intellij.psi.PsiType#getCanonicalText()

The following examples show how to use com.intellij.psi.PsiType#getCanonicalText() . 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: InvalidConfigTypeDetector.java    From aircon with MIT License 6 votes vote down vote up
@Override
protected void visitConfigTypeAnnotation(final UAnnotation node, final UClass owner) {
	final UMethod defaultValueMethod = getDefaultValueMethod(owner);
	if (defaultValueMethod == null) {
		return;
	}

	final PsiType type = defaultValueMethod.getReturnType();
	if (isOneOfTypes(type, String.class, Float.class, Integer.class, Long.class, Boolean.class)) {
		return;
	}

	final String typeName = type.getCanonicalText();
	if (typeName.equals(PRIMITIVE_FLOAT) || typeName.equals(PRIMITIVE_INT) || typeName.equals(PRIMITIVE_LONG) || typeName.equals(PRIMITIVE_BOOLEAN)) {
		return;
	}

	log(typeName);

	reportPsi(owner.getNameIdentifier());
}
 
Example 2
Source File: SpringConfigurationMetadataHintValue.java    From intellij-spring-assistant with MIT License 6 votes vote down vote up
@NotNull
public String getDocumentationForValue(@NotNull String nodeNavigationPathDotDelimited,
    @Nullable PsiType mapValueType) {
  StringBuilder builder =
      new StringBuilder().append("<b>").append(nodeNavigationPathDotDelimited).append("</b>= <b>")
          .append(unescapeValue(unescapeValue(toString()))).append("</b>");

  if (mapValueType != null) {
    String className = mapValueType.getCanonicalText();
    builder.append(" (");
    updateClassNameAsJavadocHtml(builder, className);
    builder.append(")");
  }

  if (description != null) {
    builder.append("<p>").append(description).append("</p>");
  }

  return builder.toString();
}
 
Example 3
Source File: PsiTypeUtils.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
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();
}
 
Example 4
Source File: PsiCustomUtil.java    From intellij-spring-assistant with MIT License 5 votes vote down vote up
@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;
}
 
Example 5
Source File: PsiCustomUtil.java    From intellij-spring-assistant with MIT License 5 votes vote down vote up
@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;
}
 
Example 6
Source File: PsiUtils.java    From data-mediator with Apache License 2.0 5 votes vote down vote up
public static String getNonGenericType(PsiType type) {
    if (type instanceof PsiClassType) {
        PsiClassType pct = (PsiClassType) type;
        final PsiClass psiClass = pct.resolve();

        return psiClass != null ? psiClass.getQualifiedName() : null;
    }

    return type.getCanonicalText();
}
 
Example 7
Source File: PsiUtils.java    From android-parcelable-intellij-plugin with Apache License 2.0 5 votes vote down vote up
public static String getNonGenericType(PsiType type) {
    if (type instanceof PsiClassType) {
        PsiClassType pct = (PsiClassType) type;
        final PsiClass psiClass = pct.resolve();

        return psiClass != null ? psiClass.getQualifiedName() : null;
    }

    return type.getCanonicalText();
}