mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
Decouple Python intentions
GitOrigin-RevId: e87aa7f8fde189ff2a48793879e27617ff6297e7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1102d4f910
commit
f0399e1662
@@ -3,7 +3,7 @@ package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.util.IntentionName;
|
||||
import com.intellij.ide.scratch.ScratchFileService;
|
||||
import com.intellij.ide.scratch.ScratchFileHelper;
|
||||
import com.intellij.openapi.vfs.NonPhysicalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -42,6 +42,6 @@ public abstract class BaseIntentionAction implements IntentionAction {
|
||||
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
|
||||
PsiFile containingFile = element.getContainingFile();
|
||||
return element.getManager().isInProject(element)
|
||||
|| ScratchFileService.findRootType(virtualFile) != null
|
||||
|| ScratchFileHelper.isScratchFile(virtualFile)
|
||||
|| (containingFile != null && containingFile.getViewProvider().getVirtualFile().getFileSystem() instanceof NonPhysicalFileSystem);
|
||||
}}
|
||||
@@ -4,6 +4,8 @@ package com.intellij.codeInsight.template;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -34,11 +36,18 @@ public interface TemplateBuilder {
|
||||
|
||||
void replaceElement(@NotNull PsiElement element, TextRange rangeWithinElement, Expression expression);
|
||||
|
||||
/**
|
||||
* Creates a replacement box for the specified text range within the container element.
|
||||
* @param rangeWithinElement range within the container element.
|
||||
* @param replacementText the initial value for the replacement.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
void replaceElement(PsiElement element, String varName, Expression expression, boolean alwaysStopAt);
|
||||
|
||||
@ApiStatus.Experimental
|
||||
void replaceElement (PsiElement element, String varName, String dependantVariableName, boolean alwaysStopAt);
|
||||
|
||||
|
||||
/**
|
||||
* Creates a replacement box for the specified text range within the container element.
|
||||
* @param rangeWithinElement range within the container element.
|
||||
* @param replacementText the initial value for the replacement.
|
||||
*/
|
||||
void replaceRange(TextRange rangeWithinElement, String replacementText);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.
|
||||
*/
|
||||
// Copyright 2000-2020 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.intellij.codeInsight.template.impl;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2000-2020 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.intellij.ide.scratch;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ScratchFileHelper {
|
||||
public static boolean isScratchFile(@Nullable VirtualFile virtualFile) {
|
||||
if (virtualFile == null) {
|
||||
return false;
|
||||
}
|
||||
return "Scratch".equals(virtualFile.getFileType().getName());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2020 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.intellij.psi.impl.file.impl;
|
||||
|
||||
import com.intellij.ide.scratch.ScratchFileHelper;
|
||||
import com.intellij.injected.editor.VirtualFileWindow;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
@@ -157,7 +158,7 @@ public final class ResolveScopeManagerImpl extends ResolveScopeManager {
|
||||
if (virtualFile instanceof VirtualFileWindow) {
|
||||
return GlobalSearchScope.fileScope(myProject, ((VirtualFileWindow)virtualFile).getDelegate());
|
||||
}
|
||||
if ("Scratch".equals(virtualFile.getFileType().getName())) {
|
||||
if (ScratchFileHelper.isScratchFile(virtualFile)) {
|
||||
return GlobalSearchScope.fileScope(myProject, virtualFile);
|
||||
}
|
||||
vDirectory = virtualFile.getParent();
|
||||
@@ -193,4 +194,4 @@ public final class ResolveScopeManagerImpl extends ResolveScopeManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceElement(PsiElement element, String varName, Expression expression, boolean alwaysStopAt) {
|
||||
replaceElement(element, varName, expression, alwaysStopAt, false);
|
||||
}
|
||||
@@ -98,6 +99,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||
myElements.add(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceElement (PsiElement element, String varName, String dependantVariableName, boolean alwaysStopAt) {
|
||||
final RangeMarker key = wrapElement(element);
|
||||
myAlwaysStopAtMap.put(key, alwaysStopAt ? Boolean.TRUE : Boolean.FALSE);
|
||||
|
||||
@@ -6,8 +6,6 @@ QFIX.add.import.add.import=Add "''{0}''"
|
||||
QFIX.NAME.parameters=Parameters of functions and methods
|
||||
|
||||
|
||||
QFIX.action.failed=Action failed
|
||||
|
||||
QFIX.statement.effect.move.docstring=Move docstring to the proper place
|
||||
|
||||
QFIX.statement.effect.introduce.variable=Introduce variable
|
||||
@@ -52,104 +50,6 @@ QFIX.reformat.file=Reformat file
|
||||
QFIX.bold.html.text=<b>{0}</b>
|
||||
|
||||
# Intentions: INTN
|
||||
INTN.Family.convert.import.unqualify=Convert 'import module' to 'from module import'
|
||||
INTN.Family.convert.import.qualify=Convert 'from module import' to 'import module'
|
||||
INTN.Family.toggle.import.alias=Toggle import alias
|
||||
|
||||
INTN.replace.list.comprehensions.with.for=Convert list comprehensions to for loop
|
||||
|
||||
INTN.replace.method=Replace method which is not supported in current Python version
|
||||
|
||||
INTN.split.if=Split if
|
||||
INTN.split.if.text=Split into 2 if's
|
||||
|
||||
INTN.negate.comparison=Negate comparison
|
||||
INTN.negate.$0.to.$1=Negate ''{0}'' to ''{1}''
|
||||
|
||||
INTN.string.concatenation.to.format=Replace string concatenation with format operator
|
||||
INTN.replace.plus.with.format.operator=Replace + with string formatting operator
|
||||
INTN.replace.plus.with.str.format=Replace + with str.format method call
|
||||
|
||||
# ConvertFormatOperatorToMethodIntention
|
||||
INTN.format.operator.to.method=Convert format operator usage to str.format method call
|
||||
|
||||
# PyConvertToFStringIntention
|
||||
INTN.convert.to.fstring.literal=Convert to f-string literal
|
||||
INTN.replace.with.method=Replace with str.format method call
|
||||
|
||||
INTN.flip.comparison=Flip comparison
|
||||
INTN.flip.$0=Flip ''{0}''
|
||||
INTN.flip.$0.to.$1=Flip ''{0}'' to ''{1}''
|
||||
|
||||
INTN.convert.string=Convert single-quoted string to double-quoted
|
||||
|
||||
INTN.join.if=Join if's
|
||||
INTN.join.if.text=Join two if's
|
||||
|
||||
INTN.convert.dict.constructor.to.dict.literal=Convert dict constructor to dict literal form
|
||||
INTN.convert.dict.literal.to.dict.constructor=Convert dict literal to dict constructor
|
||||
|
||||
INTN.quoted.string=Convert between single-quoted and double-quoted strings
|
||||
INTN.quoted.string.single.to.double=Convert single-quoted string to double-quoted string
|
||||
INTN.quoted.string.double.to.single=Convert double-quoted string to single-quoted string
|
||||
|
||||
INTN.convert.lambda.to.function=Convert lambda to function
|
||||
|
||||
INTN.convert.variadic.param=Convert from variadic to normal parameter(s)
|
||||
|
||||
# PyConvertTripleQuotedStringIntention
|
||||
INTN.triple.quoted.string=Convert triple-quoted string to single-quoted string
|
||||
|
||||
# PyBaseConvertCollectionLiteralIntention
|
||||
INTN.convert.collection.literal.family=Convert collection to {0}
|
||||
INTN.convert.collection.literal.text=Convert {0} to {1}
|
||||
|
||||
# PyConvertTypeCommentToVariableAnnotation
|
||||
INTN.convert.type.comment.to.variable.annotation.family=Convert type comment to variable annotation
|
||||
INTN.convert.type.comment.to.variable.annotation.text=Convert to variable annotation
|
||||
|
||||
|
||||
INTN.demorgan.law=DeMorgan law
|
||||
|
||||
# PyTransformConditionalExpressionIntention
|
||||
INTN.transform.into.if.else.statement=Transform conditional expression into if/else statement
|
||||
|
||||
# PyConvertTripleQuotedStringIntention
|
||||
INTN.doc.string.stub=Insert documentation string stub
|
||||
|
||||
#SpecifyTypeInDocstringIntention
|
||||
INTN.specify.type=Specify type for reference in docstring
|
||||
INTN.specify.return.type=Specify return type in docstring
|
||||
INTN.add.parameters.to.docstring=Add parameters to docstring
|
||||
|
||||
#SpecifyTypeInPy3AnnotationsIntention
|
||||
INTN.specify.type.in.annotation=Specify type for reference using annotation
|
||||
INTN.specify.return.type.in.annotation=Specify return type using annotation
|
||||
|
||||
#PyAnnotateTypesIntention/PyAnnotateVariableTypeIntention
|
||||
INTN.add.type.hints.for.function.family=Add type hints for function
|
||||
INTN.add.type.hints.for.function=Add type hints for function ''{0}''
|
||||
INTN.add.type.hint.for.variable.family=Add type hint for variable
|
||||
INTN.add.type.hint.for.variable=Add type hint for variable ''{0}''
|
||||
INTN.add.type.hint.for.variable.PEP484.incompatible.type=Type ''{0}'' cannot be expressed inline in PEP 484 format
|
||||
|
||||
#TypeAssertionIntention
|
||||
INTN.insert.assertion=Insert type assertion
|
||||
|
||||
#PyYieldFromIntention
|
||||
INTN.yield.from=Transform explicit iteration with 'yield' into 'yield from' expression
|
||||
|
||||
#PyConvertStaticMethodToFunctionIntention
|
||||
INTN.convert.static.method.to.function=Convert static method to function
|
||||
|
||||
#PyConvertMethodToPropertyIntention
|
||||
INTN.convert.method.to.property=Convert method to property
|
||||
|
||||
#PyConvertImportIntentionAction
|
||||
INTN.convert.relative.to.absolute=Convert relative import to absolute
|
||||
INTN.convert.absolute.to.relative=Convert absolute import to relative
|
||||
|
||||
INTN.add.alias.title=Add Alias
|
||||
|
||||
# Conflict checker
|
||||
CONFLICT.name.$0.obscured=Name ''{0}'' obscured by local definitions
|
||||
@@ -1088,8 +988,6 @@ python.call.graph=Call Graph
|
||||
python.select.locale=Select locale
|
||||
python.locales=Locales
|
||||
python.buildout.failed.to.extract.path=Failed to extract paths from {0}
|
||||
python.docstring.format=Docstring format:
|
||||
python.docstring.select.type=Select Docstring Type
|
||||
python.debugger.collection.signatures.deleted=Collected signatures were deleted
|
||||
python.debugger.nothing.to.delete=Nothing to delete
|
||||
python.rename.processor.override.message=Method {0} of class {1}\noverrides method of class {2}.\nDo you want to rename the base method?
|
||||
|
||||
@@ -183,6 +183,176 @@
|
||||
<localInspection language="Python" shortName="PyChainedComparisonsInspection" suppressId="PyChainedComparisons" bundle="messages.PyPsiBundle" key="INSP.NAME.chained.comparisons" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.PyChainedComparisonsInspection"/>
|
||||
<localInspection language="Python" shortName="PyPep8NamingInspection" suppressId="PyPep8Naming" bundle="messages.PyPsiBundle" key="INSP.pep8.naming" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.PyPep8NamingInspection"/>
|
||||
<localInspection language="Python" shortName="PyShadowingBuiltinsInspection" suppressId="PyShadowingBuiltins" bundle="messages.PyPsiBundle" key="INSP.shadowing.builtins" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.PyShadowingBuiltinsInspection"/>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyConvertMethodToPropertyIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.ImportToImportFromIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyConvertStaticMethodToFunctionIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.SpecifyTypeInDocstringIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.SpecifyTypeInPy3AnnotationsIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyAnnotateTypesIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.TypeAssertionIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.ImportFromToImportIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyAbsoluteToRelativeImportIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyRelativeToAbsoluteImportIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.ImportToggleAliasIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PySplitIfIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyNegateComparisonIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyStringConcatenationToFormatIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.ConvertFormatOperatorToMethodIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyFlipComparisonIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyDemorganIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.ReplaceListComprehensionWithForIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyJoinIfIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyDictConstructorToLiteralFormIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyDictLiteralFormToConstructorIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyQuotedStringIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyConvertLambdaToFunctionIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.ConvertVariadicParamIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyConvertTripleQuotedStringIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyConvertLiteralToTupleIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyConvertLiteralToListIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyConvertLiteralToSetIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyTransformConditionalExpressionIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyGenerateDocstringIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyYieldFromIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.convertToFString.PyConvertToFStringIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyConvertTypeCommentToVariableAnnotationIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>com.jetbrains.python.codeInsight.intentions.PyAnnotateVariableTypeIntention</className>
|
||||
<category>Python</category>
|
||||
</intentionAction>
|
||||
</extensions>
|
||||
|
||||
<extensionPoints>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user