use type-specific map to consume less memory

GitOrigin-RevId: 1a592c99f697dc0910f58d0276a525e14d6cbcda
This commit is contained in:
Vladimir Krivosheev
2020-05-09 07:38:19 +00:00
committed by intellij-monorepo-bot
parent cf9a68d7e0
commit e855f5a4f0
74 changed files with 511 additions and 669 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
<component name="libraryTable">
<library name="fastutil-min" type="repository">
<properties maven-id="com.github.develar:fastutil-min-builder:8.3.1-5" />
<properties maven-id="com.github.develar:fastutil-min-builder:8.3.1-10" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/github/develar/fastutil-min-builder/8.3.1-5/fastutil-min-builder-8.3.1-5.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/github/develar/fastutil-min-builder/8.3.1-10/fastutil-min-builder-8.3.1-10.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
@@ -30,6 +30,7 @@
<orderEntry type="library" name="NanoXML" level="project" />
<orderEntry type="library" name="jackson-databind" level="project" />
<orderEntry type="module" module-name="intellij.platform.debugger.impl" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
<component name="copyright">
<Base>
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testDiscovery.indices;
import com.intellij.openapi.Disposable;
@@ -9,7 +9,8 @@ import com.intellij.openapi.util.LowMemoryWatcher;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.indexing.StorageException;
import com.intellij.util.io.*;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -182,11 +183,10 @@ public final class DiscoveredTestDataHolder {
@NotNull List<String> usedFiles,
@Nullable String moduleName,
byte frameworkId) throws IOException {
final int testNameId = myTestEnumerator.enumerate(createTestId(testClassName, testMethodName, frameworkId));
Map<Integer, TIntArrayList> result = new HashMap<>();
Int2ObjectOpenHashMap<IntArrayList> result = new Int2ObjectOpenHashMap<>();
for (Map.Entry<String, Collection<String>> e : usedMethods.entrySet()) {
TIntArrayList methodIds = new TIntArrayList(e.getValue().size());
IntArrayList methodIds = new IntArrayList(e.getValue().size());
result.put(myClassEnumerator.enumerate(e.getKey()), methodIds);
for (String methodName : e.getValue()) {
methodIds.add(myMethodEnumerator.enumerate(methodName));
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testDiscovery.indices;
import com.intellij.openapi.progress.ProgressManager;
@@ -9,16 +9,18 @@ import com.intellij.util.indexing.impl.MapIndexStorage;
import com.intellij.util.indexing.impl.MapReduceIndex;
import com.intellij.util.indexing.impl.forward.KeyCollectionForwardIndexAccessor;
import com.intellij.util.indexing.impl.forward.PersistentMapBasedForwardIndex;
import com.intellij.util.io.*;
import gnu.trove.TIntArrayList;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorIntegerDescriptor;
import com.intellij.util.io.IntCollectionDataExternalizer;
import com.intellij.util.io.KeyDescriptor;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
public class DiscoveredTestsIndex extends MapReduceIndex<Integer, TIntArrayList, UsedSources> {
protected DiscoveredTestsIndex(@NotNull Path file) throws IOException {
public final class DiscoveredTestsIndex extends MapReduceIndex<Integer, IntArrayList, UsedSources> {
DiscoveredTestsIndex(@NotNull Path file) throws IOException {
super(INDEX_EXTENSION,
new MyIndexStorage(file),
new PersistentMapBasedForwardIndex(file.resolve("forward.idx"), false),
@@ -39,7 +41,7 @@ public class DiscoveredTestsIndex extends MapReduceIndex<Integer, TIntArrayList,
return getForwardIndex().get(testId) != null;
}
private static class MyIndexStorage extends MapIndexStorage<Integer, TIntArrayList> {
private static class MyIndexStorage extends MapIndexStorage<Integer, IntArrayList> {
protected MyIndexStorage(@NotNull Path storageFile) throws IOException {
super(storageFile, EnumeratorIntegerDescriptor.INSTANCE, IntArrayExternalizer.INSTANCE, 4 * 1024, false);
}
@@ -50,16 +52,18 @@ public class DiscoveredTestsIndex extends MapReduceIndex<Integer, TIntArrayList,
}
}
private static final IndexExtension<Integer, TIntArrayList, UsedSources> INDEX_EXTENSION = new IndexExtension<Integer, TIntArrayList, UsedSources>() {
private static final IndexExtension<Integer, IntArrayList, UsedSources> INDEX_EXTENSION = new IndexExtension<Integer, IntArrayList, UsedSources>() {
@NotNull
@Override
public IndexId<Integer, TIntArrayList> getName() {
public IndexId<Integer, IntArrayList> getName() {
return IndexId.create("jvm.discovered.tests");
}
@NotNull
@Override
public DataIndexer<Integer, TIntArrayList, UsedSources> getIndexer() {return inputData -> inputData.myUsedMethods;}
public DataIndexer<Integer, IntArrayList, UsedSources> getIndexer() {
return inputData -> inputData.myUsedMethods;
}
@NotNull
@Override
@@ -69,7 +73,7 @@ public class DiscoveredTestsIndex extends MapReduceIndex<Integer, TIntArrayList,
@NotNull
@Override
public DataExternalizer<TIntArrayList> getValueExternalizer() {
public DataExternalizer<IntArrayList> getValueExternalizer() {
return IntArrayExternalizer.INSTANCE;
}
@@ -1,20 +1,20 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testDiscovery.indices;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.DataInputOutputUtil;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
class IntArrayExternalizer implements DataExternalizer<TIntArrayList> {
final class IntArrayExternalizer implements DataExternalizer<IntArrayList> {
static final IntArrayExternalizer INSTANCE = new IntArrayExternalizer();
@Override
public void save(@NotNull DataOutput out, TIntArrayList value) throws IOException {
public void save(@NotNull DataOutput out, IntArrayList value) throws IOException {
DataInputOutputUtil.writeINT(out, value.size());
for (int i = 0; i < value.size(); i++) {
DataInputOutputUtil.writeINT(out, value.get(i));
@@ -22,9 +22,9 @@ class IntArrayExternalizer implements DataExternalizer<TIntArrayList> {
}
@Override
public TIntArrayList read(@NotNull DataInput in) throws IOException {
public IntArrayList read(@NotNull DataInput in) throws IOException {
int size = DataInputOutputUtil.readINT(in);
TIntArrayList array = new TIntArrayList(size);
IntArrayList array = new IntArrayList(size);
for (int i = 0; i < size; i++) {
array.add(DataInputOutputUtil.readINT(in));
}
@@ -1,17 +1,19 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testDiscovery.indices;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
class UsedSources {
final class UsedSources {
@NotNull
final Map<Integer, TIntArrayList> myUsedMethods;
final Int2ObjectOpenHashMap<IntArrayList> myUsedMethods;
@NotNull
final Map<Integer, Void> myUsedFiles;
UsedSources(@NotNull Map<Integer, TIntArrayList> methods, @NotNull Map<Integer, Void> files) {
UsedSources(@NotNull Int2ObjectOpenHashMap<IntArrayList> methods, @NotNull Map<Integer, Void> files) {
myUsedMethods = methods;
myUsedFiles = files;
}
+1
View File
@@ -26,5 +26,6 @@
<orderEntry type="library" name="StreamEx" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-jdk8" level="project" />
<orderEntry type="module" module-name="intellij.platform.statistics" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -11,6 +11,7 @@ import com.intellij.ui.popup.list.GroupedItemsListRenderer;
import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -19,15 +20,13 @@ import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
public class SidePanel extends JPanel {
public final class SidePanel extends JPanel {
private final JList<SidePanelItem> myList;
private final DefaultListModel<SidePanelItem> myModel;
private final Place.Navigator myNavigator;
private final Map<Integer, String> myIndex2Separator = new HashMap<>();
private final Int2ObjectOpenHashMap<String> myIndex2Separator = new Int2ObjectOpenHashMap<>();
public SidePanel(Place.Navigator navigator) {
myNavigator = navigator;
+1
View File
@@ -4,6 +4,7 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/testData" />
<excludeFolder url="file://$MODULE_DIR$/testSrc/com/intellij/java/codeInspection/bytecodeAnalysis/precompiledData" />
</content>
<content url="file://$MODULE_DIR$/../../plugins/InspectionGadgets/testsrc">
+1
View File
@@ -17,5 +17,6 @@
<orderEntry type="library" name="gson" level="project" />
<orderEntry type="module" module-name="intellij.regexp" />
<orderEntry type="module" module-name="intellij.platform.statistics" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -1,9 +1,8 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.jsonSchema.impl;
import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -11,7 +10,7 @@ import java.util.*;
/**
* @author Irina.Chernushina on 4/22/2017.
*/
public class MatchResult {
public final class MatchResult {
public final List<JsonSchemaObject> mySchemas;
public final List<Collection<? extends JsonSchemaObject>> myExcludingSchemas;
@@ -22,7 +21,7 @@ public class MatchResult {
public static MatchResult create(@NotNull JsonSchemaTreeNode root) {
List<JsonSchemaObject> schemas = new ArrayList<>();
MultiMap<Integer, JsonSchemaObject> oneOfGroups = MultiMap.create();
Int2ObjectOpenHashMap<List<JsonSchemaObject>> oneOfGroups = new Int2ObjectOpenHashMap<>();
iterateTree(root, node -> {
if (node.isAny()) return true;
int groupNumber = node.getExcludingGroupNumber();
@@ -30,15 +29,16 @@ public class MatchResult {
schemas.add(node.getSchema());
}
else {
oneOfGroups.putValue(groupNumber, node.getSchema());
oneOfGroups.computeIfAbsent(groupNumber, __ -> new ArrayList<>()).add(node.getSchema());
}
return true;
});
List<Collection<? extends JsonSchemaObject>> result = oneOfGroups.isEmpty()
? ContainerUtil.emptyList()
: new ArrayList<>(oneOfGroups.keySet().size());
for (Map.Entry<Integer, Collection<JsonSchemaObject>> entry: oneOfGroups.entrySet()) {
result.add(entry.getValue());
List<Collection<? extends JsonSchemaObject>> result;
if (oneOfGroups.isEmpty()) {
result = Collections.emptyList();
}
else {
result = new ArrayList<>(oneOfGroups.values());
}
return new MatchResult(schemas, result);
}
@@ -1,21 +1,11 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.diff.util;
public class IntPair {
/**
* @deprecated Use {@link com.intellij.util.IntPair}
*/
@Deprecated
public final class IntPair {
public final int val1;
public final int val2;
@@ -1,26 +1,12 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.diff.comparison;
import com.intellij.diff.comparison.ByLine.Line;
import com.intellij.diff.comparison.iterables.DiffIterableUtil;
import com.intellij.diff.comparison.iterables.FairDiffIterable;
import com.intellij.diff.util.IntPair;
import com.intellij.diff.util.Range;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.util.IntPair;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NotNull;
@@ -71,10 +57,10 @@ abstract class ChangeCorrector {
IntPair range1 = getOriginalRange1(ch.start1 + i);
IntPair range2 = getOriginalRange2(ch.start2 + i);
int start1 = range1.val1;
int start2 = range2.val1;
int end1 = range1.val2;
int end2 = range2.val2;
int start1 = range1.first;
int start2 = range2.first;
int end1 = range1.second;
int end2 = range2.second;
matchGap(last1, start1, last2, start2);
myBuilder.markEqual(start1, start2, end1, end2);
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.diff.comparison;
import com.intellij.diff.comparison.iterables.DiffIterable;
@@ -21,14 +7,13 @@ import com.intellij.diff.comparison.iterables.FairDiffIterable;
import com.intellij.diff.fragments.*;
import com.intellij.diff.tools.util.text.LineOffsets;
import com.intellij.diff.tools.util.text.LineOffsetsUtil;
import com.intellij.diff.util.IntPair;
import com.intellij.diff.util.MergeRange;
import com.intellij.diff.util.Range;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Consumer;
import com.intellij.util.IntPair;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.diff.FilesTooBigForDiffException;
import com.intellij.util.text.CharSequenceSubSequence;
@@ -43,9 +28,7 @@ import java.util.List;
import static com.intellij.diff.comparison.iterables.DiffIterableUtil.fair;
import static java.util.Collections.singletonList;
public class ComparisonManagerImpl extends ComparisonManager {
private static final Logger LOG = Logger.getInstance(ComparisonManagerImpl.class);
public final class ComparisonManagerImpl extends ComparisonManager {
@NotNull
public static ComparisonManagerImpl getInstanceImpl() {
return (ComparisonManagerImpl)getInstance();
@@ -369,7 +352,7 @@ public class ComparisonManagerImpl extends ComparisonManager {
IntPair offsets2 = getOffsets(lineOffsets2, startLine2, endLine2);
fragments.add(new LineFragmentImpl(startLine1, endLine1, startLine2, endLine2,
offsets1.val1, offsets1.val2, offsets2.val1, offsets2.val2));
offsets1.first, offsets1.second, offsets2.first, offsets2.second));
}
return fragments;
}
@@ -763,7 +746,7 @@ public class ComparisonManagerImpl extends ComparisonManager {
@NotNull
private static TextRange trimIgnoredRange(int start, int end, @NotNull BitSet ignored, int offset) {
IntPair intPair = TrimUtil.trim(offset + start, offset + end, ignored);
return new TextRange(intPair.val1 - offset, intPair.val2 - offset);
return new TextRange(intPair.first - offset, intPair.second - offset);
}
private static boolean isIgnoredRange(@NotNull BitSet ignored, int start, int end) {
@@ -1,24 +1,9 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
@file:JvmName("TrimUtil")
@file:Suppress("NAME_SHADOWING")
package com.intellij.diff.comparison
import com.intellij.diff.util.IntPair
import com.intellij.diff.util.MergeRange
import com.intellij.diff.util.Range
import com.intellij.openapi.util.text.StringUtil.isWhiteSpace
@@ -60,12 +45,12 @@ fun isContinuousScript(c: Int): Boolean {
script == Character.UnicodeScript.JAVANESE
}
fun trim(text: CharSequence, start: Int, end: Int): IntPair {
fun trim(text: CharSequence, start: Int, end: Int): com.intellij.util.IntPair {
return trim(start, end,
{ index -> isWhiteSpace(text[index]) })
}
fun trim(start: Int, end: Int, ignored: BitSet): IntPair {
fun trim(start: Int, end: Int, ignored: BitSet): com.intellij.util.IntPair {
return trim(start, end,
{ index -> ignored[index] })
}
@@ -313,14 +298,14 @@ private inline fun trim(start1: Int, start2: Int, start3: Int, end1: Int, end2:
}
private inline fun trim(start: Int, end: Int,
ignored: (Int) -> Boolean): IntPair {
ignored: (Int) -> Boolean): com.intellij.util.IntPair {
var start = start
var end = end
start = trimStart(start, end, ignored)
end = trimEnd(start, end, ignored)
return IntPair(start, end)
return com.intellij.util.IntPair(start, end)
}
private inline fun trimStart(start: Int, end: Int,
@@ -534,12 +519,12 @@ private inline fun trimExpand(start1: Int, start2: Int, end1: Int, end2: Int,
var end2 = end2
val starts = trimExpandForward(start1, start2, end1, end2, equals, ignored1, ignored2)
start1 = starts.val1
start2 = starts.val2
start1 = starts.first
start2 = starts.second
val ends = trimExpandBackward(start1, start2, end1, end2, equals, ignored1, ignored2)
end1 = ends.val1
end2 = ends.val2
end1 = ends.first
end2 = ends.second
return Range(start1, end1, start2, end2)
}
@@ -547,7 +532,7 @@ private inline fun trimExpand(start1: Int, start2: Int, end1: Int, end2: Int,
private inline fun trimExpandForward(start1: Int, start2: Int, end1: Int, end2: Int,
equals: (Int, Int) -> Boolean,
ignored1: (Int) -> Boolean,
ignored2: (Int) -> Boolean): IntPair {
ignored2: (Int) -> Boolean): com.intellij.util.IntPair {
var start1 = start1
var start2 = start2
@@ -573,13 +558,13 @@ private inline fun trimExpandForward(start1: Int, start2: Int, end1: Int, end2:
start1 = trimStart(start1, end1, ignored1)
start2 = trimStart(start2, end2, ignored2)
return IntPair(start1, start2)
return com.intellij.util.IntPair(start1, start2)
}
private inline fun trimExpandBackward(start1: Int, start2: Int, end1: Int, end2: Int,
equals: (Int, Int) -> Boolean,
ignored1: (Int) -> Boolean,
ignored2: (Int) -> Boolean): IntPair {
ignored2: (Int) -> Boolean): com.intellij.util.IntPair {
var end1 = end1
var end2 = end2
@@ -605,5 +590,5 @@ private inline fun trimExpandBackward(start1: Int, start2: Int, end1: Int, end2:
end1 = trimEnd(start1, end1, ignored1)
end2 = trimEnd(start2, end2, ignored2)
return IntPair(end1, end2)
return com.intellij.util.IntPair(end1, end2)
}
@@ -1,9 +1,8 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.vcs.ex;
import com.intellij.diff.util.DiffDrawUtil;
import com.intellij.diff.util.DiffUtil;
import com.intellij.diff.util.IntPair;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.DiffBundle;
import com.intellij.openapi.diff.DiffColors;
@@ -21,6 +20,7 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.TextRange;
import com.intellij.ui.paint.LinePainter2D;
import com.intellij.ui.scale.JBUIScale;
import com.intellij.util.IntPair;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.update.MergingUpdateQueue;
import com.intellij.util.ui.update.Update;
@@ -273,7 +273,7 @@ public abstract class LineStatusMarkerRenderer {
IntPair area = getGutterArea(editor);
int y = editor.visualLineToY(startLine);
int endY = editor.visualLineToY(endLine);
return new Rectangle(area.val1, y, area.val2 - area.val1, endY - y);
return new Rectangle(area.first, y, area.second - area.first, endY - y);
}
protected boolean shouldPaintGutter() {
@@ -309,8 +309,8 @@ public abstract class LineStatusMarkerRenderer {
int line2 = block.get(block.size() - 1).line2;
IntPair area = getGutterArea(editor);
final int x = area.val1;
final int endX = area.val2;
final int x = area.first;
final int endX = area.second;
final int y = editorImpl.visualLineToY(line1);
final int endY = editorImpl.visualLineToY(line2);
@@ -389,8 +389,8 @@ public abstract class LineStatusMarkerRenderer {
public static void paintSimpleRange(Graphics g, Editor editor, int line1, int line2, @Nullable Color color) {
IntPair horizontalArea = getGutterArea(editor);
int x = horizontalArea.val1;
int endX = horizontalArea.val2;
int x = horizontalArea.first;
int endX = horizontalArea.second;
int y = lineToY(editor, line1);
int endY = lineToY(editor, line2);
@@ -1,14 +1,14 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.diff.comparison
import com.intellij.diff.DiffTestCase
import com.intellij.diff.fragments.MergeLineFragment
import com.intellij.diff.util.IntPair
import com.intellij.diff.util.MergeRange
import com.intellij.diff.util.ThreeSide
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.impl.DocumentImpl
import com.intellij.openapi.util.Couple
import com.intellij.util.IntPair
import java.util.*
abstract class ComparisonMergeUtilTestBase : DiffTestCase() {
@@ -215,8 +215,8 @@ abstract class ComparisonMergeUtilTestBase : DiffTestCase() {
val starts = Trio(start1, start2, start3)
val ends = Trio(end1, end2, end3)
fun start(side: ThreeSide): Int = this(side).val1
fun end(side: ThreeSide): Int = this(side).val2
fun start(side: ThreeSide): Int = this(side).first
fun end(side: ThreeSide): Int = this(side).second
override fun toString(): String {
return "($start1, $end1) - ($start2, $end2) - ($start3, $end3)"
@@ -1,22 +1,8 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.diff.comparison
import com.intellij.diff.DiffTestCase
import com.intellij.diff.util.IntPair
import com.intellij.util.IntPair
class ComparisonUtilTest : DiffTestCase() {
fun testTrimEquals() {
@@ -133,14 +119,14 @@ class ComparisonUtilTest : DiffTestCase() {
assertTrue(fragments.size == 1, "Side: ${fragments.size})")
val fragment = fragments[0]
assertEquals(offsets1.val1, fragment.startOffset1, fragment.toString())
assertEquals(offsets1.val2, fragment.endOffset1, fragment.toString())
assertEquals(offsets2.val1, fragment.startOffset2, fragment.toString())
assertEquals(offsets2.val2, fragment.endOffset2, fragment.toString())
assertEquals(lines1.val1, fragment.startLine1, fragment.toString())
assertEquals(lines1.val2, fragment.endLine1, fragment.toString())
assertEquals(lines2.val1, fragment.startLine2, fragment.toString())
assertEquals(lines2.val2, fragment.endLine2, fragment.toString())
assertEquals(offsets1.first, fragment.startOffset1, fragment.toString())
assertEquals(offsets1.second, fragment.endOffset1, fragment.toString())
assertEquals(offsets2.first, fragment.startOffset2, fragment.toString())
assertEquals(offsets2.second, fragment.endOffset2, fragment.toString())
assertEquals(lines1.first, fragment.startLine1, fragment.toString())
assertEquals(lines1.second, fragment.endLine1, fragment.toString())
assertEquals(lines2.first, fragment.startLine2, fragment.toString())
assertEquals(lines2.second, fragment.endLine2, fragment.toString())
}
private fun doTestTrim(expected: Boolean, string1: String, string2: String) {
@@ -1,15 +1,15 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.diff.comparison
import com.intellij.diff.DiffTestCase
import com.intellij.diff.fragments.DiffFragment
import com.intellij.diff.fragments.LineFragment
import com.intellij.diff.fragments.MergeWordFragment
import com.intellij.diff.util.IntPair
import com.intellij.diff.util.ThreeSide
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.impl.DocumentImpl
import com.intellij.openapi.util.Couple
import com.intellij.util.IntPair
import java.util.*
abstract class ComparisonUtilTestBase : DiffTestCase() {
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.diff.comparison
import com.intellij.diff.DiffTestCase
@@ -8,10 +8,10 @@ import com.intellij.diff.comparison.ComparisonUtilTestBase.Companion.ins
import com.intellij.diff.comparison.ComparisonUtilTestBase.Companion.mod
import com.intellij.diff.fragments.LineFragment
import com.intellij.diff.tools.util.text.LineOffsetsUtil
import com.intellij.diff.util.IntPair
import com.intellij.diff.util.Range
import com.intellij.openapi.util.Couple
import com.intellij.openapi.util.TextRange
import com.intellij.util.IntPair
import java.util.*
class IgnoreComparisonUtilTest : DiffTestCase() {
@@ -1,23 +1,10 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.diff.util
import com.intellij.diff.DiffTestCase
import com.intellij.diff.tools.util.text.LineOffsetsUtil
import com.intellij.openapi.editor.impl.DocumentImpl
import com.intellij.util.IntPair
class LineOffsetsTest : DiffTestCase() {
fun testWithDocument() {
@@ -64,8 +51,8 @@ class LineOffsetsTest : DiffTestCase() {
assertEquals(offsets.size, lineOffsets.lineCount)
offsets.forEachIndexed { line, value ->
assertEquals(lineOffsets.getLineStart(line), value.val1)
assertEquals(lineOffsets.getLineEnd(line), value.val2)
assertEquals(lineOffsets.getLineStart(line), value.first)
assertEquals(lineOffsets.getLineEnd(line), value.second)
for (offset in lineOffsets.getLineStart(line)..lineOffsets.getLineEnd(line)) {
assertEquals(line, lineOffsets.getLineNumber(offset))
@@ -74,6 +61,6 @@ class LineOffsetsTest : DiffTestCase() {
}
private operator fun Int.not(): IntPairHelper = IntPairHelper(this)
private operator fun IntPairHelper.minus(col: Int): IntPair = IntPair(this.line, col)
private operator fun IntPairHelper.minus(col: Int) = IntPair(this.line, col)
private class IntPairHelper(val line: Int)
}
@@ -15,5 +15,6 @@
<orderEntry type="module" module-name="intellij.platform.projectModel" exported="" />
<orderEntry type="module" module-name="intellij.platform.projectModel.impl" exported="" />
<orderEntry type="library" name="XStream" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -32,8 +32,10 @@ import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.DataInputOutputUtil;
import com.intellij.util.io.EnumeratorIntegerDescriptor;
import com.intellij.util.io.KeyDescriptor;
import gnu.trove.THashMap;
import gnu.trove.TIntArrayList;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -42,19 +44,17 @@ import org.jetbrains.annotations.TestOnly;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
/**
* @author Maxim.Mossienko on 12/11/13.
*/
public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayList> {
public class DuplicatesIndex extends FileBasedIndexExtension<Integer, IntArrayList> {
static boolean ourEnabled = SystemProperties.getBooleanProperty("idea.enable.duplicates.online.calculation",
true);
static final boolean ourEnabledLightProfiles = true;
private static boolean ourEnabledOldProfiles = false;
@NonNls public static final ID<Integer, TIntArrayList> NAME = ID.create("DuplicatesIndex");
@NonNls public static final ID<Integer, IntArrayList> NAME = ID.create("DuplicatesIndex");
private static final int myBaseVersion = 25;
private final FileBasedIndex.InputFilter myInputFilter = file -> {
@@ -70,36 +70,36 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
return duplicatesProfile != null;
};
private final DataExternalizer<TIntArrayList> myValueExternalizer = new DataExternalizer<TIntArrayList>() {
private final DataExternalizer<IntArrayList> myValueExternalizer = new DataExternalizer<IntArrayList>() {
@Override
public void save(@NotNull DataOutput out, TIntArrayList list) throws IOException {
public void save(@NotNull DataOutput out, IntArrayList list) throws IOException {
if (list.size() == 2) {
DataInputOutputUtil.writeINT(out, list.getQuick(0));
DataInputOutputUtil.writeINT(out, list.getQuick(1));
DataInputOutputUtil.writeINT(out, list.getInt(0));
DataInputOutputUtil.writeINT(out, list.getInt(1));
}
else {
DataInputOutputUtil.writeINT(out, -list.size());
int prev = 0;
for (int i = 0, len = list.size(); i < len; i+=2) {
int value = list.getQuick(i);
int value = list.getInt(i);
DataInputOutputUtil.writeINT(out, value - prev);
prev = value;
DataInputOutputUtil.writeINT(out, list.getQuick(i + 1));
DataInputOutputUtil.writeINT(out, list.getInt(i + 1));
}
}
}
@Override
public TIntArrayList read(@NotNull DataInput in) throws IOException {
public IntArrayList read(@NotNull DataInput in) throws IOException {
int capacityOrValue = DataInputOutputUtil.readINT(in);
if (capacityOrValue >= 0) {
TIntArrayList list = new TIntArrayList(2);
IntArrayList list = new IntArrayList(2);
list.add(capacityOrValue);
list.add(DataInputOutputUtil.readINT(in));
return list;
}
capacityOrValue = -capacityOrValue;
TIntArrayList list = new TIntArrayList(capacityOrValue);
IntArrayList list = new IntArrayList(capacityOrValue);
int prev = 0;
while(capacityOrValue > 0) {
int value = DataInputOutputUtil.readINT(in) + prev;
@@ -112,28 +112,30 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
}
};
private final DataIndexer<Integer, TIntArrayList, FileContent> myIndexer = new DataIndexer<Integer, TIntArrayList, FileContent>() {
private final DataIndexer<Integer, IntArrayList, FileContent> myIndexer = new DataIndexer<Integer, IntArrayList, FileContent>() {
@Override
@NotNull
public Map<Integer, TIntArrayList> map(@NotNull final FileContent inputData) {
public Int2ObjectMap<IntArrayList> map(@NotNull final FileContent inputData) {
FileType type = inputData.getFileType();
DuplicatesProfile profile = findDuplicatesProfile(type);
if (profile == null || !profile.acceptsContentForIndexing(inputData)) return Collections.emptyMap();
if (profile == null || !profile.acceptsContentForIndexing(inputData)) {
return Int2ObjectMaps.emptyMap();
}
try {
PsiDependentFileContent fileContent = (PsiDependentFileContent)inputData;
if (profile instanceof LightDuplicateProfile && ourEnabledLightProfiles) {
final THashMap<Integer, TIntArrayList> result = new THashMap<>();
final Int2ObjectOpenHashMap<IntArrayList> result = new Int2ObjectOpenHashMap<>();
LighterAST ast = fileContent.getLighterAST();
((LightDuplicateProfile)profile).process(ast, new LightDuplicateProfile.Callback() {
@Override
public void process(int hash, int hash2, @NotNull LighterAST ast, LighterASTNode @NotNull ... nodes) {
TIntArrayList list = result.get(hash);
IntArrayList list = result.get(hash);
if (list == null) {
result.put(hash, list = new TIntArrayList(2));
result.put(hash, list = new IntArrayList(2));
}
list.add(nodes[0].getStartOffset());
list.add(hash2);
@@ -147,8 +149,9 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
visitor.visitNode(fileContent.getPsiFile());
return collector.getMap();
} catch (StackOverflowError ae) {
return Collections.emptyMap(); // todo Maksim
}
catch (StackOverflowError ae) {
return Int2ObjectMaps.emptyMap(); // todo Maksim
}
}
};
@@ -175,19 +178,19 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
@NotNull
@Override
public ID<Integer,TIntArrayList> getName() {
public ID<Integer, IntArrayList> getName() {
return NAME;
}
@NotNull
@Override
public DataIndexer<Integer, TIntArrayList, FileContent> getIndexer() {
public DataIndexer<Integer, IntArrayList, FileContent> getIndexer() {
return myIndexer;
}
@NotNull
@Override
public DataExternalizer<TIntArrayList> getValueExternalizer() {
public DataExternalizer<IntArrayList> getValueExternalizer() {
return myValueExternalizer;
}
@@ -206,8 +209,8 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
//private static final TracingData myTracingData = new TracingData();
private static final TracingData myTracingData = null;
private static class MyFragmentsCollector implements FragmentsCollector {
private final THashMap<Integer, TIntArrayList> myMap = new THashMap<>();
private static final class MyFragmentsCollector implements FragmentsCollector {
private final Int2ObjectOpenHashMap<IntArrayList> myMap = new Int2ObjectOpenHashMap<>();
private final DuplicatesProfile myProfile;
private final DuplocatorState myDuplocatorState;
@@ -224,13 +227,13 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
if (myTracingData != null) myTracingData.record(hash, cost, frag);
TIntArrayList list = myMap.get(hash);
if (list == null) { myMap.put(hash, list = new TIntArrayList()); }
IntArrayList list = myMap.get(hash);
if (list == null) { myMap.put(hash, list = new IntArrayList()); }
list.add(frag.getStartOffset());
list.add(0);
}
public THashMap<Integer,TIntArrayList> getMap() {
public Int2ObjectOpenHashMap<IntArrayList> getMap() {
return myMap;
}
}
@@ -40,18 +40,10 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.tree.ILightStubFileElementType;
import com.intellij.util.SmartList;
import com.intellij.util.indexing.FileBasedIndex;
import gnu.trove.TIntArrayList;
import gnu.trove.TIntIntHashMap;
import gnu.trove.TIntLongHashMap;
import gnu.trove.TIntObjectHashMap;
import it.unimi.dsi.fastutil.ints.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Iterator;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
public class DuplicatesInspectionBase extends LocalInspectionTool {
public boolean myFilterOutGeneratedCode;
private static final int MIN_FRAGMENT_SIZE = 3; // todo 3 statements constant
@@ -80,8 +72,8 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
final SmartList<ProblemDescriptor> descriptors = new SmartList<>();
final VirtualFile baseDir = project.getBaseDir();
for (Map.Entry<Integer, TextRange> entry : processor.reportedRanges.entrySet()) {
final Integer offset = entry.getKey();
for (Int2ObjectMap.Entry<TextRange> entry : processor.reportedRanges.int2ObjectEntrySet()) {
int offset = entry.getIntKey();
if (!usingLightProfile && processor.fragmentSize.get(offset) < MIN_FRAGMENT_SIZE) continue;
final VirtualFile file = processor.reportedFiles.get(offset);
String path = null;
@@ -178,7 +170,7 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
return null;
}
private class LightDuplicatedCodeProcessor extends DuplicatedCodeProcessor<LighterASTNode> {
private final class LightDuplicatedCodeProcessor extends DuplicatedCodeProcessor<LighterASTNode> {
private final TreeBackedLighterAST myAst;
private LightDuplicatedCodeProcessor(@NotNull TreeBackedLighterAST ast, VirtualFile file, Project project) {
@@ -212,7 +204,7 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
}
}
class OldDuplicatedCodeProcessor extends DuplicatedCodeProcessor<PsiFragment> {
final class OldDuplicatedCodeProcessor extends DuplicatedCodeProcessor<PsiFragment> {
private OldDuplicatedCodeProcessor(VirtualFile file, Project project) {
super(file, project, myFilterOutGeneratedCode);
}
@@ -255,13 +247,13 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
}
}
abstract static class DuplicatedCodeProcessor<T> implements FileBasedIndex.ValueProcessor<TIntArrayList> {
final TreeMap<Integer, TextRange> reportedRanges = new TreeMap<>();
final TIntObjectHashMap<VirtualFile> reportedFiles = new TIntObjectHashMap<>();
final TIntObjectHashMap<PsiElement> reportedPsi = new TIntObjectHashMap<>();
final TIntIntHashMap reportedOffsetInOtherFiles = new TIntIntHashMap();
final TIntIntHashMap fragmentSize = new TIntIntHashMap();
final TIntLongHashMap fragmentHash = new TIntLongHashMap();
abstract static class DuplicatedCodeProcessor<T> implements FileBasedIndex.ValueProcessor<IntArrayList> {
final Int2ObjectRBTreeMap<TextRange> reportedRanges = new Int2ObjectRBTreeMap<>();
final Int2ObjectOpenHashMap<VirtualFile> reportedFiles = new Int2ObjectOpenHashMap<>();
final Int2ObjectOpenHashMap<PsiElement> reportedPsi = new Int2ObjectOpenHashMap<>();
final Int2IntOpenHashMap reportedOffsetInOtherFiles = new Int2IntOpenHashMap();
final Int2IntOpenHashMap fragmentSize = new Int2IntOpenHashMap();
final Int2LongOpenHashMap fragmentHash = new Int2LongOpenHashMap();
final VirtualFile virtualFile;
final Project project;
final FileIndex myFileIndex;
@@ -288,12 +280,12 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
}
@Override
public boolean process(@NotNull VirtualFile file, TIntArrayList list) {
public boolean process(@NotNull VirtualFile file, IntArrayList list) {
for(int i = 0, len = list.size(); i < len; i+=2) {
ProgressManager.checkCanceled();
if (list.getQuick(i + 1) != myHash2) continue;
int offset = list.getQuick(i);
if (list.getInt(i + 1) != myHash2) continue;
int offset = list.getInt(i);
if (myFileIndex.isInSourceContent(virtualFile)) {
if (!myFileIndex.isInSourceContent(file)) return true;
@@ -312,13 +304,13 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
PsiElement target = getPsi(myNode);
TextRange rangeInElement = getRangeInElement(myNode);
Integer fragmentStartOffsetInteger = startOffset;
SortedMap<Integer,TextRange> map = reportedRanges.subMap(fragmentStartOffsetInteger, endOffset);
int fragmentStartOffsetInteger = startOffset;
Int2ObjectSortedMap<TextRange> map = reportedRanges.subMap(fragmentStartOffsetInteger, endOffset);
int newFragmentSize = !map.isEmpty() ? 0:1;
Iterator<Integer> iterator = map.keySet().iterator();
IntBidirectionalIterator iterator = map.keySet().iterator();
while(iterator.hasNext()) {
Integer next = iterator.next();
int next = iterator.nextInt();
iterator.remove();
reportedFiles.remove(next);
reportedOffsetInOtherFiles.remove(next);
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.editor;
import com.intellij.openapi.Disposable;
@@ -30,7 +30,7 @@ public interface InlayModel {
/**
* Introduces an inline visual element at a given offset, its width and appearance is defined by the provided renderer.
*
* @param relatesToPrecedingText whether element is associated with preceding or following text
* @param relatesToPrecedingText whether element is associated with preceding or following text
* (see {@link Inlay#isRelatedToPrecedingText()})
* @return {@code null} if requested element cannot be created, e.g. if corresponding functionality
* is not supported by current editor instance.
@@ -76,7 +76,7 @@ public interface InlayModel {
* Both visible and invisible (due to folding) elements are returned.
*/
@NotNull
List<Inlay> getInlineElementsInRange(int startOffset, int endOffset);
List<Inlay<?>> getInlineElementsInRange(int startOffset, int endOffset);
/**
* Same as {@link #getInlineElementsInRange(int, int)}, but returned list contains only inlays with renderer of given type.
@@ -192,7 +192,7 @@ public interface InlayModel {
* @see #addAfterLineEndElement(int, boolean, EditorCustomElementRenderer)
*/
@NotNull
List<Inlay> getAfterLineEndElementsForLogicalLine(int logicalLine);
List<Inlay<?>> getAfterLineEndElementsForLogicalLine(int logicalLine);
/**
* When text is inserted at inline element's offset, resulting element's position is determined by its
@@ -15,5 +15,6 @@
<orderEntry type="library" name="miglayout-swing" level="project" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" name="StreamEx" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -10,20 +10,15 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.content.Content;
import com.intellij.util.containers.hash.LinkedHashMap;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import javax.swing.Icon;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.*;
public class RunnerLayout {
public static final Key<Integer> DEFAULT_INDEX = Key.create("RunnerLayoutDefaultIndex");
public static final Key<Integer> DROP_INDEX = Key.create("RunnerLayoutDropIndex");
@@ -32,7 +27,7 @@ public class RunnerLayout {
private final Map<String, ViewImpl.Default> myDefaultViews = new HashMap<>();
protected Set<TabImpl> myTabs = new TreeSet<>(Comparator.comparingInt(TabImpl::getIndex));
private final Map<Integer, TabImpl.Default> myDefaultTabs = new HashMap<>();
private final Int2ObjectOpenHashMap<TabImpl.Default> myDefaultTabs = new Int2ObjectOpenHashMap<>();
protected General myGeneral = new General();
private final Map<String, Pair<String, LayoutAttractionPolicy>> myDefaultFocus = new HashMap<>();
@@ -21,5 +21,6 @@
<orderEntry type="library" scope="TEST" name="hamcrest" level="project" />
<orderEntry type="module" module-name="intellij.platform.util.ex" />
<orderEntry type="module" module-name="intellij.platform.util.ui" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -1,14 +1,18 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.application.options.codeStyle.properties;
import com.intellij.openapi.util.AtomicNotNullLazyValue;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public abstract class AbstractCodeStylePropertyMapper {
@@ -25,7 +29,7 @@ public abstract class AbstractCodeStylePropertyMapper {
}
private Map<String, CodeStylePropertyAccessor<?>> createMap() {
Map<String, CodeStylePropertyAccessor<?>> accessorMap = new HashMap<>();
Object2ObjectOpenHashMap<String, CodeStylePropertyAccessor<?>> accessorMap = new Object2ObjectOpenHashMap<>();
for (CodeStyleObjectDescriptor descriptor : getSupportedFields()) {
addAccessorsFor(accessorMap, descriptor.getCodeStyleObject(), descriptor.getSupportedFields());
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.application.options.codeStyle.properties;
import org.jetbrains.annotations.NotNull;
@@ -7,7 +7,6 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
public abstract class ExternalStringAccessor<T> extends CodeStyleFieldAccessor<T,String> {
public ExternalStringAccessor(@NotNull Object object, @NotNull Field field) {
super(object, field);
}
@@ -1,7 +1,9 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.application.options.codeStyle.properties;
import com.intellij.util.containers.BidirectionalMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -10,7 +12,8 @@ import java.util.ArrayList;
import java.util.List;
public class MagicIntegerConstAccessor extends ExternalStringAccessor<Integer> implements CodeStyleChoiceList {
private final BidirectionalMap<Integer, String> myValueMap = new BidirectionalMap<>();
private final Int2ObjectOpenHashMap<String> myValueMap = new Int2ObjectOpenHashMap<>();
private final Object2ObjectOpenHashMap<String, IntArrayList> myValueToKeysMap = new Object2ObjectOpenHashMap<>();
public MagicIntegerConstAccessor(@NotNull Object object,
@NotNull Field field,
@@ -18,26 +21,26 @@ public class MagicIntegerConstAccessor extends ExternalStringAccessor<Integer> i
String[] strValues) {
super(object, field);
for (int i = 0; i < Math.min(intValues.length, strValues.length); i ++) {
myValueMap.put(intValues[i], strValues[i]);
String value = strValues[i];
int intValue = intValues[i];
myValueMap.put(intValue, value);
myValueToKeysMap.computeIfAbsent(value, __ -> new IntArrayList()).add(intValue);
}
}
@Nullable
@Override
protected final Integer fromExternal(@NotNull String str) {
List<Integer> keys = myValueMap.getKeysByValue(str);
return keys != null && keys.size() > 0 ? keys.get(0) : null;
protected final @Nullable Integer fromExternal(@NotNull String str) {
IntArrayList keys = myValueToKeysMap.get(str);
return keys != null && keys.size() > 0 ? keys.getInt(0) : null;
}
@NotNull
@Override
protected final String toExternal(@NotNull Integer value) {
return myValueMap.get(value);
protected final @NotNull String toExternal(@NotNull Integer value) {
return myValueMap.get(value.intValue());
}
@NotNull
@Override
public final List<String> getChoices() {
public final @NotNull List<String> getChoices() {
return new ArrayList<>(myValueMap.values());
}
}
@@ -1,35 +1,19 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework;
import com.intellij.execution.testframework.sm.runner.states.TestStateInfo;
import com.intellij.icons.AllIcons;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.HashMap;
import java.util.Map;
/**
* @author Dmitry Avdeev
*/
public class TestIconMapper implements PoolOfTestIcons {
private final static Map<Integer, TestStateInfo.Magnitude> magnitudes = new HashMap<>();
public final class TestIconMapper implements PoolOfTestIcons {
private final static Int2ObjectOpenHashMap<TestStateInfo.Magnitude> magnitudes = new Int2ObjectOpenHashMap<>();
static {
for (TestStateInfo.Magnitude value : TestStateInfo.Magnitude.values()) {
@@ -1,11 +1,9 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.formatting;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import java.util.HashMap;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
/**
* Defines possible types of a wrap.
@@ -40,7 +38,7 @@ public enum WrapType {
*/
CHOP_DOWN_IF_LONG(CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM);
private static final Map<Integer, WrapType> LEGACY_MAPPINGS = new HashMap<>();
private static final Int2ObjectOpenHashMap<WrapType> LEGACY_MAPPINGS = new Int2ObjectOpenHashMap<>();
static {
for (WrapType wrapType : values()) {
@@ -1,20 +1,19 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.psi.codeStyle.extractor.values;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.codeStyle.extractor.Utils;
import com.intellij.psi.codeStyle.extractor.differ.Differ;
import com.intellij.util.IntPair;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class Generation {
public final class Generation {
private static final int GENERATION_POOL_SIZE = 45;
private static final int MUTATION_PER_GEN = 10;
public static int GEN_COUNT = 40;
public static int GEN_COUNT = 40;
private List<Gens> myGensPool;
private int myAge;
private final int myParentKind;
@@ -75,12 +74,12 @@ public class Generation {
}
private int reduceToSize(@NotNull Differ differ, int newPoolSize) {
List<Pair<Integer, Integer>> ranges = new ArrayList<>(myGensPool.size());
List<IntPair> ranges = new ArrayList<>(myGensPool.size());
int i = 0;
for (final Gens gens : myGensPool) {
int range = differ.getDifference(gens);
ranges.add(Pair.create(range, i++));
ranges.add(new IntPair(range, i++));
if (range == 0) {
myAge = GEN_COUNT;
newPoolSize = 1;
@@ -93,7 +92,7 @@ public class Generation {
final ArrayList<Gens> gensPool = new ArrayList<>(newPoolSize);
int count = 0;
int worseForward = 0;
for (final Pair<Integer, Integer> pair : ranges) {
for (IntPair pair : ranges) {
if (count >= newPoolSize) {
break;
}
@@ -46,5 +46,6 @@
<orderEntry type="module" module-name="intellij.platform.statistics" />
<orderEntry type="module" module-name="intellij.platform.inspect" scope="RUNTIME" />
<orderEntry type="library" name="kotlinx-coroutines-jdk8" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
</module>
@@ -37,5 +37,6 @@
<orderEntry type="library" scope="TEST" name="StreamEx" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-jdk8" level="project" />
<orderEntry type="module" module-name="intellij.platform.statistics" scope="TEST" />
<orderEntry type="library" scope="TEST" name="fastutil-min" level="project" />
</component>
</module>
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeEditor.printing;
@@ -18,6 +18,7 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.file.PsiDirectoryFactory;
import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -134,7 +135,7 @@ class ExportToHTMLManager {
@NotNull
protected static String doPaint(@NotNull String dirName,
@NotNull HTMLTextPainter textPainter,
@Nullable Map<Integer, PsiReference> refMap) throws IOException {
@Nullable Int2ObjectRBTreeMap<PsiReference> refMap) throws IOException {
String htmlFile = dirName + File.separator + getHTMLFileName(textPainter.getPsiFile());
try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(htmlFile), StandardCharsets.UTF_8)) {
textPainter.paint(refMap, writer, true);
@@ -156,11 +157,11 @@ class ExportToHTMLManager {
if (!psiFile.isValid()) {
return;
}
Map<Integer, PsiReference> refMap = null;
Int2ObjectRBTreeMap<PsiReference> refMap = null;
for (PrintOption printOption : PrintOption.EP_NAME.getExtensionList()) {
final TreeMap<Integer, PsiReference> map = printOption.collectReferences(psiFile, filesMap);
if (map != null) {
refMap = new TreeMap<>(map);
refMap = new Int2ObjectRBTreeMap<>(map);
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeEditor.printing;
import com.intellij.application.options.CodeStyle;
@@ -22,6 +22,8 @@ import com.intellij.psi.impl.file.PsiDirectoryFactory;
import com.intellij.ui.ColorUtil;
import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
import it.unimi.dsi.fastutil.ints.IntIterator;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -30,7 +32,10 @@ import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringTokenizer;
public class HTMLTextPainter {
private static final Logger LOG = Logger.getInstance(HTMLTextPainter.class);
@@ -106,7 +111,7 @@ public class HTMLTextPainter {
myFirstLineNumber = firstLineNumber;
}
public void paint(@Nullable Map<Integer, PsiReference> refMap, @NotNull Writer writer, boolean isStandalone) throws IOException {
public void paint(@Nullable Int2ObjectRBTreeMap<PsiReference> refMap, @NotNull Writer writer, boolean isStandalone) throws IOException {
HighlighterIterator hIterator = myHighlighter.createIterator(myOffset);
if (hIterator.atEnd()) {
return;
@@ -114,16 +119,15 @@ public class HTMLTextPainter {
lineCount = myFirstLineNumber;
TextAttributes prevAttributes = null;
Iterator<Integer> refKeys = null;
IntIterator refKeys = null;
int refOffset = -1;
PsiReference ref = null;
if (refMap != null) {
refKeys = refMap.keySet().iterator();
if (refKeys.hasNext()) {
Integer key = refKeys.next();
int key = refKeys.nextInt();
ref = refMap.get(key);
refOffset = key.intValue();
refOffset = key;
}
}
@@ -201,9 +205,9 @@ public class HTMLTextPainter {
writer.write("</a>");
referenceEnd = -1;
if (refKeys.hasNext()) {
Integer key = refKeys.next();
int key = refKeys.nextInt();
ref = refMap.get(key);
refOffset = key.intValue();
refOffset = key;
}
}
hIterator.advance();
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.hint;
@@ -24,6 +24,9 @@ import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.accessibility.AccessibleContextUtil;
import com.intellij.xml.util.XmlStringUtil;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntMaps;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
@@ -519,7 +522,7 @@ public class ParameterInfoComponent extends JPanel {
}
}
private class OneLineComponent extends JPanel {
private final class OneLineComponent extends JPanel {
JLabel myLabel = new JLabel("", SwingConstants.LEFT);
private OneLineComponent(){
@@ -586,7 +589,7 @@ public class ParameterInfoComponent extends JPanel {
// flagsMap is supposed to use TEXT_RANGE_COMPARATOR
private String buildLabelText(@NotNull final String text, @NotNull final TreeMap<TextRange, ParameterInfoUIContextEx.Flag> flagsMap) {
final StringBuilder labelText = new StringBuilder(text);
final Map<Integer, Integer> faultMap = new HashMap<>();
final Int2IntOpenHashMap faultMap = new Int2IntOpenHashMap();
for (Map.Entry<TextRange, ParameterInfoUIContextEx.Flag> entry : flagsMap.entrySet()) {
final TextRange highlightRange = entry.getKey();
@@ -599,10 +602,10 @@ public class ParameterInfoComponent extends JPanel {
int startOffset = highlightRange.getStartOffset();
int endOffset = highlightRange.getEndOffset() + tag.length();
for (Map.Entry<Integer, Integer> entry1 : faultMap.entrySet()) {
if (entry1.getKey() <= highlightRange.getStartOffset()) {
startOffset += entry1.getValue();
endOffset += entry1.getValue();
for (Int2IntMap.Entry entry1 : Int2IntMaps.fastIterable(faultMap)) {
if (entry1.getIntKey() <= highlightRange.getStartOffset()) {
startOffset += entry1.getIntValue();
endOffset += entry1.getIntValue();
}
}
@@ -3,8 +3,10 @@
package com.intellij.codeInsight.lookup.impl;
import com.google.common.annotations.VisibleForTesting;
import com.intellij.codeInsight.lookup.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementPresentation;
import com.intellij.codeInsight.lookup.LookupElementRenderer;
import com.intellij.codeInsight.lookup.LookupFocusDegree;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.EditorColorsUtil;
@@ -29,13 +31,16 @@ import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.accessibility.AccessibleContextUtil;
import it.unimi.dsi.fastutil.ints.Int2BooleanOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.util.*;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import static com.intellij.codeInsight.documentation.DocumentationComponent.COLOR_KEY;
@@ -43,9 +48,7 @@ import static com.intellij.codeInsight.documentation.DocumentationComponent.COLO
* @author peter
* @author Konstantin Bulenkov
*/
public class LookupCellRenderer implements ListCellRenderer<LookupElement> {
private static final Logger LOG = Logger.getInstance(LookupCellRenderer.class);
public final class LookupCellRenderer implements ListCellRenderer<LookupElement> {
private Icon myEmptyIcon = EmptyIcon.ICON_0;
private final Font myNormalFont;
private final Font myBoldFont;
@@ -66,7 +69,7 @@ public class LookupCellRenderer implements ListCellRenderer<LookupElement> {
private final SimpleColoredComponent myTailComponent;
private final SimpleColoredComponent myTypeLabel;
private final LookupPanel myPanel;
private final Map<Integer, Boolean> mySelected = new HashMap<>();
private final Int2BooleanOpenHashMap mySelected = new Int2BooleanOpenHashMap();
private static final String ELLIPSIS = "\u2026";
private int myMaxWidth = -1;
@@ -525,7 +528,7 @@ public class LookupCellRenderer implements ListCellRenderer<LookupElement> {
return 0;
}
private static class MySimpleColoredComponent extends SimpleColoredComponent {
private static final class MySimpleColoredComponent extends SimpleColoredComponent {
private MySimpleColoredComponent() {
setFocusBorderAroundIcon(true);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.refactoring.rename;
@@ -38,13 +38,15 @@ import com.intellij.usageView.UsageInfoFactory;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Processor;
import com.intellij.util.containers.MultiMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
public class RenameUtil {
public final class RenameUtil {
private static final Logger LOG = Logger.getInstance(RenameUtil.class);
private RenameUtil() {
@@ -288,7 +290,7 @@ public class RenameUtil {
public static void renameNonCodeUsages(@NotNull Project project, NonCodeUsageInfo @NotNull [] usages) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
Map<Document, Map<Integer, UsageOffset>> docsToOffsetsMap = new HashMap<>();
Object2ObjectOpenHashMap<Document, Int2ObjectOpenHashMap<UsageOffset>> docsToOffsetsMap = new Object2ObjectOpenHashMap<>();
final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
for (NonCodeUsageInfo usage : usages) {
PsiElement element = usage.getElement();
@@ -315,9 +317,9 @@ public class RenameUtil {
}
int fileOffset = replaceRange.getStartOffset();
Map<Integer, UsageOffset> offsetMap = docsToOffsetsMap.get(document);
Int2ObjectOpenHashMap<UsageOffset> offsetMap = docsToOffsetsMap.get(document);
if (offsetMap == null) {
offsetMap = new HashMap<>();
offsetMap = new Int2ObjectOpenHashMap<>();
docsToOffsetsMap.put(document, offsetMap);
}
final UsageOffset substitution = new UsageOffset(fileOffset, fileOffset + rangeInElement.getLength(), usage.newText);
@@ -14,6 +14,7 @@
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
<orderEntry type="module" module-name="intellij.platform.diff" />
<orderEntry type="module" module-name="intellij.platform.diff.impl" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
<component name="copyright">
<Base>
@@ -1,19 +1,4 @@
/*
* Copyright 2000-2009 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.history.integration.ui.models;
import com.intellij.diff.Block;
@@ -21,20 +6,19 @@ import com.intellij.history.core.Content;
import com.intellij.history.core.revisions.Revision;
import com.intellij.history.core.tree.Entry;
import com.intellij.history.integration.IdeaGateway;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SelectionCalculator {
public final class SelectionCalculator {
private static final Block EMPTY_BLOCK = new Block("", 0, 0);
private final IdeaGateway myGateway;
private final List<? extends Revision> myRevisions;
private final int myFromLine;
private final int myToLine;
private final Map<Integer, Block> myCache = new HashMap<>();
private final Int2ObjectOpenHashMap<Block> myCache = new Int2ObjectOpenHashMap<>();
public SelectionCalculator(IdeaGateway gw, List<? extends Revision> rr, int fromLine, int toLine) {
myGateway = gw;
@@ -71,7 +55,7 @@ public class SelectionCalculator {
Block result;
if (content == null) {
result = EMPTY_BLOCK;
result = EMPTY_BLOCK;
} else if (revisionIndex == 0) {
result = new Block(content, myFromLine, myToLine + 1);
}
@@ -45,5 +45,6 @@
<orderEntry type="library" name="rd-core" level="project" />
<orderEntry type="library" name="rd-framework" level="project" />
<orderEntry type="library" name="rd-swing" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -1,19 +1,4 @@
/*
* Copyright 2000-2010 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide.wizard;
import com.intellij.openapi.project.Project;
@@ -21,6 +6,7 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.ui.JBCardLayout;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -29,10 +15,9 @@ import java.util.List;
import java.util.Map;
public class AbstractWizardEx extends AbstractWizard<AbstractWizardStepEx> {
private final String myTitle;
private final Map<Object, Integer> myStepId2Index = new HashMap<>();
private final Map<Integer, AbstractWizardStepEx> myIndex2Step = new HashMap<>();
private final Int2ObjectOpenHashMap<AbstractWizardStepEx> myIndex2Step = new Int2ObjectOpenHashMap<>();
public AbstractWizardEx(String title, @Nullable Project project, List<? extends AbstractWizardStepEx> steps) {
super(title, project);
@@ -12,6 +12,7 @@ import com.intellij.ui.components.JBOptionButton;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.DialogUtil;
import com.intellij.util.ui.UIUtil;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -25,8 +26,6 @@ import java.awt.event.InputEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.function.IntPredicate;
/**
@@ -60,7 +59,7 @@ public final class MnemonicHelper extends ComponentTreeWatcher {
}
};
private Map<Integer, String> myMnemonics;
private Int2ObjectOpenHashMap<String> myMnemonics;
/**
* @see #init(Component)
@@ -137,12 +136,12 @@ public final class MnemonicHelper extends ComponentTreeWatcher {
public void checkForDuplicateMnemonics(int mnemonic, String text) {
if (mnemonic == 0) return;
if (myMnemonics == null) myMnemonics = new HashMap<>();
final String other = myMnemonics.get(Integer.valueOf(mnemonic));
if (myMnemonics == null) myMnemonics = new Int2ObjectOpenHashMap<>();
final String other = myMnemonics.get(mnemonic);
if (other != null && !other.equals(text)) {
LOG.error("conflict: multiple components with mnemonic '" + (char)mnemonic + "' seen on '" + text + "' and '" + other + "'");
}
myMnemonics.put(Integer.valueOf(mnemonic), text);
myMnemonics.put(mnemonic, text);
}
/**
@@ -0,0 +1,31 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;
public final class IntPair {
public final int first;
public final int second;
public IntPair(int first, int second) {
this.first = first;
this.second = second;
}
@Override
public int hashCode() {
return 31 * first + second;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IntPair that = (IntPair)o;
return first == that.first && second == that.second;
}
@Override
public String toString() {
return "first=" + first + ", second=" + second;
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util.ui.update;
import com.intellij.ide.UiActivity;
@@ -13,6 +13,7 @@ import com.intellij.util.Alarm;
import com.intellij.util.AlarmFactory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -22,7 +23,6 @@ import javax.swing.*;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
* Use this class to postpone task execution and optionally merge identical tasks. This is needed e.g. to reflect in UI status of some
@@ -39,7 +39,7 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable {
private volatile boolean myActive;
private volatile boolean mySuspended;
private final Map<Integer, Map<Update, Update>> myScheduledUpdates = new TreeMap<>();
private final Int2ObjectRBTreeMap<Map<Update, Update>> myScheduledUpdates = new Int2ObjectRBTreeMap<>();
private final Alarm myWaiterForMerge;
@@ -15,6 +15,10 @@ import com.intellij.ui.TabbedPaneWrapper;
import com.intellij.util.CollectConsumer;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.containers.ContainerUtil;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -38,7 +42,7 @@ public final class SearchUtil {
private static final Pattern NON_WORD_PATTERN = Pattern.compile("[\\W&&[^\\p{Punct}\\p{Blank}]]");
public static final String HIGHLIGHT_WITH_BORDER = "searchUtil.highlightWithBorder";
public static final String STYLE_END = "</style>";
private static final String STYLE_END = "</style>";
private SearchUtil() { }
@@ -77,8 +81,7 @@ public final class SearchUtil {
final Configurable unwrapped = unwrapConfigurable(configurable);
if (unwrapped instanceof CompositeConfigurable) {
unwrapped.disposeUIResources();
//noinspection unchecked
final List<? extends UnnamedConfigurable> children = ((CompositeConfigurable)unwrapped).getConfigurables();
final List<? extends UnnamedConfigurable> children = ((CompositeConfigurable<?>)unwrapped).getConfigurables();
for (final UnnamedConfigurable child : children) {
final Set<OptionDescription> childConfigurableOptions = new TreeSet<>();
options.put(new SearchableConfigurableAdapter(searchableConfigurable, child), childConfigurableOptions);
@@ -152,7 +155,7 @@ public final class SearchUtil {
processUILabel(label, configurableOptions, path);
}
else if (component instanceof JComboBox) {
List<String> labels = getItemsFromComboBox((JComboBox)component);
List<String> labels = getItemsFromComboBox((JComboBox<?>)component);
for (String each : labels) {
processUILabel(each, configurableOptions, path);
}
@@ -213,20 +216,20 @@ public final class SearchUtil {
}
@NotNull
public static List<String> getItemsFromComboBox(@NotNull JComboBox comboBox) {
ListCellRenderer renderer = comboBox.getRenderer();
private static List<String> getItemsFromComboBox(@NotNull JComboBox<?> comboBox) {
@SuppressWarnings("unchecked")
ListCellRenderer<Object> renderer = (ListCellRenderer<Object>)comboBox.getRenderer();
if (renderer == null) {
renderer = new DefaultListCellRenderer();
}
JList jList = new BasicComboPopup(comboBox).getList();
JList<?> jList = new BasicComboPopup(comboBox).getList();
List<String> result = new ArrayList<>();
int count = comboBox.getItemCount();
for (int i = 0; i < count; i++) {
Object value = comboBox.getItemAt(i);
//noinspection unchecked
Component labelComponent = renderer.getListCellRendererComponent(jList, value, i, false, false);
String label = getLabelFromComponent(labelComponent);
if (label != null) {
@@ -289,7 +292,7 @@ public final class SearchUtil {
}
}
else if (rootComponent instanceof JComboBox) {
List<String> labels = getItemsFromComboBox(((JComboBox)rootComponent));
List<String> labels = getItemsFromComboBox(((JComboBox<?>)rootComponent));
if (ContainerUtil.exists(labels, it -> isComponentHighlighted(it, option, force, configurable))) {
highlightComponent(rootComponent, option);
return true; // do not visit children of highlighted component
@@ -467,24 +470,25 @@ public final class SearchUtil {
if (filter == null || filter.length() == 0) {
textRenderer.append(text, new SimpleTextAttributes(background, foreground, JBColor.RED, style));
}
else { //markup
final HashSet<String> quoted = new HashSet<>();
else {
//markup
ObjectOpenHashSet<String> quoted = new ObjectOpenHashSet<>();
filter = processFilter(quoteStrictOccurrences(text, filter), quoted);
final TreeMap<Integer, String> indx = new TreeMap<>();
final Int2ObjectRBTreeMap<String> indexToString = new Int2ObjectRBTreeMap<>();
for (String stripped : quoted) {
int beg = 0;
int idx;
while ((idx = StringUtil.indexOfIgnoreCase(text, stripped, beg)) != -1) {
indx.put(idx, text.substring(idx, idx + stripped.length()));
indexToString.put(idx, text.substring(idx, idx + stripped.length()));
beg = idx + stripped.length();
}
}
final List<String> selectedWords = new ArrayList<>();
int pos = 0;
for (Integer index : indx.keySet()) {
final String stripped = indx.get(index);
final int start = index.intValue();
for (Int2ObjectMap.Entry<String> entry : Int2ObjectMaps.fastIterable(indexToString)) {
String stripped = entry.getValue();
int start = entry.getIntKey();
if (pos > start) {
final String highlighted = selectedWords.get(selectedWords.size() - 1);
if (highlighted.length() < stripped.length()) {
@@ -556,7 +560,7 @@ public final class SearchUtil {
return keySetList;
}
public static String processFilter(String filter, Set<? super String> quoted) {
private static String processFilter(String filter, Set<? super String> quoted) {
StringBuilder withoutQuoted = new StringBuilder();
int beg = 0;
final Matcher matcher = QUOTED.matcher(filter);
@@ -19,6 +19,9 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -149,13 +152,13 @@ public final class SocketLock {
lockPortFiles();
Map<Integer, List<String>> portToPath = new HashMap<>();
Int2ObjectOpenHashMap<List<String>> portToPath = new Int2ObjectOpenHashMap<>(2);
readPort(myConfigPath, portToPath);
readPort(mySystemPath, portToPath);
if (!portToPath.isEmpty()) {
args = JetBrainsProtocolHandler.checkForJetBrainsProtocolCommand(args);
for (Map.Entry<Integer, List<String>> entry : portToPath.entrySet()) {
Map.Entry<ActivationStatus, CliResult> status = tryActivate(entry.getKey(), entry.getValue(), args);
for (Int2ObjectMap.Entry<List<String>> entry : Int2ObjectMaps.fastIterable(portToPath)) {
Map.Entry<ActivationStatus, CliResult> status = tryActivate(entry.getIntKey(), entry.getValue(), args);
if (status.getKey() != ActivationStatus.NO_INSTANCE) {
log("exit: lock(): " + status.getValue());
unlockPortFiles();
@@ -248,9 +251,15 @@ public final class SocketLock {
}
}
private static void readPort(@NotNull Path dir, @NotNull Map<Integer, List<String>> portToPath) {
private static void readPort(@NotNull Path dir, @NotNull Int2ObjectOpenHashMap<List<String>> portToPath) {
try {
portToPath.computeIfAbsent(Integer.parseInt(readOneLine(dir.resolve(PORT_FILE))), it -> new ArrayList<>()).add(dir.toString());
int port = Integer.parseInt(readOneLine(dir.resolve(PORT_FILE)));
List<String> list = portToPath.get(port);
if (list == null) {
list = new ArrayList<>();
portToPath.put(port, list);
}
list.add(dir.toString());
}
catch (NoSuchFileException ignore) {
}
@@ -1,29 +1,14 @@
/*
* Copyright 2000-2013 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.editor.impl;
import com.intellij.openapi.editor.FoldRegion;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class FoldingAnchorsOverlayStrategy {
final class FoldingAnchorsOverlayStrategy {
private final EditorImpl myEditor;
FoldingAnchorsOverlayStrategy(EditorImpl editor) {
@@ -34,7 +19,7 @@ class FoldingAnchorsOverlayStrategy {
Collection<DisplayedFoldingAnchor> getAnchorsToDisplay(int firstVisibleOffset,
int lastVisibleOffset,
@NotNull List<FoldRegion> activeFoldRegions) {
Map<Integer, DisplayedFoldingAnchor> result = new HashMap<>();
Int2ObjectOpenHashMap<DisplayedFoldingAnchor> result = new Int2ObjectOpenHashMap<>();
FoldRegion[] visibleFoldRegions = myEditor.getFoldingModel().fetchVisible();
if (visibleFoldRegions != null) {
for (FoldRegion region : visibleFoldRegions) {
@@ -78,7 +63,7 @@ class FoldingAnchorsOverlayStrategy {
return result.values();
}
private static void tryAdding(@NotNull Map<Integer, DisplayedFoldingAnchor> resultsMap,
private static void tryAdding(@NotNull Int2ObjectOpenHashMap<DisplayedFoldingAnchor> resultsMap,
@NotNull FoldRegion region,
int visualLine,
int visualHeight,
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
/*
* @author max
@@ -8,17 +8,16 @@ package com.intellij.openapi.editor.impl;
import com.intellij.openapi.editor.IndentGuideDescriptor;
import com.intellij.openapi.editor.IndentsModel;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.util.IntPair;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class IndentsModelImpl implements IndentsModel {
private final Map<IntPair, IndentGuideDescriptor> myIndentsByLines = new HashMap<>();
private List<IndentGuideDescriptor> myIndents = new ArrayList<>();
public final class IndentsModelImpl implements IndentsModel {
private final Object2ObjectOpenHashMap<IntPair, IndentGuideDescriptor> myIndentsByLines = new Object2ObjectOpenHashMap<>();
private List<IndentGuideDescriptor> myIndents = new ArrayList<>();
@NotNull private final EditorImpl myEditor;
public IndentsModelImpl(@NotNull EditorImpl editor) {
@@ -59,34 +58,4 @@ public class IndentsModelImpl implements IndentsModel {
myIndentsByLines.put(new IntPair(descriptor.startLine, descriptor.endLine), descriptor);
}
}
private static class IntPair {
private final int start;
private final int end;
IntPair(int start, int end) {
this.start = start;
this.end = end;
}
@Override
public int hashCode() {
return 31 * start + end;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IntPair that = (IntPair)o;
return start == that.start && end == that.end;
}
@Override
public String toString() {
return "start=" + start + ", end=" + end;
}
}
}
@@ -52,7 +52,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
boolean myMoveInProgress;
boolean myPutMergedIntervalsAtBeginning;
private boolean myConsiderCaretPositionOnDocumentUpdates = true;
private List<Inlay> myInlaysAtCaret;
private List<Inlay<?>> myInlaysAtCaret;
private boolean myInBatchMode;
InlayModelImpl(@NotNull EditorImpl editor) {
@@ -74,7 +74,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
if (myInBatchMode) LOG.error("Document shouldn't be changed during batch inlay operation");
int offset = event.getOffset();
if (myConsiderCaretPositionOnDocumentUpdates && event.getOldLength() == 0 && offset == myEditor.getCaretModel().getOffset()) {
List<Inlay> inlays = getInlineElementsInRange(offset, offset);
List<Inlay<?>> inlays = getInlineElementsInRange(offset, offset);
int inlayCount = inlays.size();
if (inlayCount > 0) {
VisualPosition inlaysStartPosition = myEditor.offsetToVisualPosition(offset, false, false);
@@ -162,17 +162,15 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
@NotNull
@Override
public List<Inlay> getInlineElementsInRange(int startOffset, int endOffset) {
List<InlineInlayImpl> range =
getElementsInRange(myInlineElementsTree, startOffset, endOffset, inlay -> true, INLINE_ELEMENTS_COMPARATOR);
public List<Inlay<?>> getInlineElementsInRange(int startOffset, int endOffset) {
//noinspection unchecked
return (List)range;
return getElementsInRange(myInlineElementsTree, startOffset, endOffset, inlay -> true, INLINE_ELEMENTS_COMPARATOR);
}
@NotNull
@Override
public <T> List<Inlay<? extends T>> getInlineElementsInRange(int startOffset, int endOffset, @NotNull Class<T> type) {
List<InlineInlayImpl> range =
List<InlineInlayImpl<?>> range =
getElementsInRange(myInlineElementsTree, startOffset, endOffset, inlay -> type.isInstance(inlay.myRenderer),
INLINE_ELEMENTS_COMPARATOR);
//noinspection unchecked
@@ -197,11 +195,11 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
return (List)range;
}
private static <T extends Inlay> List<T> getElementsInRange(@NotNull IntervalTreeImpl<? extends T> tree,
int startOffset,
int endOffset,
Predicate<? super T> predicate,
Comparator<? super T> comparator) {
private static <T extends Inlay<?>> List<T> getElementsInRange(@NotNull IntervalTreeImpl<? extends T> tree,
int startOffset,
int endOffset,
Predicate<? super T> predicate,
Comparator<? super T> comparator) {
List<T> result = new ArrayList<>();
tree.processOverlappingWith(startOffset, endOffset, inlay -> {
if (predicate.test(inlay)) result.add(inlay);
@@ -290,7 +288,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
@Override
public Inlay getInlineElementAt(@NotNull VisualPosition visualPosition) {
int offset = myEditor.visualPositionToOffset(visualPosition);
List<Inlay> inlays = getInlineElementsInRange(offset, offset);
List<Inlay<?>> inlays = getInlineElementsInRange(offset, offset);
if (inlays.isEmpty()) return null;
VisualPosition inlayStartPosition = myEditor.offsetToVisualPosition(offset, false, false);
if (visualPosition.line != inlayStartPosition.line) return null;
@@ -353,12 +351,12 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
}
if (hasInlineElements) {
int offset = location.getOffset();
List<Inlay> inlays = getInlineElementsInRange(offset, offset);
List<Inlay<?>> inlays = getInlineElementsInRange(offset, offset);
if (!inlays.isEmpty()) {
VisualPosition startVisualPosition = myEditor.offsetToVisualPosition(offset);
Point inlayPoint = myEditor.visualPositionToXY(startVisualPosition);
if (point.y < inlayPoint.y || point.y >= inlayPoint.y + myEditor.getLineHeight()) return null;
Inlay inlay = findInlay(inlays, point.x, inlayPoint.x);
Inlay<?> inlay = findInlay(inlays, point.x, inlayPoint.x);
if (inlay != null) return inlay;
}
}
@@ -366,12 +364,12 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
int offset = location.getOffset();
int logicalLine = myEditor.getDocument().getLineNumber(offset);
if (offset == myEditor.getDocument().getLineEndOffset(logicalLine) && !myEditor.getFoldingModel().isOffsetCollapsed(offset)) {
List<Inlay> inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine);
List<Inlay<?>> inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine);
if (!inlays.isEmpty()) {
Rectangle bounds = inlays.get(0).getBounds();
assert bounds != null;
if (point.y < bounds.y || point.y >= bounds.y + bounds.height) return null;
Inlay inlay = findInlay(inlays, point.x, bounds.x);
Inlay<?> inlay = findInlay(inlays, point.x, bounds.x);
if (inlay != null) return inlay;
}
}
@@ -379,7 +377,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
return null;
}
private static Inlay findInlay(List<? extends Inlay> inlays, int x, int startX) {
private static Inlay<?> findInlay(List<Inlay<?>> inlays, int x, int startX) {
for (Inlay inlay : inlays) {
int endX = startX + inlay.getWidthInPixels();
if (x >= startX && x < endX) return inlay;
@@ -411,7 +409,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
@NotNull
@Override
public List<Inlay> getAfterLineEndElementsForLogicalLine(int logicalLine) {
public List<Inlay<?>> getAfterLineEndElementsForLogicalLine(int logicalLine) {
DocumentEx document = myEditor.getDocument();
if (!hasAfterLineEndElements() || logicalLine < 0 || logicalLine > 0 && logicalLine >= document.getLineCount()) {
return Collections.emptyList();
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.editor.impl.view;
import com.intellij.openapi.editor.*;
@@ -14,7 +14,6 @@ import com.intellij.openapi.editor.impl.*;
import com.intellij.openapi.editor.impl.softwrap.SoftWrapDrawingType;
import com.intellij.openapi.editor.markup.*;
import com.intellij.openapi.editor.markup.TextAttributesEffectsBuilder.EffectDescriptor;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.wm.impl.IdeBackgroundUtil;
@@ -27,16 +26,14 @@ import com.intellij.ui.paint.LinePainter2D;
import com.intellij.ui.paint.PaintUtil;
import com.intellij.ui.scale.JBUIScale;
import com.intellij.ui.scale.ScaleContext;
import com.intellij.util.DocumentUtil;
import com.intellij.util.ObjectUtils;
import com.intellij.util.Processor;
import com.intellij.util.SmartList;
import com.intellij.util.*;
import com.intellij.util.containers.PeekableIterator;
import com.intellij.util.containers.PeekableIteratorWrapper;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.util.ui.UIUtil;
import gnu.trove.TFloatArrayList;
import gnu.trove.TIntObjectHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -106,7 +103,7 @@ public class EditorPainter implements TextDrawingCallback {
return - Session.getTabGap(Session.getWhiteSpaceScale(editor)) / 2;
}
private static class Session {
private static final class Session {
private final EditorView myView;
private final EditorImpl myEditor;
private final Document myDocument;
@@ -125,7 +122,7 @@ public class EditorPainter implements TextDrawingCallback {
private final int mySeparatorHighlightersEndOffset;
private final ClipDetector myClipDetector;
private final IterationState.CaretData myCaretData;
private final Map<Integer, Couple<Integer>> myVirtualSelectionMap;
private final Int2ObjectOpenHashMap<IntPair> myVirtualSelectionMap;
private final TIntObjectHashMap<List<LineExtensionData>> myExtensionData = new TIntObjectHashMap<>(); // key is visual line
private final TIntObjectHashMap<TextAttributes> myBetweenLinesAttributes = new TIntObjectHashMap<>(); // key is bottom visual line
private final int myLineHeight;
@@ -478,8 +475,8 @@ public class EditorPainter implements TextDrawingCallback {
}
}
private static Map<Integer, Couple<Integer>> createVirtualSelectionMap(Editor editor, int startVisualLine, int endVisualLine) {
HashMap<Integer, Couple<Integer>> map = new HashMap<>();
private static @NotNull Int2ObjectOpenHashMap<IntPair> createVirtualSelectionMap(Editor editor, int startVisualLine, int endVisualLine) {
Int2ObjectOpenHashMap<IntPair> map = new Int2ObjectOpenHashMap<>();
for (Caret caret : editor.getCaretModel().getAllCarets()) {
if (caret.hasSelection()) {
VisualPosition selectionStart = caret.getSelectionStartPosition();
@@ -487,7 +484,7 @@ public class EditorPainter implements TextDrawingCallback {
if (selectionStart.line == selectionEnd.line) {
int line = selectionStart.line;
if (line >= startVisualLine && line <= endVisualLine) {
map.put(line, Couple.of(selectionStart.column, selectionEnd.column));
map.put(line, new IntPair(selectionStart.column, selectionEnd.column));
}
}
}
@@ -496,7 +493,7 @@ public class EditorPainter implements TextDrawingCallback {
}
private void paintVirtualSelectionIfNecessary(int visualLine, int columnStart, float xStart, int y) {
Couple<Integer> selectionRange = myVirtualSelectionMap.get(visualLine);
IntPair selectionRange = myVirtualSelectionMap.get(visualLine);
if (selectionRange == null || selectionRange.second <= columnStart) return;
float startX = selectionRange.first <= columnStart
? xStart
@@ -1199,7 +1196,7 @@ public class EditorPainter implements TextDrawingCallback {
caret.getSelectionStartPosition().line < bottomVisualLine && bottomVisualLine <= caret.getSelectionEndPosition().line;
}
class MyProcessor implements Processor<RangeHighlighterEx> {
final class MyProcessor implements Processor<RangeHighlighterEx> {
private int layer;
private Color backgroundColor;
@@ -1523,7 +1520,7 @@ public class EditorPainter implements TextDrawingCallback {
return view.getEditor().isRightAligned() ? new RightAligned(view) : new LeftAligned(view);
}
class LeftAligned implements XCorrector {
final class LeftAligned implements XCorrector {
private final EditorView myView;
private final int myLeftInset;
@@ -1593,7 +1590,7 @@ public class EditorPainter implements TextDrawingCallback {
}
}
class RightAligned implements XCorrector {
final class RightAligned implements XCorrector {
private final EditorView myView;
private RightAligned(@NotNull EditorView view) {
@@ -1662,7 +1659,7 @@ public class EditorPainter implements TextDrawingCallback {
}
}
private static class LineExtensionData {
private static final class LineExtensionData {
private final LineExtensionInfo info;
private final LineLayout layout;
@@ -1672,7 +1669,7 @@ public class EditorPainter implements TextDrawingCallback {
}
}
private static class MarginPositions {
private static final class MarginPositions {
private final float[] x;
private final int[] y;
@@ -15,11 +15,11 @@ import com.intellij.openapi.editor.impl.*;
import com.intellij.openapi.editor.impl.softwrap.SoftWrapDrawingType;
import com.intellij.openapi.editor.impl.softwrap.mapping.IncrementalCacheUpdateEvent;
import com.intellij.openapi.editor.impl.softwrap.mapping.SoftWrapAwareDocumentParsingListenerAdapter;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.util.DocumentEventUtil;
import com.intellij.util.DocumentUtil;
import com.intellij.util.IntPair;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,7 +33,7 @@ import java.util.stream.Stream;
/**
* Calculates width (in pixels) of editor contents.
*/
class EditorSizeManager implements PrioritizedDocumentListener, Disposable, FoldingListener, InlayModel.Listener, Dumpable {
final class EditorSizeManager implements PrioritizedDocumentListener, Disposable, FoldingListener, InlayModel.Listener, Dumpable {
private static final Logger LOG = Logger.getInstance(EditorSizeManager.class);
private static final int UNKNOWN_WIDTH = Integer.MAX_VALUE;
@@ -71,7 +71,7 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
private final List<TextRange> myDeferredRanges = new ArrayList<>();
private boolean myWidestBlockInlayValid;
private Inlay myWidestBlockInlay;
private Inlay<?> myWidestBlockInlay;
private final SoftWrapAwareDocumentParsingListenerAdapter mySoftWrapChangeListener = new SoftWrapAwareDocumentParsingListenerAdapter() {
@Override
@@ -213,7 +213,7 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
reset();
}
private void onLineInlayUpdate(@NotNull Inlay inlay) {
private void onLineInlayUpdate(@NotNull Inlay<?> inlay) {
if (myDuringDocumentUpdate) {
if (inlay.getPlacement() == Inlay.Placement.AFTER_LINE_END) {
myAfterLineEndInlayUpdated = true;
@@ -327,7 +327,7 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
assert !myEditor.getInlayModel().isInBatchMode();
boolean needFullScan = true;
if (myStartInvalidLine <= myEndInvalidLine && (myEndInvalidLine - myStartInvalidLine) < SPECIFIC_LINES_RECALC_THRESHOLD ) {
Pair<Integer, Integer> pair = calculateTextPreferredWidth(myStartInvalidLine, myEndInvalidLine);
IntPair pair = calculateTextPreferredWidth(myStartInvalidLine, myEndInvalidLine);
needFullScan = pair.first < myWidthInPixels &&
myStartInvalidLine <= myWidthDefiningLineNumber && myWidthDefiningLineNumber <= myEndInvalidLine;
if (pair.first >= myWidthInPixels) {
@@ -336,7 +336,7 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
}
}
if (needFullScan) {
Pair<Integer, Integer> pair = calculateTextPreferredWidth(0, Integer.MAX_VALUE);
IntPair pair = calculateTextPreferredWidth(0, Integer.MAX_VALUE);
myWidthInPixels = pair.first;
myWidthDefiningLineNumber = pair.second;
}
@@ -374,8 +374,10 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
}
// first number is the width, second number is the largest visual line number
private Pair<Integer, Integer> calculateTextPreferredWidth(int startVisualLine, int endVisualLine) {
if (checkDirty()) return Pair.pair(1, 0);
private IntPair calculateTextPreferredWidth(int startVisualLine, int endVisualLine) {
if (checkDirty()) {
return new IntPair(1, 0);
}
assertValidState();
VisualLinesIterator iterator = new VisualLinesIterator(myEditor, startVisualLine);
int maxWidth = 0;
@@ -389,7 +391,7 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
if (iterator.getVisualLine() >= endVisualLine) break;
iterator.advance();
}
return Pair.create(maxWidth, largestLineNumber);
return new IntPair(maxWidth, largestLineNumber);
}
int getVisualLineWidth(VisualLinesIterator visualLinesIterator, boolean allowQuickCalculation) {
@@ -431,10 +433,10 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
x += myEditor.getSoftWrapModel().getMinDrawingWidthInPixels(SoftWrapDrawingType.BEFORE_SOFT_WRAP_LINE_FEED);
}
else {
List<Inlay> inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(iterator.getEndLogicalLine());
List<Inlay<?>> inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(iterator.getEndLogicalLine());
if (!inlays.isEmpty()) {
x += myView.getPlainSpaceWidth();
for (Inlay inlay : inlays) {
for (Inlay<?> inlay : inlays) {
x += inlay.getWidthInPixels();
}
}
@@ -5,6 +5,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import javax.swing.*;
import java.awt.event.InputEvent;
@@ -298,7 +299,7 @@ public class KeyStrokeAdapter implements KeyListener {
private static final class LazyVirtualKeys {
private static final Map<String, Integer> myNameToCode = new HashMap<>();
private static final Map<Integer, String> myCodeToName = new HashMap<>();
private static final Int2ObjectOpenHashMap<String> myCodeToName = new Int2ObjectOpenHashMap<>();
static {
try {
@@ -17,5 +17,6 @@
<orderEntry type="library" name="JDOM" level="project" />
<orderEntry type="module" module-name="intellij.platform.ide" />
<orderEntry type="module" module-name="intellij.platform.statistics.uploader" exported="" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.eventLog;
import com.intellij.openapi.actionSystem.ActionPlaces;
@@ -6,6 +6,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.KeyboardShortcut;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -13,15 +14,12 @@ import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static java.awt.event.KeyEvent.*;
public class ShortcutDataProvider {
public final class ShortcutDataProvider {
@Nullable
public static String getActionEventText(@Nullable AnActionEvent event) {
return event != null ? getInputEventText(event.getInputEvent(), event.getPlace()) : null;
@@ -139,7 +137,7 @@ public class ShortcutDataProvider {
return StringUtil.join(pressed, "+");
}
private static final Map<Integer, String> ourKeyCodes = new HashMap<>();
private static final Int2ObjectOpenHashMap<String> ourKeyCodes = new Int2ObjectOpenHashMap<>();
static {
ourKeyCodes.put(VK_ENTER, "Enter");
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2009 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util.containers;
import com.intellij.util.SmartList;
@@ -72,7 +58,7 @@ public class BidirectionalMap<K,V> implements Map<K,V>{
@Override
public boolean containsKey(Object key){
return myKeyToValueMap.containsKey(key);
}
}
@Override
@SuppressWarnings("SuspiciousMethodCalls")
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util.containers;
import com.intellij.util.ArrayUtil;
@@ -6,6 +6,10 @@ import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
/**
* @deprecated Use {@link it.unimi.dsi.fastutil.ints.IntArrayList}
*/
@Deprecated
public final class IntArrayList implements Cloneable {
private int[] myData;
private int mySize;
@@ -17,5 +17,6 @@
<orderEntry type="library" name="kotlin-stdlib-jdk8" level="project" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.platform.util.ui" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -1,35 +1,18 @@
/*
* Copyright 2000-2011 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.vcs.annotate;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import java.util.HashMap;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
/**
* @author irengrig
*/
public class VcsRareLineAnnotationData implements VcsLineAnnotationData {
private final Map<Integer, VcsRevisionNumber> myMap;
public final class VcsRareLineAnnotationData implements VcsLineAnnotationData {
private final Int2ObjectOpenHashMap<VcsRevisionNumber> myMap = new Int2ObjectOpenHashMap<>();
private final int mySize;
public VcsRareLineAnnotationData(final int size) {
public VcsRareLineAnnotationData(int size) {
mySize = size;
myMap = new HashMap<>();
}
@Override
@@ -28,5 +28,6 @@
<orderEntry type="library" name="StreamEx" level="project" />
<orderEntry type="module" module-name="intellij.platform.statistics" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -1,7 +1,6 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.diff.impl.patch.apply;
import com.intellij.diff.util.IntPair;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.impl.patch.ApplyPatchStatus;
import com.intellij.openapi.diff.impl.patch.PatchHunk;
@@ -15,6 +14,7 @@ import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.changes.patch.AppliedTextPatch;
import com.intellij.util.BeforeAfter;
import com.intellij.util.Consumer;
import com.intellij.util.IntPair;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -629,9 +629,9 @@ public class GenericPatchApplier {
AppliedTextPatch.HunkStatus hunkStatus) {
if (hunk != null) {
// +1 to the end because end range is always not included -> [i;j); except add modification;
int newStart = lineWithPartContextApplied.getStartOffset() + contextRangeShift.val1;
int newStart = lineWithPartContextApplied.getStartOffset() + contextRangeShift.first;
int newEnd = hunk.isInsertion() && hunkStatus != AppliedTextPatch.HunkStatus.ALREADY_APPLIED
? newStart : lineWithPartContextApplied.getEndOffset() + 1 - contextRangeShift.val2;
? newStart : lineWithPartContextApplied.getEndOffset() + 1 - contextRangeShift.second;
myAppliedInfo.add(new AppliedTextPatch.AppliedSplitPatchHunk(hunk, newStart, newEnd, hunkStatus));
}
}
@@ -659,7 +659,7 @@ public class GenericPatchApplier {
}
}
private static class Point {
private static final class Point {
private final int myDistance;
private final int myContextDistance;
private final int myCommon;
@@ -694,7 +694,7 @@ public class GenericPatchApplier {
}
}
private class SequentialStepsChecker {
private final class SequentialStepsChecker {
private int myDistance;
// in the end, will be [excluding] end of changing interval
private int myIdx;
@@ -758,7 +758,7 @@ public class GenericPatchApplier {
}
}
private static class FirstLineDescriptor {
private static final class FirstLineDescriptor {
private final String myLine;
private final int myOffset;
private final int myStepNumber;
@@ -794,7 +794,7 @@ public class GenericPatchApplier {
}
}
private static class ExactMatchSolver extends MismatchSolver {
private static final class ExactMatchSolver extends MismatchSolver {
private ExactMatchSolver(final SplitHunk hunk) {
super(false);
final List<BeforeAfter<List<String>>> steps = hunk.getPatchSteps();
@@ -860,7 +860,7 @@ public class GenericPatchApplier {
new WalkingIterator(line, originalStart, maxWalkFromBinding, false));
}
private class WalkingIterator implements Iterator<Integer> {
private final class WalkingIterator implements Iterator<Integer> {
private final String myLine;
// true = down
private final boolean myDirection;
@@ -973,7 +973,7 @@ public class GenericPatchApplier {
}
// will not find consider fragments that intersect
private class FragmentMatcher {
private final class FragmentMatcher {
private final int myIdx;
private int myOffsetIdxInHunk;
// if we set index in hunk != 0, then we will check only one side
@@ -1,17 +1,21 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.vcs.changes.committed;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NonNls;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.Locale;
/**
* @author irengrig
*/
public class DateChangeListGroupingStrategy implements ChangeListGroupingStrategy {
public final class DateChangeListGroupingStrategy implements ChangeListGroupingStrategy {
@NonNls private final SimpleDateFormat myMonthYearFormat = new SimpleDateFormat("MMMM yyyy", Locale.ENGLISH);
private long myTimeToRecalculateAfter;
private Calendar myCurrentCalendar;
@@ -73,36 +77,34 @@ public class DateChangeListGroupingStrategy implements ChangeListGroupingStrateg
return CommittedChangeListByDateComparator.DESCENDING;
}
private static class MonthsCache {
@NonNls private final SimpleDateFormat myMonthFormat = new SimpleDateFormat("MMMM", Locale.ENGLISH);
private final Map<Integer, String> myCache;
private static final class MonthsCache {
private final Int2ObjectOpenHashMap<String> myCache = new Int2ObjectOpenHashMap<>(12);
private MonthsCache(final Calendar calendarForInit) {
myCache = new HashMap<>();
private MonthsCache(Calendar calendarForInit) {
SimpleDateFormat monthFormat = new SimpleDateFormat("MMMM", Locale.ENGLISH);
for (int i = 0; i < 12; i++) {
calendarForInit.set(Calendar.MONTH, i);
myCache.put(i, myMonthFormat.format(calendarForInit.getTime()));
myCache.put(i, monthFormat.format(calendarForInit.getTime()));
}
}
public String get(final int month) {
public String get(int month) {
return myCache.get(month);
}
}
private static class WeekDayFormatCache {
@NonNls private final SimpleDateFormat myWeekdayFormat = new SimpleDateFormat("EEEE", Locale.ENGLISH);
private final Map<Integer, String> myCache;
private static final class WeekDayFormatCache {
private final Int2ObjectOpenHashMap<String> myCache = new Int2ObjectOpenHashMap<>(7);
private WeekDayFormatCache(final Calendar calendarForInit) {
myCache = new HashMap<>();
SimpleDateFormat weekdayFormat = new SimpleDateFormat("EEEE", Locale.ENGLISH);
for (int i = 1; i < 8; i++) {
calendarForInit.set(Calendar.DAY_OF_WEEK, i);
myCache.put(i, myWeekdayFormat.format(calendarForInit.getTime()));
myCache.put(i, weekdayFormat.format(calendarForInit.getTime()));
}
}
public String get(final int dayOfWeek) {
public String get(int dayOfWeek) {
return myCache.get(dayOfWeek);
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2009 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.vcs.changes.issueLinks;
import com.intellij.openapi.project.Project;
@@ -31,7 +17,7 @@ import java.util.List;
/**
* @author yole
*/
public class IssueLinkHtmlRenderer {
public final class IssueLinkHtmlRenderer {
private IssueLinkHtmlRenderer() {
}
@@ -13,7 +13,6 @@ import com.intellij.diff.requests.MessageDiffRequest;
import com.intellij.diff.requests.NoDiffRequest;
import com.intellij.diff.requests.SimpleDiffRequest;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.diff.util.IntPair;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ModalityState;
@@ -37,6 +36,7 @@ import com.intellij.ui.components.panels.Wrapper;
import com.intellij.ui.table.TableView;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Consumer;
import com.intellij.util.IntPair;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.AnimatedIcon;
import com.intellij.util.ui.*;
@@ -55,6 +55,7 @@ import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static com.intellij.util.ObjectUtils.notNull;
@@ -161,7 +162,7 @@ public final class VcsSelectionHistoryDialog extends FrameWrapper implements Dat
final VcsFileRevision revision;
if (myList.getSelectedRowCount() == 1 && !myList.isEmpty()) {
revision = myList.getItems().get(myList.getSelectedRow());
String message = IssueLinkHtmlRenderer.formatTextIntoHtml(myProject, revision.getCommitMessage());
String message = IssueLinkHtmlRenderer.formatTextIntoHtml(myProject, Objects.requireNonNull(revision.getCommitMessage()));
myComments.setText(message);
myComments.setCaretPosition(0);
}
@@ -271,7 +272,7 @@ public final class VcsSelectionHistoryDialog extends FrameWrapper implements Dat
}
IntPair range = getSelectedRevisionsRange(data);
List<VcsFileRevision> oldSelection = data.getRevisions().subList(range.val1, range.val2);
List<VcsFileRevision> oldSelection = data.getRevisions().subList(range.first, range.second);
myListModel.setItems(newItems);
@@ -374,8 +375,8 @@ public final class VcsSelectionHistoryDialog extends FrameWrapper implements Dat
}
IntPair range = getSelectedRevisionsRange(blockData);
int revIndex1 = range.val2;
int revIndex2 = range.val1;
int revIndex1 = range.second;
int revIndex2 = range.first;
if (revIndex1 == count && revIndex2 == count) {
myDiffPanel.setRequest(NoDiffRequest.INSTANCE);
@@ -691,12 +692,12 @@ public final class VcsSelectionHistoryDialog extends FrameWrapper implements Dat
IntPair range = dialog.getSelectedRevisionsRange(blockData);
List<VcsFileRevision> revisions = blockData.getRevisions();
VcsFileRevision beforeRevision = range.val2 < revisions.size() ? revisions.get(range.val2) : VcsFileRevision.NULL;
VcsFileRevision afterRevision = revisions.get(range.val1);
VcsFileRevision beforeRevision = range.second < revisions.size() ? revisions.get(range.second) : VcsFileRevision.NULL;
VcsFileRevision afterRevision = revisions.get(range.first);
FilePath filePath = VcsUtil.getFilePath(dialog.myFile);
if (range.val2 - range.val1 > 1) {
if (range.second - range.first > 1) {
dialog.getDiffHandler().showDiffForTwo(dialog.myProject, filePath, beforeRevision, afterRevision);
}
else {
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.unscramble;
import com.intellij.execution.filters.FileHyperlinkInfo;
@@ -37,13 +37,17 @@ import com.intellij.openapi.vcs.history.VcsHistorySession;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.text.DateFormatUtil;
import com.intellij.util.ui.update.MergingUpdateQueue;
import com.intellij.util.ui.update.Update;
import com.intellij.vcs.history.VcsHistoryProviderEx;
import com.intellij.vcsUtil.VcsUtil;
import com.intellij.xml.util.XmlStringUtil;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntListIterator;
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.CalledWithReadLock;
import org.jetbrains.annotations.NotNull;
@@ -93,8 +97,8 @@ public class AnnotateStackTraceAction extends DumbAwareAction {
@Override
public void run(@NotNull ProgressIndicator indicator) {
MultiMap<VirtualFile, Integer> files2lines = new MultiMap<>();
Map<Integer, LastRevision> revisions = new HashMap<>();
Object2ObjectOpenHashMap<VirtualFile, IntArrayList> files2lines = new Object2ObjectOpenHashMap<>();
Int2ObjectOpenHashMap<LastRevision> revisions = new Int2ObjectOpenHashMap<>();
ApplicationManager.getApplication().runReadAction(() -> {
for (int line = 0; line < editor.getDocument().getLineCount(); line++) {
@@ -102,21 +106,21 @@ public class AnnotateStackTraceAction extends DumbAwareAction {
VirtualFile file = getHyperlinkVirtualFile(hyperlinks.findAllHyperlinksOnLine(line));
if (file == null) continue;
files2lines.putValue(file, line);
files2lines.computeIfAbsent(file, __ -> new IntArrayList()).add(line);
}
});
files2lines.entrySet().forEach(entry -> {
indicator.checkCanceled();
for (Map.Entry<VirtualFile, IntArrayList> entry : Object2ObjectMaps.fastIterable(files2lines)) {
VirtualFile file = entry.getKey();
Collection<Integer> lines = entry.getValue();
IntArrayList value = entry.getValue();
indicator.checkCanceled();
LastRevision revision = getLastRevision(file);
if (revision == null) return;
if (revision == null) {
continue;
}
synchronized (LOCK) {
for (Integer line : lines) {
revisions.put(line, revision);
for (IntListIterator iterator = value.iterator(); iterator.hasNext(); ) {
revisions.put(iterator.nextInt(), revision);
}
}
@@ -126,7 +130,7 @@ public class AnnotateStackTraceAction extends DumbAwareAction {
updateGutter(indicator, revisions);
}
});
});
}
// myUpdateQueue can be disposed before the last revisions are passed to the gutter
ApplicationManager.getApplication().invokeLater(() -> updateGutter(indicator, revisions));
+1
View File
@@ -38,5 +38,6 @@
<orderEntry type="library" name="StreamEx" level="project" />
<orderEntry type="module" module-name="intellij.platform.statistics" />
<orderEntry type="module" module-name="intellij.platform.lvcs" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -7,6 +7,7 @@ import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.xml.util.XmlStringUtil;
import git4idea.annotate.AnnotationTooltipBuilder;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnBundle;
@@ -257,15 +258,15 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation {
protected abstract void showAllAffectedPaths(SvnRevisionNumber number);
private static class MyPartiallyCreatedInfos {
private static final class MyPartiallyCreatedInfos {
private boolean myShowMergeSource;
private final Map<Integer, CommitInfo> myMappedLineInfo;
private final Map<Integer, CommitInfo> myMergeSourceInfos;
private final Int2ObjectOpenHashMap<CommitInfo> myMappedLineInfo;
private final Int2ObjectOpenHashMap<CommitInfo> myMergeSourceInfos;
private int myMaxIdx;
private MyPartiallyCreatedInfos() {
myMergeSourceInfos = new HashMap<>();
myMappedLineInfo = new HashMap<>();
myMergeSourceInfos = new Int2ObjectOpenHashMap<>();
myMappedLineInfo = new Int2ObjectOpenHashMap<>();
myMaxIdx = 0;
}
@@ -279,7 +280,7 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation {
void appendNumberedLineInfo(final int lineNumber, @NotNull CommitInfo info, @Nullable CommitInfo mergeInfo) {
if (myMappedLineInfo.get(lineNumber) != null) return;
myMaxIdx = (myMaxIdx < lineNumber) ? lineNumber : myMaxIdx;
myMaxIdx = Math.max(myMaxIdx, lineNumber);
myMappedLineInfo.put(lineNumber, info);
if (mergeInfo != null) {
myMergeSourceInfos.put(lineNumber, mergeInfo);
+1
View File
@@ -19,5 +19,6 @@
<orderEntry type="module" module-name="intellij.json" />
<orderEntry type="module" module-name="intellij.json.tests" scope="TEST" />
<orderEntry type="library" name="StreamEx" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.yaml.psi.impl;
import com.intellij.lang.ASTNode;
@@ -8,6 +8,7 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.util.ObjectUtils;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.yaml.YAMLTokenTypes;
import org.jetbrains.yaml.YAMLUtil;
@@ -15,9 +16,11 @@ import org.jetbrains.yaml.lexer.YAMLGrammarCharUtil;
import org.jetbrains.yaml.psi.YAMLQuotedText;
import org.jetbrains.yaml.psi.YamlPsiElementVisitor;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText {
public final class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText {
private final boolean myIsSingleQuoted;
public YAMLQuotedTextImpl(@NotNull ASTNode node) {
@@ -196,7 +199,7 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText
return "YAML quoted text";
}
private static class Escaper {
private static final class Escaper {
private static final int[][] ONE_LETTER_CONVERSIONS = new int[][] {
{'0', 0},
{'a', 7},
@@ -218,29 +221,13 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText
{'P', 8233},
};
private static final NotNullLazyValue<Map<Integer, Integer>> ESC_TO_CODE = new NotNullLazyValue<Map<Integer, Integer>>() {
@NotNull
@Override
protected Map<Integer, Integer> compute() {
final HashMap<Integer, Integer> map = new HashMap<>(ONE_LETTER_CONVERSIONS.length);
for (int[] conversion : ONE_LETTER_CONVERSIONS) {
map.put(conversion[0], conversion[1]);
}
return map;
private static final NotNullLazyValue<Int2IntOpenHashMap> ESC_TO_CODE = NotNullLazyValue.createValue(() -> {
Int2IntOpenHashMap map = new Int2IntOpenHashMap(ONE_LETTER_CONVERSIONS.length);
for (int[] conversion : ONE_LETTER_CONVERSIONS) {
map.put(conversion[0], conversion[1]);
}
};
private static final NotNullLazyValue<Map<Integer, Integer>> CODE_TO_ESC = new NotNullLazyValue<Map<Integer, Integer>>() {
@NotNull
@Override
protected Map<Integer, Integer> compute() {
final HashMap<Integer, Integer> map = new HashMap<>(ONE_LETTER_CONVERSIONS.length);
for (int[] conversion : ONE_LETTER_CONVERSIONS) {
map.put(conversion[1], conversion[2]);
}
return map;
}
};
return map;
});
static int findEscapementLength(@NotNull CharSequence text, int pos) {
if (pos + 1 >= text.length() || text.charAt(pos) != '\\') {
@@ -269,11 +256,11 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText
return Integer.parseInt(s.toString(), 16);
}
catch (NumberFormatException e) {
return (int)'?';
return '?';
}
}
else {
final Integer result = ESC_TO_CODE.getValue().get((int)text.charAt(pos + 1));
final Integer result = ESC_TO_CODE.getValue().get(text.charAt(pos + 1));
return ObjectUtils.notNull(result, (int)text.charAt(pos + 1));
}
}
@@ -22,5 +22,6 @@
<orderEntry type="library" name="gson" level="project" />
<orderEntry type="library" name="NanoXML" level="project" />
<orderEntry type="module" module-name="intellij.platform.util.ui" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.xml.util;
import com.intellij.util.containers.SoftFactoryMap;
@@ -8,18 +8,15 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* @author spleaner
*/
public class ColorIconCache {
public final class ColorIconCache {
private static final ColorIconCache INSTANCE = new ColorIconCache();
private static final SoftFactoryMap<Color, Map<Integer, Icon>> ourCache = new SoftFactoryMap<Color, Map<Integer, Icon>>() {
private static final SoftFactoryMap<Color, ConcurrentMap<Integer, Icon>> ourCache = new SoftFactoryMap<Color, ConcurrentMap<Integer, Icon>>() {
@Override
protected Map<Integer, Icon> create(Color key) {
protected ConcurrentMap<Integer, Icon> create(Color key) {
return new ConcurrentHashMap<>();
}
};