mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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),
|
||||
|
||||
+9
-2
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ class ValueContainerImpl<Value> extends UpdatableValueContainer<Value> 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<Value> extends UpdatableValueContainer<Value> 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));
|
||||
|
||||
+45
-33
@@ -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();
|
||||
}
|
||||
|
||||
+7
@@ -55,6 +55,13 @@ public abstract class ComputableActionGroup extends ActionGroup implements DumbA
|
||||
protected abstract CachedValueProvider<AnAction[]> createChildrenProvider(@NotNull ActionManager actionManager);
|
||||
|
||||
public abstract static class Simple extends ComputableActionGroup {
|
||||
protected Simple() {
|
||||
}
|
||||
|
||||
protected Simple(boolean popup) {
|
||||
super(popup);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected final CachedValueProvider<AnAction[]> createChildrenProvider(@NotNull final ActionManager actionManager) {
|
||||
|
||||
@@ -583,7 +583,6 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
}
|
||||
|
||||
public void updateConfigFilesFromStreamProviders() {
|
||||
|
||||
}
|
||||
|
||||
private static class SharedSchemeData {
|
||||
|
||||
@@ -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 <T> int compareLexicographically(@NotNull List<T> o1, @NotNull List<T> o2, @NotNull Comparator<T> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user