@Override public void invoke(@NotNull Project project, Editor editor, JetFile file) throws IncorrectOperationException { for (JetTypeReference typeReference : getElement().getTypeArgumentsAsTypes()) { if (typeReference != null) { typeReference.replace(JetPsiFactoryKt.JetPsiFactory(file).createStar()); } } }
// Temporary // Returns true if deprecated constructor is in use, like // ENTRY: Enum(arguments) instead of // ENTRY(arguments) public static boolean enumEntryUsesDeprecatedSuperConstructor(@NotNull JetEnumEntry enumEntry) { JetInitializerList initializerList = enumEntry.getInitializerList(); if (initializerList == null || initializerList.getInitializers().isEmpty()) return false; JetTypeReference typeReference = initializerList.getInitializers().get(0).getTypeReference(); if (typeReference == null) return false; JetUserType userType = (JetUserType) typeReference.getTypeElement(); if (userType == null || userType.getReferenceExpression() instanceof JetEnumEntrySuperclassReferenceExpression) return false; return true; }
// Source code is taken from org.jetbrains.kotlin.idea.projectView.JetDeclarationTreeNode, // updateImple() private String getPresentableElement(JetElement declaration) { String text = ""; if (declaration != null) { text = declaration.getName(); if (text == null) return ""; if (declaration instanceof JetClassInitializer) { text = CLASS_INITIALIZER; } else if (declaration instanceof JetProperty) { JetProperty property = (JetProperty) declaration; JetTypeReference ref = property.getTypeReference(); if (ref != null) { text += " "; text += ":"; text += " "; text += ref.getText(); } } else if (declaration instanceof JetFunction) { JetFunction function = (JetFunction) declaration; JetTypeReference receiverTypeRef = function.getReceiverTypeReference(); if (receiverTypeRef != null) { text = receiverTypeRef.getText() + "." + text; } text += "("; List<JetParameter> parameters = function.getValueParameters(); for (JetParameter parameter : parameters) { if (parameter.getName() != null) { text += parameter.getName(); text += " "; text += ":"; text += " "; } JetTypeReference typeReference = parameter.getTypeReference(); if (typeReference != null) { text += typeReference.getText(); } text += ", "; } if (parameters.size() > 0) text = text.substring(0, text.length() - 2); text += ")"; JetTypeReference typeReference = function.getTypeReference(); if (typeReference != null) { text += " "; text += ":"; text += " "; text += typeReference.getText(); } } } return text; }