mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ObjectUtils#sentinel introduced
This commit is contained in:
+1
-1
@@ -21,7 +21,7 @@ import java.util.stream.Stream;
|
||||
|
||||
final class DataFlowInstructionVisitor extends StandardInstructionVisitor {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.DataFlowInstructionVisitor");
|
||||
private static final Object ANY_VALUE = new Object();
|
||||
private static final Object ANY_VALUE = ObjectUtils.sentinel("ANY_VALUE");
|
||||
private final Map<NullabilityProblemKind.NullabilityProblem<?>, StateInfo> myStateInfos = new LinkedHashMap<>();
|
||||
private final Set<Instruction> myCCEInstructions = ContainerUtil.newHashSet();
|
||||
private final Map<MethodCallInstruction, Boolean> myFailingCalls = new HashMap<>();
|
||||
|
||||
@@ -235,13 +235,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
}
|
||||
|
||||
private final Map<Object, Runnable> actionsWhenAllDocumentsAreCommitted = new LinkedHashMap<>(); //accessed from EDT only
|
||||
private static final Object PERFORM_ALWAYS_KEY = new Object() {
|
||||
@Override
|
||||
@NonNls
|
||||
public String toString() {
|
||||
return "PERFORM_ALWAYS";
|
||||
}
|
||||
};
|
||||
private static final Object PERFORM_ALWAYS_KEY = ObjectUtils.sentinel("PERFORM_ALWAYS");
|
||||
|
||||
/**
|
||||
* Cancel previously registered action and schedules (new) action to be executed when all documents are committed.
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.AnyPsiChangeListener;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ConcurrentWeakKeySoftValueHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
@@ -257,7 +258,7 @@ public class ResolveCache {
|
||||
return (incompleteCode ? 0 : 1)*2 + (isPoly ? 0 : 1);
|
||||
}
|
||||
|
||||
private static final Object NULL_RESULT = new Object();
|
||||
private static final Object NULL_RESULT = ObjectUtils.sentinel("ResolveCache.NULL_RESULT");
|
||||
private static <TRef extends PsiReference, TResult> void cache(@NotNull TRef ref,
|
||||
@NotNull ConcurrentMap<TRef, TResult> map,
|
||||
TResult result) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.PositionTracker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -42,8 +43,8 @@ import java.util.Set;
|
||||
|
||||
public class LivePreview implements SearchResults.SearchResultsListener, SelectionListener, DocumentListener {
|
||||
private static final Key<Object> IN_SELECTION_KEY = Key.create("LivePreview.IN_SELECTION_KEY");
|
||||
private static final Object IN_SELECTION1 = new Object();
|
||||
private static final Object IN_SELECTION2 = new Object();
|
||||
private static final Object IN_SELECTION1 = ObjectUtils.sentinel("LivePreview.IN_SELECTION1");
|
||||
private static final Object IN_SELECTION2 = ObjectUtils.sentinel("LivePreview.IN_SELECTION2");
|
||||
private static final String EMPTY_STRING_DISPLAY_TEXT = "<Empty string>";
|
||||
|
||||
private boolean myListeningSelection = false;
|
||||
@@ -51,7 +52,7 @@ public class LivePreview implements SearchResults.SearchResultsListener, Selecti
|
||||
private boolean myInSmartUpdate = false;
|
||||
|
||||
private static final Key<Object> MARKER_USED = Key.create("LivePreview.MARKER_USED");
|
||||
private static final Object YES = new Object();
|
||||
private static final Object YES = ObjectUtils.sentinel("LivePreview.YES");
|
||||
private static final Key<Object> SEARCH_MARKER = Key.create("LivePreview.SEARCH_MARKER");
|
||||
|
||||
public static PrintStream ourTestOutput;
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
import com.intellij.ui.CollectionComboBoxModel;
|
||||
import com.intellij.ui.ComboboxWithBrowseButton;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -26,7 +27,7 @@ import java.util.List;
|
||||
* @author lene
|
||||
*/
|
||||
public class ExternalToolsCheckinHandlerFactory extends CheckinHandlerFactory {
|
||||
public static final Object NONE_TOOL = new Object();
|
||||
public static final Object NONE_TOOL = ObjectUtils.sentinel("NONE_TOOL");
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
+3
-6
@@ -30,10 +30,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.PairConsumer;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.Topic;
|
||||
@@ -318,8 +315,8 @@ public class BackgroundTaskUtil {
|
||||
|
||||
|
||||
private static class Helper<T> {
|
||||
private static final Object INITIAL_STATE = new Object();
|
||||
private static final Object SLOW_OPERATION_STATE = new Object();
|
||||
private static final Object INITIAL_STATE = ObjectUtils.sentinel("INITIAL_STATE");
|
||||
private static final Object SLOW_OPERATION_STATE = ObjectUtils.sentinel("SLOW_OPERATION_STATE");
|
||||
|
||||
private final Semaphore mySemaphore = new Semaphore(0);
|
||||
private final AtomicReference<Object> myResultRef = new AtomicReference<>(INITIAL_STATE);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -64,7 +65,7 @@ public interface Computable <T> {
|
||||
*/
|
||||
@Deprecated
|
||||
abstract class NullableCachedComputable<T> implements NullableComputable<T> {
|
||||
private static final Object NULL_VALUE = new Object();
|
||||
private static final Object NULL_VALUE = ObjectUtils.sentinel("NullableCachedComputable.NULL_VALUE");
|
||||
private Object myValue;
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -49,7 +50,7 @@ import java.util.*;
|
||||
@SuppressWarnings("UtilityClassWithoutPrivateConstructor")
|
||||
public class RecursionManager {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.RecursionManager");
|
||||
private static final Object NULL = new Object();
|
||||
private static final Object NULL = ObjectUtils.sentinel("RecursionManager.NULL");
|
||||
private static final ThreadLocal<CalculationStack> ourStack = new ThreadLocal<CalculationStack>() {
|
||||
@Override
|
||||
protected CalculationStack initialValue() {
|
||||
|
||||
@@ -29,7 +29,20 @@ public class ObjectUtils {
|
||||
private ObjectUtils() {
|
||||
}
|
||||
|
||||
public static final Object NULL = new Object();
|
||||
public static final Object NULL = sentinel("ObjectUtils.NULL");
|
||||
|
||||
/**
|
||||
* Creates a new object which could be used as sentinel value (special value to distinguish from any other object). It does not equal
|
||||
* to any other object. Usually should be assigned to the static final field.
|
||||
*
|
||||
* @param name an object name, returned from {@link #toString()} to simplify the debugging or heap dump analysis
|
||||
* (guaranteed to be stored as sentinel object field). If sentinel is assigned to the static final field,
|
||||
* it's recommended to supply that field name (possibly qualified with the class name).
|
||||
* @return a new sentinel object
|
||||
*/
|
||||
public static Object sentinel(final String name) {
|
||||
return new Sentinel(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> T assertNotNull(@Nullable T t) {
|
||||
@@ -117,4 +130,15 @@ public class ObjectUtils {
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
private static class Sentinel {
|
||||
private final String myName;
|
||||
|
||||
public Sentinel(String name) {myName = name;}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class IntKeyWeakValueHashMap<V> implements IntObjectMap<V> {
|
||||
return values().contains(value);
|
||||
}
|
||||
|
||||
private static final Object GCED = new Object();
|
||||
private static final Object GCED = ObjectUtils.sentinel("GCED");
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterable<Entry<V>> entries() {
|
||||
|
||||
@@ -130,7 +130,7 @@ class WeakKeyIntValueHashMap<K> implements ObjectIntMap<K> {
|
||||
throw RefValueHashMap.pointlessContainsValue();
|
||||
}
|
||||
|
||||
private static final Object GCED = new Object();
|
||||
private static final Object GCED = ObjectUtils.sentinel("GCED");
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterable<Entry<K>> entries() {
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ package com.intellij.debugger.streams.resolve;
|
||||
import com.intellij.debugger.streams.trace.TraceElement;
|
||||
import com.intellij.debugger.streams.trace.TraceInfo;
|
||||
import com.intellij.debugger.streams.wrapper.TraceUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -17,7 +18,7 @@ import java.util.Map;
|
||||
* @author Vitaliy.Bibaev
|
||||
*/
|
||||
public class IdentityResolver implements ValuesOrderResolver {
|
||||
private static final Object NULL_MARKER = new Object();
|
||||
private static final Object NULL_MARKER = ObjectUtils.sentinel("IdentityResolver.NULL_MARKER");
|
||||
@NotNull
|
||||
@Override
|
||||
public Result resolve(@NotNull TraceInfo info) {
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.xdebugger.frame.*;
|
||||
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
|
||||
@@ -46,7 +47,7 @@ import java.util.stream.Collectors;
|
||||
public class CollectionTree extends XDebuggerTree implements TraceContainer {
|
||||
private static final TreePath[] EMPTY_PATHS = new TreePath[0];
|
||||
private static final Map<Integer, Color> COLORS_CACHE = new HashMap<>();
|
||||
private static final Object NULL_MARKER = new Object();
|
||||
private static final Object NULL_MARKER = ObjectUtils.sentinel("CollectionTree.NULL_MARKER");
|
||||
|
||||
private final NodeManagerImpl myNodeManager;
|
||||
private final Project myProject;
|
||||
|
||||
Reference in New Issue
Block a user