diff --git a/idea/src/org/jetbrains/jet/plugin/findUsages/JetFindUsagesProvider.java b/idea/src/org/jetbrains/jet/plugin/findUsages/JetFindUsagesProvider.java deleted file mode 100644 index 72bc1328052..00000000000 --- a/idea/src/org/jetbrains/jet/plugin/findUsages/JetFindUsagesProvider.java +++ /dev/null @@ -1,76 +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.lang.cacheBuilder.WordsScanner; -import com.intellij.lang.findUsages.FindUsagesProvider; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiNamedElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.*; - -public class JetFindUsagesProvider implements FindUsagesProvider { - @Override - public boolean canFindUsagesFor(@NotNull PsiElement psiElement) { - return psiElement instanceof JetNamedDeclaration; - } - - @Override - public WordsScanner getWordsScanner() { - return new JetWordsScanner(); - } - - - @Override - public String getHelpId(@NotNull PsiElement psiElement) { - return null; - } - - @NotNull - @Override - public String getType(@NotNull PsiElement psiElement) { - if (psiElement instanceof JetNamedFunction) { - return "function"; - } - if (psiElement instanceof JetClass) { - return "class"; - } - if (psiElement instanceof JetParameter) { - return "parameter"; - } - if (psiElement instanceof JetProperty) { - return "property"; - } - return ""; - } - - @NotNull - @Override - public String getDescriptiveName(@NotNull PsiElement psiElement) { - if (psiElement instanceof PsiNamedElement) { - String name = ((PsiNamedElement)psiElement).getName(); - return name == null ? "" : name; - } - return ""; - } - - @NotNull - @Override - public String getNodeText(@NotNull PsiElement psiElement, boolean useFullName) { - return getDescriptiveName(psiElement); - } -} diff --git a/idea/src/org/jetbrains/jet/plugin/findUsages/JetFindUsagesProvider.kt b/idea/src/org/jetbrains/jet/plugin/findUsages/JetFindUsagesProvider.kt new file mode 100644 index 00000000000..08e7e018d5b --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/findUsages/JetFindUsagesProvider.kt @@ -0,0 +1,57 @@ +/* + * 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.lang.cacheBuilder.WordsScanner +import com.intellij.lang.findUsages.FindUsagesProvider +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiNamedElement +import org.jetbrains.jet.lang.psi.* +import org.jetbrains.jet.lexer.JetLexer +import com.intellij.lang.cacheBuilder.DefaultWordsScanner +import org.jetbrains.jet.lexer.JetTokens +import com.intellij.psi.tree.TokenSet +import org.jetbrains.jet.plugin.refactoring.changeSignature.JetParameterInfo + +public class JetFindUsagesProvider : FindUsagesProvider { + class JetWordsScanner : DefaultWordsScanner(JetLexer(), TokenSet.create(JetTokens.IDENTIFIER), JetTokens.COMMENTS, JetTokens.STRINGS) + + public override fun canFindUsagesFor(psiElement: PsiElement): Boolean = + psiElement is JetNamedDeclaration + + public override fun getWordsScanner(): WordsScanner = + JetWordsScanner() + + public override fun getHelpId(psiElement: PsiElement): String? = null + + public override fun getType(element: PsiElement): String { + return when(element) { + is JetNamedFunction -> "function" + is JetClass -> "class" + is JetParameter -> "parameter" + is JetProperty -> "property" + else -> "" + } + } + + public override fun getDescriptiveName(element: PsiElement): String { + return if (element is PsiNamedElement) element.getName() ?: "" else "" + } + + public override fun getNodeText(element: PsiElement, useFullName: Boolean): String = + getDescriptiveName(element) +} diff --git a/idea/src/org/jetbrains/jet/plugin/findUsages/JetWordsScanner.java b/idea/src/org/jetbrains/jet/plugin/findUsages/JetWordsScanner.java deleted file mode 100644 index 78fc7b8ca00..00000000000 --- a/idea/src/org/jetbrains/jet/plugin/findUsages/JetWordsScanner.java +++ /dev/null @@ -1,31 +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.lang.cacheBuilder.DefaultWordsScanner; -import com.intellij.psi.tree.TokenSet; -import org.jetbrains.jet.lexer.JetLexer; -import org.jetbrains.jet.lexer.JetTokens; - -public class JetWordsScanner extends DefaultWordsScanner { - public JetWordsScanner() { - super(new JetLexer(), - TokenSet.create(JetTokens.IDENTIFIER), - JetTokens.COMMENTS, - JetTokens.STRINGS); - } -}