diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index 356eb811ad8..b8ac9d358f8 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -184,6 +184,8 @@
+
+
findReferences(PsiElement element) {
- if (element instanceof JetClass) {
- List references = new ArrayList();
- references.addAll(ReferencesSearch.search(element).findAll());
- references.addAll(ReferencesSearch.search(JetLightClass.wrapDelegate((JetClass) element)).findAll());
- return references;
- }
- return super.findReferences(element);
- }
-
@Override
public void prepareRenaming(PsiElement element, String newName, Map allRenames) {
JetClassOrObject clazz = (JetClassOrObject) element;
diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/rename/RenameKotlinFunctionProcessor.java b/idea/src/org/jetbrains/jet/plugin/refactoring/rename/RenameKotlinFunctionProcessor.java
index 9528f4487cd..c819b4d8bd8 100644
--- a/idea/src/org/jetbrains/jet/plugin/refactoring/rename/RenameKotlinFunctionProcessor.java
+++ b/idea/src/org/jetbrains/jet/plugin/refactoring/rename/RenameKotlinFunctionProcessor.java
@@ -52,16 +52,4 @@ public class RenameKotlinFunctionProcessor extends RenamePsiElementProcessor {
}
return super.substituteElementToRename(element, editor);
}
-
- @NotNull
- @Override
- public Collection findReferences(PsiElement element) {
- if (element instanceof JetFunction) {
- List references = new ArrayList();
- references.addAll(ReferencesSearch.search(element).findAll());
- references.addAll(ReferencesSearch.search(JetLightClass.wrapMethod((JetFunction) element)).findAll());
- return references;
- }
- return super.findReferences(element);
- }
}
diff --git a/idea/src/org/jetbrains/jet/plugin/references/KotlinReferencesSearcher.java b/idea/src/org/jetbrains/jet/plugin/references/KotlinReferencesSearcher.java
new file mode 100644
index 00000000000..149b0b44428
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/references/KotlinReferencesSearcher.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2010-2012 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.references;
+
+import com.intellij.openapi.application.QueryExecutorBase;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiMethod;
+import com.intellij.psi.PsiReference;
+import com.intellij.psi.search.searches.ReferencesSearch;
+import com.intellij.util.Processor;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jet.asJava.JetLightClass;
+import org.jetbrains.jet.lang.psi.JetClass;
+import org.jetbrains.jet.lang.psi.JetClassBody;
+import org.jetbrains.jet.lang.psi.JetFunction;
+
+/**
+ * @author yole
+ */
+public class KotlinReferencesSearcher extends QueryExecutorBase {
+ @Override
+ public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor consumer) {
+ PsiElement element = queryParameters.getElementToSearch();
+ if (element instanceof JetClass) {
+ String className = ((JetClass) element).getName();
+ if (className != null) {
+ queryParameters.getOptimizer().searchWord(className, queryParameters.getScope(),
+ true, JetLightClass.wrapDelegate((JetClass) element));
+ }
+ }
+ else if (element instanceof JetFunction) {
+ final JetFunction function = (JetFunction) element;
+ final String name = function.getName();
+ if (function.getParent() instanceof JetClassBody && name != null) {
+ final PsiMethod method = JetLightClass.wrapMethod(function);
+ if (method != null) {
+ queryParameters.getOptimizer().searchWord(name, queryParameters.getScope(),
+ true, JetLightClass.wrapMethod((JetFunction) element));
+ }
+ }
+
+ }
+ }
+}