diff --git a/idea/src/org/jetbrains/jet/plugin/findUsages/JetElementDescriptionProvider.java b/idea/src/org/jetbrains/jet/plugin/findUsages/JetElementDescriptionProvider.java deleted file mode 100644 index 0fefad66e58..00000000000 --- a/idea/src/org/jetbrains/jet/plugin/findUsages/JetElementDescriptionProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.plugin.findUsages; - -import com.intellij.psi.ElementDescriptionLocation; -import com.intellij.psi.ElementDescriptionProvider; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiNamedElement; -import com.intellij.refactoring.util.RefactoringDescriptionLocation; -import com.intellij.usageView.UsageViewLongNameLocation; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.*; - -public class JetElementDescriptionProvider implements ElementDescriptionProvider { - @Override - public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) { - if (location instanceof UsageViewLongNameLocation) { - if (element instanceof PsiNamedElement && element instanceof JetElement) { - return ((PsiNamedElement) element).getName(); - } - } - else if (location instanceof RefactoringDescriptionLocation) { - if (element instanceof JetClass) { - JetClass jetClass = (JetClass) element; - return (jetClass.isTrait() ? "Trait " : "Class ") + jetClass.getName(); - } - if (element instanceof JetObjectDeclaration || element instanceof JetObjectDeclarationName) { - return "Object " + ((PsiNamedElement) element).getName(); - } - if (element instanceof JetNamedFunction) { - return "Function " + ((PsiNamedElement) element).getName(); - } - if (element instanceof JetProperty) { - return "Property " + ((PsiNamedElement) element).getName(); - } - if (element instanceof JetTypeParameter) { - return "Type parameter " + ((PsiNamedElement) element).getName(); - } - } - return null; - } -} diff --git a/idea/src/org/jetbrains/jet/plugin/findUsages/JetElementDescriptionProvider.kt b/idea/src/org/jetbrains/jet/plugin/findUsages/JetElementDescriptionProvider.kt new file mode 100644 index 00000000000..e068f3803c8 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/findUsages/JetElementDescriptionProvider.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.findUsages + +import com.intellij.psi.ElementDescriptionLocation +import com.intellij.psi.ElementDescriptionProvider +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiNamedElement +import com.intellij.refactoring.util.RefactoringDescriptionLocation +import com.intellij.usageView.UsageViewLongNameLocation +import org.jetbrains.jet.lang.psi.* + +public class JetElementDescriptionProvider : ElementDescriptionProvider { + public override fun getElementDescription(element: PsiElement, location: ElementDescriptionLocation): String? { + fun elementKind() = when (element) { + is JetClass -> if (element.isTrait()) "Trait" else "Class" + is JetObjectDeclaration, is JetObjectDeclarationName -> "Object" + is JetNamedFunction -> "Function" + is JetProperty -> "Property" + is JetTypeParameter -> "Type parameter" + else -> null + } + + if (element !is PsiNamedElement || element !is JetElement) return null + + val name = (element as PsiNamedElement).getName() + + return when(location) { + is UsageViewLongNameLocation -> + name + is RefactoringDescriptionLocation -> + elementKind()?.let { kind -> "$kind $name" } + else -> null + } + } +}