@Nullable public static Name getShortName(@NotNull JetAnnotationEntry annotation) { JetTypeReference typeReference = annotation.getTypeReference(); assert typeReference != null : "Annotation entry hasn't typeReference " + annotation.getText(); JetTypeElement typeElement = typeReference.getTypeElement(); if (typeElement instanceof JetUserType) { JetUserType userType = (JetUserType) typeElement; String shortName = userType.getReferencedName(); if (shortName != null) { return Name.identifier(shortName); } } return null; }
/** @return <code>null</code> iff the tye has syntactic errors */ @Nullable public static FqName toQualifiedName(@NotNull JetUserType userType) { List<String> reversedNames = Lists.newArrayList(); JetUserType current = userType; while (current != null) { String name = current.getReferencedName(); if (name == null) return null; reversedNames.add(name); current = current.getQualifier(); } return FqName.fromSegments(ContainerUtil.reverse(reversedNames)); }