Search in sources :

Example 1 with PyUnresolvedReferencesInspection

use of com.jetbrains.python.inspections.unresolvedReference.PyUnresolvedReferencesInspection in project intellij-community by JetBrains.

the class PyUnresolvedReferencesInspectionTest method testInspectionSettingsSerializable.

// PY-14359, PY-14158
public void testInspectionSettingsSerializable() throws Exception {
    final PyUnresolvedReferencesInspection inspection = new PyUnresolvedReferencesInspection();
    inspection.ignoredIdentifiers.add("foo.Bar.*");
    final Element serialized = new Element("tmp");
    inspection.writeSettings(serialized);
    assertTrue(JDOMUtil.writeElement(serialized).contains("foo.Bar.*"));
}
Also used : PsiElement(com.intellij.psi.PsiElement) Element(org.jdom.Element) PyUnresolvedReferencesInspection(com.jetbrains.python.inspections.unresolvedReference.PyUnresolvedReferencesInspection)

Example 2 with PyUnresolvedReferencesInspection

use of com.jetbrains.python.inspections.unresolvedReference.PyUnresolvedReferencesInspection in project intellij-community by JetBrains.

the class AddIgnoredIdentifierQuickFix method applyFix.

@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    final PsiElement context = descriptor.getPsiElement();
    InspectionProfileModifiableModelKt.modifyAndCommitProjectProfile(project, model -> {
        PyUnresolvedReferencesInspection inspection = (PyUnresolvedReferencesInspection) model.getUnwrappedTool(PyUnresolvedReferencesInspection.class.getSimpleName(), context);
        String name = myIdentifier.toString();
        if (myIgnoreAllAttributes) {
            name += END_WILDCARD;
        }
        assert inspection != null;
        if (!inspection.ignoredIdentifiers.contains(name)) {
            inspection.ignoredIdentifiers.add(name);
        }
    });
}
Also used : PyUnresolvedReferencesInspection(com.jetbrains.python.inspections.unresolvedReference.PyUnresolvedReferencesInspection) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)2 PyUnresolvedReferencesInspection (com.jetbrains.python.inspections.unresolvedReference.PyUnresolvedReferencesInspection)2 Element (org.jdom.Element)1