mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup: replace explicit types with diamonds (<>) in intellij.platform.util
This commit is contained in:
@@ -49,7 +49,7 @@ public abstract class AbstractBundle {
|
||||
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(myBundle);
|
||||
if (bundle == null) {
|
||||
bundle = getResourceBundle(myPathToBundle, getClass().getClassLoader());
|
||||
myBundle = new SoftReference<ResourceBundle>(bundle);
|
||||
myBundle = new SoftReference<>(bundle);
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class CommonBundle extends BundleBase {
|
||||
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
|
||||
if (bundle == null) {
|
||||
bundle = ResourceBundle.getBundle(BUNDLE);
|
||||
ourBundle = new SoftReference<ResourceBundle>(bundle);
|
||||
ourBundle = new SoftReference<>(bundle);
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public abstract class ProcessHandler extends UserDataHolderBase {
|
||||
private final List<ProcessListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
|
||||
private enum State {INITIAL, RUNNING, TERMINATING, TERMINATED}
|
||||
private final AtomicReference<State> myState = new AtomicReference<State>(State.INITIAL);
|
||||
private final AtomicReference<State> myState = new AtomicReference<>(State.INITIAL);
|
||||
|
||||
private final Semaphore myWaitSemaphore;
|
||||
private final ProcessListener myEventMulticaster;
|
||||
@@ -242,7 +242,7 @@ public abstract class ProcessHandler extends UserDataHolderBase {
|
||||
}
|
||||
|
||||
private final class TasksRunner extends ProcessAdapter {
|
||||
private final List<Runnable> myPendingTasks = new ArrayList<Runnable>();
|
||||
private final List<Runnable> myPendingTasks = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void startNotified(@NotNull ProcessEvent event) {
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.intellij.util.concurrency.CountingThreadFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* A thread pool for long-running workers needed for handling child processes, to avoid occupying workers in the main application pool
|
||||
@@ -17,7 +19,7 @@ public class ProcessIOExecutorService extends ThreadPoolExecutor {
|
||||
public static final ExecutorService INSTANCE = new ProcessIOExecutorService();
|
||||
|
||||
private ProcessIOExecutorService() {
|
||||
super(1, Integer.MAX_VALUE, 1, TimeUnit.MINUTES, new SynchronousQueue<Runnable>(), new CountingThreadFactory() {
|
||||
super(1, Integer.MAX_VALUE, 1, TimeUnit.MINUTES, new SynchronousQueue<>(), new CountingThreadFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Thread newThread(@NotNull final Runnable r) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ProcessWaitFor {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.process.ProcessWaitFor");
|
||||
|
||||
private final Future<?> myWaitForThreadFuture;
|
||||
private final BlockingQueue<Consumer<Integer>> myTerminationCallback = new ArrayBlockingQueue<Consumer<Integer>>(1);
|
||||
private final BlockingQueue<Consumer<Integer>> myTerminationCallback = new ArrayBlockingQueue<>(1);
|
||||
private volatile boolean myDetached;
|
||||
|
||||
/** @deprecated use {@link #ProcessWaitFor(Process, TaskExecutor, String)} instead (to be removed in IDEA 2018) */
|
||||
|
||||
@@ -145,9 +145,9 @@ public class UnixProcessManager {
|
||||
LOG.debug("Sending signal " + signal + " to process tree with root PID " + processId);
|
||||
}
|
||||
|
||||
final Ref<Integer> foundPid = new Ref<Integer>();
|
||||
final Ref<Integer> foundPid = new Ref<>();
|
||||
final ProcessInfo processInfo = new ProcessInfo();
|
||||
final List<Integer> childrenPids = new ArrayList<Integer>();
|
||||
final List<Integer> childrenPids = new ArrayList<>();
|
||||
|
||||
findChildProcesses(ourPid, processId, foundPid, processInfo, childrenPids);
|
||||
|
||||
@@ -278,11 +278,11 @@ public class UnixProcessManager {
|
||||
}
|
||||
|
||||
private static class ProcessInfo {
|
||||
private final Map<Integer, List<Integer>> BY_PARENT = new TreeMap<Integer, List<Integer>>(); // pid -> list of children pids
|
||||
private final Map<Integer, List<Integer>> BY_PARENT = new TreeMap<>(); // pid -> list of children pids
|
||||
|
||||
public void register(Integer pid, Integer parentPid) {
|
||||
List<Integer> children = BY_PARENT.get(parentPid);
|
||||
if (children == null) BY_PARENT.put(parentPid, children = new LinkedList<Integer>());
|
||||
if (children == null) BY_PARENT.put(parentPid, children = new LinkedList<>());
|
||||
children.add(pid);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class RemoteUtil {
|
||||
ConcurrentFactoryMap.createMap(new Function<Couple<Class<?>>, Map<Method, Method>>() {
|
||||
@Override
|
||||
public Map<Method, Method> fun(Couple<Class<?>> key) {
|
||||
final THashMap<Method, Method> map = new THashMap<Method, Method>();
|
||||
final THashMap<Method, Method> map = new THashMap<>();
|
||||
for (Method method : key.second.getMethods()) {
|
||||
Method m = null;
|
||||
main:
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
* this class improves on the memory usage by not creating temporary objects inside Disposer.
|
||||
*/
|
||||
public class CompositeDisposable implements Disposable {
|
||||
private final List<Disposable> myDisposables = new ArrayList<Disposable>();
|
||||
private final List<Disposable> myDisposables = new ArrayList<>();
|
||||
private boolean disposed;
|
||||
|
||||
public void add(@NotNull Disposable disposable) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class DisposableWrapper<T extends Disposable> implements Disposable {
|
||||
|
||||
@NotNull
|
||||
protected DisposableWrapper<T> createNewWrapper(@Nullable T object, @NotNull Disposable parent) {
|
||||
return new DisposableWrapper<T>(object, parent);
|
||||
return new DisposableWrapper<>(object, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.lang.ref.WeakReference;
|
||||
* @author eldar
|
||||
*/
|
||||
public class WeaklyReferencedDisposable extends WeakReference<Disposable> implements Disposable {
|
||||
private static final ReferenceQueue<Disposable> ourRefQueue = new ReferenceQueue<Disposable>();
|
||||
private static final ReferenceQueue<Disposable> ourRefQueue = new ReferenceQueue<>();
|
||||
|
||||
public WeaklyReferencedDisposable(@NotNull Disposable disposable) {
|
||||
super(disposable, ourRefQueue);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class JetBrainsProtocolHandler {
|
||||
private static String ourMainParameter = null;
|
||||
private static String ourCommand = null;
|
||||
public static final String REQUIRED_PLUGINS_KEY = "idea.required.plugins.id";
|
||||
private static final Map<String, String> ourParameters = new HashMap<String, String>(0);
|
||||
private static final Map<String, String> ourParameters = new HashMap<>(0);
|
||||
private static boolean initialized = false;
|
||||
|
||||
public static void processJetBrainsLauncherParameters(String url) {
|
||||
|
||||
@@ -408,7 +408,7 @@ public class PathManager {
|
||||
public static void loadProperties() {
|
||||
getHomePath();
|
||||
|
||||
Set<String> paths = new LinkedHashSet<String>();
|
||||
Set<String> paths = new LinkedHashSet<>();
|
||||
paths.add(System.getProperty(PROPERTIES_FILE));
|
||||
paths.add(getCustomPropertiesFile());
|
||||
paths.add(SystemProperties.getUserHome() + '/' + PROPERTIES_FILE_NAME);
|
||||
@@ -534,7 +534,7 @@ public class PathManager {
|
||||
LZ4Factory.class, // lz4-java
|
||||
};
|
||||
|
||||
final Set<String> classPath = new HashSet<String>();
|
||||
final Set<String> classPath = new HashSet<>();
|
||||
for (Class<?> aClass : classes) {
|
||||
final String path = getJarPathForClass(aClass);
|
||||
if (path != null) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FrequentEventDetector {
|
||||
private long myStartedCounting = System.currentTimeMillis();
|
||||
private final AtomicInteger myEventsPosted = new AtomicInteger();
|
||||
private final AtomicInteger myLastTraceId = new AtomicInteger();
|
||||
private final Map<String, Integer> myRecentTraces = new FixedHashMap<String, Integer>(50);
|
||||
private final Map<String, Integer> myRecentTraces = new FixedHashMap<>(50);
|
||||
private final int myEventCountThreshold;
|
||||
private final int myTimeSpanMs;
|
||||
private final Level myLevel;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class LineTokenizer extends LineTokenizerBase<String> {
|
||||
|
||||
@NotNull
|
||||
public String[] execute() {
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
doExecute(lines);
|
||||
return ArrayUtil.toStringArray(lines);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class DiffFragmentBuilder {
|
||||
@NotNull private final DiffString[] mySource2;
|
||||
private int myLastLine1 = 1;
|
||||
private int myLastLine2 = 1;
|
||||
@NotNull private final List<DiffFragment> myData = new LinkedList<DiffFragment>();
|
||||
@NotNull private final List<DiffFragment> myData = new LinkedList<>();
|
||||
|
||||
public DiffFragmentBuilder(@NotNull DiffString[] source1, @NotNull DiffString[] source2) {
|
||||
mySource1 = source1;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class FragmentListImpl implements FragmentList {
|
||||
|
||||
public static ArrayList<Fragment> shift(ArrayList<? extends Fragment> fragments, TextRange rangeShift1, TextRange rangeShift2,
|
||||
int startLine1, int startLine2) {
|
||||
ArrayList<Fragment> newFragments = new ArrayList<Fragment>(fragments.size());
|
||||
ArrayList<Fragment> newFragments = new ArrayList<>(fragments.size());
|
||||
for (Fragment fragment : fragments) {
|
||||
newFragments.add(fragment.shift(rangeShift1, rangeShift2, startLine1, startLine2));
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class BufferedStringList {
|
||||
private final ArrayList<String> myStrings = new ArrayList<String>();
|
||||
private final ArrayList<String> myStrings = new ArrayList<>();
|
||||
private final StringBuffer myLast = new StringBuffer();
|
||||
|
||||
public void add(String string) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
class List2D {
|
||||
private final List<List<DiffFragment>> myRows = new ArrayList<List<DiffFragment>>();
|
||||
private final List<List<DiffFragment>> myRows = new ArrayList<>();
|
||||
private List<DiffFragment> myCurrentRow = null;
|
||||
|
||||
public void add(DiffFragment element) {
|
||||
@@ -32,7 +32,7 @@ class List2D {
|
||||
|
||||
private void ensureRowExists() {
|
||||
if (myCurrentRow == null) {
|
||||
myCurrentRow = new ArrayList<DiffFragment>();
|
||||
myCurrentRow = new ArrayList<>();
|
||||
myRows.add(myCurrentRow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ public class Util {
|
||||
return fragments;
|
||||
}
|
||||
if (secondText.charAt(0) == rightText.charAt(0)) {
|
||||
List<DiffFragment> result = new ArrayList<DiffFragment>();
|
||||
List<DiffFragment> result = new ArrayList<>();
|
||||
result.add(side.createFragment(rightText.substring(0, 1), rightText.substring(0, 1), false));
|
||||
result.add(side.createFragment(null, DiffString.concatenate(rightText.substring(1), secondText.substring(0, 1)), true));
|
||||
result.add(side.createFragment(secondText.substring(1), secondText.substring(1), second.isModified()));
|
||||
|
||||
@@ -25,7 +25,7 @@ public class PatchHunk {
|
||||
private final int myEndLineBefore;
|
||||
private final int myStartLineAfter;
|
||||
private final int myEndLineAfter;
|
||||
private final List<PatchLine> myLines = new ArrayList<PatchLine>();
|
||||
private final List<PatchLine> myLines = new ArrayList<>();
|
||||
|
||||
public PatchHunk(final int startLineBefore, final int endLineBefore, final int startLineAfter, final int endLineAfter) {
|
||||
myStartLineBefore = startLineBefore;
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ByWord implements DiffPolicy {
|
||||
|
||||
@NotNull
|
||||
static Word[] buildWords(@NotNull DiffString text, @NotNull ComparisonPolicy policy) {
|
||||
ArrayList<Word> words = new ArrayList<Word>();
|
||||
ArrayList<Word> words = new ArrayList<>();
|
||||
if (text.isEmpty() || !Character.isWhitespace(text.charAt(0)))
|
||||
words.add(policy.createFormatting(text, TextRange.EMPTY_RANGE));
|
||||
int start = 0;
|
||||
@@ -169,7 +169,7 @@ public class ByWord implements DiffPolicy {
|
||||
}
|
||||
|
||||
private static class FragmentBuilder {
|
||||
private final ArrayList<DiffFragment> myFragments = new ArrayList<DiffFragment>();
|
||||
private final ArrayList<DiffFragment> myFragments = new ArrayList<>();
|
||||
private final Version myVersion1;
|
||||
private final Version myVersion2;
|
||||
private final DiffPolicy.ByChar BY_CHAR;
|
||||
|
||||
@@ -127,7 +127,7 @@ public interface DiffCorrection {
|
||||
}
|
||||
|
||||
class BaseFragmentRunner<ActualRunner extends BaseFragmentRunner> {
|
||||
private final ArrayList<DiffFragment> myItems = new ArrayList<DiffFragment>();
|
||||
private final ArrayList<DiffFragment> myItems = new ArrayList<>();
|
||||
private int myIndex = 0;
|
||||
private DiffFragment[] myFragments;
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import java.util.ArrayList;
|
||||
|
||||
class DummyDiffFragmentsProcessor {
|
||||
public ArrayList<LineFragment> process(String text1, String text2) {
|
||||
ArrayList<LineFragment> lineFragments = new ArrayList<LineFragment>();
|
||||
ArrayList<LineFragment> lineFragments = new ArrayList<>();
|
||||
|
||||
if (text1.isEmpty() && text2.isEmpty()) {
|
||||
return lineFragments;
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class FragmentsCollector {
|
||||
private final ArrayList<Fragment> myFragments = new ArrayList<Fragment>();
|
||||
private final ArrayList<Fragment> myFragments = new ArrayList<>();
|
||||
private int myOffset1 = 0;
|
||||
private int myOffset2 = 0;
|
||||
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class LineFragmentsCollector {
|
||||
private final ArrayList<LineFragment> myLineFragments = new ArrayList<LineFragment>();
|
||||
private final ArrayList<LineFragment> myLineFragments = new ArrayList<>();
|
||||
private int myLine1 = 0;
|
||||
private int myLine2 = 0;
|
||||
private int myOffset1 = 0;
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ public class TextCompareProcessor {
|
||||
DiffString subText1 = lineBlock.getText(diffText1, FragmentSide.SIDE1);
|
||||
DiffString subText2 = lineBlock.getText(diffText2, FragmentSide.SIDE2);
|
||||
ArrayList<LineFragment> subFragments = findSubFragments(subText1, subText2);
|
||||
lineBlock.setChildren(new ArrayList<Fragment>(subFragments));
|
||||
lineBlock.setChildren(new ArrayList<>(subFragments));
|
||||
lineBlock.adjustTypeFromChildrenTypes();
|
||||
}
|
||||
catch (FilesTooBigForDiffException ignore) {
|
||||
|
||||
@@ -334,7 +334,7 @@ public class DiffString extends CharArrayCharSequence {
|
||||
|
||||
@NotNull
|
||||
public DiffString[] execute() {
|
||||
ArrayList<DiffString> lines = new ArrayList<DiffString>();
|
||||
ArrayList<DiffString> lines = new ArrayList<>();
|
||||
doExecute(lines);
|
||||
return lines.toArray(new DiffString[0]);
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DeprecatedDuplicatesIconPathPatcher extends IconPathPatcher {
|
||||
@NonNls private static final Map<String, String> ourDeprecatedIconsReplacements = new HashMap<String, String>();
|
||||
@NonNls private static final Map<String, String> ourDeprecatedIconsReplacements = new HashMap<>();
|
||||
|
||||
static {
|
||||
ourDeprecatedIconsReplacements.put("/actions/prevfile.png", "AllIcons.Actions.Back");
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Disposer {
|
||||
|
||||
static {
|
||||
try {
|
||||
ourTree = new ObjectTree<Disposable>();
|
||||
ourTree = new ObjectTree<>();
|
||||
}
|
||||
catch (NoClassDefFoundError e) {
|
||||
throw new RuntimeException("loader=" + Disposer.class.getClassLoader(), e);
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class IconLoader {
|
||||
}
|
||||
};
|
||||
|
||||
private static final AtomicReference<IconTransform> ourTransform = new AtomicReference<IconTransform>(IconTransform.getDefault());
|
||||
private static final AtomicReference<IconTransform> ourTransform = new AtomicReference<>(IconTransform.getDefault());
|
||||
|
||||
static {
|
||||
installPathPatcher(new DeprecatedDuplicatesIconPathPatcher());
|
||||
@@ -299,7 +299,7 @@ public final class IconLoader {
|
||||
boolean findReflectiveIcon)
|
||||
{
|
||||
if (findReflectiveIcon) {
|
||||
Ref<Icon> reflectiveIcon = new Ref<Icon>(null);
|
||||
Ref<Icon> reflectiveIcon = new Ref<>(null);
|
||||
if (findReflectiveIcon(originalPath, classLoader, reflectiveIcon)) {
|
||||
return reflectiveIcon.get(); // @Nullable
|
||||
}
|
||||
@@ -318,7 +318,7 @@ public final class IconLoader {
|
||||
|
||||
@Nullable
|
||||
public static Icon findIcon(@NotNull String path, @NotNull ClassLoader classLoader) {
|
||||
Ref<Icon> reflectiveIcon = new Ref<Icon>(null);
|
||||
Ref<Icon> reflectiveIcon = new Ref<>(null);
|
||||
if (findReflectiveIcon(path, classLoader, reflectiveIcon)) {
|
||||
return reflectiveIcon.get(); // @Nullable
|
||||
}
|
||||
@@ -641,7 +641,7 @@ public final class IconLoader {
|
||||
|
||||
ImageIcon icon = myScaledIconsCache.getOrScaleIcon(1f);
|
||||
if (icon != null) {
|
||||
myRealIcon = icon.getIconWidth() < 50 && icon.getIconHeight() < 50 ? icon : new SoftReference<ImageIcon>(icon);
|
||||
myRealIcon = icon.getIconWidth() < 50 && icon.getIconHeight() < 50 ? icon : new SoftReference<>(icon);
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
@@ -766,10 +766,11 @@ public final class IconLoader {
|
||||
private class MyScaledIconsCache {
|
||||
private static final int SCALED_ICONS_CACHE_LIMIT = 5;
|
||||
|
||||
private final Map<Couple<Double>, SoftReference<ImageIcon>> scaledIconsCache = Collections.synchronizedMap(new FixedHashMap<Couple<Double>, SoftReference<ImageIcon>>(SCALED_ICONS_CACHE_LIMIT));
|
||||
private final Map<Couple<Double>, SoftReference<ImageIcon>> scaledIconsCache = Collections.synchronizedMap(
|
||||
new FixedHashMap<>(SCALED_ICONS_CACHE_LIMIT));
|
||||
|
||||
private Couple<Double> key(@NotNull ScaleContext ctx) {
|
||||
return new Couple<Double>(ctx.getScale(USR_SCALE) * ctx.getScale(OBJ_SCALE), ctx.getScale(SYS_SCALE));
|
||||
return new Couple<>(ctx.getScale(USR_SCALE) * ctx.getScale(OBJ_SCALE), ctx.getScale(SYS_SCALE));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -790,7 +791,7 @@ public final class IconLoader {
|
||||
icon = checkIcon(image, CachedImageIcon.this);
|
||||
|
||||
if (icon != null && 4L * icon.getIconWidth() * icon.getIconHeight() < ImageLoader.CACHED_IMAGE_MAX_SIZE) {
|
||||
scaledIconsCache.put(key(ctx), new SoftReference<ImageIcon>(icon));
|
||||
scaledIconsCache.put(key(ctx), new SoftReference<>(icon));
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class JDOMExternalizer {
|
||||
|
||||
@NotNull
|
||||
public static List<String> loadStringsList(Element element, String rootName, String attrName) {
|
||||
final List<String> paths = new LinkedList<String>();
|
||||
final List<String> paths = new LinkedList<>();
|
||||
if (element != null) {
|
||||
@NotNull final List list = element.getChildren(rootName);
|
||||
for (Object o : list) {
|
||||
|
||||
@@ -657,7 +657,7 @@ public class JDOMUtil {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> writtenFilesPaths = new ArrayList<String>();
|
||||
List<String> writtenFilesPaths = new ArrayList<>();
|
||||
for (int i = 0; i < newFilePaths.length; i++) {
|
||||
String newFilePath = newFilePaths[i];
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Key<T> {
|
||||
|
||||
@NotNull
|
||||
public static <T> Key<T> create(@NotNull String name) {
|
||||
return new Key<T>(name);
|
||||
return new Key<>(name);
|
||||
}
|
||||
|
||||
public T get(@Nullable UserDataHolder holder) {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class LowMemoryWatcher {
|
||||
ONLY_AFTER_GC
|
||||
}
|
||||
|
||||
private static final WeakList<LowMemoryWatcher> ourListeners = new WeakList<LowMemoryWatcher>();
|
||||
private static final WeakList<LowMemoryWatcher> ourListeners = new WeakList<>();
|
||||
private final Runnable myRunnable;
|
||||
private final LowMemoryWatcherType myType;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class MultiValuesMap<K, V>{
|
||||
|
||||
public MultiValuesMap(boolean ordered) {
|
||||
myOrdered = ordered;
|
||||
myBaseMap = ordered ? new LinkedHashMap<K, Collection<V>>() : new HashMap<K, Collection<V>>();
|
||||
myBaseMap = ordered ? new LinkedHashMap<>() : new HashMap<>();
|
||||
}
|
||||
|
||||
public void putAll(K key, @NotNull Collection<V> values) {
|
||||
@@ -36,7 +36,7 @@ public class MultiValuesMap<K, V>{
|
||||
public void put(K key, V value) {
|
||||
Collection<V> collection = myBaseMap.get(key);
|
||||
if (collection == null) {
|
||||
collection = myOrdered ? new LinkedHashSet<V>() : new HashSet<V>();
|
||||
collection = myOrdered ? new LinkedHashSet<>() : new HashSet<>();
|
||||
myBaseMap.put(key, collection);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class MultiValuesMap<K, V>{
|
||||
|
||||
@NotNull
|
||||
public Collection<V> values() {
|
||||
Set<V> result = myOrdered ? new LinkedHashSet<V>() : new HashSet<V>();
|
||||
Set<V> result = myOrdered ? new LinkedHashSet<>() : new HashSet<>();
|
||||
for (final Collection<V> values : myBaseMap.values()) {
|
||||
result.addAll(values);
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ public class MutualMap<Key, Value> {
|
||||
|
||||
public MutualMap(boolean ordered) {
|
||||
if (ordered) {
|
||||
myKey2Value = new LinkedHashMap<Key, Value>();
|
||||
myValue2Key = new LinkedHashMap<Value, Key>();
|
||||
myKey2Value = new LinkedHashMap<>();
|
||||
myValue2Key = new LinkedHashMap<>();
|
||||
} else {
|
||||
myKey2Value = new HashMap<Key, Value>();
|
||||
myValue2Key = new HashMap<Value, Key>();
|
||||
myKey2Value = new HashMap<>();
|
||||
myValue2Key = new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,6 @@ public class NotNullLazyKey<T,H extends UserDataHolder> extends Key<T>{
|
||||
|
||||
@NotNull
|
||||
public static <T,H extends UserDataHolder> NotNullLazyKey<T,H> create(@NonNls @NotNull String name, @NotNull NotNullFunction<? super H, ? extends T> function) {
|
||||
return new NotNullLazyKey<T,H>(name, function);
|
||||
return new NotNullLazyKey<>(name, function);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,6 @@ public class NullableLazyKey<T,H extends UserDataHolder> extends Key<T>{
|
||||
}
|
||||
|
||||
public static <T,H extends UserDataHolder> NullableLazyKey<T,H> create(@NonNls String name, final NullableFunction<? super H, ? extends T> function) {
|
||||
return new NullableLazyKey<T,H>(name, function);
|
||||
return new NullableLazyKey<>(name, function);
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class RecursionManager {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Object> currentStack() {
|
||||
ArrayList<Object> result = new ArrayList<Object>();
|
||||
ArrayList<Object> result = new ArrayList<>();
|
||||
LinkedHashMap<MyKey, Integer> map = ourStack.get().progressMap;
|
||||
for (MyKey pair : map.keySet()) {
|
||||
if (pair.guardId.equals(id)) {
|
||||
@@ -188,9 +188,9 @@ public class RecursionManager {
|
||||
private int reentrancyCount;
|
||||
private int memoizationStamp;
|
||||
private int depth;
|
||||
private final LinkedHashMap<MyKey, Integer> progressMap = new LinkedHashMap<MyKey, Integer>();
|
||||
private final Set<MyKey> toMemoize = new THashSet<MyKey>();
|
||||
private final THashMap<MyKey, MyKey> key2ReentrancyDuringItsCalculation = new THashMap<MyKey, MyKey>();
|
||||
private final LinkedHashMap<MyKey, Integer> progressMap = new LinkedHashMap<>();
|
||||
private final Set<MyKey> toMemoize = new THashSet<>();
|
||||
private final THashMap<MyKey, MyKey> key2ReentrancyDuringItsCalculation = new THashMap<>();
|
||||
private final Map<MyKey, Map<MyKey, Object>> intermediateCache = ContainerUtil.createSoftMap();
|
||||
private int enters;
|
||||
private int exits;
|
||||
@@ -274,10 +274,10 @@ public class RecursionManager {
|
||||
if (depth == 0) {
|
||||
intermediateCache.clear();
|
||||
if (!key2ReentrancyDuringItsCalculation.isEmpty()) {
|
||||
LOG.error("non-empty key2ReentrancyDuringItsCalculation: " + new HashMap<MyKey, MyKey>(key2ReentrancyDuringItsCalculation));
|
||||
LOG.error("non-empty key2ReentrancyDuringItsCalculation: " + new HashMap<>(key2ReentrancyDuringItsCalculation));
|
||||
}
|
||||
if (!toMemoize.isEmpty()) {
|
||||
LOG.error("non-empty toMemoize: " + new HashSet<MyKey>(toMemoize));
|
||||
LOG.error("non-empty toMemoize: " + new HashSet<>(toMemoize));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ public class RecursionManager {
|
||||
|
||||
private void enableMemoization(MyKey realKey, Set<MyKey> loop) {
|
||||
toMemoize.addAll(loop);
|
||||
List<MyKey> stack = new ArrayList<MyKey>(progressMap.keySet());
|
||||
List<MyKey> stack = new ArrayList<>(progressMap.keySet());
|
||||
|
||||
for (MyKey key : loop) {
|
||||
final MyKey existing = key2ReentrancyDuringItsCalculation.get(key);
|
||||
@@ -309,9 +309,9 @@ public class RecursionManager {
|
||||
throw new AssertionError("zero1");
|
||||
}
|
||||
|
||||
Set<MyKey> loop = new THashSet<MyKey>();
|
||||
Set<MyKey> loop = new THashSet<>();
|
||||
boolean inLoop = false;
|
||||
for (Map.Entry<MyKey, Integer> entry: new ArrayList<Map.Entry<MyKey, Integer>>(progressMap.entrySet())) {
|
||||
for (Map.Entry<MyKey, Integer> entry: new ArrayList<>(progressMap.entrySet())) {
|
||||
if (inLoop) {
|
||||
entry.setValue(reentrancyCount);
|
||||
loop.add(entry.getKey());
|
||||
|
||||
@@ -12,8 +12,8 @@ import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ShutDownTracker implements Runnable {
|
||||
private final List<Thread> myThreads = new ArrayList<Thread>();
|
||||
private final LinkedList<Runnable> myShutdownTasks = new LinkedList<Runnable>();
|
||||
private final List<Thread> myThreads = new ArrayList<>();
|
||||
private final LinkedList<Runnable> myShutdownTasks = new LinkedList<>();
|
||||
private final Thread myThread;
|
||||
|
||||
private ShutDownTracker() {
|
||||
|
||||
@@ -18,13 +18,13 @@ package com.intellij.openapi.util;
|
||||
import java.lang.ref.SoftReference;
|
||||
|
||||
public final class ThreadLocalCachedByteArray {
|
||||
private final ThreadLocal<SoftReference<byte[]>> myThreadLocal = new ThreadLocal<SoftReference<byte[]>>();
|
||||
private final ThreadLocal<SoftReference<byte[]>> myThreadLocal = new ThreadLocal<>();
|
||||
|
||||
public byte[] getBuffer(int size) {
|
||||
byte[] value = com.intellij.reference.SoftReference.dereference(myThreadLocal.get());
|
||||
if (value == null || value.length <= size) {
|
||||
value = new byte[size];
|
||||
myThreadLocal.set(new SoftReference<byte[]>(value));
|
||||
myThreadLocal.set(new SoftReference<>(value));
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
@@ -18,13 +18,13 @@ package com.intellij.openapi.util;
|
||||
import java.lang.ref.SoftReference;
|
||||
|
||||
public final class ThreadLocalCachedIntArray {
|
||||
private final ThreadLocal<SoftReference<int[]>> myThreadLocal = new ThreadLocal<SoftReference<int[]>>();
|
||||
private final ThreadLocal<SoftReference<int[]>> myThreadLocal = new ThreadLocal<>();
|
||||
|
||||
public int[] getBuffer(int size) {
|
||||
int[] value = com.intellij.reference.SoftReference.dereference(myThreadLocal.get());
|
||||
if (value == null || value.length <= size) {
|
||||
value = new int[size];
|
||||
myThreadLocal.set(new SoftReference<int[]>(value));
|
||||
myThreadLocal.set(new SoftReference<>(value));
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
@@ -20,13 +20,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.lang.ref.SoftReference;
|
||||
|
||||
public abstract class ThreadLocalCachedValue<T> {
|
||||
private final ThreadLocal<SoftReference<T>> myThreadLocal = new ThreadLocal<SoftReference<T>>();
|
||||
private final ThreadLocal<SoftReference<T>> myThreadLocal = new ThreadLocal<>();
|
||||
|
||||
public T getValue() {
|
||||
T value = com.intellij.reference.SoftReference.dereference(myThreadLocal.get());
|
||||
if (value == null) {
|
||||
value = create();
|
||||
myThreadLocal.set(new SoftReference<T>(value));
|
||||
myThreadLocal.set(new SoftReference<>(value));
|
||||
}
|
||||
else {
|
||||
init(value);
|
||||
|
||||
@@ -86,7 +86,7 @@ public class TraceableDisposable {
|
||||
@SuppressWarnings("HardCodedStringLiteral")
|
||||
@Override
|
||||
public void printStackTrace(PrintWriter s) {
|
||||
final List<StackTraceElement> stack = new ArrayList<StackTraceElement>(Arrays.asList(CREATE_TRACE.getStackTrace()));
|
||||
final List<StackTraceElement> stack = new ArrayList<>(Arrays.asList(CREATE_TRACE.getStackTrace()));
|
||||
stack.remove(0); // this line is useless it stack
|
||||
s.write(ObjectNotDisposedException.class.getCanonicalName() +
|
||||
": See stack trace responsible for creation of unreleased object below \n\tat " +
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Trinity<A, B, C> {
|
||||
}
|
||||
|
||||
public static <A, B, C> Trinity<A, B, C> create(A first, B second, C third) {
|
||||
return new Trinity<A,B,C>(first, second,third);
|
||||
return new Trinity<>(first, second, third);
|
||||
}
|
||||
|
||||
public static <T> T getFirst(@Nullable Trinity<T, ?, ?> pair) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class UserDataCache<T, Owner extends UserDataHolder, Param> exte
|
||||
}
|
||||
|
||||
public UserDataCache(@NonNls String keyName) {
|
||||
myKey = new Key<T>(keyName);
|
||||
myKey = new Key<>(keyName);
|
||||
}
|
||||
|
||||
public T get(final Owner owner, final Param parameter) {
|
||||
|
||||
@@ -251,7 +251,7 @@ public class FileUtil extends FileUtilRt {
|
||||
total += n;
|
||||
if (count == chars.length) {
|
||||
if (buffers == null) {
|
||||
buffers = new ArrayList<char[]>();
|
||||
buffers = new ArrayList<>();
|
||||
}
|
||||
buffers.add(chars);
|
||||
int newLength = Math.min(1024 * 1024, chars.length * 2);
|
||||
@@ -284,7 +284,7 @@ public class FileUtil extends FileUtilRt {
|
||||
total += n;
|
||||
if (count == bytes.length) {
|
||||
if (buffers == null) {
|
||||
buffers = new ArrayList<byte[]>();
|
||||
buffers = new ArrayList<>();
|
||||
}
|
||||
buffers.add(bytes);
|
||||
int newLength = Math.min(1024 * 1024, bytes.length * 2);
|
||||
@@ -310,7 +310,7 @@ public class FileUtil extends FileUtilRt {
|
||||
|
||||
@NotNull
|
||||
public static Future<Void> asyncDelete(@NotNull Collection<? extends File> files) {
|
||||
List<File> tempFiles = new ArrayList<File>();
|
||||
List<File> tempFiles = new ArrayList<>();
|
||||
for (File file : files) {
|
||||
final File tempFile = renameToTempFileOrDelete(file);
|
||||
if (tempFile != null) {
|
||||
@@ -320,11 +320,11 @@ public class FileUtil extends FileUtilRt {
|
||||
if (!tempFiles.isEmpty()) {
|
||||
return startDeletionThread(tempFiles.toArray(new File[0]));
|
||||
}
|
||||
return new FixedFuture<Void>(null);
|
||||
return new FixedFuture<>(null);
|
||||
}
|
||||
|
||||
private static Future<Void> startDeletionThread(@NotNull final File... tempFiles) {
|
||||
final RunnableFuture<Void> deleteFilesTask = new FutureTask<Void>(new Runnable() {
|
||||
final RunnableFuture<Void> deleteFilesTask = new FutureTask<>(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Thread currentThread = Thread.currentThread();
|
||||
@@ -1140,7 +1140,7 @@ public class FileUtil extends FileUtilRt {
|
||||
@Deprecated
|
||||
public static boolean processFilesRecursively(@NotNull File root, @NotNull Processor<? super File> processor,
|
||||
@Nullable final Processor<? super File> directoryFilter) {
|
||||
final LinkedList<File> queue = new LinkedList<File>();
|
||||
final LinkedList<File> queue = new LinkedList<>();
|
||||
queue.add(root);
|
||||
while (!queue.isEmpty()) {
|
||||
final File file = queue.removeFirst();
|
||||
@@ -1169,7 +1169,7 @@ public class FileUtil extends FileUtilRt {
|
||||
|
||||
@NotNull
|
||||
public static List<File> findFilesByMask(@NotNull Pattern pattern, @NotNull File dir) {
|
||||
final ArrayList<File> found = new ArrayList<File>();
|
||||
final ArrayList<File> found = new ArrayList<>();
|
||||
final File[] files = dir.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
@@ -1186,7 +1186,7 @@ public class FileUtil extends FileUtilRt {
|
||||
|
||||
@NotNull
|
||||
public static List<File> findFilesOrDirsByMask(@NotNull Pattern pattern, @NotNull File dir) {
|
||||
final ArrayList<File> found = new ArrayList<File>();
|
||||
final ArrayList<File> found = new ArrayList<>();
|
||||
final File[] files = dir.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
@@ -1467,7 +1467,7 @@ public class FileUtil extends FileUtilRt {
|
||||
|
||||
@NotNull
|
||||
public static List<String> splitPath(@NotNull String path) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
int index = 0;
|
||||
int nextSeparator;
|
||||
while ((nextSeparator = path.indexOf(File.separatorChar, index)) != -1) {
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.NoSuchElementException;
|
||||
*/
|
||||
public class UniqueNameBuilder<T> {
|
||||
private static final String VFS_SEPARATOR = "/";
|
||||
private final Map<T, String> myPaths = new THashMap<T, String>();
|
||||
private final Map<T, String> myPaths = new THashMap<>();
|
||||
private final String mySeparator;
|
||||
private final int myMaxLength;
|
||||
private final String myRoot;
|
||||
@@ -51,7 +51,7 @@ public class UniqueNameBuilder<T> {
|
||||
Node(String text, Node parentNode) {
|
||||
myText = text;
|
||||
myParentNode = parentNode;
|
||||
myChildren = new THashMap<String, Node>(1);
|
||||
myChildren = new THashMap<>(1);
|
||||
}
|
||||
|
||||
Node findOrAddChild(String word) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class WindowsRegistryUtil {
|
||||
|
||||
@NotNull
|
||||
public static List<String> readRegistryBranch(@NotNull String location) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
StringBuilder output = doReadBranch(location);
|
||||
if (output != null) {
|
||||
for (int pos = output.indexOf(location); pos != -1; pos = output.indexOf(location, pos + location.length())) {
|
||||
@@ -89,7 +89,7 @@ public class WindowsRegistryUtil {
|
||||
|
||||
@NotNull
|
||||
public static List<String> readRegistryBranchValues(@NotNull String location) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
StringBuilder output = doReadBranch(location);
|
||||
if (output != null) {
|
||||
// there seem to be no way to get machine-readable list of value names.
|
||||
|
||||
@@ -66,7 +66,7 @@ final class ObjectNode<T> {
|
||||
void addChild(@NotNull ObjectNode<T> child) {
|
||||
List<ObjectNode<T>> children = myChildren;
|
||||
if (children == null) {
|
||||
myChildren = new SmartList<ObjectNode<T>>(child);
|
||||
myChildren = new SmartList<>(child);
|
||||
}
|
||||
else {
|
||||
children.add(child);
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
public final class ObjectTree<T> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.objectTree.ObjectTree");
|
||||
|
||||
private static final ThreadLocal<Throwable> ourTopmostDisposeTrace = new ThreadLocal<Throwable>();
|
||||
private static final ThreadLocal<Throwable> ourTopmostDisposeTrace = new ThreadLocal<>();
|
||||
|
||||
private final List<ObjectTreeListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
|
||||
@@ -46,8 +46,8 @@ public final class ObjectTree<T> {
|
||||
// Disposable to trace or boolean marker (if trace unavailable)
|
||||
private final Map<T, Object> myDisposedObjects = ContainerUtil.createWeakMap(100, 0.5f, ContainerUtil.identityStrategy()); // guarded by treeLock
|
||||
|
||||
private final List<ObjectNode<T>> myExecutedNodes = new ArrayList<ObjectNode<T>>(); // guarded by myExecutedNodes
|
||||
private final List<T> myExecutedUnregisteredObjects = new ArrayList<T>(); // guarded by myExecutedUnregisteredObjects
|
||||
private final List<ObjectNode<T>> myExecutedNodes = new ArrayList<>(); // guarded by myExecutedNodes
|
||||
private final List<T> myExecutedUnregisteredObjects = new ArrayList<>(); // guarded by myExecutedUnregisteredObjects
|
||||
|
||||
final Object treeLock = new Object();
|
||||
|
||||
@@ -125,7 +125,7 @@ public final class ObjectTree<T> {
|
||||
|
||||
@NotNull
|
||||
private ObjectNode<T> createNodeFor(@NotNull T object, @Nullable ObjectNode<T> parentNode) {
|
||||
final ObjectNode<T> newNode = new ObjectNode<T>(this, parentNode, object, getNextModification());
|
||||
final ObjectNode<T> newNode = new ObjectNode<>(this, parentNode, object, getNextModification());
|
||||
if (parentNode == null) {
|
||||
myRootObjects.add(object);
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public final class ObjectTree<T> {
|
||||
}
|
||||
}
|
||||
else {
|
||||
SmartList<Throwable> exceptions = new SmartList<Throwable>();
|
||||
SmartList<Throwable> exceptions = new SmartList<>();
|
||||
ObjectNode<T> parent;
|
||||
synchronized (treeLock) {
|
||||
parent = node.getParent();
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.Arrays;
|
||||
* 1) too slow and 2) explodes Throwable retained size by polluting Throwable.stackTrace fields.
|
||||
*/
|
||||
public class ThrowableInterner {
|
||||
private static final WeakInterner<Throwable> myTraceInterner = new WeakInterner<Throwable>(new TObjectHashingStrategy<Throwable>() {
|
||||
private static final WeakInterner<Throwable> myTraceInterner = new WeakInterner<>(new TObjectHashingStrategy<Throwable>() {
|
||||
@Override
|
||||
public int computeHashCode(Throwable throwable) {
|
||||
String message = throwable.getMessage();
|
||||
|
||||
@@ -25,9 +25,9 @@ public class Registry {
|
||||
@NonNls
|
||||
public static final String REGISTRY_BUNDLE = "misc.registry";
|
||||
|
||||
private final Map<String, String> myUserProperties = new LinkedHashMap<String, String>();
|
||||
private final ConcurrentMap<String, RegistryValue> myValues = new ConcurrentHashMap<String, RegistryValue>();
|
||||
private final Map<String, RegistryKeyDescriptor> myContributedKeys = new HashMap<String, RegistryKeyDescriptor>();
|
||||
private final Map<String, String> myUserProperties = new LinkedHashMap<>();
|
||||
private final ConcurrentMap<String, RegistryValue> myValues = new ConcurrentHashMap<>();
|
||||
private final Map<String, RegistryKeyDescriptor> myContributedKeys = new HashMap<>();
|
||||
|
||||
private static final Registry ourInstance = new Registry();
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Registry {
|
||||
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
|
||||
if (bundle == null) {
|
||||
bundle = ResourceBundle.getBundle(REGISTRY_BUNDLE);
|
||||
ourBundle = new SoftReference<ResourceBundle>(bundle);
|
||||
ourBundle = new SoftReference<>(bundle);
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class Registry {
|
||||
final ResourceBundle bundle = getBundle();
|
||||
final Enumeration<String> keys = bundle.getKeys();
|
||||
|
||||
List<RegistryValue> result = new ArrayList<RegistryValue>();
|
||||
List<RegistryValue> result = new ArrayList<>();
|
||||
|
||||
Map<String, RegistryKeyDescriptor> contributedKeys = getInstance().myContributedKeys;
|
||||
while (keys.hasMoreElements()) {
|
||||
@@ -168,7 +168,7 @@ public class Registry {
|
||||
}
|
||||
|
||||
void restoreDefaults() {
|
||||
Map<String, String> old = new HashMap<String, String>(myUserProperties);
|
||||
Map<String, String> old = new HashMap<>(myUserProperties);
|
||||
for (String each : old.keySet()) {
|
||||
try {
|
||||
get(each).resetToDefault();
|
||||
|
||||
@@ -53,7 +53,7 @@ public class LineTokenizer {
|
||||
}
|
||||
|
||||
LineTokenizer tokenizer = new LineTokenizer(chars);
|
||||
List<String> lines = new ArrayList<String>();
|
||||
List<String> lines = new ArrayList<>();
|
||||
while(!tokenizer.atEnd()){
|
||||
int offset = tokenizer.getOffset();
|
||||
String line;
|
||||
|
||||
@@ -1270,7 +1270,7 @@ public class StringUtil extends StringUtilRt {
|
||||
if (separator.length() == 0) {
|
||||
return Collections.singletonList(s);
|
||||
}
|
||||
List<CharSequence> result = new ArrayList<CharSequence>();
|
||||
List<CharSequence> result = new ArrayList<>();
|
||||
int pos = 0;
|
||||
while (true) {
|
||||
int index = indexOf(s, separator, pos);
|
||||
@@ -1360,13 +1360,13 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
if (isIdentifierPart && i == text.length() - 1) {
|
||||
if (result == null) {
|
||||
result = new SmartList<String>();
|
||||
result = new SmartList<>();
|
||||
}
|
||||
result.add(text.substring(start, i + 1));
|
||||
}
|
||||
else if (!isIdentifierPart && start != -1) {
|
||||
if (result == null) {
|
||||
result = new SmartList<String>();
|
||||
result = new SmartList<>();
|
||||
}
|
||||
result.add(text.substring(start, i));
|
||||
start = -1;
|
||||
@@ -1393,7 +1393,7 @@ public class StringUtil extends StringUtilRt {
|
||||
@NotNull
|
||||
@Contract(pure = true)
|
||||
public static List<TextRange> getWordIndicesIn(@NotNull String text, @Nullable Set<Character> separatorsSet) {
|
||||
List<TextRange> result = new SmartList<TextRange>();
|
||||
List<TextRange> result = new SmartList<>();
|
||||
int start = -1;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
@@ -1739,7 +1739,7 @@ public class StringUtil extends StringUtilRt {
|
||||
@NotNull
|
||||
@Contract(pure = true)
|
||||
public static List<String> findMatches(@NotNull String s, @NotNull Pattern pattern, int groupIndex) {
|
||||
List<String> result = new SmartList<String>();
|
||||
List<String> result = new SmartList<>();
|
||||
Matcher m = pattern.matcher(s);
|
||||
while (m.find()) {
|
||||
String group = m.group(groupIndex);
|
||||
|
||||
@@ -101,7 +101,7 @@ public class CharsetToolkit {
|
||||
public static final byte[] UTF32LE_BOM = {-1, -2, 0, 0 };
|
||||
@NonNls public static final String FILE_ENCODING_PROPERTY = "file.encoding";
|
||||
|
||||
@NonNls private static final Map<Charset, byte[]> CHARSET_TO_MANDATORY_BOM = new THashMap<Charset, byte[]>(4);
|
||||
@NonNls private static final Map<Charset, byte[]> CHARSET_TO_MANDATORY_BOM = new THashMap<>(4);
|
||||
static {
|
||||
CHARSET_TO_MANDATORY_BOM.put(UTF_16LE_CHARSET, UTF16LE_BOM);
|
||||
CHARSET_TO_MANDATORY_BOM.put(UTF_16BE_CHARSET, UTF16BE_BOM);
|
||||
|
||||
@@ -126,7 +126,7 @@ public class FocusWatcher implements ContainerListener,FocusListener{
|
||||
}
|
||||
|
||||
public final void install(@NotNull Component component){
|
||||
myTopComponent = new WeakReference<Component>(component);
|
||||
myTopComponent = new WeakReference<>(component);
|
||||
installImpl(component);
|
||||
}
|
||||
|
||||
@@ -184,10 +184,10 @@ public class FocusWatcher implements ContainerListener,FocusListener{
|
||||
protected void focusLostImpl(final FocusEvent e){}
|
||||
|
||||
private void setFocusedComponent(final Component focusedComponent) {
|
||||
myFocusedComponent = new WeakReference<Component>(focusedComponent);
|
||||
myFocusedComponent = new WeakReference<>(focusedComponent);
|
||||
}
|
||||
|
||||
private void setNearestFocusableComponent(final Component nearestFocusableComponent) {
|
||||
myNearestFocusableComponent = new WeakReference<Component>(nearestFocusableComponent);
|
||||
myNearestFocusableComponent = new WeakReference<>(nearestFocusableComponent);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class AllOccurrencesMatcher extends MinusculeMatcher {
|
||||
public FList<TextRange> matchingFragments(@NotNull String name) {
|
||||
FList<TextRange> match = delegate.matchingFragments(name);
|
||||
if (!ContainerUtil.isEmpty(match)) {
|
||||
List<FList<TextRange>> allMatchesReversed = new ArrayList<FList<TextRange>>();
|
||||
List<FList<TextRange>> allMatchesReversed = new ArrayList<>();
|
||||
int lastOffset = 0;
|
||||
while (!ContainerUtil.isEmpty(match)) {
|
||||
FList<TextRange> reversedWithAbsoluteOffsets = FList.emptyList();
|
||||
|
||||
@@ -30,7 +30,7 @@ public class NameUtil {
|
||||
|
||||
@NotNull
|
||||
public static String[] nameToWords(@NotNull String name){
|
||||
List<String> array = new ArrayList<String>();
|
||||
List<String> array = new ArrayList<>();
|
||||
int index = 0;
|
||||
|
||||
while(index < name.length()){
|
||||
@@ -228,7 +228,7 @@ public class NameUtil {
|
||||
@NotNull
|
||||
public static String[] splitNameIntoWords(@NotNull String name) {
|
||||
final String[] underlineDelimited = name.split("_");
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String word : underlineDelimited) {
|
||||
addAllWords(word, result);
|
||||
}
|
||||
@@ -242,7 +242,7 @@ public class NameUtil {
|
||||
boolean upperCaseStyle,
|
||||
boolean preferLongerNames,
|
||||
boolean isArray) {
|
||||
ArrayList<String> answer = new ArrayList<String>();
|
||||
ArrayList<String> answer = new ArrayList<>();
|
||||
String[] words = nameToWords(name);
|
||||
|
||||
for (int step = 0; step < words.length; step++) {
|
||||
|
||||
@@ -753,7 +753,7 @@ class TypoTolerantMatcher extends MinusculeMatcher {
|
||||
}
|
||||
|
||||
void addError(int index, @NotNull Error error) {
|
||||
if (myErrors == null) myErrors = new SmartList<Pair<Integer, Error>>();
|
||||
if (myErrors == null) myErrors = new SmartList<>();
|
||||
Pair<Integer, Error> pair = Pair.create(index, error);
|
||||
myErrors.add(pair);
|
||||
|
||||
@@ -871,7 +871,7 @@ class TypoTolerantMatcher extends MinusculeMatcher {
|
||||
}
|
||||
|
||||
public int length(char[] pattern) {
|
||||
final Ref<Integer> ref = new Ref<Integer>(pattern.length);
|
||||
final Ref<Integer> ref = new Ref<>(pattern.length);
|
||||
processErrors(0, Integer.MAX_VALUE, new Processor<Pair<Integer, Error>>() {
|
||||
@Override
|
||||
public boolean process(Pair<Integer, Error> error) {
|
||||
|
||||
@@ -348,7 +348,7 @@ public class JBColor extends Color {
|
||||
return namedColor("Borders.color", new JBColor(Gray._192, Gray._50));
|
||||
}
|
||||
|
||||
private static final Map<String, Color> defaultThemeColors = new HashMap<String, Color>();
|
||||
private static final Map<String, Color> defaultThemeColors = new HashMap<>();
|
||||
|
||||
@NotNull
|
||||
public static Color get(@NotNull final String colorId, @NotNull final Color defaultColor) {
|
||||
|
||||
@@ -80,10 +80,10 @@ public class TableUtil {
|
||||
}
|
||||
|
||||
if (table.getSelectionModel().isSelectionEmpty()) {
|
||||
return new ArrayList<Object[]>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
final List<Object[]> removedItems = new SmartList<Object[]>();
|
||||
final List<Object[]> removedItems = new SmartList<>();
|
||||
final ItemRemovable itemRemovable = (ItemRemovable)model;
|
||||
final int columnCount = model.getColumnCount();
|
||||
doRemoveSelectedItems(table, new ItemRemovable() {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class UIBundle {
|
||||
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
|
||||
if (bundle == null) {
|
||||
bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE);
|
||||
ourBundle = new SoftReference<ResourceBundle>(bundle);
|
||||
ourBundle = new SoftReference<>(bundle);
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Foundation {
|
||||
// May be removed if we use toStringViaUTF16
|
||||
System.setProperty("jna.encoding", "UTF8");
|
||||
|
||||
Map<String, Object> foundationOptions = new HashMap<String, Object>();
|
||||
Map<String, Object> foundationOptions = new HashMap<>();
|
||||
//foundationOptions.put(Library.OPTION_TYPE_MAPPER, FoundationTypeMapper.INSTANCE);
|
||||
|
||||
myFoundationLibrary = Native.loadLibrary("Foundation", FoundationLibrary.class, foundationOptions);
|
||||
@@ -273,7 +273,7 @@ public class Foundation {
|
||||
}
|
||||
|
||||
private static Callback ourRunnableCallback;
|
||||
private static final Map<String, RunnableInfo> ourMainThreadRunnables = new HashMap<String, RunnableInfo>();
|
||||
private static final Map<String, RunnableInfo> ourMainThreadRunnables = new HashMap<>();
|
||||
private static long ourCurrentRunnableCount = 0;
|
||||
private static final Object RUNNABLE_LOCK = new Object();
|
||||
|
||||
@@ -375,7 +375,7 @@ public class Foundation {
|
||||
|
||||
@NotNull
|
||||
public static Map<String, String> toStringMap(@Nullable ID delegate) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
Map<String, String> result = new HashMap<>();
|
||||
if (isNil(delegate)) {
|
||||
return result;
|
||||
}
|
||||
@@ -418,7 +418,7 @@ public class Foundation {
|
||||
|
||||
@NotNull
|
||||
public List<ID> getList() {
|
||||
List<ID> result = new ArrayList<ID>();
|
||||
List<ID> result = new ArrayList<>();
|
||||
for (int i = 0; i < count(); i++) {
|
||||
result.add(at(i));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class NSDefaults {
|
||||
public static final String ourTouchBarShowFnValue = "functionKeys";
|
||||
|
||||
private static class Path {
|
||||
private final @NotNull ArrayList<Node> myPath = new ArrayList<Node>();
|
||||
private final @NotNull ArrayList<Node> myPath = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -283,7 +283,7 @@ public class NSDefaults {
|
||||
|
||||
// for debug
|
||||
private List<String> _listAllKeys() {
|
||||
List<String> res = new ArrayList<String>(100);
|
||||
List<String> res = new ArrayList<>(100);
|
||||
final Foundation.NSAutoreleasePool pool = new Foundation.NSAutoreleasePool();
|
||||
try {
|
||||
final ID defaults = Foundation.invoke("NSUserDefaults", "standardUserDefaults");
|
||||
|
||||
@@ -398,7 +398,7 @@ public class LinePainter2D {
|
||||
sizeWithStroke = sw_1 + prefSize + sw_2;
|
||||
}
|
||||
_xy -= (pm == ParityMode.ODD ? sizeWithStroke - PaintUtil.devPixel(g) : sizeWithStroke) / 2 - sw_1;
|
||||
return new Pair<Double, Double>(_xy, prefSize);
|
||||
return new Pair<>(_xy, prefSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ public class CollectConsumer<T> implements Consumer<T> {
|
||||
}
|
||||
|
||||
public CollectConsumer() {
|
||||
this(new SmartList<T>());
|
||||
this(new SmartList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class CommonProcessors {
|
||||
}
|
||||
|
||||
public CollectProcessor() {
|
||||
myCollection = new ArrayList<T>();
|
||||
myCollection = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +79,7 @@ public class CommonProcessors {
|
||||
private final Set<T> myCollection;
|
||||
|
||||
public CollectUniquesProcessor() {
|
||||
myCollection = new HashSet<T>();
|
||||
myCollection = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,7 +109,7 @@ public class CommonProcessors {
|
||||
|
||||
public UniqueProcessor(@NotNull Processor<? super T> delegate, @NotNull TObjectHashingStrategy<T> strategy) {
|
||||
myDelegate = delegate;
|
||||
processed = new THashSet<T>(strategy);
|
||||
processed = new THashSet<>(strategy);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ComponentTreeEventDispatcher<T extends EventListener> {
|
||||
}
|
||||
|
||||
public static <T extends EventListener> ComponentTreeEventDispatcher<T> create(@Nullable Component root, @NotNull Class<T> listenerClass) {
|
||||
return new ComponentTreeEventDispatcher<T>(root, listenerClass);
|
||||
return new ComponentTreeEventDispatcher<>(root, listenerClass);
|
||||
}
|
||||
|
||||
private ComponentTreeEventDispatcher(@Nullable final Component root, @NotNull Class<T> listenerClass) {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ConcurrencyUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Future<T>> futures = new ArrayList<Future<T>>(tasks.size());
|
||||
List<Future<T>> futures = new ArrayList<>(tasks.size());
|
||||
boolean done = false;
|
||||
try {
|
||||
for (Callable<T> t : tasks) {
|
||||
@@ -115,7 +115,7 @@ public class ConcurrencyUtil {
|
||||
@NotNull
|
||||
public static ThreadPoolExecutor newSingleThreadExecutor(@NonNls @NotNull String name, int priority) {
|
||||
return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(), newNamedThreadFactory(name, true, priority));
|
||||
new LinkedBlockingQueue<>(), newNamedThreadFactory(name, true, priority));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -59,7 +59,7 @@ public class EnvironmentUtil {
|
||||
});
|
||||
}
|
||||
else {
|
||||
ourEnvGetter = new FixedFuture<Map<String, String>>(getSystemEnv());
|
||||
ourEnvGetter = new FixedFuture<>(getSystemEnv());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class EnvironmentUtil {
|
||||
|
||||
private static Map<String, String> getSystemEnv() {
|
||||
if (SystemInfo.isWindows) {
|
||||
return unmodifiableMap(new THashMap<String, String>(System.getenv(), CaseInsensitiveStringHashingStrategy.INSTANCE));
|
||||
return unmodifiableMap(new THashMap<>(System.getenv(), CaseInsensitiveStringHashingStrategy.INSTANCE));
|
||||
}
|
||||
else {
|
||||
return System.getenv();
|
||||
@@ -214,7 +214,7 @@ public class EnvironmentUtil {
|
||||
protected Pair<String, Map<String, String>> readBatOutputAndEnv(@NotNull File batchFile, List<String> args) throws Exception {
|
||||
File envFile = FileUtil.createTempFile("intellij-cmd-env.", ".tmp", false);
|
||||
try {
|
||||
List<String> cl = new ArrayList<String>();
|
||||
List<String> cl = new ArrayList<>();
|
||||
cl.add(CommandLineUtil.getWinShellName());
|
||||
cl.add("/c");
|
||||
cl.add("call");
|
||||
@@ -311,9 +311,9 @@ public class EnvironmentUtil {
|
||||
|
||||
@NotNull
|
||||
public static Map<String, String> parseEnv(String... lines) throws Exception {
|
||||
Set<String> toIgnore = new HashSet<String>(Arrays.asList("_", "PWD", "SHLVL", DISABLE_OMZ_AUTO_UPDATE, INTELLIJ_ENVIRONMENT_READER));
|
||||
Set<String> toIgnore = new HashSet<>(Arrays.asList("_", "PWD", "SHLVL", DISABLE_OMZ_AUTO_UPDATE, INTELLIJ_ENVIRONMENT_READER));
|
||||
Map<String, String> env = System.getenv();
|
||||
Map<String, String> newEnv = new HashMap<String, String>();
|
||||
Map<String, String> newEnv = new HashMap<>();
|
||||
|
||||
for (String line : lines) {
|
||||
int pos = line.indexOf('=');
|
||||
|
||||
@@ -34,18 +34,18 @@ public class EventDispatcher<T extends EventListener> {
|
||||
|
||||
@NotNull
|
||||
public static <T extends EventListener> EventDispatcher<T> create(@NotNull Class<T> listenerClass) {
|
||||
return new EventDispatcher<T>(listenerClass, null);
|
||||
return new EventDispatcher<>(listenerClass, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T extends EventListener> EventDispatcher<T> create(@NotNull Class<T> listenerClass, @NotNull Map<String, Object> methodReturnValues) {
|
||||
assertNonVoidMethodReturnValuesAreDeclared(methodReturnValues, listenerClass);
|
||||
return new EventDispatcher<T>(listenerClass, methodReturnValues);
|
||||
return new EventDispatcher<>(listenerClass, methodReturnValues);
|
||||
}
|
||||
|
||||
private static void assertNonVoidMethodReturnValuesAreDeclared(@NotNull Map<String, Object> methodReturnValues,
|
||||
@NotNull Class<?> listenerClass) {
|
||||
List<Method> declared = new ArrayList<Method>(ReflectionUtil.getClassPublicMethods(listenerClass));
|
||||
List<Method> declared = new ArrayList<>(ReflectionUtil.getClassPublicMethods(listenerClass));
|
||||
for (final Map.Entry<String, Object> entry : methodReturnValues.entrySet()) {
|
||||
final String methodName = entry.getKey();
|
||||
Method found = ContainerUtil.find(declared, new Condition<Method>() {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class FieldAccessor<E, T> {
|
||||
public boolean isAvailable() {
|
||||
if (myFieldRef == null) {
|
||||
try {
|
||||
myFieldRef = new Ref<Field>();
|
||||
myFieldRef = new Ref<>();
|
||||
myFieldRef.set(myClass.getDeclaredField(myName));
|
||||
myFieldRef.get().setAccessible(true);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ListWithSelection<E> extends ArrayList<E> {
|
||||
}
|
||||
|
||||
public ListWithSelection() {
|
||||
this(new ArrayList<E>());
|
||||
this(new ArrayList<>());
|
||||
}
|
||||
|
||||
public boolean select(E object){
|
||||
|
||||
@@ -45,7 +45,7 @@ public class NewInstanceFactory<T> implements Factory<T> {
|
||||
|
||||
public static <T> Factory<T> fromClass(@NotNull final Class<? extends T> clazz) {
|
||||
try {
|
||||
return new NewInstanceFactory<T>(clazz.getConstructor(ArrayUtil.EMPTY_CLASS_ARRAY), ArrayUtil.EMPTY_OBJECT_ARRAY);
|
||||
return new NewInstanceFactory<>(clazz.getConstructor(ArrayUtil.EMPTY_CLASS_ARRAY), ArrayUtil.EMPTY_OBJECT_ARRAY);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
return new Factory<T>() {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ProcessingContext {
|
||||
}
|
||||
|
||||
private void checkMapInitialized() {
|
||||
if (myMap == null) myMap = new HashMap<Object, Object>(1);
|
||||
if (myMap == null) myMap = new HashMap<>(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ public class ReflectionUtil {
|
||||
|
||||
Constructor<?>[] constructors = aClass.getDeclaredConstructors();
|
||||
Exception exception = null;
|
||||
List<Constructor<?>> defaultCtors = new SmartList<Constructor<?>>();
|
||||
List<Constructor<?>> defaultCtors = new SmartList<>();
|
||||
ctorLoop:
|
||||
for (Constructor<?> constructor : constructors) {
|
||||
try {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ResourceUtil {
|
||||
*/
|
||||
@NotNull
|
||||
private static List<String> calculateBundleNames(@NotNull String baseName, @NotNull Locale locale) {
|
||||
final List<String> result = new ArrayList<String>(3);
|
||||
final List<String> result = new ArrayList<>(3);
|
||||
|
||||
result.add(0, baseName);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SingletonSet<E> implements Set<E> {
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new SingletonIterator<E>(theElement);
|
||||
return new SingletonIterator<>(theElement);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -125,7 +125,7 @@ public class SingletonSet<E> implements Set<E> {
|
||||
|
||||
@NotNull
|
||||
public static <T> Set<T> withCustomStrategy(T o, @NotNull TObjectHashingStrategy<T> strategy) {
|
||||
return new CustomStrategySingletonSet<T>(o, strategy);
|
||||
return new CustomStrategySingletonSet<>(o, strategy);
|
||||
}
|
||||
|
||||
private static class CustomStrategySingletonSet<E> extends SingletonSet<E> {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class SmartFMap<K,V> implements Map<K,V> {
|
||||
}
|
||||
|
||||
public SmartFMap<K, V> plus(@NotNull K key, V value) {
|
||||
return new SmartFMap<K, V>(doPlus(myMap, key, value));
|
||||
return new SmartFMap<>(doPlus(myMap, key, value));
|
||||
}
|
||||
|
||||
private static Object doPlus(Object oldMap, Object key, Object value) {
|
||||
@@ -65,7 +65,7 @@ public class SmartFMap<K,V> implements Map<K,V> {
|
||||
|
||||
public SmartFMap<K, V> minus(@NotNull K key) {
|
||||
if (myMap instanceof Map) {
|
||||
THashMap<K, V> newMap = new THashMap<K, V>((Map<K, V>)myMap);
|
||||
THashMap<K, V> newMap = new THashMap<>((Map<K, V>)myMap);
|
||||
newMap.remove(key);
|
||||
if (newMap.size() <= ARRAY_THRESHOLD) {
|
||||
Object[] newArray = new Object[newMap.size() * 2];
|
||||
@@ -74,10 +74,10 @@ public class SmartFMap<K,V> implements Map<K,V> {
|
||||
newArray[i++] = k;
|
||||
newArray[i++] = newMap.get(k);
|
||||
}
|
||||
return new SmartFMap<K, V>(newArray);
|
||||
return new SmartFMap<>(newArray);
|
||||
}
|
||||
|
||||
return new SmartFMap<K, V>(newMap);
|
||||
return new SmartFMap<>(newMap);
|
||||
}
|
||||
|
||||
Object[] array = (Object[])myMap;
|
||||
@@ -90,7 +90,7 @@ public class SmartFMap<K,V> implements Map<K,V> {
|
||||
Object[] newArray = new Object[array.length - 2];
|
||||
System.arraycopy(array, 0, newArray, 0, i);
|
||||
System.arraycopy(array, i + 2, newArray, i, array.length - i - 2);
|
||||
return new SmartFMap<K, V>(newArray);
|
||||
return new SmartFMap<>(newArray);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@@ -206,7 +206,7 @@ public class SmartFMap<K,V> implements Map<K,V> {
|
||||
public Set<K> keySet() {
|
||||
if (isEmpty()) return Collections.emptySet();
|
||||
|
||||
LinkedHashSet<K> result = new LinkedHashSet<K>();
|
||||
LinkedHashSet<K> result = new LinkedHashSet<>();
|
||||
for (Entry<K, V> entry : entrySet()) {
|
||||
result.add(entry.getKey());
|
||||
}
|
||||
@@ -218,7 +218,7 @@ public class SmartFMap<K,V> implements Map<K,V> {
|
||||
public Collection<V> values() {
|
||||
if (isEmpty()) return Collections.emptyList();
|
||||
|
||||
ArrayList<V> result = new ArrayList<V>();
|
||||
ArrayList<V> result = new ArrayList<>();
|
||||
for (Entry<K, V> entry : entrySet()) {
|
||||
result.add(entry.getValue());
|
||||
}
|
||||
@@ -249,15 +249,15 @@ public class SmartFMap<K,V> implements Map<K,V> {
|
||||
public Set<Entry<K, V>> entrySet() {
|
||||
if (isEmpty()) return Collections.emptySet();
|
||||
|
||||
LinkedHashSet<Entry<K, V>> set = new LinkedHashSet<Entry<K, V>>();
|
||||
LinkedHashSet<Entry<K, V>> set = new LinkedHashSet<>();
|
||||
if (myMap instanceof Map) {
|
||||
for (Entry<K, V> entry : ((Map<K, V>)myMap).entrySet()) {
|
||||
set.add(new AbstractMap.SimpleImmutableEntry<K, V>(entry));
|
||||
set.add(new AbstractMap.SimpleImmutableEntry<>(entry));
|
||||
}
|
||||
} else {
|
||||
Object[] array = (Object[])myMap;
|
||||
for (int i = 0; i < array.length; i += 2) {
|
||||
set.add(new AbstractMap.SimpleImmutableEntry<K, V>((K)array[i], (V)array[i + 1]));
|
||||
set.add(new AbstractMap.SimpleImmutableEntry<>((K)array[i], (V)array[i + 1]));
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableSet(set);
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext")
|
||||
abstract class Timed<T> implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.Timed");
|
||||
private static final Map<Timed, Boolean> ourReferences = Collections.synchronizedMap(new WeakHashMap<Timed, Boolean>());
|
||||
private static final Map<Timed, Boolean> ourReferences = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
protected static final int SERVICE_DELAY = 60;
|
||||
|
||||
private int myLastCheckedAccessCount;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
public class TreeItem <Data> {
|
||||
private Data myData;
|
||||
private TreeItem<Data> myParent;
|
||||
private final List<TreeItem<Data>> myChildren = new ArrayList<TreeItem<Data>>();
|
||||
private final List<TreeItem<Data>> myChildren = new ArrayList<>();
|
||||
|
||||
public TreeItem(Data data) {
|
||||
myData = data;
|
||||
|
||||
@@ -26,7 +26,7 @@ public abstract class WeakListener<Src, Listener> implements InvocationHandler{
|
||||
|
||||
protected WeakListener(Src source, Class<Listener> listenerInterface, Listener listenerImpl) {
|
||||
mySource = source;
|
||||
myDelegate = new WeakReference<Listener>(listenerImpl);
|
||||
myDelegate = new WeakReference<>(listenerImpl);
|
||||
final ClassLoader classLoader = listenerImpl.getClass().getClassLoader();
|
||||
final Listener proxy = (Listener)Proxy.newProxyInstance(classLoader, new Class[]{listenerInterface}, this);
|
||||
addListener(source, proxy);
|
||||
|
||||
@@ -139,7 +139,7 @@ public class AppScheduledExecutorService extends SchedulingWrapper {
|
||||
|
||||
private static class BackendThreadPoolExecutor extends ThreadPoolExecutor {
|
||||
BackendThreadPoolExecutor(@NotNull ThreadFactory factory) {
|
||||
super(1, Integer.MAX_VALUE, 1, TimeUnit.MINUTES, new SynchronousQueue<Runnable>(), factory);
|
||||
super(1, Integer.MAX_VALUE, 1, TimeUnit.MINUTES, new SynchronousQueue<>(), factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,17 +47,17 @@ public class AtomicFieldUpdater<ContainingClass, FieldType> {
|
||||
|
||||
@NotNull
|
||||
public static <T, V> AtomicFieldUpdater<T, V> forFieldOfType(@NotNull Class<T> ownerClass, @NotNull Class<V> fieldType) {
|
||||
return new AtomicFieldUpdater<T, V>(ownerClass, fieldType);
|
||||
return new AtomicFieldUpdater<>(ownerClass, fieldType);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> AtomicFieldUpdater<T, Long> forLongFieldIn(@NotNull Class<T> ownerClass) {
|
||||
return new AtomicFieldUpdater<T, Long>(ownerClass, long.class);
|
||||
return new AtomicFieldUpdater<>(ownerClass, long.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> AtomicFieldUpdater<T, Integer> forIntFieldIn(@NotNull Class<T> ownerClass) {
|
||||
return new AtomicFieldUpdater<T, Integer>(ownerClass, int.class);
|
||||
return new AtomicFieldUpdater<>(ownerClass, int.class);
|
||||
}
|
||||
|
||||
private AtomicFieldUpdater(@NotNull Class<ContainingClass> ownerClass, @NotNull Class<FieldType> fieldType) {
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package com.intellij.util.concurrency;
|
||||
|
||||
import java.util.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
@@ -37,7 +37,7 @@ public class BlockingSet<T> {
|
||||
private final Lock lock;
|
||||
|
||||
public BlockingSet() {
|
||||
set = new HashSet<T>();
|
||||
set = new HashSet<>();
|
||||
lock = new ReentrantLock();
|
||||
unlock = lock.newCondition();
|
||||
}
|
||||
@@ -78,6 +78,6 @@ public class BlockingSet<T> {
|
||||
}
|
||||
|
||||
public static <T> BlockingSet<T> newInstance() {
|
||||
return new BlockingSet<T>();
|
||||
return new BlockingSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class BoundedTaskExecutor extends AbstractExecutorService {
|
||||
// low 32 bits: number of tasks running (or trying to run)
|
||||
// high 32 bits: myTaskQueue modification stamp
|
||||
private final AtomicLong myStatus = new AtomicLong();
|
||||
private final BlockingQueue<Runnable> myTaskQueue = new LinkedBlockingQueue<Runnable>();
|
||||
private final BlockingQueue<Runnable> myTaskQueue = new LinkedBlockingQueue<>();
|
||||
|
||||
BoundedTaskExecutor(@NotNull @Nls(capitalization = Nls.Capitalization.Title) String name, @NotNull Executor backendExecutor, int maxThreads) {
|
||||
myName = name;
|
||||
@@ -187,7 +187,7 @@ public class BoundedTaskExecutor extends AbstractExecutorService {
|
||||
|
||||
private void wrapAndExecute(@NotNull final Runnable firstTask, final long status) {
|
||||
try {
|
||||
final AtomicReference<Runnable> currentTask = new AtomicReference<Runnable>(firstTask);
|
||||
final AtomicReference<Runnable> currentTask = new AtomicReference<>(firstTask);
|
||||
myBackendExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -282,7 +282,7 @@ public class BoundedTaskExecutor extends AbstractExecutorService {
|
||||
|
||||
@NotNull
|
||||
public List<Runnable> clearAndCancelAll() {
|
||||
List<Runnable> queued = new ArrayList<Runnable>();
|
||||
List<Runnable> queued = new ArrayList<>();
|
||||
myTaskQueue.drainTo(queued);
|
||||
for (Runnable task : queued) {
|
||||
if (task instanceof FutureTask) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class FixedFuture<T> implements Future<T> {
|
||||
}
|
||||
|
||||
public static <T> FixedFuture<T> completeExceptionally(@NotNull Throwable throwable) {
|
||||
return new FixedFuture<T>(throwable);
|
||||
return new FixedFuture<>(throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -69,7 +69,7 @@ class SchedulingWrapper implements ScheduledExecutorService {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
delayQueue.removeAll(new HashSet<MyScheduledFutureTask>(result));
|
||||
delayQueue.removeAll(new HashSet<>(result));
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("Shutdown. Drained tasks: "+result);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class SchedulingWrapper implements ScheduledExecutorService {
|
||||
@Override
|
||||
public boolean awaitTermination(long timeout, @NotNull TimeUnit unit) throws InterruptedException {
|
||||
if (!isShutdown()) throw new IllegalStateException("must await termination after shutdown() or shutdownNow() only");
|
||||
List<MyScheduledFutureTask> tasks = new ArrayList<MyScheduledFutureTask>(delayQueue);
|
||||
List<MyScheduledFutureTask> tasks = new ArrayList<>(delayQueue);
|
||||
for (MyScheduledFutureTask task : tasks) {
|
||||
if (task.getBackendExecutorService() != backendExecutorService) {
|
||||
continue;
|
||||
@@ -321,7 +321,7 @@ class SchedulingWrapper implements ScheduledExecutorService {
|
||||
public <V> ScheduledFuture<V> schedule(@NotNull Callable<V> callable,
|
||||
long delay,
|
||||
@NotNull TimeUnit unit) {
|
||||
MyScheduledFutureTask<V> t = new MyScheduledFutureTask<V>(callable, triggerTime(delayQueue, delay, unit));
|
||||
MyScheduledFutureTask<V> t = new MyScheduledFutureTask<>(callable, triggerTime(delayQueue, delay, unit));
|
||||
return delayedExecute(t);
|
||||
}
|
||||
|
||||
@@ -343,10 +343,10 @@ class SchedulingWrapper implements ScheduledExecutorService {
|
||||
if (delay <= 0) {
|
||||
throw new IllegalArgumentException("delay must be positive but got: "+delay);
|
||||
}
|
||||
MyScheduledFutureTask<Void> sft = new MyScheduledFutureTask<Void>(command,
|
||||
null,
|
||||
triggerTime(delayQueue, initialDelay, unit),
|
||||
unit.toNanos(-delay));
|
||||
MyScheduledFutureTask<Void> sft = new MyScheduledFutureTask<>(command,
|
||||
null,
|
||||
triggerTime(delayQueue, initialDelay, unit),
|
||||
unit.toNanos(-delay));
|
||||
return delayedExecute(sft);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ArrayListSet<E> extends AbstractSet<E> {
|
||||
private final List<E> myList = new ArrayList<E>();
|
||||
private final List<E> myList = new ArrayList<>();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,7 @@ public class BiDirectionalEnumerator<T> extends Enumerator<T> {
|
||||
public BiDirectionalEnumerator(int expectNumber, @NotNull TObjectHashingStrategy<T> strategy) {
|
||||
super(expectNumber, strategy);
|
||||
|
||||
myIntToObjectMap = new TIntObjectHashMap<T>(expectNumber);
|
||||
myIntToObjectMap = new TIntObjectHashMap<>(expectNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.HashMap;
|
||||
import java.util.*;
|
||||
|
||||
public class BidirectionalMap<K,V> implements Map<K,V>{
|
||||
private final Map<K,V> myKeyToValueMap = new THashMap<K,V>();
|
||||
private final Map<V,List<K>> myValueToKeysMap = new THashMap<V,List<K>>();
|
||||
private final Map<K,V> myKeyToValueMap = new THashMap<>();
|
||||
private final Map<V,List<K>> myValueToKeysMap = new THashMap<>();
|
||||
|
||||
@Override
|
||||
public V put(K key, V value){
|
||||
@@ -38,7 +38,7 @@ public class BidirectionalMap<K,V> implements Map<K,V>{
|
||||
|
||||
List<K> array = myValueToKeysMap.get(value);
|
||||
if (array == null){
|
||||
array = new ArrayList<K>();
|
||||
array = new ArrayList<>();
|
||||
myValueToKeysMap.put(value, array);
|
||||
}
|
||||
array.add(key);
|
||||
@@ -130,6 +130,6 @@ public class BidirectionalMap<K,V> implements Map<K,V>{
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new HashMap<K,V>(myKeyToValueMap).toString();
|
||||
return new HashMap<>(myKeyToValueMap).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class BidirectionalMultiMap<K, V> {
|
||||
private final Map<V, Set<K>> myValue2Keys;
|
||||
|
||||
public BidirectionalMultiMap() {
|
||||
this(new java.util.HashMap<K, Set<V>>(), new HashMap<V, Set<K>>());
|
||||
this(new java.util.HashMap<>(), new HashMap<>());
|
||||
}
|
||||
|
||||
public BidirectionalMultiMap(final Map<K, Set<V>> key2Values, final Map<V, Set<K>> value2Keys) {
|
||||
@@ -76,12 +76,12 @@ public class BidirectionalMultiMap<K, V> {
|
||||
|
||||
@NotNull
|
||||
protected Set<V> createValuesSet() {
|
||||
return new HashSet<V>();
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected Set<K> createKeysSet() {
|
||||
return new java.util.HashSet<K>();
|
||||
return new java.util.HashSet<>();
|
||||
}
|
||||
|
||||
public boolean removeKey(K key) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ClassMap<T> {
|
||||
protected final Map<Class, T> myMap;
|
||||
|
||||
public ClassMap() {
|
||||
this(new THashMap<Class, T>());
|
||||
this(new THashMap<>());
|
||||
}
|
||||
protected ClassMap(@NotNull Map<Class, T> map) {
|
||||
myMap = map;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ConcurrentBitSet {
|
||||
* Each long word stores next 64 bits part of the set.
|
||||
* Therefore the i-th bit of the set is stored in {@code arrays.get(arrayIndex(i)).get(wordIndexInArray(i))} word in the {@code 1L << i} position.
|
||||
*/
|
||||
private final AtomicReferenceArray<AtomicLongArray> arrays = new AtomicReferenceArray<AtomicLongArray>(32);
|
||||
private final AtomicReferenceArray<AtomicLongArray> arrays = new AtomicReferenceArray<>(32);
|
||||
private static int arrayIndex(int bitIndex) {
|
||||
int i = (bitIndex >> ADDRESS_BITS_PER_WORD) + 1;
|
||||
return 31 - Integer.numberOfLeadingZeros(i);
|
||||
|
||||
@@ -88,7 +88,7 @@ public abstract class ConcurrentFactoryMap<K,V> implements ConcurrentMap<K,V> {
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
return new CollectionWrapper.Set<K>(myMap.keySet());
|
||||
return new CollectionWrapper.Set<>(myMap.keySet());
|
||||
}
|
||||
|
||||
public boolean removeValue(Object value) {
|
||||
@@ -127,7 +127,7 @@ public abstract class ConcurrentFactoryMap<K,V> implements ConcurrentMap<K,V> {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
return new CollectionWrapper<V>(myMap.values());
|
||||
return new CollectionWrapper<>(myMap.values());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -141,7 +141,7 @@ public abstract class ConcurrentFactoryMap<K,V> implements ConcurrentMap<K,V> {
|
||||
|
||||
@Override
|
||||
public Entry<K, V> unwrap(Entry<K, V> val) {
|
||||
return val.getKey() == FAKE_NULL() || val.getValue() == FAKE_NULL() ? new EntryWrapper<K, V>(val) : val;
|
||||
return val.getKey() == FAKE_NULL() || val.getValue() == FAKE_NULL() ? new EntryWrapper<>(val) : val;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ import java.util.*;
|
||||
* Null values are NOT allowed
|
||||
*/
|
||||
abstract class ConcurrentIntKeyRefValueHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
private final ConcurrentIntObjectHashMap<IntReference<V>> myMap = new ConcurrentIntObjectHashMap<IntReference<V>>();
|
||||
private final ReferenceQueue<V> myQueue = new ReferenceQueue<V>();
|
||||
private final ConcurrentIntObjectHashMap<IntReference<V>> myMap = new ConcurrentIntObjectHashMap<>();
|
||||
private final ReferenceQueue<V> myQueue = new ReferenceQueue<>();
|
||||
|
||||
@NotNull
|
||||
protected abstract IntReference<V> createReference(int key, @NotNull V value, @NotNull ReferenceQueue<V> queue);
|
||||
@@ -176,7 +176,7 @@ abstract class ConcurrentIntKeyRefValueHashMap<V> implements ConcurrentIntObject
|
||||
continue;
|
||||
}
|
||||
final int key = entry.getKey();
|
||||
nextVEntry = new SimpleEntry<V>(key, v);
|
||||
nextVEntry = new SimpleEntry<>(key, v);
|
||||
nextReferenceEntry = entry;
|
||||
return;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ abstract class ConcurrentIntKeyRefValueHashMap<V> implements ConcurrentIntObject
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
Set<V> result = new THashSet<V>();
|
||||
Set<V> result = new THashSet<>();
|
||||
ContainerUtil.addAll(result, elements());
|
||||
return result;
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,6 +63,6 @@ class ConcurrentIntKeySoftValueHashMap<V> extends ConcurrentIntKeyRefValueHashMa
|
||||
@NotNull
|
||||
@Override
|
||||
protected IntReference<V> createReference(int key, @NotNull V value, @NotNull ReferenceQueue<V> queue) {
|
||||
return new MyRef<V>(key, value, queue);
|
||||
return new MyRef<>(key, value, queue);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,6 +63,6 @@ class ConcurrentIntKeyWeakValueHashMap<V> extends ConcurrentIntKeyRefValueHashMa
|
||||
@NotNull
|
||||
@Override
|
||||
protected IntReference<V> createReference(int key, @NotNull V value, @NotNull ReferenceQueue<V> queue) {
|
||||
return new MyRef<V>(key, value, queue);
|
||||
return new MyRef<>(key, value, queue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
public boolean containsValue(@NotNull Object value) {
|
||||
Node<V>[] t;
|
||||
if ((t = table) != null) {
|
||||
Traverser<V> it = new Traverser<V>(t, t.length, 0, t.length);
|
||||
Traverser<V> it = new Traverser<>(t, t.length, 0, t.length);
|
||||
for (Node<V> p; (p = it.advance()) != null; ) {
|
||||
V v;
|
||||
if ((v = p.val) == value || (v != null && value.equals(v))) {
|
||||
@@ -539,7 +539,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
}
|
||||
else if ((f = tabAt(tab, i = (n - 1) & hash)) == null) {
|
||||
if (casTabAt(tab, i, null,
|
||||
new Node<V>(hash, key, value, null))) {
|
||||
new Node<>(hash, key, value, null))) {
|
||||
break; // no lock when adding to empty bin
|
||||
}
|
||||
}
|
||||
@@ -562,8 +562,8 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
}
|
||||
Node<V> pred = e;
|
||||
if ((e = e.next) == null) {
|
||||
pred.next = new Node<V>(hash, key,
|
||||
value, null);
|
||||
pred.next = new Node<>(hash, key,
|
||||
value, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -751,7 +751,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
ValuesView<V> vs;
|
||||
return (vs = values) != null ? vs : (values = new ValuesView<V>(this));
|
||||
return (vs = values) != null ? vs : (values = new ValuesView<>(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -773,7 +773,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
@NotNull
|
||||
public Set<Entry<V>> entrySet() {
|
||||
EntrySetView<V> es;
|
||||
return (es = entrySet) != null ? es : (entrySet = new EntrySetView<V>(this));
|
||||
return (es = entrySet) != null ? es : (entrySet = new EntrySetView<>(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -788,7 +788,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
int h = 0;
|
||||
Node<V>[] t;
|
||||
if ((t = table) != null) {
|
||||
Traverser<V> it = new Traverser<V>(t, t.length, 0, t.length);
|
||||
Traverser<V> it = new Traverser<>(t, t.length, 0, t.length);
|
||||
for (Node<V> p; (p = it.advance()) != null; ) {
|
||||
h += p.key ^ p.val.hashCode();
|
||||
}
|
||||
@@ -811,7 +811,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
public String toString() {
|
||||
Node<V>[] t;
|
||||
int f = (t = table) == null ? 0 : t.length;
|
||||
Traverser<V> it = new Traverser<V>(t, f, 0, f);
|
||||
Traverser<V> it = new Traverser<>(t, f, 0, f);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('{');
|
||||
Node<V> p;
|
||||
@@ -850,7 +850,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
IntObjectMap<?> m = (IntObjectMap)o;
|
||||
Node<V>[] t;
|
||||
int f = (t = table) == null ? 0 : t.length;
|
||||
Traverser<V> it = new Traverser<V>(t, f, 0, f);
|
||||
Traverser<V> it = new Traverser<>(t, f, 0, f);
|
||||
for (Node<V> p; (p = it.advance()) != null; ) {
|
||||
V val = p.val;
|
||||
Object v = m.get(p.key);
|
||||
@@ -956,7 +956,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
@NotNull
|
||||
@Override
|
||||
public int[] keys() {
|
||||
Object[] entries = new EntrySetView<V>(this).toArray();
|
||||
Object[] entries = new EntrySetView<>(this).toArray();
|
||||
int[] result = new int[entries.length];
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
Entry<V> entry = (Entry<V>)entries[i];
|
||||
@@ -976,7 +976,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
public Enumeration<V> elements() {
|
||||
Node<V>[] t;
|
||||
int f = (t = table) == null ? 0 : t.length;
|
||||
return new ValueIterator<V>(t, f, 0, f, this);
|
||||
return new ValueIterator<>(t, f, 0, f, this);
|
||||
}
|
||||
|
||||
// ConcurrentHashMap-only methods
|
||||
@@ -1237,7 +1237,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
transferIndex = n;
|
||||
}
|
||||
int nextn = nextTab.length;
|
||||
ForwardingNode<V> fwd = new ForwardingNode<V>(nextTab);
|
||||
ForwardingNode<V> fwd = new ForwardingNode<>(nextTab);
|
||||
boolean advance = true;
|
||||
boolean finishing = false; // to ensure sweep before committing nextTab
|
||||
for (int i = 0, bound = 0; ; ) {
|
||||
@@ -1310,10 +1310,10 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
int pk = p.key;
|
||||
V pv = p.val;
|
||||
if ((ph & n) == 0) {
|
||||
ln = new Node<V>(ph, pk, pv, ln);
|
||||
ln = new Node<>(ph, pk, pv, ln);
|
||||
}
|
||||
else {
|
||||
hn = new Node<V>(ph, pk, pv, hn);
|
||||
hn = new Node<>(ph, pk, pv, hn);
|
||||
}
|
||||
}
|
||||
setTabAt(nextTab, i, ln);
|
||||
@@ -1328,7 +1328,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
int lc = 0, hc = 0;
|
||||
for (Node<V> e = t.first; e != null; e = e.next) {
|
||||
int h = e.hash;
|
||||
TreeNode<V> p = new TreeNode<V>
|
||||
TreeNode<V> p = new TreeNode<>
|
||||
(h, e.key, e.val, null, null);
|
||||
if ((h & n) == 0) {
|
||||
if ((p.prev = loTail) == null) {
|
||||
@@ -1352,9 +1352,9 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
}
|
||||
}
|
||||
ln = (lc <= UNTREEIFY_THRESHOLD) ? untreeify(lo) :
|
||||
(hc != 0) ? new TreeBin<V>(lo) : t;
|
||||
(hc != 0) ? new TreeBin<>(lo) : t;
|
||||
hn = (hc <= UNTREEIFY_THRESHOLD) ? untreeify(hi) :
|
||||
(lc != 0) ? new TreeBin<V>(hi) : t;
|
||||
(lc != 0) ? new TreeBin<>(hi) : t;
|
||||
setTabAt(nextTab, i, ln);
|
||||
setTabAt(nextTab, i + n, hn);
|
||||
setTabAt(tab, i, fwd);
|
||||
@@ -1499,8 +1499,8 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
TreeNode<V> hd = null, tl = null;
|
||||
for (Node<V> e = b; e != null; e = e.next) {
|
||||
TreeNode<V> p =
|
||||
new TreeNode<V>(e.hash, e.key, e.val,
|
||||
null, null);
|
||||
new TreeNode<>(e.hash, e.key, e.val,
|
||||
null, null);
|
||||
if ((p.prev = tl) == null) {
|
||||
hd = p;
|
||||
}
|
||||
@@ -1509,7 +1509,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
}
|
||||
tl = p;
|
||||
}
|
||||
setTabAt(tab, index, new TreeBin<V>(hd));
|
||||
setTabAt(tab, index, new TreeBin<>(hd));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1522,7 +1522,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
static <V> Node<V> untreeify(Node<V> b) {
|
||||
Node<V> hd = null, tl = null;
|
||||
for (Node<V> q = b; q != null; q = q.next) {
|
||||
Node<V> p = new Node<V>(q.hash, q.key, q.val, null);
|
||||
Node<V> p = new Node<>(q.hash, q.key, q.val, null);
|
||||
if (tl == null) {
|
||||
hd = p;
|
||||
}
|
||||
@@ -1757,7 +1757,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
for (TreeNode<V> p = root; ; ) {
|
||||
int dir, ph;
|
||||
if (p == null) {
|
||||
first = root = new TreeNode<V>(h, k, v, null, null);
|
||||
first = root = new TreeNode<>(h, k, v, null, null);
|
||||
break;
|
||||
}
|
||||
else if ((ph = p.hash) > h) {
|
||||
@@ -1786,7 +1786,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
TreeNode<V> xp = p;
|
||||
if ((p = (dir <= 0) ? p.left : p.right) == null) {
|
||||
TreeNode<V> x, f = first;
|
||||
first = x = new TreeNode<V>(h, k, v, f, xp);
|
||||
first = x = new TreeNode<>(h, k, v, f, xp);
|
||||
if (f != null) {
|
||||
f.prev = x;
|
||||
}
|
||||
@@ -2303,7 +2303,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
spare = s.next;
|
||||
}
|
||||
else {
|
||||
s = new TableStack<V>();
|
||||
s = new TableStack<>();
|
||||
}
|
||||
s.tab = t;
|
||||
s.length = n;
|
||||
@@ -2414,7 +2414,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
final V v = p.val;
|
||||
lastReturned = p;
|
||||
advance();
|
||||
return new SimpleEntry<V>(k, v);
|
||||
return new SimpleEntry<>(k, v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2648,7 +2648,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
ConcurrentIntObjectHashMap<V> m = map;
|
||||
Node<V>[] t;
|
||||
int f = (t = m.table) == null ? 0 : t.length;
|
||||
return new ValueIterator<V>(t, f, 0, f, m);
|
||||
return new ValueIterator<>(t, f, 0, f, m);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2704,7 +2704,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
ConcurrentIntObjectHashMap<V> m = map;
|
||||
Node<V>[] t;
|
||||
int f = (t = m.table) == null ? 0 : t.length;
|
||||
return new EntryIterator<V>(t, f, 0, f, m);
|
||||
return new EntryIterator<>(t, f, 0, f, m);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2728,7 +2728,7 @@ class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
int h = 0;
|
||||
Node<V>[] t;
|
||||
if ((t = map.table) != null) {
|
||||
Traverser<V> it = new Traverser<V>(t, t.length, 0, t.length);
|
||||
Traverser<V> it = new Traverser<>(t, t.length, 0, t.length);
|
||||
for (Node<V> p; (p = it.advance()) != null; ) {
|
||||
h += p.hashCode();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user