@Override public void invoke(@NotNull Project project, Editor editor, KtFile file) throws IncorrectOperationException { for (KtTypeReference typeReference : getElement().getTypeArgumentsAsTypes()) { if (typeReference != null) { typeReference.replace(KtPsiFactoryKt.KtPsiFactory(file).createStar()); } } }
@Override public void invoke(@NotNull Project project, Editor editor, KtFile file) throws IncorrectOperationException { if (getElement() instanceof KtBinaryExpressionWithTypeRHS) { KtExpression left = ((KtBinaryExpressionWithTypeRHS) getElement()).getLeft(); KtTypeReference right = ((KtBinaryExpressionWithTypeRHS) getElement()).getRight(); if (right != null) { KtExpression expression = KtPsiFactoryKt.KtPsiFactory(file) .createExpression(left.getText() + operation + right.getText()); getElement().replace(expression); } } }
@Nullable public static Name getShortName(@NotNull KtAnnotationEntry annotation) { KtTypeReference typeReference = annotation.getTypeReference(); assert typeReference != null : "Annotation entry hasn't typeReference " + annotation.getText(); KtTypeElement typeElement = typeReference.getTypeElement(); if (typeElement instanceof KtUserType) { KtUserType userType = (KtUserType) typeElement; String shortName = userType.getReferencedName(); if (shortName != null) { return Name.identifier(shortName); } } return null; }
@NotNull private static KtProperty createProperty( @NotNull KtProperty property, @NotNull KotlinType propertyType, @Nullable String initializer) { KtTypeReference typeRef = property.getTypeReference(); String typeString = null; if (typeRef != null) { typeString = typeRef.getText(); } else if (!propertyType.isError()) { typeString = IdeDescriptorRenderers.SOURCE_CODE.renderType(propertyType); } return KtPsiFactoryKt.KtPsiFactory(property) .createProperty(property.getName(), typeString, property.isVar(), initializer); }