long (@NotNull Object dependency) { if (dependency instanceof VirtualFile) { return ((VirtualFile)dependency).getModificationStamp(); } if (dependency instanceof ModificationTracker) { return ((ModificationTracker)dependency).getModificationCount(); } else if (dependency instanceof Reference){ Object original = ((Reference<?>)dependency).get(); if(original == null) return -1; return getTimeStamp(original); } else if (dependency instanceof Ref) { Object original = ((Ref<?>)dependency).get(); if(original == null) return -1; return getTimeStamp(original); } else if (dependency instanceof Document) { return ((Document)dependency).getModificationStamp(); } else if (dependency instanceof CachedValueBase) { // to check for up to date for a cached value dependency we use .isUpToDate() method, not the timestamp return 0; } else { Logger.getInstance(CachedValueBase.class).error("Wrong dependency type: " + dependency.getClass()); return -1; } }