Exemplo n.º 1
0
    @Override
    protected void rehash(int newCapacity) {
      // rehash should discard gced keys
      // because otherwise there is a remote probability of
      // having two (Weak|Soft)Keys with accidentally equal hashCodes and different but gced key
      // values
      int oldCapacity = _set.length;
      Object[] oldKeys = _set;
      V[] oldVals = _values;

      _set = new Object[newCapacity];
      _values = (V[]) new Object[newCapacity];

      for (int i = oldCapacity; i-- > 0; ) {
        Object o = oldKeys[i];
        if (o == null || o == REMOVED) continue;
        Key<K> k = (Key<K>) o;
        K key = k.get();
        if (key == null) continue;
        int index = insertionIndex(k);
        if (index < 0) {
          // make 'key' alive till this point to not allow 'o.referent' to be gced
          throwObjectContractViolation(_set[-index - 1], o + "; key: " + key);
        }
        _set[index] = o;
        _values[index] = oldVals[i];
      }
    }
Exemplo n.º 2
0
 @NotNull
 @Override
 public Navigatable createNavigatable(@NotNull Project project) {
   if (ALTERNATIVE_SOURCE_KEY.get(myFile) != null) {
     return new OpenFileDescriptor(project, getFile(), getLine(), 0);
   }
   return XSourcePositionImpl.doCreateOpenFileDescriptor(project, this);
 }
Exemplo n.º 3
0
 @NotNull
 @Override
 public VirtualFile getFile() {
   VirtualFile file = ALTERNATIVE_SOURCE_KEY.get(myFile);
   if (file != null) {
     return file;
   }
   return myFile;
 }