mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Migrate PyCreatePropertyQuickFix and PyDefaultArgumentQuickFix to ModCommand
PY-65297 GitOrigin-RevId: 7c5579c5f2f2a6f06ada8306eb82573ba684cbcf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b47333fffa
commit
eb35f95a8d
+6
-6
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.inspections.quickfix;
|
||||
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.PyPsiBundle;
|
||||
@@ -13,7 +13,7 @@ import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import com.jetbrains.python.refactoring.PyPsiRefactoringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PyCreatePropertyQuickFix implements LocalQuickFix {
|
||||
public class PyCreatePropertyQuickFix extends PsiUpdateModCommandQuickFix {
|
||||
private final AccessDirection myAccessDirection;
|
||||
|
||||
public PyCreatePropertyQuickFix(AccessDirection dir) {
|
||||
@@ -27,8 +27,7 @@ public class PyCreatePropertyQuickFix implements LocalQuickFix {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
public void applyFix(@NotNull final Project project, @NotNull final PsiElement element, @NotNull ModPsiUpdater updater) {
|
||||
if (element instanceof PyQualifiedExpression) {
|
||||
final PyExpression qualifier = ((PyQualifiedExpression)element).getQualifier();
|
||||
if (qualifier != null) {
|
||||
@@ -40,7 +39,8 @@ public class PyCreatePropertyQuickFix implements LocalQuickFix {
|
||||
final String fieldName = "_" + propertyName;
|
||||
final PyElementGenerator generator = PyElementGenerator.getInstance(project);
|
||||
final PyFunction property = generator.createProperty(LanguageLevel.forElement(cls), propertyName, fieldName, myAccessDirection);
|
||||
PyPsiRefactoringUtil.addElementToStatementList(property, cls.getStatementList(), myAccessDirection == AccessDirection.READ);
|
||||
final PyStatementList statementsList = updater.getWritable(cls.getStatementList());
|
||||
PyPsiRefactoringUtil.addElementToStatementList(property, statementsList, myAccessDirection == AccessDirection.READ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user