Merge remote-tracking branch 'origin/master'
authorEkaterina Tuzova <Ekaterina.Tuzova@jetbrains.com>
Mon, 18 Nov 2013 12:46:03 +0000 (16:46 +0400)
committerEkaterina Tuzova <Ekaterina.Tuzova@jetbrains.com>
Mon, 18 Nov 2013 12:46:03 +0000 (16:46 +0400)
python/psi-api/src/com/jetbrains/python/psi/impl/PyResolveResultRater.java [new file with mode: 0644]
python/src/META-INF/python-core.xml
python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java
python/src/com/jetbrains/python/refactoring/classes/PyClassRefactoringUtil.java
python/src/com/jetbrains/python/refactoring/move/PyMoveClassOrFunctionProcessor.java

diff --git a/python/psi-api/src/com/jetbrains/python/psi/impl/PyResolveResultRater.java b/python/psi-api/src/com/jetbrains/python/psi/impl/PyResolveResultRater.java
new file mode 100644 (file)
index 0000000..961293f
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-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 com.jetbrains.python.psi.impl;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+
+public interface PyResolveResultRater {
+  ExtensionPointName<PyResolveResultRater> EP_NAME = ExtensionPointName.create("Pythonid.resolveResultRater");
+
+  int getRate(@NotNull final PsiElement target);
+}
index 4abdce69e8a00004a40c556fd8f1db7800e65196..4846385475a90d49724d7b5b693eadac3c7189c4 100644 (file)
 
   <extensionPoints>
     <extensionPoint qualifiedName="Pythonid.importResolver" interface="com.jetbrains.python.psi.impl.PyImportResolver"/>
+    <extensionPoint qualifiedName="Pythonid.resolveResultRater" interface="com.jetbrains.python.psi.impl.PyResolveResultRater"/>
     <extensionPoint qualifiedName="Pythonid.typeProvider" interface="com.jetbrains.python.psi.impl.PyTypeProvider"/>
     <extensionPoint qualifiedName="Pythonid.pySuperMethodsSearch" interface="com.intellij.util.QueryExecutor"/>
     <extensionPoint qualifiedName="Pythonid.pyClassInheritorsSearch" interface="com.intellij.util.QueryExecutor"/>
index 57fe1a6230dbd5eb0bbc3b3dd8b86f33efebcd40..6a80851cea1bc2a680e6205f43da8cccc352363a 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.jetbrains.python.psi.resolve;
 
+import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleUtilCore;
 import com.intellij.openapi.projectRoots.Sdk;
@@ -366,6 +367,9 @@ public class ResolveImportUtil {
           if (vFile != null && vFile.getLength() > 0) {
             rate += 100;
           }
+          for (PyResolveResultRater rater : Extensions.getExtensions(PyResolveResultRater.EP_NAME)) {
+            rate += rater.getRate(target);
+          }
         }
         ret.poke(target, rate);
       }
index f5ba91893134c0aa8e9900433c7ca5715f51926c..9b11d159ae1f951af7e580441c95a3c651e2af07 100644 (file)
@@ -25,16 +25,15 @@ import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtilBase;
 import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.psi.util.QualifiedName;
 import com.jetbrains.python.PyNames;
 import com.jetbrains.python.PythonFileType;
 import com.jetbrains.python.codeInsight.PyCodeInsightSettings;
 import com.jetbrains.python.codeInsight.imports.AddImportHelper;
-import com.jetbrains.python.documentation.DocStringTypeReference;
 import com.jetbrains.python.psi.*;
 import com.jetbrains.python.psi.impl.PyBuiltinCache;
 import com.jetbrains.python.psi.impl.PyImportedModule;
 import com.jetbrains.python.psi.impl.PyPsiUtils;
-import com.intellij.psi.util.QualifiedName;
 import com.jetbrains.python.psi.resolve.QualifiedNameFinder;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -190,7 +189,7 @@ public class PyClassRefactoringUtil {
       public void visitPyStringLiteralExpression(PyStringLiteralExpression node) {
         super.visitPyStringLiteralExpression(node);
         for (PsiReference ref : node.getReferences()) {
-          if (ref instanceof DocStringTypeReference && ref.isReferenceTo(oldElement)) {
+          if (ref.isReferenceTo(oldElement)) {
             ref.bindToElement(newElement);
           }
         }
index fe4da8e6cc9282d41bf5ceee5078a3105a49aeb0..5c22514f28f2ee6198588932335b9e106057cd9e 100644 (file)
@@ -23,6 +23,7 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.psi.util.QualifiedName;
 import com.intellij.refactoring.BaseRefactoringProcessor;
 import com.intellij.refactoring.ui.UsageViewDescriptorAdapter;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
@@ -33,9 +34,7 @@ import com.jetbrains.python.PyBundle;
 import com.jetbrains.python.PyNames;
 import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil;
 import com.jetbrains.python.codeInsight.imports.PyImportOptimizer;
-import com.jetbrains.python.documentation.DocStringTypeReference;
 import com.jetbrains.python.psi.*;
-import com.intellij.psi.util.QualifiedName;
 import com.jetbrains.python.psi.resolve.QualifiedNameFinder;
 import com.jetbrains.python.refactoring.PyRefactoringUtil;
 import com.jetbrains.python.refactoring.classes.PyClassRefactoringUtil;
@@ -193,7 +192,7 @@ public class PyMoveClassOrFunctionProcessor extends BaseRefactoringProcessor {
     }
     if (usage instanceof PyStringLiteralExpression) {
       for (PsiReference ref : usage.getReferences()) {
-        if (ref instanceof DocStringTypeReference && ref.isReferenceTo(oldElement)) {
+        if (ref.isReferenceTo(oldElement)) {
           ref.bindToElement(newElement);
         }
       }