From 76b3bee7e5985402969114e78a909095fb77f322 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Mon, 18 Nov 2013 15:45:00 +0400 Subject: [PATCH] fixed PY-9967 App Engine: do not resolve to installed to interpreter library --- .../python/psi/impl/PyResolveResultRater.java | 26 +++++++++++++++++++ python/src/META-INF/python-core.xml | 1 + .../python/psi/resolve/ResolveImportUtil.java | 4 +++ 3 files changed, 31 insertions(+) create mode 100644 python/psi-api/src/com/jetbrains/python/psi/impl/PyResolveResultRater.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 index 000000000000..961293fecc62 --- /dev/null +++ b/python/psi-api/src/com/jetbrains/python/psi/impl/PyResolveResultRater.java @@ -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 EP_NAME = ExtensionPointName.create("Pythonid.resolveResultRater"); + + int getRate(@NotNull final PsiElement target); +} diff --git a/python/src/META-INF/python-core.xml b/python/src/META-INF/python-core.xml index 6c02c7a05f2b..f94ee48f9a8f 100644 --- a/python/src/META-INF/python-core.xml +++ b/python/src/META-INF/python-core.xml @@ -511,6 +511,7 @@ + diff --git a/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java b/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java index 57fe1a6230db..6a80851cea1b 100644 --- a/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java +++ b/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java @@ -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); }