diff --git a/bin/scripts/unix/idea.sh b/bin/scripts/unix/idea.sh index 2bfd582f3f62..786a99486585 100755 --- a/bin/scripts/unix/idea.sh +++ b/bin/scripts/unix/idea.sh @@ -51,7 +51,11 @@ if [ -x "$READLINK" ]; then fi IDE_BIN_HOME=`dirname "$SCRIPT_LOCATION"` -IDE_HOME=`dirname "$IDE_BIN_HOME"` +if [ "$IDE_BIN_HOME" = "." ]; then + IDE_HOME=".." +else + IDE_HOME=`dirname "$IDE_BIN_HOME"` +fi # --------------------------------------------------------------------- # Locate a JDK installation directory which will be used to run the IDE. diff --git a/build/cucumber-test-runner/src/com/intellij/cucumber/CucumberMain.java b/build/cucumber-test-runner/src/com/intellij/cucumber/CucumberMain.java index 120d43d18c04..74461c6f3fa4 100644 --- a/build/cucumber-test-runner/src/com/intellij/cucumber/CucumberMain.java +++ b/build/cucumber-test-runner/src/com/intellij/cucumber/CucumberMain.java @@ -46,7 +46,6 @@ public class CucumberMain { exitStatus = 1; } System.exit(exitStatus); - } public static int run(final String[] argv, final ClassLoader classLoader) throws IOException { diff --git a/java/java-impl/src/com/intellij/reporting/ReportMissingOrExcessiveInlineHint.kt b/java/java-impl/src/com/intellij/reporting/ReportMissingOrExcessiveInlineHint.kt index 544a739d08c6..fc6772fddd04 100644 --- a/java/java-impl/src/com/intellij/reporting/ReportMissingOrExcessiveInlineHint.kt +++ b/java/java-impl/src/com/intellij/reporting/ReportMissingOrExcessiveInlineHint.kt @@ -95,7 +95,7 @@ class ReportMissingOrExcessiveInlineHint : AnAction() { ApplicationManager.getApplication().executeOnPooledThread { val text = file.readText() LOG.debug("File text $text") - if (StatsSender.send(text)) { + if (StatsSender.send(text, compress = false)) { file.delete() LOG.debug("File deleted") } diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java index 497b88fe2218..5def887f1990 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java @@ -861,4 +861,15 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { schemeName.substring(DefaultColorsScheme.EDITABLE_COPY_PREFIX.length()) : schemeName; } + + + @Nullable + public AbstractColorsScheme getOriginal() { + String originalSchemeName = getMetaProperties().getProperty(META_INFO_ORIGINAL); + if (originalSchemeName != null) { + EditorColorsScheme originalScheme = EditorColorsManager.getInstance().getScheme(originalSchemeName); + if (originalScheme instanceof AbstractColorsScheme) return (AbstractColorsScheme)originalScheme; + } + return null; + } } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java index f413476106f8..f8907df084c4 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java @@ -27,6 +27,7 @@ import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationBundle; import com.intellij.openapi.application.ApplicationNamesInfo; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.colors.*; import com.intellij.openapi.editor.colors.impl.*; import com.intellij.openapi.editor.markup.EffectType; @@ -72,6 +73,8 @@ import java.util.List; public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract implements EditorOptionsProvider { public static final String ID = "reference.settingsdialog.IDE.editor.colors"; + + private static Logger LOG = Logger.getInstance("#" + ColorAndFontOptions.class.getName()); private Map mySchemes; private MyColorScheme mySelectedScheme; @@ -245,6 +248,16 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract resetSchemesCombo(null); mySomeSchemesDeleted = mySomeSchemesDeleted || !deletedNewlyCreated; } + + + void resetSchemeToOriginal(@NotNull String name) { + MyColorScheme schemeToReset = mySchemes.get(name); + schemeToReset.resetToOriginal(); + resetImpl(); + selectScheme(name); + resetSchemesCombo(null); + ((EditorColorsManagerImpl)EditorColorsManager.getInstance()).schemeChangedOrSwitched(null); + } @Override public void apply() throws ConfigurationException { @@ -1167,6 +1180,16 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract } return false; } + + public void resetToOriginal() { + if (myParentScheme instanceof AbstractColorsScheme) { + AbstractColorsScheme originalScheme = ((AbstractColorsScheme)myParentScheme).getOriginal(); + if (originalScheme != null) { + originalScheme.copyTo((AbstractColorsScheme)myParentScheme); + ((AbstractColorsScheme)myParentScheme).setSaveNeeded(true); + } + } + } } @Override diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java b/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java index c9fceee7ab3a..547e7af7897c 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java @@ -21,9 +21,7 @@ import com.intellij.application.options.SaveSchemeDialog; import com.intellij.application.options.SkipSelfSearchComponent; import com.intellij.openapi.application.ApplicationBundle; import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme; -import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl; -import com.intellij.openapi.editor.colors.impl.EmptyColorScheme; +import com.intellij.openapi.editor.colors.impl.*; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.options.SchemeImportException; import com.intellij.openapi.options.SchemeImportUtil; @@ -32,6 +30,7 @@ import com.intellij.openapi.options.SchemeImporterEP; import com.intellij.openapi.project.DefaultProjectFactory; import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.MessageType; +import com.intellij.openapi.ui.Messages; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.EventDispatcher; import com.intellij.util.containers.ContainerUtil; @@ -51,6 +50,7 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { private ComboBox mySchemeComboBox; private JButton myDeleteButton; + private JButton myResetButton; private JButton myImportButton; private JLabel myHintLabel; @@ -79,6 +79,12 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { if (areSchemesLoaded()) { myDispatcher.getMulticaster().schemeChanged(SchemesPanel.this); } + AbstractColorsScheme originalScheme = + selected instanceof AbstractColorsScheme ? ((AbstractColorsScheme)selected).getOriginal() : null; + myResetButton.setEnabled( + !readOnly && + selectedName.startsWith(DefaultColorsScheme.EDITABLE_COPY_PREFIX) && + originalScheme instanceof ReadOnlyColorsScheme); } } }); @@ -128,6 +134,23 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { panel.add(myDeleteButton, new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new JBInsets(0, 0, 5, 5), 0, 0)); + myResetButton = new JButton(ApplicationBundle.message("color.scheme.reset")); + myResetButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(@NotNull ActionEvent e) { + String selectedName = getSelectedSchemeName(); + if (selectedName != null) { + if (Messages + .showOkCancelDialog(ApplicationBundle.message("color.scheme.reset.message"), + ApplicationBundle.message("color.scheme.reset.title"), Messages.getQuestionIcon()) == Messages.OK) { + myOptions.resetSchemeToOriginal(selectedName); + } + } + } + }); + panel.add(myResetButton, + new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new JBInsets(0, 0, 5, 5), 0, + 0)); myImportButton = new JButton("Import..."); myImportButton.addActionListener(new ActionListener() { @Override diff --git a/platform/lang-impl/src/com/intellij/find/EditorSearchSession.java b/platform/lang-impl/src/com/intellij/find/EditorSearchSession.java index 6df0f6ab9fff..e825aa99611b 100644 --- a/platform/lang-impl/src/com/intellij/find/EditorSearchSession.java +++ b/platform/lang-impl/src/com/intellij/find/EditorSearchSession.java @@ -16,6 +16,7 @@ package com.intellij.find; +import com.intellij.execution.impl.ConsoleViewUtil; import com.intellij.find.editorHeaderActions.*; import com.intellij.find.impl.livePreview.LivePreviewController; import com.intellij.find.impl.livePreview.SearchResults; @@ -154,7 +155,7 @@ public class EditorSearchSession implements SearchSession, updateUIWithFindModel(); mySearchResults.clear(); updateResults(true); - FindUtil.updateFindInFileModel(getProject(), myFindModel); + FindUtil.updateFindInFileModel(getProject(), myFindModel, !ConsoleViewUtil.isConsoleViewEditor(editor)); } }); diff --git a/platform/lang-impl/src/com/intellij/find/FindUtil.java b/platform/lang-impl/src/com/intellij/find/FindUtil.java index 13700a68f07c..ca8c1af0bccd 100644 --- a/platform/lang-impl/src/com/intellij/find/FindUtil.java +++ b/platform/lang-impl/src/com/intellij/find/FindUtil.java @@ -143,14 +143,20 @@ public class FindUtil { model.setPromptOnReplace(false); } - public static void updateFindInFileModel(@Nullable Project project, @NotNull FindModel with) { + public static void updateFindInFileModel(@Nullable Project project, @NotNull FindModel with, boolean saveFindString) { FindModel model = FindManager.getInstance(project).getFindInFileModel(); model.setCaseSensitive(with.isCaseSensitive()); model.setWholeWordsOnly(with.isWholeWordsOnly()); model.setRegularExpressions(with.isRegularExpressions()); model.setSearchContext(with.getSearchContext()); + + if (saveFindString && !with.getStringToFind().isEmpty()) { + model.setStringToFind(with.getStringToFind()); + } + if (with.isReplaceState()) { model.setPreserveCase(with.isPreserveCase()); + if (saveFindString) model.setStringToReplace(with.getStringToReplace()); } } diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/actions/IncrementalFindAction.java b/platform/lang-impl/src/com/intellij/openapi/editor/actions/IncrementalFindAction.java index 347cb9e52d40..015ecdbe9026 100644 --- a/platform/lang-impl/src/com/intellij/openapi/editor/actions/IncrementalFindAction.java +++ b/platform/lang-impl/src/com/intellij/openapi/editor/actions/IncrementalFindAction.java @@ -28,7 +28,6 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.actionSystem.EditorAction; import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.project.Project; -import com.intellij.openapi.wm.IdeFocusManager; public class IncrementalFindAction extends EditorAction { public static class Handler extends EditorActionHandler { @@ -57,9 +56,14 @@ public class IncrementalFindAction extends EditorAction { model = new FindModel(); model.copyFrom(findManager.getFindInFileModel()); } - FindUtil.configureFindModel(myReplace, editor, model, true); + boolean consoleViewEditor = ConsoleViewUtil.isConsoleViewEditor(editor); + FindUtil.configureFindModel(myReplace, editor, model, consoleViewEditor); EditorSearchSession.start(editor, model, project).getComponent() .requestFocusInTheSearchFieldAndSelectContent(project); + if (!consoleViewEditor && editor.getSelectionModel().hasSelection()) { + // selection is used as string to find without search model modification so save the pattern explicitly + FindUtil.updateFindInFileModel(project, model, true); + } } } } diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java index 5fa1eb211f74..7adff76945de 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java @@ -24,6 +24,7 @@ import com.intellij.openapi.command.UndoConfirmationPolicy; import com.intellij.openapi.editor.*; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; +import com.intellij.reporting.FreezeLogger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -132,7 +133,7 @@ public class TypedAction { public final void actionPerformed(@Nullable final Editor editor, final char charTyped, final DataContext dataContext) { if (editor == null) return; Project project = CommonDataKeys.PROJECT.getData(dataContext); - FreezeLogger.runUnderPerformanceMonitor(project, () -> myRawHandler.execute(editor, charTyped, dataContext)); + FreezeLogger.getInstance().runUnderPerformanceMonitor(project, () -> myRawHandler.execute(editor, charTyped, dataContext)); } private class DefaultRawHandler implements TypedActionHandler { diff --git a/platform/platform-api/src/com/intellij/reporting/FreezeLogger.java b/platform/platform-api/src/com/intellij/reporting/FreezeLogger.java new file mode 100644 index 000000000000..7db0f94b6297 --- /dev/null +++ b/platform/platform-api/src/com/intellij/reporting/FreezeLogger.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2016 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. + */ +package com.intellij.reporting; + +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public abstract class FreezeLogger { + + public static FreezeLogger getInstance() { + return ServiceManager.getService(FreezeLogger.class); + } + + public abstract void runUnderPerformanceMonitor(@Nullable Project project, @NotNull Runnable action); + +} diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/FreezeLogger.java b/platform/platform-impl/src/com/intellij/reporting/FreezeLoggerImpl.java similarity index 63% rename from platform/platform-api/src/com/intellij/openapi/editor/actionSystem/FreezeLogger.java rename to platform/platform-impl/src/com/intellij/reporting/FreezeLoggerImpl.java index 31567aade6b0..2c9214a6d238 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/FreezeLogger.java +++ b/platform/platform-impl/src/com/intellij/reporting/FreezeLoggerImpl.java @@ -13,25 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.openapi.editor.actionSystem; +package com.intellij.reporting; import com.intellij.diagnostic.ThreadDumper; +import com.intellij.openapi.application.ApplicationInfo; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; import com.intellij.util.Alarm; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class FreezeLogger { +public class FreezeLoggerImpl extends FreezeLogger { - private static final Logger LOG = Logger.getInstance(FreezeLogger.class); + private static final Logger LOG = Logger.getInstance(FreezeLoggerImpl.class); private static final Alarm ALARM = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, ApplicationManager.getApplication()); private static final int MAX_ALLOWED_TIME = 500; - public static void runUnderPerformanceMonitor(@Nullable Project project, @NotNull Runnable action) { + @Override + public void runUnderPerformanceMonitor(@Nullable Project project, @NotNull Runnable action) { if (ApplicationManager.getApplication().isUnitTestMode()) { action.run(); return; @@ -64,8 +67,35 @@ public class FreezeLogger { final String msg = "Typing freeze report, (DumbMode=" + isInDumbMode + ") thread dumps attached. EDT stacktrace:\n" + edtTrace + "\n\n\n"; - - LOG.error(msg, dumps); + + if (Registry.is("typing.freeze.report.dumps")) { + ThreadDumpInfo info = new ThreadDumpInfo(dumps, isInDumbMode); + String report = ReporterKt.createReportLine("typing-freeze-dumps", info); + if (!StatsSender.INSTANCE.send(report, true)) { + LOG.debug("Error while reporting thread dump"); + } + } + else { + LOG.error(msg, dumps); + } } +} + +class ThreadDumpInfo { + public final String dump; + public final String version; + public final String product; + public final String buildNumber; + public final boolean isEAP; + public final boolean isInDumbMode; + + public ThreadDumpInfo(String dump, boolean isInDumbMode) { + this.dump = dump; + this.product = ApplicationInfo.getInstance().getVersionName(); + this.version = ApplicationInfo.getInstance().getFullVersion(); + this.buildNumber = ApplicationInfo.getInstance().getBuild().toString(); + this.isEAP = ApplicationManager.getApplication().isEAP(); + this.isInDumbMode = isInDumbMode; + } } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/reporting/Reporter.kt b/platform/platform-impl/src/com/intellij/reporting/Reporter.kt index 10117bd1d4d8..c867421a4852 100644 --- a/platform/platform-impl/src/com/intellij/reporting/Reporter.kt +++ b/platform/platform-impl/src/com/intellij/reporting/Reporter.kt @@ -15,14 +15,21 @@ */ package com.intellij.reporting +import com.google.common.net.HttpHeaders import com.google.gson.Gson import com.intellij.openapi.application.PermanentInstallationID import com.intellij.openapi.diagnostic.Logger +import org.apache.commons.codec.binary.Base64OutputStream import org.apache.http.client.fluent.Request import org.apache.http.entity.ContentType +import org.apache.http.message.BasicHeader +import java.io.ByteArrayOutputStream +import java.util.zip.GZIPOutputStream -private class StatsServerInfo(@JvmField var status: String, @JvmField var url: String) { +private class StatsServerInfo(@JvmField var status: String, + @JvmField var url: String, + @JvmField var urlForZipBase64Content: String) { fun isServiceAlive() = "ok" == status } @@ -30,16 +37,15 @@ private object Utils { val gson = Gson() } - object StatsSender { private val infoUrl = "https://www.jetbrains.com/config/features-service-status.json" private val LOG = Logger.getInstance(StatsSender::class.java) - - private fun requestServerUrl(): String? { + + private fun requestServerUrl(): StatsServerInfo? { try { val response = Request.Get(infoUrl).execute().returnContent().asString() val info = Utils.gson.fromJson(response, StatsServerInfo::class.java) - if (info.isServiceAlive()) return info.url + if (info.isServiceAlive()) return info } catch (e: Exception) { LOG.debug(e) @@ -47,11 +53,11 @@ object StatsSender { return null } - - fun send(text: String): Boolean { - val url = requestServerUrl() ?: return false + + fun send(text: String, compress: Boolean = true): Boolean { + val info = requestServerUrl() ?: return false try { - val response = Request.Post(url).bodyString(text, ContentType.TEXT_HTML).execute() + val response = createRequest(info, text, compress).execute() val code = response.handleResponse { it.statusLine.statusCode } if (code >= 200 && code < 300) { return true @@ -62,7 +68,28 @@ object StatsSender { } return false } - + + private fun createRequest(info: StatsServerInfo, text: String, compress: Boolean): Request { + if (compress) { + val data = Base64GzipCompressor.compress(text) + val request = Request.Post(info.urlForZipBase64Content).bodyByteArray(data) + request.addHeader(BasicHeader(HttpHeaders.CONTENT_ENCODING, "gzip")) + return request + } + + return Request.Post(info.url).bodyString(text, ContentType.TEXT_HTML) + } + +} + +private object Base64GzipCompressor { + fun compress(text: String): ByteArray { + val outputStream = ByteArrayOutputStream() + val base64Stream = GZIPOutputStream(Base64OutputStream(outputStream)) + base64Stream.write(text.toByteArray()) + base64Stream.close() + return outputStream.toByteArray() + } } fun createReportLine(recorderId: String, data: T): String { diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties index 8fa5a4e63a04..a149ef0c2b97 100644 --- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties +++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties @@ -762,4 +762,8 @@ checkbox.stop.4=Stop #4 checkbox.stop.5=Stop #5 checkbox.rainbow=Unique color for each parameter
and local variable
Chosen from generated gradient label.rainbow.inheritance=
''{0}->Unique color''
of {2} -label.rainbow.inheritance.tooltip=''{0}->Unique color'' from
''{1}'' section \ No newline at end of file +label.rainbow.inheritance.tooltip=''{0}->Unique color'' from
''{1}'' section + +color.scheme.reset=Reset +color.scheme.reset.message=Reset the scheme to its default values?\nNote: all the changes you have made to the scheme will be lost. +color.scheme.reset.title=Scheme Reset \ No newline at end of file diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 4c2e426a25c4..b7970bf6bcbf 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -141,6 +141,8 @@ + 0) { if (isEven && (i & 1) != 1) { final PsiJavaToken token = polyadicExpression.getTokenBeforeOperand(operand); diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ComparisonUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ComparisonUtils.java index 78e5e1d02d08..889f4fc48f92 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ComparisonUtils.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ComparisonUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2016 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,10 +15,10 @@ */ package com.siyeh.ig.psiutils; -import com.intellij.psi.*; +import com.intellij.psi.JavaTokenType; +import com.intellij.psi.PsiExpression; +import com.intellij.psi.PsiPolyadicExpression; import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.TypeConversionUtil; -import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -60,37 +60,6 @@ public class ComparisonUtils { s_invertedComparisons.put(JavaTokenType.LE, ">"); } - /** - * Returns the actual type of compared values in comparison expression after unboxing and promotion if applicable. - * - * @param expression the expression to get the type of compared values - * @return the resulting type or null if expression is not a comparison or type is not known. - */ - @Contract("null -> null") - @Nullable - public static PsiType getComparisonType(PsiExpression expression) { - if(!(expression instanceof PsiPolyadicExpression)) return null; - PsiPolyadicExpression operation = (PsiPolyadicExpression)expression; - IElementType tokenType = operation.getOperationTokenType(); - if (!isComparisonOperation(tokenType)) return null; - PsiType lType; - PsiType rType; - if(operation instanceof PsiBinaryExpression) { - PsiExpression left = ((PsiBinaryExpression)operation).getLOperand(); - PsiExpression right = ((PsiBinaryExpression)operation).getROperand(); - lType = left.getType(); - rType = right == null ? null : right.getType(); - } else { - PsiExpression[] operands = operation.getOperands(); - if(operands.length <= 2) return null; - lType = PsiType.BOOLEAN; - rType = operands[operands.length-1].getType(); - } - if (lType == null || rType == null) return null; - if (lType.equals(rType)) return lType; - return TypeConversionUtil.unboxAndBalanceTypes(lType, rType); - } - public static boolean isComparison(@Nullable PsiExpression expression) { if (!(expression instanceof PsiPolyadicExpression)) { return false; diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/double_negation/DoubleDoubleNegation.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/double_negation/DoubleDoubleNegation.after.java new file mode 100644 index 000000000000..16c2a617ba73 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/double_negation/DoubleDoubleNegation.after.java @@ -0,0 +1,5 @@ +class X { + void vm(Double a, Double b) { + boolean r = a == null || b != null; + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/double_negation/DoubleDoubleNegation.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/double_negation/DoubleDoubleNegation.java new file mode 100644 index 000000000000..4604a99ec3e1 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/controlflow/double_negation/DoubleDoubleNegation.java @@ -0,0 +1,5 @@ +class X { + void vm(Double a, Double b) { + boolean r = !(a != null) || b != null; + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/confusing_else/ConfusingElse.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/confusing_else/ConfusingElse.java index 8bbaff2049ad..3467a5cf6e86 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/confusing_else/ConfusingElse.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/confusing_else/ConfusingElse.java @@ -5,7 +5,7 @@ public class ConfusingElse { public static void main(String[] args) { if (foo()) { return; - } else { + } else { System.out.println("ConfusingElseInspection.main"); } bar(); @@ -55,7 +55,7 @@ public class ConfusingElse { void elseIf(int i) { if (i == 1) { return; - } else if (i == 3) { + } else if (i == 3) { System.out.println("i = " + i); } System.out.println(); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/confusing_else/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/confusing_else/expected.xml deleted file mode 100644 index d94e453d2145..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/confusing_else/expected.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - ConfusingElse.java - 8 - Confusing 'else' branch - <code>else</code> branch may be unwrapped, as the if branch never completes #loc - - - - ConfusingElse.java - 58 - Confusing 'else' branch - <code>else</code> branch may be unwrapped, as the if branch never completes #loc - - - \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/double_negation/DoubleNegation.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/double_negation/DoubleNegation.java index 892d98f4c126..0fc7f88eeb22 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/double_negation/DoubleNegation.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/double_negation/DoubleNegation.java @@ -3,10 +3,14 @@ package com.siyeh.igtest.controlflow.double_negation; public class DoubleNegation { void negative(boolean b1, boolean b2, boolean b3) { - boolean r1 = !(b1 != b2); - boolean r2 = !!b1; - boolean r3 = !b1 != b2; - boolean r4 = (b1 != (b2 != b3)); - boolean r5 = (b1 != b2 != b3); + boolean r1 = !(b1 != b2); + boolean r2 = !!b1; + boolean r3 = !b1 != b2; + boolean r4 = (b1 != (b2 != b3)); + boolean r5 = (b1 != b2 != b3); + } + + void vm(Double a, double b) { + boolean r = !(a != null) || !(b != Double.NaN != false); } } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/double_negation/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/double_negation/expected.xml deleted file mode 100644 index 7bb448512b89..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/double_negation/expected.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - DoubleNegation.java - 6 - Double negation - Double negation in <code>!(b1 != b2)</code> #loc - - - - DoubleNegation.java - 7 - Double negation - Double negation in <code>!!b1</code> #loc - - - - DoubleNegation.java - 8 - Double negation - Double negation in <code>!b1 != b2</code> #loc - - - - DoubleNegation.java - 9 - Double negation - Double negation in <code>b1 != (b2 != b3)</code> #loc - - - - DoubleNegation.java - 10 - Double negation - Double negation in <code>b1 != b2 != b3</code> #loc - - \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/ConfusingElseInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/ConfusingElseInspectionTest.java index 2dd49fa4729e..81a5dbbc3b45 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/ConfusingElseInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/ConfusingElseInspectionTest.java @@ -1,12 +1,36 @@ +/* + * Copyright 2000-2016 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. + */ package com.siyeh.ig.controlflow; -import com.siyeh.ig.IGInspectionTestCase; +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.Nullable; -public class ConfusingElseInspectionTest - extends IGInspectionTestCase { +/** + * @author Bas Leijdekkers + */ +public class ConfusingElseInspectionTest extends LightInspectionTestCase { - public void test() throws Exception { - doTest("com/siyeh/igtest/controlflow/confusing_else", - new ConfusingElseInspection()); + public void testConfusingElse() { + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new ConfusingElseInspection(); } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/DoubleNegationInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/DoubleNegationInspectionTest.java index 18039b1c76c5..537b0eafa5ce 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/DoubleNegationInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/DoubleNegationInspectionTest.java @@ -1,11 +1,36 @@ +/* + * Copyright 2000-2016 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. + */ package com.siyeh.ig.controlflow; -import com.siyeh.ig.IGInspectionTestCase; +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.Nullable; -public class DoubleNegationInspectionTest - extends IGInspectionTestCase { +/** + * @author Bas Leijdekkers + */ +public class DoubleNegationInspectionTest extends LightInspectionTestCase { - public void test() throws Exception { - doTest("com/siyeh/igtest/controlflow/double_negation", new DoubleNegationInspection()); + public void testDoubleNegation() { + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new DoubleNegationInspection(); } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/controlflow/DoubleNegationFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/controlflow/DoubleNegationFixTest.java new file mode 100644 index 000000000000..53f0fdbe7a42 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/controlflow/DoubleNegationFixTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2016 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. + */ +package com.siyeh.ig.fixes.controlflow; + +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.IGQuickFixesTestCase; +import com.siyeh.ig.controlflow.DoubleNegationInspection; + +/** + * @author Bas Leijdekkers + */ +public class DoubleNegationFixTest extends IGQuickFixesTestCase { + + @Override + protected void setUp() throws Exception { + super.setUp(); + myFixture.enableInspections(new DoubleNegationInspection()); + myRelativePath = "controlflow/double_negation"; + myDefaultHint = InspectionGadgetsBundle.message("double.negation.quickfix"); + } + + public void testDoubleDoubleNegation() { doTest(); } +} diff --git a/python/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml b/python/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml index 6f44d77b14f5..56cc6fd48a17 100644 --- a/python/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml +++ b/python/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml @@ -1,5 +1,5 @@ - + diff --git a/python/resources/pycharm_core_about.png b/python/resources/pycharm_core_about.png index 8d3a5fe10cc4..161061ef3b97 100644 Binary files a/python/resources/pycharm_core_about.png and b/python/resources/pycharm_core_about.png differ diff --git a/python/resources/pycharm_core_about@2x.png b/python/resources/pycharm_core_about@2x.png index 21daa2ad13a0..a6c9ea344b74 100644 Binary files a/python/resources/pycharm_core_about@2x.png and b/python/resources/pycharm_core_about@2x.png differ diff --git a/python/resources/pycharm_core_logo.png b/python/resources/pycharm_core_logo.png index edd5c810cc29..03bc5db0452f 100644 Binary files a/python/resources/pycharm_core_logo.png and b/python/resources/pycharm_core_logo.png differ diff --git a/python/resources/pycharm_core_logo@2x.png b/python/resources/pycharm_core_logo@2x.png index 7ab4358b172b..f5a029a47679 100644 Binary files a/python/resources/pycharm_core_logo@2x.png and b/python/resources/pycharm_core_logo@2x.png differ diff --git a/python/src/com/jetbrains/python/console/PydevConsoleExecuteActionHandler.java b/python/src/com/jetbrains/python/console/PydevConsoleExecuteActionHandler.java index eb8182b63c8c..3ec2c23b24bc 100644 --- a/python/src/com/jetbrains/python/console/PydevConsoleExecuteActionHandler.java +++ b/python/src/com/jetbrains/python/console/PydevConsoleExecuteActionHandler.java @@ -57,7 +57,7 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut private final ConsoleCommunication myConsoleCommunication; private boolean myEnabled = false; - private int myIpythonInputPromptCount = 0; + private int myIpythonInputPromptCount = 1; public PydevConsoleExecuteActionHandler(LanguageConsoleView consoleView, ProcessHandler processHandler,