IDEA-242821 IDEA unresponsive when reloading a large project

Also do cleanup, use jdk collections in other places

GitOrigin-RevId: d4d8af4ed0044d99f87d837e8082c6fe8c2fe540
This commit is contained in:
Vladimir Krivosheev
2020-06-09 13:22:51 +03:00
committed by intellij-monorepo-bot
parent 0b5f2bd81e
commit df0d4e5d5e
60 changed files with 427 additions and 779 deletions
@@ -1,18 +1,4 @@
/*
* 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.execution.testDiscovery;
import com.intellij.execution.testframework.autotest.AbstractAutoTestManager;
@@ -34,8 +20,7 @@ import org.jetbrains.annotations.NotNull;
storages = {@Storage(StoragePathMacros.WORKSPACE_FILE)}
)
public class JavaAutoRunManager extends AbstractAutoTestManager {
@NotNull
public static JavaAutoRunManager getInstance(Project project) {
public static @NotNull JavaAutoRunManager getInstance(Project project) {
return ServiceManager.getService(project, JavaAutoRunManager.class);
}
@@ -43,9 +28,8 @@ public class JavaAutoRunManager extends AbstractAutoTestManager {
super(project);
}
@NotNull
@Override
protected AutoTestWatcher createWatcher(Project project) {
protected @NotNull AutoTestWatcher createWatcher(@NotNull Project project) {
return new AutoTestWatcher() {
private boolean myHasErrors = false;
private Disposable myEventDisposable;
@@ -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.facet.impl.ui.libraries;
import com.intellij.framework.library.FrameworkLibraryVersion;
@@ -36,10 +22,11 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
public class LibraryCompositionSettings implements Disposable {
public final class LibraryCompositionSettings implements Disposable {
private final CustomLibraryDescription myLibraryDescription;
@NotNull private final NotNullComputable<String> myPathProvider;
private FrameworkLibraryVersionFilter myVersionFilter;
@@ -49,8 +36,7 @@ public class LibraryCompositionSettings implements Disposable {
private Library mySelectedLibrary;
private boolean myDownloadLibraries;
private LibraryDownloadSettings myDownloadSettings;
private final Map<Library, ExistingLibraryEditor> myExistingLibraryEditors =
ContainerUtil.newIdentityTroveMap();
private final Map<Library, ExistingLibraryEditor> myExistingLibraryEditors = new IdentityHashMap<>();
private FrameworkLibraryProvider myLibraryProvider;
public LibraryCompositionSettings(final @NotNull CustomLibraryDescription libraryDescription,
@@ -1,19 +1,4 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// 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.roots.ui.configuration.projectRoot;
import com.intellij.openapi.project.Project;
@@ -27,18 +12,15 @@ import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibrary
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorListener;
import com.intellij.openapi.util.Disposer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
public class LibrariesModifiableModel implements LibraryTable.ModifiableModel {
public final class LibrariesModifiableModel implements LibraryTable.ModifiableModel {
//todo[nik] remove LibraryImpl#equals method instead of using identity maps
private final Map<Library, ExistingLibraryEditor> myLibrary2EditorMap =
ContainerUtil.newIdentityTroveMap();
private final Set<Library> myRemovedLibraries = ContainerUtil.newIdentityTroveSet();
private final Map<Library, ExistingLibraryEditor> myLibrary2EditorMap = new IdentityHashMap<>();
private final Set<Library> myRemovedLibraries = Collections.newSetFromMap(new IdentityHashMap<>());
private LibraryTable.ModifiableModel myLibrariesModifiableModel;
private final Project myProject;
@@ -16,16 +16,16 @@ import com.intellij.util.WalkingState;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.FactoryMap;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import java.util.*;
public abstract class SliceNullnessAnalyzerBase {
@NotNull
private final SliceLeafEquality myLeafEquality;
private final @NotNull SliceLeafEquality myLeafEquality;
@NotNull
private final SliceLanguageSupportProvider myProvider;
private final @NotNull SliceLanguageSupportProvider myProvider;
public SliceNullnessAnalyzerBase(@NotNull SliceLeafEquality leafEquality,
@NotNull SliceLanguageSupportProvider provider) {
@@ -37,11 +37,11 @@ public abstract class SliceNullnessAnalyzerBase {
SliceRootNode root = createNewTree(result, oldRoot, map);
SliceUsage rootUsage = oldRoot.getCachedChildren().get(0).getValue();
SliceManager.getInstance(root.getProject()).createToolWindow(true, root, true, SliceManager.getElementDescription(null, rootUsage.getElement(), " Grouped by Nullness") );
SliceManager.getInstance(Objects.requireNonNull(root.getProject()))
.createToolWindow(true, root, true, SliceManager.getElementDescription(null, Objects.requireNonNull(rootUsage).getElement(), " Grouped by Nullness") );
}
@NotNull
public SliceRootNode createNewTree(NullAnalysisResult result, SliceRootNode oldRoot, final Map<SliceNode, NullAnalysisResult> map) {
public @NotNull SliceRootNode createNewTree(NullAnalysisResult result, SliceRootNode oldRoot, final Map<SliceNode, NullAnalysisResult> map) {
SliceRootNode root = oldRoot.copy();
assert oldRoot.getCachedChildren().size() == 1;
SliceNode oldRootStart = oldRoot.getCachedChildren().get(0);
@@ -63,7 +63,7 @@ public abstract class SliceNullnessAnalyzerBase {
SliceNode oldRootStart,
String nodeName,
final int group) {
Collection<PsiElement> groupedByValue = result.groupedByValue[group];
Collection<PsiElement> groupedByValue = result.groupedByValue.get(group);
if (groupedByValue.isEmpty()) {
return null;
}
@@ -107,7 +107,7 @@ public abstract class SliceNullnessAnalyzerBase {
ProgressManager.getInstance().run(new Task.Backgroundable(
root.getProject(), JavaRefactoringBundle.message("dataflow.to.here.expand.progress", encouragementPiece), true) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
public void run(final @NotNull ProgressIndicator indicator) {
NullAnalysisResult l = calcNullableLeaves(root, treeStructure, map);
leafExpressions.set(l);
}
@@ -132,25 +132,25 @@ public abstract class SliceNullnessAnalyzerBase {
});
}
public static Map<SliceNode, NullAnalysisResult> createMap() {
return FactoryMap.createMap(k->new NullAnalysisResult(), ContainerUtil::newIdentityTroveMap);
public static @NotNull Map<SliceNode, NullAnalysisResult> createMap() {
return FactoryMap.createMap(k -> new NullAnalysisResult(), () -> new Reference2ObjectOpenHashMap<>());
}
private static NullAnalysisResult node(@NotNull SliceNode node, @NotNull Map<SliceNode, NullAnalysisResult> nulls) {
return nulls.get(node);
}
private static Collection<PsiElement> group(@NotNull SliceNode node, @NotNull Map<SliceNode, NullAnalysisResult> nulls, int group) {
return nulls.get(node).groupedByValue[group];
return nulls.get(node).groupedByValue.get(group);
}
@NotNull
public NullAnalysisResult calcNullableLeaves(@NotNull final SliceNode root,
@NotNull AbstractTreeStructure treeStructure,
@NotNull final Map<SliceNode, NullAnalysisResult> map) {
public @NotNull NullAnalysisResult calcNullableLeaves(final @NotNull SliceNode root,
@NotNull AbstractTreeStructure treeStructure,
final @NotNull Map<SliceNode, NullAnalysisResult> map) {
final SliceLeafAnalyzer.SliceNodeGuide guide = new SliceLeafAnalyzer.SliceNodeGuide(treeStructure);
WalkingState<SliceNode> walkingState = new WalkingState<SliceNode>(guide) {
@Override
public void visit(@NotNull final SliceNode element) {
public void visit(final @NotNull SliceNode element) {
element.calculateDupNode();
node(element, map).clear();
SliceNode duplicate = element.getDuplicate();
@@ -195,16 +195,15 @@ public abstract class SliceNullnessAnalyzerBase {
* @param element element to find nullability for
* @return element nullability
*/
@NotNull
protected Nullability checkNullability(final PsiElement element) {
protected @NotNull Nullability checkNullability(final PsiElement element) {
throw new UnsupportedOperationException();
}
public static class NullAnalysisResult {
public static final class NullAnalysisResult {
static final int NULLS = 0;
static final int NOT_NULLS = 1;
static final int UNKNOWNS = 2;
final Collection<PsiElement>[] groupedByValue = new Collection[] {new THashSet<PsiElement>(),new THashSet<PsiElement>(),new THashSet<PsiElement>()};
final List<ObjectOpenHashSet<PsiElement>> groupedByValue = Arrays.asList(new ObjectOpenHashSet<>(), new ObjectOpenHashSet<>(), new ObjectOpenHashSet<>());
public void clear() {
for (Collection<PsiElement> elements : groupedByValue) {
@@ -213,9 +212,9 @@ public abstract class SliceNullnessAnalyzerBase {
}
private void add(NullAnalysisResult duplicate) {
for (int i = 0; i < groupedByValue.length; i++) {
Collection<PsiElement> elements = groupedByValue[i];
Collection<PsiElement> other = duplicate.groupedByValue[i];
for (int i = 0; i < groupedByValue.size(); i++) {
Collection<PsiElement> elements = groupedByValue.get(i);
Collection<PsiElement> other = duplicate.groupedByValue.get(i);
elements.addAll(other);
}
}
@@ -1,8 +1,4 @@
// 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
*/
package com.intellij.psi.search.searches;
import com.intellij.openapi.extensions.ExtensionPointName;
@@ -15,7 +11,7 @@ import com.intellij.util.Query;
import com.intellij.util.QueryExecutor;
import org.jetbrains.annotations.NotNull;
public class AllClassesSearch extends ExtensibleQueryFactory<PsiClass, AllClassesSearch.SearchParameters> {
public final class AllClassesSearch extends ExtensibleQueryFactory<PsiClass, AllClassesSearch.SearchParameters> {
public static final ExtensionPointName<QueryExecutor<PsiClass, AllClassesSearch.SearchParameters>> EP_NAME = ExtensionPointName.create("com.intellij.allClassesSearch");
public static final AllClassesSearch INSTANCE = new AllClassesSearch();
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// 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.util;
import com.intellij.lang.java.JavaLanguage;
@@ -20,13 +6,14 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import gnu.trove.TObjectIntHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
public class ClassUtil {
public final class ClassUtil {
private ClassUtil() { }
public static String extractPackageName(String className) {
@@ -83,9 +70,9 @@ public class ClassUtil {
}
private static int getNonQualifiedClassIdx(@NotNull final PsiClass psiClass, @NotNull final PsiClass containingClass) {
TObjectIntHashMap<PsiClass> indices =
Object2IntMap<PsiClass> indices =
CachedValuesManager.getCachedValue(containingClass, () -> {
final TObjectIntHashMap<PsiClass> map = new TObjectIntHashMap<>();
Object2IntOpenHashMap<PsiClass> map = new Object2IntOpenHashMap<>();
int index = 0;
for (PsiClass aClass : SyntaxTraverser.psiTraverser().withRoot(containingClass).postOrderDfsTraversal().filter(PsiClass.class)) {
if (aClass.getQualifiedName() == null) {
@@ -95,7 +82,7 @@ public class ClassUtil {
return CachedValueProvider.Result.create(map, containingClass);
});
return indices.get(psiClass);
return indices.getInt(psiClass);
}
public static PsiClass findNonQualifiedClassByIndex(@NotNull String indexName,
@@ -1,26 +1,14 @@
/*
* 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.psi.impl.cache;
import com.intellij.psi.JavaTokenType;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.BitUtil;
import gnu.trove.TIntObjectHashMap;
import gnu.trove.TObjectIntHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
/**
* Constants used in Java stubs; may differ from ones used in a .class file format.
@@ -44,9 +32,9 @@ public final class ModifierFlags {
public static final int OPEN_MASK = 0x2000;
public static final int TRANSITIVE_MASK = 0x4000;
public static final TObjectIntHashMap<String> NAME_TO_MODIFIER_FLAG_MAP = new TObjectIntHashMap<>();
public static final TIntObjectHashMap<String> MODIFIER_FLAG_TO_NAME_MAP = new TIntObjectHashMap<>();
public static final TObjectIntHashMap<IElementType> KEYWORD_TO_MODIFIER_FLAG_MAP = new TObjectIntHashMap<>();
public static final Object2IntMap<String> NAME_TO_MODIFIER_FLAG_MAP = new Object2IntOpenHashMap<>();
public static final Int2ObjectMap<String> MODIFIER_FLAG_TO_NAME_MAP = new Int2ObjectOpenHashMap<>();
public static final Object2IntMap<IElementType> KEYWORD_TO_MODIFIER_FLAG_MAP = new Object2IntOpenHashMap<>();
static {
NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.PUBLIC, PUBLIC_MASK);
NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.PRIVATE, PRIVATE_MASK);
@@ -64,8 +52,8 @@ public final class ModifierFlags {
NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.OPEN, OPEN_MASK);
NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.TRANSITIVE, TRANSITIVE_MASK);
for (Object name : NAME_TO_MODIFIER_FLAG_MAP.keys()) {
MODIFIER_FLAG_TO_NAME_MAP.put(NAME_TO_MODIFIER_FLAG_MAP.get((String)name), (String)name);
for (Object name : NAME_TO_MODIFIER_FLAG_MAP.keySet()) {
MODIFIER_FLAG_TO_NAME_MAP.put(NAME_TO_MODIFIER_FLAG_MAP.getInt(name), (String)name);
}
KEYWORD_TO_MODIFIER_FLAG_MAP.put(JavaTokenType.PUBLIC_KEYWORD, PUBLIC_MASK);
@@ -85,7 +73,7 @@ public final class ModifierFlags {
}
public static boolean hasModifierProperty(String name, int mask) {
int flag = NAME_TO_MODIFIER_FLAG_MAP.get(name);
int flag = NAME_TO_MODIFIER_FLAG_MAP.getInt(name);
assert flag != 0 : name;
return BitUtil.isSet(mask, flag);
}
@@ -20,7 +20,7 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.util.CharTable;
import org.jetbrains.annotations.NotNull;
public class RecordUtil {
public final class RecordUtil {
private static final String DEPRECATED_ANNOTATION_NAME = "Deprecated";
private static final String DEPRECATED_TAG = "@deprecated";
@@ -63,7 +63,7 @@ public class RecordUtil {
public static int packModifierList(@NotNull LighterAST tree, @NotNull LighterASTNode modList) {
int packed = 0;
for (final LighterASTNode child : tree.getChildren(modList)) {
packed |= ModifierFlags.KEYWORD_TO_MODIFIER_FLAG_MAP.get(child.getTokenType());
packed |= ModifierFlags.KEYWORD_TO_MODIFIER_FLAG_MAP.getInt(child.getTokenType());
}
return packed;
}
@@ -189,7 +189,7 @@ public class PsiModifierListImpl extends JavaStubPsiElement<PsiModifierListStub>
public boolean hasExplicitModifier(@NotNull String name) {
PsiModifierListStub stub = getGreenStub();
if (stub != null) {
return BitUtil.isSet(stub.getModifiersMask(), ModifierFlags.NAME_TO_MODIFIER_FLAG_MAP.get(name));
return BitUtil.isSet(stub.getModifiersMask(), ModifierFlags.NAME_TO_MODIFIER_FLAG_MAP.getInt(name));
}
final CompositeElement tree = (CompositeElement)getNode();
@@ -102,6 +102,7 @@ import com.intellij.util.ref.GCWatcher;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.CheckDtdReferencesInspection;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import kotlin.Unit;
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.Nls;
@@ -1204,7 +1205,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
((EditorImpl)myEditor).getScrollPane().getViewport().setSize(1000, 1000);
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);
final Set<LightweightHint> shown = ContainerUtil.newIdentityTroveSet();
final Set<LightweightHint> shown = new ReferenceOpenHashSet<>();
getProject().getMessageBus().connect().subscribe(EditorHintListener.TOPIC, (project, hint, flags) -> {
shown.add(hint);
hint.addHintListener(event -> shown.remove(hint));
@@ -1950,7 +1951,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
configureByText(JavaFileType.INSTANCE, "class S { void foo() { boolean var; if (<selection>va<caret>r</selection>) {}} }");
((EditorImpl)myEditor).getScrollPane().getViewport().setSize(1000, 1000);
final Set<LightweightHint> visibleHints = ContainerUtil.newIdentityTroveSet();
final Set<LightweightHint> visibleHints = new ReferenceOpenHashSet<>();
getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(EditorHintListener.TOPIC, new EditorHintListener() {
@Override
public void hintShown(final Project project, @NotNull final LightweightHint hint, final int flags) {
@@ -21,7 +21,7 @@ import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.containers.hash.EqualityPolicy;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -94,7 +94,7 @@ public class BaseCompletionLookupArranger extends LookupArranger implements Comp
ProcessingContext context = createContext();
Classifier<LookupElement> classifier = myClassifiers.get(sorter);
while (classifier != null) {
final THashSet<LookupElement> itemSet = ContainerUtil.newIdentityTroveSet(thisSorterItems);
Set<LookupElement> itemSet = new ReferenceOpenHashSet<>(thisSorterItems);
List<LookupElement> unsortedItems = ContainerUtil.filter(myItems, lookupElement -> itemSet.contains(lookupElement));
List<Pair<LookupElement, Object>> pairs = classifier.getSortingWeights(unsortedItems, context);
if (!hideSingleValued || !haveSameWeights(pairs)) {
@@ -339,7 +339,7 @@ public class BaseCompletionLookupArranger extends LookupArranger implements Comp
LookupElement relevantSelection = findMostRelevantItem(sortedByRelevance);
List<LookupElement> listModel = isAlphaSorted() ?
sortByPresentation(items) :
fillModelByRelevance(lookup, ContainerUtil.newIdentityTroveSet(items), sortedByRelevance, relevantSelection);
fillModelByRelevance(lookup, new ReferenceOpenHashSet<>(items), sortedByRelevance, relevantSelection);
int toSelect = getItemToSelect(lookup, listModel, onExplicitAction, relevantSelection);
LOG.assertTrue(toSelect >= 0);
@@ -12,7 +12,6 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.containers.ContainerUtil
import com.intellij.util.io.createDirectories
import com.intellij.util.io.systemIndependentPath
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import org.jdom.Element
import org.xmlpull.mxp1.MXParser
import org.xmlpull.v1.XmlPullParser
@@ -28,13 +27,13 @@ internal class SchemeLoader<T : Any, MUTABLE_SCHEME : T>(private val schemeManag
private val oldSchemes: List<T>,
private val preScheduledFilesToDelete: MutableSet<String>,
private val isDuringLoad: Boolean) {
private val filesToDelete: MutableSet<String> = ObjectOpenHashSet()
private val filesToDelete: MutableSet<String> = HashSet()
private val schemes: MutableList<T> = oldSchemes.toMutableList()
private var newSchemesOffset = schemes.size
// scheme could be changed - so, hashcode will be changed - we must use identity hashing strategy
private val schemeToInfo = ContainerUtil.newIdentityTroveMap<T, ExternalInfo>()
private val schemeToInfo = IdentityHashMap<T, ExternalInfo>()
private val isApplied = AtomicBoolean()
@@ -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.requests;
import com.intellij.diff.chains.DiffRequestProducer;
@@ -21,7 +7,7 @@ import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ErrorDiffRequest extends MessageDiffRequest {
public final class ErrorDiffRequest extends MessageDiffRequest {
@Nullable private final DiffRequestProducer myProducer;
@Nullable private final Throwable myException;
@@ -13,10 +13,7 @@ import com.intellij.openapi.externalSystem.model.DataNode;
import com.intellij.openapi.externalSystem.model.ExternalProjectInfo;
import com.intellij.openapi.externalSystem.model.Key;
import com.intellij.openapi.externalSystem.model.ProjectKeys;
import com.intellij.openapi.externalSystem.model.project.Identifiable;
import com.intellij.openapi.externalSystem.model.project.ModuleData;
import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
import com.intellij.openapi.externalSystem.model.project.*;
import com.intellij.openapi.externalSystem.service.project.ProjectDataManager;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
@@ -48,6 +45,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
@@ -286,8 +284,8 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper {
}
private Couple<CheckedTreeNode> createRoot() {
final Map<DataNode, DataNodeCheckedTreeNode> treeNodeMap = ContainerUtil.newIdentityTroveMap();
final Map<String, DataNode> ideGroupingMap = new TreeMap<>(); // need order for assigning parents
final Map<DataNode<?>, DataNodeCheckedTreeNode> treeNodeMap = new IdentityHashMap<>();
final Map<String, DataNode<?>> ideGroupingMap = new TreeMap<>(); // need order for assigning parents
final DataNodeCheckedTreeNode[] preselectedNode = {null};
final DataNodeCheckedTreeNode[] rootModuleNode = {null};
@@ -355,7 +353,7 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper {
}
});
for (Map.Entry<String, DataNode> groupingEntry : ideGroupingMap.entrySet()) {
for (Map.Entry<String, DataNode<?>> groupingEntry : ideGroupingMap.entrySet()) {
DataNode node = groupingEntry.getValue();
if (!(node.getData() instanceof ModuleData)) continue;
ModuleData moduleData = (ModuleData)node.getData();
@@ -521,9 +519,9 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper {
if (!checked && parent instanceof DataNodeCheckedTreeNode) {
if (myDataNode.getKey().equals(ProjectKeys.MODULE) &&
((DataNodeCheckedTreeNode)parent).myDataNode.getKey().equals(ProjectKeys.PROJECT)) {
final DataNode projectDataNode = ((DataNodeCheckedTreeNode)parent).myDataNode;
final ProjectData projectData = (ProjectData)projectDataNode.getData();
final ModuleData moduleData = (ModuleData)myDataNode.getData();
DataNode<?> projectDataNode = ((DataNodeCheckedTreeNode)parent).myDataNode;
ExternalConfigPathAware projectData = (ProjectData)projectDataNode.getData();
ExternalConfigPathAware moduleData = (ModuleData)myDataNode.getData();
if (moduleData.getLinkedExternalProjectPath().equals(projectData.getLinkedExternalProjectPath())) {
if (ExternalSystemApiUtil.findAll(projectDataNode, ProjectKeys.MODULE).size() == 1) {
((DataNodeCheckedTreeNode)parent).setChecked(false);
@@ -691,9 +689,11 @@ public final class ExternalProjectDataSelectorDialog extends DialogWrapper {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final DefaultTreeModel treeModel = (DefaultTreeModel)myTree.getModel();
final Object root = treeModel.getRoot();
if (!(root instanceof CheckedTreeNode)) return;
TreeModel treeModel = (DefaultTreeModel)myTree.getModel();
Object root = treeModel.getRoot();
if (!(root instanceof CheckedTreeNode)) {
return;
}
if (!myShowSelectedRowsOnly) {
myTree.setNodeState((CheckedTreeNode)root, true);
@@ -13,7 +13,8 @@ import com.intellij.util.ProcessingContext;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.JBIterable;
import com.intellij.util.containers.MultiMap;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -22,7 +23,7 @@ import java.util.*;
/**
* @author peter
*/
public class StatisticsWeigher extends CompletionWeigher {
public final class StatisticsWeigher extends CompletionWeigher {
private static final Logger LOG = Logger.getInstance(LookupStatisticsWeigher.class);
private static final Key<StatisticsInfo> BASE_STATISTICS_INFO = Key.create("Base statistics info");
@@ -34,8 +35,8 @@ public class StatisticsWeigher extends CompletionWeigher {
public static class LookupStatisticsWeigher extends Classifier<LookupElement> {
private final CompletionLocation myLocation;
private final Map<LookupElement, StatisticsComparable> myWeights = new IdentityHashMap<>();
private final Set<String> myStringsWithWeights = new THashSet<>();
private final Set<LookupElement> myNoStats = ContainerUtil.newIdentityTroveSet();
private final Set<String> myStringsWithWeights = new ObjectOpenHashSet<>();
private final Set<LookupElement> myNoStats = new ReferenceOpenHashSet<>();
public LookupStatisticsWeigher(CompletionLocation location, Classifier<LookupElement> next) {
super(next, "stats");
@@ -67,7 +68,7 @@ public class StatisticsWeigher extends CompletionWeigher {
}
private static Iterable<LookupElement> withoutInitial(Iterable<? extends LookupElement> allItems, List<? extends LookupElement> initial) {
Set<LookupElement> initialSet = ContainerUtil.newIdentityTroveSet(initial);
Set<LookupElement> initialSet = new ReferenceOpenHashSet<>(initial);
return JBIterable.<LookupElement>from(allItems).filter(element -> !initialSet.contains(element));
}
@@ -18,19 +18,19 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.indexing.DumbModeAccessType;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.indexing.FileBasedIndexImpl;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
public class IdeaIndexBasedFindInProjectSearchEngine implements FindInProjectSearchEngine {
public final class IdeaIndexBasedFindInProjectSearchEngine implements FindInProjectSearchEngine {
@Override
public @Nullable FindInProjectSearcher createSearcher(@NotNull FindModel findModel, @NotNull Project project) {
public @NotNull FindInProjectSearcher createSearcher(@NotNull FindModel findModel, @NotNull Project project) {
return new MyFindInProjectSearcher(project, findModel);
}
private static class MyFindInProjectSearcher implements FindInProjectSearcher {
private static final class MyFindInProjectSearcher implements FindInProjectSearcher {
private @NotNull final ProjectFileIndex myFileIndex;
private @NotNull final FileBasedIndexImpl myFileBasedIndex;
private @NotNull final Project myProject;
@@ -67,17 +67,17 @@ public class IdeaIndexBasedFindInProjectSearchEngine implements FindInProjectSea
final GlobalSearchScope scope = GlobalSearchScopeUtil.toGlobalSearchScope(FindInProjectUtil.getScopeFromModel(myProject, myFindModel),
myProject);
final Set<Integer> keys = new THashSet<>();
IntSet keys = new IntOpenHashSet();
TrigramBuilder.processTrigrams(stringToFind, new TrigramBuilder.TrigramProcessor() {
@Override
public boolean execute(int value) {
public boolean test(int value) {
keys.add(value);
return true;
}
});
if (!keys.isEmpty()) {
final List<VirtualFile> hits = new ArrayList<>();
List<VirtualFile> hits = new ArrayList<>();
FileBasedIndex.getInstance().ignoreDumbMode(() -> {
FileBasedIndex.getInstance().getFilesWithKey(TrigramIndex.INDEX_ID, keys, Processors.cancelableCollectProcessor(hits), scope);
}, DumbModeAccessType.RAW_INDEX_DATA_ACCEPTABLE);
@@ -85,8 +85,7 @@ public class IdeaIndexBasedFindInProjectSearchEngine implements FindInProjectSea
return Collections.unmodifiableCollection(hits);
}
final Set<VirtualFile> resultFiles = new THashSet<>();
Set<VirtualFile> resultFiles = new HashSet<>();
PsiSearchHelper helper = PsiSearchHelper.getInstance(myProject);
helper.processCandidateFilesForText(scope, UsageSearchContext.ANY, myFindModel.isCaseSensitive(), stringToFind, file -> {
ContainerUtil.addIfNotNull(resultFiles, file);
@@ -129,7 +128,7 @@ public class IdeaIndexBasedFindInProjectSearchEngine implements FindInProjectSea
private static boolean hasTrigrams(@NotNull String text) {
return !TrigramBuilder.processTrigrams(text, new TrigramBuilder.TrigramProcessor() {
@Override
public boolean execute(int value) {
public boolean test(int value) {
return false;
}
});
@@ -1,22 +1,4 @@
/*
* Copyright 2000-2014 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.
*/
/*
* @author max
*/
// 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.find.ngrams;
import com.intellij.openapi.fileTypes.FileType;
@@ -28,18 +10,16 @@ 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 it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.*;
public class TrigramIndex extends ScalarIndexExtension<Integer> implements CustomInputsIndexFileBasedIndexExtension<Integer>,
public final class TrigramIndex extends ScalarIndexExtension<Integer> implements CustomInputsIndexFileBasedIndexExtension<Integer>,
DocumentChangeDependentIndex {
/**
* @deprecated not used anymore, always enabled
@@ -70,7 +50,6 @@ public class TrigramIndex extends ScalarIndexExtension<Integer> implements Custo
public Map<Integer, Void> map(@NotNull FileContent inputData) {
MyTrigramProcessor trigramProcessor = new MyTrigramProcessor();
TrigramBuilder.processTrigrams(inputData.getContentAsText(), trigramProcessor);
return trigramProcessor.map;
}
};
@@ -137,9 +116,9 @@ public class TrigramIndex extends ScalarIndexExtension<Integer> implements Custo
@Override
public Collection<Integer> read(@NotNull DataInput in) throws IOException {
int size = DataInputOutputUtil.readINT(in);
ArrayList<Integer> result = new ArrayList<>(size);
List<Integer> result = new ArrayList<>(size);
int prev = 0;
while(size -- > 0) {
while (size-- > 0) {
int l = (int)(DataInputOutputUtil.readLONG(in) + prev);
result.add(l);
prev = l;
@@ -149,16 +128,17 @@ public class TrigramIndex extends ScalarIndexExtension<Integer> implements Custo
};
}
private static class MyTrigramProcessor extends TrigramBuilder.TrigramProcessor {
Map<Integer, Void> map;
private static final class MyTrigramProcessor extends TrigramBuilder.TrigramProcessor {
Int2ObjectMap<Void> map;
@Override
public boolean consumeTrigramsCount(int count) {
map = new THashMap<>(count);
map = new Int2ObjectOpenHashMap<>(count);
return true;
}
@Override
public boolean execute(int value) {
public boolean test(int value) {
map.put(value, null);
return true;
}
@@ -1,30 +1,12 @@
/*
* 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.openapi.options;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashMap;
import gnu.trove.TObjectObjectProcedure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.function.BiConsumer;
public class CompoundScheme<E extends SchemeElement> implements ExternalizableScheme {
@@ -39,22 +21,20 @@ public class CompoundScheme<E extends SchemeElement> implements ExternalizableSc
myElements.add(t);
}
@NotNull
public final List<E> getElements() {
public final @NotNull List<E> getElements() {
if (myElements.isEmpty()) {
return Collections.emptyList();
}
return Collections.unmodifiableList(new ArrayList<>(myElements));
}
@NotNull
@Override
public String getName() {
public @NotNull String getName() {
return myName;
}
@Override
public final void setName(@NotNull final String name) {
public final void setName(final @NotNull String name) {
myName = name;
for (E template : myElements) {
template.setGroupName(name);
@@ -69,8 +49,7 @@ public class CompoundScheme<E extends SchemeElement> implements ExternalizableSc
return myElements.isEmpty();
}
@NotNull
private CompoundScheme<E> createNewInstance(String name) {
private @NotNull CompoundScheme<E> createNewInstance(String name) {
try {
Constructor<? extends CompoundScheme> constructor = getClass().getConstructor(String.class);
try {
@@ -107,30 +86,21 @@ public class CompoundScheme<E extends SchemeElement> implements ExternalizableSc
}
public static final class MutatorHelper<T extends CompoundScheme<E>, E extends SchemeElement> {
private final THashMap<T, T> copiedToOriginal = ContainerUtil.newIdentityTroveMap();
private final Map<T, T> copiedToOriginal = new IdentityHashMap<>();
@NotNull
public T copy(@NotNull T scheme) {
public @NotNull T copy(@NotNull T scheme) {
//noinspection unchecked
T copied = (T)scheme.copy();
copiedToOriginal.put(copied, scheme);
return copied;
}
@NotNull
public List<T> apply(@NotNull final List<? extends T> copiedSchemes) {
public @NotNull List<T> apply(final @NotNull List<? extends T> copiedSchemes) {
return apply(copiedSchemes, null);
}
@NotNull
public List<T> apply(@NotNull final List<? extends T> copiedSchemes, @Nullable BiConsumer<? super T, ? super T> changedConsumer) {
copiedToOriginal.retainEntries(new TObjectObjectProcedure<T, T>() {
@Override
public boolean execute(T copied, T original) {
return ContainerUtil.containsIdentity(copiedSchemes, copied);
}
});
public @NotNull List<T> apply(@NotNull List<? extends T> copiedSchemes, @Nullable BiConsumer<? super T, ? super T> changedConsumer) {
copiedToOriginal.values().removeIf(it -> !ContainerUtil.containsIdentity(copiedSchemes, it));
List<T> originals = new ArrayList<>(copiedSchemes.size());
for (T copied : copiedSchemes) {
T original = copiedToOriginal.remove(copied);
@@ -3,8 +3,10 @@ package com.intellij.slicer;
import com.intellij.analysis.AnalysisUIOptions;
import com.intellij.ide.impl.ContentManagerWatcher;
import com.intellij.lang.LangBundle;
import com.intellij.openapi.components.*;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.ToolWindow;
@@ -20,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.regex.Pattern;
@State(name = "SliceManager", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
public class SliceManager implements PersistentStateComponent<SliceManager.StoredSettingsBean> {
public final class SliceManager implements PersistentStateComponent<SliceManager.StoredSettingsBean> {
private final Project myProject;
private ContentManager myBackContentManager;
private ContentManager myForthContentManager;
@@ -34,7 +36,7 @@ public class SliceManager implements PersistentStateComponent<SliceManager.Store
}
public static SliceManager getInstance(@NotNull Project project) {
return ServiceManager.getService(project, SliceManager.class);
return project.getService(SliceManager.class);
}
public SliceManager(@NotNull Project project) {
@@ -70,8 +72,8 @@ public class SliceManager implements PersistentStateComponent<SliceManager.Store
}
/**
* Opens the dataflow analysis toolwindow starting from the given element
*
* Opens the dataflow analysis toolwindow starting from the given element
*
* @param element root element
* @param params analysis parameters
*/
@@ -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.keymap.impl.ui;
import com.intellij.ide.IdeBundle;
@@ -21,7 +21,7 @@ import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.util.List;
class QuickListsUi implements ConfigurableUi<List<QuickList>> {
final class QuickListsUi implements ConfigurableUi<List<QuickList>> {
public static final String EMPTY = "empty";
public static final String PANEL = "panel";
private final KeymapListener keymapListener;
@@ -8,10 +8,10 @@ import com.intellij.ui.layout.*
import com.intellij.ui.layout.migLayout.patched.*
import com.intellij.ui.scale.JBUIScale
import com.intellij.util.SmartList
import com.intellij.util.containers.ContainerUtil
import net.miginfocom.layout.*
import java.awt.Component
import java.awt.Container
import java.util.*
import javax.swing.*
internal class MigLayoutBuilder(val spacing: SpacingConfiguration) : LayoutBuilderImpl {
@@ -49,7 +49,7 @@ internal class MigLayoutBuilder(val spacing: SpacingConfiguration) : LayoutBuild
/**
* Map of component to constraints shared among rows (since components are unique)
*/
internal val componentConstraints: MutableMap<Component, CC> = ContainerUtil.newIdentityTroveMap()
internal val componentConstraints: MutableMap<Component, CC> = IdentityHashMap()
override val rootRow = MigLayoutRow(parent = null, builder = this, indent = 0)
private val buttonGroupStack: MutableList<ButtonGroup> = mutableListOf()
@@ -1,32 +1,18 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// 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;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.PairProcessor;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.OrderedSet;
import gnu.trove.THashMap;
import gnu.trove.TObjectObjectProcedure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiPredicate;
public abstract class CollectionModelEditor<T, E extends CollectionItemEditor<T>> implements ElementProducer<T> {
protected static final Logger LOG = Logger.getInstance(CollectionModelEditor.class);
@@ -74,14 +60,9 @@ public abstract class CollectionModelEditor<T, E extends CollectionItemEditor<T>
return false;
}
public void processModifiedItems(@NotNull final PairProcessor<? super T, ? super T> processor) {
public void processModifiedItems(@NotNull BiPredicate<T, T> processor) {
// don't want to expose TObjectObjectProcedure - avoid implementation details
helper.process(new TObjectObjectProcedure<T, T>() {
@Override
public boolean execute(T newItem, T oldItem) {
return processor.process(newItem, oldItem);
}
});
helper.process(processor);
}
@NotNull
@@ -93,11 +74,11 @@ public abstract class CollectionModelEditor<T, E extends CollectionItemEditor<T>
return true;
}
protected class ModelHelper {
protected final class ModelHelper {
final OrderedSet<T> originalItems = new OrderedSet<>(ContainerUtil.identityStrategy());
private final THashMap<T, T> modifiedToOriginal = ContainerUtil.newIdentityTroveMap();
private final THashMap<T, T> originalToModified = ContainerUtil.newIdentityTroveMap();
private final Map<T, T> modifiedToOriginal = new IdentityHashMap<>();
private final Map<T, T> originalToModified = new IdentityHashMap<>();
public void reset(@Nullable List<? extends T> newOriginalItems) {
if (newOriginalItems != null) {
@@ -140,8 +121,14 @@ public abstract class CollectionModelEditor<T, E extends CollectionItemEditor<T>
return !modifiedToOriginal.isEmpty();
}
public void process(@NotNull TObjectObjectProcedure<T, T> procedure) {
modifiedToOriginal.forEachEntry(procedure);
public void process(@NotNull BiPredicate<T, T> procedure) {
for (Map.Entry<T, T> entry : modifiedToOriginal.entrySet()) {
T key = entry.getKey();
T value = entry.getValue();
if (!procedure.test(key, value)) {
break;
}
}
}
}
@@ -1,25 +1,10 @@
/*
* 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.util.ui;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.CollectionListModel;
import com.intellij.ui.MutableCollectionComboBoxModel;
import gnu.trove.TObjectObjectProcedure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -80,13 +65,10 @@ public abstract class ListModelEditorBase<T> extends CollectionModelEditor<T, Li
return items;
}
helper.process(new TObjectObjectProcedure<T, T>() {
@Override
public boolean execute(T newItem, T oldItem) {
itemEditor.applyModifiedProperties(newItem, oldItem);
silentlyReplaceItem(newItem, oldItem, -1);
return true;
}
helper.process((newItem, oldItem) -> {
itemEditor.applyModifiedProperties(newItem, oldItem);
silentlyReplaceItem(newItem, oldItem, -1);
return true;
});
helper.reset(items);
@@ -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.table;
import com.intellij.ide.IdeBundle;
@@ -255,7 +255,7 @@ public class TableModelEditor<T> extends CollectionModelEditor<T, CollectionItem
public void selectItem(@NotNull final T item) {
table.clearSelection();
final Ref<T> ref;
Ref<T> ref;
if (helper.hasModifiedItems()) {
ref = Ref.create();
helper.process((modified, original) -> {
@@ -168,4 +168,5 @@ com.jetbrains.php.composer.resolve 1.0
"ev3dev C/C++" "0.7.2 (51324)"
javaFMI 1.0.0
fistache.framework.id 1.1.3
dev.blachut.svelte.lang 0.12.1
dev.blachut.svelte.lang 0.12.1
com.intellij.ideolog 201.0.22.0 201.0.21.0 201.0.20.0 201.0.19.0
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2012 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.util.text;
import com.intellij.openapi.util.Ref;
@@ -26,7 +12,7 @@ public class TrigramBuilderTest extends TestCase {
TrigramBuilder.processTrigrams("String$CharData", new TrigramBuilder.TrigramProcessor() {
@Override
public boolean execute(int value) {
public boolean test(int value) {
list.add(value);
return true;
}
@@ -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.util.io;
import com.intellij.idea.HardwareAgentRequired;
@@ -20,11 +6,12 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.SkipSlowTestLocally;
import com.intellij.util.MathUtil;
import com.intellij.util.containers.CollectionFactory;
import com.intellij.util.containers.IntObjectCache;
import com.intellij.util.io.storage.AbstractStorage;
import gnu.trove.THashSet;
import gnu.trove.TIntIntHashMap;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import org.jetbrains.annotations.NotNull;
import java.io.*;
@@ -177,7 +164,7 @@ public class PersistentMapPerformanceTest extends PersistentMapTestBase {
FileUtil.createParentDirs(file);
int size = 10000000;
TIntIntHashMap checkMap = new TIntIntHashMap(size);
Int2IntOpenHashMap checkMap = new Int2IntOpenHashMap(size);
Random r = new Random(1);
while (size != checkMap.size()) {
if (checkMap.size() == 0) {
@@ -202,18 +189,17 @@ public class PersistentMapPerformanceTest extends PersistentMapTestBase {
};
final PersistentHashMap<Integer, Integer> mapFinal = map;
boolean result = checkMap.forEachEntry((a, b) -> {
for (ObjectIterator<Int2IntMap.Entry> iterator = checkMap.int2IntEntrySet().fastIterator(); iterator.hasNext(); ) {
Int2IntMap.Entry entry = iterator.next();
try {
mapFinal.put(a, b);
mapFinal.put(entry.getIntKey(), entry.getIntValue());
}
catch (IOException e) {
e.printStackTrace();
fail();
return false;
break;
}
return true;
});
assertTrue(result);
}
map.close();
LOG.debug("Done:" + (System.currentTimeMillis() - started));
started = System.currentTimeMillis();
@@ -224,18 +210,16 @@ public class PersistentMapPerformanceTest extends PersistentMapTestBase {
}
};
final PersistentHashMap<Integer, Integer> mapFinal2 = map;
result = checkMap.forEachEntry((a, b) -> {
for (ObjectIterator<Int2IntMap.Entry> iterator = checkMap.int2IntEntrySet().fastIterator(); iterator.hasNext(); ) {
try {
assertEquals(b, (int)mapFinal2.get(a));
Int2IntMap.Entry entry = iterator.next();
assertEquals(entry.getIntValue(), (int)mapFinal2.get(entry.getIntKey()));
}
catch (IOException e) {
e.printStackTrace();
fail();
return false;
}
return true;
});
assertTrue(result);
}
LOG.debug("Done 2:" + (System.currentTimeMillis() - started));
}
@@ -256,7 +240,7 @@ public class PersistentMapPerformanceTest extends PersistentMapTestBase {
@Override
public Collection<String> read(@NotNull DataInput in) throws IOException {
final Set<String> result = new THashSet<>(FileUtil.PATH_HASHING_STRATEGY);
final Set<String> result = CollectionFactory.createFilePathSet();
final DataInputStream stream = (DataInputStream)in;
while (stream.available() > 0) {
final String str = IOUtil.readString(stream);
@@ -620,7 +620,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Pers
}
}
private final Map<RootProvider, Set<OrderEntry>> myRegisteredRootProviders = ContainerUtil.newIdentityTroveMap();
private final Map<RootProvider, Set<OrderEntry>> myRegisteredRootProviders = new IdentityHashMap<>();
void addJdkTableListener(@NotNull ProjectJdkTable.Listener jdkTableListener, @NotNull Disposable parent) {
myJdkTableMultiListener.addListener(jdkTableListener);
@@ -5,7 +5,6 @@ import com.intellij.diagnostic.PluginException
import com.intellij.openapi.components.ComponentManager
import com.intellij.openapi.extensions.PluginId
import com.intellij.util.messages.MessageBus
import gnu.trove.THashSet
import java.io.File
import java.lang.Deprecated
import java.lang.reflect.Constructor
@@ -128,7 +127,7 @@ private fun getGreediestSatisfiableConstructor(aClass: Class<*>,
}
if (unsatisfiableDependencyTypes == null) {
unsatisfiableDependencyTypes = THashSet()
unsatisfiableDependencyTypes = HashSet()
}
unsatisfiableDependencyTypes.add(parameterTypes)
unsatisfiedDependencyType = expectedType
@@ -149,7 +148,7 @@ private fun getGreediestSatisfiableConstructor(aClass: Class<*>,
else if (!failedDependency && lastSatisfiableConstructorSize == parameterTypes.size) {
// satisfied and same size as previous one?
if (conflicts == null) {
conflicts = THashSet()
conflicts = HashSet()
}
conflicts.add(constructor)
greediestConstructor?.let {
@@ -14,6 +14,6 @@
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
<orderEntry type="module" module-name="intellij.platform.debugger" />
<orderEntry type="module" module-name="intellij.platform.diff.impl" />
<orderEntry type="library" name="Trove4j" level="project" />
<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.execution.testframework.autotest;
import com.intellij.execution.RunnerAndConfigurationSettings;
@@ -51,8 +51,7 @@ public abstract class AbstractAutoTestManager implements PersistentStateComponen
myWatcher = createWatcher(project);
}
@Nullable
private static ExecutionEnvironment getCurrentEnvironment(@NotNull Content content) {
private static @Nullable ExecutionEnvironment getCurrentEnvironment(@NotNull Content content) {
JComponent component = content.getComponent();
if (component == null) {
return null;
@@ -101,8 +100,7 @@ public abstract class AbstractAutoTestManager implements PersistentStateComponen
return configurations;
}
@NotNull
protected abstract AutoTestWatcher createWatcher(Project project);
protected abstract @NotNull AutoTestWatcher createWatcher(@NotNull Project project);
public void setAutoTestEnabled(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment environment, boolean enabled) {
Content content = descriptor.getAttachedContent();
@@ -173,10 +171,10 @@ public abstract class AbstractAutoTestManager implements PersistentStateComponen
}
}
private void scheduleRestartOnTermination(@NotNull final RunContentDescriptor descriptor,
@NotNull final ProcessHandler processHandler,
private void scheduleRestartOnTermination(final @NotNull RunContentDescriptor descriptor,
final @NotNull ProcessHandler processHandler,
final int modificationStamp,
@NotNull final AutoTestWatcher watcher) {
final @NotNull AutoTestWatcher watcher) {
ProcessListener restarterListener = ON_TERMINATION_RESTARTER_KEY.get(processHandler);
if (restarterListener != null) {
clearRestarterListener(processHandler);
@@ -210,9 +208,8 @@ public abstract class AbstractAutoTestManager implements PersistentStateComponen
PropertiesComponent.getInstance(myProject).setValue(AUTO_TEST_MANAGER_DELAY, myDelayMillis, AUTO_TEST_MANAGER_DELAY_DEFAULT);
}
@Nullable
@Override
public State getState() {
public @Nullable State getState() {
State state = new State();
for (RunProfile profile : myEnabledRunProfiles) {
saveConfigurationState(state, profile);
@@ -1,41 +1,21 @@
/*
* 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.autotest;
import com.intellij.ide.scratch.ScratchUtil;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
@State(
name = "AutoTestManager",
storages = {@Storage(StoragePathMacros.WORKSPACE_FILE)}
)
public class AutoTestManager extends AbstractAutoTestManager {
import java.util.function.Predicate;
@NotNull
public static AutoTestManager getInstance(Project project) {
return ServiceManager.getService(project, AutoTestManager.class);
@State(name = "AutoTestManager", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
public final class AutoTestManager extends AbstractAutoTestManager {
public static @NotNull AutoTestManager getInstance(Project project) {
return project.getService(AutoTestManager.class);
}
public AutoTestManager(@NotNull Project project) {
@@ -43,9 +23,8 @@ public class AutoTestManager extends AbstractAutoTestManager {
}
@Override
@NotNull
protected AutoTestWatcher createWatcher(Project project) {
return new DelayedDocumentWatcher(project, myDelayMillis, this::restartAllAutoTests, file -> {
protected @NotNull AutoTestWatcher createWatcher(@NotNull Project project) {
return new DelayedDocumentWatcher(project, myDelayMillis, this::restartAllAutoTests, (Predicate<? super VirtualFile>)file -> {
if (ScratchUtil.isScratch(file)) {
return false;
}
@@ -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.testframework.autotest;
import com.intellij.AppTopics;
@@ -23,7 +23,7 @@ import com.intellij.util.Consumer;
import com.intellij.util.PsiErrorElementUtil;
import com.intellij.util.SingleAlarm;
import com.intellij.util.messages.MessageBusConnection;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,27 +31,40 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Collection;
import java.util.Set;
import java.util.function.IntConsumer;
import java.util.function.Predicate;
public class DelayedDocumentWatcher implements AutoTestWatcher {
public final class DelayedDocumentWatcher implements AutoTestWatcher {
// All instance fields should be accessed in EDT
private final Project myProject;
private final int myDelayMillis;
private final Consumer<? super Integer> myModificationStampConsumer;
private final Condition<? super VirtualFile> myChangedFileFilter;
private final IntConsumer myModificationStampConsumer;
private final Predicate<? super VirtualFile> myChangedFileFilter;
private final MyDocumentAdapter myListener;
private Disposable myDisposable;
private SingleAlarm myAlarm;
private final Set<VirtualFile> myChangedFiles = new THashSet<>();
// reduce memory usage
private final Set<VirtualFile> myChangedFiles = new ObjectOpenHashSet<>();
private boolean myDocumentSavingInProgress = false;
private MessageBusConnection myConnection;
private int myModificationStamp = 0;
/**
* @deprecated Use {@link #DelayedDocumentWatcher(Project, int, IntConsumer, Condition)}
*/
@Deprecated
public DelayedDocumentWatcher(@NotNull Project project,
int delayMillis,
@NotNull Consumer<? super Integer> modificationStampConsumer,
@Nullable Condition<? super VirtualFile> changedFileFilter) {
this(project, delayMillis, (IntConsumer)it -> modificationStampConsumer.consume(it), it -> changedFileFilter.value(it));
}
public DelayedDocumentWatcher(@NotNull Project project,
int delayMillis,
@NotNull IntConsumer modificationStampConsumer,
@Nullable Predicate<? super VirtualFile> changedFileFilter) {
myProject = project;
myDelayMillis = delayMillis;
myModificationStampConsumer = modificationStampConsumer;
@@ -127,7 +140,7 @@ public class DelayedDocumentWatcher implements AutoTestWatcher {
if (ProjectUtil.isProjectOrWorkspaceFile(file)) {
return;
}
if (myChangedFileFilter != null && !myChangedFileFilter.value(file)) {
if (myChangedFileFilter != null && !myChangedFileFilter.test(file)) {
return;
}
@@ -163,7 +176,7 @@ public class DelayedDocumentWatcher implements AutoTestWatcher {
return;
}
myChangedFiles.clear();
myModificationStampConsumer.consume(myModificationStamp);
myModificationStampConsumer.accept(myModificationStamp);
});
}
}
@@ -9,6 +9,7 @@ import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -25,7 +26,8 @@ final class ObjectTree {
// identity used here to prevent problems with hashCode/equals overridden by not very bright minds
private final Set<Disposable> myRootObjects = new ReferenceOpenHashSet<>(); // guarded by treeLock
private final Map<Disposable, ObjectNode> myObject2NodeMap = ContainerUtil.newIdentityTroveMap(); // guarded by treeLock
// guarded by treeLock
private final Map<Disposable, ObjectNode> myObject2NodeMap = new Reference2ObjectOpenHashMap<>();
// Disposable to trace or boolean marker (if trace unavailable)
private final Map<Disposable, Object> myDisposedObjects = ContainerUtil.createWeakMap(100, 0.5f, ContainerUtil.identityStrategy()); // guarded by treeLock
@@ -5,7 +5,6 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ExceptionUtil;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -134,7 +133,7 @@ public final class RecursionManager {
@NotNull
@Override
public List<Key> currentStack() {
ArrayList<Key> result = new ArrayList<>();
List<Key> result = new ArrayList<>();
for (MyKey pair : ourStack.get().progressMap.keySet()) {
if (pair.guardId.equals(id)) {
//noinspection unchecked
@@ -225,12 +224,12 @@ public final class RecursionManager {
}
}
private static class CalculationStack {
private static final class CalculationStack {
private int reentrancyCount;
private int depth;
private int firstLoopStart = Integer.MAX_VALUE; // outermost recursion-prevented frame depth; memoized values are dropped on its change.
private final LinkedHashMap<MyKey, StackFrame> progressMap = new LinkedHashMap<>();
private final Map<MyKey, Throwable> preventions = ContainerUtil.newIdentityTroveMap();
private final Map<MyKey, Throwable> preventions = new IdentityHashMap<>();
private final Map<MyKey, MemoizedValue> intermediateCache = ContainerUtil.createSoftKeySoftValueMap();
private int enters;
private int exits;
@@ -396,7 +395,7 @@ public final class RecursionManager {
void addPrevention(int stamp, MyKey prevented) {
reentrancyStamp = stamp;
if (preventionsInside == null) {
preventionsInside = new THashSet<>();
preventionsInside = new HashSet<>();
}
preventionsInside.add(prevented);
}
@@ -1,33 +1,16 @@
/*
* 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.openapi.util.io;
import com.intellij.openapi.util.text.StringUtil;
import gnu.trove.THashMap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
/**
* @author yole
*/
public class UniqueNameBuilder<T> {
public final class UniqueNameBuilder<T> {
private static final String VFS_SEPARATOR = "/";
private final Map<T, String> myPaths = new THashMap<>();
private final Map<T, String> myPaths = new HashMap<>();
private final String mySeparator;
private final int myMaxLength;
private final String myRoot;
@@ -46,16 +29,16 @@ public class UniqueNameBuilder<T> {
return myPaths.size();
}
private static class Node {
private static final class Node {
final String myText;
final THashMap<String, Node> myChildren;
final HashMap<String, Node> myChildren;
final Node myParentNode;
int myNestedChildrenCount;
Node(String text, Node parentNode) {
myText = text;
myParentNode = parentNode;
myChildren = new THashMap<>(1);
myChildren = new HashMap<>();
}
Node findOrAddChild(String word) {
@@ -111,7 +94,7 @@ public class UniqueNameBuilder<T> {
firstNodeBeforeNodeWithBranches = current;
}
}
if (current.myChildren.size() != 1 && firstNodeWithBranches == null) {
firstNodeWithBranches = current;
}
@@ -146,7 +129,7 @@ public class UniqueNameBuilder<T> {
return mySeparator;
}
private static class PathComponentsIterator implements Iterator<String> {
private static final class PathComponentsIterator implements Iterator<String> {
private final String myPath;
private int myLastPos;
private int mySeparatorPos;
@@ -166,12 +149,13 @@ public class UniqueNameBuilder<T> {
public String next() {
if (myLastPos == 0) throw new NoSuchElementException();
String pathComponent;
if (mySeparatorPos != -1) {
pathComponent = myPath.substring(mySeparatorPos, myLastPos);
myLastPos = mySeparatorPos;
mySeparatorPos = myPath.lastIndexOf(VFS_SEPARATOR, myLastPos - 1);
} else {
}
else {
pathComponent = myPath.substring(0, myLastPos);
if (!pathComponent.startsWith(VFS_SEPARATOR)) pathComponent = VFS_SEPARATOR + pathComponent;
myLastPos = 0;
@@ -2,7 +2,6 @@
package com.intellij.openapi.util.registry;
import com.intellij.diagnostic.LoadingState;
import gnu.trove.THashMap;
import org.jdom.Element;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
@@ -30,18 +29,16 @@ public final class Registry {
private final Map<String, String> myUserProperties = new LinkedHashMap<>();
private final ConcurrentMap<String, RegistryValue> myValues = new ConcurrentHashMap<>();
private final THashMap<String, RegistryKeyDescriptor> myContributedKeys = new THashMap<>();
private final Map<String, RegistryKeyDescriptor> myContributedKeys = new HashMap<>();
private static final Registry ourInstance = new Registry();
private volatile boolean myLoaded = false;
@NotNull
public static RegistryValue get(@NonNls @NotNull String key) {
public static @NotNull RegistryValue get(@NonNls @NotNull String key) {
return getInstance().doGet(key);
}
@NotNull
private RegistryValue doGet(@NonNls @NotNull String key) {
private @NotNull RegistryValue doGet(@NonNls @NotNull String key) {
RegistryValue value = myValues.get(key);
if (value != null) {
return value;
@@ -92,8 +89,7 @@ public final class Registry {
return get(key).asDouble();
}
@NotNull
public static String stringValue(@NonNls @NotNull String key) throws MissingResourceException {
public static @NotNull String stringValue(@NonNls @NotNull String key) throws MissingResourceException {
return get(key).asString();
}
@@ -101,8 +97,7 @@ public final class Registry {
return get(key).asColor(defaultValue);
}
@NotNull
static ResourceBundle getBundle() {
static @NotNull ResourceBundle getBundle() {
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(REGISTRY_BUNDLE);
@@ -128,14 +123,12 @@ public final class Registry {
return null;
}
@NotNull
public static Registry getInstance() {
public static @NotNull Registry getInstance() {
LoadingState.COMPONENTS_REGISTERED.checkOccurred();
return ourInstance;
}
@NotNull
public Element getState() {
public @NotNull Element getState() {
final Element state = new Element("registry");
for (String eachKey : myUserProperties.keySet()) {
final Element entry = new Element("entry");
@@ -172,14 +165,12 @@ public final class Registry {
return myLoaded;
}
@NotNull
@ApiStatus.Internal
public Map<String, String> getUserProperties() {
public @NotNull Map<String, String> getUserProperties() {
return myUserProperties;
}
@NotNull
public static List<RegistryValue> getAll() {
public static @NotNull List<RegistryValue> getAll() {
final ResourceBundle bundle = getBundle();
final Enumeration<String> keys = bundle.getKeys();
@@ -231,10 +222,8 @@ public final class Registry {
public static synchronized void addKeys(@NotNull List<RegistryKeyDescriptor> descriptors) {
// getInstance must be not used here - phase COMPONENT_REGISTERED is not yet completed
THashMap<String, RegistryKeyDescriptor> map = ourInstance.myContributedKeys;
map.ensureCapacity(descriptors.size());
for (RegistryKeyDescriptor descriptor : descriptors) {
map.put(descriptor.getName(), descriptor);
ourInstance.myContributedKeys.put(descriptor.getName(), descriptor);
}
}
@@ -1,12 +1,10 @@
// 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
*/
package com.intellij.openapi.util.text;
import com.intellij.util.text.CharArrayUtil;
import gnu.trove.TIntProcedure;
import org.jetbrains.annotations.NotNull;
import java.util.function.IntPredicate;
public final class TrigramBuilder {
private TrigramBuilder() {
@@ -55,12 +53,14 @@ public final class TrigramBuilder {
return consumer.consumeTrigramsCount(set.size()) && set.forEach(consumer);
}
public static abstract class TrigramProcessor implements TIntProcedure {
public boolean consumeTrigramsCount(int count) { return true; }
public static abstract class TrigramProcessor implements IntPredicate {
public boolean consumeTrigramsCount(int count) {
return true;
}
}
}
class AddonlyIntSet {
final class AddonlyIntSet {
//private static final int MAGIC = 0x9E3779B9;
private int size;
private int[] data;
@@ -138,11 +138,18 @@ class AddonlyIntSet {
return false;
}
public boolean forEach(TIntProcedure consumer) {
if (hasZeroKey && !consumer.execute(0)) return false;
for(int o:data) {
if (o == 0) continue;
if(!consumer.execute(o)) return false;
public boolean forEach(@NotNull IntPredicate consumer) {
if (hasZeroKey && !consumer.test(0)) {
return false;
}
for (int o : data) {
if (o == 0) {
continue;
}
if (!consumer.test(o)) {
return false;
}
}
return true;
}
@@ -201,7 +201,7 @@ public final class CollectionFactory {
public static @NotNull Set<String> createFilePathSet(@NotNull Collection<String> paths) {
if (SystemInfoRt.isFileSystemCaseSensitive) {
return new ObjectOpenHashSet<>(paths);
return new HashSet<>(paths);
}
else {
return new ObjectOpenCustomHashSet<>(paths, CaseInsensitiveStringHashingStrategy.INSTANCE);
@@ -153,7 +153,6 @@ public class ContainerUtil {
/**
* @deprecated Use {@link IdentityHashMap#IdentityHashMap()}
*/
@SuppressWarnings("unused")
@Deprecated
public static @NotNull <K, V> IdentityHashMap<K, V> newIdentityHashMap() {
return new IdentityHashMap<>();
@@ -302,16 +301,6 @@ public class ContainerUtil {
return new SmartList<>(element);
}
/**
* @deprecated Use {@link SmartList(T)}
*/
@SafeVarargs
@Contract(pure = true)
@Deprecated
public static @NotNull <T> List<T> newSmartList(T @NotNull ... elements) {
return new SmartList<>(elements);
}
/**
* @deprecated Use {@link HashSet#HashSet()}
*/
@@ -394,7 +383,7 @@ public class ContainerUtil {
}
/**
* @deprecated Use {@link THashSet#THashSet()}
* @deprecated Use {@link HashSet#HashSet()}
*/
@Deprecated
@Contract(pure = true)
@@ -403,15 +392,10 @@ public class ContainerUtil {
}
/**
* @deprecated Use {@link THashSet#THashSet(TObjectHashingStrategy)}
* @deprecated Use {@link HashSet}
*/
@Deprecated
@Contract(pure = true)
public static @NotNull <T> THashSet<T> newTroveSet(@NotNull TObjectHashingStrategy<T> strategy) {
return new THashSet<>(strategy);
}
@SafeVarargs
@Deprecated
@Contract(pure = true)
public static @NotNull <T> THashSet<T> newTroveSet(T @NotNull ... elements) {
return new THashSet<>(Arrays.asList(elements));
@@ -427,7 +411,11 @@ public class ContainerUtil {
return new THashSet<>(Arrays.asList(elements), strategy);
}
/**
* @deprecated Use {@link HashSet}.
*/
@Contract(pure = true)
@Deprecated
public static @NotNull <T> THashSet<T> newTroveSet(@NotNull TObjectHashingStrategy<T> strategy, @NotNull Collection<? extends T> elements) {
return new THashSet<>(elements, strategy);
}
@@ -450,15 +438,19 @@ public class ContainerUtil {
return new THashSet<>(identityStrategy());
}
@Contract(pure = true)
public static @NotNull <K> THashSet<K> newIdentityTroveSet(int initialCapacity) {
return new THashSet<>(initialCapacity, identityStrategy());
}
/**
* @deprecated Use {@link it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet}.
*/
@Deprecated
@Contract(pure = true)
public static @NotNull <K> THashSet<K> newIdentityTroveSet(@NotNull Collection<? extends K> collection) {
return new THashSet<>(collection, identityStrategy());
}
/**
* @deprecated Use {@link it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap}
*/
@Deprecated
@Contract(pure = true)
public static @NotNull <K,V> THashMap<K,V> newIdentityTroveMap() {
return new THashMap<>(identityStrategy());
@@ -18,6 +18,7 @@ package com.intellij.util.containers;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Disposer;
import com.intellij.util.ArrayUtilRt;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,7 +34,7 @@ import java.util.function.Predicate;
*
* @param <E> the type of elements held in this list
*/
public class DisposableWrapperList<E> extends AbstractList<E> {
public final class DisposableWrapperList<E> extends AbstractList<E> {
@NotNull private final List<DisposableWrapper> myWrappedList = ContainerUtil.createLockFreeCopyOnWriteList();
public DisposableWrapperList() {
@@ -125,7 +126,7 @@ public class DisposableWrapperList<E> extends AbstractList<E> {
@Override
public boolean removeIf(@NotNull Predicate<? super E> filter) {
Set<DisposableWrapper> removedWrappers = ContainerUtil.newIdentityTroveSet(myWrappedList.size());
Set<DisposableWrapper> removedWrappers = new ReferenceOpenHashSet<>(myWrappedList.size());
boolean result = myWrappedList.removeIf(disposableWrapper -> {
if (filter.test(disposableWrapper.delegate) && (disposableWrapper.makeUnique() || removedWrappers.contains(disposableWrapper))) {
removedWrappers.add(disposableWrapper);
@@ -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.util.containers;
import gnu.trove.THashMap;
@@ -66,7 +52,7 @@ abstract class RefHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V> {
return k1 == k2 || strategy.equals(k1, k2);
}
private class MyMap extends THashMap<Key<K>, V> {
private final class MyMap extends THashMap<Key<K>, V> {
private MyMap(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor, new TObjectHashingStrategy<Key<K>>() {
@Override
@@ -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.util.containers;
import com.intellij.util.DeprecatedMethodException;
@@ -56,7 +42,7 @@ public final class WeakHashMap<K, V> extends RefHashMap<K, V> {
return new WeakKey<>(k, strategy, q);
}
private static class WeakKey<T> extends WeakReference<T> implements Key<T> {
private static final class WeakKey<T> extends WeakReference<T> implements Key<T> {
private final int myHash; // Hashcode of key, stored here since the key may be tossed by the GC
@NotNull private final TObjectHashingStrategy<? super T> myStrategy;
@@ -1,18 +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.openapi.vcs.actions;
import com.intellij.diff.DiffDialogHints;
@@ -20,11 +6,11 @@ import com.intellij.diff.DiffManager;
import com.intellij.diff.chains.DiffRequestChain;
import com.intellij.diff.chains.DiffRequestProducerException;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.DiffNavigationContext;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
@@ -43,7 +29,6 @@ import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain;
import com.intellij.openapi.vcs.changes.ui.ChangesComparator;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
import com.intellij.openapi.ListSelection;
import com.intellij.util.containers.CacheOneStepIterator;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -51,12 +36,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
import static com.intellij.openapi.diagnostic.Logger.getInstance;
class ShowDiffFromAnnotation extends DumbAwareAction implements UpToDateLineNumberListener {
private static final Logger LOG = getInstance(ShowDiffFromAnnotation.class);
@NotNull private final Project myProject;
final class ShowDiffFromAnnotation extends DumbAwareAction implements UpToDateLineNumberListener {
private final @NotNull Project myProject;
private final FileAnnotation myFileAnnotation;
private final RevisionChangesProvider myChangesProvider;
private int currentLine = -1;
@@ -91,19 +72,17 @@ class ShowDiffFromAnnotation extends DumbAwareAction implements UpToDateLineNumb
if (revisionNumber == null) return;
DiffRequestChain requestChain = new ChangeDiffRequestChain.Async() {
@NotNull
@Override
protected ListSelection<ChangeDiffRequestProducer> loadRequestProducers() throws DiffRequestProducerException {
protected @NotNull ListSelection<ChangeDiffRequestProducer> loadRequestProducers() throws DiffRequestProducerException {
return loadRequests(myFileAnnotation, myChangesProvider, actualNumber);
}
};
DiffManager.getInstance().showDiff(myProject, requestChain, DiffDialogHints.FRAME);
}
@NotNull
private static ListSelection<ChangeDiffRequestProducer> loadRequests(@NotNull FileAnnotation fileAnnotation,
@NotNull RevisionChangesProvider changesProvider,
int actualNumber) throws DiffRequestProducerException {
private static @NotNull ListSelection<ChangeDiffRequestProducer> loadRequests(@NotNull FileAnnotation fileAnnotation,
@NotNull RevisionChangesProvider changesProvider,
int actualNumber) throws DiffRequestProducerException {
try {
Pair<? extends CommittedChangeList, FilePath> pair = changesProvider.getChangesIn(actualNumber);
if (pair == null || pair.getFirst() == null || pair.getSecond() == null) {
@@ -113,7 +92,7 @@ class ShowDiffFromAnnotation extends DumbAwareAction implements UpToDateLineNumb
FilePath targetPath = pair.getSecond();
List<Change> changes = ContainerUtil.sorted(pair.getFirst().getChanges(), ChangesComparator.getInstance(true));
Map<Change, Map<Key, Object>> context = new HashMap<>();
Map<Change, Map<Key<?>, Object>> context = new HashMap<>();
int idx = findSelfInList(changes, targetPath);
if (idx != -1) {
DiffNavigationContext navigationContext = createDiffNavigationContext(fileAnnotation, actualNumber);
@@ -155,8 +134,7 @@ class ShowDiffFromAnnotation extends DumbAwareAction implements UpToDateLineNumb
/*
* Locate line in annotated content, using lines that are known to be modified in this revision
*/
@Nullable
private static DiffNavigationContext createDiffNavigationContext(@NotNull FileAnnotation fileAnnotation, int actualLine) {
private static @Nullable DiffNavigationContext createDiffNavigationContext(@NotNull FileAnnotation fileAnnotation, int actualLine) {
String annotatedContent = fileAnnotation.getAnnotatedContent();
if (StringUtil.isEmptyOrSpaces(annotatedContent)) return null;
@@ -172,7 +150,7 @@ class ShowDiffFromAnnotation extends DumbAwareAction implements UpToDateLineNumb
}, contentsLines[correctedLine]);
}
private final static int ourVicinity = 5;
private static final int ourVicinity = 5;
private static int correctActualLineIfTextEmpty(@NotNull FileAnnotation fileAnnotation, String @NotNull [] contentsLines,
final int actualLine) {
@@ -200,11 +178,11 @@ class ShowDiffFromAnnotation extends DumbAwareAction implements UpToDateLineNumb
/**
* Slightly break the contract: can return null from next() while had claimed hasNext()
*/
private static class ContextLineIterator implements Iterator<String> {
private static final class ContextLineIterator implements Iterator<String> {
private final String @NotNull [] myContentsLines;
private final VcsRevisionNumber myRevisionNumber;
@NotNull private final FileAnnotation myAnnotation;
private final @NotNull FileAnnotation myAnnotation;
private final int myStopAtLine;
// we assume file has at least one line ;)
private int myCurrentLine; // to start looking for next line with revision from
@@ -1,13 +1,7 @@
// 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.actions.diff;
import static com.intellij.diff.DiffRequestFactoryImpl.DIFF_TITLE_RENAME_SEPARATOR;
import static com.intellij.util.ObjectUtils.tryCast;
import com.intellij.diff.DiffContentFactory;
import com.intellij.diff.DiffContentFactoryEx;
import com.intellij.diff.DiffRequestFactory;
import com.intellij.diff.DiffRequestFactoryImpl;
import com.intellij.diff.*;
import com.intellij.diff.chains.DiffRequestProducer;
import com.intellij.diff.chains.DiffRequestProducerException;
import com.intellij.diff.contents.DiffContent;
@@ -31,36 +25,30 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.ByteBackedContentRevision;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListChange;
import com.intellij.openapi.vcs.changes.ChangesUtil;
import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vcs.changes.CurrentContentRevision;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.changes.actions.diff.lst.LocalChangeListDiffRequest;
import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain;
import com.intellij.openapi.vcs.impl.LineStatusTrackerManager;
import com.intellij.openapi.vcs.merge.MergeData;
import com.intellij.diff.DiffVcsDataKeys;
import com.intellij.openapi.vcs.merge.MergeUtils;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ThreeState;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDiffRequestChain.Producer {
import static com.intellij.diff.DiffRequestFactoryImpl.DIFF_TITLE_RENAME_SEPARATOR;
import static com.intellij.util.ObjectUtils.tryCast;
public final class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDiffRequestChain.Producer {
private static final Logger LOG = Logger.getInstance(ChangeDiffRequestProducer.class);
public static final Key<Change> CHANGE_KEY = Key.create("DiffRequestPresentable.Change");
@@ -78,47 +66,41 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
@Deprecated
public static final String BASE_VERSION = DiffBundle.message("merge.version.title.base");
@Nullable private final Project myProject;
@NotNull private final Change myChange;
@NotNull private final Map<Key, Object> myChangeContext;
private final @Nullable Project myProject;
private final @NotNull Change myChange;
private final @NotNull Map<Key<?>, Object> myChangeContext;
private ChangeDiffRequestProducer(@Nullable Project project, @NotNull Change change, @NotNull Map<Key, Object> changeContext) {
private ChangeDiffRequestProducer(@Nullable Project project, @NotNull Change change, @NotNull Map<Key<?>, Object> changeContext) {
myChange = change;
myProject = project;
myChangeContext = changeContext;
}
@NotNull
public Change getChange() {
public @NotNull Change getChange() {
return myChange;
}
@Nullable
public Project getProject() {
public @Nullable Project getProject() {
return myProject;
}
@NotNull
@Override
public String getName() {
public @NotNull String getName() {
return getFilePath().getPath();
}
@NotNull
@Override
public FilePath getFilePath() {
public @NotNull FilePath getFilePath() {
return ChangesUtil.getFilePath(myChange);
}
@NotNull
@Override
public FileStatus getFileStatus() {
public @NotNull FileStatus getFileStatus() {
return myChange.getFileStatus();
}
@Nullable
@Override
public Object getPopupTag() {
public @Nullable Object getPopupTag() {
return myChangeContext.get(TAG_KEY);
}
@@ -172,15 +154,13 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
return revision != null ? revision.getFile().hashCode() : 0;
}
@Nullable
public static ChangeDiffRequestProducer create(@Nullable Project project, @NotNull Change change) {
public static @Nullable ChangeDiffRequestProducer create(@Nullable Project project, @NotNull Change change) {
return create(project, change, null);
}
@Nullable
public static ChangeDiffRequestProducer create(@Nullable Project project,
@NotNull Change change,
@Nullable Map<Key, Object> changeContext) {
public static @Nullable ChangeDiffRequestProducer create(@Nullable Project project,
@NotNull Change change,
@Nullable Map<Key<?>, Object> changeContext) {
if (!canCreate(project, change)) return null;
return new ChangeDiffRequestProducer(project, change, ContainerUtil.notNullize(changeContext));
}
@@ -203,10 +183,9 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
return true;
}
@NotNull
@Override
public DiffRequest process(@NotNull UserDataHolder context,
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
public @NotNull DiffRequest process(@NotNull UserDataHolder context,
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
try {
return loadCurrentContents(context, indicator);
}
@@ -219,9 +198,8 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
}
}
@NotNull
protected DiffRequest loadCurrentContents(@NotNull UserDataHolder context,
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
private @NotNull DiffRequest loadCurrentContents(@NotNull UserDataHolder context,
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
DiffRequestProducerException wrapperException = null;
DiffRequestProducerException requestException = null;
@@ -246,7 +224,9 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
break;
}
}
if (request == null) request = createRequest(myProject, myChange, context, indicator);
if (request == null) {
request = createRequest(myProject, myChange, context, indicator);
}
}
catch (DiffRequestProducerException e) {
requestException = e;
@@ -267,8 +247,9 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
request.putUserData(CHANGE_KEY, myChange);
request.putUserData(DiffViewerWrapper.KEY, wrapper);
for (Map.Entry<Key, Object> entry : myChangeContext.entrySet()) {
request.putUserData(entry.getKey(), entry.getValue());
for (Map.Entry<Key<?>, Object> entry : myChangeContext.entrySet()) {
//noinspection unchecked,rawtypes
request.putUserData((Key)entry.getKey(), entry.getValue());
}
DiffUtil.putDataKey(request, VcsDataKeys.CURRENT_CHANGE, myChange);
@@ -276,11 +257,10 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
return request;
}
@NotNull
private DiffRequest createRequest(@Nullable Project project,
@NotNull Change change,
@NotNull UserDataHolder context,
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
private @NotNull DiffRequest createRequest(@Nullable Project project,
@NotNull Change change,
@NotNull UserDataHolder context,
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
if (ChangesUtil.isTextConflictingChange(change)) { // three side diff
return createMergeRequest(project, change, context);
}
@@ -293,10 +273,9 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
return request;
}
@NotNull
private static DiffRequest createMergeRequest(@Nullable Project project,
@NotNull Change change,
@NotNull UserDataHolder context) throws DiffRequestProducerException {
private static @NotNull DiffRequest createMergeRequest(@Nullable Project project,
@NotNull Change change,
@NotNull UserDataHolder context) throws DiffRequestProducerException {
FilePath path = ChangesUtil.getFilePath(change);
VirtualFile file = path.getVirtualFile();
if (file == null) {
@@ -338,11 +317,10 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
}
}
@NotNull
private SimpleDiffRequest createSimpleRequest(@Nullable Project project,
@NotNull Change change,
@NotNull UserDataHolder context,
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
private @NotNull SimpleDiffRequest createSimpleRequest(@Nullable Project project,
@NotNull Change change,
@NotNull UserDataHolder context,
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
ContentRevision bRev = change.getBeforeRevision();
ContentRevision aRev = change.getAfterRevision();
@@ -374,10 +352,9 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
return request;
}
@Nullable
private static LocalChangeListDiffRequest createLocalChangeListRequest(@Nullable Project project,
@NotNull Change change,
@NotNull ContentDiffRequest request) {
private static @Nullable LocalChangeListDiffRequest createLocalChangeListRequest(@Nullable Project project,
@NotNull Change change,
@NotNull ContentDiffRequest request) {
if (project == null) return null;
if (!(change instanceof ChangeListChange)) return null;
ChangeListChange changeListChange = (ChangeListChange)change;
@@ -397,26 +374,24 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
request);
}
@NotNull
public static String getRequestTitle(@NotNull Change change) {
public static @NotNull String getRequestTitle(@NotNull Change change) {
FilePath bPath = ChangesUtil.getBeforePath(change);
FilePath aPath = ChangesUtil.getAfterPath(change);
return DiffRequestFactoryImpl.getTitle(bPath, aPath, DIFF_TITLE_RENAME_SEPARATOR);
}
@NotNull
public static String getRevisionTitle(@Nullable ContentRevision revision, @NotNull String defaultValue) {
if (revision == null) return defaultValue;
public static @NotNull String getRevisionTitle(@Nullable ContentRevision revision, @NotNull String defaultValue) {
if (revision == null) {
return defaultValue;
}
String title = revision.getRevisionNumber().asString();
if (title == null || title.isEmpty()) return defaultValue;
return title;
return title.isEmpty() ? defaultValue : title;
}
@NotNull
public static DiffContent createContent(@Nullable Project project,
@Nullable ContentRevision revision,
@NotNull UserDataHolder context,
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
public static @NotNull DiffContent createContent(@Nullable Project project,
@Nullable ContentRevision revision,
@NotNull UserDataHolder context,
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
try {
indicator.checkCanceled();
@@ -1,23 +1,10 @@
/*
* 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.actions.diff;
import com.intellij.diff.DiffManager;
import com.intellij.diff.chains.DiffRequestChain;
import com.intellij.diff.util.DiffUserDataKeys;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.AnActionExtensionProvider;
@@ -28,7 +15,6 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain;
import com.intellij.openapi.ListSelection;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -37,7 +23,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class ShowDiffAction implements AnActionExtensionProvider {
public final class ShowDiffAction implements AnActionExtensionProvider {
@Override
public boolean isActive(@NotNull AnActionEvent e) {
return true; // order="last"
@@ -118,8 +104,9 @@ public class ShowDiffAction implements AnActionExtensionProvider {
DiffRequestChain chain = new ChangeDiffRequestChain(presentables.getList(), presentables.getSelectedIndex());
for (Map.Entry<Key, Object> entry : context.getChainContext().entrySet()) {
chain.putUserData(entry.getKey(), entry.getValue());
for (Map.Entry<Key<?>, Object> entry : context.getChainContext().entrySet()) {
//noinspection unchecked,rawtypes
chain.putUserData((Key)entry.getKey(), entry.getValue());
}
chain.putUserData(DiffUserDataKeys.CONTEXT_ACTIONS, context.getActions());
@@ -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.vcs.changes.actions.diff;
import com.intellij.diff.DiffDialogHints;
@@ -15,8 +15,8 @@ public class ShowDiffContext {
@NotNull private final DiffDialogHints myDialogHints;
@Nullable private List<AnAction> myActions;
@Nullable private Map<Key, Object> myChainContext;
@Nullable private Map<Change, Map<Key, Object>> myRequestContext;
@Nullable private Map<Key<?>, Object> myChainContext;
@Nullable private Map<Change, Map<Key<?>, Object>> myRequestContext;
public ShowDiffContext() {
this(DiffDialogHints.DEFAULT);
@@ -38,16 +38,15 @@ public class ShowDiffContext {
}
@NotNull
public Map<Key, Object> getChainContext() {
public Map<Key<?>, Object> getChainContext() {
return ContainerUtil.notNullize(myChainContext);
}
@NotNull
public Map<Key, Object> getChangeContext(@NotNull Change change) {
public Map<Key<?>, Object> getChangeContext(@NotNull Change change) {
if (myRequestContext == null) return Collections.emptyMap();
Map<Key, Object> map = myRequestContext.get(change);
if (map == null) return Collections.emptyMap();
return map;
Map<Key<?>, Object> map = myRequestContext.get(change);
return map == null ? Collections.emptyMap() : map;
}
public void addActions(@NotNull List<? extends AnAction> action) {
@@ -36,13 +36,12 @@ import static com.intellij.diff.util.DiffUserDataKeysEx.VCS_DIFF_RIGHT_CONTENT_T
import static com.intellij.vcsUtil.VcsUtil.getShortRevisionString;
public final class VcsDiffUtil {
@CalledInAwt
public static void showDiffFor(@NotNull Project project,
@NotNull final Collection<? extends Change> changes,
@NotNull final String revNumTitle1,
@NotNull final String revNumTitle2,
@NotNull final FilePath filePath) {
@NotNull Collection<? extends Change> changes,
@NotNull String revNumTitle1,
@NotNull String revNumTitle2,
@NotNull FilePath filePath) {
if (filePath.isDirectory()) {
showChangesDialog(project, getDialogTitle(filePath, revNumTitle1, revNumTitle2), new ArrayList<>(changes));
}
@@ -51,13 +50,13 @@ public final class VcsDiffUtil {
DiffManager.getInstance().showDiff(project, new MessageDiffRequest("No Changes Found"));
}
else {
final HashMap<Key, Object> revTitlesMap = new HashMap<>(2);
Map<Key<?>, Object> revTitlesMap = new HashMap<>(2);
revTitlesMap.put(VCS_DIFF_LEFT_CONTENT_TITLE, revNumTitle1);
revTitlesMap.put(VCS_DIFF_RIGHT_CONTENT_TITLE, revNumTitle2);
ShowDiffContext showDiffContext = new ShowDiffContext() {
@NotNull
@Override
public Map<Key, Object> getChangeContext(@NotNull Change change) {
public Map<Key<?>, Object> getChangeContext(@NotNull Change change) {
return revTitlesMap;
}
};
@@ -78,7 +77,7 @@ public final class VcsDiffUtil {
(localMark ? " (" + VcsBundle.message("diff.title.local") + ")" : "");
}
public static void putFilePathsIntoChangeContext(@NotNull Change change, @NotNull Map<Key, Object> context) {
public static void putFilePathsIntoChangeContext(@NotNull Change change, @NotNull Map<Key<?>, Object> context) {
ContentRevision afterRevision = change.getAfterRevision();
ContentRevision beforeRevision = change.getBeforeRevision();
FilePath aFile = afterRevision == null ? null : afterRevision.getFile();
@@ -39,18 +39,17 @@ public final class VcsLogMessagesTrigramIndex extends VcsLogFullDetailsIndex<Voi
return getCommitsWithAllKeys(trigramProcessor.map.keySet());
}
public static class TrigramMessageIndexer implements DataIndexer<Integer, Void, VcsCommitMetadata> {
public static final class TrigramMessageIndexer implements DataIndexer<Integer, Void, VcsCommitMetadata> {
@NotNull
@Override
public Map<Integer, Void> map(@NotNull VcsCommitMetadata inputData) {
MyTrigramProcessor trigramProcessor = new MyTrigramProcessor();
TrigramBuilder.processTrigrams(inputData.getFullMessage(), trigramProcessor);
return trigramProcessor.map;
}
}
private static class MyTrigramProcessor extends TrigramBuilder.TrigramProcessor {
private static final class MyTrigramProcessor extends TrigramBuilder.TrigramProcessor {
Int2ObjectMap<Void> map;
@Override
@@ -60,7 +59,7 @@ public final class VcsLogMessagesTrigramIndex extends VcsLogFullDetailsIndex<Voi
}
@Override
public boolean execute(int value) {
public boolean test(int value) {
map.put(value, null);
return true;
}
@@ -1,18 +1,4 @@
/*
* 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.vcs.log.impl;
import com.intellij.diff.chains.DiffRequestProducerException;
@@ -80,7 +66,7 @@ public class MergedChangeDiffRequestProvider implements ChangeDiffRequestProvide
}
@NotNull
private static String getRevisionTitle(@NotNull Map<Key, Object> context,
private static String getRevisionTitle(@NotNull Map<Key<?>, Object> context,
@NotNull Key<String> key,
@Nullable ContentRevision revision,
@NotNull String defaultTitle) {
@@ -89,14 +75,14 @@ public class MergedChangeDiffRequestProvider implements ChangeDiffRequestProvide
return ChangeDiffRequestProducer.getRevisionTitle(revision, defaultTitle);
}
public static class MyProducer implements ChangeDiffRequestChain.Producer {
public static final class MyProducer implements ChangeDiffRequestChain.Producer {
@Nullable private final Project myProject;
@NotNull private final MergedChange myMergedChange;
@NotNull private final Map<Key, Object> myContext;
@NotNull private final Map<Key<?>, Object> myContext;
public MyProducer(@Nullable Project project,
@NotNull MergedChange mergedChange,
@NotNull Map<Key, Object> context) {
@NotNull Map<Key<?>, Object> context) {
myProject = project;
myContext = context;
assert mergedChange.getSourceChanges().size() == 2;
@@ -44,7 +44,7 @@ import com.intellij.vcs.log.impl.VcsLogUiProperties;
import com.intellij.vcs.log.ui.VcsLogActionPlaces;
import com.intellij.vcs.log.util.VcsLogUiUtil;
import com.intellij.vcs.log.util.VcsLogUtil;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -64,7 +64,7 @@ import static com.intellij.vcs.log.impl.MainVcsLogUiProperties.SHOW_ONLY_AFFECTE
/**
* Change browser for commits in the Log. For merge commits, can display changes to commits parents in separate groups.
*/
public class VcsLogChangesBrowser extends FilterableChangesBrowser {
public final class VcsLogChangesBrowser extends FilterableChangesBrowser {
@NotNull public static final DataKey<Boolean> HAS_AFFECTED_FILES = DataKey.create("VcsLogChangesBrowser.HasAffectedFiles");
@NotNull private final Project myProject;
@NotNull private final MainVcsLogUiProperties myUiProperties;
@@ -213,7 +213,7 @@ public class VcsLogChangesBrowser extends FilterableChangesBrowser {
if (detail.getParents().size() > 1) {
for (int i = 0; i < detail.getParents().size(); i++) {
THashSet<Change> changesSet = ContainerUtil.newIdentityTroveSet(detail.getChanges(i));
Set<Change> changesSet = new ReferenceOpenHashSet<>(detail.getChanges(i));
myChangesToParents.put(new CommitId(detail.getParents().get(i), detail.getRoot()), changesSet);
}
}
@@ -352,7 +352,7 @@ public class VcsLogChangesBrowser extends FilterableChangesBrowser {
if (!(userObject instanceof Change)) return null;
Change change = (Change)userObject;
Map<Key, Object> context = new HashMap<>();
Map<Key<?>, Object> context = new HashMap<>();
if (!(change instanceof MergedChange)) {
putRootTagIntoChangeContext(change, context);
}
@@ -362,7 +362,7 @@ public class VcsLogChangesBrowser extends FilterableChangesBrowser {
@Nullable
public static ChangeDiffRequestChain.Producer createDiffRequestProducer(@NotNull Project project,
@NotNull Change change,
@NotNull Map<Key, Object> context,
@NotNull Map<Key<?>, Object> context,
boolean forDiffPreview) {
if (change instanceof MergedChange) {
MergedChange mergedChange = (MergedChange)change;
@@ -381,7 +381,7 @@ public class VcsLogChangesBrowser extends FilterableChangesBrowser {
return ChangeDiffRequestProducer.create(project, change, context);
}
private void putRootTagIntoChangeContext(@NotNull Change change, @NotNull Map<Key, Object> context) {
private void putRootTagIntoChangeContext(@NotNull Change change, @NotNull Map<Key<?>, Object> context) {
CommitId parentId = null;
for (CommitId commitId : myChangesToParents.keySet()) {
if (myChangesToParents.get(commitId).contains(change)) {
@@ -396,7 +396,7 @@ public class VcsLogChangesBrowser extends FilterableChangesBrowser {
}
}
private static void putFilePathsIntoMergedChangeContext(@NotNull MergedChange change, @NotNull Map<Key, Object> context) {
private static void putFilePathsIntoMergedChangeContext(@NotNull MergedChange change, @NotNull Map<Key<?>, Object> context) {
ContentRevision centerRevision = change.getAfterRevision();
ContentRevision leftRevision = change.getSourceChanges().get(0).getBeforeRevision();
ContentRevision rightRevision = change.getSourceChanges().get(1).getBeforeRevision();
@@ -1,11 +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 org.jetbrains.idea.devkit.inspections;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.include.FileIncludeManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.GlobalSearchScopesCore;
@@ -23,11 +26,9 @@ import org.jetbrains.idea.devkit.util.ComponentType;
import org.jetbrains.idea.devkit.util.DescriptorUtil;
import org.jetbrains.idea.devkit.util.PsiUtil;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
class RegistrationCheckerUtil {
final class RegistrationCheckerUtil {
enum RegistrationType {
ALL,
ALL_COMPONENTS,
@@ -141,12 +142,11 @@ class RegistrationCheckerUtil {
}
private static class RegistrationTypeFinder {
private static final class RegistrationTypeFinder {
private final PsiClass myPsiClass;
private final RegistrationType myRegistrationType;
private final Set<PsiClass> myTypes = ContainerUtil.newIdentityTroveSet(1);
private final Set<PsiClass> myTypes = Collections.newSetFromMap(new IdentityHashMap<>());
private RegistrationTypeFinder(PsiClass psiClass, RegistrationType registrationType) {
myPsiClass = psiClass;
@@ -11,9 +11,9 @@ import com.intellij.openapi.util.Pair;
import com.intellij.psi.StringEscapesTokenTypes;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public class PropertiesHighlighter extends SyntaxHighlighterBase {
@@ -55,8 +55,8 @@ public class PropertiesHighlighter extends SyntaxHighlighterBase {
);
static {
keys1 = new THashMap<>();
keys2 = new THashMap<>();
keys1 = new HashMap<>();
keys2 = new HashMap<>();
keys1.put(PropertiesTokenTypes.VALUE_CHARACTERS, PROPERTY_VALUE);
keys1.put(PropertiesTokenTypes.END_OF_LINE_COMMENT, PROPERTY_COMMENT);
@@ -1,16 +1,13 @@
// 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.lang.properties.psi;
import gnu.trove.TIntHashSet;
import org.jetbrains.annotations.NotNull;
/**
* @author Konstantin Bulenkov
*/
public class PropertiesResourceBundleUtil {
private static final TIntHashSet SYMBOLS_TO_ESCAPE = new TIntHashSet(new int[]{'=', ':'});
private static final char ESCAPE_SYMBOL = '\\';
public final class PropertiesResourceBundleUtil {
private static final char ESCAPE_SYMBOL = '\\';
/**
* Allows to map given 'raw' property value text to the 'user-friendly' text to show at the resource bundle editor.
@@ -20,8 +17,7 @@ public class PropertiesResourceBundleUtil {
* @param text 'raw' property value text
* @return 'user-friendly' text to show at the resource bundle editor
*/
@NotNull
public static String fromPropertyValueToValueEditor(@NotNull String text) {
public static @NotNull String fromPropertyValueToValueEditor(@NotNull String text) {
StringBuilder buffer = new StringBuilder();
boolean escaped = false;
for (int i = 0; i < text.length(); i++) {
@@ -42,9 +38,7 @@ public class PropertiesResourceBundleUtil {
/**
* Converts property value from given {@code valueFormat} to 'raw' format (how it should be stored in *.properties file)
*/
@NotNull
public static String convertValueToFileFormat(@NotNull String value, char delimiter,
@NotNull PropertyKeyValueFormat valueFormat) {
public static @NotNull String convertValueToFileFormat(@NotNull String value, char delimiter, @NotNull PropertyKeyValueFormat valueFormat) {
if (valueFormat == PropertyKeyValueFormat.FILE) return value;
StringBuilder buffer = new StringBuilder();
@@ -61,7 +55,7 @@ public class PropertiesResourceBundleUtil {
}
}
else if ((i == 0 && (c == ' ' || c == '\t')) // Leading white space
|| (delimiter == ' ' && SYMBOLS_TO_ESCAPE.contains(c))) /* Special symbol*/ {
|| (delimiter == ' ' && (c == '=' || c == ':' /* special symbol */))) {
buffer.append(ESCAPE_SYMBOL);
buffer.append(c);
}
@@ -27,7 +27,7 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.containers.ContainerUtil;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.intellij.plugins.xpathView.Config;
import java.util.*;
@@ -93,7 +93,7 @@ public class HighlighterUtil {
}
private static boolean purgeInvalidHighlighters(Editor editor, List<RangeHighlighter> hl) {
final Set<RangeHighlighter> set = ContainerUtil.newIdentityTroveSet(Arrays.asList(editor.getMarkupModel().getAllHighlighters()));
final Set<RangeHighlighter> set = new ReferenceOpenHashSet<>(editor.getMarkupModel().getAllHighlighters());
boolean hasHighlighter = false;
for (Iterator<RangeHighlighter> iterator = hl.iterator(); iterator.hasNext();) {
final RangeHighlighter h = iterator.next();
@@ -22,5 +22,6 @@
<orderEntry type="module" module-name="intellij.xml.impl" />
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
<orderEntry type="library" name="NanoXML" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
</component>
</module>
@@ -23,7 +23,7 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
import com.intellij.util.Alarm;
import com.intellij.util.containers.ContainerUtil;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import org.intellij.plugins.xsltDebugger.rt.engine.Watchable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -46,11 +46,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
* This is just the second best solution though as it would be better to avoid any interaction with the debuggee on the
* EDT, but, at least right now, it seems to be more reliable against bad surprises.
*/
class EDTGuard implements InvocationHandler {
final class EDTGuard implements InvocationHandler {
// maximum time to wait for a result on the EDT
private static final long MAX_TIMEOUT = 10 * 1000;
private final Map<Object, Object> myInstanceCache = ContainerUtil.newIdentityTroveMap();
private final Map<Object, Object> myInstanceCache = new Reference2ObjectOpenHashMap<>();
private final Object myTarget;
@@ -27,6 +27,7 @@ import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.util.XmlStringUtil;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.intellij.plugins.relaxNG.model.descriptors.CompositeDescriptor;
import org.intellij.plugins.relaxNG.model.descriptors.RngElementDescriptor;
import org.intellij.plugins.relaxNG.model.descriptors.RngXmlAttributeDescriptor;
@@ -36,7 +37,7 @@ import org.kohsuke.rngom.digested.DElementPattern;
import java.util.Collection;
public class RngDocumentationProvider implements DocumentationProvider {
final class RngDocumentationProvider implements DocumentationProvider {
private static final Logger LOG = Logger.getInstance(RngDocumentationProvider.class);
@NonNls
@@ -79,15 +80,14 @@ public class RngDocumentationProvider implements DocumentationProvider {
final XmlAttribute attribute = (XmlAttribute)c;
final XmlAttributeDescriptor descriptor = attribute.getDescriptor();
if (descriptor instanceof RngXmlAttributeDescriptor) {
final RngXmlAttributeDescriptor d = (RngXmlAttributeDescriptor)descriptor;
final StringBuilder sb = new StringBuilder();
final Collection<PsiElement> declaration = ContainerUtil.newIdentityTroveSet(d.getDeclarations());
final Collection<PsiElement> declaration = new ReferenceOpenHashSet<>(descriptor.getDeclarations());
for (PsiElement psiElement : declaration) {
if (psiElement instanceof XmlTag) {
if (sb.length() > 0) {
sb.append("<hr>");
}
sb.append(getDocumentationFromTag((XmlTag)psiElement, d.getName(), "Attribute"));
sb.append(getDocumentationFromTag((XmlTag)psiElement, descriptor.getName(), "Attribute"));
}
}
return makeDocumentation(sb);
@@ -13,22 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.intellij.plugins.relaxNG.compact.parser;
import com.intellij.lang.PsiBuilder;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.ContainerUtil;
import org.intellij.plugins.relaxNG.compact.RncElementTypes;
import java.util.IdentityHashMap;
import java.util.Map;
import static org.intellij.plugins.relaxNG.compact.RncTokenTypes.*;
public class PatternParsing extends DeclarationParsing {
protected static final Map<IElementType, IElementType> TOKEN_MAP =
ContainerUtil.newIdentityTroveMap();
public final class PatternParsing extends DeclarationParsing {
private static final Map<IElementType, IElementType> TOKEN_MAP = new IdentityHashMap<>();
static {
TOKEN_MAP.put(COMMA, RncElementTypes.SEQUENCE);
@@ -13,16 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.intellij.plugins.relaxNG.model.descriptors;
import com.intellij.util.containers.ContainerUtil;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import org.kohsuke.rngom.digested.*;
import java.util.Set;
public class RecursionSaveWalker extends DPatternWalker {
private final Set<DPattern> myVisited = ContainerUtil.newIdentityTroveSet(256);
private final Set<DPattern> myVisited = new ReferenceOpenHashSet<>(256);
protected RecursionSaveWalker() {
}