mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
|
||||
<id>Pythonid</id>
|
||||
<name>Python</name>
|
||||
<idea-version since-build="128.0" until-build="129.999"/>
|
||||
<idea-version since-build="130.0" until-build="131.0"/>
|
||||
<description>Smart editing for Python scripts</description>
|
||||
<version>2.10.1</version>
|
||||
<version>2.11</version>
|
||||
<depends>com.intellij.modules.ultimate</depends>
|
||||
<depends>com.intellij.modules.java</depends>
|
||||
<depends>Coverage</depends>
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.codeInsight.editorActions.moveUpDown;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.editorActions.moveUpDown.LineMover;
|
||||
import com.intellij.codeInsight.editorActions.moveUpDown.LineRange;
|
||||
import com.intellij.codeInsight.editorActions.moveUpDown.StatementUpDownMover;
|
||||
@@ -241,7 +241,7 @@ public class StatementMover extends LineMover {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isMoveToEmptyLine(Editor editor, MoveInfo info, boolean down) {
|
||||
final Document document = editor.getDocument();
|
||||
if (document.getLineCount() >= info.toMove2.endLine) {
|
||||
@@ -467,7 +467,7 @@ public class StatementMover extends LineMover {
|
||||
}
|
||||
else
|
||||
myStatementListToAddPass.addBefore(passStatement, myStatementListToAddPass.getStatements()[0]);
|
||||
CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(myStatementListToAddPass);
|
||||
CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(myStatementListToAddPass);
|
||||
}
|
||||
if (myStatementToIncreaseIndent != null) {
|
||||
if (!down && myStatementPartToRemovePass != null && myStatementToAddLinebreak == null) {
|
||||
@@ -487,7 +487,7 @@ public class StatementMover extends LineMover {
|
||||
final PyPassStatement passStatement =
|
||||
PyElementGenerator.getInstance(editor.getProject()).createFromText(LanguageLevel.getDefault(), PyPassStatement.class, PyNames.PASS);
|
||||
myStatementListToAddPassAfter.add(passStatement);
|
||||
CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(myStatementListToAddPassAfter);
|
||||
CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(myStatementListToAddPassAfter);
|
||||
}
|
||||
|
||||
// remove obsolete pass statement
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.codeInsight.intentions;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.controlflow.ControlFlow;
|
||||
import com.intellij.codeInsight.controlflow.Instruction;
|
||||
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
|
||||
@@ -87,7 +87,7 @@ public class PyConvertLambdaToFunctionIntention extends BaseIntentionAction {
|
||||
function = (PyFunction)statementParent.addBefore(function, statement);
|
||||
}
|
||||
|
||||
function = CodeInsightUtilBase
|
||||
function = CodeInsightUtilCore
|
||||
.forcePsiPostprocessAndRestoreElement(function);
|
||||
|
||||
if (parent instanceof PyAssignmentStatement) {
|
||||
@@ -97,8 +97,8 @@ public class PyConvertLambdaToFunctionIntention extends BaseIntentionAction {
|
||||
PsiFile parentScope = lambdaExpression.getContainingFile();
|
||||
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(parentScope);
|
||||
PsiElement functionName = function.getNameIdentifier();
|
||||
functionName = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(functionName);
|
||||
lambdaExpression = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(lambdaExpression);
|
||||
functionName = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(functionName);
|
||||
lambdaExpression = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(lambdaExpression);
|
||||
|
||||
ReferenceNameExpression refExpr = new ReferenceNameExpression(name);
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.codeInsight.intentions;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
@@ -69,7 +69,7 @@ public class SpecifyTypeInPy3AnnotationsIntention extends TypeIntention {
|
||||
final PyNamedParameter namedParameter = elementGenerator.createParameter(name, defaultParamText, PyNames.OBJECT, LanguageLevel.forElement(parameter));
|
||||
assert namedParameter != null;
|
||||
parameter = (PyParameter)parameter.replace(namedParameter);
|
||||
parameter = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(parameter);
|
||||
parameter = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(parameter);
|
||||
editor.getCaretModel().moveToOffset(parameter.getTextOffset());
|
||||
PyAnnotation annotation = parameter instanceof PyNamedParameter? ((PyNamedParameter)parameter).getAnnotation() : null;
|
||||
if (annotation != null) {
|
||||
@@ -101,7 +101,7 @@ public class SpecifyTypeInPy3AnnotationsIntention extends TypeIntention {
|
||||
final PyFunction function = elementGenerator.createFromText(LanguageLevel.forElement(callable), PyFunction.class,
|
||||
functionText);
|
||||
callable = (PyFunction)callable.replace(function);
|
||||
callable = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(callable);
|
||||
callable = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(callable);
|
||||
|
||||
final PyAnnotation annotation = ((PyFunction)callable).getAnnotation();
|
||||
assert annotation != null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.codeInsight.intentions;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -124,7 +124,7 @@ public class TypeAssertionIntention implements IntentionAction {
|
||||
int textOffSet = element.getTextOffset();
|
||||
editor.getCaretModel().moveToOffset(textOffSet);
|
||||
|
||||
element = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(element);
|
||||
element = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(element);
|
||||
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(element);
|
||||
builder.replaceRange(TextRange.create(text.length()-1, text.length()-1), PyNames.OBJECT);
|
||||
Template template = ((TemplateBuilderImpl)builder).buildInlineTemplate();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.codeInsight.override;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.featureStatistics.ProductivityFeatureNames;
|
||||
import com.intellij.ide.util.MemberChooser;
|
||||
@@ -139,7 +139,7 @@ public class PyOverrideImplementUtil {
|
||||
PyFunction baseFunction = (PyFunction) newMember.getPsiElement();
|
||||
final PyFunctionBuilder builder = buildOverriddenFunction(pyClass, baseFunction);
|
||||
PyFunction function = builder.addFunctionAfter(statementList, anchor, LanguageLevel.forElement(statementList));
|
||||
element = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(function);
|
||||
element = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(function);
|
||||
}
|
||||
|
||||
PyPsiUtils.removeRedundantPass(statementList);
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -368,9 +368,9 @@ public class PyDocstringGenerator {
|
||||
PyExpression str = elementGenerator.createDocstring(replacementToOffset.getFirst()).getExpression();
|
||||
myDocStringExpression.replace(str);
|
||||
if (myFunction != null) {
|
||||
myFunction = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(myFunction);
|
||||
myFunction = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(myFunction);
|
||||
}
|
||||
PyDocStringOwner owner = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(myDocStringOwner);
|
||||
PyDocStringOwner owner = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(myDocStringOwner);
|
||||
if (owner != null) {
|
||||
myDocStringOwner = owner;
|
||||
}
|
||||
@@ -402,7 +402,7 @@ public class PyDocstringGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
myFunction = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(myFunction);
|
||||
myFunction = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(myFunction);
|
||||
myDocStringExpression = myFunction.getDocStringExpression();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.jetbrains.python.psi.PyAugAssignmentStatement;
|
||||
import com.jetbrains.python.psi.PyDelStatement;
|
||||
import com.jetbrains.python.psi.PyReferenceExpression;
|
||||
import com.jetbrains.python.psi.PyTargetExpression;
|
||||
import com.jetbrains.python.psi.impl.PyAugAssignmentStatementNavigator;
|
||||
@@ -19,7 +20,7 @@ public class PyReadWriteAccessDetector extends ReadWriteAccessDetector {
|
||||
|
||||
@Override
|
||||
public boolean isDeclarationWriteAccess(PsiElement element) {
|
||||
return element instanceof PyTargetExpression;
|
||||
return element instanceof PyTargetExpression || element.getParent() instanceof PyDelStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,7 +30,7 @@ public class PyReadWriteAccessDetector extends ReadWriteAccessDetector {
|
||||
|
||||
@Override
|
||||
public Access getExpressionAccess(PsiElement expression) {
|
||||
if (expression instanceof PyTargetExpression) {
|
||||
if (isDeclarationWriteAccess(expression)) {
|
||||
return Access.Write;
|
||||
}
|
||||
if (expression instanceof PyReferenceExpression) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.inspections.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.template.TemplateBuilder;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderFactory;
|
||||
@@ -87,7 +87,7 @@ public class AddFieldQuickFix implements LocalQuickFix {
|
||||
}
|
||||
|
||||
private void showTemplateBuilder(PsiElement initStatement) {
|
||||
initStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(initStatement);
|
||||
initStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(initStatement);
|
||||
if (initStatement instanceof PyAssignmentStatement) {
|
||||
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(initStatement);
|
||||
final PyExpression assignedValue = ((PyAssignmentStatement)initStatement).getAssignedValue();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.inspections.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.template.TemplateBuilder;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderFactory;
|
||||
@@ -96,7 +96,7 @@ public class AddFunctionQuickFix implements LocalQuickFix {
|
||||
}
|
||||
|
||||
private static void showTemplateBuilder(PyFunction method) {
|
||||
method = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(method);
|
||||
method = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(method);
|
||||
|
||||
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(method);
|
||||
ParamHelper.walkDownParamArray(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.inspections.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.template.TemplateBuilder;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderFactory;
|
||||
@@ -125,7 +125,7 @@ public class AddMethodQuickFix implements LocalQuickFix {
|
||||
}
|
||||
|
||||
private static void showTemplateBuilder(PyFunction method) {
|
||||
method = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(method);
|
||||
method = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(method);
|
||||
|
||||
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(method);
|
||||
ParamHelper.walkDownParamArray(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.inspections.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.template.TemplateBuilder;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderFactory;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
@@ -57,7 +57,7 @@ public class CreateClassQuickFix implements LocalQuickFix {
|
||||
else {
|
||||
pyClass = (PyClass) anchor.getParent().addBefore(pyClass, anchor);
|
||||
}
|
||||
pyClass = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(pyClass);
|
||||
pyClass = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(pyClass);
|
||||
TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(pyClass);
|
||||
builder.replaceElement(pyClass.getSuperClassExpressions() [0], "object");
|
||||
builder.replaceElement(pyClass.getStatementList(), PyNames.PASS);
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.inspections.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.template.TemplateBuilder;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderFactory;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
@@ -35,9 +35,9 @@ public class StatementEffectIntroduceVariableQuickFix implements LocalQuickFix {
|
||||
final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
|
||||
final PyAssignmentStatement assignment = elementGenerator.createFromText(LanguageLevel.forElement(expression), PyAssignmentStatement.class,
|
||||
"var = " + expression.getText());
|
||||
|
||||
|
||||
expression = expression.replace(assignment);
|
||||
expression = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(expression);
|
||||
expression = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(expression);
|
||||
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(expression);
|
||||
builder.replaceElement(((PyAssignmentStatement)expression).getLeftHandSideExpression(), "var");
|
||||
builder.run();
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.inspections.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.template.TemplateBuilder;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderFactory;
|
||||
@@ -85,7 +85,7 @@ public class UnresolvedRefCreateFunctionQuickFix implements LocalQuickFix {
|
||||
function = (PyFunction)parent.addBefore(function, statement);
|
||||
}
|
||||
}
|
||||
function = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(function);
|
||||
function = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(function);
|
||||
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(function);
|
||||
ParamHelper.walkDownParamArray(
|
||||
function.getParameterList().getParameters(),
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.inspections.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.template.TemplateBuilder;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderFactory;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
@@ -45,7 +45,7 @@ public class UnresolvedReferenceAddParameterQuickFix implements LocalQuickFix {
|
||||
if (function != null) {
|
||||
final PyParameterList parameterList = function.getParameterList();
|
||||
parameterList.addParameter(parameter);
|
||||
CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(parameterList);
|
||||
CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(parameterList);
|
||||
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(parameter);
|
||||
builder.replaceRange(TextRange.create(parameter.getTextLength() - 4, parameter.getTextLength()), "None");
|
||||
builder.run();
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.PythonFileType;
|
||||
import com.jetbrains.python.codeInsight.PyCodeInsightSettings;
|
||||
@@ -124,7 +124,7 @@ public class PyClassRefactoringUtil {
|
||||
for (PyElement element : elements) {
|
||||
final Set<PsiElement> comments = PyUtil.getComments(element);
|
||||
if (comments.size() > 0) {
|
||||
PyPsiUtils.removeElements(PsiUtilBase.toPsiElementArray(comments));
|
||||
PyPsiUtils.removeElements(PsiUtilCore.toPsiElementArray(comments));
|
||||
}
|
||||
}
|
||||
PyPsiUtils.removeElements(elements);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.refactoring.extractmethod;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.codeFragment.CodeFragment;
|
||||
import com.intellij.codeInsight.highlighting.HighlightManager;
|
||||
import com.intellij.find.FindManager;
|
||||
@@ -133,7 +133,7 @@ public class PyExtractMethodUtil {
|
||||
|
||||
// Replace statements with call
|
||||
callElement = replaceElements(elementsRange, callElement);
|
||||
callElement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(callElement);
|
||||
callElement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(callElement);
|
||||
processDuplicates(callElement, generatedMethod, finder, editor);
|
||||
|
||||
// Set editor
|
||||
@@ -186,7 +186,7 @@ public class PyExtractMethodUtil {
|
||||
|
||||
// replace statements with call
|
||||
callElement = replaceElements(elementsRange, callElement);
|
||||
callElement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(callElement);
|
||||
callElement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(callElement);
|
||||
processDuplicates(callElement, generatedMethod, finder, editor);
|
||||
|
||||
// Set editor
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.refactoring.introduce;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -143,7 +143,7 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
|
||||
public Collection<String> getSuggestedNames(@NotNull final PyExpression expression) {
|
||||
Collection<String> candidates = generateSuggestedNames(expression);
|
||||
|
||||
|
||||
Collection<String> res = new ArrayList<String>();
|
||||
for (String name : candidates) {
|
||||
if (myValidator.checkPossibleName(name, expression)) {
|
||||
@@ -160,7 +160,7 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
res.add(name + index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
performIntroduceWithDialog(operation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void performInplaceIntroduce(IntroduceOperation operation) {
|
||||
final PsiElement statement = performRefactoring(operation);
|
||||
if (statement instanceof PyAssignmentStatement) {
|
||||
@@ -479,7 +479,7 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
PsiElement declaration = createDeclaration(operation);
|
||||
|
||||
declaration = performReplace(declaration, operation);
|
||||
declaration = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(declaration);
|
||||
declaration = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(declaration);
|
||||
return declaration;
|
||||
}
|
||||
|
||||
@@ -494,10 +494,10 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
: PsiTreeUtil.getParentOfType(initializer, PyStatement.class);
|
||||
return createDeclaration(project, assignmentText, anchor);
|
||||
}
|
||||
|
||||
|
||||
private static class InitializerTextBuilder extends PyRecursiveElementVisitor {
|
||||
private final StringBuilder myResult = new StringBuilder();
|
||||
|
||||
|
||||
@Override
|
||||
public void visitWhiteSpace(PsiWhiteSpace space) {
|
||||
myResult.append(space.getText().replace('\n', ' ').replace("\\", ""));
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.refactoring.introduce.parameter;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
@@ -48,7 +48,7 @@ public class PyIntroduceParameterHandler extends IntroduceHandler {
|
||||
if (function != null && declaration != null) {
|
||||
PyParameterList parameterList = function.getParameterList();
|
||||
parameterList.addParameter(PyElementGenerator.getInstance(function.getProject()).createParameter(declaration.getText()));
|
||||
CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(function);
|
||||
CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(function);
|
||||
return parameterList.findParameterByName(declaration.getTargets()[0].getText());
|
||||
}
|
||||
return null;
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.jetbrains.python.refactoring.invertBoolean;
|
||||
|
||||
import com.intellij.lang.findUsages.DescriptiveNameUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
@@ -33,7 +34,7 @@ public class PyInvertBooleanDialog extends RefactoringDialog {
|
||||
myLabel.setText(RefactoringBundle.message("invert.boolean.name.of.inverted.element", typeString));
|
||||
myCaptionLabel.setText(RefactoringBundle.message("invert.0.1",
|
||||
typeString,
|
||||
UsageViewUtil.getDescriptiveName(myElement)));
|
||||
DescriptiveNameUtil.getDescriptiveName(myElement)));
|
||||
|
||||
setTitle(PyInvertBooleanHandler.REFACTORING_NAME);
|
||||
init();
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.jetbrains.python.refactoring.surround.surrounders.expressions;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -34,7 +34,7 @@ public class PyWithParenthesesSurrounder extends PyExpressionSurrounder {
|
||||
assert expression != null;
|
||||
expression.replace(element);
|
||||
element = (PyExpression) element.replace(parenthesesExpression);
|
||||
element = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(element);
|
||||
element = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(element);
|
||||
return element.getTextRange();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.jetbrains.python.refactoring.surround.surrounders.statements;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -36,7 +36,7 @@ public class PyWithIfElseSurrounder extends PyStatementSurrounder {
|
||||
ifStatement = (PyIfStatement) parent.addBefore(ifStatement, elements[0]);
|
||||
parent.deleteChildRange(elements[0], elements[elements.length - 1]);
|
||||
|
||||
ifStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(ifStatement);
|
||||
ifStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(ifStatement);
|
||||
if (ifStatement == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.jetbrains.python.refactoring.surround.surrounders.statements;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -30,7 +30,7 @@ public class PyWithIfSurrounder extends PyStatementSurrounder {
|
||||
ifStatement = (PyIfStatement) parent.addBefore(ifStatement, elements[0]);
|
||||
parent.deleteChildRange(elements[0], elements[elements.length - 1]);
|
||||
|
||||
ifStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(ifStatement);
|
||||
ifStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(ifStatement);
|
||||
if (ifStatement == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.refactoring.surround.surrounders.statements;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -36,7 +36,7 @@ public class PyWithReturnSurrounder extends PyStatementSurrounder {
|
||||
PsiElement element = elements[0];
|
||||
expression.replace(element);
|
||||
element = element.replace(returnStatement);
|
||||
element = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(element);
|
||||
element = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(element);
|
||||
return element.getTextRange();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.jetbrains.python.refactoring.surround.surrounders.statements;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -31,7 +31,7 @@ public class PyWithWhileElseSurrounder extends PyStatementSurrounder {
|
||||
whileStatement = (PyWhileStatement) parent.addBefore(whileStatement, elements[0]);
|
||||
parent.deleteChildRange(elements[0], elements[elements.length - 1]);
|
||||
|
||||
whileStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(whileStatement);
|
||||
whileStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(whileStatement);
|
||||
if (whileStatement == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.jetbrains.python.refactoring.surround.surrounders.statements;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -31,7 +31,7 @@ public class PyWithWhileSurrounder extends PyStatementSurrounder{
|
||||
whileStatement = (PyWhileStatement) parent.addBefore(whileStatement, elements[0]);
|
||||
parent.deleteChildRange(elements[0], elements[elements.length - 1]);
|
||||
|
||||
whileStatement = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(whileStatement);
|
||||
whileStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(whileStatement);
|
||||
if (whileStatement == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.intellij.lang.annotation.ExternalAnnotator;
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
@@ -23,6 +24,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
@@ -141,9 +143,14 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
|
||||
public void apply(@NotNull PsiFile file, State annotationResult, @NotNull AnnotationHolder holder) {
|
||||
if (annotationResult == null || !file.isValid()) return;
|
||||
final String text = file.getText();
|
||||
Project project = file.getProject();
|
||||
final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
|
||||
|
||||
for (Problem problem : annotationResult.problems) {
|
||||
if (ignoreDueToSettings(file.getProject(), problem)) continue;
|
||||
int offset = StringUtil.lineColToOffset(text, problem.myLine - 1, problem.myColumn - 1);
|
||||
if (ignoreDueToSettings(project, problem)) continue;
|
||||
final int line = problem.myLine - 1;
|
||||
final int column = problem.myColumn - 1;
|
||||
int offset = document != null ? document.getLineStartOffset(line) + column : StringUtil.lineColToOffset(text, line, column);
|
||||
PsiElement problemElement = file.findElementAt(offset);
|
||||
if (!(problemElement instanceof PsiWhiteSpace) && !(problem.myCode.startsWith("E3"))) {
|
||||
final PsiElement elementAfter = file.findElementAt(offset + 1);
|
||||
@@ -153,8 +160,9 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
|
||||
}
|
||||
if (problemElement != null) {
|
||||
TextRange problemRange = problemElement.getTextRange();
|
||||
if (StringUtil.offsetToLineNumber(text, problemRange.getStartOffset()) != StringUtil.offsetToLineNumber(text, problemRange.getEndOffset())) {
|
||||
problemRange = new TextRange(offset, StringUtil.lineColToOffset(text, problem.myLine, 0)-1);
|
||||
if (crossesLineBoundary(document, text, problemRange)) {
|
||||
int lineEndOffset = document != null ? document.getLineEndOffset(line) : StringUtil.lineColToOffset(text, line+1, 0) - 1;
|
||||
problemRange = new TextRange(offset, lineEndOffset);
|
||||
}
|
||||
final Annotation annotation;
|
||||
final String message = "PEP 8: " + problem.myDescription;
|
||||
@@ -180,6 +188,15 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean crossesLineBoundary(@Nullable Document document, String text, TextRange problemRange) {
|
||||
int start = problemRange.getStartOffset();
|
||||
int end = problemRange.getEndOffset();
|
||||
if (document != null) {
|
||||
return document.getLineNumber(start) != document.getLineNumber(end);
|
||||
}
|
||||
return StringUtil.offsetToLineNumber(text, start) != StringUtil.offsetToLineNumber(text, end);
|
||||
}
|
||||
|
||||
private static boolean ignoreDueToSettings(Project project, Problem problem) {
|
||||
String stripTrailingSpaces = EditorSettingsExternalizable.getInstance().getStripTrailingSpaces();
|
||||
if (!stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE)) {
|
||||
|
||||
Reference in New Issue
Block a user