diff --git a/platform/util/src/com/intellij/AbstractBundle.java b/platform/util/src/com/intellij/AbstractBundle.java index 562cf72273e2..39031f8b000f 100644 --- a/platform/util/src/com/intellij/AbstractBundle.java +++ b/platform/util/src/com/intellij/AbstractBundle.java @@ -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(bundle); + myBundle = new SoftReference<>(bundle); } return bundle; } diff --git a/platform/util/src/com/intellij/CommonBundle.java b/platform/util/src/com/intellij/CommonBundle.java index 118aeae99e6a..4d385cb7db45 100644 --- a/platform/util/src/com/intellij/CommonBundle.java +++ b/platform/util/src/com/intellij/CommonBundle.java @@ -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(bundle); + ourBundle = new SoftReference<>(bundle); } return bundle; } diff --git a/platform/util/src/com/intellij/execution/process/ProcessHandler.java b/platform/util/src/com/intellij/execution/process/ProcessHandler.java index 737f6d839cfb..56c3bd6f9ecb 100644 --- a/platform/util/src/com/intellij/execution/process/ProcessHandler.java +++ b/platform/util/src/com/intellij/execution/process/ProcessHandler.java @@ -36,7 +36,7 @@ public abstract class ProcessHandler extends UserDataHolderBase { private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private enum State {INITIAL, RUNNING, TERMINATING, TERMINATED} - private final AtomicReference myState = new AtomicReference(State.INITIAL); + private final AtomicReference 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 myPendingTasks = new ArrayList(); + private final List myPendingTasks = new ArrayList<>(); @Override public void startNotified(@NotNull ProcessEvent event) { diff --git a/platform/util/src/com/intellij/execution/process/ProcessIOExecutorService.java b/platform/util/src/com/intellij/execution/process/ProcessIOExecutorService.java index f305a312fa97..0349c79264a8 100644 --- a/platform/util/src/com/intellij/execution/process/ProcessIOExecutorService.java +++ b/platform/util/src/com/intellij/execution/process/ProcessIOExecutorService.java @@ -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(), new CountingThreadFactory() { + super(1, Integer.MAX_VALUE, 1, TimeUnit.MINUTES, new SynchronousQueue<>(), new CountingThreadFactory() { @NotNull @Override public Thread newThread(@NotNull final Runnable r) { diff --git a/platform/util/src/com/intellij/execution/process/ProcessWaitFor.java b/platform/util/src/com/intellij/execution/process/ProcessWaitFor.java index a09c06721bb1..d98997625195 100644 --- a/platform/util/src/com/intellij/execution/process/ProcessWaitFor.java +++ b/platform/util/src/com/intellij/execution/process/ProcessWaitFor.java @@ -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> myTerminationCallback = new ArrayBlockingQueue>(1); + private final BlockingQueue> myTerminationCallback = new ArrayBlockingQueue<>(1); private volatile boolean myDetached; /** @deprecated use {@link #ProcessWaitFor(Process, TaskExecutor, String)} instead (to be removed in IDEA 2018) */ diff --git a/platform/util/src/com/intellij/execution/process/UnixProcessManager.java b/platform/util/src/com/intellij/execution/process/UnixProcessManager.java index 861512df8ca4..050e313f4631 100644 --- a/platform/util/src/com/intellij/execution/process/UnixProcessManager.java +++ b/platform/util/src/com/intellij/execution/process/UnixProcessManager.java @@ -145,9 +145,9 @@ public class UnixProcessManager { LOG.debug("Sending signal " + signal + " to process tree with root PID " + processId); } - final Ref foundPid = new Ref(); + final Ref foundPid = new Ref<>(); final ProcessInfo processInfo = new ProcessInfo(); - final List childrenPids = new ArrayList(); + final List childrenPids = new ArrayList<>(); findChildProcesses(ourPid, processId, foundPid, processInfo, childrenPids); @@ -278,11 +278,11 @@ public class UnixProcessManager { } private static class ProcessInfo { - private final Map> BY_PARENT = new TreeMap>(); // pid -> list of children pids + private final Map> BY_PARENT = new TreeMap<>(); // pid -> list of children pids public void register(Integer pid, Integer parentPid) { List children = BY_PARENT.get(parentPid); - if (children == null) BY_PARENT.put(parentPid, children = new LinkedList()); + if (children == null) BY_PARENT.put(parentPid, children = new LinkedList<>()); children.add(pid); } diff --git a/platform/util/src/com/intellij/execution/rmi/RemoteUtil.java b/platform/util/src/com/intellij/execution/rmi/RemoteUtil.java index 10e2f575dd40..30420df04cfb 100644 --- a/platform/util/src/com/intellij/execution/rmi/RemoteUtil.java +++ b/platform/util/src/com/intellij/execution/rmi/RemoteUtil.java @@ -44,7 +44,7 @@ public class RemoteUtil { ConcurrentFactoryMap.createMap(new Function>, Map>() { @Override public Map fun(Couple> key) { - final THashMap map = new THashMap(); + final THashMap map = new THashMap<>(); for (Method method : key.second.getMethods()) { Method m = null; main: diff --git a/platform/util/src/com/intellij/openapi/CompositeDisposable.java b/platform/util/src/com/intellij/openapi/CompositeDisposable.java index 5755ba891863..4025cbb73dee 100644 --- a/platform/util/src/com/intellij/openapi/CompositeDisposable.java +++ b/platform/util/src/com/intellij/openapi/CompositeDisposable.java @@ -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 myDisposables = new ArrayList(); + private final List myDisposables = new ArrayList<>(); private boolean disposed; public void add(@NotNull Disposable disposable) { diff --git a/platform/util/src/com/intellij/openapi/DisposableWrapper.java b/platform/util/src/com/intellij/openapi/DisposableWrapper.java index 5dff31b48c87..3672f928c6a0 100644 --- a/platform/util/src/com/intellij/openapi/DisposableWrapper.java +++ b/platform/util/src/com/intellij/openapi/DisposableWrapper.java @@ -22,7 +22,7 @@ public class DisposableWrapper implements Disposable { @NotNull protected DisposableWrapper createNewWrapper(@Nullable T object, @NotNull Disposable parent) { - return new DisposableWrapper(object, parent); + return new DisposableWrapper<>(object, parent); } @Override diff --git a/platform/util/src/com/intellij/openapi/WeaklyReferencedDisposable.java b/platform/util/src/com/intellij/openapi/WeaklyReferencedDisposable.java index f0e4a7386124..b6b676a65104 100644 --- a/platform/util/src/com/intellij/openapi/WeaklyReferencedDisposable.java +++ b/platform/util/src/com/intellij/openapi/WeaklyReferencedDisposable.java @@ -16,7 +16,7 @@ import java.lang.ref.WeakReference; * @author eldar */ public class WeaklyReferencedDisposable extends WeakReference implements Disposable { - private static final ReferenceQueue ourRefQueue = new ReferenceQueue(); + private static final ReferenceQueue ourRefQueue = new ReferenceQueue<>(); public WeaklyReferencedDisposable(@NotNull Disposable disposable) { super(disposable, ourRefQueue); diff --git a/platform/util/src/com/intellij/openapi/application/JetBrainsProtocolHandler.java b/platform/util/src/com/intellij/openapi/application/JetBrainsProtocolHandler.java index c4cf9fae45ab..d771b130938c 100644 --- a/platform/util/src/com/intellij/openapi/application/JetBrainsProtocolHandler.java +++ b/platform/util/src/com/intellij/openapi/application/JetBrainsProtocolHandler.java @@ -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 ourParameters = new HashMap(0); + private static final Map ourParameters = new HashMap<>(0); private static boolean initialized = false; public static void processJetBrainsLauncherParameters(String url) { diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index c6b8000dd60b..f80c0a66cafb 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -408,7 +408,7 @@ public class PathManager { public static void loadProperties() { getHomePath(); - Set paths = new LinkedHashSet(); + Set 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 classPath = new HashSet(); + final Set classPath = new HashSet<>(); for (Class aClass : classes) { final String path = getJarPathForClass(aClass); if (path != null) { diff --git a/platform/util/src/com/intellij/openapi/diagnostic/FrequentEventDetector.java b/platform/util/src/com/intellij/openapi/diagnostic/FrequentEventDetector.java index fdfd5359b218..26f8dad0f0d1 100644 --- a/platform/util/src/com/intellij/openapi/diagnostic/FrequentEventDetector.java +++ b/platform/util/src/com/intellij/openapi/diagnostic/FrequentEventDetector.java @@ -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 myRecentTraces = new FixedHashMap(50); + private final Map myRecentTraces = new FixedHashMap<>(50); private final int myEventCountThreshold; private final int myTimeSpanMs; private final Level myLevel; diff --git a/platform/util/src/com/intellij/openapi/diff/LineTokenizer.java b/platform/util/src/com/intellij/openapi/diff/LineTokenizer.java index 9a6d61e8efbf..ce121e0df9b9 100644 --- a/platform/util/src/com/intellij/openapi/diff/LineTokenizer.java +++ b/platform/util/src/com/intellij/openapi/diff/LineTokenizer.java @@ -32,7 +32,7 @@ public class LineTokenizer extends LineTokenizerBase { @NotNull public String[] execute() { - ArrayList lines = new ArrayList(); + ArrayList lines = new ArrayList<>(); doExecute(lines); return ArrayUtil.toStringArray(lines); } diff --git a/platform/util/src/com/intellij/openapi/diff/impl/DiffFragmentBuilder.java b/platform/util/src/com/intellij/openapi/diff/impl/DiffFragmentBuilder.java index 64630e981753..c0a729a419b2 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/DiffFragmentBuilder.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/DiffFragmentBuilder.java @@ -63,7 +63,7 @@ public class DiffFragmentBuilder { @NotNull private final DiffString[] mySource2; private int myLastLine1 = 1; private int myLastLine2 = 1; - @NotNull private final List myData = new LinkedList(); + @NotNull private final List myData = new LinkedList<>(); public DiffFragmentBuilder(@NotNull DiffString[] source1, @NotNull DiffString[] source2) { mySource1 = source1; diff --git a/platform/util/src/com/intellij/openapi/diff/impl/fragments/FragmentListImpl.java b/platform/util/src/com/intellij/openapi/diff/impl/fragments/FragmentListImpl.java index abb086c5b613..297a685f52f5 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/fragments/FragmentListImpl.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/fragments/FragmentListImpl.java @@ -74,7 +74,7 @@ public class FragmentListImpl implements FragmentList { public static ArrayList shift(ArrayList fragments, TextRange rangeShift1, TextRange rangeShift2, int startLine1, int startLine2) { - ArrayList newFragments = new ArrayList(fragments.size()); + ArrayList newFragments = new ArrayList<>(fragments.size()); for (Fragment fragment : fragments) { newFragments.add(fragment.shift(rangeShift1, rangeShift2, startLine1, startLine2)); } diff --git a/platform/util/src/com/intellij/openapi/diff/impl/highlighting/BufferedStringList.java b/platform/util/src/com/intellij/openapi/diff/impl/highlighting/BufferedStringList.java index 8f45cd9f5d11..217a364bde39 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/highlighting/BufferedStringList.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/highlighting/BufferedStringList.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; class BufferedStringList { - private final ArrayList myStrings = new ArrayList(); + private final ArrayList myStrings = new ArrayList<>(); private final StringBuffer myLast = new StringBuffer(); public void add(String string) { diff --git a/platform/util/src/com/intellij/openapi/diff/impl/highlighting/List2D.java b/platform/util/src/com/intellij/openapi/diff/impl/highlighting/List2D.java index 7b645327af54..d11aa0b930e2 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/highlighting/List2D.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/highlighting/List2D.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.List; class List2D { - private final List> myRows = new ArrayList>(); + private final List> myRows = new ArrayList<>(); private List myCurrentRow = null; public void add(DiffFragment element) { @@ -32,7 +32,7 @@ class List2D { private void ensureRowExists() { if (myCurrentRow == null) { - myCurrentRow = new ArrayList(); + myCurrentRow = new ArrayList<>(); myRows.add(myCurrentRow); } } diff --git a/platform/util/src/com/intellij/openapi/diff/impl/highlighting/Util.java b/platform/util/src/com/intellij/openapi/diff/impl/highlighting/Util.java index 2da7b5c38176..c16e1fbbe86d 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/highlighting/Util.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/highlighting/Util.java @@ -342,7 +342,7 @@ public class Util { return fragments; } if (secondText.charAt(0) == rightText.charAt(0)) { - List result = new ArrayList(); + List 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())); diff --git a/platform/util/src/com/intellij/openapi/diff/impl/patch/PatchHunk.java b/platform/util/src/com/intellij/openapi/diff/impl/patch/PatchHunk.java index 2597e6420dcf..daf4d4faee8a 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/patch/PatchHunk.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/patch/PatchHunk.java @@ -25,7 +25,7 @@ public class PatchHunk { private final int myEndLineBefore; private final int myStartLineAfter; private final int myEndLineAfter; - private final List myLines = new ArrayList(); + private final List myLines = new ArrayList<>(); public PatchHunk(final int startLineBefore, final int endLineBefore, final int startLineAfter, final int endLineAfter) { myStartLineBefore = startLineBefore; diff --git a/platform/util/src/com/intellij/openapi/diff/impl/processing/ByWord.java b/platform/util/src/com/intellij/openapi/diff/impl/processing/ByWord.java index 9a259457842b..d5dd8637afb7 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/processing/ByWord.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/processing/ByWord.java @@ -133,7 +133,7 @@ public class ByWord implements DiffPolicy { @NotNull static Word[] buildWords(@NotNull DiffString text, @NotNull ComparisonPolicy policy) { - ArrayList words = new ArrayList(); + ArrayList 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 myFragments = new ArrayList(); + private final ArrayList myFragments = new ArrayList<>(); private final Version myVersion1; private final Version myVersion2; private final DiffPolicy.ByChar BY_CHAR; diff --git a/platform/util/src/com/intellij/openapi/diff/impl/processing/DiffCorrection.java b/platform/util/src/com/intellij/openapi/diff/impl/processing/DiffCorrection.java index 060f540f824b..32e9e9b022ff 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/processing/DiffCorrection.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/processing/DiffCorrection.java @@ -127,7 +127,7 @@ public interface DiffCorrection { } class BaseFragmentRunner { - private final ArrayList myItems = new ArrayList(); + private final ArrayList myItems = new ArrayList<>(); private int myIndex = 0; private DiffFragment[] myFragments; diff --git a/platform/util/src/com/intellij/openapi/diff/impl/processing/DummyDiffFragmentsProcessor.java b/platform/util/src/com/intellij/openapi/diff/impl/processing/DummyDiffFragmentsProcessor.java index 5be87b5d2b9c..ee7c430b0ade 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/processing/DummyDiffFragmentsProcessor.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/processing/DummyDiffFragmentsProcessor.java @@ -24,7 +24,7 @@ import java.util.ArrayList; class DummyDiffFragmentsProcessor { public ArrayList process(String text1, String text2) { - ArrayList lineFragments = new ArrayList(); + ArrayList lineFragments = new ArrayList<>(); if (text1.isEmpty() && text2.isEmpty()) { return lineFragments; diff --git a/platform/util/src/com/intellij/openapi/diff/impl/processing/FragmentsCollector.java b/platform/util/src/com/intellij/openapi/diff/impl/processing/FragmentsCollector.java index 6cb92a49d081..716e0145f9d5 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/processing/FragmentsCollector.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/processing/FragmentsCollector.java @@ -23,7 +23,7 @@ import com.intellij.openapi.util.TextRange; import java.util.ArrayList; class FragmentsCollector { - private final ArrayList myFragments = new ArrayList(); + private final ArrayList myFragments = new ArrayList<>(); private int myOffset1 = 0; private int myOffset2 = 0; diff --git a/platform/util/src/com/intellij/openapi/diff/impl/processing/LineFragmentsCollector.java b/platform/util/src/com/intellij/openapi/diff/impl/processing/LineFragmentsCollector.java index 75342869c566..eb6f3048694e 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/processing/LineFragmentsCollector.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/processing/LineFragmentsCollector.java @@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; class LineFragmentsCollector { - private final ArrayList myLineFragments = new ArrayList(); + private final ArrayList myLineFragments = new ArrayList<>(); private int myLine1 = 0; private int myLine2 = 0; private int myOffset1 = 0; diff --git a/platform/util/src/com/intellij/openapi/diff/impl/processing/TextCompareProcessor.java b/platform/util/src/com/intellij/openapi/diff/impl/processing/TextCompareProcessor.java index ee54e7818e89..23ba30a487bd 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/processing/TextCompareProcessor.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/processing/TextCompareProcessor.java @@ -83,7 +83,7 @@ public class TextCompareProcessor { DiffString subText1 = lineBlock.getText(diffText1, FragmentSide.SIDE1); DiffString subText2 = lineBlock.getText(diffText2, FragmentSide.SIDE2); ArrayList subFragments = findSubFragments(subText1, subText2); - lineBlock.setChildren(new ArrayList(subFragments)); + lineBlock.setChildren(new ArrayList<>(subFragments)); lineBlock.adjustTypeFromChildrenTypes(); } catch (FilesTooBigForDiffException ignore) { diff --git a/platform/util/src/com/intellij/openapi/diff/impl/string/DiffString.java b/platform/util/src/com/intellij/openapi/diff/impl/string/DiffString.java index 51c212153aac..b0422bc29ba4 100644 --- a/platform/util/src/com/intellij/openapi/diff/impl/string/DiffString.java +++ b/platform/util/src/com/intellij/openapi/diff/impl/string/DiffString.java @@ -334,7 +334,7 @@ public class DiffString extends CharArrayCharSequence { @NotNull public DiffString[] execute() { - ArrayList lines = new ArrayList(); + ArrayList lines = new ArrayList<>(); doExecute(lines); return lines.toArray(new DiffString[0]); } diff --git a/platform/util/src/com/intellij/openapi/util/DeprecatedDuplicatesIconPathPatcher.java b/platform/util/src/com/intellij/openapi/util/DeprecatedDuplicatesIconPathPatcher.java index aada1f52e72f..738528e20fb8 100644 --- a/platform/util/src/com/intellij/openapi/util/DeprecatedDuplicatesIconPathPatcher.java +++ b/platform/util/src/com/intellij/openapi/util/DeprecatedDuplicatesIconPathPatcher.java @@ -11,7 +11,7 @@ import java.util.Map; * @author Konstantin Bulenkov */ public class DeprecatedDuplicatesIconPathPatcher extends IconPathPatcher { - @NonNls private static final Map ourDeprecatedIconsReplacements = new HashMap(); + @NonNls private static final Map ourDeprecatedIconsReplacements = new HashMap<>(); static { ourDeprecatedIconsReplacements.put("/actions/prevfile.png", "AllIcons.Actions.Back"); diff --git a/platform/util/src/com/intellij/openapi/util/Disposer.java b/platform/util/src/com/intellij/openapi/util/Disposer.java index bc79e86dae08..3ffebd3f9650 100644 --- a/platform/util/src/com/intellij/openapi/util/Disposer.java +++ b/platform/util/src/com/intellij/openapi/util/Disposer.java @@ -34,7 +34,7 @@ public class Disposer { static { try { - ourTree = new ObjectTree(); + ourTree = new ObjectTree<>(); } catch (NoClassDefFoundError e) { throw new RuntimeException("loader=" + Disposer.class.getClassLoader(), e); diff --git a/platform/util/src/com/intellij/openapi/util/IconLoader.java b/platform/util/src/com/intellij/openapi/util/IconLoader.java index 7095d0237476..400d96716f4f 100644 --- a/platform/util/src/com/intellij/openapi/util/IconLoader.java +++ b/platform/util/src/com/intellij/openapi/util/IconLoader.java @@ -61,7 +61,7 @@ public final class IconLoader { } }; - private static final AtomicReference ourTransform = new AtomicReference(IconTransform.getDefault()); + private static final AtomicReference ourTransform = new AtomicReference<>(IconTransform.getDefault()); static { installPathPatcher(new DeprecatedDuplicatesIconPathPatcher()); @@ -299,7 +299,7 @@ public final class IconLoader { boolean findReflectiveIcon) { if (findReflectiveIcon) { - Ref reflectiveIcon = new Ref(null); + Ref 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 reflectiveIcon = new Ref(null); + Ref 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(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, SoftReference> scaledIconsCache = Collections.synchronizedMap(new FixedHashMap, SoftReference>(SCALED_ICONS_CACHE_LIMIT)); + private final Map, SoftReference> scaledIconsCache = Collections.synchronizedMap( + new FixedHashMap<>(SCALED_ICONS_CACHE_LIMIT)); private Couple key(@NotNull ScaleContext ctx) { - return new Couple(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(icon)); + scaledIconsCache.put(key(ctx), new SoftReference<>(icon)); } return icon; } diff --git a/platform/util/src/com/intellij/openapi/util/JDOMExternalizer.java b/platform/util/src/com/intellij/openapi/util/JDOMExternalizer.java index fdc56a2b04f1..43d773e7f2c6 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMExternalizer.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMExternalizer.java @@ -125,7 +125,7 @@ public class JDOMExternalizer { @NotNull public static List loadStringsList(Element element, String rootName, String attrName) { - final List paths = new LinkedList(); + final List paths = new LinkedList<>(); if (element != null) { @NotNull final List list = element.getChildren(rootName); for (Object o : list) { diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index 2c1ab6288f2d..21903caf1341 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -657,7 +657,7 @@ public class JDOMUtil { } } - List writtenFilesPaths = new ArrayList(); + List writtenFilesPaths = new ArrayList<>(); for (int i = 0; i < newFilePaths.length; i++) { String newFilePath = newFilePaths[i]; diff --git a/platform/util/src/com/intellij/openapi/util/Key.java b/platform/util/src/com/intellij/openapi/util/Key.java index 41235fb12359..edc6f1cd0380 100644 --- a/platform/util/src/com/intellij/openapi/util/Key.java +++ b/platform/util/src/com/intellij/openapi/util/Key.java @@ -47,7 +47,7 @@ public class Key { @NotNull public static Key create(@NotNull String name) { - return new Key(name); + return new Key<>(name); } public T get(@Nullable UserDataHolder holder) { diff --git a/platform/util/src/com/intellij/openapi/util/LowMemoryWatcher.java b/platform/util/src/com/intellij/openapi/util/LowMemoryWatcher.java index ff3ed4d24400..d7b383048ae9 100644 --- a/platform/util/src/com/intellij/openapi/util/LowMemoryWatcher.java +++ b/platform/util/src/com/intellij/openapi/util/LowMemoryWatcher.java @@ -32,7 +32,7 @@ public class LowMemoryWatcher { ONLY_AFTER_GC } - private static final WeakList ourListeners = new WeakList(); + private static final WeakList ourListeners = new WeakList<>(); private final Runnable myRunnable; private final LowMemoryWatcherType myType; diff --git a/platform/util/src/com/intellij/openapi/util/MultiValuesMap.java b/platform/util/src/com/intellij/openapi/util/MultiValuesMap.java index 43b8598123c2..5d19055f3365 100644 --- a/platform/util/src/com/intellij/openapi/util/MultiValuesMap.java +++ b/platform/util/src/com/intellij/openapi/util/MultiValuesMap.java @@ -18,7 +18,7 @@ public class MultiValuesMap{ public MultiValuesMap(boolean ordered) { myOrdered = ordered; - myBaseMap = ordered ? new LinkedHashMap>() : new HashMap>(); + myBaseMap = ordered ? new LinkedHashMap<>() : new HashMap<>(); } public void putAll(K key, @NotNull Collection values) { @@ -36,7 +36,7 @@ public class MultiValuesMap{ public void put(K key, V value) { Collection collection = myBaseMap.get(key); if (collection == null) { - collection = myOrdered ? new LinkedHashSet() : new HashSet(); + collection = myOrdered ? new LinkedHashSet<>() : new HashSet<>(); myBaseMap.put(key, collection); } @@ -54,7 +54,7 @@ public class MultiValuesMap{ @NotNull public Collection values() { - Set result = myOrdered ? new LinkedHashSet() : new HashSet(); + Set result = myOrdered ? new LinkedHashSet<>() : new HashSet<>(); for (final Collection values : myBaseMap.values()) { result.addAll(values); } diff --git a/platform/util/src/com/intellij/openapi/util/MutualMap.java b/platform/util/src/com/intellij/openapi/util/MutualMap.java index d96dc4aca505..ce1bf8ca6440 100644 --- a/platform/util/src/com/intellij/openapi/util/MutualMap.java +++ b/platform/util/src/com/intellij/openapi/util/MutualMap.java @@ -28,11 +28,11 @@ public class MutualMap { public MutualMap(boolean ordered) { if (ordered) { - myKey2Value = new LinkedHashMap(); - myValue2Key = new LinkedHashMap(); + myKey2Value = new LinkedHashMap<>(); + myValue2Key = new LinkedHashMap<>(); } else { - myKey2Value = new HashMap(); - myValue2Key = new HashMap(); + myKey2Value = new HashMap<>(); + myValue2Key = new HashMap<>(); } } diff --git a/platform/util/src/com/intellij/openapi/util/NotNullLazyKey.java b/platform/util/src/com/intellij/openapi/util/NotNullLazyKey.java index fc07f7f58f6f..afca8e1df48a 100644 --- a/platform/util/src/com/intellij/openapi/util/NotNullLazyKey.java +++ b/platform/util/src/com/intellij/openapi/util/NotNullLazyKey.java @@ -51,6 +51,6 @@ public class NotNullLazyKey extends Key{ @NotNull public static NotNullLazyKey create(@NonNls @NotNull String name, @NotNull NotNullFunction function) { - return new NotNullLazyKey(name, function); + return new NotNullLazyKey<>(name, function); } } diff --git a/platform/util/src/com/intellij/openapi/util/NullableLazyKey.java b/platform/util/src/com/intellij/openapi/util/NullableLazyKey.java index 5a004012cca6..ff227aa75be1 100644 --- a/platform/util/src/com/intellij/openapi/util/NullableLazyKey.java +++ b/platform/util/src/com/intellij/openapi/util/NullableLazyKey.java @@ -47,6 +47,6 @@ public class NullableLazyKey extends Key{ } public static NullableLazyKey create(@NonNls String name, final NullableFunction function) { - return new NullableLazyKey(name, function); + return new NullableLazyKey<>(name, function); } } \ No newline at end of file diff --git a/platform/util/src/com/intellij/openapi/util/RecursionManager.java b/platform/util/src/com/intellij/openapi/util/RecursionManager.java index 8309414397bb..38525ed13446 100644 --- a/platform/util/src/com/intellij/openapi/util/RecursionManager.java +++ b/platform/util/src/com/intellij/openapi/util/RecursionManager.java @@ -131,7 +131,7 @@ public class RecursionManager { @NotNull @Override public List currentStack() { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); LinkedHashMap 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 progressMap = new LinkedHashMap(); - private final Set toMemoize = new THashSet(); - private final THashMap key2ReentrancyDuringItsCalculation = new THashMap(); + private final LinkedHashMap progressMap = new LinkedHashMap<>(); + private final Set toMemoize = new THashSet<>(); + private final THashMap key2ReentrancyDuringItsCalculation = new THashMap<>(); private final Map> 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(key2ReentrancyDuringItsCalculation)); + LOG.error("non-empty key2ReentrancyDuringItsCalculation: " + new HashMap<>(key2ReentrancyDuringItsCalculation)); } if (!toMemoize.isEmpty()) { - LOG.error("non-empty toMemoize: " + new HashSet(toMemoize)); + LOG.error("non-empty toMemoize: " + new HashSet<>(toMemoize)); } } @@ -292,7 +292,7 @@ public class RecursionManager { private void enableMemoization(MyKey realKey, Set loop) { toMemoize.addAll(loop); - List stack = new ArrayList(progressMap.keySet()); + List 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 loop = new THashSet(); + Set loop = new THashSet<>(); boolean inLoop = false; - for (Map.Entry entry: new ArrayList>(progressMap.entrySet())) { + for (Map.Entry entry: new ArrayList<>(progressMap.entrySet())) { if (inLoop) { entry.setValue(reentrancyCount); loop.add(entry.getKey()); diff --git a/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java b/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java index 2104933c0215..eb2f1455129d 100644 --- a/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java +++ b/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java @@ -12,8 +12,8 @@ import java.util.List; import java.util.concurrent.TimeUnit; public class ShutDownTracker implements Runnable { - private final List myThreads = new ArrayList(); - private final LinkedList myShutdownTasks = new LinkedList(); + private final List myThreads = new ArrayList<>(); + private final LinkedList myShutdownTasks = new LinkedList<>(); private final Thread myThread; private ShutDownTracker() { diff --git a/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedByteArray.java b/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedByteArray.java index 70915e2dba87..d29afa9c2998 100644 --- a/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedByteArray.java +++ b/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedByteArray.java @@ -18,13 +18,13 @@ package com.intellij.openapi.util; import java.lang.ref.SoftReference; public final class ThreadLocalCachedByteArray { - private final ThreadLocal> myThreadLocal = new ThreadLocal>(); + private final ThreadLocal> 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(value)); + myThreadLocal.set(new SoftReference<>(value)); } return value; diff --git a/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedIntArray.java b/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedIntArray.java index 581bb99566a9..d0326cbd8fe9 100644 --- a/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedIntArray.java +++ b/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedIntArray.java @@ -18,13 +18,13 @@ package com.intellij.openapi.util; import java.lang.ref.SoftReference; public final class ThreadLocalCachedIntArray { - private final ThreadLocal> myThreadLocal = new ThreadLocal>(); + private final ThreadLocal> 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(value)); + myThreadLocal.set(new SoftReference<>(value)); } return value; diff --git a/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedValue.java b/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedValue.java index 3441599661c0..1e79a2a672c5 100644 --- a/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedValue.java +++ b/platform/util/src/com/intellij/openapi/util/ThreadLocalCachedValue.java @@ -20,13 +20,13 @@ import org.jetbrains.annotations.NotNull; import java.lang.ref.SoftReference; public abstract class ThreadLocalCachedValue { - private final ThreadLocal> myThreadLocal = new ThreadLocal>(); + private final ThreadLocal> myThreadLocal = new ThreadLocal<>(); public T getValue() { T value = com.intellij.reference.SoftReference.dereference(myThreadLocal.get()); if (value == null) { value = create(); - myThreadLocal.set(new SoftReference(value)); + myThreadLocal.set(new SoftReference<>(value)); } else { init(value); diff --git a/platform/util/src/com/intellij/openapi/util/TraceableDisposable.java b/platform/util/src/com/intellij/openapi/util/TraceableDisposable.java index 662b494d6dd1..4f8d58e173db 100644 --- a/platform/util/src/com/intellij/openapi/util/TraceableDisposable.java +++ b/platform/util/src/com/intellij/openapi/util/TraceableDisposable.java @@ -86,7 +86,7 @@ public class TraceableDisposable { @SuppressWarnings("HardCodedStringLiteral") @Override public void printStackTrace(PrintWriter s) { - final List stack = new ArrayList(Arrays.asList(CREATE_TRACE.getStackTrace())); + final List 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 " + diff --git a/platform/util/src/com/intellij/openapi/util/Trinity.java b/platform/util/src/com/intellij/openapi/util/Trinity.java index 9b30eb461929..334322d91ebb 100644 --- a/platform/util/src/com/intellij/openapi/util/Trinity.java +++ b/platform/util/src/com/intellij/openapi/util/Trinity.java @@ -43,7 +43,7 @@ public class Trinity { } public static Trinity create(A first, B second, C third) { - return new Trinity(first, second,third); + return new Trinity<>(first, second, third); } public static T getFirst(@Nullable Trinity pair) { diff --git a/platform/util/src/com/intellij/openapi/util/UserDataCache.java b/platform/util/src/com/intellij/openapi/util/UserDataCache.java index bfeca344a57f..f8cce3bc52da 100644 --- a/platform/util/src/com/intellij/openapi/util/UserDataCache.java +++ b/platform/util/src/com/intellij/openapi/util/UserDataCache.java @@ -27,7 +27,7 @@ public abstract class UserDataCache exte } public UserDataCache(@NonNls String keyName) { - myKey = new Key(keyName); + myKey = new Key<>(keyName); } public T get(final Owner owner, final Param parameter) { diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index 340bd8f7cc9a..60ef399519c0 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -251,7 +251,7 @@ public class FileUtil extends FileUtilRt { total += n; if (count == chars.length) { if (buffers == null) { - buffers = new ArrayList(); + 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(); + 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 asyncDelete(@NotNull Collection files) { - List tempFiles = new ArrayList(); + List 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(null); + return new FixedFuture<>(null); } private static Future startDeletionThread(@NotNull final File... tempFiles) { - final RunnableFuture deleteFilesTask = new FutureTask(new Runnable() { + final RunnableFuture 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 processor, @Nullable final Processor directoryFilter) { - final LinkedList queue = new LinkedList(); + final LinkedList 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 findFilesByMask(@NotNull Pattern pattern, @NotNull File dir) { - final ArrayList found = new ArrayList(); + final ArrayList 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 findFilesOrDirsByMask(@NotNull Pattern pattern, @NotNull File dir) { - final ArrayList found = new ArrayList(); + final ArrayList 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 splitPath(@NotNull String path) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); int index = 0; int nextSeparator; while ((nextSeparator = path.indexOf(File.separatorChar, index)) != -1) { diff --git a/platform/util/src/com/intellij/openapi/util/io/UniqueNameBuilder.java b/platform/util/src/com/intellij/openapi/util/io/UniqueNameBuilder.java index 70f4d985cdd9..68b080d02191 100644 --- a/platform/util/src/com/intellij/openapi/util/io/UniqueNameBuilder.java +++ b/platform/util/src/com/intellij/openapi/util/io/UniqueNameBuilder.java @@ -27,7 +27,7 @@ import java.util.NoSuchElementException; */ public class UniqueNameBuilder { private static final String VFS_SEPARATOR = "/"; - private final Map myPaths = new THashMap(); + private final Map myPaths = new THashMap<>(); private final String mySeparator; private final int myMaxLength; private final String myRoot; @@ -51,7 +51,7 @@ public class UniqueNameBuilder { Node(String text, Node parentNode) { myText = text; myParentNode = parentNode; - myChildren = new THashMap(1); + myChildren = new THashMap<>(1); } Node findOrAddChild(String word) { diff --git a/platform/util/src/com/intellij/openapi/util/io/WindowsRegistryUtil.java b/platform/util/src/com/intellij/openapi/util/io/WindowsRegistryUtil.java index af8c41e686f9..dd6f3b23ec63 100644 --- a/platform/util/src/com/intellij/openapi/util/io/WindowsRegistryUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/WindowsRegistryUtil.java @@ -70,7 +70,7 @@ public class WindowsRegistryUtil { @NotNull public static List readRegistryBranch(@NotNull String location) { - List result = new ArrayList(); + List 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 readRegistryBranchValues(@NotNull String location) { - List result = new ArrayList(); + List result = new ArrayList<>(); StringBuilder output = doReadBranch(location); if (output != null) { // there seem to be no way to get machine-readable list of value names. diff --git a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectNode.java b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectNode.java index 67a71a94c16e..71d5df318c5b 100644 --- a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectNode.java +++ b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectNode.java @@ -66,7 +66,7 @@ final class ObjectNode { void addChild(@NotNull ObjectNode child) { List> children = myChildren; if (children == null) { - myChildren = new SmartList>(child); + myChildren = new SmartList<>(child); } else { children.add(child); diff --git a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java index e7050fcb1806..ffe4c464d91a 100644 --- a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java +++ b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java @@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicLong; public final class ObjectTree { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.objectTree.ObjectTree"); - private static final ThreadLocal ourTopmostDisposeTrace = new ThreadLocal(); + private static final ThreadLocal ourTopmostDisposeTrace = new ThreadLocal<>(); private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); @@ -46,8 +46,8 @@ public final class ObjectTree { // Disposable to trace or boolean marker (if trace unavailable) private final Map myDisposedObjects = ContainerUtil.createWeakMap(100, 0.5f, ContainerUtil.identityStrategy()); // guarded by treeLock - private final List> myExecutedNodes = new ArrayList>(); // guarded by myExecutedNodes - private final List myExecutedUnregisteredObjects = new ArrayList(); // guarded by myExecutedUnregisteredObjects + private final List> myExecutedNodes = new ArrayList<>(); // guarded by myExecutedNodes + private final List myExecutedUnregisteredObjects = new ArrayList<>(); // guarded by myExecutedUnregisteredObjects final Object treeLock = new Object(); @@ -125,7 +125,7 @@ public final class ObjectTree { @NotNull private ObjectNode createNodeFor(@NotNull T object, @Nullable ObjectNode parentNode) { - final ObjectNode newNode = new ObjectNode(this, parentNode, object, getNextModification()); + final ObjectNode newNode = new ObjectNode<>(this, parentNode, object, getNextModification()); if (parentNode == null) { myRootObjects.add(object); } @@ -154,7 +154,7 @@ public final class ObjectTree { } } else { - SmartList exceptions = new SmartList(); + SmartList exceptions = new SmartList<>(); ObjectNode parent; synchronized (treeLock) { parent = node.getParent(); diff --git a/platform/util/src/com/intellij/openapi/util/objectTree/ThrowableInterner.java b/platform/util/src/com/intellij/openapi/util/objectTree/ThrowableInterner.java index 0934ea331559..169222651e4c 100644 --- a/platform/util/src/com/intellij/openapi/util/objectTree/ThrowableInterner.java +++ b/platform/util/src/com/intellij/openapi/util/objectTree/ThrowableInterner.java @@ -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 myTraceInterner = new WeakInterner(new TObjectHashingStrategy() { + private static final WeakInterner myTraceInterner = new WeakInterner<>(new TObjectHashingStrategy() { @Override public int computeHashCode(Throwable throwable) { String message = throwable.getMessage(); diff --git a/platform/util/src/com/intellij/openapi/util/registry/Registry.java b/platform/util/src/com/intellij/openapi/util/registry/Registry.java index 3b754c1ba582..6e4436fc2272 100644 --- a/platform/util/src/com/intellij/openapi/util/registry/Registry.java +++ b/platform/util/src/com/intellij/openapi/util/registry/Registry.java @@ -25,9 +25,9 @@ public class Registry { @NonNls public static final String REGISTRY_BUNDLE = "misc.registry"; - private final Map myUserProperties = new LinkedHashMap(); - private final ConcurrentMap myValues = new ConcurrentHashMap(); - private final Map myContributedKeys = new HashMap(); + private final Map myUserProperties = new LinkedHashMap<>(); + private final ConcurrentMap myValues = new ConcurrentHashMap<>(); + private final Map 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(bundle); + ourBundle = new SoftReference<>(bundle); } return bundle; } @@ -151,7 +151,7 @@ public class Registry { final ResourceBundle bundle = getBundle(); final Enumeration keys = bundle.getKeys(); - List result = new ArrayList(); + List result = new ArrayList<>(); Map contributedKeys = getInstance().myContributedKeys; while (keys.hasMoreElements()) { @@ -168,7 +168,7 @@ public class Registry { } void restoreDefaults() { - Map old = new HashMap(myUserProperties); + Map old = new HashMap<>(myUserProperties); for (String each : old.keySet()) { try { get(each).resetToDefault(); diff --git a/platform/util/src/com/intellij/openapi/util/text/LineTokenizer.java b/platform/util/src/com/intellij/openapi/util/text/LineTokenizer.java index 6be17426ec2c..73b2cf911fe6 100644 --- a/platform/util/src/com/intellij/openapi/util/text/LineTokenizer.java +++ b/platform/util/src/com/intellij/openapi/util/text/LineTokenizer.java @@ -53,7 +53,7 @@ public class LineTokenizer { } LineTokenizer tokenizer = new LineTokenizer(chars); - List lines = new ArrayList(); + List lines = new ArrayList<>(); while(!tokenizer.atEnd()){ int offset = tokenizer.getOffset(); String line; diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index 0601e83e1dd5..5cb3d06d203e 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -1270,7 +1270,7 @@ public class StringUtil extends StringUtilRt { if (separator.length() == 0) { return Collections.singletonList(s); } - List result = new ArrayList(); + List 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(); + result = new SmartList<>(); } result.add(text.substring(start, i + 1)); } else if (!isIdentifierPart && start != -1) { if (result == null) { - result = new SmartList(); + 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 getWordIndicesIn(@NotNull String text, @Nullable Set separatorsSet) { - List result = new SmartList(); + List 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 findMatches(@NotNull String s, @NotNull Pattern pattern, int groupIndex) { - List result = new SmartList(); + List result = new SmartList<>(); Matcher m = pattern.matcher(s); while (m.find()) { String group = m.group(groupIndex); diff --git a/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java b/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java index 7d7c13355bf3..a19e51c1a5a0 100644 --- a/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java +++ b/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java @@ -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_TO_MANDATORY_BOM = new THashMap(4); + @NonNls private static final Map 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); diff --git a/platform/util/src/com/intellij/openapi/wm/FocusWatcher.java b/platform/util/src/com/intellij/openapi/wm/FocusWatcher.java index 669d4752b641..d6560b43b0bf 100644 --- a/platform/util/src/com/intellij/openapi/wm/FocusWatcher.java +++ b/platform/util/src/com/intellij/openapi/wm/FocusWatcher.java @@ -126,7 +126,7 @@ public class FocusWatcher implements ContainerListener,FocusListener{ } public final void install(@NotNull Component component){ - myTopComponent = new WeakReference(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(focusedComponent); + myFocusedComponent = new WeakReference<>(focusedComponent); } private void setNearestFocusableComponent(final Component nearestFocusableComponent) { - myNearestFocusableComponent = new WeakReference(nearestFocusableComponent); + myNearestFocusableComponent = new WeakReference<>(nearestFocusableComponent); } } \ No newline at end of file diff --git a/platform/util/src/com/intellij/psi/codeStyle/AllOccurrencesMatcher.java b/platform/util/src/com/intellij/psi/codeStyle/AllOccurrencesMatcher.java index 85905391cec7..2581a503e83f 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/AllOccurrencesMatcher.java +++ b/platform/util/src/com/intellij/psi/codeStyle/AllOccurrencesMatcher.java @@ -51,7 +51,7 @@ public class AllOccurrencesMatcher extends MinusculeMatcher { public FList matchingFragments(@NotNull String name) { FList match = delegate.matchingFragments(name); if (!ContainerUtil.isEmpty(match)) { - List> allMatchesReversed = new ArrayList>(); + List> allMatchesReversed = new ArrayList<>(); int lastOffset = 0; while (!ContainerUtil.isEmpty(match)) { FList reversedWithAbsoluteOffsets = FList.emptyList(); diff --git a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java index 2582a9067a4d..0dd909208587 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java +++ b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java @@ -30,7 +30,7 @@ public class NameUtil { @NotNull public static String[] nameToWords(@NotNull String name){ - List array = new ArrayList(); + List 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 result = new ArrayList(); + List result = new ArrayList<>(); for (String word : underlineDelimited) { addAllWords(word, result); } @@ -242,7 +242,7 @@ public class NameUtil { boolean upperCaseStyle, boolean preferLongerNames, boolean isArray) { - ArrayList answer = new ArrayList(); + ArrayList answer = new ArrayList<>(); String[] words = nameToWords(name); for (int step = 0; step < words.length; step++) { diff --git a/platform/util/src/com/intellij/psi/codeStyle/TypoTolerantMatcher.java b/platform/util/src/com/intellij/psi/codeStyle/TypoTolerantMatcher.java index 575a130fb13e..4e323f654113 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/TypoTolerantMatcher.java +++ b/platform/util/src/com/intellij/psi/codeStyle/TypoTolerantMatcher.java @@ -753,7 +753,7 @@ class TypoTolerantMatcher extends MinusculeMatcher { } void addError(int index, @NotNull Error error) { - if (myErrors == null) myErrors = new SmartList>(); + if (myErrors == null) myErrors = new SmartList<>(); Pair pair = Pair.create(index, error); myErrors.add(pair); @@ -871,7 +871,7 @@ class TypoTolerantMatcher extends MinusculeMatcher { } public int length(char[] pattern) { - final Ref ref = new Ref(pattern.length); + final Ref ref = new Ref<>(pattern.length); processErrors(0, Integer.MAX_VALUE, new Processor>() { @Override public boolean process(Pair error) { diff --git a/platform/util/src/com/intellij/ui/JBColor.java b/platform/util/src/com/intellij/ui/JBColor.java index c31b682cd1d8..9e070997c39a 100644 --- a/platform/util/src/com/intellij/ui/JBColor.java +++ b/platform/util/src/com/intellij/ui/JBColor.java @@ -348,7 +348,7 @@ public class JBColor extends Color { return namedColor("Borders.color", new JBColor(Gray._192, Gray._50)); } - private static final Map defaultThemeColors = new HashMap(); + private static final Map defaultThemeColors = new HashMap<>(); @NotNull public static Color get(@NotNull final String colorId, @NotNull final Color defaultColor) { diff --git a/platform/util/src/com/intellij/ui/TableUtil.java b/platform/util/src/com/intellij/ui/TableUtil.java index 8365a71a4a6d..c69dca5b7be1 100644 --- a/platform/util/src/com/intellij/ui/TableUtil.java +++ b/platform/util/src/com/intellij/ui/TableUtil.java @@ -80,10 +80,10 @@ public class TableUtil { } if (table.getSelectionModel().isSelectionEmpty()) { - return new ArrayList(0); + return new ArrayList<>(0); } - final List removedItems = new SmartList(); + final List removedItems = new SmartList<>(); final ItemRemovable itemRemovable = (ItemRemovable)model; final int columnCount = model.getColumnCount(); doRemoveSelectedItems(table, new ItemRemovable() { diff --git a/platform/util/src/com/intellij/ui/UIBundle.java b/platform/util/src/com/intellij/ui/UIBundle.java index 8802f9dfe830..8d45841305d6 100644 --- a/platform/util/src/com/intellij/ui/UIBundle.java +++ b/platform/util/src/com/intellij/ui/UIBundle.java @@ -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(bundle); + ourBundle = new SoftReference<>(bundle); } return bundle; } diff --git a/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java b/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java index e0405fa532be..afddbc052776 100644 --- a/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java +++ b/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java @@ -27,7 +27,7 @@ public class Foundation { // May be removed if we use toStringViaUTF16 System.setProperty("jna.encoding", "UTF8"); - Map foundationOptions = new HashMap(); + Map 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 ourMainThreadRunnables = new HashMap(); + private static final Map 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 toStringMap(@Nullable ID delegate) { - Map result = new HashMap(); + Map result = new HashMap<>(); if (isNil(delegate)) { return result; } @@ -418,7 +418,7 @@ public class Foundation { @NotNull public List getList() { - List result = new ArrayList(); + List result = new ArrayList<>(); for (int i = 0; i < count(); i++) { result.add(at(i)); } diff --git a/platform/util/src/com/intellij/ui/mac/foundation/NSDefaults.java b/platform/util/src/com/intellij/ui/mac/foundation/NSDefaults.java index 4eb853675d0b..64593629a7c5 100644 --- a/platform/util/src/com/intellij/ui/mac/foundation/NSDefaults.java +++ b/platform/util/src/com/intellij/ui/mac/foundation/NSDefaults.java @@ -19,7 +19,7 @@ public class NSDefaults { public static final String ourTouchBarShowFnValue = "functionKeys"; private static class Path { - private final @NotNull ArrayList myPath = new ArrayList(); + private final @NotNull ArrayList myPath = new ArrayList<>(); @Override public String toString() { @@ -283,7 +283,7 @@ public class NSDefaults { // for debug private List _listAllKeys() { - List res = new ArrayList(100); + List res = new ArrayList<>(100); final Foundation.NSAutoreleasePool pool = new Foundation.NSAutoreleasePool(); try { final ID defaults = Foundation.invoke("NSUserDefaults", "standardUserDefaults"); diff --git a/platform/util/src/com/intellij/ui/paint/LinePainter2D.java b/platform/util/src/com/intellij/ui/paint/LinePainter2D.java index d0190c7e02f5..b717dbfeb378 100644 --- a/platform/util/src/com/intellij/ui/paint/LinePainter2D.java +++ b/platform/util/src/com/intellij/ui/paint/LinePainter2D.java @@ -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(_xy, prefSize); + return new Pair<>(_xy, prefSize); } /** diff --git a/platform/util/src/com/intellij/util/CollectConsumer.java b/platform/util/src/com/intellij/util/CollectConsumer.java index 620712a97700..0869fe7acff7 100644 --- a/platform/util/src/com/intellij/util/CollectConsumer.java +++ b/platform/util/src/com/intellij/util/CollectConsumer.java @@ -30,7 +30,7 @@ public class CollectConsumer implements Consumer { } public CollectConsumer() { - this(new SmartList()); + this(new SmartList<>()); } @Override diff --git a/platform/util/src/com/intellij/util/CommonProcessors.java b/platform/util/src/com/intellij/util/CommonProcessors.java index 23cde7005c87..474177a8d01f 100644 --- a/platform/util/src/com/intellij/util/CommonProcessors.java +++ b/platform/util/src/com/intellij/util/CommonProcessors.java @@ -38,7 +38,7 @@ public class CommonProcessors { } public CollectProcessor() { - myCollection = new ArrayList(); + myCollection = new ArrayList<>(); } @Override @@ -79,7 +79,7 @@ public class CommonProcessors { private final Set myCollection; public CollectUniquesProcessor() { - myCollection = new HashSet(); + myCollection = new HashSet<>(); } @Override @@ -109,7 +109,7 @@ public class CommonProcessors { public UniqueProcessor(@NotNull Processor delegate, @NotNull TObjectHashingStrategy strategy) { myDelegate = delegate; - processed = new THashSet(strategy); + processed = new THashSet<>(strategy); } @Override diff --git a/platform/util/src/com/intellij/util/ComponentTreeEventDispatcher.java b/platform/util/src/com/intellij/util/ComponentTreeEventDispatcher.java index 4c14925f0dae..ea38dcc76e9e 100644 --- a/platform/util/src/com/intellij/util/ComponentTreeEventDispatcher.java +++ b/platform/util/src/com/intellij/util/ComponentTreeEventDispatcher.java @@ -41,7 +41,7 @@ public class ComponentTreeEventDispatcher { } public static ComponentTreeEventDispatcher create(@Nullable Component root, @NotNull Class listenerClass) { - return new ComponentTreeEventDispatcher(root, listenerClass); + return new ComponentTreeEventDispatcher<>(root, listenerClass); } private ComponentTreeEventDispatcher(@Nullable final Component root, @NotNull Class listenerClass) { diff --git a/platform/util/src/com/intellij/util/ConcurrencyUtil.java b/platform/util/src/com/intellij/util/ConcurrencyUtil.java index d7ce10101e32..56548d194c06 100644 --- a/platform/util/src/com/intellij/util/ConcurrencyUtil.java +++ b/platform/util/src/com/intellij/util/ConcurrencyUtil.java @@ -46,7 +46,7 @@ public class ConcurrencyUtil { return null; } - List> futures = new ArrayList>(tasks.size()); + List> futures = new ArrayList<>(tasks.size()); boolean done = false; try { for (Callable 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(), newNamedThreadFactory(name, true, priority)); + new LinkedBlockingQueue<>(), newNamedThreadFactory(name, true, priority)); } @NotNull diff --git a/platform/util/src/com/intellij/util/EnvironmentUtil.java b/platform/util/src/com/intellij/util/EnvironmentUtil.java index 928b2abd6788..d2ecac83ff52 100644 --- a/platform/util/src/com/intellij/util/EnvironmentUtil.java +++ b/platform/util/src/com/intellij/util/EnvironmentUtil.java @@ -59,7 +59,7 @@ public class EnvironmentUtil { }); } else { - ourEnvGetter = new FixedFuture>(getSystemEnv()); + ourEnvGetter = new FixedFuture<>(getSystemEnv()); } } @@ -79,7 +79,7 @@ public class EnvironmentUtil { private static Map getSystemEnv() { if (SystemInfo.isWindows) { - return unmodifiableMap(new THashMap(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> readBatOutputAndEnv(@NotNull File batchFile, List args) throws Exception { File envFile = FileUtil.createTempFile("intellij-cmd-env.", ".tmp", false); try { - List cl = new ArrayList(); + List cl = new ArrayList<>(); cl.add(CommandLineUtil.getWinShellName()); cl.add("/c"); cl.add("call"); @@ -311,9 +311,9 @@ public class EnvironmentUtil { @NotNull public static Map parseEnv(String... lines) throws Exception { - Set toIgnore = new HashSet(Arrays.asList("_", "PWD", "SHLVL", DISABLE_OMZ_AUTO_UPDATE, INTELLIJ_ENVIRONMENT_READER)); + Set toIgnore = new HashSet<>(Arrays.asList("_", "PWD", "SHLVL", DISABLE_OMZ_AUTO_UPDATE, INTELLIJ_ENVIRONMENT_READER)); Map env = System.getenv(); - Map newEnv = new HashMap(); + Map newEnv = new HashMap<>(); for (String line : lines) { int pos = line.indexOf('='); diff --git a/platform/util/src/com/intellij/util/EventDispatcher.java b/platform/util/src/com/intellij/util/EventDispatcher.java index f58ed1af1bee..1fe1398aa60f 100644 --- a/platform/util/src/com/intellij/util/EventDispatcher.java +++ b/platform/util/src/com/intellij/util/EventDispatcher.java @@ -34,18 +34,18 @@ public class EventDispatcher { @NotNull public static EventDispatcher create(@NotNull Class listenerClass) { - return new EventDispatcher(listenerClass, null); + return new EventDispatcher<>(listenerClass, null); } @NotNull public static EventDispatcher create(@NotNull Class listenerClass, @NotNull Map methodReturnValues) { assertNonVoidMethodReturnValuesAreDeclared(methodReturnValues, listenerClass); - return new EventDispatcher(listenerClass, methodReturnValues); + return new EventDispatcher<>(listenerClass, methodReturnValues); } private static void assertNonVoidMethodReturnValuesAreDeclared(@NotNull Map methodReturnValues, @NotNull Class listenerClass) { - List declared = new ArrayList(ReflectionUtil.getClassPublicMethods(listenerClass)); + List declared = new ArrayList<>(ReflectionUtil.getClassPublicMethods(listenerClass)); for (final Map.Entry entry : methodReturnValues.entrySet()) { final String methodName = entry.getKey(); Method found = ContainerUtil.find(declared, new Condition() { diff --git a/platform/util/src/com/intellij/util/FieldAccessor.java b/platform/util/src/com/intellij/util/FieldAccessor.java index cfe8af35c357..fb6473cd94e0 100644 --- a/platform/util/src/com/intellij/util/FieldAccessor.java +++ b/platform/util/src/com/intellij/util/FieldAccessor.java @@ -43,7 +43,7 @@ public class FieldAccessor { public boolean isAvailable() { if (myFieldRef == null) { try { - myFieldRef = new Ref(); + myFieldRef = new Ref<>(); myFieldRef.set(myClass.getDeclaredField(myName)); myFieldRef.get().setAccessible(true); } diff --git a/platform/util/src/com/intellij/util/ListWithSelection.java b/platform/util/src/com/intellij/util/ListWithSelection.java index 44a9aa3dbb70..bea4491f73b2 100644 --- a/platform/util/src/com/intellij/util/ListWithSelection.java +++ b/platform/util/src/com/intellij/util/ListWithSelection.java @@ -31,7 +31,7 @@ public class ListWithSelection extends ArrayList { } public ListWithSelection() { - this(new ArrayList()); + this(new ArrayList<>()); } public boolean select(E object){ diff --git a/platform/util/src/com/intellij/util/NewInstanceFactory.java b/platform/util/src/com/intellij/util/NewInstanceFactory.java index 6a0695e2779e..16e327229c98 100644 --- a/platform/util/src/com/intellij/util/NewInstanceFactory.java +++ b/platform/util/src/com/intellij/util/NewInstanceFactory.java @@ -45,7 +45,7 @@ public class NewInstanceFactory implements Factory { public static Factory fromClass(@NotNull final Class clazz) { try { - return new NewInstanceFactory(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() { diff --git a/platform/util/src/com/intellij/util/ProcessingContext.java b/platform/util/src/com/intellij/util/ProcessingContext.java index 1ef90c83e6b8..8c7b0580c60e 100644 --- a/platform/util/src/com/intellij/util/ProcessingContext.java +++ b/platform/util/src/com/intellij/util/ProcessingContext.java @@ -69,7 +69,7 @@ public class ProcessingContext { } private void checkMapInitialized() { - if (myMap == null) myMap = new HashMap(1); + if (myMap == null) myMap = new HashMap<>(1); } } diff --git a/platform/util/src/com/intellij/util/ReflectionUtil.java b/platform/util/src/com/intellij/util/ReflectionUtil.java index 2f8e56f00428..3d683bdbc151 100644 --- a/platform/util/src/com/intellij/util/ReflectionUtil.java +++ b/platform/util/src/com/intellij/util/ReflectionUtil.java @@ -453,7 +453,7 @@ public class ReflectionUtil { Constructor[] constructors = aClass.getDeclaredConstructors(); Exception exception = null; - List> defaultCtors = new SmartList>(); + List> defaultCtors = new SmartList<>(); ctorLoop: for (Constructor constructor : constructors) { try { diff --git a/platform/util/src/com/intellij/util/ResourceUtil.java b/platform/util/src/com/intellij/util/ResourceUtil.java index f941e6c508e6..9af8dd677cbd 100644 --- a/platform/util/src/com/intellij/util/ResourceUtil.java +++ b/platform/util/src/com/intellij/util/ResourceUtil.java @@ -68,7 +68,7 @@ public class ResourceUtil { */ @NotNull private static List calculateBundleNames(@NotNull String baseName, @NotNull Locale locale) { - final List result = new ArrayList(3); + final List result = new ArrayList<>(3); result.add(0, baseName); diff --git a/platform/util/src/com/intellij/util/SingletonSet.java b/platform/util/src/com/intellij/util/SingletonSet.java index d289424a4e16..8db704baa98f 100644 --- a/platform/util/src/com/intellij/util/SingletonSet.java +++ b/platform/util/src/com/intellij/util/SingletonSet.java @@ -48,7 +48,7 @@ public class SingletonSet implements Set { @NotNull @Override public Iterator iterator() { - return new SingletonIterator(theElement); + return new SingletonIterator<>(theElement); } @NotNull @@ -125,7 +125,7 @@ public class SingletonSet implements Set { @NotNull public static Set withCustomStrategy(T o, @NotNull TObjectHashingStrategy strategy) { - return new CustomStrategySingletonSet(o, strategy); + return new CustomStrategySingletonSet<>(o, strategy); } private static class CustomStrategySingletonSet extends SingletonSet { diff --git a/platform/util/src/com/intellij/util/SmartFMap.java b/platform/util/src/com/intellij/util/SmartFMap.java index 3b1b59625b85..4239b68a4c2f 100644 --- a/platform/util/src/com/intellij/util/SmartFMap.java +++ b/platform/util/src/com/intellij/util/SmartFMap.java @@ -28,7 +28,7 @@ public class SmartFMap implements Map { } public SmartFMap plus(@NotNull K key, V value) { - return new SmartFMap(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 implements Map { public SmartFMap minus(@NotNull K key) { if (myMap instanceof Map) { - THashMap newMap = new THashMap((Map)myMap); + THashMap newMap = new THashMap<>((Map)myMap); newMap.remove(key); if (newMap.size() <= ARRAY_THRESHOLD) { Object[] newArray = new Object[newMap.size() * 2]; @@ -74,10 +74,10 @@ public class SmartFMap implements Map { newArray[i++] = k; newArray[i++] = newMap.get(k); } - return new SmartFMap(newArray); + return new SmartFMap<>(newArray); } - return new SmartFMap(newMap); + return new SmartFMap<>(newMap); } Object[] array = (Object[])myMap; @@ -90,7 +90,7 @@ public class SmartFMap implements Map { 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(newArray); + return new SmartFMap<>(newArray); } } return this; @@ -206,7 +206,7 @@ public class SmartFMap implements Map { public Set keySet() { if (isEmpty()) return Collections.emptySet(); - LinkedHashSet result = new LinkedHashSet(); + LinkedHashSet result = new LinkedHashSet<>(); for (Entry entry : entrySet()) { result.add(entry.getKey()); } @@ -218,7 +218,7 @@ public class SmartFMap implements Map { public Collection values() { if (isEmpty()) return Collections.emptyList(); - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); for (Entry entry : entrySet()) { result.add(entry.getValue()); } @@ -249,15 +249,15 @@ public class SmartFMap implements Map { public Set> entrySet() { if (isEmpty()) return Collections.emptySet(); - LinkedHashSet> set = new LinkedHashSet>(); + LinkedHashSet> set = new LinkedHashSet<>(); if (myMap instanceof Map) { for (Entry entry : ((Map)myMap).entrySet()) { - set.add(new AbstractMap.SimpleImmutableEntry(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)array[i], (V)array[i + 1])); + set.add(new AbstractMap.SimpleImmutableEntry<>((K)array[i], (V)array[i + 1])); } } return Collections.unmodifiableSet(set); diff --git a/platform/util/src/com/intellij/util/Timed.java b/platform/util/src/com/intellij/util/Timed.java index 3a6e83e0bc20..b0b12b9ee1da 100644 --- a/platform/util/src/com/intellij/util/Timed.java +++ b/platform/util/src/com/intellij/util/Timed.java @@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit; @SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext") abstract class Timed implements Disposable { private static final Logger LOG = Logger.getInstance("#com.intellij.util.Timed"); - private static final Map ourReferences = Collections.synchronizedMap(new WeakHashMap()); + private static final Map ourReferences = Collections.synchronizedMap(new WeakHashMap<>()); protected static final int SERVICE_DELAY = 60; private int myLastCheckedAccessCount; diff --git a/platform/util/src/com/intellij/util/TreeItem.java b/platform/util/src/com/intellij/util/TreeItem.java index 8aa1e339ba7a..c91368f3daf9 100644 --- a/platform/util/src/com/intellij/util/TreeItem.java +++ b/platform/util/src/com/intellij/util/TreeItem.java @@ -21,7 +21,7 @@ import java.util.List; public class TreeItem { private Data myData; private TreeItem myParent; - private final List> myChildren = new ArrayList>(); + private final List> myChildren = new ArrayList<>(); public TreeItem(Data data) { myData = data; diff --git a/platform/util/src/com/intellij/util/WeakListener.java b/platform/util/src/com/intellij/util/WeakListener.java index 12fe2aab3ebd..47f2bdf00f15 100644 --- a/platform/util/src/com/intellij/util/WeakListener.java +++ b/platform/util/src/com/intellij/util/WeakListener.java @@ -26,7 +26,7 @@ public abstract class WeakListener implements InvocationHandler{ protected WeakListener(Src source, Class listenerInterface, Listener listenerImpl) { mySource = source; - myDelegate = new WeakReference(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); diff --git a/platform/util/src/com/intellij/util/concurrency/AppScheduledExecutorService.java b/platform/util/src/com/intellij/util/concurrency/AppScheduledExecutorService.java index 526ab3fae4f5..70ad4aced261 100644 --- a/platform/util/src/com/intellij/util/concurrency/AppScheduledExecutorService.java +++ b/platform/util/src/com/intellij/util/concurrency/AppScheduledExecutorService.java @@ -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(), factory); + super(1, Integer.MAX_VALUE, 1, TimeUnit.MINUTES, new SynchronousQueue<>(), factory); } @Override diff --git a/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java b/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java index 30516eef13ad..8c996a477a21 100644 --- a/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java +++ b/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java @@ -47,17 +47,17 @@ public class AtomicFieldUpdater { @NotNull public static AtomicFieldUpdater forFieldOfType(@NotNull Class ownerClass, @NotNull Class fieldType) { - return new AtomicFieldUpdater(ownerClass, fieldType); + return new AtomicFieldUpdater<>(ownerClass, fieldType); } @NotNull public static AtomicFieldUpdater forLongFieldIn(@NotNull Class ownerClass) { - return new AtomicFieldUpdater(ownerClass, long.class); + return new AtomicFieldUpdater<>(ownerClass, long.class); } @NotNull public static AtomicFieldUpdater forIntFieldIn(@NotNull Class ownerClass) { - return new AtomicFieldUpdater(ownerClass, int.class); + return new AtomicFieldUpdater<>(ownerClass, int.class); } private AtomicFieldUpdater(@NotNull Class ownerClass, @NotNull Class fieldType) { diff --git a/platform/util/src/com/intellij/util/concurrency/BlockingSet.java b/platform/util/src/com/intellij/util/concurrency/BlockingSet.java index 21fd32ef3bbf..48620e04db07 100644 --- a/platform/util/src/com/intellij/util/concurrency/BlockingSet.java +++ b/platform/util/src/com/intellij/util/concurrency/BlockingSet.java @@ -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 { private final Lock lock; public BlockingSet() { - set = new HashSet(); + set = new HashSet<>(); lock = new ReentrantLock(); unlock = lock.newCondition(); } @@ -78,6 +78,6 @@ public class BlockingSet { } public static BlockingSet newInstance() { - return new BlockingSet(); + return new BlockingSet<>(); } } diff --git a/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java b/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java index 60b6f38c8409..1c3d818a9510 100644 --- a/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java +++ b/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java @@ -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 myTaskQueue = new LinkedBlockingQueue(); + private final BlockingQueue 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 currentTask = new AtomicReference(firstTask); + final AtomicReference currentTask = new AtomicReference<>(firstTask); myBackendExecutor.execute(new Runnable() { @Override public void run() { @@ -282,7 +282,7 @@ public class BoundedTaskExecutor extends AbstractExecutorService { @NotNull public List clearAndCancelAll() { - List queued = new ArrayList(); + List queued = new ArrayList<>(); myTaskQueue.drainTo(queued); for (Runnable task : queued) { if (task instanceof FutureTask) { diff --git a/platform/util/src/com/intellij/util/concurrency/FixedFuture.java b/platform/util/src/com/intellij/util/concurrency/FixedFuture.java index def50c5686d8..cf6a52ed43c0 100644 --- a/platform/util/src/com/intellij/util/concurrency/FixedFuture.java +++ b/platform/util/src/com/intellij/util/concurrency/FixedFuture.java @@ -36,7 +36,7 @@ public class FixedFuture implements Future { } public static FixedFuture completeExceptionally(@NotNull Throwable throwable) { - return new FixedFuture(throwable); + return new FixedFuture<>(throwable); } @Override diff --git a/platform/util/src/com/intellij/util/concurrency/SchedulingWrapper.java b/platform/util/src/com/intellij/util/concurrency/SchedulingWrapper.java index fe342491a038..9366fad27b33 100644 --- a/platform/util/src/com/intellij/util/concurrency/SchedulingWrapper.java +++ b/platform/util/src/com/intellij/util/concurrency/SchedulingWrapper.java @@ -69,7 +69,7 @@ class SchedulingWrapper implements ScheduledExecutorService { return false; } }); - delayQueue.removeAll(new HashSet(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 tasks = new ArrayList(delayQueue); + List tasks = new ArrayList<>(delayQueue); for (MyScheduledFutureTask task : tasks) { if (task.getBackendExecutorService() != backendExecutorService) { continue; @@ -321,7 +321,7 @@ class SchedulingWrapper implements ScheduledExecutorService { public ScheduledFuture schedule(@NotNull Callable callable, long delay, @NotNull TimeUnit unit) { - MyScheduledFutureTask t = new MyScheduledFutureTask(callable, triggerTime(delayQueue, delay, unit)); + MyScheduledFutureTask 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 sft = new MyScheduledFutureTask(command, - null, - triggerTime(delayQueue, initialDelay, unit), - unit.toNanos(-delay)); + MyScheduledFutureTask sft = new MyScheduledFutureTask<>(command, + null, + triggerTime(delayQueue, initialDelay, unit), + unit.toNanos(-delay)); return delayedExecute(sft); } diff --git a/platform/util/src/com/intellij/util/containers/ArrayListSet.java b/platform/util/src/com/intellij/util/containers/ArrayListSet.java index 6077133f80ec..c283ff522253 100644 --- a/platform/util/src/com/intellij/util/containers/ArrayListSet.java +++ b/platform/util/src/com/intellij/util/containers/ArrayListSet.java @@ -23,7 +23,7 @@ import java.util.Iterator; import java.util.List; public class ArrayListSet extends AbstractSet { - private final List myList = new ArrayList(); + private final List myList = new ArrayList<>(); @NotNull @Override diff --git a/platform/util/src/com/intellij/util/containers/BiDirectionalEnumerator.java b/platform/util/src/com/intellij/util/containers/BiDirectionalEnumerator.java index 7432f03731f2..f4fa99b9adfd 100644 --- a/platform/util/src/com/intellij/util/containers/BiDirectionalEnumerator.java +++ b/platform/util/src/com/intellij/util/containers/BiDirectionalEnumerator.java @@ -27,7 +27,7 @@ public class BiDirectionalEnumerator extends Enumerator { public BiDirectionalEnumerator(int expectNumber, @NotNull TObjectHashingStrategy strategy) { super(expectNumber, strategy); - myIntToObjectMap = new TIntObjectHashMap(expectNumber); + myIntToObjectMap = new TIntObjectHashMap<>(expectNumber); } @Override diff --git a/platform/util/src/com/intellij/util/containers/BidirectionalMap.java b/platform/util/src/com/intellij/util/containers/BidirectionalMap.java index 1bef4a92a8c3..d47454cbefa8 100644 --- a/platform/util/src/com/intellij/util/containers/BidirectionalMap.java +++ b/platform/util/src/com/intellij/util/containers/BidirectionalMap.java @@ -23,8 +23,8 @@ import java.util.HashMap; import java.util.*; public class BidirectionalMap implements Map{ - private final Map myKeyToValueMap = new THashMap(); - private final Map> myValueToKeysMap = new THashMap>(); + private final Map myKeyToValueMap = new THashMap<>(); + private final Map> myValueToKeysMap = new THashMap<>(); @Override public V put(K key, V value){ @@ -38,7 +38,7 @@ public class BidirectionalMap implements Map{ List array = myValueToKeysMap.get(value); if (array == null){ - array = new ArrayList(); + array = new ArrayList<>(); myValueToKeysMap.put(value, array); } array.add(key); @@ -130,6 +130,6 @@ public class BidirectionalMap implements Map{ @Override public String toString() { - return new HashMap(myKeyToValueMap).toString(); + return new HashMap<>(myKeyToValueMap).toString(); } } diff --git a/platform/util/src/com/intellij/util/containers/BidirectionalMultiMap.java b/platform/util/src/com/intellij/util/containers/BidirectionalMultiMap.java index 603791a2bc65..40bf77a176dc 100644 --- a/platform/util/src/com/intellij/util/containers/BidirectionalMultiMap.java +++ b/platform/util/src/com/intellij/util/containers/BidirectionalMultiMap.java @@ -30,7 +30,7 @@ public class BidirectionalMultiMap { private final Map> myValue2Keys; public BidirectionalMultiMap() { - this(new java.util.HashMap>(), new HashMap>()); + this(new java.util.HashMap<>(), new HashMap<>()); } public BidirectionalMultiMap(final Map> key2Values, final Map> value2Keys) { @@ -76,12 +76,12 @@ public class BidirectionalMultiMap { @NotNull protected Set createValuesSet() { - return new HashSet(); + return new HashSet<>(); } @NotNull protected Set createKeysSet() { - return new java.util.HashSet(); + return new java.util.HashSet<>(); } public boolean removeKey(K key) { diff --git a/platform/util/src/com/intellij/util/containers/ClassMap.java b/platform/util/src/com/intellij/util/containers/ClassMap.java index d2d3bbb3e6dc..7347b6a66148 100644 --- a/platform/util/src/com/intellij/util/containers/ClassMap.java +++ b/platform/util/src/com/intellij/util/containers/ClassMap.java @@ -28,7 +28,7 @@ public class ClassMap { protected final Map myMap; public ClassMap() { - this(new THashMap()); + this(new THashMap<>()); } protected ClassMap(@NotNull Map map) { myMap = map; diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentBitSet.java b/platform/util/src/com/intellij/util/containers/ConcurrentBitSet.java index 135ff949145c..efee2a05acc2 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentBitSet.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentBitSet.java @@ -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 arrays = new AtomicReferenceArray(32); + private final AtomicReferenceArray arrays = new AtomicReferenceArray<>(32); private static int arrayIndex(int bitIndex) { int i = (bitIndex >> ADDRESS_BITS_PER_WORD) + 1; return 31 - Integer.numberOfLeadingZeros(i); diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentFactoryMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentFactoryMap.java index 4a8ed6da46de..69de1b85c4b0 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentFactoryMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentFactoryMap.java @@ -88,7 +88,7 @@ public abstract class ConcurrentFactoryMap implements ConcurrentMap { @NotNull @Override public Set keySet() { - return new CollectionWrapper.Set(myMap.keySet()); + return new CollectionWrapper.Set<>(myMap.keySet()); } public boolean removeValue(Object value) { @@ -127,7 +127,7 @@ public abstract class ConcurrentFactoryMap implements ConcurrentMap { @NotNull @Override public Collection values() { - return new CollectionWrapper(myMap.values()); + return new CollectionWrapper<>(myMap.values()); } @NotNull @@ -141,7 +141,7 @@ public abstract class ConcurrentFactoryMap implements ConcurrentMap { @Override public Entry unwrap(Entry val) { - return val.getKey() == FAKE_NULL() || val.getValue() == FAKE_NULL() ? new EntryWrapper(val) : val; + return val.getKey() == FAKE_NULL() || val.getValue() == FAKE_NULL() ? new EntryWrapper<>(val) : val; } }; } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentIntKeyRefValueHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentIntKeyRefValueHashMap.java index 18a85fd0df84..b0b72e257563 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentIntKeyRefValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentIntKeyRefValueHashMap.java @@ -30,8 +30,8 @@ import java.util.*; * Null values are NOT allowed */ abstract class ConcurrentIntKeyRefValueHashMap implements ConcurrentIntObjectMap { - private final ConcurrentIntObjectHashMap> myMap = new ConcurrentIntObjectHashMap>(); - private final ReferenceQueue myQueue = new ReferenceQueue(); + private final ConcurrentIntObjectHashMap> myMap = new ConcurrentIntObjectHashMap<>(); + private final ReferenceQueue myQueue = new ReferenceQueue<>(); @NotNull protected abstract IntReference createReference(int key, @NotNull V value, @NotNull ReferenceQueue queue); @@ -176,7 +176,7 @@ abstract class ConcurrentIntKeyRefValueHashMap implements ConcurrentIntObject continue; } final int key = entry.getKey(); - nextVEntry = new SimpleEntry(key, v); + nextVEntry = new SimpleEntry<>(key, v); nextReferenceEntry = entry; return; } @@ -256,7 +256,7 @@ abstract class ConcurrentIntKeyRefValueHashMap implements ConcurrentIntObject @NotNull @Override public Collection values() { - Set result = new THashSet(); + Set result = new THashSet<>(); ContainerUtil.addAll(result, elements()); return result; } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentIntKeySoftValueHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentIntKeySoftValueHashMap.java index e42b279dda2a..9219cc39a958 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentIntKeySoftValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentIntKeySoftValueHashMap.java @@ -63,6 +63,6 @@ class ConcurrentIntKeySoftValueHashMap extends ConcurrentIntKeyRefValueHashMa @NotNull @Override protected IntReference createReference(int key, @NotNull V value, @NotNull ReferenceQueue queue) { - return new MyRef(key, value, queue); + return new MyRef<>(key, value, queue); } } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentIntKeyWeakValueHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentIntKeyWeakValueHashMap.java index 00c920c52980..dac77faf0b34 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentIntKeyWeakValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentIntKeyWeakValueHashMap.java @@ -63,6 +63,6 @@ class ConcurrentIntKeyWeakValueHashMap extends ConcurrentIntKeyRefValueHashMa @NotNull @Override protected IntReference createReference(int key, @NotNull V value, @NotNull ReferenceQueue queue) { - return new MyRef(key, value, queue); + return new MyRef<>(key, value, queue); } } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentIntObjectHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentIntObjectHashMap.java index 80395bb6e148..91d4164a96c1 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentIntObjectHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentIntObjectHashMap.java @@ -497,7 +497,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { public boolean containsValue(@NotNull Object value) { Node[] t; if ((t = table) != null) { - Traverser it = new Traverser(t, t.length, 0, t.length); + Traverser it = new Traverser<>(t, t.length, 0, t.length); for (Node p; (p = it.advance()) != null; ) { V v; if ((v = p.val) == value || (v != null && value.equals(v))) { @@ -539,7 +539,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { } else if ((f = tabAt(tab, i = (n - 1) & hash)) == null) { if (casTabAt(tab, i, null, - new Node(hash, key, value, null))) { + new Node<>(hash, key, value, null))) { break; // no lock when adding to empty bin } } @@ -562,8 +562,8 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { } Node pred = e; if ((e = e.next) == null) { - pred.next = new Node(hash, key, - value, null); + pred.next = new Node<>(hash, key, + value, null); break; } } @@ -751,7 +751,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { @Override public Collection values() { ValuesView vs; - return (vs = values) != null ? vs : (values = new ValuesView(this)); + return (vs = values) != null ? vs : (values = new ValuesView<>(this)); } /** @@ -773,7 +773,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { @NotNull public Set> entrySet() { EntrySetView es; - return (es = entrySet) != null ? es : (entrySet = new EntrySetView(this)); + return (es = entrySet) != null ? es : (entrySet = new EntrySetView<>(this)); } /** @@ -788,7 +788,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { int h = 0; Node[] t; if ((t = table) != null) { - Traverser it = new Traverser(t, t.length, 0, t.length); + Traverser it = new Traverser<>(t, t.length, 0, t.length); for (Node p; (p = it.advance()) != null; ) { h += p.key ^ p.val.hashCode(); } @@ -811,7 +811,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { public String toString() { Node[] t; int f = (t = table) == null ? 0 : t.length; - Traverser it = new Traverser(t, f, 0, f); + Traverser it = new Traverser<>(t, f, 0, f); StringBuilder sb = new StringBuilder(); sb.append('{'); Node p; @@ -850,7 +850,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { IntObjectMap m = (IntObjectMap)o; Node[] t; int f = (t = table) == null ? 0 : t.length; - Traverser it = new Traverser(t, f, 0, f); + Traverser it = new Traverser<>(t, f, 0, f); for (Node p; (p = it.advance()) != null; ) { V val = p.val; Object v = m.get(p.key); @@ -956,7 +956,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { @NotNull @Override public int[] keys() { - Object[] entries = new EntrySetView(this).toArray(); + Object[] entries = new EntrySetView<>(this).toArray(); int[] result = new int[entries.length]; for (int i = 0; i < entries.length; i++) { Entry entry = (Entry)entries[i]; @@ -976,7 +976,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { public Enumeration elements() { Node[] t; int f = (t = table) == null ? 0 : t.length; - return new ValueIterator(t, f, 0, f, this); + return new ValueIterator<>(t, f, 0, f, this); } // ConcurrentHashMap-only methods @@ -1237,7 +1237,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { transferIndex = n; } int nextn = nextTab.length; - ForwardingNode fwd = new ForwardingNode(nextTab); + ForwardingNode 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 implements ConcurrentIntObjectMap { int pk = p.key; V pv = p.val; if ((ph & n) == 0) { - ln = new Node(ph, pk, pv, ln); + ln = new Node<>(ph, pk, pv, ln); } else { - hn = new Node(ph, pk, pv, hn); + hn = new Node<>(ph, pk, pv, hn); } } setTabAt(nextTab, i, ln); @@ -1328,7 +1328,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { int lc = 0, hc = 0; for (Node e = t.first; e != null; e = e.next) { int h = e.hash; - TreeNode p = new TreeNode + TreeNode 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 implements ConcurrentIntObjectMap { } } ln = (lc <= UNTREEIFY_THRESHOLD) ? untreeify(lo) : - (hc != 0) ? new TreeBin(lo) : t; + (hc != 0) ? new TreeBin<>(lo) : t; hn = (hc <= UNTREEIFY_THRESHOLD) ? untreeify(hi) : - (lc != 0) ? new TreeBin(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 implements ConcurrentIntObjectMap { TreeNode hd = null, tl = null; for (Node e = b; e != null; e = e.next) { TreeNode p = - new TreeNode(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 implements ConcurrentIntObjectMap { } tl = p; } - setTabAt(tab, index, new TreeBin(hd)); + setTabAt(tab, index, new TreeBin<>(hd)); } } } @@ -1522,7 +1522,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { static Node untreeify(Node b) { Node hd = null, tl = null; for (Node q = b; q != null; q = q.next) { - Node p = new Node(q.hash, q.key, q.val, null); + Node p = new Node<>(q.hash, q.key, q.val, null); if (tl == null) { hd = p; } @@ -1757,7 +1757,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { for (TreeNode p = root; ; ) { int dir, ph; if (p == null) { - first = root = new TreeNode(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 implements ConcurrentIntObjectMap { TreeNode xp = p; if ((p = (dir <= 0) ? p.left : p.right) == null) { TreeNode x, f = first; - first = x = new TreeNode(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 implements ConcurrentIntObjectMap { spare = s.next; } else { - s = new TableStack(); + s = new TableStack<>(); } s.tab = t; s.length = n; @@ -2414,7 +2414,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { final V v = p.val; lastReturned = p; advance(); - return new SimpleEntry(k, v); + return new SimpleEntry<>(k, v); } } @@ -2648,7 +2648,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { ConcurrentIntObjectHashMap m = map; Node[] t; int f = (t = m.table) == null ? 0 : t.length; - return new ValueIterator(t, f, 0, f, m); + return new ValueIterator<>(t, f, 0, f, m); } @Override @@ -2704,7 +2704,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { ConcurrentIntObjectHashMap m = map; Node[] t; int f = (t = m.table) == null ? 0 : t.length; - return new EntryIterator(t, f, 0, f, m); + return new EntryIterator<>(t, f, 0, f, m); } @Override @@ -2728,7 +2728,7 @@ class ConcurrentIntObjectHashMap implements ConcurrentIntObjectMap { int h = 0; Node[] t; if ((t = map.table) != null) { - Traverser it = new Traverser(t, t.length, 0, t.length); + Traverser it = new Traverser<>(t, t.length, 0, t.length); for (Node p; (p = it.advance()) != null; ) { h += p.hashCode(); } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentLongObjectHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentLongObjectHashMap.java index bc33d531c8a9..7623183a1641 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentLongObjectHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentLongObjectHashMap.java @@ -460,7 +460,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { public boolean containsValue(@NotNull Object value) { Node[] t; if ((t = table) != null) { - Traverser it = new Traverser(t, t.length, 0, t.length); + Traverser it = new Traverser<>(t, t.length, 0, t.length); for (Node p; (p = it.advance()) != null; ) { V v; if ((v = p.val) == value || (v != null && value.equals(v))) { @@ -502,7 +502,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { } else if ((f = tabAt(tab, i = (n - 1) & hash)) == null) { if (casTabAt(tab, i, null, - new Node(hash, key, value, null))) { + new Node<>(hash, key, value, null))) { break; // no lock when adding to empty bin } } @@ -525,8 +525,8 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { } Node pred = e; if ((e = e.next) == null) { - pred.next = new Node(hash, key, - value, null); + pred.next = new Node<>(hash, key, + value, null); break; } } @@ -714,7 +714,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { @Override public Collection values() { ValuesView vs; - return (vs = values) != null ? vs : (values = new ValuesView(this)); + return (vs = values) != null ? vs : (values = new ValuesView<>(this)); } /** @@ -734,7 +734,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { */ public Set> entrySet() { EntrySetView es; - return (es = entrySet) != null ? es : (entrySet = new EntrySetView(this)); + return (es = entrySet) != null ? es : (entrySet = new EntrySetView<>(this)); } /** @@ -749,7 +749,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { int h = 0; Node[] t; if ((t = table) != null) { - Traverser it = new Traverser(t, t.length, 0, t.length); + Traverser it = new Traverser<>(t, t.length, 0, t.length); for (Node p; (p = it.advance()) != null; ) { h += p.key ^ p.val.hashCode(); } @@ -772,7 +772,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { public String toString() { Node[] t; int f = (t = table) == null ? 0 : t.length; - Traverser it = new Traverser(t, f, 0, f); + Traverser it = new Traverser<>(t, f, 0, f); StringBuilder sb = new StringBuilder(); sb.append('{'); Node p; @@ -811,7 +811,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { ConcurrentLongObjectMap m = (ConcurrentLongObjectMap)o; Node[] t; int f = (t = table) == null ? 0 : t.length; - Traverser it = new Traverser(t, f, 0, f); + Traverser it = new Traverser<>(t, f, 0, f); for (Node p; (p = it.advance()) != null; ) { V val = p.val; Object v = m.get(p.key); @@ -918,7 +918,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { @NotNull @Override public long[] keys() { - Object[] entries = new EntrySetView(this).toArray(); + Object[] entries = new EntrySetView<>(this).toArray(); long[] result = new long[entries.length]; for (int i = 0; i < entries.length; i++) { LongEntry entry = (LongEntry)entries[i]; @@ -938,7 +938,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { public Enumeration elements() { Node[] t; int f = (t = table) == null ? 0 : t.length; - return new ValueIterator(t, f, 0, f, this); + return new ValueIterator<>(t, f, 0, f, this); } // ConcurrentHashMap-only methods @@ -1199,7 +1199,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { transferIndex = n; } int nextn = nextTab.length; - ForwardingNode fwd = new ForwardingNode(nextTab); + ForwardingNode fwd = new ForwardingNode<>(nextTab); boolean advance = true; boolean finishing = false; // to ensure sweep before committing nextTab for (int i = 0, bound = 0; ; ) { @@ -1272,10 +1272,10 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { long pk = p.key; V pv = p.val; if ((ph & n) == 0) { - ln = new Node(ph, pk, pv, ln); + ln = new Node<>(ph, pk, pv, ln); } else { - hn = new Node(ph, pk, pv, hn); + hn = new Node<>(ph, pk, pv, hn); } } setTabAt(nextTab, i, ln); @@ -1290,7 +1290,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { int lc = 0, hc = 0; for (Node e = t.first; e != null; e = e.next) { int h = e.hash; - TreeNode p = new TreeNode + TreeNode p = new TreeNode<> (h, e.key, e.val, null, null); if ((h & n) == 0) { if ((p.prev = loTail) == null) { @@ -1314,9 +1314,9 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { } } ln = (lc <= UNTREEIFY_THRESHOLD) ? untreeify(lo) : - (hc != 0) ? new TreeBin(lo) : t; + (hc != 0) ? new TreeBin<>(lo) : t; hn = (hc <= UNTREEIFY_THRESHOLD) ? untreeify(hi) : - (lc != 0) ? new TreeBin(hi) : t; + (lc != 0) ? new TreeBin<>(hi) : t; setTabAt(nextTab, i, ln); setTabAt(nextTab, i + n, hn); setTabAt(tab, i, fwd); @@ -1461,8 +1461,8 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { TreeNode hd = null, tl = null; for (Node e = b; e != null; e = e.next) { TreeNode p = - new TreeNode(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; } @@ -1471,7 +1471,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { } tl = p; } - setTabAt(tab, index, new TreeBin(hd)); + setTabAt(tab, index, new TreeBin<>(hd)); } } } @@ -1484,7 +1484,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { static Node untreeify(Node b) { Node hd = null, tl = null; for (Node q = b; q != null; q = q.next) { - Node p = new Node(q.hash, q.key, q.val, null); + Node p = new Node<>(q.hash, q.key, q.val, null); if (tl == null) { hd = p; } @@ -1719,7 +1719,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { for (TreeNode p = root; ; ) { int dir, ph; if (p == null) { - first = root = new TreeNode(h, k, v, null, null); + first = root = new TreeNode<>(h, k, v, null, null); break; } else if ((ph = p.hash) > h) { @@ -1748,7 +1748,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { TreeNode xp = p; if ((p = (dir <= 0) ? p.left : p.right) == null) { TreeNode x, f = first; - first = x = new TreeNode(h, k, v, f, xp); + first = x = new TreeNode<>(h, k, v, f, xp); if (f != null) { f.prev = x; } @@ -2265,7 +2265,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { spare = s.next; } else { - s = new TableStack(); + s = new TableStack<>(); } s.tab = t; s.length = n; @@ -2618,7 +2618,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { ConcurrentLongObjectHashMap m = map; Node[] t; int f = (t = m.table) == null ? 0 : t.length; - return new ValueIterator(t, f, 0, f, m); + return new ValueIterator<>(t, f, 0, f, m); } @Override @@ -2635,7 +2635,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { @NotNull @Override public Iterable> entries() { - return new EntrySetView(this); + return new EntrySetView<>(this); } /** @@ -2680,7 +2680,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { ConcurrentLongObjectHashMap m = map; Node[] t; int f = (t = m.table) == null ? 0 : t.length; - return new EntryIterator(t, f, 0, f, m); + return new EntryIterator<>(t, f, 0, f, m); } @Override @@ -2704,7 +2704,7 @@ class ConcurrentLongObjectHashMap implements ConcurrentLongObjectMap { int h = 0; Node[] t; if ((t = map.table) != null) { - Traverser it = new Traverser(t, t.length, 0, t.length); + Traverser it = new Traverser<>(t, t.length, 0, t.length); for (Node p; (p = it.advance()) != null; ) { h += p.hashCode(); } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentMostlySingularMultiMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentMostlySingularMultiMap.java index 845e587a7b74..37614e793e07 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentMostlySingularMultiMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentMostlySingularMultiMap.java @@ -40,13 +40,13 @@ public class ConcurrentMostlySingularMultiMap extends MostlySingularMultiM } else if (current instanceof MostlySingularMultiMap.ValueList) { ValueList curList = (ValueList)current; - ValueList newList = new ValueList(curList.size() + 1); + ValueList newList = new ValueList<>(curList.size() + 1); newList.addAll(curList); newList.add(value); if (map.replace(key, curList, newList)) break; } else { - ValueList newList = new ValueList(2); + ValueList newList = new ValueList<>(2); newList.add(current); newList.add(value); if (map.replace(key, current, newList)) break; diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentRefHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentRefHashMap.java index d56b5153fdfb..589b31927b34 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentRefHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentRefHashMap.java @@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentMap; * Null values are NOT allowed */ abstract class ConcurrentRefHashMap extends AbstractMap implements ConcurrentMap, TObjectHashingStrategy { - final ReferenceQueue myReferenceQueue = new ReferenceQueue(); + final ReferenceQueue myReferenceQueue = new ReferenceQueue<>(); private final ConcurrentMap, V> myMap; // hashing strategy must be canonical, we compute corresponding hash codes using our own myHashingStrategy @NotNull private final TObjectHashingStrategy myHashingStrategy; @@ -288,7 +288,7 @@ abstract class ConcurrentRefHashMap extends AbstractMap implements C /* Weak key has been cleared by GC */ continue; } - next = new RefEntry(ent, k); + next = new RefEntry<>(ent, k); return true; } return false; diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentRefValueHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentRefValueHashMap.java index 740265a0fae7..1d9c73a30329 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentRefValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentRefValueHashMap.java @@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentMap; */ abstract class ConcurrentRefValueHashMap implements ConcurrentMap { private final ConcurrentMap> myMap = ContainerUtil.newConcurrentMap(); - protected final ReferenceQueue myQueue = new ReferenceQueue(); + protected final ReferenceQueue myQueue = new ReferenceQueue<>(); interface ValueReference { @NotNull @@ -166,7 +166,7 @@ abstract class ConcurrentRefValueHashMap implements ConcurrentMap { @NotNull @Override public Collection values() { - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); final Collection> refs = myMap.values(); for (ValueReference ref : refs) { final V value = ref.get(); @@ -181,7 +181,7 @@ abstract class ConcurrentRefValueHashMap implements ConcurrentMap { @Override public Set> entrySet() { final Set keys = keySet(); - Set> entries = new HashSet>(); + Set> entries = new HashSet<>(); for (final K key : keys) { final V value = get(key); diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentSoftHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentSoftHashMap.java index 62b2c07baf4b..ef7649363c30 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentSoftHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentSoftHashMap.java @@ -73,6 +73,6 @@ final class ConcurrentSoftHashMap extends ConcurrentRefHashMap { @Override protected KeyReference createKeyReference(@NotNull K key, @NotNull TObjectHashingStrategy hashingStrategy) { - return new SoftKey(key, hashingStrategy.computeHashCode(key), hashingStrategy, myReferenceQueue); + return new SoftKey<>(key, hashingStrategy.computeHashCode(key), hashingStrategy, myReferenceQueue); } } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentSoftKeySoftValueHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentSoftKeySoftValueHashMap.java index e7d40ce03cc1..fe0dc6f744dc 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentSoftKeySoftValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentSoftKeySoftValueHashMap.java @@ -77,7 +77,7 @@ class ConcurrentSoftKeySoftValueHashMap extends ConcurrentWeakKeySoftValue @NotNull KeyReference createKeyReference(@NotNull K k, @NotNull final V v) { final ValueReference valueReference = createValueReference(v, myValueQueue); - SoftKey keyReference = new SoftKey(k, valueReference, myHashingStrategy, myKeyQueue); + SoftKey keyReference = new SoftKey<>(k, valueReference, myHashingStrategy, myKeyQueue); if (valueReference instanceof SoftValue) { ((SoftValue)valueReference).myKeyReference = keyReference; } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentSoftValueHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentSoftValueHashMap.java index 9494f21f48d0..51a870339ce7 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentSoftValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentSoftValueHashMap.java @@ -60,6 +60,6 @@ final class ConcurrentSoftValueHashMap extends ConcurrentRefValueHashMap createValueReference(@NotNull K key, @NotNull V value) { - return new MySoftReference(key, value, myQueue); + return new MySoftReference<>(key, value, myQueue); } } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentWeakHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentWeakHashMap.java index 50b098293652..798f96876fac 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentWeakHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentWeakHashMap.java @@ -64,7 +64,7 @@ public final class ConcurrentWeakHashMap extends ConcurrentRefHashMap createKeyReference(@NotNull K key, @NotNull TObjectHashingStrategy hashingStrategy) { - return new WeakKey(key, hashingStrategy.computeHashCode(key), hashingStrategy, myReferenceQueue); + return new WeakKey<>(key, hashingStrategy.computeHashCode(key), hashingStrategy, myReferenceQueue); } @Deprecated diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentWeakKeySoftValueHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentWeakKeySoftValueHashMap.java index dac7be3e7a2f..2304f502b961 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentWeakKeySoftValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentWeakKeySoftValueHashMap.java @@ -37,8 +37,8 @@ import java.util.concurrent.ConcurrentMap; @Deprecated public class ConcurrentWeakKeySoftValueHashMap implements ConcurrentMap { private final ConcurrentMap, ValueReference> myMap; - final ReferenceQueue myKeyQueue = new ReferenceQueue(); - final ReferenceQueue myValueQueue = new ReferenceQueue(); + final ReferenceQueue myKeyQueue = new ReferenceQueue<>(); + final ReferenceQueue myValueQueue = new ReferenceQueue<>(); @NotNull final TObjectHashingStrategy myHashingStrategy; protected ConcurrentWeakKeySoftValueHashMap(int initialCapacity, @@ -137,7 +137,7 @@ public class ConcurrentWeakKeySoftValueHashMap implements ConcurrentMap createKeyReference(@NotNull K k, @NotNull final V v) { final ValueReference valueReference = createValueReference(v, myValueQueue); - WeakKey keyReference = new WeakKey(k, valueReference, myHashingStrategy, myKeyQueue); + WeakKey keyReference = new WeakKey<>(k, valueReference, myHashingStrategy, myKeyQueue); if (valueReference instanceof SoftValue) { ((SoftValue)valueReference).myKeyReference = keyReference; } @@ -146,7 +146,7 @@ public class ConcurrentWeakKeySoftValueHashMap implements ConcurrentMap createValueReference(@NotNull V value, @NotNull ReferenceQueue queue) { - return new SoftValue(value, queue); + return new SoftValue<>(value, queue); } @Override diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentWeakKeyWeakValueHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentWeakKeyWeakValueHashMap.java index c9ed750e86aa..f35c56dcbbcc 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentWeakKeyWeakValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentWeakKeyWeakValueHashMap.java @@ -65,7 +65,7 @@ class ConcurrentWeakKeyWeakValueHashMap extends ConcurrentWeakKeySoftValue @NotNull KeyReference createKeyReference(@NotNull K k, @NotNull final V v) { final ValueReference valueReference = createValueReference(v, myValueQueue); - WeakKey keyReference = new WeakKey(k, valueReference, myHashingStrategy, myKeyQueue); + WeakKey keyReference = new WeakKey<>(k, valueReference, myHashingStrategy, myKeyQueue); if (valueReference instanceof WeakValue) { ((WeakValue)valueReference).myKeyReference = keyReference; } @@ -75,6 +75,6 @@ class ConcurrentWeakKeyWeakValueHashMap extends ConcurrentWeakKeySoftValue @Override @NotNull protected ValueReference createValueReference(@NotNull V value, @NotNull ReferenceQueue queue) { - return new WeakValue(value, queue); + return new WeakValue<>(value, queue); } } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentWeakValueHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentWeakValueHashMap.java index 1a91b1329b31..49db70c1f0a2 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentWeakValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentWeakValueHashMap.java @@ -59,6 +59,6 @@ final class ConcurrentWeakValueHashMap extends ConcurrentRefValueHashMap createValueReference(@NotNull K key, @NotNull V value) { - return new MyWeakReference(key, value, myQueue); + return new MyWeakReference<>(key, value, myQueue); } } diff --git a/platform/util/src/com/intellij/util/containers/ContainerUtil.java b/platform/util/src/com/intellij/util/containers/ContainerUtil.java index 8539b7601c29..a150155089eb 100644 --- a/platform/util/src/com/intellij/util/containers/ContainerUtil.java +++ b/platform/util/src/com/intellij/util/containers/ContainerUtil.java @@ -30,13 +30,13 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static HashMap newHashMap() { - return new HashMap(); + return new HashMap<>(); } @NotNull @Contract(pure=true) public static HashMap newHashMap(@NotNull Map map) { - return new HashMap(map); + return new HashMap<>(map); } @NotNull @@ -90,19 +90,19 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static THashMap newTroveMap() { - return new THashMap(); + return new THashMap<>(); } @NotNull @Contract(pure=true) public static THashMap newTroveMap(@NotNull TObjectHashingStrategy strategy) { - return new THashMap(strategy); + return new THashMap<>(strategy); } @NotNull @Contract(pure=true) public static , V> EnumMap newEnumMap(@NotNull Class keyType) { - return new EnumMap(keyType); + return new EnumMap<>(keyType); } @SuppressWarnings("unchecked") @@ -122,7 +122,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static IdentityHashMap newIdentityHashMap() { - return new IdentityHashMap(); + return new IdentityHashMap<>(); } @NotNull @@ -146,7 +146,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static ArrayList newArrayList() { - return new ArrayList(); + return new ArrayList<>(); } @NotNull @@ -164,7 +164,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static ArrayList newArrayListWithCapacity(int size) { - return new ArrayList(size); + return new ArrayList<>(size); } @NotNull @@ -261,31 +261,31 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static List newSmartList() { - return new SmartList(); + return new SmartList<>(); } @NotNull @Contract(pure=true) public static List newSmartList(T element) { - return new SmartList(element); + return new SmartList<>(element); } @NotNull @Contract(pure=true) public static List newSmartList(@NotNull T... elements) { - return new SmartList(elements); + return new SmartList<>(elements); } @NotNull @Contract(pure=true) public static HashSet newHashSet() { - return new HashSet(); + return new HashSet<>(); } @NotNull @Contract(pure=true) public static HashSet newHashSet(int initialCapacity) { - return new HashSet(initialCapacity); + return new HashSet<>(initialCapacity); } @NotNull @@ -333,13 +333,13 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static THashSet newTroveSet() { - return new THashSet(); + return new THashSet<>(); } @NotNull @Contract(pure=true) public static THashSet newTroveSet(@NotNull TObjectHashingStrategy strategy) { - return new THashSet(strategy); + return new THashSet<>(strategy); } @NotNull @@ -351,42 +351,42 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static THashSet newTroveSet(@NotNull TObjectHashingStrategy strategy, @NotNull T... elements) { - return new THashSet(Arrays.asList(elements), strategy); + return new THashSet<>(Arrays.asList(elements), strategy); } @NotNull @Contract(pure=true) public static THashSet newTroveSet(@NotNull TObjectHashingStrategy strategy, @NotNull Collection elements) { - return new THashSet(elements, strategy); + return new THashSet<>(elements, strategy); } @NotNull @Contract(pure=true) public static THashSet newTroveSet(@NotNull Collection elements) { - return new THashSet(elements); + return new THashSet<>(elements); } @NotNull @Contract(pure=true) public static THashSet newIdentityTroveSet() { - return new THashSet(ContainerUtil.identityStrategy()); + return new THashSet<>(ContainerUtil.identityStrategy()); } @NotNull @Contract(pure=true) public static THashSet newIdentityTroveSet(int initialCapacity) { - return new THashSet(initialCapacity, ContainerUtil.identityStrategy()); + return new THashSet<>(initialCapacity, ContainerUtil.identityStrategy()); } @NotNull @Contract(pure=true) public static THashSet newIdentityTroveSet(@NotNull Collection collection) { - return new THashSet(collection, ContainerUtil.identityStrategy()); + return new THashSet<>(collection, ContainerUtil.identityStrategy()); } @NotNull @Contract(pure=true) public static THashMap newIdentityTroveMap() { - return new THashMap(ContainerUtil.identityStrategy()); + return new THashMap<>(ContainerUtil.identityStrategy()); } @NotNull @@ -416,17 +416,17 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static ConcurrentMap newConcurrentMap() { - return new ConcurrentHashMap(); + return new ConcurrentHashMap<>(); } @Contract(pure=true) public static ConcurrentMap newConcurrentMap(int initialCapacity) { - return new ConcurrentHashMap(initialCapacity); + return new ConcurrentHashMap<>(initialCapacity); } @Contract(pure=true) public static ConcurrentMap newConcurrentMap(int initialCapacity, float loadFactor, int concurrencyLevel) { - return new ConcurrentHashMap(initialCapacity, loadFactor, concurrencyLevel); + return new ConcurrentHashMap<>(initialCapacity, loadFactor, concurrencyLevel); } @NotNull @@ -452,7 +452,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static Map union(@NotNull Map map, @NotNull Map map2) { - Map result = new THashMap(map.size() + map2.size()); + Map result = new THashMap<>(map.size() + map2.size()); result.putAll(map); result.putAll(map2); return result; @@ -467,7 +467,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static Set union(@NotNull Collection set, @NotNull Collection set2) { - Set result = new THashSet(set.size() + set2.size()); + Set result = new THashSet<>(set.size() + set2.size()); result.addAll(set); result.addAll(set2); return result; @@ -482,14 +482,14 @@ public class ContainerUtil extends ContainerUtilRt { case 1: return Collections.singleton(elements[0]); default: - return Collections.unmodifiableSet(new THashSet(Arrays.asList(elements))); + return Collections.unmodifiableSet(new THashSet<>(Arrays.asList(elements))); } } @NotNull @Contract(pure=true) public static ImmutableList immutableList(@NotNull E ... array) { - return new ImmutableListBackedByArray(array); + return new ImmutableListBackedByArray<>(array); } @NotNull @@ -501,13 +501,13 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static ImmutableList immutableList(@NotNull List list) { - return new ImmutableListBackedByList(list); + return new ImmutableListBackedByList<>(list); } @NotNull @Contract(pure=true) public static ImmutableMapBuilder immutableMapBuilder() { - return new ImmutableMapBuilder(); + return new ImmutableMapBuilder<>(); } @NotNull @@ -535,7 +535,7 @@ public class ContainerUtil extends ContainerUtilRt { } public static class ImmutableMapBuilder { - private final Map myMap = new THashMap(); + private final Map myMap = new THashMap<>(); public ImmutableMapBuilder put(K key, V value) { myMap.put(key, value); @@ -606,7 +606,7 @@ public class ContainerUtil extends ContainerUtilRt { map1 = map2; map2 = t; } - final Map res = new HashMap(map1); + final Map res = new HashMap<>(map1); for (Map.Entry entry : map2.entrySet()) { K key = entry.getKey(); V v2 = entry.getValue(); @@ -622,7 +622,7 @@ public class ContainerUtil extends ContainerUtilRt { @Contract(pure=true) public static Map> diff(@NotNull Map map1, @NotNull Map map2) { Set keys = union(map1.keySet(), map2.keySet()); - Map> res = new HashMap>(); + Map> res = new HashMap<>(); for (K k : keys) { V v1 = map1.get(k); V v2 = map2.get(k); @@ -682,7 +682,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull List list2, @NotNull Comparator comparator, boolean mergeEqualItems) { - final List result = new ArrayList(list1.size() + list2.size()); + final List result = new ArrayList<>(list1.size() + list2.size()); processSortedListsInOrder(list1, list2, comparator, mergeEqualItems, new Consumer() { @Override public void consume(T t) { @@ -731,7 +731,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull public static List collect(@NotNull Iterator iterator) { if (!iterator.hasNext()) return emptyList(); - List list = new ArrayList(); + List list = new ArrayList<>(); addAll(list, iterator); return list; } @@ -739,7 +739,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull public static Set collectSet(@NotNull Iterator iterator) { if (!iterator.hasNext()) return Collections.emptySet(); - Set hashSet = new HashSet(); + Set hashSet = new HashSet<>(); addAll(hashSet, iterator); return hashSet; } @@ -747,7 +747,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure = true) public static Map newMapFromKeys(@NotNull Iterator keys, @NotNull Convertor valueConvertor) { - Map map = new HashMap(); + Map map = new HashMap<>(); while (keys.hasNext()) { K key = keys.next(); map.put(key, valueConvertor.convert(key)); @@ -758,7 +758,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure = true) public static Map newMapFromValues(@NotNull Iterator values, @NotNull Convertor keyConvertor) { - Map map = new HashMap(); + Map map = new HashMap<>(); fillMapWithValues(map, values, keyConvertor); return map; } @@ -775,13 +775,13 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure = true) public static Map> classify(@NotNull Iterator iterator, @NotNull Convertor keyConvertor) { - Map> hashMap = new LinkedHashMap>(); + Map> hashMap = new LinkedHashMap<>(); while (iterator.hasNext()) { V value = iterator.next(); final K key = keyConvertor.convert(value); Set set = hashMap.get(key); if (set == null) { - hashMap.put(key, set = new LinkedHashSet()); // ordered set!! + hashMap.put(key, set = new LinkedHashSet<>()); // ordered set!! } set.add(value); } @@ -898,7 +898,7 @@ public class ContainerUtil extends ContainerUtilRt { @Contract(pure=true) public static Map map2Map(@NotNull Collection collection, @NotNull Function> mapper) { - final Map set = new THashMap(collection.size()); + final Map set = new THashMap<>(collection.size()); for (T t : collection) { Pair pair = mapper.fun(t); set.put(pair.first, pair.second); @@ -917,7 +917,7 @@ public class ContainerUtil extends ContainerUtilRt { @Contract(pure = true) public static Map map2MapNotNull(@NotNull Collection collection, @NotNull Function> mapper) { - final Map set = new THashMap(collection.size()); + final Map set = new THashMap<>(collection.size()); for (T t : collection) { Pair pair = mapper.fun(t); if (pair != null) { @@ -930,7 +930,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static Map map2Map(@NotNull Collection> collection) { - final Map result = new THashMap(collection.size()); + final Map result = new THashMap<>(collection.size()); for (Pair pair : collection) { result.put(pair.first, pair.second); } @@ -997,7 +997,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static List findAll(@NotNull T[] collection, @NotNull Condition condition) { - final List result = new SmartList(); + final List result = new SmartList<>(); for (T t : collection) { if (condition.value(t)) { result.add(t); @@ -1022,7 +1022,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure = true) public static Map filter(@NotNull Map map, @NotNull Condition keyFilter) { - Map result = new HashMap(); + Map result = new HashMap<>(); for (Map.Entry entry : map.entrySet()) { if (keyFilter.value(entry.getKey())) { result.put(entry.getKey(), entry.getValue()); @@ -1035,7 +1035,7 @@ public class ContainerUtil extends ContainerUtilRt { @Contract(pure=true) public static List findAll(@NotNull Collection collection, @NotNull Condition condition) { if (collection.isEmpty()) return emptyList(); - final List result = new SmartList(); + final List result = new SmartList<>(); for (final T t : collection) { if (condition.value(t)) { result.add(t); @@ -1086,7 +1086,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static List findAll(@NotNull Collection collection, @NotNull Class instanceOf) { - final List result = new SmartList(); + final List result = new SmartList<>(); for (final T t : collection) { if (instanceOf.isInstance(t)) { @SuppressWarnings("unchecked") V v = (V)t; @@ -1106,7 +1106,7 @@ public class ContainerUtil extends ContainerUtilRt { } public static void removeDuplicates(@NotNull Collection collection) { - Set collected = new HashSet(); + Set collected = new HashSet<>(); for (Iterator iterator = collection.iterator(); iterator.hasNext();) { T t = iterator.next(); if (!collected.contains(t)) { @@ -1121,7 +1121,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static Map stringMap(@NotNull final String... keyValues) { - final Map result = new HashMap(); + final Map result = new HashMap<>(); for (int i = 0; i < keyValues.length - 1; i+=2) { result.put(keyValues[i], keyValues[i+1]); } @@ -1375,7 +1375,7 @@ public class ContainerUtil extends ContainerUtilRt { for (final Collection ts : list) { totalSize += ts.size(); } - List result = new ArrayList(totalSize); + List result = new ArrayList<>(totalSize); for (final Collection ts : list) { result.addAll(ts); } @@ -1459,13 +1459,13 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static Iterator concatIterators(@NotNull Iterator... iterators) { - return new SequenceIterator(iterators); + return new SequenceIterator<>(iterators); } @NotNull @Contract(pure=true) public static Iterator concatIterators(@NotNull Collection> iterators) { - return new SequenceIterator(iterators); + return new SequenceIterator<>(iterators); } @NotNull @@ -1539,7 +1539,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static List concat(@NotNull Iterable list, @NotNull Function> listGenerator) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (final V v : list) { result.addAll(listGenerator.fun(v)); } @@ -1571,7 +1571,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static Collection intersection(@NotNull Collection collection1, @NotNull Collection collection2) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (T t : collection1) { if (collection2.contains(t)) { result.add(t); @@ -1922,7 +1922,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static List map(@NotNull Iterable iterable, @NotNull Function mapping) { - List result = new ArrayList(iterable instanceof Collection ? ((Collection)iterable).size() : 10); + List result = new ArrayList<>(iterable instanceof Collection ? ((Collection)iterable).size() : 10); for (T t : iterable) { result.add(mapping.fun(t)); } @@ -1960,7 +1960,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static V[] mapNotNull(@NotNull T[] array, @NotNull Function mapping, @NotNull V[] emptyArray) { - List result = new ArrayList(array.length); + List result = new ArrayList<>(array.length); for (T t : array) { V v = mapping.fun(t); if (v != null) { @@ -1982,7 +1982,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static List mapNotNull(@NotNull Iterable iterable, @NotNull Function mapping) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (T t : iterable) { final V o = mapping.fun(t); if (o != null) { @@ -2009,7 +2009,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static List packNullables(@NotNull T... elements) { - List list = new ArrayList(); + List list = new ArrayList<>(); for (T element : elements) { addIfNotNull(list, element); } @@ -2022,7 +2022,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static List map(@NotNull T[] array, @NotNull Function mapping) { - List result = new ArrayList(array.length); + List result = new ArrayList<>(array.length); for (T t : array) { result.add(mapping.fun(t)); } @@ -2175,7 +2175,7 @@ public class ContainerUtil extends ContainerUtilRt { public static List unfold(@Nullable T t, @NotNull NullableFunction next) { if (t == null) return emptyList(); - List list = new ArrayList(); + List list = new ArrayList<>(); while (t != null) { list.add(t); t = next.fun(t); @@ -2289,7 +2289,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static Set singleton(final T o, @NotNull final TObjectHashingStrategy strategy) { - return strategy == TObjectHashingStrategy.CANONICAL ? new SingletonSet(o) : SingletonSet.withCustomStrategy(o, strategy); + return strategy == TObjectHashingStrategy.CANONICAL ? new SingletonSet<>(o) : SingletonSet.withCustomStrategy(o, strategy); } /** @@ -2320,7 +2320,7 @@ public class ContainerUtil extends ContainerUtilRt { } else if (cmp == 0) { if (result == null) { - result = new ArrayList(list.size()); + result = new ArrayList<>(list.size()); result.addAll(list.subList(0, i)); } } @@ -2342,7 +2342,7 @@ public class ContainerUtil extends ContainerUtilRt { for (Collection list : collections) { totalSize += list.size(); } - List result = new ArrayList(totalSize); + List result = new ArrayList<>(totalSize); for (Collection list : collections) { result.addAll(list); } @@ -2360,7 +2360,7 @@ public class ContainerUtil extends ContainerUtilRt { for (Iterable list : collections) { totalSize += list instanceof Collection ? ((Collection)list).size() : 10; } - List result = new ArrayList(totalSize); + List result = new ArrayList<>(totalSize); for (Iterable list : collections) { for (E e : list) { result.add(e); @@ -2458,7 +2458,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(pure=true) public static Map reverseMap(@NotNull Map map) { - final Map result = new HashMap(); + final Map result = new HashMap<>(); for (Map.Entry entry : map.entrySet()) { result.put(entry.getValue(), entry.getKey()); } @@ -2505,7 +2505,7 @@ public class ContainerUtil extends ContainerUtilRt { @Contract(value = " -> new", pure = true) public static CopyOnWriteArrayList createEmptyCOWList() { // does not create garbage new Object[0] - return new CopyOnWriteArrayList(ContainerUtilRt.emptyList()); + return new CopyOnWriteArrayList<>(ContainerUtilRt.emptyList()); } /** @@ -2527,49 +2527,49 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(value = "_ -> new", pure = true) public static List createLockFreeCopyOnWriteList(@NotNull Collection c) { - return new LockFreeCopyOnWriteArrayList(c); + return new LockFreeCopyOnWriteArrayList<>(c); } @NotNull @Contract(value = " -> new", pure = true) public static ConcurrentIntObjectMap createConcurrentIntObjectMap() { - return new ConcurrentIntObjectHashMap(); + return new ConcurrentIntObjectHashMap<>(); } @NotNull @Contract(value = "_,_,_ -> new", pure = true) public static ConcurrentIntObjectMap createConcurrentIntObjectMap(int initialCapacity, float loadFactor, int concurrencyLevel) { - return new ConcurrentIntObjectHashMap(initialCapacity, loadFactor, concurrencyLevel); + return new ConcurrentIntObjectHashMap<>(initialCapacity, loadFactor, concurrencyLevel); } @NotNull @Contract(value = " -> new", pure = true) public static ConcurrentIntObjectMap createConcurrentIntObjectSoftValueMap() { - return new ConcurrentIntKeySoftValueHashMap(); + return new ConcurrentIntKeySoftValueHashMap<>(); } @NotNull @Contract(value = " -> new", pure = true) public static ConcurrentLongObjectMap createConcurrentLongObjectMap() { - return new ConcurrentLongObjectHashMap(); + return new ConcurrentLongObjectHashMap<>(); } @NotNull @Contract(value = "_ -> new", pure = true) public static ConcurrentLongObjectMap createConcurrentLongObjectMap(int initialCapacity) { - return new ConcurrentLongObjectHashMap(initialCapacity); + return new ConcurrentLongObjectHashMap<>(initialCapacity); } @NotNull @Contract(value = " -> new", pure = true) public static ConcurrentMap createConcurrentWeakValueMap() { - return new ConcurrentWeakValueHashMap(); + return new ConcurrentWeakValueHashMap<>(); } @NotNull @Contract(value = " -> new", pure = true) public static ConcurrentIntObjectMap createConcurrentIntObjectWeakValueMap() { - return new ConcurrentIntKeyWeakValueHashMap(); + return new ConcurrentIntKeyWeakValueHashMap<>(); } @NotNull @@ -2579,7 +2579,7 @@ public class ContainerUtil extends ContainerUtilRt { int concurrencyLevel, @NotNull final TObjectHashingStrategy hashingStrategy) { //noinspection deprecation - return new ConcurrentWeakKeySoftValueHashMap(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy); + return new ConcurrentWeakKeySoftValueHashMap<>(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy); } @NotNull @@ -2588,7 +2588,7 @@ public class ContainerUtil extends ContainerUtilRt { float loadFactor, int concurrencyLevel, @NotNull final TObjectHashingStrategy hashingStrategy) { - return new ConcurrentSoftKeySoftValueHashMap(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy); + return new ConcurrentSoftKeySoftValueHashMap<>(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy); } @NotNull @@ -2606,27 +2606,27 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(value = "_ -> new", pure = true) public static ConcurrentMap createConcurrentWeakKeyWeakValueMap(@NotNull TObjectHashingStrategy strategy) { - return new ConcurrentWeakKeyWeakValueHashMap(100, 0.75f, Runtime.getRuntime().availableProcessors(), - strategy); + return new ConcurrentWeakKeyWeakValueHashMap<>(100, 0.75f, Runtime.getRuntime().availableProcessors(), + strategy); } @NotNull @Contract(value = " -> new", pure = true) public static ConcurrentMap createConcurrentSoftValueMap() { - return new ConcurrentSoftValueHashMap(); + return new ConcurrentSoftValueHashMap<>(); } @NotNull @Contract(value = " -> new", pure = true) public static ConcurrentMap createConcurrentSoftMap() { - return new ConcurrentSoftHashMap(); + return new ConcurrentSoftHashMap<>(); } @NotNull @Contract(value = " -> new", pure = true) public static ConcurrentMap createConcurrentWeakMap() { //noinspection deprecation - return new ConcurrentWeakHashMap(0.75f); + return new ConcurrentWeakHashMap<>(0.75f); } @NotNull @@ -2635,7 +2635,7 @@ public class ContainerUtil extends ContainerUtilRt { float loadFactor, int concurrencyLevel, @NotNull TObjectHashingStrategy hashingStrategy) { - return new ConcurrentSoftHashMap(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy); + return new ConcurrentSoftHashMap<>(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy); } @NotNull @@ -2645,14 +2645,14 @@ public class ContainerUtil extends ContainerUtilRt { int concurrencyLevel, @NotNull TObjectHashingStrategy hashingStrategy) { //noinspection deprecation - return new ConcurrentWeakHashMap(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy); + return new ConcurrentWeakHashMap<>(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy); } @NotNull @Contract(value = "_ -> new", pure = true) public static ConcurrentMap createConcurrentWeakMap(@NotNull TObjectHashingStrategy hashingStrategy) { //noinspection deprecation - return new ConcurrentWeakHashMap(hashingStrategy); + return new ConcurrentWeakHashMap<>(hashingStrategy); } /** @@ -2661,13 +2661,13 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Contract(value = " -> new", pure = true) public static ConcurrentList createConcurrentList() { - return new LockFreeCopyOnWriteArrayList(); + return new LockFreeCopyOnWriteArrayList<>(); } @NotNull @Contract(value = "_ -> new", pure = true) public static ConcurrentList createConcurrentList(@NotNull Collection collection) { - return new LockFreeCopyOnWriteArrayList(collection); + return new LockFreeCopyOnWriteArrayList<>(collection); } /** @@ -2716,7 +2716,7 @@ public class ContainerUtil extends ContainerUtilRt { @Contract(pure=true) public static Set map2LinkedSet(@NotNull Collection collection, @NotNull Function mapper) { if (collection.isEmpty()) return Collections.emptySet(); - Set set = new LinkedHashSet(collection.size()); + Set set = new LinkedHashSet<>(collection.size()); for (final T t : collection) { set.add(mapper.fun(t)); } @@ -2727,7 +2727,7 @@ public class ContainerUtil extends ContainerUtilRt { @Contract(pure=true) public static Set map2SetNotNull(@NotNull Collection collection, @NotNull Function mapper) { if (collection.isEmpty()) return Collections.emptySet(); - Set set = new HashSet(collection.size()); + Set set = new HashSet<>(collection.size()); for (T t : collection) { V value = mapper.fun(t); if (value != null) { @@ -2777,13 +2777,13 @@ public class ContainerUtil extends ContainerUtilRt { return Collections.emptyList(); } else if (list.size() == 1) { - return new SmartList(list.get(0)); + return new SmartList<>(list.get(0)); } else if (list.isEmpty()) { - return new SmartList(); + return new SmartList<>(); } else { - return new ArrayList(list); + return new ArrayList<>(list); } } @@ -2800,7 +2800,7 @@ public class ContainerUtil extends ContainerUtilRt { return Collections.emptyList(); } - List result = new SmartList(); + List result = new SmartList<>(); while (enumeration.hasMoreElements()) { result.add(enumeration.nextElement()); } @@ -2897,13 +2897,13 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull @Override protected Map> createMap() { - return new TreeMap>(); + return new TreeMap<>(); } @NotNull @Override protected Map> createMap(int initialCapacity, float loadFactor) { - return new TreeMap>(); + return new TreeMap<>(); } @NotNull @@ -2915,20 +2915,20 @@ public class ContainerUtil extends ContainerUtilRt { @Contract(value = " -> new", pure = true) @NotNull public static Map createWeakKeySoftValueMap() { - return new WeakKeySoftValueHashMap(); + return new WeakKeySoftValueHashMap<>(); } @Contract(value = " -> new", pure = true) @NotNull public static Map createWeakKeyWeakValueMap() { //noinspection deprecation - return new WeakKeyWeakValueHashMap(true); + return new WeakKeyWeakValueHashMap<>(true); } @Contract(value = " -> new", pure = true) @NotNull public static Map createSoftKeySoftValueMap() { - return new SoftKeySoftValueHashMap(true); + return new SoftKeySoftValueHashMap<>(true); } /** @@ -2940,7 +2940,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull public static Map createSoftValueMap() { //noinspection deprecation - return new SoftValueHashMap(ContainerUtil.canonicalStrategy()); + return new SoftValueHashMap<>(ContainerUtil.canonicalStrategy()); } /** @@ -2952,7 +2952,7 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull public static Map createWeakValueMap() { //noinspection deprecation - return new WeakValueHashMap(ContainerUtil.canonicalStrategy()); + return new WeakValueHashMap<>(ContainerUtil.canonicalStrategy()); } /** @@ -2964,14 +2964,14 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull public static Map createSoftMap() { //noinspection deprecation - return new SoftHashMap(4); + return new SoftHashMap<>(4); } @Contract(value = "_ -> new", pure = true) @NotNull public static Map createSoftMap(@NotNull TObjectHashingStrategy strategy) { //noinspection deprecation - return new SoftHashMap(strategy); + return new SoftHashMap<>(strategy); } /** @@ -2995,25 +2995,25 @@ public class ContainerUtil extends ContainerUtilRt { @NotNull public static Map createWeakMap(int initialCapacity, float loadFactor, @NotNull TObjectHashingStrategy strategy) { //noinspection deprecation - return new WeakHashMap(initialCapacity, loadFactor, strategy); + return new WeakHashMap<>(initialCapacity, loadFactor, strategy); } @Contract(value = " -> new", pure = true) @NotNull public static Set createWeakSet() { - return new WeakHashSet(); + return new WeakHashSet<>(); } @Contract(value = " -> new", pure = true) @NotNull public static IntObjectMap createIntKeyWeakValueMap() { - return new IntKeyWeakValueHashMap(); + return new IntKeyWeakValueHashMap<>(); } @Contract(value = " -> new", pure = true) @NotNull public static ObjectIntMap createWeakKeyIntValueMap() { - return new WeakKeyIntValueHashMap(); + return new WeakKeyIntValueHashMap<>(); } } diff --git a/platform/util/src/com/intellij/util/containers/ConvertingIterator.java b/platform/util/src/com/intellij/util/containers/ConvertingIterator.java index 63d1c8453f0b..be6714a9ae74 100644 --- a/platform/util/src/com/intellij/util/containers/ConvertingIterator.java +++ b/platform/util/src/com/intellij/util/containers/ConvertingIterator.java @@ -62,6 +62,6 @@ public class ConvertingIterator implements Iterator { } public static ConvertingIterator create(Iterator iterator, Convertor convertor) { - return new ConvertingIterator(iterator, convertor); + return new ConvertingIterator<>(iterator, convertor); } } diff --git a/platform/util/src/com/intellij/util/containers/DistinctRootsCollection.java b/platform/util/src/com/intellij/util/containers/DistinctRootsCollection.java index a1c1b7068f7d..e482c34df1c7 100644 --- a/platform/util/src/com/intellij/util/containers/DistinctRootsCollection.java +++ b/platform/util/src/com/intellij/util/containers/DistinctRootsCollection.java @@ -23,7 +23,7 @@ import java.util.Collection; import java.util.Iterator; public abstract class DistinctRootsCollection implements Collection { - private final Collection myCollection = new ArrayList(); + private final Collection myCollection = new ArrayList<>(); protected abstract boolean isAncestor(@NotNull T ancestor, @NotNull T t); @@ -73,7 +73,7 @@ public abstract class DistinctRootsCollection implements Collection { @Override public boolean add(T o) { - Collection toRemove = new ArrayList(); + Collection toRemove = new ArrayList<>(); for (T existing : myCollection) { if (isAncestor(existing, o)) { return false; diff --git a/platform/util/src/com/intellij/util/containers/Enumerator.java b/platform/util/src/com/intellij/util/containers/Enumerator.java index 56efbdcf8b3d..6f964e25b7c9 100644 --- a/platform/util/src/com/intellij/util/containers/Enumerator.java +++ b/platform/util/src/com/intellij/util/containers/Enumerator.java @@ -31,7 +31,7 @@ public class Enumerator { private int myNextNumber = 1; public Enumerator(int expectNumber, @NotNull TObjectHashingStrategy strategy) { - myNumbers = new TObjectIntHashMap(expectNumber, strategy); + myNumbers = new TObjectIntHashMap<>(expectNumber, strategy); } public void clear() { diff --git a/platform/util/src/com/intellij/util/containers/FList.java b/platform/util/src/com/intellij/util/containers/FList.java index aef3e282c2f2..45ac0b37686e 100644 --- a/platform/util/src/com/intellij/util/containers/FList.java +++ b/platform/util/src/com/intellij/util/containers/FList.java @@ -58,7 +58,7 @@ public class FList extends AbstractList { } public FList prepend(E elem) { - return new FList(elem, this, mySize + 1); + return new FList<>(elem, this, mySize + 1); } public FList without(E elem) { diff --git a/platform/util/src/com/intellij/util/containers/FactoryMap.java b/platform/util/src/com/intellij/util/containers/FactoryMap.java index c0dc4fef6547..a7df019c2d95 100644 --- a/platform/util/src/com/intellij/util/containers/FactoryMap.java +++ b/platform/util/src/com/intellij/util/containers/FactoryMap.java @@ -49,7 +49,7 @@ public abstract class FactoryMap implements Map { @NotNull protected Map createMap() { - return new THashMap(); + return new THashMap<>(); } @Nullable @@ -118,7 +118,7 @@ public abstract class FactoryMap implements Map { final Set ts = getMap().keySet(); K nullKey = FAKE_NULL(); if (ts.contains(nullKey)) { - final java.util.HashSet hashSet = new HashSet(ts); + final java.util.HashSet hashSet = new HashSet<>(ts); hashSet.remove(nullKey); hashSet.add(null); return hashSet; @@ -177,7 +177,7 @@ public abstract class FactoryMap implements Map { return ContainerUtil.map2Set(getMap().entrySet(), new Function, Entry>() { @Override public Entry fun(Entry entry) { - return new AbstractMap.SimpleEntry(nullize(entry.getKey()), nullize(entry.getValue())); + return new AbstractMap.SimpleEntry<>(nullize(entry.getKey()), nullize(entry.getValue())); } }); } diff --git a/platform/util/src/com/intellij/util/containers/FilteredTraverserBase.java b/platform/util/src/com/intellij/util/containers/FilteredTraverserBase.java index 26376024c53b..07a6bc0a795a 100644 --- a/platform/util/src/com/intellij/util/containers/FilteredTraverserBase.java +++ b/platform/util/src/com/intellij/util/containers/FilteredTraverserBase.java @@ -325,42 +325,42 @@ public abstract class FilteredTraverserBase reset() { Meta e = empty(); - return new Meta(roots, e.traversal, e.expand, e.regard, e.filter, forceIgnore, forceDisregard, e.interceptor); + return new Meta<>(roots, e.traversal, e.expand, e.regard, e.filter, forceIgnore, forceDisregard, e.interceptor); } public Meta withRoots(@NotNull Iterable roots) { - return new Meta(roots, traversal, expand, regard, filter, forceIgnore, forceDisregard, interceptor); + return new Meta<>(roots, traversal, expand, regard, filter, forceIgnore, forceDisregard, interceptor); } public Meta withTraversal(TreeTraversal traversal) { - return new Meta(roots, traversal, expand, regard, filter, forceIgnore, forceDisregard, interceptor); + return new Meta<>(roots, traversal, expand, regard, filter, forceIgnore, forceDisregard, interceptor); } public Meta expand(@NotNull Condition c) { - return new Meta(roots, traversal, expand.append(c), regard, this.filter, forceIgnore, forceDisregard, interceptor); + return new Meta<>(roots, traversal, expand.append(c), regard, this.filter, forceIgnore, forceDisregard, interceptor); } public Meta regard(@NotNull Condition c) { - return new Meta(roots, traversal, expand, regard.append(c), this.filter, forceIgnore, forceDisregard, interceptor); + return new Meta<>(roots, traversal, expand, regard.append(c), this.filter, forceIgnore, forceDisregard, interceptor); } public Meta filter(@NotNull Condition c) { - return new Meta(roots, traversal, expand, regard, this.filter.append(c), forceIgnore, forceDisregard, interceptor); + return new Meta<>(roots, traversal, expand, regard, this.filter.append(c), forceIgnore, forceDisregard, interceptor); } public Meta forceIgnore(Condition c) { - return new Meta(roots, traversal, expand, regard, this.filter, forceIgnore.append(c), forceDisregard, interceptor); + return new Meta<>(roots, traversal, expand, regard, this.filter, forceIgnore.append(c), forceDisregard, interceptor); } public Meta forceDisregard(Condition c) { - return new Meta(roots, traversal, expand, regard, this.filter, forceIgnore, forceDisregard.append(c), interceptor); + return new Meta<>(roots, traversal, expand, regard, this.filter, forceIgnore, forceDisregard.append(c), interceptor); } public Meta interceptTraversal(Function transform) { if (transform == Function.ID) return this; Function newTransform = this.interceptor == Function.ID ? transform : Functions.compose(this.interceptor, transform); - return new Meta(roots, traversal, expand, regard, this.filter, forceIgnore, forceDisregard, newTransform); + return new Meta<>(roots, traversal, expand, regard, this.filter, forceIgnore, forceDisregard, newTransform); } TreeTraversal.GuidedIt.Guide createChildrenGuide(final T parent) { @@ -421,8 +421,8 @@ public abstract class FilteredTraverserBase { - final static Cond TRUE = new Cond(Conditions.TRUE, null); - final static Cond FALSE = new Cond(Conditions.FALSE, null); + final static Cond TRUE = new Cond<>(Conditions.TRUE, null); + final static Cond FALSE = new Cond<>(Conditions.FALSE, null); final Condition impl; final Cond next; @@ -433,7 +433,7 @@ public abstract class FilteredTraverserBase append(Condition impl) { - return new Cond(impl, this); + return new Cond<>(impl, this); } boolean valueAnd(T t) { diff --git a/platform/util/src/com/intellij/util/containers/FilteringIterator.java b/platform/util/src/com/intellij/util/containers/FilteringIterator.java index dc22f16ab39d..45ce2ef24de1 100644 --- a/platform/util/src/com/intellij/util/containers/FilteringIterator.java +++ b/platform/util/src/com/intellij/util/containers/FilteringIterator.java @@ -104,7 +104,7 @@ public class FilteringIterator implements PeekableIterator Iterator create(Iterator iterator, Condition condition) { if (condition == Condition.TRUE || condition == Conditions.TRUE) return (Iterator)iterator; - return new FilteringIterator(iterator, condition); + return new FilteringIterator<>(iterator, condition); } public static Condition alwaysTrueCondition(Class aClass) { @@ -112,7 +112,7 @@ public class FilteringIterator implements PeekableIterator InstanceOf instanceOf(final Class aClass) { - return new InstanceOf(aClass); + return new InstanceOf<>(aClass); } public static Iterator createInstanceOf(Iterator iterator, Class aClass) { diff --git a/platform/util/src/com/intellij/util/containers/HashSetQueue.java b/platform/util/src/com/intellij/util/containers/HashSetQueue.java index 1cd030429460..919c9292d2e3 100644 --- a/platform/util/src/com/intellij/util/containers/HashSetQueue.java +++ b/platform/util/src/com/intellij/util/containers/HashSetQueue.java @@ -32,11 +32,11 @@ import java.util.Queue; * Implementation is backed by {@link gnu.trove.THashSet} containing double-linked QueueEntry nodes holding elements themselves. */ public class HashSetQueue extends AbstractCollection implements Queue { - private final OpenTHashSet> set = new OpenTHashSet>(); + private final OpenTHashSet> set = new OpenTHashSet<>(); // Entries in the queue are double-linked circularly, the TOMB serving as a sentinel. // TOMB.next is the first entry; TOMB.prev is the last entry; // TOMB.next == TOMB.prev == TOMB means the queue is empty - private final QueueEntry TOMB = new QueueEntry(cast(new Object())); + private final QueueEntry TOMB = new QueueEntry<>(cast(new Object())); public HashSetQueue() { TOMB.next = TOMB.prev = TOMB; @@ -69,7 +69,7 @@ public class HashSetQueue extends AbstractCollection implements Queue { @Override public boolean add(@NotNull T t) { - QueueEntry newLast = new QueueEntry(t); + QueueEntry newLast = new QueueEntry<>(t); boolean added = set.add(newLast); if (!added) return false; QueueEntry oldLast = TOMB.prev; @@ -118,7 +118,7 @@ public class HashSetQueue extends AbstractCollection implements Queue { } private QueueEntry findEntry(@NotNull T t) { - return set.get(new QueueEntry(t)); + return set.get(new QueueEntry<>(t)); } @Override @@ -178,7 +178,7 @@ public class HashSetQueue extends AbstractCollection implements Queue { @NotNull @Override public IteratorPosition position() { - return new MyIteratorPosition(cursor, count, TOMB); + return new MyIteratorPosition<>(cursor, count, TOMB); } }; } @@ -204,7 +204,7 @@ public class HashSetQueue extends AbstractCollection implements Queue { @Override public PositionalIterator.IteratorPosition next() { - return cursor.next == TOMB ? null : new MyIteratorPosition(cursor.next, count + 1, TOMB); + return cursor.next == TOMB ? null : new MyIteratorPosition<>(cursor.next, count + 1, TOMB); } @Override diff --git a/platform/util/src/com/intellij/util/containers/ImmutableList.java b/platform/util/src/com/intellij/util/containers/ImmutableList.java index d49c812d9029..894574fdecbe 100644 --- a/platform/util/src/com/intellij/util/containers/ImmutableList.java +++ b/platform/util/src/com/intellij/util/containers/ImmutableList.java @@ -94,7 +94,7 @@ public abstract class ImmutableList extends AbstractCollection implements @NotNull @Override public ImmutableList subList(int fromIndex, int toIndex) { - return new SubList(this, fromIndex, toIndex); + return new SubList<>(this, fromIndex, toIndex); } @Override @@ -247,7 +247,7 @@ public abstract class ImmutableList extends AbstractCollection implements @NotNull @Contract("_ -> new") public static ImmutableList singleton(T element) { - return new Singleton(element); + return new Singleton<>(element); } private static class Singleton extends ImmutableList { private final E element; diff --git a/platform/util/src/com/intellij/util/containers/ImmutableUserMap.java b/platform/util/src/com/intellij/util/containers/ImmutableUserMap.java index 1f37643b0bb9..bf3e3ac3b52c 100644 --- a/platform/util/src/com/intellij/util/containers/ImmutableUserMap.java +++ b/platform/util/src/com/intellij/util/containers/ImmutableUserMap.java @@ -35,7 +35,7 @@ public abstract class ImmutableUserMap { public abstract T get(@NotNull Key key); public final ImmutableUserMap put(@NotNull final Key key, final T value) { - return new ImmutableUserMapImpl(key, value, this); + return new ImmutableUserMapImpl<>(key, value, this); } private static class ImmutableUserMapImpl extends ImmutableUserMap { diff --git a/platform/util/src/com/intellij/util/containers/IntKeyWeakValueHashMap.java b/platform/util/src/com/intellij/util/containers/IntKeyWeakValueHashMap.java index 298e2c90a83c..36b8f08737e5 100644 --- a/platform/util/src/com/intellij/util/containers/IntKeyWeakValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/IntKeyWeakValueHashMap.java @@ -26,8 +26,8 @@ import java.lang.ref.WeakReference; import java.util.*; class IntKeyWeakValueHashMap implements IntObjectMap { - private final TIntObjectHashMap> myMap = new TIntObjectHashMap>(); - private final ReferenceQueue myQueue = new ReferenceQueue(); + private final TIntObjectHashMap> myMap = new TIntObjectHashMap<>(); + private final ReferenceQueue myQueue = new ReferenceQueue<>(); private static class MyReference extends WeakReference { private final int key; @@ -57,7 +57,7 @@ class IntKeyWeakValueHashMap implements IntObjectMap { @Override public final V put(int key, @NotNull V value) { processQueue(); - MyReference ref = new MyReference(key, value, myQueue); + MyReference ref = new MyReference<>(key, value, myQueue); MyReference oldRef = myMap.put(key, ref); return SoftReference.dereference(oldRef); } @@ -93,7 +93,7 @@ class IntKeyWeakValueHashMap implements IntObjectMap { @Override @NotNull public final Collection values() { - List result = new ArrayList(); + List result = new ArrayList<>(); Object[] refs = myMap.getValues(); for (Object o : refs) { @SuppressWarnings("unchecked") @@ -147,7 +147,7 @@ class IntKeyWeakValueHashMap implements IntObjectMap { @NotNull private Iterator> entriesIterator() { - final MovingIterator entryIterator = new MovingIterator(myMap); + final MovingIterator entryIterator = new MovingIterator<>(myMap); return new Iterator>() { private Entry nextVEntry; private int lastReturned; @@ -178,7 +178,7 @@ class IntKeyWeakValueHashMap implements IntObjectMap { continue; } final int key = entryIterator.key(); - nextVEntry = new SimpleEntry(key, v); + nextVEntry = new SimpleEntry<>(key, v); return; } nextVEntry = null; diff --git a/platform/util/src/com/intellij/util/containers/IntObjectCache.java b/platform/util/src/com/intellij/util/containers/IntObjectCache.java index 9863f808d4b7..650437ddef8d 100644 --- a/platform/util/src/com/intellij/util/containers/IntObjectCache.java +++ b/platform/util/src/com/intellij/util/containers/IntObjectCache.java @@ -57,7 +57,7 @@ public class IntObjectCache extends ObjectCacheBase implements Iterable { myTop = myBack = 0; myCache = new CacheEntry[cacheSize + 1]; for (int i = 0; i < myCache.length; ++i) { - myCache[i] = new CacheEntry(); + myCache[i] = new CacheEntry<>(); } myHashTableSize = getAdjustedTableSize(cacheSize); myHashTable = new int[myHashTableSize]; @@ -200,7 +200,7 @@ public class IntObjectCache extends ObjectCacheBase implements Iterable { } public void resize(int newSize) { - final IntObjectCache newCache = new IntObjectCache(newSize); + final IntObjectCache newCache = new IntObjectCache<>(newSize); final CacheEntry[] cache = myCache; int back = myBack; while (back != 0) { diff --git a/platform/util/src/com/intellij/util/containers/IntToIntSetMap.java b/platform/util/src/com/intellij/util/containers/IntToIntSetMap.java index 74dc9e196fec..0143b716b281 100644 --- a/platform/util/src/com/intellij/util/containers/IntToIntSetMap.java +++ b/platform/util/src/com/intellij/util/containers/IntToIntSetMap.java @@ -31,7 +31,7 @@ public class IntToIntSetMap { public IntToIntSetMap(int initialCapacity, float loadfactor) { mySingle = new TIntIntHashMap(initialCapacity, loadfactor); - myMulti = new TIntObjectHashMap(initialCapacity, loadfactor); + myMulti = new TIntObjectHashMap<>(initialCapacity, loadfactor); } public void addOccurence(int key, int value) { diff --git a/platform/util/src/com/intellij/util/containers/InternalIterator.java b/platform/util/src/com/intellij/util/containers/InternalIterator.java index 2e7a268993c5..1c34439ae3f0 100644 --- a/platform/util/src/com/intellij/util/containers/InternalIterator.java +++ b/platform/util/src/com/intellij/util/containers/InternalIterator.java @@ -38,7 +38,7 @@ public interface InternalIterator{ } public static InternalIterator create(Collection collection) { - return new Collector(collection); + return new Collector<>(collection); } } @@ -57,11 +57,11 @@ public interface InternalIterator{ } public static InternalIterator create(InternalIterator iterator, Condition filter) { - return new Filtering(iterator, filter); + return new Filtering<>(iterator, filter); } public static InternalIterator createInstanceOf(InternalIterator iterator, FilteringIterator.InstanceOf filter) { - return new Filtering((InternalIterator)iterator, filter); + return new Filtering<>((InternalIterator)iterator, filter); } public static InternalIterator createInstanceOf(InternalIterator iterator, Class aClass) { diff --git a/platform/util/src/com/intellij/util/containers/Interner.java b/platform/util/src/com/intellij/util/containers/Interner.java index 291b3b825dbf..e6a75940e216 100644 --- a/platform/util/src/com/intellij/util/containers/Interner.java +++ b/platform/util/src/com/intellij/util/containers/Interner.java @@ -19,15 +19,15 @@ public class Interner { private final OpenTHashSet mySet; public Interner() { - mySet = new OpenTHashSet(); + mySet = new OpenTHashSet<>(); } public Interner(@NotNull Collection initialItems) { - mySet = new OpenTHashSet(initialItems); + mySet = new OpenTHashSet<>(initialItems); } public Interner(@NotNull TObjectHashingStrategy strategy) { - mySet = new OpenTHashSet(strategy); + mySet = new OpenTHashSet<>(strategy); } @NotNull diff --git a/platform/util/src/com/intellij/util/containers/JBIterable.java b/platform/util/src/com/intellij/util/containers/JBIterable.java index 6da4b419685a..a6dee226d504 100644 --- a/platform/util/src/com/intellij/util/containers/JBIterable.java +++ b/platform/util/src/com/intellij/util/containers/JBIterable.java @@ -312,7 +312,7 @@ public abstract class JBIterable implements Iterable { public final JBIterable append(@Nullable Iterable other) { if (other == null || other == EMPTY) return this; if (this == EMPTY) return from(other); - Appended parent = this instanceof Appended ? (Appended)this : new Appended(this, null); + Appended parent = this instanceof Appended ? (Appended)this : new Appended<>(this, null); // to keep append lazy, ignore the fact that 'other' can also be an Appended return new Appended(other, parent); } @@ -464,7 +464,7 @@ public abstract class JBIterable implements Iterable { */ @NotNull public JBIterable flatten(@NotNull final Function> function) { - return intercept(new FlattenFun(function)); + return intercept(new FlattenFun<>(function)); } private static final class FlattenFun implements Function, Iterator> { @@ -474,7 +474,7 @@ public abstract class JBIterable implements Iterable { @Override public Iterator fun(final Iterator iterator) { - return new FlattenIt(iterator, Stateful.copy(function)); + return new FlattenIt<>(iterator, Stateful.copy(function)); } static final class FlattenIt extends JBIterator { @@ -516,7 +516,7 @@ public abstract class JBIterable implements Iterable { @Override public boolean value(E e) { - if (visited == null) visited = new java.util.HashSet(); + if (visited == null) visited = new java.util.HashSet<>(); return visited.add(identity.fun(e)); } }); @@ -533,7 +533,7 @@ public abstract class JBIterable implements Iterable { ((Intercepted)this).original, Functions.compose(((Intercepted)this).interceptor, function)); } - return new Intercepted(this, function); + return new Intercepted<>(this, function); } private static final class Intercepted extends JBIterable { diff --git a/platform/util/src/com/intellij/util/containers/JBIterator.java b/platform/util/src/com/intellij/util/containers/JBIterator.java index 714a141722fd..417eb5036b01 100644 --- a/platform/util/src/com/intellij/util/containers/JBIterator.java +++ b/platform/util/src/com/intellij/util/containers/JBIterator.java @@ -176,7 +176,7 @@ public abstract class JBIterator implements Iterator { @NotNull public final JBIterator take(int count) { // add first so that the underlying iterator stay on 'count' position - return addOp(!(myLastOp instanceof NextOp), new WhileOp(new CountDown(count))); + return addOp(!(myLastOp instanceof NextOp), new WhileOp<>(new CountDown<>(count))); } @NotNull @@ -186,7 +186,7 @@ public abstract class JBIterator implements Iterator { @NotNull public final JBIterator skip(int count) { - return skipWhile(new CountDown(count)); + return skipWhile(new CountDown<>(count)); } @NotNull diff --git a/platform/util/src/com/intellij/util/containers/JBTreeTraverser.java b/platform/util/src/com/intellij/util/containers/JBTreeTraverser.java index 458b77de114d..aed604763066 100644 --- a/platform/util/src/com/intellij/util/containers/JBTreeTraverser.java +++ b/platform/util/src/com/intellij/util/containers/JBTreeTraverser.java @@ -23,12 +23,12 @@ public class JBTreeTraverser extends FilteredTraverserBase JBTreeTraverser from(@NotNull Function> treeStructure) { - return new JBTreeTraverser(treeStructure); + return new JBTreeTraverser<>(treeStructure); } @NotNull public static JBTreeTraverser of(@NotNull Function treeStructure) { - return new JBTreeTraverser(Functions.compose(treeStructure, Functions.wrapArray())); + return new JBTreeTraverser<>(Functions.compose(treeStructure, Functions.wrapArray())); } public JBTreeTraverser(Function> treeStructure) { @@ -42,6 +42,6 @@ public class JBTreeTraverser extends FilteredTraverserBase newInstance(Meta meta) { - return new JBTreeTraverser(meta, getTree()); + return new JBTreeTraverser<>(meta, getTree()); } } \ No newline at end of file diff --git a/platform/util/src/com/intellij/util/containers/LinkedMultiMap.java b/platform/util/src/com/intellij/util/containers/LinkedMultiMap.java index 194969a48532..76ef272b435a 100644 --- a/platform/util/src/com/intellij/util/containers/LinkedMultiMap.java +++ b/platform/util/src/com/intellij/util/containers/LinkedMultiMap.java @@ -29,13 +29,13 @@ public class LinkedMultiMap extends MultiMap { @NotNull @Override protected Map> createMap() { - return new LinkedHashMap>(getEqualityPolicy()); + return new LinkedHashMap<>(getEqualityPolicy()); } @NotNull @Override protected Map> createMap(int initialCapacity, float loadFactor) { - return new LinkedHashMap>(initialCapacity, loadFactor, getEqualityPolicy()); + return new LinkedHashMap<>(initialCapacity, loadFactor, getEqualityPolicy()); } protected EqualityPolicy getEqualityPolicy() { diff --git a/platform/util/src/com/intellij/util/containers/LockFreeCopyOnWriteArrayList.java b/platform/util/src/com/intellij/util/containers/LockFreeCopyOnWriteArrayList.java index edd32c1bad52..ed62a6a64150 100644 --- a/platform/util/src/com/intellij/util/containers/LockFreeCopyOnWriteArrayList.java +++ b/platform/util/src/com/intellij/util/containers/LockFreeCopyOnWriteArrayList.java @@ -662,7 +662,7 @@ class LockFreeCopyOnWriteArrayList implements List, RandomAccess, Concurre do { elements = array; Set existing = ContainerUtil.map2Set(elements, Functions.identity()); - List toAddList = new ArrayList(c.size()); + List toAddList = new ArrayList<>(c.size()); for (E e : c) { if (!existing.contains(e)) toAddList.add(e); } diff --git a/platform/util/src/com/intellij/util/containers/MostlySingularMultiMap.java b/platform/util/src/com/intellij/util/containers/MostlySingularMultiMap.java index acb2ebab34c0..9851584fb6e3 100644 --- a/platform/util/src/com/intellij/util/containers/MostlySingularMultiMap.java +++ b/platform/util/src/com/intellij/util/containers/MostlySingularMultiMap.java @@ -28,7 +28,7 @@ public class MostlySingularMultiMap implements Serializable { @NotNull protected Map createMap() { - return new THashMap(); + return new THashMap<>(); } public void add(@NotNull K key, @NotNull V value) { @@ -42,7 +42,7 @@ public class MostlySingularMultiMap implements Serializable { curList.add(value); } else { - ValueList newList = new ValueList(); + ValueList newList = new ValueList<>(); newList.add(current); newList.add(value); myMap.put(key, newList); @@ -172,7 +172,7 @@ public class MostlySingularMultiMap implements Serializable { @NotNull public static MostlySingularMultiMap newMap() { - return new MostlySingularMultiMap(); + return new MostlySingularMultiMap<>(); } private static final MostlySingularMultiMap EMPTY = new EmptyMap(); diff --git a/platform/util/src/com/intellij/util/containers/MultiMap.java b/platform/util/src/com/intellij/util/containers/MultiMap.java index 705f9615be44..9347212b0c2b 100644 --- a/platform/util/src/com/intellij/util/containers/MultiMap.java +++ b/platform/util/src/com/intellij/util/containers/MultiMap.java @@ -38,7 +38,7 @@ public class MultiMap implements Serializable { @NotNull public MultiMap copy() { - return new MultiMap(this); + return new MultiMap<>(this); } public MultiMap(int initialCapacity, float loadFactor) { @@ -47,17 +47,17 @@ public class MultiMap implements Serializable { @NotNull protected Map> createMap() { - return new java.util.HashMap>(); + return new java.util.HashMap<>(); } @NotNull protected Map> createMap(int initialCapacity, float loadFactor) { - return new HashMap>(initialCapacity, loadFactor); + return new HashMap<>(initialCapacity, loadFactor); } @NotNull protected Collection createCollection() { - return new SmartList(); + return new SmartList<>(); } @NotNull @@ -255,7 +255,7 @@ public class MultiMap implements Serializable { */ @NotNull public static MultiMap create() { - return new MultiMap(); + return new MultiMap<>(); } @NotNull @@ -264,14 +264,14 @@ public class MultiMap implements Serializable { @NotNull @Override protected Map> createMap() { - return new THashMap>(strategy); + return new THashMap<>(strategy); } }; } @NotNull public static MultiMap createLinked() { - return new LinkedMultiMap(); + return new LinkedMultiMap<>(); } @NotNull @@ -297,7 +297,7 @@ public class MultiMap implements Serializable { @NotNull @Override protected Collection createCollection() { - return new OrderedSet(); + return new OrderedSet<>(); } @NotNull @@ -314,7 +314,7 @@ public class MultiMap implements Serializable { @NotNull @Override protected Map> createMap() { - return new THashMap>(); + return new THashMap<>(); } }; } @@ -347,7 +347,7 @@ public class MultiMap implements Serializable { @NotNull @Override protected Collection createCollection() { - return new SmartHashSet(); + return new SmartHashSet<>(); } @NotNull @@ -359,7 +359,7 @@ public class MultiMap implements Serializable { @NotNull @Override protected Map> createMap() { - return new THashMap>(strategy); + return new THashMap<>(strategy); } }; } @@ -376,7 +376,7 @@ public class MultiMap implements Serializable { } public static MultiMap create(int initialCapacity, float loadFactor) { - return new MultiMap(initialCapacity, loadFactor); + return new MultiMap<>(initialCapacity, loadFactor); } @Override @@ -391,7 +391,7 @@ public class MultiMap implements Serializable { @Override public String toString() { - return new java.util.HashMap>(myMap).toString(); + return new java.util.HashMap<>(myMap).toString(); } /** diff --git a/platform/util/src/com/intellij/util/containers/ObjectCache.java b/platform/util/src/com/intellij/util/containers/ObjectCache.java index 54472ff486f8..07342bc2903b 100644 --- a/platform/util/src/com/intellij/util/containers/ObjectCache.java +++ b/platform/util/src/com/intellij/util/containers/ObjectCache.java @@ -55,7 +55,7 @@ public class ObjectCache extends ObjectCacheBase implements Iterable { myTop = myBack = 0; myCache = new CacheEntry[cacheSize + 1]; for (int i = 0; i < myCache.length; ++i) { - myCache[i] = new CacheEntry(); + myCache[i] = new CacheEntry<>(); } myHashTableSize = getAdjustedTableSize(cacheSize); myHashTable = new int[myHashTableSize]; @@ -102,7 +102,7 @@ public class ObjectCache extends ObjectCacheBase implements Iterable { } public void removeAll() { - final ArrayList keys = new ArrayList(count()); + final ArrayList keys = new ArrayList<>(count()); int current = myTop; while (current > 0) { if (myCache[current].value != null) { @@ -262,7 +262,7 @@ public class ObjectCache extends ObjectCacheBase implements Iterable { @Override public Iterator iterator() { - return new ObjectCacheIterator(this); + return new ObjectCacheIterator<>(this); } protected static class ObjectCacheIterator implements Iterator { diff --git a/platform/util/src/com/intellij/util/containers/OrderedSet.java b/platform/util/src/com/intellij/util/containers/OrderedSet.java index 8f7cc03f8d25..26665a076111 100644 --- a/platform/util/src/com/intellij/util/containers/OrderedSet.java +++ b/platform/util/src/com/intellij/util/containers/OrderedSet.java @@ -31,7 +31,7 @@ public class OrderedSet extends ArrayList implements Set, RandomAccess public OrderedSet(@NotNull Collection set) { super(set.size()); - myHashSet = new OpenTHashSet(set.size()); + myHashSet = new OpenTHashSet<>(set.size()); addAll(set); } @@ -41,7 +41,7 @@ public class OrderedSet extends ArrayList implements Set, RandomAccess public OrderedSet(@NotNull TObjectHashingStrategy hashingStrategy, int capacity) { super(capacity); - myHashSet = new OpenTHashSet(capacity, hashingStrategy); + myHashSet = new OpenTHashSet<>(capacity, hashingStrategy); } public OrderedSet(int capacity) { diff --git a/platform/util/src/com/intellij/util/containers/PathInterner.java b/platform/util/src/com/intellij/util/containers/PathInterner.java index b6ff0c08ebd1..492e7fb93975 100644 --- a/platform/util/src/com/intellij/util/containers/PathInterner.java +++ b/platform/util/src/com/intellij/util/containers/PathInterner.java @@ -41,13 +41,13 @@ public class PathInterner { return Arrays.equals(o1, o2); } }; - private final OpenTHashSet myInternMap = new OpenTHashSet(); + private final OpenTHashSet myInternMap = new OpenTHashSet<>(); @Nullable protected SubstringWrapper[] internParts(String path, boolean forAddition) { int start = 0; boolean asBytes = forAddition && IOUtil.isAscii(path); - List key = new ArrayList(); + List key = new ArrayList<>(); SubstringWrapper flyweightKey = new SubstringWrapper(); while (start < path.length()) { flyweightKey.findSubStringUntilNextSeparator(path, start); @@ -164,9 +164,9 @@ public class PathInterner { } public static class PathEnumerator { - private final TObjectIntHashMap mySeqToIdx = new TObjectIntHashMap( + private final TObjectIntHashMap mySeqToIdx = new TObjectIntHashMap<>( PathInterner.HASHING_STRATEGY); - private final List myIdxToSeq = new ArrayList(); + private final List myIdxToSeq = new ArrayList<>(); private final PathInterner myInterner = new PathInterner(); public PathEnumerator() { @@ -174,7 +174,7 @@ public class PathInterner { } public List getAllPaths() { - ArrayList result = new ArrayList(myIdxToSeq.size() - 1); + ArrayList result = new ArrayList<>(myIdxToSeq.size() - 1); for (SubstringWrapper[] wrappers : myIdxToSeq) { if (wrappers != null) { result.add(PathInterner.restorePath(wrappers)); @@ -212,7 +212,7 @@ public class PathInterner { } public static class PathMap { - private final THashMap myMap = new THashMap(PathInterner.HASHING_STRATEGY); + private final THashMap myMap = new THashMap<>(PathInterner.HASHING_STRATEGY); private final PathInterner myInterner = new PathInterner(); @Nullable diff --git a/platform/util/src/com/intellij/util/containers/RefHashMap.java b/platform/util/src/com/intellij/util/containers/RefHashMap.java index 096610482d84..e19eaa811f0c 100644 --- a/platform/util/src/com/intellij/util/containers/RefHashMap.java +++ b/platform/util/src/com/intellij/util/containers/RefHashMap.java @@ -29,7 +29,7 @@ import java.util.*; */ abstract class RefHashMap extends AbstractMap implements Map { private final MyMap myMap; - private final ReferenceQueue myReferenceQueue = new ReferenceQueue(); + private final ReferenceQueue myReferenceQueue = new ReferenceQueue<>(); private final HardKey myHardKeyInstance = new HardKey(); // "singleton" @NotNull private final TObjectHashingStrategy myStrategy; @@ -325,7 +325,7 @@ abstract class RefHashMap extends AbstractMap implements Map { // weak key has been cleared by GC, ignore continue; } - next = new MyEntry(ent, k, wk.hashCode(), myStrategy); + next = new MyEntry<>(ent, k, wk.hashCode(), myStrategy); return true; } return false; diff --git a/platform/util/src/com/intellij/util/containers/RefKeyRefValueHashMap.java b/platform/util/src/com/intellij/util/containers/RefKeyRefValueHashMap.java index c2494ece5043..0253be075f3f 100644 --- a/platform/util/src/com/intellij/util/containers/RefKeyRefValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/RefKeyRefValueHashMap.java @@ -22,7 +22,7 @@ import java.util.*; abstract class RefKeyRefValueHashMap implements Map{ private final RefHashMap> myMap; - private final ReferenceQueue myQueue = new ReferenceQueue(); + private final ReferenceQueue myQueue = new ReferenceQueue<>(); RefKeyRefValueHashMap(@NotNull RefHashMap> weakKeyMap) { myMap = weakKeyMap; @@ -116,7 +116,7 @@ abstract class RefKeyRefValueHashMap implements Map{ @NotNull @Override public Collection values() { - List result = new ArrayList(); + List result = new ArrayList<>(); final Collection> refs = myMap.values(); for (ValueReference ref : refs) { final V value = ref.get(); diff --git a/platform/util/src/com/intellij/util/containers/RefValueHashMap.java b/platform/util/src/com/intellij/util/containers/RefValueHashMap.java index 0dd19437ca82..893a9a3488aa 100644 --- a/platform/util/src/com/intellij/util/containers/RefValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/RefValueHashMap.java @@ -27,7 +27,7 @@ import java.util.*; abstract class RefValueHashMap implements Map{ private final Map> myMap; - private final ReferenceQueue myQueue = new ReferenceQueue(); + private final ReferenceQueue myQueue = new ReferenceQueue<>(); @NotNull static IncorrectOperationException pointlessContainsKey() { @@ -45,11 +45,11 @@ abstract class RefValueHashMap implements Map{ } RefValueHashMap() { - myMap = new THashMap>(); + myMap = new THashMap<>(); } RefValueHashMap(@NotNull TObjectHashingStrategy strategy) { - myMap = new THashMap>(strategy); + myMap = new THashMap<>(strategy); } protected abstract MyReference createReference(@NotNull K key, V value, @NotNull ReferenceQueue queue); @@ -128,7 +128,7 @@ abstract class RefValueHashMap implements Map{ @NotNull @Override public Collection values() { - List result = new ArrayList(); + List result = new ArrayList<>(); final Collection> refs = myMap.values(); for (MyReference ref : refs) { final V value = ref.get(); diff --git a/platform/util/src/com/intellij/util/containers/SequenceIterator.java b/platform/util/src/com/intellij/util/containers/SequenceIterator.java index 2e565e6a72e2..e4e370ecf6c6 100644 --- a/platform/util/src/com/intellij/util/containers/SequenceIterator.java +++ b/platform/util/src/com/intellij/util/containers/SequenceIterator.java @@ -65,12 +65,12 @@ public class SequenceIterator implements Iterator { @NotNull public static SequenceIterator create(@NotNull Iterator first, @NotNull Iterator second) { - return new SequenceIterator(first, second); + return new SequenceIterator<>(first, second); } @NotNull public static SequenceIterator create(@NotNull Iterator first, @NotNull Iterator second, @NotNull Iterator third) { - return new SequenceIterator(first, second, third); + return new SequenceIterator<>(first, second, third); } } diff --git a/platform/util/src/com/intellij/util/containers/SoftArrayHashMap.java b/platform/util/src/com/intellij/util/containers/SoftArrayHashMap.java index 5c1d82dae7b9..3165f2532982 100644 --- a/platform/util/src/com/intellij/util/containers/SoftArrayHashMap.java +++ b/platform/util/src/com/intellij/util/containers/SoftArrayHashMap.java @@ -87,7 +87,7 @@ public class SoftArrayHashMap implements Cloneable { } SoftArrayHashMap softArrayHashMap = myContinuationMap.get(key); if (softArrayHashMap == null) { - myContinuationMap.put(key, softArrayHashMap = new SoftArrayHashMap(myStrategy)); + myContinuationMap.put(key, softArrayHashMap = new SoftArrayHashMap<>(myStrategy)); } softArrayHashMap.put(array, index + 1, value); } @@ -113,7 +113,7 @@ public class SoftArrayHashMap implements Cloneable { @Override public final SoftArrayHashMap clone() { - final SoftArrayHashMap copy = new SoftArrayHashMap(myStrategy); + final SoftArrayHashMap copy = new SoftArrayHashMap<>(myStrategy); copy.myContinuationMap = copyMap(myContinuationMap); copy.myValuesMap = copyMap(myValuesMap); copy.myEmptyValue = myEmptyValue; diff --git a/platform/util/src/com/intellij/util/containers/SoftHashMap.java b/platform/util/src/com/intellij/util/containers/SoftHashMap.java index 015257adb660..a4f992b5296a 100644 --- a/platform/util/src/com/intellij/util/containers/SoftHashMap.java +++ b/platform/util/src/com/intellij/util/containers/SoftHashMap.java @@ -56,7 +56,7 @@ public final class SoftHashMap extends RefHashMap { @NotNull @Override protected Key createKey(@NotNull T k, @NotNull TObjectHashingStrategy strategy, @NotNull ReferenceQueue q) { - return new SoftKey(k, strategy, q); + return new SoftKey<>(k, strategy, q); } private static class SoftKey extends SoftReference implements Key { diff --git a/platform/util/src/com/intellij/util/containers/SoftKeySoftValueHashMap.java b/platform/util/src/com/intellij/util/containers/SoftKeySoftValueHashMap.java index e4634276fafe..ff6a2c1cd885 100644 --- a/platform/util/src/com/intellij/util/containers/SoftKeySoftValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/SoftKeySoftValueHashMap.java @@ -28,7 +28,7 @@ import java.util.*; @Deprecated public final class SoftKeySoftValueHashMap implements Map{ private final RefHashMap> mySoftKeyMap = (RefHashMap>)ContainerUtil.>createSoftMap(); - private final ReferenceQueue myQueue = new ReferenceQueue(); + private final ReferenceQueue myQueue = new ReferenceQueue<>(); @Deprecated public SoftKeySoftValueHashMap() { @@ -72,7 +72,7 @@ public final class SoftKeySoftValueHashMap implements Map{ public V put(K key, V value) { processQueue(); RefHashMap.Key softKey = mySoftKeyMap.createKey(key); - ValueReference reference = new ValueReference(softKey, value, myQueue); + ValueReference reference = new ValueReference<>(softKey, value, myQueue); ValueReference oldRef = mySoftKeyMap.putKey(softKey, reference); return com.intellij.reference.SoftReference.dereference(oldRef); } @@ -124,7 +124,7 @@ public final class SoftKeySoftValueHashMap implements Map{ @NotNull @Override public Collection values() { - List result = new ArrayList(); + List result = new ArrayList<>(); final Collection> refs = mySoftKeyMap.values(); for (ValueReference ref : refs) { final V value = ref.get(); diff --git a/platform/util/src/com/intellij/util/containers/SoftValueHashMap.java b/platform/util/src/com/intellij/util/containers/SoftValueHashMap.java index cdf8a2125035..52cdd259f541 100644 --- a/platform/util/src/com/intellij/util/containers/SoftValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/SoftValueHashMap.java @@ -52,6 +52,6 @@ public final class SoftValueHashMap extends RefValueHashMap{ @Override protected MyReference createReference(@NotNull K key, V value, @NotNull ReferenceQueue queue) { - return new MySoftReference(key, value, queue); + return new MySoftReference<>(key, value, queue); } } diff --git a/platform/util/src/com/intellij/util/containers/SortedList.java b/platform/util/src/com/intellij/util/containers/SortedList.java index b8550ff83b55..eae95511acf5 100644 --- a/platform/util/src/com/intellij/util/containers/SortedList.java +++ b/platform/util/src/com/intellij/util/containers/SortedList.java @@ -30,7 +30,7 @@ public class SortedList extends AbstractList{ public SortedList(@NotNull Comparator comparator) { myComparator = comparator; - myMap = new TreeMap>(comparator); + myMap = new TreeMap<>(comparator); } @NotNull @@ -46,7 +46,7 @@ public class SortedList extends AbstractList{ private void addToMap(T element) { List group = myMap.get(element); if (group == null) { - myMap.put(element, group = new SmartList()); + myMap.put(element, group = new SmartList<>()); } group.add(element); myDelegate = null; diff --git a/platform/util/src/com/intellij/util/containers/TransferToEDTQueue.java b/platform/util/src/com/intellij/util/containers/TransferToEDTQueue.java index 9f8c1d34725a..d9f58829e761 100644 --- a/platform/util/src/com/intellij/util/containers/TransferToEDTQueue.java +++ b/platform/util/src/com/intellij/util/containers/TransferToEDTQueue.java @@ -53,7 +53,7 @@ public class TransferToEDTQueue { private final Condition myShutUpCondition; private final int myMaxUnitOfWorkThresholdMs; //-1 means indefinite - private final Queue myQueue = new Queue(10); // guarded by myQueue + private final Queue myQueue = new Queue<>(10); // guarded by myQueue private final AtomicBoolean invokeLaterScheduled = new AtomicBoolean(); private final Runnable myUpdateRunnable = new Runnable() { @Override @@ -99,7 +99,7 @@ public class TransferToEDTQueue { } public static TransferToEDTQueue createRunnableMerger(@NotNull @NonNls String name, int maxUnitOfWorkThresholdMs) { - return new TransferToEDTQueue(name, new Processor() { + return new TransferToEDTQueue<>(name, new Processor() { @Override public boolean process(Runnable runnable) { runnable.run(); diff --git a/platform/util/src/com/intellij/util/containers/TreeTraversal.java b/platform/util/src/com/intellij/util/containers/TreeTraversal.java index 5c3b95c18a59..e89adb4a44de 100644 --- a/platform/util/src/com/intellij/util/containers/TreeTraversal.java +++ b/platform/util/src/com/intellij/util/containers/TreeTraversal.java @@ -104,7 +104,7 @@ public abstract class TreeTraversal { @Override public boolean value(T e) { - if (visited == null) visited = new java.util.HashSet(); + if (visited == null) visited = new java.util.HashSet<>(); //noinspection unchecked return visited.add(((Function)identity).fun(e)); } @@ -240,7 +240,7 @@ public abstract class TreeTraversal { @Override public It createIterator(@NotNull Iterable roots, @NotNull Function> tree) { //noinspection unchecked - return new GuidedItImpl(roots, tree, (GuidedIt.Guide)guide); + return new GuidedItImpl<>(roots, tree, (GuidedIt.Guide)guide); } }; } @@ -258,7 +258,7 @@ public abstract class TreeTraversal { @NotNull @Override public It createIterator(@NotNull Iterable roots, @NotNull Function> tree) { - return new BiOrderIt(roots, tree, BiOrderIt.Order.BOTH); + return new BiOrderIt<>(roots, tree, BiOrderIt.Order.BOTH); } }; @@ -274,7 +274,7 @@ public abstract class TreeTraversal { @NotNull @Override public It createIterator(@NotNull Iterable roots, @NotNull Function> tree) { - return new BiOrderIt(roots, tree, BiOrderIt.Order.PRE); + return new BiOrderIt<>(roots, tree, BiOrderIt.Order.PRE); } }; @@ -290,7 +290,7 @@ public abstract class TreeTraversal { @NotNull @Override public It createIterator(@NotNull Iterable roots, @NotNull Function> tree) { - return new BiOrderIt(roots, tree, BiOrderIt.Order.POST); + return new BiOrderIt<>(roots, tree, BiOrderIt.Order.POST); } }; @@ -304,7 +304,7 @@ public abstract class TreeTraversal { @NotNull @Override public It createIterator(@NotNull Iterable roots, @NotNull Function> tree) { - return new LeavesDfsIt(roots, tree); + return new LeavesDfsIt<>(roots, tree); } }; @@ -321,7 +321,7 @@ public abstract class TreeTraversal { @NotNull @Override public It createIterator(@NotNull Iterable roots, @NotNull Function> tree) { - return new InterleavedIt(roots, tree); + return new InterleavedIt<>(roots, tree); } }; @@ -337,7 +337,7 @@ public abstract class TreeTraversal { @NotNull @Override public It createIterator(@NotNull Iterable roots, @NotNull Function> tree) { - return new PlainBfsIt(roots, tree); + return new PlainBfsIt<>(roots, tree); } }; @@ -351,7 +351,7 @@ public abstract class TreeTraversal { @NotNull @Override public It createIterator(@NotNull Iterable roots, @NotNull Function> tree) { - return new TracingBfsIt(roots, tree); + return new TracingBfsIt<>(roots, tree); } }; @@ -364,7 +364,7 @@ public abstract class TreeTraversal { @NotNull @Override public It createIterator(@NotNull Iterable roots, @NotNull Function> tree) { - return new LeavesBfsIt(roots, tree); + return new LeavesBfsIt<>(roots, tree); } }; @@ -530,7 +530,7 @@ public abstract class TreeTraversal { private static final class PlainBfsIt extends It { - final ArrayDeque queue = new ArrayDeque(); + final ArrayDeque queue = new ArrayDeque<>(); P1 top; PlainBfsIt(@NotNull Iterable roots, Function> tree) { @@ -552,7 +552,7 @@ public abstract class TreeTraversal { private static final class LeavesBfsIt extends TracingIt { - final ArrayDeque queue = new ArrayDeque(); + final ArrayDeque queue = new ArrayDeque<>(); LeavesBfsIt(@NotNull Iterable roots, Function> tree) { super(tree); @@ -574,7 +574,7 @@ public abstract class TreeTraversal { private final static class TracingBfsIt extends TracingIt { - final ArrayDeque queue = new ArrayDeque(); + final ArrayDeque queue = new ArrayDeque<>(); final Map paths = ContainerUtil.newTroveMap(ContainerUtil.identityStrategy()); P1 top; P1 cur; @@ -730,7 +730,7 @@ public abstract class TreeTraversal { private static final class P1 extends P> { - static P1 create(T node) { return create(new P1(), node); } + static P1 create(T node) { return create(new P1<>(), node); } static P1 create(Iterable it) { return create(new P1(), it); } P1 add(@NotNull P1 next) { @@ -761,7 +761,7 @@ public abstract class TreeTraversal { private static final class P2 extends P> { P2 next, prev; - static P2 create(T node) { return create(new P2(), node); } + static P2 create(T node) { return create(new P2<>(), node); } static P2 create(Iterable it) { return create(new P2(), it); } P2 add(@NotNull P2 next) { diff --git a/platform/util/src/com/intellij/util/containers/UnsafeWeakList.java b/platform/util/src/com/intellij/util/containers/UnsafeWeakList.java index de9960f9bea9..b287f6ce18e7 100644 --- a/platform/util/src/com/intellij/util/containers/UnsafeWeakList.java +++ b/platform/util/src/com/intellij/util/containers/UnsafeWeakList.java @@ -41,7 +41,7 @@ import java.util.*; */ public class UnsafeWeakList extends AbstractCollection { protected final List> myList; - private final ReferenceQueue myQueue = new ReferenceQueue(); + private final ReferenceQueue myQueue = new ReferenceQueue<>(); private int myAlive; private int modCount; @@ -55,11 +55,11 @@ public class UnsafeWeakList extends AbstractCollection { } public UnsafeWeakList() { - myList = new ArrayList>(); + myList = new ArrayList<>(); } public UnsafeWeakList(int capacity) { - myList = new ArrayList>(capacity); + myList = new ArrayList<>(capacity); } boolean processQueue() { @@ -96,7 +96,7 @@ public class UnsafeWeakList extends AbstractCollection { continue; } if (toSaveAlive != i) { - myList.set(toSaveAlive, new MyReference(toSaveAlive, t, myQueue)); + myList.set(toSaveAlive, new MyReference<>(toSaveAlive, t, myQueue)); } toSaveAlive++; } @@ -108,7 +108,7 @@ public class UnsafeWeakList extends AbstractCollection { } private void append(@NotNull T element) { - myList.add(new MyReference(myList.size(), element, myQueue)); + myList.add(new MyReference<>(myList.size(), element, myQueue)); myAlive++; modCount++; } diff --git a/platform/util/src/com/intellij/util/containers/WeakHashMap.java b/platform/util/src/com/intellij/util/containers/WeakHashMap.java index 78e4b945b3fd..a2b7e4629639 100644 --- a/platform/util/src/com/intellij/util/containers/WeakHashMap.java +++ b/platform/util/src/com/intellij/util/containers/WeakHashMap.java @@ -53,7 +53,7 @@ public final class WeakHashMap extends RefHashMap { @NotNull @Override protected Key createKey(@NotNull T k, @NotNull TObjectHashingStrategy strategy, @NotNull ReferenceQueue q) { - return new WeakKey(k, strategy, q); + return new WeakKey<>(k, strategy, q); } private static class WeakKey extends WeakReference implements Key { diff --git a/platform/util/src/com/intellij/util/containers/WeakHashSet.java b/platform/util/src/com/intellij/util/containers/WeakHashSet.java index ea3854f34d35..85b296a9898f 100644 --- a/platform/util/src/com/intellij/util/containers/WeakHashSet.java +++ b/platform/util/src/com/intellij/util/containers/WeakHashSet.java @@ -30,8 +30,8 @@ import java.util.Set; * Null keys are NOT allowed */ final class WeakHashSet extends AbstractSet { - private final Set> set = new THashSet>(); - private final ReferenceQueue queue = new ReferenceQueue(); + private final Set> set = new THashSet<>(); + private final ReferenceQueue queue = new ReferenceQueue<>(); private static class MyRef extends WeakReference { private final int myHashCode; @@ -89,7 +89,7 @@ final class WeakHashSet extends AbstractSet { @Override public boolean add(@NotNull T t) { processQueue(); - MyRef ref = new MyRef(t, queue); + MyRef ref = new MyRef<>(t, queue); return set.add(ref); } @@ -97,14 +97,14 @@ final class WeakHashSet extends AbstractSet { public boolean remove(@NotNull Object o) { processQueue(); //noinspection unchecked - return set.remove(new HardRef((T)o)); + return set.remove(new HardRef<>((T)o)); } @Override public boolean contains(@NotNull Object o) { processQueue(); //noinspection unchecked - return set.contains(new HardRef((T)o)); + return set.contains(new HardRef<>((T)o)); } @Override diff --git a/platform/util/src/com/intellij/util/containers/WeakKeyIntValueHashMap.java b/platform/util/src/com/intellij/util/containers/WeakKeyIntValueHashMap.java index 558c173a4165..7cc51174304a 100644 --- a/platform/util/src/com/intellij/util/containers/WeakKeyIntValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/WeakKeyIntValueHashMap.java @@ -29,8 +29,8 @@ import java.util.Iterator; import java.util.Set; class WeakKeyIntValueHashMap implements ObjectIntMap { - private final TObjectIntHashMap> myMap = new TObjectIntHashMap>(); - private final ReferenceQueue myQueue = new ReferenceQueue(); + private final TObjectIntHashMap> myMap = new TObjectIntHashMap<>(); + private final ReferenceQueue myQueue = new ReferenceQueue<>(); private static class MyReference extends WeakReference { private final int myHashCode; @@ -68,21 +68,21 @@ class WeakKeyIntValueHashMap implements ObjectIntMap { @Override public final int get(@NotNull K key) { - MyReference ref = new MyReference(key, null); + MyReference ref = new MyReference<>(key, null); return myMap.get(ref); } @Override public final int put(@NotNull K key, int value) { processQueue(); - MyReference ref = new MyReference(key, myQueue); + MyReference ref = new MyReference<>(key, myQueue); return myMap.put(ref, value); } @Override public final int remove(@NotNull K key) { processQueue(); - MyReference ref = new MyReference(key, myQueue); + MyReference ref = new MyReference<>(key, myQueue); return myMap.remove(ref); } @@ -104,7 +104,7 @@ class WeakKeyIntValueHashMap implements ObjectIntMap { @Override public final boolean containsKey(@NotNull K key) { - MyReference ref = new MyReference(key, null); + MyReference ref = new MyReference<>(key, null); return myMap.containsKey(ref); } @@ -117,7 +117,7 @@ class WeakKeyIntValueHashMap implements ObjectIntMap { @NotNull @Override public Set keySet() { - return new THashSet(ContainerUtil.map(myMap.keys(), new Function() { + return new THashSet<>(ContainerUtil.map(myMap.keys(), new Function() { @Override public K fun(Object ref) { return SoftReference.dereference((MyReference)ref); diff --git a/platform/util/src/com/intellij/util/containers/WeakKeySoftValueHashMap.java b/platform/util/src/com/intellij/util/containers/WeakKeySoftValueHashMap.java index 42de72b93b43..50fa6e6c0756 100644 --- a/platform/util/src/com/intellij/util/containers/WeakKeySoftValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/WeakKeySoftValueHashMap.java @@ -46,6 +46,6 @@ final class WeakKeySoftValueHashMap extends RefKeyRefValueHashMap impl protected ValueReference createValueReference(@NotNull RefHashMap.Key key, V referent, ReferenceQueue q) { - return new SoftValueReference(key, referent, q); + return new SoftValueReference<>(key, referent, q); } } diff --git a/platform/util/src/com/intellij/util/containers/WeakKeyWeakValueHashMap.java b/platform/util/src/com/intellij/util/containers/WeakKeyWeakValueHashMap.java index 338dd5a6198b..0eee205f2cfc 100644 --- a/platform/util/src/com/intellij/util/containers/WeakKeyWeakValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/WeakKeyWeakValueHashMap.java @@ -56,6 +56,6 @@ public final class WeakKeyWeakValueHashMap extends RefKeyRefValueHashMap createValueReference(@NotNull RefHashMap.Key key, V referent, ReferenceQueue q) { - return new WeakValueReference(key, referent, q); + return new WeakValueReference<>(key, referent, q); } } diff --git a/platform/util/src/com/intellij/util/containers/WeakStringInterner.java b/platform/util/src/com/intellij/util/containers/WeakStringInterner.java index 8cb5be9c8aee..39e4f4066668 100644 --- a/platform/util/src/com/intellij/util/containers/WeakStringInterner.java +++ b/platform/util/src/com/intellij/util/containers/WeakStringInterner.java @@ -27,7 +27,7 @@ import java.util.Set; * @author peter */ public class WeakStringInterner extends StringInterner { - private final WeakInterner myDelegate = new WeakInterner(); + private final WeakInterner myDelegate = new WeakInterner<>(); @NotNull @Override diff --git a/platform/util/src/com/intellij/util/containers/WeakValueHashMap.java b/platform/util/src/com/intellij/util/containers/WeakValueHashMap.java index c67ead41c08d..9968ccbe5da1 100644 --- a/platform/util/src/com/intellij/util/containers/WeakValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/WeakValueHashMap.java @@ -56,6 +56,6 @@ public final class WeakValueHashMap extends RefValueHashMap { @Override protected MyReference createReference(@NotNull K key, V value, @NotNull ReferenceQueue queue) { - return new MyWeakReference(key, value, queue); + return new MyWeakReference<>(key, value, queue); } } diff --git a/platform/util/src/com/intellij/util/containers/hash/HashMap.java b/platform/util/src/com/intellij/util/containers/hash/HashMap.java index 15b3aa29d9cd..2cbbf0fe55a0 100644 --- a/platform/util/src/com/intellij/util/containers/hash/HashMap.java +++ b/platform/util/src/com/intellij/util/containers/hash/HashMap.java @@ -124,7 +124,7 @@ public class HashMap extends AbstractMap implements Map { } - final Entry e = new Entry(key, value); + final Entry e = new Entry<>(key, value); e.hashNext = table[index]; diff --git a/platform/util/src/com/intellij/util/containers/hash/HashSet.java b/platform/util/src/com/intellij/util/containers/hash/HashSet.java index 646cec28cf4d..9e60393f38c5 100644 --- a/platform/util/src/com/intellij/util/containers/hash/HashSet.java +++ b/platform/util/src/com/intellij/util/containers/hash/HashSet.java @@ -123,7 +123,7 @@ public class HashSet extends AbstractSet implements Set { - final Entry e = new Entry(key); + final Entry e = new Entry<>(key); e.hashNext = table[index]; diff --git a/platform/util/src/com/intellij/util/diff/Diff.java b/platform/util/src/com/intellij/util/diff/Diff.java index 92051f57dad9..fa82bfb96c50 100644 --- a/platform/util/src/com/intellij/util/diff/Diff.java +++ b/platform/util/src/com/intellij/util/diff/Diff.java @@ -61,7 +61,7 @@ public class Diff { if (changeRef != null) return changeRef.get(); int trimmedLength = objects1.length + objects2.length - 2 * startShift - 2 * endCut; - Enumerator enumerator = new Enumerator(trimmedLength, ContainerUtil.canonicalStrategy()); + Enumerator enumerator = new Enumerator<>(trimmedLength, ContainerUtil.canonicalStrategy()); int[] ints1 = enumerator.enumerate(objects1, startShift, endCut); int[] ints2 = enumerator.enumerate(objects2, startShift, endCut); return doBuildChanges(ints1, ints2, new ChangeBuilder(startShift)); @@ -89,7 +89,7 @@ public class Diff { Change change = trimmedLength1 != 0 || trimmedLength2 != 0 ? new Change(startShift, startShift, trimmedLength1, trimmedLength2, null) : null; - return new Ref(change); + return new Ref<>(change); } private static Change doBuildChanges(@NotNull int[] ints1, @NotNull int[] ints2, @NotNull ChangeBuilder builder) @@ -257,7 +257,7 @@ public class Diff { } public ArrayList toList() { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); Change current = this; while (current != null) { result.add(current); diff --git a/platform/util/src/com/intellij/util/diff/DiffTree.java b/platform/util/src/com/intellij/util/diff/DiffTree.java index c28e9c1db2dc..9e97d523c911 100644 --- a/platform/util/src/com/intellij/util/diff/DiffTree.java +++ b/platform/util/src/com/intellij/util/diff/DiffTree.java @@ -32,8 +32,8 @@ public class DiffTree { private final FlyweightCapableTreeStructure myOldTree; private final FlyweightCapableTreeStructure myNewTree; private final ShallowNodeComparator myComparator; - private final List> myOldChildrenLists = new ArrayList>(); - private final List> myNewChildrenLists = new ArrayList>(); + private final List> myOldChildrenLists = new ArrayList<>(); + private final List> myNewChildrenLists = new ArrayList<>(); private final CharSequence myOldText; private final CharSequence myNewText; private final int myOldTreeStart; @@ -57,7 +57,7 @@ public class DiffTree { @NotNull ShallowNodeComparator comparator, @NotNull DiffTreeChangeBuilder consumer, @NotNull CharSequence oldText) { - final DiffTree tree = new DiffTree(oldTree, newTree, comparator, oldText); + final DiffTree tree = new DiffTree<>(oldTree, newTree, comparator, oldText); tree.build(oldTree.getRoot(), newTree.getRoot(), 0, consumer); } @@ -97,8 +97,8 @@ public class DiffTree { } if (level == myNewChildrenLists.size()) { - myNewChildrenLists.add(new Ref()); - myOldChildrenLists.add(new Ref()); + myNewChildrenLists.add(new Ref<>()); + myOldChildrenLists.add(new Ref<>()); } final Ref oldChildrenR = myOldChildrenLists.get(level); diff --git a/platform/util/src/com/intellij/util/graph/CachingSemiGraph.java b/platform/util/src/com/intellij/util/graph/CachingSemiGraph.java index 537c5414571b..b7d5be9d8c3e 100644 --- a/platform/util/src/com/intellij/util/graph/CachingSemiGraph.java +++ b/platform/util/src/com/intellij/util/graph/CachingSemiGraph.java @@ -26,7 +26,7 @@ import java.util.*; */ public class CachingSemiGraph implements GraphGenerator.SemiGraph { public static InboundSemiGraph cache(InboundSemiGraph original) { - return new CachingSemiGraph(original); + return new CachingSemiGraph<>(original); } private final Set myNodes; @@ -34,11 +34,11 @@ public class CachingSemiGraph implements GraphGenerator.SemiGraph { private CachingSemiGraph(InboundSemiGraph original) { myNodes = ContainerUtil.newLinkedHashSet(original.getNodes()); - myIn = new THashMap>(); + myIn = new THashMap<>(); for (Node node : myNodes) { final Iterator inIterator = original.getIn(node); if (inIterator.hasNext()) { - ArrayList value = new ArrayList(); + ArrayList value = new ArrayList<>(); ContainerUtil.addAll(value, inIterator); myIn.put(node, value); } diff --git a/platform/util/src/com/intellij/util/graph/DFSTBuilder.java b/platform/util/src/com/intellij/util/graph/DFSTBuilder.java index 5430ada16ede..8d994835c80e 100644 --- a/platform/util/src/com/intellij/util/graph/DFSTBuilder.java +++ b/platform/util/src/com/intellij/util/graph/DFSTBuilder.java @@ -39,7 +39,7 @@ public class DFSTBuilder { private Comparator myNComparator; private Comparator myTComparator; private final TIntArrayList mySCCs = new TIntArrayList(); // strongly connected component sizes - private final TObjectIntHashMap myNodeToTNumber = new TObjectIntHashMap(); // node -> number in scc topological order. Independent scc are in reversed loading order + private final TObjectIntHashMap myNodeToTNumber = new TObjectIntHashMap<>(); // node -> number in scc topological order. Independent scc are in reversed loading order private final Node[] myInvT; // number in (enumerate all nodes scc by scc) order -> node private final Node[] myAllNodes; @@ -82,7 +82,7 @@ public class DFSTBuilder { } myGraph = graph; int size = graph.getNodes().size(); - myNodeToNNumber = new TObjectIntHashMap(size * 2, 0.5f); + myNodeToNNumber = new TObjectIntHashMap<>(size * 2, 0.5f); myInvN = (Node[])new Object[size]; myInvT = (Node[])new Object[size]; new Tarjan().build(); @@ -130,8 +130,8 @@ public class DFSTBuilder { } } - private final Stack frames = new Stack(); // recursion stack - private final TObjectIntHashMap nodeIndex = new TObjectIntHashMap(); + private final Stack frames = new Stack<>(); // recursion stack + private final TObjectIntHashMap nodeIndex = new TObjectIntHashMap<>(); private int dfsIndex; private int sccsSizeCombined; private final TIntArrayList topo = new TIntArrayList(index.length); // nodes in reverse topological order @@ -145,7 +145,7 @@ public class DFSTBuilder { for (int i = 0; i < index.length; i++) { if (index[i] == -1) { frames.push(new Frame(i)); - List> sccs = new ArrayList>(); + List> sccs = new ArrayList<>(); strongConnect(sccs); @@ -224,7 +224,7 @@ public class DFSTBuilder { // we are really back, pop a scc if (lowLink[i] == index[i]) { // found yer - List scc = new ArrayList(); + List scc = new ArrayList<>(); int pushedI; do { pushedI = nodesOnStack.pop(); @@ -379,7 +379,7 @@ public class DFSTBuilder { @NotNull public List getSortedNodes() { - List result = new ArrayList(myGraph.getNodes()); + List result = new ArrayList<>(myGraph.getNodes()); Collections.sort(result, comparator()); return result; } diff --git a/platform/util/src/com/intellij/util/graph/GraphGenerator.java b/platform/util/src/com/intellij/util/graph/GraphGenerator.java index e9ebfb43e159..9072299c0766 100644 --- a/platform/util/src/com/intellij/util/graph/GraphGenerator.java +++ b/platform/util/src/com/intellij/util/graph/GraphGenerator.java @@ -29,7 +29,7 @@ import java.util.*; public class GraphGenerator implements Graph { @NotNull public static Graph generate(InboundSemiGraph graph) { - return new GraphGenerator(graph); + return new GraphGenerator<>(graph); } private final InboundSemiGraph myGraph; @@ -37,12 +37,12 @@ public class GraphGenerator implements Graph { private GraphGenerator(@NotNull InboundSemiGraph graph) { myGraph = graph; - myOuts = new THashMap>(); + myOuts = new THashMap<>(); buildOuts(); } private void buildOuts() { - final Set> edges = new THashSet>(); + final Set> edges = new THashSet<>(); Collection nodes = myGraph.getNodes(); @@ -58,7 +58,7 @@ public class GraphGenerator implements Graph { List edgesFromInNode = myOuts.get(inNode); if (edgesFromInNode == null) { - edgesFromInNode = new ArrayList(); + edgesFromInNode = new ArrayList<>(); myOuts.put(inNode, edgesFromInNode); } edgesFromInNode.add(node); @@ -101,7 +101,7 @@ public class GraphGenerator implements Graph { /** @deprecated use {@link #generate(InboundSemiGraph)} (to be removed in IDEA 2018) */ @Deprecated public static GraphGenerator create(SemiGraph graph) { - return new GraphGenerator(graph); + return new GraphGenerator<>(graph); } // } \ No newline at end of file diff --git a/platform/util/src/com/intellij/util/indexing/IndexId.java b/platform/util/src/com/intellij/util/indexing/IndexId.java index 6029457983b9..9ef8472293fd 100644 --- a/platform/util/src/com/intellij/util/indexing/IndexId.java +++ b/platform/util/src/com/intellij/util/indexing/IndexId.java @@ -9,7 +9,7 @@ import java.util.Map; @ApiStatus.Experimental public class IndexId { - private static final Map> ourInstances = new THashMap>(); + private static final Map> ourInstances = new THashMap<>(); @NotNull private final String myName; @@ -34,7 +34,7 @@ public class IndexId { @SuppressWarnings("unchecked") IndexId id = (IndexId)ourInstances.get(name); if (id == null) { - ourInstances.put(name, id = new IndexId(name)); + ourInstances.put(name, id = new IndexId<>(name)); } return id; } diff --git a/platform/util/src/com/intellij/util/indexing/impl/ChangeTrackingValueContainer.java b/platform/util/src/com/intellij/util/indexing/impl/ChangeTrackingValueContainer.java index 6ee9768d1525..5a6cbe8546f6 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/ChangeTrackingValueContainer.java +++ b/platform/util/src/com/intellij/util/indexing/impl/ChangeTrackingValueContainer.java @@ -52,7 +52,7 @@ public class ChangeTrackingValueContainer extends UpdatableValueContainer merged.addValue(inputId, value); } - if (myAdded == null) myAdded = new ValueContainerImpl(); + if (myAdded == null) myAdded = new ValueContainerImpl<>(); myAdded.addValue(inputId, value); } @@ -119,7 +119,7 @@ public class ChangeTrackingValueContainer extends UpdatableValueContainer (newMerged.size() > ValueContainerImpl.NUMBER_OF_VALUES_THRESHOLD || (myAdded != null && myAdded.size() > ValueContainerImpl.NUMBER_OF_VALUES_THRESHOLD))) { // Calculate file ids that have Value mapped to avoid O(NumberOfValuesInMerged) during removal - fileId2ValueMapping = new FileId2ValueMapping(newMerged); + fileId2ValueMapping = new FileId2ValueMapping<>(newMerged); } final FileId2ValueMapping finalFileId2ValueMapping = fileId2ValueMapping; if (myInvalidated != null) { diff --git a/platform/util/src/com/intellij/util/indexing/impl/DebugAssertions.java b/platform/util/src/com/intellij/util/indexing/impl/DebugAssertions.java index c32854240e8c..2be07dec44b6 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/DebugAssertions.java +++ b/platform/util/src/com/intellij/util/indexing/impl/DebugAssertions.java @@ -56,9 +56,9 @@ public class DebugAssertions { public static boolean equals(Collection keys, Collection keys2, KeyDescriptor keyDescriptor) { if (keys == null && keys2 == null) return true; if (keys == null || keys2 == null || keys.size() != keys2.size()) return false; - LinkedHashMap map = new LinkedHashMap(keys.size(), 0.8f, keyDescriptor); + LinkedHashMap map = new LinkedHashMap<>(keys.size(), 0.8f, keyDescriptor); for(Key key:keys) map.put(key, Boolean.TRUE); - LinkedHashMap map2 = new LinkedHashMap(keys.size(), 0.8f, keyDescriptor); + LinkedHashMap map2 = new LinkedHashMap<>(keys.size(), 0.8f, keyDescriptor); for(Key key:keys2) map2.put(key, Boolean.TRUE); return map.equals(map2); } diff --git a/platform/util/src/com/intellij/util/indexing/impl/FileId2ValueMapping.java b/platform/util/src/com/intellij/util/indexing/impl/FileId2ValueMapping.java index 06d076652775..9c88f05e4023 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/FileId2ValueMapping.java +++ b/platform/util/src/com/intellij/util/indexing/impl/FileId2ValueMapping.java @@ -28,7 +28,7 @@ class FileId2ValueMapping { private boolean myOnePerFileValidationEnabled = true; FileId2ValueMapping(ValueContainerImpl _valueContainer) { - id2ValueMap = new TIntObjectHashMap(); + id2ValueMap = new TIntObjectHashMap<>(); valueContainer = _valueContainer; TIntArrayList removedFileIdList = null; @@ -43,7 +43,7 @@ class FileId2ValueMapping { if (previousValue != null) { // delay removal of duplicated id -> value mapping since it will affect valueIterator we are using if (removedFileIdList == null) { removedFileIdList = new TIntArrayList(); - removedValueList = new SmartList(); + removedValueList = new SmartList<>(); } removedFileIdList.add(id); removedValueList.add(previousValue); diff --git a/platform/util/src/com/intellij/util/indexing/impl/InputIndexDataExternalizer.java b/platform/util/src/com/intellij/util/indexing/impl/InputIndexDataExternalizer.java index 6a48b7c03ccb..2da00bb9cdaf 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/InputIndexDataExternalizer.java +++ b/platform/util/src/com/intellij/util/indexing/impl/InputIndexDataExternalizer.java @@ -55,7 +55,7 @@ public class InputIndexDataExternalizer implements DataExternalizer read(@NotNull DataInput in) throws IOException { try { final int size = DataInputOutputUtil.readINT(in); - final List list = new ArrayList(size); + final List list = new ArrayList<>(size); for (int idx = 0; idx < size; idx++) { list.add(myKeyDescriptor.read(in)); } diff --git a/platform/util/src/com/intellij/util/indexing/impl/KeyCollectionBasedForwardIndex.java b/platform/util/src/com/intellij/util/indexing/impl/KeyCollectionBasedForwardIndex.java index db04c4acbab2..6375243ee78d 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/KeyCollectionBasedForwardIndex.java +++ b/platform/util/src/com/intellij/util/indexing/impl/KeyCollectionBasedForwardIndex.java @@ -28,7 +28,7 @@ public abstract class KeyCollectionBasedForwardIndex extends MapBase @Override protected InputDataDiffBuilder getDiffBuilder(int inputId, Collection keys) { - return new CollectionInputDataDiffBuilder(inputId, keys); + return new CollectionInputDataDiffBuilder<>(inputId, keys); } @Override diff --git a/platform/util/src/com/intellij/util/indexing/impl/MapIndexStorage.java b/platform/util/src/com/intellij/util/indexing/impl/MapIndexStorage.java index 5415c0062479..38ebcad83378 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/MapIndexStorage.java +++ b/platform/util/src/com/intellij/util/indexing/impl/MapIndexStorage.java @@ -100,7 +100,7 @@ public abstract class MapIndexStorage implements IndexStorage createValue(final Key key) { - return new ChangeTrackingValueContainer(new ChangeTrackingValueContainer.Initializer() { + return new ChangeTrackingValueContainer<>(new ChangeTrackingValueContainer.Initializer() { @NotNull @Override public Object getLock() { @@ -114,7 +114,7 @@ public abstract class MapIndexStorage implements IndexStorage(); + value = new ValueContainerImpl<>(); } } catch (IOException e) { @@ -239,7 +239,7 @@ public abstract class MapIndexStorage implements IndexStorage valueContainer = new ChangeTrackingValueContainer(null); + ChangeTrackingValueContainer valueContainer = new ChangeTrackingValueContainer<>(null); valueContainer.addValue(inputId, value); myMap.put(key, valueContainer); } diff --git a/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java b/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java index 9de1b96c2223..bf025054c278 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java +++ b/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java @@ -198,7 +198,7 @@ public abstract class MapReduceIndex implements InvertedIndex< try { lock.lock(); if (myDisposed) { - return new ValueContainerImpl(); + return new ValueContainerImpl<>(); } ValueContainerImpl.ourDebugIndexInfo.set(myIndexId); return myStorage.read(key); @@ -257,14 +257,14 @@ public abstract class MapReduceIndex implements InvertedIndex< if (myForwardIndex != null) { return myForwardIndex.getDiffBuilder(inputId); } - return new EmptyInputDataDiffBuilder(inputId); + return new EmptyInputDataDiffBuilder<>(inputId); } @NotNull protected UpdateData createUpdateData(@NotNull Map data, @NotNull ThrowableComputable, IOException> keys, @NotNull ThrowableRunnable forwardIndexUpdate) { - return new UpdateData(data, keys, myIndexId, forwardIndexUpdate); + return new UpdateData<>(data, keys, myIndexId, forwardIndexUpdate); } @NotNull diff --git a/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java b/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java index 30e305d8e555..dfbb58979ffb 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java +++ b/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java @@ -98,7 +98,7 @@ class ValueContainerImpl extends UpdatableValueContainer implement return myInputIdMapping != null ? myInputIdMapping instanceof THashMap ? ((THashMap)myInputIdMapping).size(): 1 : 0; } - static final ThreadLocal ourDebugIndexInfo = new ThreadLocal(); + static final ThreadLocal ourDebugIndexInfo = new ThreadLocal<>(); @Override public void removeAssociatedValue(int inputId) { @@ -110,8 +110,8 @@ class ValueContainerImpl extends UpdatableValueContainer implement if (valueIterator.getValueAssociationPredicate().contains(inputId)) { if (fileSetObjects == null) { - fileSetObjects = new SmartList(); - valueObjects = new SmartList(); + fileSetObjects = new SmartList<>(); + valueObjects = new SmartList<>(); } else if (DebugAssertions.DEBUG) { LOG.error("Expected only one value per-inputId for " + ourDebugIndexInfo.get(), String.valueOf(fileSetObjects.get(0)), String.valueOf(value)); @@ -410,7 +410,7 @@ class ValueContainerImpl extends UpdatableValueContainer implement THashMap mapping = asMapping(); if (mapping == null) { Value oldMapping = (Value)myInputIdMapping; - myInputIdMapping = mapping = new THashMap(2); + myInputIdMapping = mapping = new THashMap<>(2); mapping.put(oldMapping, myInputIdMappingValue); myInputIdMappingValue = null; } @@ -467,7 +467,7 @@ class ValueContainerImpl extends UpdatableValueContainer implement final int inputId = -valueCount; if (mapping == null && size() > NUMBER_OF_VALUES_THRESHOLD) { // avoid O(NumberOfValues) - mapping = new FileId2ValueMapping(this); + mapping = new FileId2ValueMapping<>(this); } boolean doCompact; diff --git a/platform/util/src/com/intellij/util/indexing/impl/ValueContainerMap.java b/platform/util/src/com/intellij/util/indexing/impl/ValueContainerMap.java index 8489714dccf8..1a8658f68ea1 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/ValueContainerMap.java +++ b/platform/util/src/com/intellij/util/indexing/impl/ValueContainerMap.java @@ -33,7 +33,7 @@ class ValueContainerMap extends PersistentHashMap keyKeyDescriptor, @NotNull DataExternalizer valueExternalizer, boolean keyIsUniqueForIndexedFile) throws IOException { - super(file, keyKeyDescriptor, new ValueContainerExternalizer(valueExternalizer)); + super(file, keyKeyDescriptor, new ValueContainerExternalizer<>(valueExternalizer)); myValueExternalizer = valueExternalizer; myKeyIsUniqueForIndexedFile = keyIsUniqueForIndexedFile; } @@ -81,7 +81,7 @@ class ValueContainerMap extends PersistentHashMap read(@NotNull final DataInput in) throws IOException { - final ValueContainerImpl valueContainer = new ValueContainerImpl(); + final ValueContainerImpl valueContainer = new ValueContainerImpl<>(); valueContainer.readFrom((DataInputStream)in, myValueExternalizer); return valueContainer; diff --git a/platform/util/src/com/intellij/util/io/CachingEnumerator.java b/platform/util/src/com/intellij/util/io/CachingEnumerator.java index cc310e31d863..22b8e12b5964 100644 --- a/platform/util/src/com/intellij/util/io/CachingEnumerator.java +++ b/platform/util/src/com/intellij/util/io/CachingEnumerator.java @@ -42,8 +42,8 @@ public class CachingEnumerator implements DataEnumerator { int probationalSize = 8192; for(int i = 0; i < STRIPE_COUNT; ++i) { - myHashcodeToIdCache[i] = new SLRUMap(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT); - myIdToStringCache[i] = new SLRUMap(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT); + myHashcodeToIdCache[i] = new SLRUMap<>(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT); + myIdToStringCache[i] = new SLRUMap<>(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT); myStripeLocks[i] = new ReentrantLock(); } diff --git a/platform/util/src/com/intellij/util/io/CompressedAppendableFile.java b/platform/util/src/com/intellij/util/io/CompressedAppendableFile.java index ae5efcb554fd..48c9f09d2aaf 100644 --- a/platform/util/src/com/intellij/util/io/CompressedAppendableFile.java +++ b/platform/util/src/com/intellij/util/io/CompressedAppendableFile.java @@ -495,7 +495,7 @@ public class CompressedAppendableFile { } private static class FileChunkReadCache extends SLRUMap, byte[]> { - private final FileChunkKey myKey = new FileChunkKey(null, 0); + private final FileChunkKey myKey = new FileChunkKey<>(null, 0); FileChunkReadCache() { super(64, 64); diff --git a/platform/util/src/com/intellij/util/io/FileAccessorCache.java b/platform/util/src/com/intellij/util/io/FileAccessorCache.java index a0ec902d8d87..45ffeaa2df4b 100644 --- a/platform/util/src/com/intellij/util/io/FileAccessorCache.java +++ b/platform/util/src/com/intellij/util/io/FileAccessorCache.java @@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger; public abstract class FileAccessorCache implements com.intellij.util.containers.hash.EqualityPolicy { /*@GuardedBy("myCacheLock")*/ private final SLRUMap> myCache; - /*@GuardedBy("myCacheLock")*/ private final List myElementsToBeDisposed = new ArrayList(); + /*@GuardedBy("myCacheLock")*/ private final List myElementsToBeDisposed = new ArrayList<>(); private final Object myCacheLock = new Object(); private final Object myUpdateLock = new Object(); @@ -58,7 +58,7 @@ public abstract class FileAccessorCache implements com.intellij.util.conta @NotNull private Handle createHandle(K key) { try { - Handle cached = new Handle(createAccessor(key), this); + Handle cached = new Handle<>(createAccessor(key), this); cached.allocate(); synchronized (myCacheLock) { @@ -77,7 +77,7 @@ public abstract class FileAccessorCache implements com.intellij.util.conta List fileAccessorsToBeDisposed; synchronized (myCacheLock) { if (myElementsToBeDisposed.isEmpty()) return; - fileAccessorsToBeDisposed = new ArrayList(myElementsToBeDisposed); + fileAccessorsToBeDisposed = new ArrayList<>(myElementsToBeDisposed); myElementsToBeDisposed.clear(); } diff --git a/platform/util/src/com/intellij/util/io/FileChunkKey.java b/platform/util/src/com/intellij/util/io/FileChunkKey.java index c251a281cace..7a76966a98bf 100644 --- a/platform/util/src/com/intellij/util/io/FileChunkKey.java +++ b/platform/util/src/com/intellij/util/io/FileChunkKey.java @@ -62,6 +62,6 @@ class FileChunkKey implements Comparable>, Sh @Override public ShareableKey getStableCopy() { - return new FileChunkKey(owner, offset); + return new FileChunkKey<>(owner, offset); } } diff --git a/platform/util/src/com/intellij/util/io/IOUtil.java b/platform/util/src/com/intellij/util/io/IOUtil.java index c2c2d29e5a21..38ad6783bd4e 100644 --- a/platform/util/src/com/intellij/util/io/IOUtil.java +++ b/platform/util/src/com/intellij/util/io/IOUtil.java @@ -240,7 +240,7 @@ public class IOUtil { @NotNull public static List readStringList(@NotNull DataInput in) throws IOException { int size = DataInputOutputUtil.readINT(in); - List strings = new ArrayList(size); + List strings = new ArrayList<>(size); for (int i = 0; i < size; i++) { strings.add(readUTF(in)); } diff --git a/platform/util/src/com/intellij/util/io/OpenChannelsCache.java b/platform/util/src/com/intellij/util/io/OpenChannelsCache.java index 280f04b23a26..30250dc308a0 100644 --- a/platform/util/src/com/intellij/util/io/OpenChannelsCache.java +++ b/platform/util/src/com/intellij/util/io/OpenChannelsCache.java @@ -38,7 +38,7 @@ public class OpenChannelsCache { // TODO: Will it make sense to have a backgroun public OpenChannelsCache(final int cacheSizeLimit, @NonNls String accessMode) { myCacheSizeLimit = cacheSizeLimit; myAccessMode = accessMode; - myCache = new LinkedHashMap(cacheSizeLimit, 0.5f, true); + myCache = new LinkedHashMap<>(cacheSizeLimit, 0.5f, true); } public synchronized RandomAccessFile getChannel(File ioFile) throws FileNotFoundException { @@ -56,7 +56,7 @@ public class OpenChannelsCache { // TODO: Will it make sense to have a backgroun int dropCount = myCache.size() - myCacheSizeLimit; if (dropCount >= 0) { - List keysToDrop = new ArrayList(); + List keysToDrop = new ArrayList<>(); for (Map.Entry entry : myCache.entrySet()) { if (dropCount < 0) break; if (!entry.getValue().isLocked()) { diff --git a/platform/util/src/com/intellij/util/io/Page.java b/platform/util/src/com/intellij/util/io/Page.java index a4a3d37c11d7..395c269aec0d 100644 --- a/platform/util/src/com/intellij/util/io/Page.java +++ b/platform/util/src/com/intellij/util/io/Page.java @@ -30,7 +30,7 @@ import java.util.BitSet; public class Page { public static final int PAGE_SIZE = SystemProperties.getIntProperty("idea.io.page.size", 8 * 1024); - private static final LimitedPool ourBufferPool = new LimitedPool(10, new LimitedPool.ObjectFactory() { + private static final LimitedPool ourBufferPool = new LimitedPool<>(10, new LimitedPool.ObjectFactory() { @NotNull @Override public ByteBuffer create() { diff --git a/platform/util/src/com/intellij/util/io/PagePool.java b/platform/util/src/com/intellij/util/io/PagePool.java index 6e5bb335c897..c21f158c411a 100644 --- a/platform/util/src/com/intellij/util/io/PagePool.java +++ b/platform/util/src/com/intellij/util/io/PagePool.java @@ -37,7 +37,7 @@ public class PagePool { private int finalizationId = 0; - private final TreeMap myFinalizationQueue = new TreeMap(); + private final TreeMap myFinalizationQueue = new TreeMap<>(); private final Object lock = new Object(); private final Object finalizationMonitor = new Object(); diff --git a/platform/util/src/com/intellij/util/io/PagedFileStorage.java b/platform/util/src/com/intellij/util/io/PagedFileStorage.java index 0aa498b94de4..0f812f49b48b 100644 --- a/platform/util/src/com/intellij/util/io/PagedFileStorage.java +++ b/platform/util/src/com/intellij/util/io/PagedFileStorage.java @@ -493,7 +493,7 @@ public class PagedFileStorage implements Forceable { // todo avoid locking for access private final ReentrantLock mySegmentsAllocationLock = new ReentrantLock(); - private final ConcurrentLinkedQueue mySegmentsToRemove = new ConcurrentLinkedQueue(); + private final ConcurrentLinkedQueue mySegmentsToRemove = new ConcurrentLinkedQueue<>(); private volatile long mySize; private volatile long mySizeLimit; private volatile int myMappingChangeCount; @@ -708,7 +708,7 @@ public class PagedFileStorage implements Forceable { for (Map.Entry entry : mySegments.entrySet()) { if ((entry.getKey() & FILE_INDEX_MASK) == index) { if (mineBuffers == null) { - mineBuffers = new TreeMap(new Comparator() { + mineBuffers = new TreeMap<>(new Comparator() { @Override public int compare(Integer o1, Integer o2) { return o1 - o2; diff --git a/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java b/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java index 55f10486a52f..f4f3160b575f 100644 --- a/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java +++ b/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java @@ -133,7 +133,7 @@ public abstract class PersistentEnumeratorBase implements Forceable, Close ENUMERATION_CACHE_SIZE = property == null ? 8192 : Integer.valueOf(property); } - private static final SLRUMap ourEnumerationCache = new SLRUMap(ENUMERATION_CACHE_SIZE, ENUMERATION_CACHE_SIZE); + private static final SLRUMap ourEnumerationCache = new SLRUMap<>(ENUMERATION_CACHE_SIZE, ENUMERATION_CACHE_SIZE); @TestOnly public static void clearCacheForTests() { @@ -372,8 +372,8 @@ public abstract class PersistentEnumeratorBase implements Forceable, Close @NotNull public Collection getAllDataObjects(@Nullable final DataFilter filter) throws IOException { - final List values = new ArrayList(); - processAllDataObject(new CommonProcessors.CollectProcessor(values), filter); + final List values = new ArrayList<>(); + processAllDataObject(new CommonProcessors.CollectProcessor<>(values), filter); return values; } diff --git a/platform/util/src/com/intellij/util/io/PersistentEnumeratorDelegate.java b/platform/util/src/com/intellij/util/io/PersistentEnumeratorDelegate.java index 1386f626c772..1f4c23522758 100644 --- a/platform/util/src/com/intellij/util/io/PersistentEnumeratorDelegate.java +++ b/platform/util/src/com/intellij/util/io/PersistentEnumeratorDelegate.java @@ -35,8 +35,8 @@ public class PersistentEnumeratorDelegate implements Closeable, Forceable @NotNull KeyDescriptor dataDescriptor, final int initialSize, @Nullable PagedFileStorage.StorageLockContext lockContext) throws IOException { - myEnumerator = useBtree() ? new PersistentBTreeEnumerator(file, dataDescriptor, initialSize, lockContext) : - new PersistentEnumerator(file, dataDescriptor, initialSize); + myEnumerator = useBtree() ? new PersistentBTreeEnumerator<>(file, dataDescriptor, initialSize, lockContext) : + new PersistentEnumerator<>(file, dataDescriptor, initialSize); } public PersistentEnumeratorDelegate(@NotNull final File file, @@ -44,8 +44,8 @@ public class PersistentEnumeratorDelegate implements Closeable, Forceable final int initialSize, @Nullable PagedFileStorage.StorageLockContext lockContext, int version) throws IOException { - myEnumerator = useBtree() ? new PersistentBTreeEnumerator(file, dataDescriptor, initialSize, lockContext, version) : - new PersistentEnumerator(file, dataDescriptor, initialSize, null, version); + myEnumerator = useBtree() ? new PersistentBTreeEnumerator<>(file, dataDescriptor, initialSize, lockContext, version) : + new PersistentEnumerator<>(file, dataDescriptor, initialSize, null, version); } static boolean useBtree() { diff --git a/platform/util/src/com/intellij/util/io/PersistentHashMap.java b/platform/util/src/com/intellij/util/io/PersistentHashMap.java index 44d069f0520c..72205afd6ec5 100644 --- a/platform/util/src/com/intellij/util/io/PersistentHashMap.java +++ b/platform/util/src/com/intellij/util/io/PersistentHashMap.java @@ -101,7 +101,7 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< } private final LimitedPool myStreamPool = - new LimitedPool(10, new LimitedPool.ObjectFactory() { + new LimitedPool<>(10, new LimitedPool.ObjectFactory() { @Override @NotNull public BufferExposingByteArrayOutputStream create() { @@ -520,8 +520,8 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< @NotNull public Collection getAllKeysWithExistingMapping() throws IOException { - final List values = new ArrayList(); - processKeysWithExistingMapping(new CommonProcessors.CollectProcessor(values)); + final List values = new ArrayList<>(); + processKeysWithExistingMapping(new CommonProcessors.CollectProcessor<>(values)); return values; } @@ -884,7 +884,7 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< private void newCompact(@NotNull PersistentHashMapValueStorage newStorage) throws IOException { long started = System.currentTimeMillis(); - final List infos = new ArrayList(10000); + final List infos = new ArrayList<>(10000); traverseAllRecords(new PersistentEnumerator.RecordsProcessor() { @Override diff --git a/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java b/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java index 020b8f8d9d62..c872cdd255a4 100644 --- a/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java +++ b/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java @@ -57,10 +57,10 @@ public class PersistentHashMapValueStorage { public static class CreationTimeOptions { public static final ThreadLocal EXCEPTIONAL_IO_CANCELLATION = - new ThreadLocal(); - public static final ThreadLocal READONLY = new ThreadLocal(); - public static final ThreadLocal COMPACT_CHUNKS_WITH_VALUE_DESERIALIZATION = new ThreadLocal(); - public static final ThreadLocal HAS_NO_CHUNKS = new ThreadLocal(); + new ThreadLocal<>(); + public static final ThreadLocal READONLY = new ThreadLocal<>(); + public static final ThreadLocal COMPACT_CHUNKS_WITH_VALUE_DESERIALIZATION = new ThreadLocal<>(); + public static final ThreadLocal HAS_NO_CHUNKS = new ThreadLocal<>(); static final ThreadLocal DO_COMPRESSION = new ThreadLocal() { @Override @@ -351,7 +351,7 @@ public class PersistentHashMapValueStorage { return compactValuesWithoutChunks(infos, storage); } - PriorityQueue records = new PriorityQueue( + PriorityQueue records = new PriorityQueue<>( infos.size(), new Comparator() { @Override public int compare(PersistentHashMap.CompactionRecordInfo info, PersistentHashMap.CompactionRecordInfo info2) { diff --git a/platform/util/src/com/intellij/util/io/PersistentStringEnumerator.java b/platform/util/src/com/intellij/util/io/PersistentStringEnumerator.java index 666fc943d291..b0ac428b752f 100644 --- a/platform/util/src/com/intellij/util/io/PersistentStringEnumerator.java +++ b/platform/util/src/com/intellij/util/io/PersistentStringEnumerator.java @@ -51,7 +51,7 @@ public class PersistentStringEnumerator extends PersistentEnumeratorDelegate(new DataEnumerator() { + myCache = cacheLastMappings ? new CachingEnumerator<>(new DataEnumerator() { @Override public int enumerate(@Nullable String value) throws IOException { return PersistentStringEnumerator.super.enumerate(value); diff --git a/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java b/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java index 145fcfea4051..cbe578a1f948 100644 --- a/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java +++ b/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java @@ -34,7 +34,7 @@ public class HeavyProcessLatch { private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.storage.HeavyProcessLatch"); public static final HeavyProcessLatch INSTANCE = new HeavyProcessLatch(); - private final Set myHeavyProcesses = new THashSet(); + private final Set myHeavyProcesses = new THashSet<>(); private final EventDispatcher myEventDispatcher = EventDispatcher.create(HeavyProcessListener.class); private final EventDispatcher myUIProcessDispatcher = EventDispatcher.create(HeavyProcessListener.class); @@ -46,7 +46,7 @@ public class HeavyProcessLatch { private static final int MAX_PRIORITIZATION_MILLIS = 12 * 1000; private volatile long myPrioritizingStarted; - private final List toExecuteOutOfHeavyActivity = new ArrayList(); + private final List toExecuteOutOfHeavyActivity = new ArrayList<>(); private HeavyProcessLatch() { } @@ -76,7 +76,7 @@ public class HeavyProcessLatch { toRunNow = Collections.emptyList(); } else { - toRunNow = new ArrayList(toExecuteOutOfHeavyActivity); + toRunNow = new ArrayList<>(toExecuteOutOfHeavyActivity); toExecuteOutOfHeavyActivity.clear(); } } diff --git a/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java b/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java index e2ec4c10cbd2..f5edc7ec66a6 100644 --- a/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java +++ b/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java @@ -46,7 +46,7 @@ public class RefCountingStorage extends AbstractStorage { @NotNull protected ExecutorService createExecutor() { - return new ThreadPoolExecutor(1, 1, Long.MAX_VALUE, TimeUnit.DAYS, new LinkedBlockingQueue(), ConcurrencyUtil + return new ThreadPoolExecutor(1, 1, Long.MAX_VALUE, TimeUnit.DAYS, new LinkedBlockingQueue<>(), ConcurrencyUtil .newNamedThreadFactory("RefCountingStorage write content helper")); } diff --git a/platform/util/src/com/intellij/util/io/zip/JBZipFile.java b/platform/util/src/com/intellij/util/io/zip/JBZipFile.java index 1923ff91d6fa..c32cad9aeab6 100644 --- a/platform/util/src/com/intellij/util/io/zip/JBZipFile.java +++ b/platform/util/src/com/intellij/util/io/zip/JBZipFile.java @@ -49,12 +49,12 @@ public class JBZipFile implements Closeable { /** * A list of entries in the file. */ - private final List entries = new ArrayList(HASH_SIZE); + private final List entries = new ArrayList<>(HASH_SIZE); /** * A map of entry names. */ - private final Map nameMap = new HashMap(HASH_SIZE); + private final Map nameMap = new HashMap<>(HASH_SIZE); /** * The encoding to use for filenames and the file comment @@ -438,7 +438,7 @@ public class JBZipFile implements Closeable { if (myOutputStream != null) { myOutputStream = null; - final Map existingEntries = new LinkedHashMap(); + final Map existingEntries = new LinkedHashMap<>(); for (JBZipEntry entry : entries) { existingEntries.put(entry, entry.getData()); } diff --git a/platform/util/src/com/intellij/util/io/zip/ReorderJarsMain.java b/platform/util/src/com/intellij/util/io/zip/ReorderJarsMain.java index ee5a726a078f..c2f348e7303f 100644 --- a/platform/util/src/com/intellij/util/io/zip/ReorderJarsMain.java +++ b/platform/util/src/com/intellij/util/io/zip/ReorderJarsMain.java @@ -102,13 +102,13 @@ public class ReorderJarsMain { private static Set loadIgnoredJars(String libPath) throws IOException { final File ignoredJarsFile = new File(libPath, "required_for_dist.txt"); - final Set ignoredJars = new HashSet(); + final Set ignoredJars = new HashSet<>(); ContainerUtil.addAll(ignoredJars, FileUtil.loadFile(ignoredJarsFile).split("\r\n")); return ignoredJars; } private static Map> getOrder(final File loadingFile) throws IOException { - final Map> entriesOrder = new HashMap>(); + final Map> entriesOrder = new HashMap<>(); final String[] lines = FileUtil.loadFile(loadingFile).split("\n"); for (String line : lines) { line = line.trim(); @@ -118,7 +118,7 @@ public class ReorderJarsMain { final String jarUrl = line.substring(i + 1); List entries = entriesOrder.get(jarUrl); if (entries == null) { - entries = new ArrayList(); + entries = new ArrayList<>(); entriesOrder.put(jarUrl, entries); } entries.add(entry); diff --git a/platform/util/src/com/intellij/util/keyFMap/KeyFMapRenderer.java b/platform/util/src/com/intellij/util/keyFMap/KeyFMapRenderer.java index b5fdc3e4afb7..3661ea1a8255 100644 --- a/platform/util/src/com/intellij/util/keyFMap/KeyFMapRenderer.java +++ b/platform/util/src/com/intellij/util/keyFMap/KeyFMapRenderer.java @@ -14,7 +14,7 @@ class KeyFMapRenderer { Map.Entry[] res = new Map.Entry[length]; for (int i = 0; i < length; i++) { Key key = keys[i]; - res[i] = new AbstractMap.SimpleImmutableEntry(key, map.get(key)); + res[i] = new AbstractMap.SimpleImmutableEntry<>(key, map.get(key)); } return res; } diff --git a/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java b/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java index 6cbb6756cb61..c1daaf3a64fb 100644 --- a/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java +++ b/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java @@ -44,7 +44,7 @@ public class CompoundRuntimeException extends RuntimeException { } public List getExceptions() { - return new ArrayList(myExceptions); + return new ArrayList<>(myExceptions); } @Override diff --git a/platform/util/src/com/intellij/util/lang/JavaVersion.java b/platform/util/src/com/intellij/util/lang/JavaVersion.java index c33fcf21018b..04ae46b6a533 100644 --- a/platform/util/src/com/intellij/util/lang/JavaVersion.java +++ b/platform/util/src/com/intellij/util/lang/JavaVersion.java @@ -198,8 +198,8 @@ public final class JavaVersion implements Comparable { } // partitioning - List separators = new ArrayList(); - List numbers = new ArrayList(); + List separators = new ArrayList<>(); + List numbers = new ArrayList<>(); int length = str.length(), p = 0; boolean number = false; while (p < length) { diff --git a/platform/util/src/com/intellij/util/loader/LoadedResourcesDumper.java b/platform/util/src/com/intellij/util/loader/LoadedResourcesDumper.java index 86e0f61561bd..ddefdedecfd3 100644 --- a/platform/util/src/com/intellij/util/loader/LoadedResourcesDumper.java +++ b/platform/util/src/com/intellij/util/loader/LoadedResourcesDumper.java @@ -25,7 +25,7 @@ import java.util.Set; public class LoadedResourcesDumper implements ClassPath.ResourceLoadingLogger { private PrintStream myOrder; private long myOrderSize; - private final Set myOrderedUrls = new HashSet(); + private final Set myOrderedUrls = new HashSet<>(); @SuppressWarnings("UseOfSystemOutOrSystemErr") @Override diff --git a/platform/util/src/com/intellij/util/messages/MessageBusFactory.java b/platform/util/src/com/intellij/util/messages/MessageBusFactory.java index 54496579bfca..17c23bb774a4 100644 --- a/platform/util/src/com/intellij/util/messages/MessageBusFactory.java +++ b/platform/util/src/com/intellij/util/messages/MessageBusFactory.java @@ -27,7 +27,7 @@ import java.util.concurrent.atomic.AtomicReference; public class MessageBusFactory { - private static final AtomicReference ourImpl = new AtomicReference(Impl.DEFAULT); + private static final AtomicReference ourImpl = new AtomicReference<>(Impl.DEFAULT); private MessageBusFactory() {} diff --git a/platform/util/src/com/intellij/util/messages/Topic.java b/platform/util/src/com/intellij/util/messages/Topic.java index 439483fd0f44..1b7eb1f543b1 100644 --- a/platform/util/src/com/intellij/util/messages/Topic.java +++ b/platform/util/src/com/intellij/util/messages/Topic.java @@ -59,12 +59,12 @@ public class Topic { @NotNull public static Topic create(@NonNls @NotNull String displayName, @NotNull Class listenerClass) { - return new Topic(displayName, listenerClass); + return new Topic<>(displayName, listenerClass); } @NotNull public static Topic create(@NonNls @NotNull String displayName, @NotNull Class listenerClass, BroadcastDirection direction) { - return new Topic(displayName, listenerClass, direction); + return new Topic<>(displayName, listenerClass, direction); } /** diff --git a/platform/util/src/com/intellij/util/messages/impl/MessageBusImpl.java b/platform/util/src/com/intellij/util/messages/impl/MessageBusImpl.java index 2a4760a541d4..df2e8f9ddd81 100644 --- a/platform/util/src/com/intellij/util/messages/impl/MessageBusImpl.java +++ b/platform/util/src/com/intellij/util/messages/impl/MessageBusImpl.java @@ -75,7 +75,7 @@ public class MessageBusImpl implements MessageBus { private MessageBusImpl(Object owner) { myOwner = owner + " of " + owner.getClass(); myConnectionDisposable = Disposer.newDisposable(myOwner); - myOrder = new ArrayList(); + myOrder = new ArrayList<>(); } @Override @@ -128,7 +128,7 @@ public class MessageBusImpl implements MessageBus { if (lastChildIndex == Integer.MAX_VALUE) { LOG.error("Too many child buses"); } - List childOrder = new ArrayList(myOrder.size() + 1); + List childOrder = new ArrayList<>(myOrder.size() + 1); childOrder.addAll(myOrder); childOrder.add(lastChildIndex + 1); childBus.myOrder = childOrder; @@ -290,7 +290,7 @@ public class MessageBusImpl implements MessageBus { private List getTopicSubscribers(Topic topic) { List topicSubscribers = mySubscriberCache.get(topic); if (topicSubscribers == null) { - topicSubscribers = new SmartList(); + topicSubscribers = new SmartList<>(); calcSubscribers(topic, topicSubscribers); mySubscriberCache.put(topic, topicSubscribers); } @@ -301,7 +301,7 @@ public class MessageBusImpl implements MessageBus { ThreadLocal> ref = getRootBus().myWaitingBuses; SortedMap map = ref.get(); if (map == null) { - ref.set(map = new TreeMap(MESSAGE_BUS_COMPARATOR)); + ref.set(map = new TreeMap<>(MESSAGE_BUS_COMPARATOR)); } Integer countObject = map.get(this); int count = countObject == null ? 0 : countObject; @@ -337,7 +337,7 @@ public class MessageBusImpl implements MessageBus { for (MessageBusImpl bus : map.keySet()) { if (ensureAlive(map, bus)) { if (liveBuses == null) { - liveBuses = new SmartList(); + liveBuses = new SmartList<>(); } liveBuses.add(bus); } @@ -362,7 +362,7 @@ public class MessageBusImpl implements MessageBus { private static List appendExceptions(List exceptions, List busExceptions) { if (!busExceptions.isEmpty()) { - if (exceptions == null) exceptions = new SmartList(); + if (exceptions == null) exceptions = new SmartList<>(); exceptions.addAll(busExceptions); } return exceptions; @@ -398,7 +398,7 @@ public class MessageBusImpl implements MessageBus { } catch (Throwable e) { if (exceptions == null) { - exceptions = new SmartList(); + exceptions = new SmartList<>(); } exceptions.add(e); } @@ -456,7 +456,7 @@ public class MessageBusImpl implements MessageBus { return new ThreadLocal>() { @Override protected Queue initialValue() { - return new ConcurrentLinkedQueue(); + return new ConcurrentLinkedQueue<>(); } }; } @@ -469,7 +469,7 @@ public class MessageBusImpl implements MessageBus { *

* Used to avoid traversing the whole hierarchy when there are no messages to be sent in most of it */ - private final ThreadLocal> myWaitingBuses = new ThreadLocal>(); + private final ThreadLocal> myWaitingBuses = new ThreadLocal<>(); public RootBus(@NotNull Object owner) { super(owner); diff --git a/platform/util/src/com/intellij/util/ref/DebugReflectionUtil.java b/platform/util/src/com/intellij/util/ref/DebugReflectionUtil.java index d261e2205fe6..1413a3667ec3 100644 --- a/platform/util/src/com/intellij/util/ref/DebugReflectionUtil.java +++ b/platform/util/src/com/intellij/util/ref/DebugReflectionUtil.java @@ -42,7 +42,7 @@ import java.util.List; import java.util.Map; public class DebugReflectionUtil { - private static final Map allFields = new THashMap(new TObjectHashingStrategy() { + private static final Map allFields = new THashMap<>(new TObjectHashingStrategy() { // default strategy seems to be too slow @Override public int computeHashCode(Class aClass) { @@ -63,7 +63,7 @@ public class DebugReflectionUtil { if (cached == null) { try { Field[] declaredFields = aClass.getDeclaredFields(); - List fields = new ArrayList(declaredFields.length + 5); + List fields = new ArrayList<>(declaredFields.length + 5); for (Field declaredField : declaredFields) { declaredField.setAccessible(true); Class type = declaredField.getType(); @@ -130,7 +130,7 @@ public class DebugReflectionUtil { @NotNull Condition shouldExamineValue, @NotNull final PairProcessor leakProcessor) { TIntHashSet visited = new TIntHashSet(100); - Queue toVisit = new Queue(100); + Queue toVisit = new Queue<>(100); for (Map.Entry entry : startRoots.entrySet()) { Object startRoot = entry.getKey(); diff --git a/platform/util/src/com/intellij/util/ref/GCUtil.java b/platform/util/src/com/intellij/util/ref/GCUtil.java index 57d294dd46d1..e7c711d3b773 100644 --- a/platform/util/src/com/intellij/util/ref/GCUtil.java +++ b/platform/util/src/com/intellij/util/ref/GCUtil.java @@ -32,9 +32,9 @@ public class GCUtil { @TestOnly public static void tryGcSoftlyReachableObjects() { //long started = System.nanoTime(); - ReferenceQueue q = new ReferenceQueue(); - SoftReference ref = new SoftReference(new Object(), q); - ArrayList> list = new ArrayList>(100 + useReference(ref)); + ReferenceQueue q = new ReferenceQueue<>(); + SoftReference ref = new SoftReference<>(new Object(), q); + ArrayList> list = new ArrayList<>(100 + useReference(ref)); System.gc(); final long freeMemory = Runtime.getRuntime().freeMemory(); diff --git a/platform/util/src/com/intellij/util/text/CharArrayUtil.java b/platform/util/src/com/intellij/util/text/CharArrayUtil.java index d14562f5c075..0640a641e9ed 100644 --- a/platform/util/src/com/intellij/util/text/CharArrayUtil.java +++ b/platform/util/src/com/intellij/util/text/CharArrayUtil.java @@ -464,7 +464,7 @@ public class CharArrayUtil { @NotNull public static TextRange[] getIndents(@NotNull CharSequence charsSequence, int shift) { - List result = new ArrayList(); + List result = new ArrayList<>(); int whitespaceEnd = -1; int lastTextFound = 0; for(int i = charsSequence.length() - 1; i >= 0; i--){ diff --git a/platform/util/src/com/intellij/util/text/LineReader.java b/platform/util/src/com/intellij/util/text/LineReader.java index a29742aebf38..c8332b5722a3 100644 --- a/platform/util/src/com/intellij/util/text/LineReader.java +++ b/platform/util/src/com/intellij/util/text/LineReader.java @@ -35,7 +35,7 @@ public class LineReader { public List readLines() throws IOException { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); byte[] line; while ((line = readLineInternal()) != null) result.add(line); return result; diff --git a/platform/util/src/com/intellij/util/text/MarkdownUtil.java b/platform/util/src/com/intellij/util/text/MarkdownUtil.java index 060303820bd9..2d0e80b4a32b 100644 --- a/platform/util/src/com/intellij/util/text/MarkdownUtil.java +++ b/platform/util/src/com/intellij/util/text/MarkdownUtil.java @@ -63,7 +63,7 @@ public class MarkdownUtil { if (imageEndIndex != -1) { TextRange linkRange = findEnclosingLink(text, i, imageEndIndex); if (intervals == null) { - intervals = new ArrayList(1); + intervals = new ArrayList<>(1); } final TextRange range; if (linkRange != null) { diff --git a/platform/util/src/com/intellij/util/text/TextRangeUtil.java b/platform/util/src/com/intellij/util/text/TextRangeUtil.java index d022f2f7e3b0..f19420b40fe8 100644 --- a/platform/util/src/com/intellij/util/text/TextRangeUtil.java +++ b/platform/util/src/com/intellij/util/text/TextRangeUtil.java @@ -55,7 +55,7 @@ public class TextRangeUtil { Collections.sort(excludedRanges, RANGE_COMPARATOR); } int enabledRangeStart = original.getStartOffset(); - List enabledRanges = new ArrayList(); + List enabledRanges = new ArrayList<>(); for (TextRange excludedRange : excludedRanges) { if (excludedRange.getEndOffset() < enabledRangeStart) continue; int excludedRangeStart = excludedRange.getStartOffset(); diff --git a/platform/util/src/com/intellij/util/text/TextRanges.java b/platform/util/src/com/intellij/util/text/TextRanges.java index 8c3ddc5b55a3..baa4774aa1df 100644 --- a/platform/util/src/com/intellij/util/text/TextRanges.java +++ b/platform/util/src/com/intellij/util/text/TextRanges.java @@ -62,7 +62,7 @@ public class TextRanges implements Iterable { @Override public Iterator iterator() { - return new UnmodifiableIterator(myRanges.iterator()); + return new UnmodifiableIterator<>(myRanges.iterator()); } public Iterator revIterator() { diff --git a/platform/util/src/com/intellij/util/text/UniqueNameGenerator.java b/platform/util/src/com/intellij/util/text/UniqueNameGenerator.java index d200ba140fde..713bf3331bec 100644 --- a/platform/util/src/com/intellij/util/text/UniqueNameGenerator.java +++ b/platform/util/src/com/intellij/util/text/UniqueNameGenerator.java @@ -29,7 +29,7 @@ import java.util.Set; * @author peter */ public class UniqueNameGenerator implements Condition { - private final Set myExistingNames = new THashSet(); + private final Set myExistingNames = new THashSet<>(); public UniqueNameGenerator(@NotNull Collection elements, @Nullable Function namer) { for (T t : elements) { diff --git a/platform/util/src/com/intellij/util/ui/AppleBoldDottedPainter.java b/platform/util/src/com/intellij/util/ui/AppleBoldDottedPainter.java index bd4af246c908..5a4eea2946af 100644 --- a/platform/util/src/com/intellij/util/ui/AppleBoldDottedPainter.java +++ b/platform/util/src/com/intellij/util/ui/AppleBoldDottedPainter.java @@ -34,7 +34,7 @@ public class AppleBoldDottedPainter { private static final int HEIGHT = 3; private static final int WIDTH = 4; - private static final Map myPainters = new HashMap(); + private static final Map myPainters = new HashMap<>(); private static final int PATTERN_WIDTH = 4000; private final BufferedImage myImage; diff --git a/platform/util/src/com/intellij/util/ui/EmptyIcon.java b/platform/util/src/com/intellij/util/ui/EmptyIcon.java index 5c036be2cd62..ab0dc1cca0b8 100644 --- a/platform/util/src/com/intellij/util/ui/EmptyIcon.java +++ b/platform/util/src/com/intellij/util/ui/EmptyIcon.java @@ -24,7 +24,7 @@ import static com.intellij.util.ui.JBUI.ScaleType.PIX_SCALE; * @see ColorIcon */ public class EmptyIcon extends JBUI.CachingScalableJBIcon { - private static final Map, EmptyIcon> cache = new HashMap, EmptyIcon>(); + private static final Map, EmptyIcon> cache = new HashMap<>(); public static final Icon ICON_18 = JBUI.scale(create(18)); public static final Icon ICON_16 = JBUI.scale(create(16)); diff --git a/platform/util/src/com/intellij/util/ui/FontInfo.java b/platform/util/src/com/intellij/util/ui/FontInfo.java index ef2bca8837ad..d7bf05924d5e 100644 --- a/platform/util/src/com/intellij/util/ui/FontInfo.java +++ b/platform/util/src/com/intellij/util/ui/FontInfo.java @@ -115,7 +115,7 @@ public final class FontInfo { private static List byName() { String[] names = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(ENGLISH); - List list = new ArrayList(names.length); + List list = new ArrayList<>(names.length); for (String name : names) { FontInfo info = byName(name); if (info != null) list.add(info); @@ -136,7 +136,7 @@ public final class FontInfo { private static List byFont() { Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); - List list = new ArrayList(fonts.length); + List list = new ArrayList<>(fonts.length); for (Font font : fonts) { FontInfo info = byFont(font); if (info != null) list.add(info); diff --git a/platform/util/src/com/intellij/util/ui/GridBag.java b/platform/util/src/com/intellij/util/ui/GridBag.java index bfa35f55df9f..0eff674e635e 100644 --- a/platform/util/src/com/intellij/util/ui/GridBag.java +++ b/platform/util/src/com/intellij/util/ui/GridBag.java @@ -73,7 +73,7 @@ public class GridBag extends GridBagConstraints { @NotNull private final TIntIntHashMap myDefaultColumnPaddingsY = new TIntIntHashMap(); @Nullable private Insets myDefaultInsets = insets; - @NotNull private final TIntObjectHashMap myDefaultColumnInsets = new TIntObjectHashMap(); + @NotNull private final TIntObjectHashMap myDefaultColumnInsets = new TIntObjectHashMap<>(); public GridBag() { gridx = gridy = -1; diff --git a/platform/util/src/com/intellij/util/ui/JBUI.java b/platform/util/src/com/intellij/util/ui/JBUI.java index 0504661b6587..bffdf830b7a6 100644 --- a/platform/util/src/com/intellij/util/ui/JBUI.java +++ b/platform/util/src/com/intellij/util/ui/JBUI.java @@ -169,7 +169,7 @@ public class JBUI { new ThreadLocal>>() { @Override protected EnumMap> initialValue() { - return new EnumMap>(ScaleType.class); + return new EnumMap<>(ScaleType.class); } }; @@ -178,7 +178,7 @@ public class JBUI { EnumMap> emap = cache.get(); TDoubleObjectHashMap map = emap.get(type); if (map == null) { - emap.put(type, map = new TDoubleObjectHashMap()); + emap.put(type, map = new TDoubleObjectHashMap<>()); } Scale scale = map.get(value); if (scale != null) return scale; @@ -965,7 +965,7 @@ public class JBUI { } public void addUpdateListener(@NotNull UpdateListener l) { - if (listeners == null) listeners = new ArrayList(1); + if (listeners == null) listeners = new ArrayList<>(1); listeners.add(l); } @@ -1012,7 +1012,7 @@ public class JBUI { */ public static class Cache { private final Function myDataProvider; - private final AtomicReference> myData = new AtomicReference>(null); + private final AtomicReference> myData = new AtomicReference<>(null); /** * @param dataProvider provides a data object matching the passed scale context @@ -1097,7 +1097,7 @@ public class JBUI { @NotNull public static ScaleContext create(@Nullable Component comp) { final ScaleContext ctx = new ScaleContext(SYS_SCALE.of(sysScale(comp))); - if (comp != null) ctx.compRef = new WeakReference(comp); + if (comp != null) ctx.compRef = new WeakReference<>(comp); return ctx; } diff --git a/platform/util/src/com/intellij/util/ui/JBValue.java b/platform/util/src/com/intellij/util/ui/JBValue.java index d406e6f9e86e..4a8b3937a636 100644 --- a/platform/util/src/com/intellij/util/ui/JBValue.java +++ b/platform/util/src/com/intellij/util/ui/JBValue.java @@ -130,7 +130,7 @@ public abstract class JBValue { * This can be a better choice when values are used multiple times in a code block. */ public static class JBValueGroup { - private final List group = new LinkedList(); + private final List group = new LinkedList<>(); private final PropertyChangeListener listener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { diff --git a/platform/util/src/com/intellij/util/ui/Layers.java b/platform/util/src/com/intellij/util/ui/Layers.java index 447c85f971e2..d8166378358e 100644 --- a/platform/util/src/com/intellij/util/ui/Layers.java +++ b/platform/util/src/com/intellij/util/ui/Layers.java @@ -23,7 +23,7 @@ import java.util.ArrayList; public class Layers extends JLayeredPane { - private final ArrayList myComponents = new ArrayList(); + private final ArrayList myComponents = new ArrayList<>(); public Layers() { setLayout(new Layout()); diff --git a/platform/util/src/com/intellij/util/ui/ListTableModel.java b/platform/util/src/com/intellij/util/ui/ListTableModel.java index 6edb46322bde..4b73171d5219 100644 --- a/platform/util/src/com/intellij/util/ui/ListTableModel.java +++ b/platform/util/src/com/intellij/util/ui/ListTableModel.java @@ -31,7 +31,7 @@ public class ListTableModel extends TableViewModel implements Editab private SortOrder mySortOrder = SortOrder.ASCENDING; public ListTableModel(@NotNull ColumnInfo... columnInfos) { - this(columnInfos, new ArrayList(), 0, SortOrder.ASCENDING); + this(columnInfos, new ArrayList<>(), 0, SortOrder.ASCENDING); } public ListTableModel(@NotNull ColumnInfo[] columnNames, @NotNull List items, int selectedColumn) { diff --git a/platform/util/src/com/intellij/util/ui/RadioButtonEnumModel.java b/platform/util/src/com/intellij/util/ui/RadioButtonEnumModel.java index c5d668c7dcb7..68ad9b2f7975 100644 --- a/platform/util/src/com/intellij/util/ui/RadioButtonEnumModel.java +++ b/platform/util/src/com/intellij/util/ui/RadioButtonEnumModel.java @@ -34,7 +34,7 @@ public class RadioButtonEnumModel> { private final List myEnums; public static > RadioButtonEnumModel bindEnum(Class e, ButtonGroup group) { - return new RadioButtonEnumModel(e, group); + return new RadioButtonEnumModel<>(e, group); } private RadioButtonEnumModel(Class e, ButtonGroup group) { diff --git a/platform/util/src/com/intellij/util/ui/SplitBySeparatorPolicy.java b/platform/util/src/com/intellij/util/ui/SplitBySeparatorPolicy.java index 6dd9bed5ee6e..8003f4202c1c 100644 --- a/platform/util/src/com/intellij/util/ui/SplitBySeparatorPolicy.java +++ b/platform/util/src/com/intellij/util/ui/SplitBySeparatorPolicy.java @@ -35,8 +35,8 @@ public class SplitBySeparatorPolicy extends FilePathSplittingPolicy { int currentLength = 0; - List end = new ArrayList(); - List begin = new ArrayList(); + List end = new ArrayList<>(); + List begin = new ArrayList<>(); int size = components.size(); int mult = 1; @@ -76,7 +76,7 @@ public class SplitBySeparatorPolicy extends FilePathSplittingPolicy { } private static ArrayList getComponents(File file) { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); File current = file; while (current != null) { result.add(getFileName(current)); diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index a9e199d059cd..5efc671202e3 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -497,7 +497,7 @@ public class UIUtil { } // accessed from com.intellij.util.ui.TestScaleHelper via reflect - private static final AtomicReference jreHiDPI = new AtomicReference(); + private static final AtomicReference jreHiDPI = new AtomicReference<>(); private static volatile boolean jreHiDPI_earlierVersion; @TestOnly @@ -957,7 +957,7 @@ public class UIUtil { @NotNull public static String[] splitText(@NotNull String text, @NotNull FontMetrics fontMetrics, int widthLimit, char separator) { - ArrayList lines = new ArrayList(); + ArrayList lines = new ArrayList<>(); String currentLine = ""; StringBuilder currentAtom = new StringBuilder(); @@ -1044,7 +1044,7 @@ public class UIUtil { return defColor; } - private static final Map> ourDefaultIconMethodsCache = new ConcurrentHashMap>(); + private static final Map> ourDefaultIconMethodsCache = new ConcurrentHashMap<>(); public static int getCheckBoxTextHorizontalOffset(@NotNull JCheckBox cb) { // logic copied from javax.swing.plaf.basic.BasicRadioButtonUI.paint ButtonUI ui = cb.getUI(); @@ -1708,7 +1708,7 @@ public class UIUtil { @NotNull public static String[] getValidFontNames(final boolean familyName) { - Set result = new TreeSet(); + Set result = new TreeSet<>(); // adds fonts that can display symbols at [A, Z] + [a, z] + [0, 9] for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) { @@ -2409,7 +2409,7 @@ public class UIUtil { @TestOnly public static void pump() { assert !SwingUtilities.isEventDispatchThread(); - final BlockingQueue queue = new LinkedBlockingQueue(); + final BlockingQueue queue = new LinkedBlockingQueue<>(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { @@ -3598,7 +3598,7 @@ public class UIUtil { @NotNull public static List findComponentsOfType(JComponent parent, @NotNull Class cls) { - final ArrayList result = new ArrayList(); + final ArrayList result = new ArrayList<>(); findComponentsOfType(parent, cls, result); return result; } @@ -3617,7 +3617,7 @@ public class UIUtil { } public static class TextPainter { - private final List> myLines = new ArrayList>(); + private final List> myLines = new ArrayList<>(); private boolean myDrawShadow; private Color myShadowColor; private float myLineSpacing; @@ -3883,7 +3883,7 @@ public class UIUtil { } public static void setFutureRootPane(@NotNull JComponent c, @NotNull JRootPane pane) { - c.putClientProperty(ROOT_PANE, new WeakReference(pane)); + c.putClientProperty(ROOT_PANE, new WeakReference<>(pane)); } public static boolean isMeaninglessFocusOwner(@Nullable Component c) { @@ -4305,7 +4305,7 @@ public class UIUtil { graphics.setFont(new Font(family, Font.PLAIN, patternSize)); if (graphics.getFontMetrics().getStringBounds(pattern, graphics).equals(patternBounds)) { if (ourRealFontFamilies == null) { - ourRealFontFamilies = new HashMap(); + ourRealFontFamilies = new HashMap<>(); } ourRealFontFamilies.put(genericFontFamily, family); return family; @@ -4546,7 +4546,7 @@ public class UIUtil { Window c1Ancestor = findWindowAncestor(c1); Window c2Ancestor = findWindowAncestor(c2); - Set ownerSet = new HashSet(); + Set ownerSet = new HashSet<>(); Window owner = c1Ancestor; diff --git a/platform/util/src/com/intellij/util/ui/WavePainter2D.java b/platform/util/src/com/intellij/util/ui/WavePainter2D.java index a30c58eff834..d63b9af036ab 100644 --- a/platform/util/src/com/intellij/util/ui/WavePainter2D.java +++ b/platform/util/src/com/intellij/util/ui/WavePainter2D.java @@ -16,7 +16,7 @@ import java.util.Map; public class WavePainter2D extends WavePainter { private static final float STROKE_WIDTH = 0.7f; - private static final Map myPainters = new HashMap(); + private static final Map myPainters = new HashMap<>(); private static final int PATTERN_WIDTH = 4000; private final BufferedImage myImage; diff --git a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java index 27c27e4cfff2..64ec97625f00 100644 --- a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java @@ -77,7 +77,7 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple itemBindings = binding == null ? Collections.emptyList() : Collections.singletonList(binding); } else { - itemBindings = new SmartList(); + itemBindings = new SmartList<>(); if (binding != null) { itemBindings.add(binding); } @@ -116,7 +116,7 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple String tagName = isSurroundWithTag() ? getCollectionTagName(object) : null; if (tagName == null) { - List result = new SmartList(); + List result = new SmartList<>(); if (!ContainerUtil.isEmpty(collection)) { for (Object item : collection) { ContainerUtil.addAllNotNull(result, serializeItem(item, result, filter)); @@ -157,7 +157,7 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple assert elements.size() == 1; Element element = elements.get(0); - return doDeserializeList(context == null && element.getName().equals(Constants.SET) ? new HashSet() : context, element.getChildren()); + return doDeserializeList(context == null && element.getName().equals(Constants.SET) ? new HashSet<>() : context, element.getChildren()); } @NotNull diff --git a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java index 8c85d6cf9557..2b0d1a87ac79 100644 --- a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java @@ -145,7 +145,7 @@ public class BeanBinding extends NotNullDeserializeBinding { @NotNull public final TObjectFloatHashMap computeBindingWeights(@NotNull LinkedHashSet accessorNameTracker) { - TObjectFloatHashMap weights = new TObjectFloatHashMap(accessorNameTracker.size()); + TObjectFloatHashMap weights = new TObjectFloatHashMap<>(accessorNameTracker.size()); float weight = 0; float step = (float)myBindings.length / (float)accessorNameTracker.size(); for (String name : accessorNameTracker) { @@ -287,7 +287,7 @@ public class BeanBinding extends NotNullDeserializeBinding { return accessors; } - accessors = new ArrayList(); + accessors = new ArrayList<>(); Map> nameToAccessors; // special case for Rectangle.class to avoid infinite recursion during serialization due to bounds() method @@ -350,7 +350,7 @@ public class BeanBinding extends NotNullDeserializeBinding { @NotNull private static Map> collectPropertyAccessors(@NotNull Class aClass, @NotNull List accessors) { - final Map> candidates = new TreeMap>(); // (name,(getter,setter)) + final Map> candidates = new TreeMap<>(); // (name,(getter,setter)) for (Method method : aClass.getMethods()) { if (!Modifier.isPublic(method.getModifiers())) { continue; diff --git a/platform/util/src/com/intellij/util/xmlb/JDOMElementBinding.java b/platform/util/src/com/intellij/util/xmlb/JDOMElementBinding.java index 77321e5205c4..14b55398c6b4 100644 --- a/platform/util/src/com/intellij/util/xmlb/JDOMElementBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/JDOMElementBinding.java @@ -35,7 +35,7 @@ class JDOMElementBinding extends NotNullDeserializeBinding implements MultiNodeB return targetElement; } if (value instanceof Element[]) { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); for (Element element : ((Element[])value)) { result.add(element.clone().setName(myTagName)); } diff --git a/platform/util/src/com/intellij/util/xmlb/JDOMXIncluder.java b/platform/util/src/com/intellij/util/xmlb/JDOMXIncluder.java index 0461252eb3ee..9db099947b21 100644 --- a/platform/util/src/com/intellij/util/xmlb/JDOMXIncluder.java +++ b/platform/util/src/com/intellij/util/xmlb/JDOMXIncluder.java @@ -77,7 +77,7 @@ public class JDOMXIncluder { throws XIncludeException, MalformedURLException { LOG.assertTrue(!isIncludeElement(original)); - Stack bases = new Stack(); + Stack bases = new Stack<>(); if (base != null) { bases.push(base); } @@ -201,7 +201,7 @@ public class JDOMXIncluder { @NotNull private List doResolve(@NotNull Element original, URL base) throws XIncludeException, MalformedURLException { - Stack bases = new Stack(); + Stack bases = new Stack<>(); if (base != null) { bases.push(base); } @@ -315,7 +315,7 @@ public class JDOMXIncluder { e = e.getChild(subTagName.substring(1)); } assert e != null; - return new ArrayList(e.getContent()); + return new ArrayList<>(e.getContent()); } @NotNull diff --git a/platform/util/src/com/intellij/util/xmlb/SkipDefaultValuesSerializationFilters.java b/platform/util/src/com/intellij/util/xmlb/SkipDefaultValuesSerializationFilters.java index 7be9d67fef7d..05ac8a805b86 100644 --- a/platform/util/src/com/intellij/util/xmlb/SkipDefaultValuesSerializationFilters.java +++ b/platform/util/src/com/intellij/util/xmlb/SkipDefaultValuesSerializationFilters.java @@ -29,7 +29,7 @@ import java.util.Map; * Please use {@link SkipDefaultsSerializationFilter} if state class doesn't implement "equals" (in Kotlin use data classes {@see http://kotlinlang.org/docs/reference/data-classes.html}) */ public class SkipDefaultValuesSerializationFilters extends SerializationFilterBase { - private final Map, Object> myDefaultBeans = new THashMap, Object>(); + private final Map, Object> myDefaultBeans = new THashMap<>(); public SkipDefaultValuesSerializationFilters() { } diff --git a/platform/util/src/com/intellij/util/xmlb/SmartSerializer.java b/platform/util/src/com/intellij/util/xmlb/SmartSerializer.java index 7dec8d4556e2..b6d855af5d63 100644 --- a/platform/util/src/com/intellij/util/xmlb/SmartSerializer.java +++ b/platform/util/src/com/intellij/util/xmlb/SmartSerializer.java @@ -28,7 +28,7 @@ public final class SmartSerializer { private final SerializationFilter mySerializationFilter; public SmartSerializer(boolean trackSerializedNames, boolean useSkipEmptySerializationFilter) { - mySerializedAccessorNameTracker = trackSerializedNames ? new LinkedHashSet() : null; + mySerializedAccessorNameTracker = trackSerializedNames ? new LinkedHashSet<>() : null; mySerializationFilter = useSkipEmptySerializationFilter ? new SkipEmptySerializationFilter() { diff --git a/platform/util/src/com/intellij/util/xmlb/TagBinding.java b/platform/util/src/com/intellij/util/xmlb/TagBinding.java index 472b77e96b88..bede00363c6a 100644 --- a/platform/util/src/com/intellij/util/xmlb/TagBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/TagBinding.java @@ -55,7 +55,7 @@ class TagBinding extends BasePrimitiveBinding implements MultiNodeBinding { } else { String name = elements.get(0).getName(); - children = new ArrayList(); + children = new ArrayList<>(); for (Element element : elements) { assert element.getName().equals(name); children.addAll(element.getChildren()); diff --git a/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java b/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java index 60478aa39e6d..5dfb3e7e1501 100644 --- a/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java +++ b/platform/util/src/com/intellij/util/xmlb/XmlSerializerImpl.java @@ -97,7 +97,7 @@ public final class XmlSerializerImpl { Map, Binding> map = com.intellij.reference.SoftReference.dereference(ourBindings); if (map == null) { map = ContainerUtil.newConcurrentMap(); - ourBindings = new SoftReference, Binding>>(map); + ourBindings = new SoftReference<>(map); } return map; } diff --git a/platform/util/src/org/jdom/ImmutableElement.java b/platform/util/src/org/jdom/ImmutableElement.java index d04ee8f901f9..3a8ba0af02cd 100644 --- a/platform/util/src/org/jdom/ImmutableElement.java +++ b/platform/util/src/org/jdom/ImmutableElement.java @@ -281,7 +281,7 @@ class ImmutableElement extends Element { // Cloning additional namespaces if (additionalNamespaces != null) { - element.additionalNamespaces = new ArrayList(additionalNamespaces); + element.additionalNamespaces = new ArrayList<>(additionalNamespaces); } // Cloning content diff --git a/platform/util/src/org/jdom/ImmutableSameTypeAttributeList.java b/platform/util/src/org/jdom/ImmutableSameTypeAttributeList.java index ba0cb3ea2a7d..0a67a6cde93b 100644 --- a/platform/util/src/org/jdom/ImmutableSameTypeAttributeList.java +++ b/platform/util/src/org/jdom/ImmutableSameTypeAttributeList.java @@ -115,7 +115,7 @@ class ImmutableSameTypeAttributeList implements List { } private List toList() { - List list = new ArrayList(size()); + List list = new ArrayList<>(size()); for (int i = 0; i < size(); i++) { list.add(get(i)); } diff --git a/platform/util/src/org/jdom/JDOMInterner.java b/platform/util/src/org/jdom/JDOMInterner.java index f8a70d5a83c1..3d8d1a41a6b9 100644 --- a/platform/util/src/org/jdom/JDOMInterner.java +++ b/platform/util/src/org/jdom/JDOMInterner.java @@ -17,7 +17,7 @@ import static com.intellij.openapi.util.JDOMUtil.getAttributes; public class JDOMInterner { private static final Condition IS_ELEMENT = Conditions.instanceOf(Element.class); private final StringInterner myStrings = new StringInterner(); - private final OpenTHashSet myElements = new OpenTHashSet(new TObjectHashingStrategy() { + private final OpenTHashSet myElements = new OpenTHashSet<>(new TObjectHashingStrategy() { @Override public int computeHashCode(Element e) { int result = e.getName().hashCode() * 31; @@ -53,7 +53,7 @@ public class JDOMInterner { } else if (c1 instanceof Element) { if (!(c2 instanceof Element)) return false; - if (!equals((Element)c1,(Element)c2)) return false; + if (!equals((Element)c1, (Element)c2)) return false; } else { throw new RuntimeException(c1.toString()); @@ -97,7 +97,7 @@ public class JDOMInterner { return name.hashCode() * 31 + (value == null ? 0 : value.hashCode()); } - private final OpenTHashSet myTexts = new OpenTHashSet(new TObjectHashingStrategy() { + private final OpenTHashSet myTexts = new OpenTHashSet<>(new TObjectHashingStrategy() { @Override public int computeHashCode(Text object) { return computeTextHashCode(object);