Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2012-09-23 00:31:56 +04:00
40 changed files with 242 additions and 97 deletions
+1 -1
View File
@@ -383,7 +383,7 @@ private layoutWin(Map args, String target) {
}
winScripts(target, "$home/community", "pycharm.bat", args)
winVMOptions(target, args.system_selector, "pycharm.exe", "pycharm64.exe")
winVMOptions(target, args.system_selector, "pycharm.exe")
ant.copy(file: "$home/python/help/pycharmhelp.jar", todir: "$target/help", failonerror: false)
}
@@ -21,7 +21,7 @@ public class PythonSdkComboBox extends ComboboxWithBrowseButton {
private Project myProject;
public PythonSdkComboBox() {
getComboBox().setRenderer(new SdkListCellRenderer("<No Interpreter>", getComboBox().getRenderer()));
getComboBox().setRenderer(new SdkListCellRenderer("<No Interpreter>"));
addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Sdk selectedSdk = getSelectedSdk();
@@ -27,7 +27,7 @@ public class PyManagePackagesDialog extends DialogWrapper {
setTitle("Manage Python Packages");
final JComboBox sdkComboBox = new JComboBox(new CollectionComboBoxModel(PythonSdkType.getAllSdks(), sdk));
sdkComboBox.setRenderer(new PySdkListCellRenderer(sdkComboBox.getRenderer(), null));
sdkComboBox.setRenderer(new PySdkListCellRenderer(null));
PyPackagesNotificationPanel notificationPanel = new PyPackagesNotificationPanel(project);
final PyPackagesPanel packagesPanel = new PyPackagesPanel(project, notificationPanel);
@@ -43,9 +43,9 @@ public class PyPluginCommonOptionsForm implements AbstractPyCommonOptionsForm {
final List<Module> validModules = data.getValidModules();
Module selection = validModules.size() > 0 ? validModules.get(0) : null;
myModuleComboBox.setModel(new CollectionComboBoxModel(validModules, selection));
myModuleComboBox.setRenderer(new PyModuleRenderer(PyPluginCommonOptionsForm.this.myModuleComboBox.getRenderer()));
myModuleComboBox.setRenderer(new PyModuleRenderer());
myInterpreterComboBox.setRenderer(new SdkListCellRenderer("<Project Default>", myInterpreterComboBox.getRenderer()));
myInterpreterComboBox.setRenderer(new SdkListCellRenderer("<Project Default>"));
myWorkingDirectoryTextField.addBrowseFolderListener("Select Working Directory", "", data.getProject(),
FileChooserDescriptorFactory.createSingleFolderDescriptor());
+9 -3
View File
@@ -400,9 +400,15 @@
<applicationService serviceInterface="com.jetbrains.python.documentation.PythonDocumentationMap"
serviceImplementation="com.jetbrains.python.documentation.PythonDocumentationMap"/>
<applicationConfigurable instance="com.jetbrains.python.documentation.PythonDocumentationConfigurable"/>
<projectConfigurable instance="com.jetbrains.python.configuration.PyIntegratedToolsModulesConfigurable"/>
<projectConfigurable instance="com.jetbrains.python.templateLanguages.TemplateLanguageModulesConfigurable"/>
<applicationConfigurable instance="com.jetbrains.python.documentation.PythonDocumentationConfigurable"
id="com.jetbrains.python.documentation.PythonDocumentationConfigurable"
displayName="Python External Documentation"/>
<projectConfigurable instance="com.jetbrains.python.configuration.PyIntegratedToolsModulesConfigurable"
id="com.jetbrains.python.configuration.PyIntegratedToolsModulesConfigurable" displayName="Python Integrated Tools"
nonDefaultProject="true"/>
<projectConfigurable instance="com.jetbrains.python.templateLanguages.TemplateLanguageModulesConfigurable"
id="com.jetbrains.python.templateLanguages.TemplateLanguageModulesConfigurable"
displayName="Python Template Languages"/>
<projectService serviceInterface="com.jetbrains.python.documentation.PyDocumentationSettings"
serviceImplementation="com.jetbrains.python.documentation.PyDocumentationSettings"/>
<psi.referenceContributor implementation="com.jetbrains.python.documentation.DocStringReferenceContributor"/>
@@ -495,6 +495,9 @@ public class StatementMover extends LineMover {
PyStatementList statementList = myStatementPartToRemovePass.getStatementList();
if (statementList != null) {
PyPsiUtils.removeRedundantPass(statementList);
final PsiElement whitespace = myStatementPartToRemovePass.getNextSibling();
if (whitespace instanceof PsiWhiteSpace)
whitespace.delete();
}
}
}
@@ -68,7 +68,7 @@ public abstract class ModuleAwareProjectConfigurable<T extends UnnamedConfigurab
final Splitter splitter = new Splitter(false, 0.25f);
final JBList moduleList = new JBList(new CollectionListModel<Module>(modules));
moduleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
moduleList.setCellRenderer(new PyModuleRenderer(moduleList.getCellRenderer()));
moduleList.setCellRenderer(new PyModuleRenderer());
splitter.setFirstComponent(new JBScrollPane(moduleList));
final CardLayout layout = new CardLayout();
final JPanel cardPanel = new JPanel(layout);
@@ -113,7 +113,7 @@ public class PythonCopyPasteProcessor implements CopyPastePreProcessor {
newText = new String(text); // to indent correctly (see PasteHandler)
}
if (element instanceof PsiWhiteSpace &&
if ((element instanceof PsiWhiteSpace || element.getTextOffset() == 0) &&
(StringUtil.countChars(element.getText(), '\n') <= 2 && !StringUtil.isEmptyOrSpaces(text))) {
newText += "\n";
}
@@ -8,6 +8,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.IFileElementType;
import com.intellij.psi.tree.TokenSet;
import com.jetbrains.python.PythonDialectsTokenSetProvider;
@@ -20,6 +21,7 @@ import static com.jetbrains.python.PyTokenTypes.*;
/**
* @author yole
*/
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, CustomFormattingModelBuilder {
private static final boolean DUMP_FORMATTING_AST = false;
@@ -50,12 +52,12 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
protected SpacingBuilder createSpacingBuilder(CodeStyleSettings settings) {
final IFileElementType file = LanguageParserDefinitions.INSTANCE.forLanguage(PythonLanguage.getInstance()).getFileNodeType();
final PyCodeStyleSettings pySettings = settings.getCustomSettings(PyCodeStyleSettings.class);
final TokenSet STATEMENT_OR_DECLARATION = TokenSet.orSet(PythonDialectsTokenSetProvider.INSTANCE.getStatementTokens(),
CLASS_OR_FUNCTION);
final TokenSet STATEMENT_OR_DECLARATION =
TokenSet.orSet(PythonDialectsTokenSetProvider.INSTANCE.getStatementTokens(), CLASS_OR_FUNCTION);
final CommonCodeStyleSettings commonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
return new SpacingBuilder(settings)
.between(IMPORT_STATEMENTS, STATEMENT_OR_DECLARATION.minus(IMPORT_STATEMENTS)).blankLines(commonSettings.BLANK_LINES_AFTER_IMPORTS)
.between(IMPORT_STATEMENTS, TokenSet.andNot(STATEMENT_OR_DECLARATION, IMPORT_STATEMENTS)).blankLines(commonSettings.BLANK_LINES_AFTER_IMPORTS)
.betweenInside(CLASS_OR_FUNCTION, CLASS_OR_FUNCTION, file).blankLines(pySettings.BLANK_LINES_BETWEEN_TOP_LEVEL_CLASSES_FUNCTIONS)
.between(CLASS_DECLARATION, STATEMENT_OR_DECLARATION).blankLines(commonSettings.BLANK_LINES_AROUND_CLASS)
.between(STATEMENT_OR_DECLARATION, CLASS_DECLARATION).blankLines(commonSettings.BLANK_LINES_AROUND_CLASS)
@@ -71,9 +73,9 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
.afterInside(GT, ANNOTATION).spaces(1)
.betweenInside(MINUS, GT, ANNOTATION).none()
.beforeInside(ANNOTATION, FUNCTION_DECLARATION).spaces(1)
.between(TokenSet.not(TokenSet.create(LAMBDA_KEYWORD)), PARAMETER_LIST).spaceIf(commonSettings.SPACE_BEFORE_METHOD_PARENTHESES)
.between(allButLambda(), PARAMETER_LIST).spaceIf(commonSettings.SPACE_BEFORE_METHOD_PARENTHESES)
.before(COLON).spaceIf(pySettings.SPACE_BEFORE_PY_COLON)
.after(COMMA).spaceIf(commonSettings.SPACE_AFTER_COMMA)
.before(COMMA).spaceIf(commonSettings.SPACE_BEFORE_COMMA)
@@ -103,6 +105,16 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
.around(IN_KEYWORD).spaces(1);
}
private static TokenSet allButLambda() {
final PythonLanguage pythonLanguage = PythonLanguage.getInstance();
return TokenSet.create(IElementType.enumerate(new IElementType.Predicate() {
@Override
public boolean matches(IElementType type) {
return type != LAMBDA_KEYWORD && type.getLanguage().isKindOf(pythonLanguage);
}
}));
}
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
@@ -12,12 +12,10 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.AnActionButton;
import com.intellij.ui.CollectionListModel;
import com.intellij.ui.FilterComponent;
import com.intellij.ui.ToolbarDecorator;
import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
import com.intellij.ui.table.JBTable;
import com.intellij.util.Function;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.update.UiNotifyConnector;
import com.jetbrains.python.packaging.*;
@@ -82,6 +80,7 @@ public class ManagePackagesDialog extends DialogWrapper {
private final PyPackagesPanel myPackageListPanel;
private Set<String> currentlyInstalling = new HashSet<String>();
protected final ListSpeedSearch myListSpeedSearch;
public ManagePackagesDialog(@NotNull Project project, @NotNull final Sdk sdk, @NotNull final PyPackagesPanel packageListPanel) {
super(false);
@@ -125,6 +124,14 @@ public class ManagePackagesDialog extends DialogWrapper {
});
}
};
myListSpeedSearch = new ListSpeedSearch(this.myPackages, new Function<Object, String>() {
@Override
public String fun(Object o) {
if (o instanceof ComparablePair)
return ((ComparablePair)o).getFirst();
return "";
}
});
myPackagesPanel = ToolbarDecorator.createDecorator(this.myPackages).disableAddAction().
disableUpDownActions().disableRemoveAction().addExtraAction(reloadButton).createPanel();
myPackagesPanel.setPreferredSize(new Dimension(400, -1));
@@ -2,27 +2,22 @@ package com.jetbrains.python.run;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.ui.HtmlListCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.ListCellRendererWrapper;
import javax.swing.*;
/**
* @author yole
*/
public class PyModuleRenderer extends HtmlListCellRenderer<Module> {
public PyModuleRenderer(final ListCellRenderer renderer) {
super();
}
public class PyModuleRenderer extends ListCellRendererWrapper<Module> {
@Override
protected void doCustomize(JList list, Module module, int index, boolean selected, boolean hasFocus) {
public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) {
if (module == null) {
append("[none]", SimpleTextAttributes.REGULAR_ATTRIBUTES);
setText("[none]");
}
else {
setIcon(ModuleType.get(module).getIcon());
append(module.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
setText(module.getName());
}
}
}
@@ -10,7 +10,6 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.platform.LocationNameFieldsBinding;
import com.intellij.ui.CollectionComboBoxModel;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.HtmlListCellRenderer;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.util.PathUtil;
import com.jetbrains.python.packaging.PyPackageService;
@@ -158,8 +157,7 @@ public class CreateVirtualEnvDialog extends IdeaDialog {
}
private void updateSdkList(Sdk sdk, final List<Sdk> allSdks) {
final HtmlListCellRenderer<Sdk> sdkListCellRenderer = new PySdkListCellRenderer(mySdkCombo.getRenderer(), null);
mySdkCombo.setRenderer(sdkListCellRenderer);
mySdkCombo.setRenderer(new PySdkListCellRenderer(null));
List<Sdk> baseSdks = new ArrayList<Sdk>();
for (Sdk s : allSdks) {
if (!PythonSdkType.isInvalid(s) && !PythonSdkType.isVirtualEnv(s) && !PythonRemoteSdkAdditionalData.isRemoteSdk(s.getHomePath())) {
@@ -4,34 +4,36 @@ import com.intellij.icons.AllIcons;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkModificator;
import com.intellij.openapi.projectRoots.SdkType;
import com.intellij.ui.HtmlListCellRenderer;
import com.intellij.ui.LayeredIcon;
import com.intellij.ui.ListCellRendererWrapper;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Map;
public class PySdkListCellRenderer extends HtmlListCellRenderer<Sdk> {
private final Map<Sdk, SdkModificator> mySdkModificators;
public class PySdkListCellRenderer extends ListCellRendererWrapper<Sdk> {
private final Map<Sdk, SdkModificator> mySdkModifiers;
public PySdkListCellRenderer(ListCellRenderer listCellRenderer, Map<Sdk, SdkModificator> sdkModificators) {
super();
mySdkModificators = sdkModificators;
public PySdkListCellRenderer(@Nullable Map<Sdk, SdkModificator> sdkModifiers) {
mySdkModifiers = sdkModifiers;
}
@Override
protected void doCustomize(final JList list, final Sdk sdk, final int index, final boolean selected, final boolean hasFocus) {
public void customize(JList list, Sdk sdk, int index, boolean selected, boolean hasFocus) {
if (sdk != null) {
final PythonSdkFlavor flavor = PythonSdkFlavor.getPlatformIndependentFlavor(sdk.getHomePath());
final Icon icon = flavor != null ? flavor.getIcon() : ((SdkType) sdk.getSdkType()).getIcon();
final String name;
if (mySdkModificators != null && mySdkModificators.containsKey(sdk)) {
name = mySdkModificators.get(sdk).getName();
if (mySdkModifiers != null && mySdkModifiers.containsKey(sdk)) {
name = mySdkModifiers.get(sdk).getName();
}
else {
name = sdk.getName();
}
if (PythonSdkType.isInvalid(sdk)) {
append("[invalid] " + name);
setText("[invalid] " + name);
final LayeredIcon layered = new LayeredIcon(2);
layered.setIcon(icon, 0);
// TODO: Create a separate invalid SDK overlay icon
@@ -40,7 +42,7 @@ public class PySdkListCellRenderer extends HtmlListCellRenderer<Sdk> {
setIcon(layered);
}
else {
append(name);
setText(name);
setIcon(icon);
}
}
@@ -214,19 +214,19 @@ public abstract class AbstractPythonTestRunConfiguration extends AbstractPythonR
public String suggestedName() {
switch (myTestType) {
case TEST_CLASS:
return getTitle() + " in " + myClassName;
return getPluralTitle() + " in " + myClassName;
case TEST_METHOD:
return getTitle() + " in " + myClassName + "." + myMethodName;
return getTitle() + " " + myClassName + "." + myMethodName;
case TEST_SCRIPT:
String name = new File(getScriptName()).getName();
if (name.endsWith(".py")) {
name = name.substring(0, name.length() - 3);
}
return getTitle() + " in " + name;
return getPluralTitle() + " in " + name;
case TEST_FOLDER:
return getTitle() + " in " + FileUtil.toSystemDependentName(myFolderName);
return getPluralTitle() + " in " + FileUtil.toSystemDependentName(myFolderName);
case TEST_FUNCTION:
return getTitle() + " in " + myMethodName;
return getTitle() + " " + myMethodName;
default:
throw new IllegalStateException("Unknown test type: " + myTestType);
}
@@ -234,6 +234,8 @@ public abstract class AbstractPythonTestRunConfiguration extends AbstractPythonR
protected abstract String getTitle();
protected abstract String getPluralTitle();
@Override
public RefactoringElementListener getRefactoringElementListener(PsiElement element) {
if (element instanceof PsiDirectory) {
@@ -18,7 +18,8 @@ import org.jetbrains.annotations.NotNull;
*/
public class PythonAtTestRunConfiguration extends AbstractPythonTestRunConfiguration
implements PythonAtTestRunConfigurationParams {
protected String myTitle = "Attests";
protected String myTitle = "Attest";
protected String myPluralTitle = "Attests";
public PythonAtTestRunConfiguration(RunConfigurationModule module,
ConfigurationFactory configurationFactory,
String name) {
@@ -55,6 +56,11 @@ public class PythonAtTestRunConfiguration extends AbstractPythonTestRunConfigura
return myTitle;
}
@Override
protected String getPluralTitle() {
return myPluralTitle;
}
public static void copyParams(PythonAtTestRunConfigurationParams source, PythonAtTestRunConfigurationParams target) {
copyParams(source.getTestRunConfigurationParams(), target.getTestRunConfigurationParams());
}
@@ -16,7 +16,8 @@ import org.jetbrains.annotations.NotNull;
*/
public class PythonDocTestRunConfiguration extends AbstractPythonTestRunConfiguration
implements PythonDocTestRunConfigurationParams {
protected String myTitle = "Doctests";
protected String myPluralTitle = "Doctests";
protected String myTitle = "Doctest";
public PythonDocTestRunConfiguration(RunConfigurationModule module,
ConfigurationFactory configurationFactory,
String name) {
@@ -53,6 +54,11 @@ public class PythonDocTestRunConfiguration extends AbstractPythonTestRunConfigur
return myTitle;
}
@Override
protected String getPluralTitle() {
return myPluralTitle;
}
public static void copyParams(PythonDocTestRunConfigurationParams source, PythonDocTestRunConfigurationParams target) {
copyParams(source.getTestRunConfigurationParams(), target.getTestRunConfigurationParams());
}
@@ -20,7 +20,8 @@ import org.jetbrains.annotations.NotNull;
public class PythonNoseTestRunConfiguration extends AbstractPythonTestRunConfiguration
implements PythonNoseTestRunConfigurationParams {
private String myParams = ""; // parameters for nosetests
protected String myTitle = "Nosetests";
protected String myTitle = "Nosetest";
protected String myPluralTitle = "Nosetests";
private boolean useParam = false;
public PythonNoseTestRunConfiguration(RunConfigurationModule module,
@@ -58,6 +59,11 @@ public class PythonNoseTestRunConfiguration extends AbstractPythonTestRunConfigu
return myTitle;
}
@Override
protected String getPluralTitle() {
return myPluralTitle;
}
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
return new PythonNoseTestCommandLineState(this, env);
}
@@ -25,6 +25,10 @@ public class PyTestRunConfiguration extends AbstractPythonTestRunConfiguration i
private boolean useParam = false;
private boolean useKeyword = false;
protected String myTitle = "py.test";
protected String myPluralTitle = "py.tests";
private static final String TEST_TO_RUN_FIELD = "testToRun";
private static final String KEYWORDS_FIELD = "keywords";
private static final String PARAMS_FIELD = "params";
@@ -126,6 +130,11 @@ public class PyTestRunConfiguration extends AbstractPythonTestRunConfiguration i
@Override
protected String getTitle() {
return "py.tests";
return myTitle;
}
@Override
protected String getPluralTitle() {
return myPluralTitle;
}
}
@@ -19,7 +19,8 @@ public class PythonUnitTestRunConfiguration extends
AbstractPythonTestRunConfiguration
implements PythonUnitTestRunConfigurationParams {
private boolean myIsPureUnittest = true;
protected String myTitle = "Unittests";
protected String myTitle = "Unittest";
protected String myPluralTitle = "Unittests";
public PythonUnitTestRunConfiguration(RunConfigurationModule module,
ConfigurationFactory configurationFactory,
@@ -59,6 +60,11 @@ public class PythonUnitTestRunConfiguration extends
return myTitle;
}
@Override
protected String getPluralTitle() {
return myPluralTitle;
}
public static void copyParams(PythonUnitTestRunConfigurationParams source, PythonUnitTestRunConfigurationParams target) {
copyParams(source.getTestRunConfigurationParams(), target.getTestRunConfigurationParams());
target.setPureUnittest(source.isPureUnittest());
@@ -0,0 +1,3 @@
a = 1
b = 2
a = 1
@@ -0,0 +1,2 @@
<caret>b = 2
a = 1
@@ -0,0 +1,3 @@
b = 2
<selection>a = 1
</selection>
@@ -0,0 +1 @@
<weak_warning descr="Assignment can be replaced with augmented assignment">var_1 = var_1 + 1</weak_warning>
@@ -0,0 +1,8 @@
# PY-2488
<weak_warning descr="Assignment can be replaced with augmented assignment">a = a ** 1</weak_warning>
<weak_warning descr="Assignment can be replaced with augmented assignment">x = x % 3</weak_warning>
<weak_warning descr="Assignment can be replaced with augmented assignment">x = x | 3</weak_warning>
<weak_warning descr="Assignment can be replaced with augmented assignment">x = x & 3</weak_warning>
<weak_warning descr="Assignment can be replaced with augmented assignment">x = x ^ 3</weak_warning>
@@ -0,0 +1,2 @@
# PY-2483
<weak_warning descr="Assignment can be replaced with augmented assignment">list[0] = list[0] + 1</weak_warning>
@@ -0,0 +1 @@
<weak_warning descr="Assignment can be replaced with augmented assignment">var = var * 2</weak_warning>
@@ -0,0 +1,2 @@
var_7 += 2
@@ -0,0 +1,5 @@
str = "string"
var_3 = var_3
var_4 = 1
@@ -0,0 +1,3 @@
#PY-2514
dy = 1 - dy
@@ -0,0 +1,8 @@
#PY-6331
var = "string"
var = "some " + var
#PY-6490
foo = "a"
bar = "b"
foo = bar + foo
@@ -0,0 +1,8 @@
var_3 = var_3
var_4 = 1
<weak_warning descr="Assignment can be replaced with augmented assignment">var_6 = var_6 + var_4</weak_warning>
#PY-2482
<weak_warning descr="Assignment can be replaced with augmented assignment">var = 2 + var</weak_warning>
@@ -0,0 +1,7 @@
str = "string"
<weak_warning descr="Assignment can be replaced with augmented assignment">var_2 = var_2 + str</weak_warning>
var_3 = var_3
var_4 = 1
<weak_warning descr="Assignment can be replaced with augmented assignment">var_5 = var_5 + "string"</weak_warning>
@@ -1,39 +0,0 @@
<weak_warning descr="Assignment can be replaced with augmented assignment">var = var * 2</weak_warning>
<weak_warning descr="Assignment can be replaced with augmented assignment">var_1 = var_1 + 1</weak_warning>
str = "string"
<weak_warning descr="Assignment can be replaced with augmented assignment">var_2 = var_2 + str</weak_warning>
var_3 = var_3
var_4 = 1
<weak_warning descr="Assignment can be replaced with augmented assignment">var_5 = var_5 + "string"</weak_warning>
<weak_warning descr="Assignment can be replaced with augmented assignment">var_6 = var_6 + var_4</weak_warning>
var_7 += 2
#PY-2482
<weak_warning descr="Assignment can be replaced with augmented assignment">var = 2 + var</weak_warning>
# PY-2483
<weak_warning descr="Assignment can be replaced with augmented assignment">list[0] = list[0] + 1</weak_warning>
# PY-2488
<weak_warning descr="Assignment can be replaced with augmented assignment">a = a ** 1</weak_warning>
<weak_warning descr="Assignment can be replaced with augmented assignment">x = x % 3</weak_warning>
<weak_warning descr="Assignment can be replaced with augmented assignment">x = x | 3</weak_warning>
<weak_warning descr="Assignment can be replaced with augmented assignment">x = x & 3</weak_warning>
<weak_warning descr="Assignment can be replaced with augmented assignment">x = x ^ 3</weak_warning>
#PY-2514
dy = 1 - dy
#PY-6331
var = "string"
var = "some " + var
#PY-6490
foo = "a"
bar = "b"
foo = bar + foo
+5
View File
@@ -0,0 +1,5 @@
a = <caret>1 # <- move statement down here
if True:
pass
else:
b = 2
@@ -0,0 +1,4 @@
if True:
a = 1 # <- move statement down here
else:
b = 2
@@ -0,0 +1,5 @@
a = 1 # <- move statement down here
if True:
pass
else:
b = 2
@@ -255,6 +255,10 @@ public class PyCopyPasteTest extends PyTestCase {
doTest();
}
public void testBeginningOfFile() { //PY-7524
doTest();
}
private void doTest() {
String name = getTestName(false);
@@ -173,6 +173,10 @@ public class PyStatementMoverTest extends PyTestCase {
doTest();
}
public void testRemovePass() { // PY-6282
doTest();
}
public void testWith() { // PY-5202
try {
setLanguageLevel(LanguageLevel.PYTHON27);
@@ -259,10 +259,6 @@ public class PythonInspectionsTest extends PyTestCase {
doHighlightingTest(PyBroadExceptionInspection.class);
}
public void testPyAugmentAssignmentInspection() {
doHighlightingTest(PyAugmentAssignmentInspection.class);
}
public void testPyDictDuplicateKeysInspection() {
doHighlightingTest(PyDictDuplicateKeysInspection.class);
}
@@ -0,0 +1,55 @@
package com.jetbrains.python.inspections;
import com.jetbrains.python.fixtures.PyTestCase;
/**
* User: ktisha
*/
public class PyAugmentAssignmentInspectionTest extends PyTestCase {
public void testMult() {
doTest();
}
public void testAdd() {
doTest();
}
public void testNegativeAssignment() {
doTest();
}
public void testNegative() {
doTest();
}
public void testNegativeMinus() {
doTest();
}
public void testNegativeString() {
doTest();
}
public void testString() {
doTest();
}
public void testNumeric() {
doTest();
}
public void testList() {
doTest();
}
public void testDifferentOperations() {
doTest();
}
private void doTest() {
myFixture.configureByFile("inspections/PyAugmentAssignmentInspection/" + getTestName(true) + ".py");
myFixture.enableInspections(PyAugmentAssignmentInspection.class);
myFixture.checkHighlighting(true, false, true);
}
}