From d0ba1a736f60dab46e805748fcccecb5fe4c2c92 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 8 Sep 2014 20:24:44 +0200 Subject: [PATCH 1/5] repository should be created only when upstream set VCS -> Sync Settings splitted to separated ActionSyncType (now VCS -> Sync Settings -> Merge | Reset To Theirs | Reset To Yours) --- .../openapi/actionSystem/ComputableActionGroup.java | 7 +++++++ .../com/intellij/openapi/options/SchemesManagerImpl.java | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ComputableActionGroup.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ComputableActionGroup.java index b5027fd9df81..3b0e247180b2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ComputableActionGroup.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ComputableActionGroup.java @@ -55,6 +55,13 @@ public abstract class ComputableActionGroup extends ActionGroup implements DumbA protected abstract CachedValueProvider createChildrenProvider(@NotNull ActionManager actionManager); public abstract static class Simple extends ComputableActionGroup { + protected Simple() { + } + + protected Simple(boolean popup) { + super(popup); + } + @NotNull @Override protected final CachedValueProvider createChildrenProvider(@NotNull final ActionManager actionManager) { diff --git a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java index 16494bc4788a..6142b696ff24 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java @@ -583,7 +583,6 @@ public class SchemesManagerImpl Date: Tue, 9 Sep 2014 09:43:20 +0400 Subject: [PATCH 2/5] GWT: allow selecting several GWT modules in run configuration (IDEA-24138) --- .../com/intellij/util/containers/ContainerUtil.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/platform/util/src/com/intellij/util/containers/ContainerUtil.java b/platform/util/src/com/intellij/util/containers/ContainerUtil.java index ab8ab2a33aa4..821cf5122903 100644 --- a/platform/util/src/com/intellij/util/containers/ContainerUtil.java +++ b/platform/util/src/com/intellij/util/containers/ContainerUtil.java @@ -2382,5 +2382,16 @@ public class ContainerUtil extends ContainerUtilRt { } return o1.size() < o2.size() ? -1 : o1.size() == o2.size() ? 0 : 1; } + + @Contract(pure=true) + public static int compareLexicographically(@NotNull List o1, @NotNull List o2, @NotNull Comparator comparator) { + for (int i = 0; i < Math.min(o1.size(), o2.size()); i++) { + int result = comparator.compare(o1.get(i), o2.get(i)); + if (result != 0) { + return result; + } + } + return o1.size() < o2.size() ? -1 : o1.size() == o2.size() ? 0 : 1; + } } From 5ab38b6027a082b1b9640c23eb1e16ca975cc38c Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 9 Sep 2014 12:23:18 +0400 Subject: [PATCH 3/5] extract light method object: provide anchor where generated call was generated --- .../ExtractLightMethodObjectHandler.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java index cecc7ef123ea..a93a4574d854 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java @@ -45,10 +45,16 @@ public class ExtractLightMethodObjectHandler { public static class ExtractedData { private String myGeneratedCallText; private PsiClass myGeneratedInnerClass; + private final PsiElement myAnchor; - public ExtractedData(String generatedCallText, PsiClass generatedInnerClass) { + public ExtractedData(String generatedCallText, PsiClass generatedInnerClass, PsiElement anchor) { myGeneratedCallText = generatedCallText; myGeneratedInnerClass = generatedInnerClass; + myAnchor = anchor; + } + + public PsiElement getAnchor() { + return myAnchor; } public String getGeneratedCallText() { @@ -126,7 +132,8 @@ public class ExtractLightMethodObjectHandler { final String generatedCall = copy.getText().substring(start, outStatement.getTextOffset()); return new ExtractedData(generatedCall, - (PsiClass)CodeStyleManager.getInstance(project).reformat(extractMethodObjectProcessor.getInnerClass())); + (PsiClass)CodeStyleManager.getInstance(project).reformat(extractMethodObjectProcessor.getInnerClass()), + anchor); } From c0ef69ccf1ee063adefd334fe1609cf448bfbbd1 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Tue, 9 Sep 2014 10:27:45 +0200 Subject: [PATCH 4/5] cope with duplicated changed file ids --- .../util/indexing/ValueContainerImpl.java | 4 +- .../containers/ChangeBufferingList.java | 78 +++++++++++-------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/ValueContainerImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/ValueContainerImpl.java index 3e7f3bd03739..90f29dccb4d1 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/ValueContainerImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/ValueContainerImpl.java @@ -458,7 +458,7 @@ class ValueContainerImpl extends UpdatableValueContainer implement } else { // serialize positive file ids with delta encoding ChangeBufferingList originalInput = (ChangeBufferingList)fileSetObject; - IntIterator intIterator = originalInput.intIterator(); + IntIterator intIterator = originalInput.rawIntIterator(); DataInputOutputUtil.writeINT(out, -intIterator.size()); if (intIterator.hasAscendingOrder()) { @@ -493,7 +493,7 @@ class ValueContainerImpl extends UpdatableValueContainer implement final int[] bits = ourSpareBuffer.getBuffer(bitsLength); for(int i = 0; i < bitsLength; ++i) bits[i] = 0; - intIterator = originalInput.intIterator(); + intIterator = originalInput.rawIntIterator(); while(intIterator.hasNext()) { final int id = intIterator.next() - offset; bits[id >> INT_BITS_SHIFT] |= (1 << (id)); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/containers/ChangeBufferingList.java b/platform/lang-impl/src/com/intellij/util/indexing/containers/ChangeBufferingList.java index 103f7d5fb587..a1373c06a23f 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/containers/ChangeBufferingList.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/containers/ChangeBufferingList.java @@ -19,8 +19,6 @@ import com.intellij.util.indexing.DebugAssertions; import com.intellij.util.indexing.ValueContainer; import gnu.trove.TIntProcedure; -import java.util.Arrays; - import static com.intellij.util.indexing.DebugAssertions.DEBUG; /** @@ -37,7 +35,8 @@ public class ChangeBufferingList implements Cloneable { //static final int MAX_FILES = 100; private volatile int[] changes; private short length; - private short removals; + private boolean hasRemovals; + private volatile boolean mayHaveDupes; private volatile RandomAccessIntContainer randomAccessContainer; private IdSet checkSet; @@ -75,7 +74,8 @@ public class ChangeBufferingList implements Cloneable { private void addChange(int value) { changes[length++] = value; - if (value < 0) ++removals; + if (value < 0 && !hasRemovals) hasRemovals = true; + if(!mayHaveDupes) mayHaveDupes = true; } public void remove(int value) { @@ -118,37 +118,26 @@ public class ChangeBufferingList implements Cloneable { RandomAccessIntContainer idSet; if (randomAccessContainer == null) { - int someElementsNumberEstimation = length - removals; + int someElementsNumberEstimation = length; int[] minMax = calcMinMax(changes, length); // todo we can check these lengths instead of only relying upon reaching MAX_FILES - int lengthOfBitSet = IdBitSet.sizeInBytes(minMax[1], minMax[0]); - int lengthOfIntSet = 4 * length; + //int lengthOfBitSet = IdBitSet.sizeInBytes(minMax[1], minMax[0]); + //int lengthOfIntSet = 4 * length; if (someElementsNumberEstimation < MAX_FILES) { - if (removals == 0) { - if (DEBUG) { - ValueContainer.IntIterator sorted = SortedFileIdSetIterator.getTransientIterator(new ChangesIterator(changes, length)); - int lastIndex = 0; - while(sorted.hasNext()) { - currentChanges[lastIndex++] = sorted.next(); - } - - DebugAssertions.assertTrue(lastIndex == length); - idSet = new SortedIdSet(currentChanges, lastIndex); - } else { - Arrays.sort(currentChanges, 0, length); - idSet = new SortedIdSet(currentChanges, length); + if (!hasRemovals) { + if (mayHaveDupes) { + mergeChangesRemovingDupes(); } + idSet = new SortedIdSet(currentChanges, length); + copyChanges = false; } else { idSet = new SortedIdSet(Math.max(someElementsNumberEstimation, 3)); } } - else if (removals == 0) { - if (lengthOfBitSet > lengthOfIntSet) { - int a = 1; - } + else if (!hasRemovals) { idSet = new IdBitSet(changes, length, 0); copyChanges = false; } else { @@ -186,13 +175,26 @@ public class ChangeBufferingList implements Cloneable { } length = 0; - removals = 0; + hasRemovals = false; + mayHaveDupes = false; randomAccessContainer = idSet; changes = null; return randomAccessContainer; } } + private void mergeChangesRemovingDupes() { // duplicated ids can be present for some index due to cancellation of indexing for next index + int[] currentChanges = changes; + ValueContainer.IntIterator sorted = SortedFileIdSetIterator.getTransientIterator(new ChangesIterator(currentChanges, length)); + int lastIndex = 0; + while(sorted.hasNext()) { + currentChanges[lastIndex++] = sorted.next(); + } + + length = (short)lastIndex; + mayHaveDupes = false; + } + public void ensureCapacity(int diff) { RandomAccessIntContainer intContainer = randomAccessContainer; if (length == MAX_FILES) { @@ -224,7 +226,7 @@ public class ChangeBufferingList implements Cloneable { if (DEBUG) DebugAssertions.assertTrue(checkSet.isEmpty()); return true; } - if (removals == 0) { + if (!hasRemovals) { boolean b = length == 0; if (DEBUG) DebugAssertions.assertTrue(b == checkSet.isEmpty()); return b; @@ -252,14 +254,24 @@ public class ChangeBufferingList implements Cloneable { public ValueContainer.IntIterator intIterator() { RandomAccessIntContainer intContainer = randomAccessContainer; - if (intContainer == null && removals == 0) { - ValueContainer.IntIterator iterator = new ChangesIterator(changes, length); - if (DEBUG) { - ValueContainer.IntIterator iteratorSurelyWithoutDupes = SortedFileIdSetIterator.getTransientIterator(iterator); - DebugAssertions.assertTrue(iteratorSurelyWithoutDupes.size() == length); - iterator = iterator.createCopyInInitialState(); + if (intContainer == null && !hasRemovals) { + int[] currentChanges = changes; + if (currentChanges != null) { + if (mayHaveDupes) { + synchronized (currentChanges) { + if (mayHaveDupes) mergeChangesRemovingDupes(); + } + } + return new ChangesIterator(currentChanges, length); } - return iterator; + } + return getRandomAccessContainer().intIterator(); + } + + public ValueContainer.IntIterator rawIntIterator() { + RandomAccessIntContainer intContainer = randomAccessContainer; + if (intContainer == null && !hasRemovals) { + return new ChangesIterator(changes, length); // dupes are possible } return getRandomAccessContainer().intIterator(); } From 6f9062608e092f96c737ac528f6e2fb616ced2e4 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 9 Sep 2014 12:31:57 +0400 Subject: [PATCH 5/5] compiling evaluator - use correct context --- .../debugger/ui/impl/watch/CompilingEvaluator.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java index 698412203319..51a57c3cca8a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java @@ -15,7 +15,6 @@ */ package com.intellij.debugger.ui.impl.watch; -import com.intellij.codeInsight.CodeInsightUtil; import com.intellij.debugger.DebuggerInvocationUtil; import com.intellij.debugger.EvaluatingComputable; import com.intellij.debugger.engine.ContextUtil; @@ -29,8 +28,10 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.*; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiCodeFragment; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiJavaFile; import com.intellij.refactoring.extractMethodObject.ExtractLightMethodObjectHandler; import com.sun.jdi.*; @@ -102,10 +103,7 @@ public class CompilingEvaluator implements ExpressionEvaluator { @Override public ExpressionEvaluator compute() throws EvaluateException { final TextWithImports callCode = getCallCode(); - PsiFile file = myData.getGeneratedInnerClass().getContainingFile(); - final TextRange range = myPsiContext.getTextRange(); - final PsiElement copyContext = - CodeInsightUtil.findElementInRange(file, range.getStartOffset(), range.getEndOffset(), myPsiContext.getClass()); + PsiElement copyContext = myData.getAnchor(); final CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(callCode, copyContext); return factory.getEvaluatorBuilder(). build(factory.createCodeFragment(callCode, copyContext, project),