mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Get rid of deprecated API in Python inspections
We have PyInspectionExtension, no need to have PyUnresolvedReferenceSkipperExtPoint GitOrigin-RevId: e8f722d4f637cec2d452785648651956c8956408
This commit is contained in:
committed by
intellij-monorepo-bot
parent
43f2910aa7
commit
a2035d15b0
@@ -113,4 +113,9 @@ public abstract class PyInspectionExtension {
|
||||
public boolean ignoreInterpreterWarnings(@NotNull PyFile file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Do not report "unused import"
|
||||
*/
|
||||
public boolean unusedImportShouldBeSkipped(@NotNull PyImportedNameDefiner importNameDefiner) {return false;}
|
||||
}
|
||||
|
||||
@@ -644,7 +644,6 @@
|
||||
<extensionPoint qualifiedName="Pythonid.pythonCommandLineEnvironmentProvider" interface="com.jetbrains.python.run.PythonCommandLineEnvironmentProvider"/>
|
||||
<extensionPoint qualifiedName="Pythonid.importResolver" interface="com.jetbrains.python.psi.impl.PyImportResolver"/>
|
||||
<extensionPoint qualifiedName="Pythonid.magicLiteral" interface="com.jetbrains.python.magicLiteral.PyMagicLiteralExtensionPoint"/>
|
||||
<extensionPoint qualifiedName="Pythonid.unresolvedReferenceSkipper" interface="com.jetbrains.python.inspections.unresolvedReference.PyUnresolvedReferenceSkipperExtPoint"/>
|
||||
<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"/>
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.inspections.unresolvedReference;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.jetbrains.python.psi.PyImportedNameDefiner;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Inject this point to ask "unused reference" inspection to skip some unused references.
|
||||
* For example in Django you may import "I18N" to your "settings.py". It is not used in "settings.py", but used by Django
|
||||
* and should not be marked as "unused".
|
||||
*
|
||||
* @author Ilya.Kazakevich
|
||||
*/
|
||||
@Deprecated
|
||||
//TODO: switch to PyInspectionExtension
|
||||
public interface PyUnresolvedReferenceSkipperExtPoint {
|
||||
@NotNull
|
||||
ExtensionPointName<PyUnresolvedReferenceSkipperExtPoint> EP_NAME = ExtensionPointName.create("Pythonid.unresolvedReferenceSkipper");
|
||||
|
||||
/**
|
||||
* Checks if some unused import should be skipped
|
||||
*
|
||||
* @param importNameDefiner unused import
|
||||
* @return true if should be skipped
|
||||
*/
|
||||
boolean unusedImportShouldBeSkipped(@NotNull PyImportedNameDefiner importNameDefiner);
|
||||
}
|
||||
+1
-16
@@ -1086,7 +1086,7 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
|
||||
// Remove those unsed, that are reported to be skipped by extension points
|
||||
final Set<PyImportedNameDefiner> unusedImportToSkip = new HashSet<>();
|
||||
for (final PyImportedNameDefiner unusedImport : unusedImports) {
|
||||
if (importShouldBeSkippedByExtPoint(unusedImport)) { // Pass to extension points
|
||||
if (PyInspectionExtension.EP_NAME.getExtensionList().stream().anyMatch(o -> o.unusedImportShouldBeSkipped(unusedImport))) {
|
||||
unusedImportToSkip.add(unusedImport);
|
||||
}
|
||||
}
|
||||
@@ -1198,19 +1198,4 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if one or more extension points ask unused import to be skipped
|
||||
*
|
||||
* @param importNameDefiner unused import
|
||||
* @return true of one or more asks
|
||||
*/
|
||||
private static boolean importShouldBeSkippedByExtPoint(@NotNull final PyImportedNameDefiner importNameDefiner) {
|
||||
for (final PyUnresolvedReferenceSkipperExtPoint skipper : PyUnresolvedReferenceSkipperExtPoint.EP_NAME.getExtensions()) {
|
||||
if (skipper.unusedImportShouldBeSkipped(importNameDefiner)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user