mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
reduce classloading - prefer JDK ArrayList
GitOrigin-RevId: 54258671f50febc9494c7d251164b04280fd4aed
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9620d6ee8c
commit
59899406c0
@@ -31,11 +31,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public class CollectionAddAllCanBeReplacedWithConstructorInspection extends AbstractBaseJavaLocalInspectionTool {
|
||||
|
||||
public final class CollectionAddAllCanBeReplacedWithConstructorInspection extends AbstractBaseJavaLocalInspectionTool {
|
||||
private final CollectionsListSettings mySettings = new CollectionsListSettings() {
|
||||
@Override
|
||||
protected Collection<String> getDefaultSettings() {
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.intellij.codeInspection.options.OptionContainer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -46,7 +45,7 @@ public abstract class CollectionsListSettings implements OptionContainer {
|
||||
private final List<String> myCollectionClassesRequiringCapacity;
|
||||
|
||||
public CollectionsListSettings() {
|
||||
myCollectionClassesRequiringCapacity = new SmartList<>(getDefaultSettings());
|
||||
myCollectionClassesRequiringCapacity = new ArrayList<>(getDefaultSettings());
|
||||
}
|
||||
|
||||
public void readSettings(@NotNull Element node) throws InvalidDataException {
|
||||
|
||||
@@ -1,21 +1,6 @@
|
||||
/*
|
||||
* 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-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.FilteringIterator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
@@ -30,14 +15,14 @@ public final class JpsElementCollectionImpl<E extends JpsElement> extends JpsEle
|
||||
|
||||
JpsElementCollectionImpl(JpsElementChildRole<E> role) {
|
||||
myChildRole = role;
|
||||
myElements = new SmartList<>();
|
||||
myElements = new ArrayList<>();
|
||||
myCopyToOriginal = null;
|
||||
}
|
||||
|
||||
private JpsElementCollectionImpl(JpsElementCollectionImpl<E> original) {
|
||||
myChildRole = original.myChildRole;
|
||||
myElements = new SmartList<>();
|
||||
myCopyToOriginal = new HashMap<>();
|
||||
myElements = new ArrayList<>(original.myElements.size());
|
||||
myCopyToOriginal = new HashMap<>(original.myElements.size());
|
||||
for (E e : original.myElements) {
|
||||
//noinspection unchecked
|
||||
final E copy = (E)e.getBulkModificationSupport().createCopy();
|
||||
@@ -53,13 +38,12 @@ public final class JpsElementCollectionImpl<E extends JpsElement> extends JpsEle
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X extends JpsTypedElement<P>, P extends JpsElement> Iterable<X> getElementsOfType(@NotNull final JpsElementType<P> type) {
|
||||
public <X extends JpsTypedElement<P>, P extends JpsElement> Iterable<X> getElementsOfType(final @NotNull JpsElementType<P> type) {
|
||||
return new JpsElementIterable<>(type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public E addChild(@NotNull JpsElementCreator<E> creator) {
|
||||
public @NotNull E addChild(@NotNull JpsElementCreator<E> creator) {
|
||||
return addChild(creator.create());
|
||||
}
|
||||
|
||||
@@ -86,9 +70,8 @@ public final class JpsElementCollectionImpl<E extends JpsElement> extends JpsEle
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsElementCollectionImpl<E> createCopy() {
|
||||
public @NotNull JpsElementCollectionImpl<E> createCopy() {
|
||||
return new JpsElementCollectionImpl<>(this);
|
||||
}
|
||||
|
||||
@@ -118,7 +101,7 @@ public final class JpsElementCollectionImpl<E extends JpsElement> extends JpsEle
|
||||
}
|
||||
}
|
||||
|
||||
private class JpsElementIterable<X extends JpsTypedElement<P>, P extends JpsElement> implements Iterable<X> {
|
||||
private final class JpsElementIterable<X extends JpsTypedElement<P>, P extends JpsElement> implements Iterable<X> {
|
||||
private final JpsElementType<? extends JpsElement> myType;
|
||||
|
||||
JpsElementIterable(JpsElementType<P> type) {
|
||||
|
||||
@@ -1,21 +1,6 @@
|
||||
/*
|
||||
* 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-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.model.jarRepository.impl;
|
||||
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElementChildRole;
|
||||
import org.jetbrains.jps.model.ex.JpsElementBase;
|
||||
@@ -23,6 +8,7 @@ import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
|
||||
import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoriesConfiguration;
|
||||
import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryDescription;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -30,10 +16,10 @@ import java.util.List;
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
*/
|
||||
public class JpsRemoteRepositoriesConfigurationImpl extends JpsElementBase<JpsRemoteRepositoriesConfigurationImpl> implements JpsRemoteRepositoriesConfiguration{
|
||||
public final class JpsRemoteRepositoriesConfigurationImpl extends JpsElementBase<JpsRemoteRepositoriesConfigurationImpl> implements JpsRemoteRepositoriesConfiguration{
|
||||
public static final JpsElementChildRole<JpsRemoteRepositoriesConfiguration> ROLE = JpsElementChildRoleBase.create("remote repositories configuration");
|
||||
|
||||
private final List<JpsRemoteRepositoryDescription> myRepositories = new SmartList<>();
|
||||
private final List<JpsRemoteRepositoryDescription> repositories = new ArrayList<>();
|
||||
|
||||
public JpsRemoteRepositoriesConfigurationImpl() {
|
||||
this(Arrays.asList( // defaults
|
||||
@@ -43,13 +29,12 @@ public class JpsRemoteRepositoriesConfigurationImpl extends JpsElementBase<JpsRe
|
||||
}
|
||||
|
||||
public JpsRemoteRepositoriesConfigurationImpl(List<? extends JpsRemoteRepositoryDescription> repositories) {
|
||||
myRepositories.addAll(repositories);
|
||||
this.repositories.addAll(repositories);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsRemoteRepositoriesConfigurationImpl createCopy() {
|
||||
return new JpsRemoteRepositoriesConfigurationImpl(myRepositories);
|
||||
public @NotNull JpsRemoteRepositoriesConfigurationImpl createCopy() {
|
||||
return new JpsRemoteRepositoriesConfigurationImpl(repositories);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,12 +44,12 @@ public class JpsRemoteRepositoriesConfigurationImpl extends JpsElementBase<JpsRe
|
||||
|
||||
@Override
|
||||
public List<JpsRemoteRepositoryDescription> getRepositories() {
|
||||
return Collections.unmodifiableList(myRepositories);
|
||||
return Collections.unmodifiableList(repositories);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRepositories(List<? extends JpsRemoteRepositoryDescription> repositories) {
|
||||
myRepositories.clear();
|
||||
myRepositories.addAll(repositories);
|
||||
this.repositories.clear();
|
||||
this.repositories.addAll(repositories);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,6 @@
|
||||
/*
|
||||
* 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-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.model.serialization.jarRepository;
|
||||
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
@@ -24,12 +9,13 @@ import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryDescription;
|
||||
import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryService;
|
||||
import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
*/
|
||||
public class JpsRemoteRepositoriesConfigurationSerializer extends JpsProjectExtensionSerializer {
|
||||
public final class JpsRemoteRepositoriesConfigurationSerializer extends JpsProjectExtensionSerializer {
|
||||
private static final String ELEMENT_TAG = "remote-repository";
|
||||
private static final String OPTION_TAG = "option";
|
||||
private static final String ID_PROPERTY = "id";
|
||||
@@ -42,15 +28,15 @@ public class JpsRemoteRepositoriesConfigurationSerializer extends JpsProjectExte
|
||||
|
||||
@Override
|
||||
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
|
||||
final List<JpsRemoteRepositoryDescription> result = new SmartList<>();
|
||||
final List<Element> children = componentTag.getChildren(ELEMENT_TAG);
|
||||
List<JpsRemoteRepositoryDescription> result = new ArrayList<>();
|
||||
List<Element> children = componentTag.getChildren(ELEMENT_TAG);
|
||||
for (Element repoElement : children) {
|
||||
String id = null;
|
||||
String name = null;
|
||||
String url = null;
|
||||
for (Element element : repoElement.getChildren(OPTION_TAG)) {
|
||||
final String option = element.getAttributeValue("name");
|
||||
final String optionValue = element.getAttributeValue("value");
|
||||
String option = element.getAttributeValue("name");
|
||||
String optionValue = element.getAttributeValue("value");
|
||||
if (ID_PROPERTY.equals(option)) {
|
||||
id = optionValue;
|
||||
}
|
||||
@@ -65,7 +51,7 @@ public class JpsRemoteRepositoriesConfigurationSerializer extends JpsProjectExte
|
||||
result.add(new JpsRemoteRepositoryDescription(id, name, url));
|
||||
}
|
||||
}
|
||||
final JpsRemoteRepositoriesConfiguration config = JpsRemoteRepositoryService.getInstance().getOrCreateRemoteRepositoriesConfiguration(project);
|
||||
JpsRemoteRepositoriesConfiguration config = JpsRemoteRepositoryService.getInstance().getOrCreateRemoteRepositoriesConfiguration(project);
|
||||
if (!result.isEmpty()) {
|
||||
config.setRepositories(result);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.registry.EarlyAccessRegistryManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.concurrency.SynchronizedClearableLazy;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
@@ -55,7 +54,14 @@ public final class BuildNumber implements Comparable<BuildNumber> {
|
||||
}
|
||||
|
||||
public boolean isSnapshot() {
|
||||
return ArrayUtil.indexOf(myComponents, SNAPSHOT_VALUE) != -1;
|
||||
int result = -1;
|
||||
for (int i = 0; i < myComponents.length; i++) {
|
||||
if (myComponents[i] == SNAPSHOT_VALUE) {
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result != -1;
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
@@ -127,7 +133,10 @@ public final class BuildNumber implements Comparable<BuildNumber> {
|
||||
}
|
||||
|
||||
public static @Nullable BuildNumber fromString(@NotNull String version, @Nullable String pluginName, @Nullable String productCodeIfAbsentInVersion) {
|
||||
if (version.isEmpty()) return null;
|
||||
if (version.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String code = version;
|
||||
int productSeparator = code.indexOf('-');
|
||||
String productCode;
|
||||
@@ -136,7 +145,7 @@ public final class BuildNumber implements Comparable<BuildNumber> {
|
||||
code = code.substring(productSeparator + 1);
|
||||
}
|
||||
else {
|
||||
productCode = productCodeIfAbsentInVersion != null ? productCodeIfAbsentInVersion : "";
|
||||
productCode = productCodeIfAbsentInVersion == null ? "" : productCodeIfAbsentInVersion;
|
||||
}
|
||||
|
||||
if (SNAPSHOT.equals(code) || isPlaceholder(code)) {
|
||||
@@ -152,17 +161,17 @@ public final class BuildNumber implements Comparable<BuildNumber> {
|
||||
}
|
||||
|
||||
String[] stringComponents = code.split("\\.");
|
||||
int[] intComponentsList = new int[stringComponents.length];
|
||||
int[] intComponentList = new int[stringComponents.length];
|
||||
for (int i = 0, n = stringComponents.length; i < n; i++) {
|
||||
String stringComponent = stringComponents[i];
|
||||
int comp = parseBuildNumber(version, stringComponent, pluginName);
|
||||
intComponentsList[i] = comp;
|
||||
if (comp == SNAPSHOT_VALUE && (i + 1) != n) {
|
||||
intComponentsList = Arrays.copyOf(intComponentsList, i + 1);
|
||||
int component = parseBuildNumber(version, stringComponent, pluginName);
|
||||
intComponentList[i] = component;
|
||||
if (component == SNAPSHOT_VALUE && (i + 1) != n) {
|
||||
intComponentList = Arrays.copyOf(intComponentList, i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new BuildNumber(productCode, intComponentsList);
|
||||
return new BuildNumber(productCode, intComponentList);
|
||||
}
|
||||
else {
|
||||
int buildNumber = parseBuildNumber(version, code, pluginName);
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.patterns;
|
||||
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("ForLoopReplaceableByForEach")
|
||||
public final class ElementPatternCondition<T> {
|
||||
private final InitialPatternCondition<T> initialCondition;
|
||||
private final List<PatternCondition<? super T>> conditions;
|
||||
|
||||
private final InitialPatternCondition<T> myInitialCondition;
|
||||
private final List<PatternCondition<? super T>> myConditions;
|
||||
|
||||
public ElementPatternCondition(final InitialPatternCondition<T> startCondition) {
|
||||
myInitialCondition = startCondition;
|
||||
myConditions = Collections.emptyList();
|
||||
public ElementPatternCondition(@NotNull InitialPatternCondition<T> startCondition) {
|
||||
initialCondition = startCondition;
|
||||
conditions = Collections.emptyList();
|
||||
}
|
||||
|
||||
ElementPatternCondition(InitialPatternCondition<T> initialCondition, List<PatternCondition<? super T>> conditions) {
|
||||
myInitialCondition = initialCondition;
|
||||
myConditions = conditions;
|
||||
ElementPatternCondition(@NotNull InitialPatternCondition<T> initialCondition, @NotNull List<PatternCondition<? super T>> conditions) {
|
||||
this.initialCondition = initialCondition;
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
private ElementPatternCondition(ElementPatternCondition<T> original, PatternCondition<? super T> condition) {
|
||||
myInitialCondition = original.getInitialCondition();
|
||||
myConditions = new SmartList<>(original.getConditions());
|
||||
myConditions.add(condition);
|
||||
private ElementPatternCondition(@NotNull ElementPatternCondition<T> original, PatternCondition<? super T> condition) {
|
||||
initialCondition = original.getInitialCondition();
|
||||
conditions = new ArrayList<>(original.conditions.size() + 1);
|
||||
conditions.addAll(original.conditions);
|
||||
conditions.add(condition);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@@ -35,21 +35,21 @@ public final class ElementPatternCondition<T> {
|
||||
}
|
||||
|
||||
public void append(StringBuilder builder, String indent) {
|
||||
myInitialCondition.append(builder, indent);
|
||||
final int conditionSize = myConditions.size();
|
||||
initialCondition.append(builder, indent);
|
||||
int conditionSize = conditions.size();
|
||||
|
||||
for (int i = 0; i < conditionSize; ++i) { // for each is slower
|
||||
final PatternCondition<? super T> condition = myConditions.get(i);
|
||||
condition.append(builder.append(".\n").append(indent), indent);
|
||||
// for each it is slower
|
||||
for (int i = 0; i < conditionSize; ++i) {
|
||||
conditions.get(i).append(builder.append(".\n").append(indent), indent);
|
||||
}
|
||||
}
|
||||
|
||||
public List<PatternCondition<? super T>> getConditions() {
|
||||
return myConditions;
|
||||
return conditions;
|
||||
}
|
||||
|
||||
public InitialPatternCondition<T> getInitialCondition() {
|
||||
return myInitialCondition;
|
||||
return initialCondition;
|
||||
}
|
||||
|
||||
public ElementPatternCondition<T> append(PatternCondition<? super T> condition) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ui.content.impl;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
@@ -38,7 +38,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
private static final Logger LOG = Logger.getInstance(ContentManagerImpl.class);
|
||||
|
||||
private ContentUI myUI;
|
||||
private final List<Content> myContents = new ArrayList<>();
|
||||
private final List<Content> contents = new ArrayList<>();
|
||||
private final List<ContentManagerImpl> myNestedManagers = new SmartList<>();
|
||||
private final EventDispatcher<ContentManagerListener> myDispatcher = EventDispatcher.create(ContentManagerListener.class);
|
||||
private final List<Content> mySelection = new ArrayList<>();
|
||||
@@ -173,9 +173,9 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
|
||||
private void doAddContent(final @NotNull Content content, final int index) {
|
||||
ThreadingAssertions.assertEventDispatchThread();
|
||||
if (myContents.contains(content)) {
|
||||
myContents.remove(content);
|
||||
myContents.add(index < 0 ? myContents.size() : index, content);
|
||||
if (contents.contains(content)) {
|
||||
contents.remove(content);
|
||||
contents.add(index < 0 ? contents.size() : index, content);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -192,8 +192,8 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
}
|
||||
|
||||
((ContentImpl)content).setManager(this);
|
||||
final int insertIndex = index < 0 ? myContents.size() : index;
|
||||
myContents.add(insertIndex, content);
|
||||
final int insertIndex = index < 0 ? contents.size() : index;
|
||||
contents.add(insertIndex, content);
|
||||
content.addPropertyChangeListener(this);
|
||||
fireContentAdded(content, insertIndex);
|
||||
if (myUI.isToSelectAddedContent() || mySelection.isEmpty() && !myUI.canBeEmptySelection()) {
|
||||
@@ -203,7 +203,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
else {
|
||||
addSelectedContent(content);
|
||||
}
|
||||
if (myComponent != null && myComponent.isFocusOwner() && myContents.size() == 1) {
|
||||
if (myComponent != null && myComponent.isFocusOwner() && contents.size() == 1) {
|
||||
requestFocus(content, true);
|
||||
}
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
|
||||
try {
|
||||
Content selection = mySelection.isEmpty() ? null : mySelection.get(mySelection.size() - 1);
|
||||
int selectedIndex = selection != null ? myContents.indexOf(selection) : -1;
|
||||
int selectedIndex = selection != null ? contents.indexOf(selection) : -1;
|
||||
|
||||
if (!fireContentRemoveQuery(content, indexToBeRemoved) || !content.isValid()) {
|
||||
return ActionCallback.REJECTED;
|
||||
@@ -275,7 +275,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
|
||||
mySelectionHistory.remove(content);
|
||||
myContentWithChangedComponent.remove(content);
|
||||
myContents.remove(content);
|
||||
contents.remove(content);
|
||||
content.removePropertyChangeListener(this);
|
||||
|
||||
fireContentRemoved(content, indexToBeRemoved);
|
||||
@@ -285,10 +285,10 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
Disposer.dispose(content);
|
||||
}
|
||||
|
||||
int newSize = myContents.size();
|
||||
int newSize = contents.size();
|
||||
if (newSize > 0) {
|
||||
if (indexToSelect > -1) {
|
||||
final Content toSelect = !mySelectionHistory.isEmpty() ? mySelectionHistory.get(0) : myContents.get(indexToSelect);
|
||||
final Content toSelect = !mySelectionHistory.isEmpty() ? mySelectionHistory.get(0) : contents.get(indexToSelect);
|
||||
if (!isSelected(toSelect)) {
|
||||
if (myUI.isSingleSelection()) {
|
||||
ActionCallback result = new ActionCallback();
|
||||
@@ -307,7 +307,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
return ActionCallback.DONE;
|
||||
}
|
||||
finally {
|
||||
if (ApplicationManager.getApplication().isDispatchThread() && !myDisposed && myContents.isEmpty()) {
|
||||
if (ApplicationManager.getApplication().isDispatchThread() && !myDisposed && contents.isEmpty()) {
|
||||
// cleanup visibleComponent in TabbedPaneUI only if there is no content left,
|
||||
// otherwise immediate adding of a new content will lead to having visible two TabWrapper component at the same time.
|
||||
myUI.getComponent().updateUI(); //cleanup visibleComponent from Alloy...TabbedPaneUI
|
||||
@@ -317,46 +317,55 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
|
||||
@Override
|
||||
public void removeAllContents(boolean dispose) {
|
||||
if (myContents.isEmpty()) {
|
||||
if (contents.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Content content : List.copyOf(myContents)) {
|
||||
for (Content content : List.copyOf(contents)) {
|
||||
removeContent(content, dispose);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentCount() {
|
||||
return myContents.size();
|
||||
return contents.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
boolean empty = ContentManager.super.isEmpty();
|
||||
if (!empty) return false;
|
||||
if (!empty) {
|
||||
return false;
|
||||
}
|
||||
for (ContentManager manager : myNestedManagers) {
|
||||
if (!manager.isEmpty()) return false;
|
||||
if (!manager.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content @NotNull [] getContents() {
|
||||
return myContents.toArray(new Content[0]);
|
||||
return contents.toArray(new Content[0]);
|
||||
}
|
||||
|
||||
public List<Content> getContentsRecursively() {
|
||||
SmartList<Content> list = new SmartList<>(myContents);
|
||||
for (ContentManagerImpl nestedManager : myNestedManagers) {
|
||||
list.addAll(nestedManager.getContentsRecursively());
|
||||
}
|
||||
List<Content> list = new ArrayList<>();
|
||||
collectContentsRecursively(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void collectContentsRecursively(@NotNull List<Content> to) {
|
||||
to.addAll(contents);
|
||||
for (ContentManagerImpl nestedManager : myNestedManagers) {
|
||||
nestedManager.collectContentsRecursively(to);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content findContent(String displayName) {
|
||||
for (Content content : myContents) {
|
||||
for (Content content : contents) {
|
||||
if (content.getDisplayName().equals(displayName)) {
|
||||
return content;
|
||||
}
|
||||
@@ -366,7 +375,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
|
||||
@Override
|
||||
public Content getContent(int index) {
|
||||
return index >= 0 && index < myContents.size() ? myContents.get(index) : null;
|
||||
return index >= 0 && index < contents.size() ? contents.get(index) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -382,7 +391,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
|
||||
@Override
|
||||
public int getIndexOfContent(@NotNull Content content) {
|
||||
return myContents.indexOf(content);
|
||||
return contents.indexOf(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -415,7 +424,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
if (!canCloseContents()) {
|
||||
return false;
|
||||
}
|
||||
for (Content content : myContents) {
|
||||
for (Content content : contents) {
|
||||
if (content.isCloseable()) {
|
||||
return true;
|
||||
}
|
||||
@@ -500,7 +509,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
if (!checkSelectionChangeShouldBeProcessed(content, implicit)) {
|
||||
return ActionCallback.REJECTED;
|
||||
}
|
||||
if (!myContents.contains(content)) {
|
||||
if (!contents.contains(content)) {
|
||||
for (ContentManagerImpl manager : myNestedManagers) {
|
||||
ActionCallback nestedCallback = manager.setSelectedContent(content, requestFocus, forcedFocus, implicit);
|
||||
if (nestedCallback != ActionCallback.REJECTED) return nestedCallback;
|
||||
@@ -626,7 +635,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
public @NotNull ActionCallback requestFocus(final Content content, final boolean forced) {
|
||||
final Content toSelect = content == null ? getSelectedContent() : content;
|
||||
if (toSelect == null) return ActionCallback.REJECTED;
|
||||
assert myContents.contains(toSelect);
|
||||
assert contents.contains(toSelect);
|
||||
JComponent preferredFocusableComponent = toSelect.getPreferredFocusableComponent();
|
||||
return preferredFocusableComponent != null ? getFocusManager().requestFocusInProject(preferredFocusableComponent, myProject) : ActionCallback.REJECTED;
|
||||
}
|
||||
@@ -658,7 +667,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
|
||||
@Override
|
||||
public @NotNull ContentFactory getFactory() {
|
||||
return ApplicationManager.getApplication().getService(ContentFactory.class);
|
||||
return ContentFactory.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -673,7 +682,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
|
||||
if (myDisposed) return;
|
||||
myDisposed = true;
|
||||
|
||||
myContents.clear();
|
||||
contents.clear();
|
||||
myNestedManagers.clear();
|
||||
mySelection.clear();
|
||||
myContentWithChangedComponent.clear();
|
||||
|
||||
@@ -1,4 +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.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.roots.impl.libraries;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -11,7 +11,6 @@ import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.workspaceModel.ide.legacyBridge.GlobalLibraryTableBridge;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -22,9 +21,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
final class LibraryTablesRegistrarImpl extends LibraryTablesRegistrar implements Disposable {
|
||||
private static final ExtensionPointName<CustomLibraryTableDescription> CUSTOM_TABLES_EP = new ExtensionPointName<>("com.intellij.customLibraryTable");
|
||||
private final Map<String, LibraryTableBase> myCustomLibraryTables = new ConcurrentHashMap<>();
|
||||
private volatile boolean myExtensionsLoaded = false;
|
||||
private final Object myExtensionsLoadingLock = new Object();
|
||||
private final Map<String, LibraryTableBase> customLibraryTables = new ConcurrentHashMap<>();
|
||||
private volatile boolean extensionLoaded = false;
|
||||
private final Object extensionLoadingLock = new Object();
|
||||
|
||||
LibraryTablesRegistrarImpl() {
|
||||
//this is needed to ensure that VirtualFilePointerManager is initialized before custom library tables and therefore disposed after them;
|
||||
@@ -60,43 +59,43 @@ final class LibraryTablesRegistrarImpl extends LibraryTablesRegistrar implements
|
||||
}
|
||||
|
||||
public @NotNull Map<String, LibraryTableBase> getCustomLibrariesMap() {
|
||||
if (myExtensionsLoaded) {
|
||||
return myCustomLibraryTables;
|
||||
if (extensionLoaded) {
|
||||
return customLibraryTables;
|
||||
}
|
||||
|
||||
synchronized (myExtensionsLoadingLock) {
|
||||
if (!myExtensionsLoaded) {
|
||||
synchronized (extensionLoadingLock) {
|
||||
if (!extensionLoaded) {
|
||||
CUSTOM_TABLES_EP.getPoint().addExtensionPointListener(new ExtensionPointListener<>() {
|
||||
@Override
|
||||
public void extensionAdded(@NotNull CustomLibraryTableDescription extension, @NotNull PluginDescriptor pluginDescriptor) {
|
||||
LibraryTableBase table = new CustomLibraryTableImpl(extension.getTableLevel(), extension.getPresentation());
|
||||
myCustomLibraryTables.put(extension.getTableLevel(), table);
|
||||
customLibraryTables.put(extension.getTableLevel(), table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extensionRemoved(@NotNull CustomLibraryTableDescription extension, @NotNull PluginDescriptor pluginDescriptor) {
|
||||
LibraryTableBase table = myCustomLibraryTables.remove(extension.getTableLevel());
|
||||
LibraryTableBase table = customLibraryTables.remove(extension.getTableLevel());
|
||||
if (table != null) {
|
||||
Disposer.dispose(table);
|
||||
}
|
||||
}
|
||||
}, true, null);
|
||||
myExtensionsLoaded = true;
|
||||
extensionLoaded = true;
|
||||
}
|
||||
}
|
||||
return myCustomLibraryTables;
|
||||
return customLibraryTables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<LibraryTable> getCustomLibraryTables() {
|
||||
return new SmartList<>(getCustomLibrariesMap().values());
|
||||
return List.copyOf(getCustomLibrariesMap().values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
for (LibraryTableBase value : myCustomLibraryTables.values()) {
|
||||
for (LibraryTableBase value : customLibraryTables.values()) {
|
||||
Disposer.dispose(value);
|
||||
}
|
||||
myCustomLibraryTables.clear();
|
||||
customLibraryTables.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +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.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
@@ -1006,5 +1006,4 @@ public final class ArrayUtil {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.util.function.ObjIntConsumer;
|
||||
import java.util.function.ToIntFunction;
|
||||
|
||||
public final class DFSTBuilder<Node> {
|
||||
|
||||
private final @NotNull OutboundSemiGraph<Node> myGraph;
|
||||
|
||||
private final ToIntFunction<Node> myNodeToNNumber;
|
||||
@@ -204,7 +203,7 @@ public final class DFSTBuilder<Node> {
|
||||
|
||||
// we have returned to the node
|
||||
if (index[i] == -1) {
|
||||
// actually we visit node first time, prepare
|
||||
// actually, we visit node first time, prepare
|
||||
index[i] = dfsIndex;
|
||||
lowLink[i] = dfsIndex;
|
||||
dfsIndex++;
|
||||
|
||||
Reference in New Issue
Block a user