@Override protected void selectActionPerformed(AnActionEvent event, PsiElement element, String packageName) { if (!Utils.isAndroidClass(packageName)) { NotificationUtils.infoNotification("Must be Android class or Method"); return; } String linkUrl = BASE_URL; if (element instanceof PsiMethod) { PsiMethod psiMethod = (PsiMethod) element; PsiParameter[] parameters = psiMethod.getParameterList().getParameters(); StringBuilder paramsBuilder = new StringBuilder("#" + psiMethod.getName()); paramsBuilder.append("("); for (int i = 0; i < parameters.length; i++) { PsiParameter parameter = parameters[i]; paramsBuilder.append(parameter.getType().getCanonicalText()); if (i < parameters.length - 1) { paramsBuilder.append(",%20"); } } paramsBuilder.append(")"); linkUrl += getRealPackage(psiMethod.getContainingClass()) + paramsBuilder.toString(); } else if (element instanceof PsiClass) { PsiClass psiClass = (PsiClass) element; linkUrl += getRealPackage(psiClass); } LOG.info("linkUrl= " + linkUrl); Utils.openUrl(linkUrl); }
} else if (element instanceof PsiVariable) { PsiVariable psiVariable = (PsiVariable) element; packageName = psiVariable.getType().getCanonicalText(); Log.debug("PsiVariable:" + psiVariable.getType().getCanonicalText()); } else { Log.debug("cls = " + element.getClass());
@Override public String fun(PsiType psiType) { return psiType.getCanonicalText(annotated); } }, " | ");
private static boolean isCharacterType(PsiType type) { //return PsiType.CHAR.isAssignableFrom(type); if (type == PsiType.CHAR) { return true; } if (type instanceof PsiClassType) { String fqn = type.getCanonicalText(); return TYPE_CHARACTER_WRAPPER.equals(fqn); } return false; }
private static boolean isBooleanType(PsiType type) { //return PsiType.BOOLEAN.isAssignableFrom(type); if (type == PsiType.BOOLEAN) { return true; } if (type instanceof PsiClassType) { String fqn = type.getCanonicalText(); return TYPE_BOOLEAN_WRAPPER.equals(fqn); } return false; }
@NotNull @Override public String getCanonicalText(boolean annotated) { return myConjuncts[0].getCanonicalText(annotated); }
@NotNull @Override public String getCanonicalText(boolean annotated) { return getText(myComponentType.getCanonicalText(annotated), "[]", true, annotated); }
@Override @NotNull public String getCanonicalText(boolean annotated) { return getText(true, annotated, myBound == null ? null : myBound.getCanonicalText(annotated)); }
public static boolean isFromExternalTypeLanguage(@NotNull PsiType type) { String internalCanonicalText = type.getInternalCanonicalText(); return internalCanonicalText != null && internalCanonicalText.equals(type.getCanonicalText()); }
public static boolean isString(@NonNull PsiType type) { if (type instanceof PsiClassType) { final String shortName = ((PsiClassType)type).getClassName(); if (!Objects.equal(shortName, CommonClassNames.JAVA_LANG_STRING_SHORT)) { return false; } } return CommonClassNames.JAVA_LANG_STRING.equals(type.getCanonicalText()); }
/** * Same as {@code getCanonicalText(false)}. */ @NonNls @NotNull public abstract String getCanonicalText();
/** Returns true if the given type matches the given fully qualified type name */ public boolean typeMatches( @Nullable PsiType type, @NonNull String typeName) { return type != null && type.getCanonicalText().equals(typeName); }
@NotNull @Override public String getCanonicalText(boolean annotated) { return getText(getComponentType().getCanonicalText(annotated), "...", true, annotated); }
@Contract("null -> false") public static boolean isPrimitiveWrapper(final PsiType type) { return type != null && isPrimitiveWrapper(type.getCanonicalText()); }
/** * Returns true if the node evaluates to an instance of type SecureRandom */ private static boolean isSecureRandomType( @NonNull JavaContext context, @NonNull PsiElement node) { PsiType type = TypeEvaluator.evaluate(context, node); return type != null && JAVA_SECURITY_SECURE_RANDOM.equals(type.getCanonicalText()); } }
@NotNull @Override public List<String> getMethodTypes(NavigatablePsiElement method) { if (!(method instanceof PsiMethod)) return super.getMethodTypes(method); PsiMethod psiMethod = (PsiMethod)method; PsiType returnType = psiMethod.getReturnType(); List<String> strings = new ArrayList<>(); strings.add(returnType == null ? "" : returnType.getCanonicalText()); for (PsiParameter parameter : psiMethod.getParameterList().getParameters()) { PsiType type = parameter.getType(); boolean generic = type instanceof PsiClassType && ((PsiClassType)type).resolve() instanceof PsiTypeParameter; strings.add((generic ? "<" : "") + type.getCanonicalText(false) + (generic ? ">" : "")); strings.add(parameter.getName()); } return strings; }
public static boolean isFluentSetter(@NotNull PsiMethod method, PsiType psiType) { return !psiType.getCanonicalText().startsWith( "java.lang" ) && method.getReturnType() != null && !isAdderWithUpperCase4thCharacter( method ) && TypeConversionUtil.isAssignable( method.getReturnType(), psiType ); }
private static boolean specifiesLocale(@NonNull PsiMethod method) { PsiParameterList parameterList = method.getParameterList(); PsiParameter[] parameters = parameterList.getParameters(); for (PsiParameter parameter : parameters) { PsiType type = parameter.getType(); if (type.getCanonicalText().equals(LOCALE_CLS)) { return true; } } return false; } }
@Nullable public static PsiField getFieldOfGetter(PsiMethod method) { PsiField field = getSimplyReturnedField(method, getGetterReturnExpression(method)); if (field != null) { final PsiType returnType = method.getReturnType(); if (returnType != null && field.getType().equalsToText(returnType.getCanonicalText())) { return field; } } return null; }
private static boolean hasLooperConstructorParameter(@NonNull PsiClass cls) { for (PsiMethod constructor : cls.getConstructors()) { for (PsiParameter parameter : constructor.getParameterList().getParameters()) { PsiType type = parameter.getType(); if (LOOPER_CLS.equals(type.getCanonicalText())) { return true; } } } return false; } }