diff --git a/java/java-impl/src/com/intellij/openapi/roots/impl/LanguageLevelUsagesCollector.java b/java/java-impl/src/com/intellij/openapi/roots/impl/LanguageLevelUsagesCollector.java index a022b701ff6c..f44addaddb8b 100644 --- a/java/java-impl/src/com/intellij/openapi/roots/impl/LanguageLevelUsagesCollector.java +++ b/java/java-impl/src/com/intellij/openapi/roots/impl/LanguageLevelUsagesCollector.java @@ -23,12 +23,14 @@ import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.LanguageLevelModuleExtension; import com.intellij.openapi.roots.LanguageLevelProjectExtension; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.pom.java.LanguageLevel; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; import org.jetbrains.annotations.NotNull; +import java.util.Collections; import java.util.Set; public class LanguageLevelUsagesCollector extends AbstractApplicationUsagesCollector { @@ -49,10 +51,10 @@ public class LanguageLevelUsagesCollector extends AbstractApplicationUsagesColle final LanguageLevelModuleExtension instance = LanguageLevelModuleExtension.getInstance(module); final LanguageLevel languageLevel = instance.getLanguageLevel(); if (languageLevel != null) { - languageLevels.add(languageLevel.getPresentableText()); + languageLevels.add(languageLevel.toString()); } } - languageLevels.add(LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().getPresentableText()); + languageLevels.add(LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().toString()); return ContainerUtil.map2Set(languageLevels, new Function() { @Override diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectionQuotingTypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectionQuotingTypedHandler.java index 0273772c329f..308109eb210e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectionQuotingTypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectionQuotingTypedHandler.java @@ -47,7 +47,8 @@ public class SelectionQuotingTypedHandler extends TypedHandlerDelegate { return super.checkAutoPopup(c, project, editor, psiFile); } myCaretPosition = editor.getCaretModel().getOffset(); - if (selectedText.length() > 1 && !Registry.is("editor.smarterSelectionQuoting")) { + boolean replace = false; + if (selectedText.length() > 1) { final char firstChar = selectedText.charAt(0); if (isSimilarDelimiters(firstChar, c) && selectedText.charAt(selectedText.length() - 1) == getMatchingDelimiter(firstChar) && @@ -55,14 +56,16 @@ public class SelectionQuotingTypedHandler extends TypedHandlerDelegate { !shouldSkipReplacementOfQuotesOrBraces(psiFile, editor, selectedText, c) ) { selectedText = selectedText.substring(1, selectedText.length() - 1); + replace = true; } } final int caretOffset = editor.getSelectionModel().getSelectionStart(); final char c2 = getMatchingDelimiter(c); final String newText = String.valueOf(c) + selectedText + c2; EditorModificationUtil.insertStringAtCaret(editor, newText); - if (Registry.is("editor.smarterSelectionQuoting")) { + if (Registry.is("editor.smarterSelectionQuoting") && !replace) { myReplacedTextRange = new TextRange(caretOffset + 1, caretOffset + newText.length() - 1); + myCaretPosition += 1; } else { myReplacedTextRange = new TextRange(caretOffset, caretOffset + newText.length()); } @@ -109,7 +112,7 @@ public class SelectionQuotingTypedHandler extends TypedHandlerDelegate { if (myReplacedTextRange.getEndOffset() <= editor.getDocument().getTextLength()) { editor.getSelectionModel().setSelection(myReplacedTextRange.getStartOffset(), myReplacedTextRange.getEndOffset()); if (Registry.is("editor.smarterSelectionQuoting")) { - editor.getCaretModel().moveToOffset(myCaretPosition + 1); + editor.getCaretModel().moveToOffset(myCaretPosition); } } myReplacedTextRange = null; diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java index da3d82636502..18f0c22cd82c 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java @@ -65,11 +65,15 @@ import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.FocusManager; import javax.swing.*; import java.awt.*; -import java.awt.event.*; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import java.util.Collections; import java.util.concurrent.atomic.AtomicBoolean; @@ -612,10 +616,10 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { }); } - public static void printToConsole(final LanguageConsoleImpl console, - final String string, - final ConsoleViewContentType mainType, - ConsoleViewContentType additionalType) { + public static void printToConsole(@NotNull final LanguageConsoleImpl console, + @NotNull final String string, + @NotNull final ConsoleViewContentType mainType, + @Nullable ConsoleViewContentType additionalType) { final TextAttributes mainAttributes = mainType.getAttributes(); final TextAttributes attributes; if (additionalType == null) { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java b/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java index 59f3f8a6e4f1..5b11661f8c11 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java @@ -70,7 +70,7 @@ public class StatisticsUploadAssistant { return settings != null && settings.isAllowed(); } - public static String getData(@NotNull Set disabledGroups) { + public String getData(@NotNull Set disabledGroups) { return getStringPatch(disabledGroups, ProjectManager.getInstance().getOpenProjects()); } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/beans/ConvertUsagesUtil.java b/platform/platform-impl/src/com/intellij/internal/statistic/beans/ConvertUsagesUtil.java index e8f2c6e8acd8..f3cada41e1c3 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/beans/ConvertUsagesUtil.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/beans/ConvertUsagesUtil.java @@ -21,139 +21,154 @@ import com.intellij.util.containers.hash.HashMap; import java.util.*; public class ConvertUsagesUtil { - private static final Character GROUP_SEPARATOR = ':'; - private static final Character GROUPS_SEPARATOR = ';'; - private static final Character GROUP_VALUE_SEPARATOR = ','; + private static final Character GROUP_SEPARATOR = ':'; + private static final Character GROUPS_SEPARATOR = ';'; + private static final Character GROUP_VALUE_SEPARATOR = ','; - private ConvertUsagesUtil() { + private ConvertUsagesUtil() { + } + + + // @NotNull + public static String convertUsages(Map> map) { + assert map != null; + final Map> sortedMap = sortDescriptorsByPriority(map); + + StringBuffer buffer = new StringBuffer(); + for (Map.Entry> entry : sortedMap.entrySet()) { + buffer.append(entry.getKey().getId()); + buffer.append(GROUP_SEPARATOR); + buffer.append(convertValueMap(entry.getValue())); + buffer.append(GROUPS_SEPARATOR); } + return buffer.toString(); + } - // @NotNull - public static String convertUsages(Map> map) { - assert map != null; - final Map> sortedMap = sortDescriptorsByPriority(map); + //@NotNull + public static String convertValueMap(Set descriptors) { + assert descriptors != null; + final StringBuffer buffer = new StringBuffer(); + for (UsageDescriptor usageDescriptor : descriptors) { + buffer.append(usageDescriptor.getKey()); + buffer.append("="); + buffer.append(usageDescriptor.getValue()); + buffer.append(GROUP_VALUE_SEPARATOR); + } + buffer.deleteCharAt(buffer.length() - 1); - StringBuffer buffer = new StringBuffer(); - for (Map.Entry> entry : sortedMap.entrySet()) { - buffer.append(entry.getKey().getId()); - buffer.append(GROUP_SEPARATOR); - buffer.append(convertValueMap(entry.getValue())); - buffer.append(GROUPS_SEPARATOR); + return buffer.toString(); + } + + //@NotNull + public static String cutPatchString(String patchStr, int maxSize) { + assert patchStr != null; + for (int i = maxSize - 1; i >= 0; i--) { + final char c = patchStr.charAt(i); + if (c == GROUPS_SEPARATOR || c == GROUP_VALUE_SEPARATOR) { + return patchStr.substring(0, i); + } + } + return ""; + } + + //@NotNull + public static Map> convertString(String usages) { + assert usages != null; + Map> descriptors = new HashMap>(); + for (String groupStr : usages.split(GROUPS_SEPARATOR.toString())) { + if (!isEmptyOrSpaces(groupStr)) { + final StringPair group = getPair(groupStr, GROUP_SEPARATOR.toString()); + if (group != null) { + descriptors.putAll(convertValueString(GroupDescriptor.create(group.first), group.second)); } - - return buffer.toString(); + } } + return descriptors; + } - //@NotNull - public static String convertValueMap(Set descriptors) { - assert descriptors != null; - final StringBuffer buffer = new StringBuffer(); - for (UsageDescriptor usageDescriptor : descriptors) { - buffer.append(usageDescriptor.getKey()); - buffer.append("="); - buffer.append(usageDescriptor.getValue()); - buffer.append(GROUP_VALUE_SEPARATOR); - } - buffer.deleteCharAt(buffer.length() - 1); - - return buffer.toString(); - } - - //@NotNull - public static String cutPatchString(String patchStr, int maxSize) { - assert patchStr != null; - for (int i = maxSize - 1; i >= 0; i--) { - final char c = patchStr.charAt(i); - if (c == GROUPS_SEPARATOR || c == GROUP_VALUE_SEPARATOR) { - return patchStr.substring(0, i); + //@NotNull + public static Map> convertValueString(GroupDescriptor groupId, String valueData) { + assert groupId != null; + final Map> descriptors = new HashMap>(); + for (String value : valueData.split(GROUP_VALUE_SEPARATOR.toString())) { + if (!isEmptyOrSpaces(value)) { + final StringPair pair = getPair(value, "="); + if (pair != null) { + final String count = pair.second; + if (!isEmptyOrSpaces(count)) { + try { + final int i = Integer.parseInt(count); + if (!descriptors.containsKey(groupId)) { + descriptors.put(groupId, new LinkedHashSet()); + } + descriptors.get(groupId).add(new UsageDescriptor(pair.first, i)); } - } - return ""; - } - - //@NotNull - public static Map> convertString(String usages) { - assert usages != null; - Map> descriptors = new HashMap>(); - for (String groupStr : usages.split(GROUPS_SEPARATOR.toString())) { - if (!isEmptyOrSpaces(groupStr)) { - final StringPair group = getPair(groupStr, GROUP_SEPARATOR.toString()); - if (group != null) { - descriptors.putAll(convertValueString(GroupDescriptor.create(group.first), group.second)); - } + catch (NumberFormatException ignored) { } + } } - return descriptors; + } } - //@NotNull - public static Map> convertValueString(GroupDescriptor groupId, String valueData) { - assert groupId != null; - final Map> descriptors = new HashMap>(); - for (String value : valueData.split(GROUP_VALUE_SEPARATOR.toString())) { - if (!isEmptyOrSpaces(value)) { - final StringPair pair = getPair(value, "="); - if (pair != null) { - final String count = pair.second; - if (!isEmptyOrSpaces(count)) { - try { - final int i = Integer.parseInt(count); - if (!descriptors.containsKey(groupId)) { - descriptors.put(groupId, new LinkedHashSet()); - } - descriptors.get(groupId).add(new UsageDescriptor(pair.first, i)); - } catch (NumberFormatException ignored) { - } - } - } - } - } + return descriptors; + } - return descriptors; + //@Nullable + public static StringPair getPair(String str, String separator) { + assert str != null; + assert separator != null; + final int i = str.indexOf(separator); + if (i > 0 && i < str.length() - 1) { + String key = str.substring(0, i).trim(); + String value = str.substring(i + 1).trim(); + if (!isEmptyOrSpaces(key) && !isEmptyOrSpaces(value)) { + return new StringPair(key, value); + } } + return null; + } - //@Nullable - public static StringPair getPair(String str, String separator) { - assert str != null; - assert separator != null; - final int i = str.indexOf(separator); - if (i > 0 && i < str.length() - 1) { - String key = str.substring(0, i).trim(); - String value = str.substring(i + 1).trim(); - if (!isEmptyOrSpaces(key) && !isEmptyOrSpaces(value)) { - return new StringPair(key, value); - } - } - return null; + //@NotNull + public static Map> sortDescriptorsByPriority(Map> descriptors) { + assert descriptors != null; + final SortedMap> map = new TreeMap>(new Comparator() { + public int compare(GroupDescriptor g1, GroupDescriptor g2) { + final int priority = (int)(g2.getPriority() - g1.getPriority()); + return priority == 0 ? g1.getId().compareTo(g2.getId()) : priority; + } + }); + + map.putAll(descriptors); + + return map; + } + + private static class StringPair { + public final String first; + public final String second; + + public StringPair(String first, String second) { + this.first = first; + this.second = second; } + } - //@NotNull - public static Map> sortDescriptorsByPriority(Map> descriptors) { - assert descriptors != null; - final SortedMap> map = new TreeMap>(new Comparator() { - public int compare(GroupDescriptor g1, GroupDescriptor g2) { - final int priority = (int) (g2.getPriority() - g1.getPriority()); - return priority == 0 ? g1.getId().compareTo(g2.getId()) : priority; - } - }); + public static boolean isEmptyOrSpaces(final String s) { + return s == null || s.trim().length() == 0; + } - map.putAll(descriptors); + public static void assertDescriptorName(String key) { + assert key != null; + assert containsChar(key, ConvertUsagesUtil.GROUP_SEPARATOR) == false; + assert containsChar(key, ConvertUsagesUtil.GROUPS_SEPARATOR) == false; + assert containsChar(key, ConvertUsagesUtil.GROUP_VALUE_SEPARATOR) == false; + assert key.contains("=") == false; + assert key.contains("'") == false; + assert key.contains("\"") == false; + } - return map; - } - - private static class StringPair { - public final String first; - public final String second; - - public StringPair(String first, String second) { - this.first = first; - this.second = second; - } - } - - public static boolean isEmptyOrSpaces(final String s) { - return s == null || s.trim().length() == 0; - } + public static boolean containsChar(final String value, final char ch) { + return value.indexOf(ch) >= 0; + } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/beans/GroupDescriptor.java b/platform/platform-impl/src/com/intellij/internal/statistic/beans/GroupDescriptor.java index fcbff6c4f6a2..9da21feb3126 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/beans/GroupDescriptor.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/beans/GroupDescriptor.java @@ -24,8 +24,9 @@ public class GroupDescriptor implements Comparable { private double myPriority; public static GroupDescriptor create(String id) { - assert id != null; - return new GroupDescriptor(id); + ConvertUsagesUtil.assertDescriptorName(id); + + return new GroupDescriptor(id); } public static GroupDescriptor create(String id, double priority) { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/beans/UsageDescriptor.java b/platform/platform-impl/src/com/intellij/internal/statistic/beans/UsageDescriptor.java index a8fc36e07216..a806a674e132 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/beans/UsageDescriptor.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/beans/UsageDescriptor.java @@ -20,7 +20,7 @@ public class UsageDescriptor implements Comparable { private int myValue; public UsageDescriptor(String key, int value) { - assert key != null; + ConvertUsagesUtil.assertDescriptorName(key); myKey = key; myValue = value; diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/connect/RemotelyConfigurableStatisticsService.java b/platform/platform-impl/src/com/intellij/internal/statistic/connect/RemotelyConfigurableStatisticsService.java index b3a34c03c11f..ceddf9c2c5cc 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/connect/RemotelyConfigurableStatisticsService.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/connect/RemotelyConfigurableStatisticsService.java @@ -29,7 +29,7 @@ public class RemotelyConfigurableStatisticsService implements StatisticsService return new StatisticsResult(StatisticsResult.ResultCode.NOT_PERMITTED_SERVER, "NOT_PERMITTED"); } - String content = myAssistant.getData(); + String content = myAssistant.getData(myConnectionService.getDisabledGroups()); if (StringUtil.isEmptyOrSpaces(content)) { return new StatisticsResult(StatisticsResult.ResultCode.NOTHING_TO_SEND, "NOTHING_TO_SEND"); diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsHttpClientSender.java b/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsHttpClientSender.java index c7e97df3dc7a..535b8ad9b53c 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsHttpClientSender.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsHttpClientSender.java @@ -56,6 +56,9 @@ public class StatisticsHttpClientSender implements StatisticsDataSender { throw new StatServiceException("Error during updating statistics " + (!StringUtil.isEmptyOrSpaces(value) ? " : " + value : "")); } } + catch (StatServiceException e) { + throw e; + } catch (Exception e) { throw new StatServiceException("Error during data sending...", e); } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistenceComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistenceComponent.java index e241f2139cc9..63a6a2c1252c 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistenceComponent.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistenceComponent.java @@ -19,6 +19,7 @@ package com.intellij.internal.statistic.persistence; import com.intellij.ide.AppLifecycleListener; import com.intellij.internal.statistic.AbstractApplicationUsagesCollector; import com.intellij.internal.statistic.UsagesCollector; +import com.intellij.internal.statistic.beans.ConvertUsagesUtil; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; import com.intellij.openapi.application.ApplicationManager; @@ -94,7 +95,7 @@ public class ApplicationStatisticsPersistenceComponent extends ApplicationStatis if (!StringUtil.isEmptyOrSpaces(projectId) && !StringUtil.isEmptyOrSpaces(frameworks)) { Set frameworkDescriptors = new HashSet(); for (String key : StringUtil.split(frameworks, TOKENIZER)) { - frameworkDescriptors.add(new UsageDescriptor(key, 1)); + frameworkDescriptors.add(getUsageDescriptor(key)); } getApplicationData(groupDescriptor).put(projectId, frameworkDescriptors); } @@ -129,13 +130,37 @@ public class ApplicationStatisticsPersistenceComponent extends ApplicationStatis return element; } - private static String joinUsages(@NotNull Set usages) { - return StringUtil.join(usages, new Function() { - @Override - public String fun(UsageDescriptor usageDescriptor) { - return usageDescriptor.getKey(); + private UsageDescriptor getUsageDescriptor(String usage) { + // for instance, usage can be: "_foo"(equals "_foo=1") or "_foo=2" + final int i = usage.indexOf("="); + if (i > 0 && i < usage.length() - 1) { + String key = usage.substring(0, i).trim(); + String value = usage.substring(i + 1).trim(); + if (!StringUtil.isEmptyOrSpaces(key) && !StringUtil.isEmptyOrSpaces(value)) { + try { + final int count = Integer.parseInt(value); + if (count > 0) { + return new UsageDescriptor(key, count); + } } - }, TOKENIZER); + catch (NumberFormatException e) { + } + } + } + return new UsageDescriptor(usage, 1); + } + + private static String joinUsages(@NotNull Set usages) { + // for instance, usage can be: "_foo"(equals "_foo=1") or "_foo=2" + return StringUtil.join(usages, new Function() { + @Override + public String fun(UsageDescriptor usageDescriptor) { + final String key = usageDescriptor.getKey(); + final int value = usageDescriptor.getValue(); + + return value > 1 ? key + "=" + value : key; + } + }, TOKENIZER); } @NotNull diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index f3120595d01d..051aca1afc25 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -236,8 +236,8 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat } frame.setBounds(myFrameBounds); - frame.setExtendedState(myFrameExtendedState); frame.setVisible(true); + frame.setExtendedState(myFrameExtendedState); } public IdeFrameImpl[] getAllFrames() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java index 81ddc58e5cf2..261041040983 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java @@ -39,10 +39,10 @@ import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.*; import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.changes.actions.IgnoredSettingsAction; -import com.intellij.openapi.vcs.changes.ui.ChangesBrowserNode; import com.intellij.openapi.vcs.changes.ui.ChangesListView; import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.impl.DebugUtil; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentFactory; @@ -102,7 +102,7 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro private final TreeSelectionListener myTsl; private final FileAndDocumentListenersForShortDiff myListenersForShortDiff; private Content myContent; - private Change[] mySelectedPaths; + private Change[] mySelectedChanges; public static ChangesViewI getInstance(Project project) { return PeriodicalTasksCloser.getInstance().safeGetComponent(project, ChangesViewI.class); @@ -161,27 +161,10 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro @Override public void valueChanged(TreeSelectionEvent e) { Change[] selectedChanges = myView.getSelectedChanges(); - if (mySelectedPaths == null && selectedChanges == null) { - return; - } - if (mySelectedPaths != null && selectedChanges != null) { - if (mySelectedPaths.length == selectedChanges.length) { - boolean changed = false; - int idx = 0; - for (; idx < selectedChanges.length; idx++) { - Change change = selectedChanges[idx]; - if (! change.equals(mySelectedPaths[idx])) { - changed = true; - break; - } - } - if (! changed) return; - } - } + if (Comparing.equal(mySelectedChanges, selectedChanges)) return; + mySelectedChanges = selectedChanges; if (LOG.isDebugEnabled()) { - StringWriter sw = new StringWriter(); - new Throwable().printStackTrace(new PrintWriter(sw)); - LOG.debug("selection changed. selected: " + toStringPaths(myView.getSelectionPaths()) + " from: " + sw.toString()); + LOG.debug("selection changed. selected: " + toStringPaths(myView.getSelectionPaths()) + " from: " + DebugUtil.currentStackTrace()); } SwingUtilities.invokeLater(new Runnable() { @Override diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java index 232bb48aca7b..16d141524036 100644 --- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java +++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java @@ -166,19 +166,19 @@ public class XDebuggerTestUtil { assertVariableValue(findVar(vars, name), name, value); } - public static void assertVariableValueMatches(Collection vars, + public static void assertVariableValueMatches(@NotNull Collection vars, @Nullable String name, @Nullable String valuePattern) throws InterruptedException { assertVariableValueMatches(findVar(vars, name), name, valuePattern); } - public static void assertVariableValueMatches(XValue var, + public static void assertVariableValueMatches(@NotNull XValue var, @Nullable String name, @Nullable String valuePattern) throws InterruptedException { assertVariableValueMatches(var, name, null, valuePattern); } - public static void assertVariableValueMatches(XValue var, + public static void assertVariableValueMatches(@NotNull XValue var, @Nullable String name, @Nullable String type, @Nullable String valuePattern) throws InterruptedException { @@ -190,7 +190,9 @@ public class XDebuggerTestUtil { } } - public static void assertVariableTypeMatches(XValue var, String name, @Language("RegExp") String typePattern) throws InterruptedException { + public static void assertVariableTypeMatches(@NotNull XValue var, + @Nullable String name, + @Nullable @Language("RegExp") String typePattern) throws InterruptedException { XTestValueNode node = computePresentation(var); if (name != null) { Assert.assertEquals(name, node.myName); @@ -200,7 +202,8 @@ public class XDebuggerTestUtil { } } - public static void assertVariableFullValue(XValue var, @Nullable String value) throws InterruptedException { + public static void assertVariableFullValue(@NotNull XValue var, + @Nullable String value) throws InterruptedException { XTestValueNode node = computePresentation(var); final String[] result = new String[1]; diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/performance/ManualArrayCopyInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/performance/ManualArrayCopyInspection.java index f76b1a46ad4a..80953c044bc1 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/performance/ManualArrayCopyInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/performance/ManualArrayCopyInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2011 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. @@ -333,7 +333,7 @@ public class ManualArrayCopyInspection extends BaseInspection { } final int precedence = ParenthesesUtils.getPrecedence(min); final String minText; - if (precedence > ParenthesesUtils.ADDITIVE_PRECEDENCE) { + if (precedence >= ParenthesesUtils.ADDITIVE_PRECEDENCE) { minText = '(' + min.getText() + ')'; } else { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java index 59a48f74f8ac..99c2137acf56 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableAssignedVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2011 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. @@ -73,10 +73,10 @@ class VariableAssignedVisitor extends JavaRecursiveElementVisitor { if (assigned) { return; } + super.visitPrefixExpression(prefixExpression); if (!checkUnaryExpressions) { return; } - super.visitPrefixExpression(prefixExpression); final IElementType tokenType = prefixExpression.getOperationTokenType(); if (!tokenType.equals(JavaTokenType.PLUSPLUS) && !tokenType.equals(JavaTokenType.MINUSMINUS)) { @@ -94,10 +94,10 @@ class VariableAssignedVisitor extends JavaRecursiveElementVisitor { if (assigned) { return; } + super.visitPostfixExpression(postfixExpression); if (!checkUnaryExpressions) { return; } - super.visitPostfixExpression(postfixExpression); final IElementType tokenType = postfixExpression.getOperationTokenType(); if (!tokenType.equals(JavaTokenType.PLUSPLUS) && !tokenType.equals(JavaTokenType.MINUSMINUS)) { diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java index 369146295d13..c595e4e93337 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java @@ -166,4 +166,15 @@ public class MismatchedCollectionQueryUpdate { for (final String value : ourValues) {} } } + + private void updateAttachmentWarning(final String message) { + final List includedAttachments; + if (message instanceof Object && + !(includedAttachments = boo()).isEmpty()) { + if (includedAttachments.size() == 1) { + } + } + } + + List boo() {return null;} } diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidPrecompileTask.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidPrecompileTask.java index f66ac9e057aa..6f784713b4d5 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidPrecompileTask.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidPrecompileTask.java @@ -42,6 +42,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; +import java.util.Arrays; import java.util.Collection; import java.util.Set; @@ -92,11 +93,14 @@ public class AndroidPrecompileTask implements CompileTask { LOG.debug("Platform-tools revision for module " + module.getName() + " is " + platformToolsRevision); - if (platformToolsRevision >= 0 && platformToolsRevision <= 7) { - if (facet.getConfiguration().LIBRARY_PROJECT) { + if (facet.getConfiguration().LIBRARY_PROJECT) { + if (platformToolsRevision >= 0 && platformToolsRevision <= 7) { LOG.debug("Excluded sources of module " + module.getName()); excludeAllSourceRoots(module, configuration, addedEntries); } + else { + unexcludeAllSourceRoots(module, configuration); + } } } @@ -160,6 +164,24 @@ public class AndroidPrecompileTask implements CompileTask { vFile.refresh(false, true); } } + + private static void unexcludeAllSourceRoots(Module module, + ExcludedEntriesConfiguration configuration) { + final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots(); + final Set sourceRootSet = new HashSet(); + sourceRootSet.addAll(Arrays.asList(sourceRoots)); + + final ExcludeEntryDescription[] descriptions = configuration.getExcludeEntryDescriptions(); + configuration.removeAllExcludeEntryDescriptions(); + + for (ExcludeEntryDescription description : descriptions) { + final VirtualFile file = description.getVirtualFile(); + + if (file == null || !sourceRootSet.contains(file)) { + configuration.addExcludeEntryDescription(description); + } + } + } private static void excludeAllSourceRoots(Module module, ExcludedEntriesConfiguration configuration, diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/XsltSupport.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/XsltSupport.java index 0b16c272cc4b..76887f89f3eb 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/XsltSupport.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/XsltSupport.java @@ -231,7 +231,7 @@ public class XsltSupport { return level != XsltChecker.LanguageLevel.NONE; } - public static XsltChecker.LanguageLevel getXsltLanguageLevel(PsiFile psiFile) { + public static XsltChecker.LanguageLevel getXsltLanguageLevel(@NotNull PsiFile psiFile) { final CachedValuesManager mgr = CachedValuesManager.getManager(psiFile.getProject()); return mgr.getParameterizedCachedValue(psiFile, FORCE_XSLT_KEY, XsltSupportProvider.INSTANCE, false, psiFile); } diff --git a/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java b/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java index ef5cfaa4f279..c1a96c3c7478 100644 --- a/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java +++ b/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java @@ -22,9 +22,15 @@ import net.sf.saxon.expr.instruct.GlobalVariable; import net.sf.saxon.expr.instruct.LocalVariable; import net.sf.saxon.expr.instruct.SlotManager; import net.sf.saxon.functions.FunctionLibrary; -import net.sf.saxon.om.*; +import net.sf.saxon.om.Item; +import net.sf.saxon.om.SequenceIterator; +import net.sf.saxon.om.StructuredQName; +import net.sf.saxon.om.ValueRepresentation; import net.sf.saxon.style.*; import net.sf.saxon.trans.XPathException; +import net.sf.saxon.tree.iter.EmptyIterator; +import net.sf.saxon.tree.iter.SingletonIterator; +import net.sf.saxon.type.AnyItemType; import net.sf.saxon.type.ItemType; import net.sf.saxon.type.Type; import net.sf.saxon.type.TypeHierarchy; @@ -74,18 +80,7 @@ class Saxon9StyleFrame extends AbstractSaxon9Frame extends AbstractSaxon9Frame getVariables() { assert isValid(); + Saxon9TraceListener.MUTED = true; + final ArrayList variables; + try { + variables = collectVariables(); + } finally { + Saxon9TraceListener.MUTED = false; + } + + Collections.sort(variables, VariableComparator.INSTANCE); + + return variables; + } + + private ArrayList collectVariables() { final ArrayList variables = new ArrayList(); final HashMap globalVariables = @@ -107,20 +131,11 @@ class Saxon9StyleFrame extends AbstractSaxon9Frame extends AbstractSaxon9Frame implements Debu final String name = variable.getName().getLocalName(); try { final Value value = kind == Debugger.Variable.Kind.PARAMETER ? - eval("$" + variable.getName().toNamespacedString()) : // http://youtrack.jetbrains.net/issue/IDEA-78638 + eval("$" + variable.getName().toString()) : // http://youtrack.jetbrains.net/issue/IDEA-78638 new XObjectValue(variable.getValue(myTransformer, myCurrentNode)); variables.add(new VariableImpl(name, value, global, kind, variable.getSystemId(), variable.getLineNumber())); diff --git a/plugins/xslt-debugger/src/META-INF/plugin.xml b/plugins/xslt-debugger/src/META-INF/plugin.xml index c02c972de3da..2670f2b5e4bf 100644 --- a/plugins/xslt-debugger/src/META-INF/plugin.xml +++ b/plugins/xslt-debugger/src/META-INF/plugin.xml @@ -20,8 +20,7 @@ - - + diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java index 65fa36c0ee2b..6b3205e94a1f 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java @@ -8,7 +8,10 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiManager; +import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.breakpoints.XBreakpointProperties; +import com.intellij.xdebugger.breakpoints.XLineBreakpoint; import com.intellij.xdebugger.breakpoints.XLineBreakpointType; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import com.intellij.xdebugger.ui.DebuggerIcons; @@ -24,12 +27,13 @@ import javax.swing.*; * User: sweinreuter * Date: 03.03.11 */ -public abstract class XsltBreakpointType extends XLineBreakpointType { +public class XsltBreakpointType extends XLineBreakpointType { - private final XsltDebuggerEditorsProvider myMyEditorsProvider = new XsltDebuggerEditorsProvider(getLanguageLevel()); + private final XsltDebuggerEditorsProvider myMyEditorsProvider1 = new XsltDebuggerEditorsProvider(XsltChecker.LanguageLevel.V1); + private final XsltDebuggerEditorsProvider myMyEditorsProvider2 = new XsltDebuggerEditorsProvider(XsltChecker.LanguageLevel.V2); - protected XsltBreakpointType(final String id) { - super(id, "XSLT Breakpoints"); + public XsltBreakpointType() { + super("xslt", "XSLT Breakpoints"); } @Override @@ -45,14 +49,29 @@ public abstract class XsltBreakpointType extends XLineBreakpointType breakpoint, @NotNull Project project) { + final XSourcePosition position = breakpoint.getSourcePosition(); + if (position == null) { + return null; + } + + final PsiFile file = PsiManager.getInstance(project).findFile(position.getFile()); + if (file == null) { + return null; + } + + final XsltChecker.LanguageLevel level = XsltSupport.getXsltLanguageLevel(file); + if (level == XsltChecker.LanguageLevel.V1) { + return myMyEditorsProvider1; + } else if (level == XsltChecker.LanguageLevel.V2) { + return myMyEditorsProvider2; + } + + return null; } @NotNull @@ -71,26 +90,4 @@ public abstract class XsltBreakpointType extends XLineBreakpointType[] myXBreakpointHandlers = new XBreakpointHandler[]{ - new XsltBreakpointHandler(this, XsltBreakpointType.V1.class), - new XsltBreakpointHandler(this, XsltBreakpointType.V2.class) + new XsltBreakpointHandler(this, XsltBreakpointType.class), }; private XsltDebuggerSession myDebuggerSession;