示例#1
0
 private void process(BasicBlock bb, TIntArrayList locks) {
   int n = bb.size();
   int k = locks.size();
   for (int i = 0; i < n; i++) {
     Quad q = bb.getQuad(i);
     Operator op = q.getOperator();
     if (op instanceof Monitor) {
       if (op instanceof MONITORENTER) {
         TIntArrayList locks2 = new TIntArrayList(k + 1);
         for (int j = 0; j < k; j++) locks2.add(locks.get(j));
         int lIdx = domL.indexOf(q);
         assert (lIdx >= 0);
         locks2.add(lIdx);
         locks = locks2;
         k++;
       } else {
         k--;
         TIntArrayList locks2 = new TIntArrayList(k);
         for (int j = 0; j < k; j++) locks2.add(locks.get(j));
         locks = locks2;
       }
     } else if (op.isHeapInst() && k > 0) {
       int eIdx = domE.indexOf(q);
       assert (eIdx >= 0);
       add(locks.get(k - 1), eIdx);
     }
   }
   for (Object o : bb.getSuccessors()) {
     BasicBlock bb2 = (BasicBlock) o;
     if (!visited.contains(bb2)) {
       visited.add(bb2);
       process(bb2, locks);
     }
   }
 }
  private void applyChildrenChangeEvents(VirtualFile parent, List<VFileEvent> events) {
    final NewVirtualFileSystem delegate = getDelegate(parent);
    TIntArrayList childrenIdsUpdated = new TIntArrayList();
    List<VirtualFile> childrenToBeUpdated = new SmartList<VirtualFile>();

    assert parent != null && parent != mySuperRoot;
    final int parentId = getFileId(parent);
    assert parentId != 0;
    TIntHashSet parentChildrenIds = new TIntHashSet(FSRecords.list(parentId));
    boolean hasRemovedChildren = false;

    for (VFileEvent event : events) {
      if (event instanceof VFileCreateEvent) {
        String name = ((VFileCreateEvent) event).getChildName();
        final VirtualFile fake = new FakeVirtualFile(parent, name);
        final FileAttributes attributes = delegate.getAttributes(fake);

        if (attributes != null) {
          final int childId = createAndFillRecord(delegate, fake, parentId, attributes);
          assert parent instanceof VirtualDirectoryImpl : parent;
          final VirtualDirectoryImpl dir = (VirtualDirectoryImpl) parent;
          VirtualFileSystemEntry child = dir.createChild(name, childId, dir.getFileSystem());
          childrenToBeUpdated.add(child);
          childrenIdsUpdated.add(childId);
          parentChildrenIds.add(childId);
        }
      } else if (event instanceof VFileDeleteEvent) {
        VirtualFile file = ((VFileDeleteEvent) event).getFile();
        if (!file.exists()) {
          LOG.error("Deleting a file, which does not exist: " + file.getPath());
          continue;
        }

        hasRemovedChildren = true;
        int id = getFileId(file);

        childrenToBeUpdated.add(file);
        childrenIdsUpdated.add(-id);
        parentChildrenIds.remove(id);
      }
    }

    FSRecords.updateList(parentId, parentChildrenIds.toArray());

    if (hasRemovedChildren) clearIdCache();
    VirtualDirectoryImpl parentImpl = (VirtualDirectoryImpl) parent;

    for (int i = 0, len = childrenIdsUpdated.size(); i < len; ++i) {
      final int childId = childrenIdsUpdated.get(i);
      final VirtualFile childFile = childrenToBeUpdated.get(i);

      if (childId > 0) {
        parentImpl.addChild((VirtualFileSystemEntry) childFile);
      } else {
        FSRecords.deleteRecordRecursively(-childId);
        parentImpl.removeChild(childFile);
        invalidateSubtree(childFile);
      }
    }
  }
  @NotNull
  @Override
  protected List<HighlightInfo> doHighlighting() {
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();

    TIntArrayList toIgnore = new TIntArrayList();
    toIgnore.add(Pass.EXTERNAL_TOOLS);
    toIgnore.add(Pass.LOCAL_INSPECTIONS);
    toIgnore.add(Pass.WHOLE_FILE_LOCAL_INSPECTIONS);
    toIgnore.add(Pass.POPUP_HINTS);
    return CodeInsightTestFixtureImpl.instantiateAndRun(
        getFile(), getEditor(), toIgnore.toNativeArray(), false);
  }
示例#4
0
 public static TIntArrayList getPath(GRIBTNode node) {
   if (node != null) {
     TIntArrayList path = new TIntArrayList();
     path.add(node.AS);
     GRIBTNode parent = node.parent;
     while (parent != root) {
       path.add(parent.AS);
       parent = parent.parent;
     }
     return path;
   } else {
     return new TIntArrayList();
   }
 }
    @Override
    public void add(int hash, int cost, @Nullable PsiFragment frag) {
      if (!isIndexedFragment(frag, cost, myProfile, myDuplocatorState)) {
        return;
      }

      if (myTracingData != null) myTracingData.record(hash, cost, frag);

      TIntArrayList list = myMap.get(hash);
      if (list == null) {
        myMap.put(hash, list = new TIntArrayList());
      }
      list.add(frag.getStartOffset());
      list.add(0);
    }
示例#6
0
  /** Get/allocate spaceNeeded entries for the designated float-based attribute */
  private int getFloatSpace(int attrId, int spaceNeeded) {
    int sequence =
        AttrDefinitionMgr.getAttrIndex(attrId); // this should be unique across all attributes

    if (sequence < indicesPlusOne.size()) {
      int indexPlusOne = indicesPlusOne.getQuick(sequence);
      if (indexPlusOne > 0) {
        Assert.state(
            getLength(attrId) == spaceNeeded,
            "getLength = "
                + getLength(attrId)
                + ", requested = "
                + spaceNeeded); // dumbo check to ensure not asking for diff size
        return indexPlusOne - 1;
      }
    } else {
      padSpace(indicesPlusOne, sequence);
    }

    // okay, it's not been allocated so ...
    int index = nextFloatsIndex;
    nextFloatsIndex += spaceNeeded;

    indicesPlusOne.set(sequence, index + 1);

    // Add to list of attrIds for iterator
    Assert.state(attrIds.contains(attrId) == false);
    attrIds.add(attrId);

    setLength(sequence, spaceNeeded);

    syncToStore(); // we sync here as we've modified
    return index;
  }
示例#7
0
  private void refreshTable() {
    IDevice[] devices = myDetectedDevicesRef.get();
    myDisplayedDevices = devices;

    final IDevice[] selectedDevices = getSelectedDevices();
    final TIntArrayList selectedRows = new TIntArrayList();
    for (int i = 0; i < devices.length; i++) {
      if (ArrayUtil.indexOf(selectedDevices, devices[i]) >= 0) {
        selectedRows.add(i);
      }
    }

    myProcessSelectionFlag = false;
    myDeviceTable.setModel(new MyDeviceTableModel(devices));
    if (selectedRows.size() == 0 && devices.length > 0) {
      myDeviceTable.getSelectionModel().setSelectionInterval(0, 0);
    }
    for (int selectedRow : selectedRows.toNativeArray()) {
      if (selectedRow < devices.length) {
        myDeviceTable.getSelectionModel().addSelectionInterval(selectedRow, selectedRow);
      }
    }
    fireSelectedDevicesChanged();
    myProcessSelectionFlag = true;
    updatePreviouslySelectedSerials();
  }
示例#8
0
  public SelectionData selectTests(String methodName, Edge[] dangerousEdges)
      throws MethodNotFoundException {
    TestHistory th = thHandler.getTestHistory(methodName);
    int maxTestID = th.getHighestTestID();
    TIntArrayList testList = new TIntArrayList();

    for (int i = 0; i < dangerousEdges.length; i++) {
      // int predBlockID = dangerousEdges[i].getPredNodeID();
      int succBlockID = dangerousEdges[i].getSuccNodeID();

      for (int j = 0; j < maxTestID; j++) {
        if (
        /*th.query(predBlockID, j) &&*/ th.query(succBlockID, j)) {
          testList.add(j + 1);
        }
      }
    }

    SelectionData sd = new SelectionData();
    if (testList.size() > 0) {
      sd.tests = testList.toNativeArray();
    } else {
      sd.tests = new int[0];
    }

    return sd;
  }
  public static boolean checkParametersNumber(
      @NotNull List<CandidateInfo> conflicts,
      final int argumentsCount,
      boolean ignoreIfStaticsProblem) {
    boolean atLeastOneMatch = false;
    TIntArrayList unmatchedIndices = null;
    for (int i = 0; i < conflicts.size(); i++) {
      ProgressManager.checkCanceled();
      CandidateInfo info = conflicts.get(i);
      if (ignoreIfStaticsProblem && !info.isStaticsScopeCorrect()) return true;
      if (!(info instanceof MethodCandidateInfo)) continue;
      PsiMethod method = ((MethodCandidateInfo) info).getElement();
      if (method.isVarArgs()) return true;
      if (method.getParameterList().getParametersCount() == argumentsCount) {
        // remove all unmatched before
        if (unmatchedIndices != null) {
          for (int u = unmatchedIndices.size() - 1; u >= 0; u--) {
            int index = unmatchedIndices.get(u);
            conflicts.remove(index);
            i--;
          }
          unmatchedIndices = null;
        }
        atLeastOneMatch = true;
      } else if (atLeastOneMatch) {
        conflicts.remove(i);
        i--;
      } else {
        if (unmatchedIndices == null) unmatchedIndices = new TIntArrayList(conflicts.size() - i);
        unmatchedIndices.add(i);
      }
    }

    return atLeastOneMatch;
  }
示例#10
0
 @Override
 public boolean setInputFormat(Instances instanceInfo) throws Exception {
   TIntArrayList matchingIndices = new TIntArrayList();
   for (int i = 0; i < instanceInfo.numAttributes(); i++) {
     if (matchClass && i == instanceInfo.classIndex()) {
       matchingIndices.add(i);
       continue;
     }
     if (prefix != null && instanceInfo.attribute(i).name().startsWith(prefix)) {
       matchingIndices.add(i);
       continue;
     }
   }
   super.setAttributeIndicesArray(matchingIndices.toNativeArray());
   return super.setInputFormat(instanceInfo);
 }
 @Override
 public TIntArrayList read(final DataInput in) throws IOException {
   int size = DataInputOutputUtil.readSINT(in);
   if (size == Integer.MAX_VALUE) {
     return new TIntArrayList();
   } else if (size <= 0) {
     TIntArrayList result = new TIntArrayList(1);
     result.add(-size);
     return result;
   } else {
     TIntArrayList result = new TIntArrayList(size);
     for (int i = 0; i < size; i++) {
       result.add(DataInputOutputUtil.readINT(in));
     }
     return result;
   }
 }
 protected TIntArrayList getParametersToRemove() {
   TIntArrayList parameters = new TIntArrayList();
   for (int i = 0; i < myParametersToRemoveChecked.length; i++) {
     if (myParametersToRemoveChecked[i]) {
       parameters.add(i);
     }
   }
   return parameters;
 }
 private TIntArrayList getParametersToRemove() {
   TIntArrayList list = new TIntArrayList();
   for (Object o : toRemoveCBs.keys()) {
     if (((JCheckBox) o).isSelected()) {
       list.add(toRemoveCBs.get((JCheckBox) o));
     }
   }
   return list;
 }
示例#14
0
  @Nullable
  private VirtualFileSystemEntry findFileById(
      int id, boolean cachedOnly, TIntArrayList visited, int mask) {
    VirtualFileSystemEntry cached = myIdToDirCache.get(id);
    if (cached != null) return cached;

    if (visited != null
        && (visited.size() >= DEPTH_LIMIT || (mask & id) == id && visited.contains(id))) {
      @NonNls
      String sb =
          "Dead loop detected in persistent FS (id=" + id + " cached-only=" + cachedOnly + "):";
      for (int i = 0; i < visited.size(); i++) {
        int _id = visited.get(i);
        sb +=
            "\n  "
                + _id
                + " '"
                + getName(_id)
                + "' "
                + String.format("%02x", getFileAttributes(_id))
                + ' '
                + myIdToDirCache.containsKey(_id);
      }
      LOG.error(sb);
      return null;
    }

    int parentId = getParent(id);
    if (parentId >= id) {
      if (visited == null) visited = new TIntArrayList(DEPTH_LIMIT);
    }
    if (visited != null) visited.add(id);

    VirtualFileSystemEntry result;
    if (parentId == 0) {
      myRootsLock.readLock().lock();
      try {
        result = myRootsById.get(id);
      } finally {
        myRootsLock.readLock().unlock();
      }
    } else {
      VirtualFileSystemEntry parentFile = findFileById(parentId, cachedOnly, visited, mask | id);
      if (parentFile instanceof VirtualDirectoryImpl) {
        result = ((VirtualDirectoryImpl) parentFile).findChildById(id, cachedOnly);
      } else {
        result = null;
      }
    }

    if (result != null && result.isDirectory()) {
      VirtualFileSystemEntry old = myIdToDirCache.put(id, result);
      if (old != null) result = old;
    }
    return result;
  }
示例#15
0
 /** Helper method to represent an Attribute as a single-element vector. */
 private int[] toValueIndexArray(Attribute attribute) {
   TIntArrayList out = new TIntArrayList();
   for (String value : values) {
     int valueIndex = attribute.indexOfValue(value);
     if (valueIndex < 0)
       throw new NoSuchElementException(
           "no such value: '" + value + "' in attribute '" + attribute.toString() + "'");
     out.add(valueIndex);
   }
   return out.toNativeArray();
 }
 @Override
 public TIntArrayList read(@NotNull DataInput in) throws IOException {
   int capacityOrValue = DataInputOutputUtil.readINT(in);
   if (capacityOrValue >= 0) {
     TIntArrayList list = new TIntArrayList(2);
     list.add(capacityOrValue);
     list.add(DataInputOutputUtil.readINT(in));
     return list;
   }
   capacityOrValue = -capacityOrValue;
   TIntArrayList list = new TIntArrayList(capacityOrValue);
   int prev = 0;
   while (capacityOrValue > 0) {
     int value = DataInputOutputUtil.readINT(in) + prev;
     list.add(value);
     prev = value;
     list.add(DataInputOutputUtil.readINT(in));
     capacityOrValue -= 2;
   }
   return list;
 }
示例#17
0
 public void visit(jq_Method m) {
   if (m.isAbstract()) return;
   ControlFlowGraph cfg = m.getCFG();
   BasicBlock entry = cfg.entry();
   TIntArrayList locks = new TIntArrayList();
   if (m.isSynchronized()) {
     int lIdx = domL.indexOf(entry);
     assert (lIdx >= 0);
     locks.add(lIdx);
   }
   process(entry, locks);
   visited.clear();
 }
示例#18
0
 public void removePaths(VirtualFile... paths) {
   final Set<VirtualFile> pathsSet = new java.util.HashSet<VirtualFile>(Arrays.asList(paths));
   int size = getRowCount();
   final TIntArrayList indicesToRemove = new TIntArrayList(paths.length);
   for (int idx = 0; idx < size; idx++) {
     VirtualFile path = getValueAt(idx);
     if (pathsSet.contains(path)) {
       indicesToRemove.add(idx);
     }
   }
   final List list = ListUtil.removeIndices(myList, indicesToRemove.toNativeArray());
   itemsRemoved(list);
 }
  @NotNull
  private FSRecords.NameId[] persistAllChildren(
      @NotNull final VirtualFile file, final int id, @NotNull FSRecords.NameId[] current) {
    assert file != mySuperRoot;
    final NewVirtualFileSystem fs = replaceWithNativeFS(getDelegate(file));

    String[] delegateNames = VfsUtil.filterNames(fs.list(file));
    if (delegateNames.length == 0 && current.length > 0) {
      return current;
    }

    Set<String> toAdd = ContainerUtil.newHashSet(delegateNames);
    for (FSRecords.NameId nameId : current) {
      toAdd.remove(nameId.name);
    }

    final TIntArrayList childrenIds = new TIntArrayList(current.length + toAdd.size());
    final List<FSRecords.NameId> nameIds =
        ContainerUtil.newArrayListWithExpectedSize(current.length + toAdd.size());
    for (FSRecords.NameId nameId : current) {
      childrenIds.add(nameId.id);
      nameIds.add(nameId);
    }
    for (String newName : toAdd) {
      FakeVirtualFile child = new FakeVirtualFile(file, newName);
      FileAttributes attributes = fs.getAttributes(child);
      if (attributes != null) {
        int childId = createAndFillRecord(fs, child, id, attributes);
        childrenIds.add(childId);
        nameIds.add(new FSRecords.NameId(childId, FileNameCache.storeName(newName), newName));
      }
    }

    FSRecords.updateList(id, childrenIds.toNativeArray());
    setChildrenCached(id);

    return nameIds.toArray(new FSRecords.NameId[nameIds.size()]);
  }
示例#20
0
  @NotNull
  private static LineSet createLineSet(@NotNull CharSequence text, boolean markModified) {
    TIntArrayList starts = new TIntArrayList();
    TByteArrayList flags = new TByteArrayList();

    LineTokenizer lineTokenizer = new LineTokenizer(text);
    while (!lineTokenizer.atEnd()) {
      starts.add(lineTokenizer.getOffset());
      flags.add(
          (byte) (lineTokenizer.getLineSeparatorLength() | (markModified ? MODIFIED_MASK : 0)));
      lineTokenizer.advance();
    }
    return new LineSet(starts.toNativeArray(), flags.toNativeArray(), text.length());
  }
 public void forceInitFromModel() {
   Set<ClasspathTableItem<?>> oldSelection = new HashSet<ClasspathTableItem<?>>();
   for (int i : myEntryTable.getSelectedRows()) {
     ContainerUtil.addIfNotNull(getItemAt(i), oldSelection);
   }
   myModel.clear();
   myModel.init();
   myModel.fireTableDataChanged();
   TIntArrayList newSelection = new TIntArrayList();
   for (int i = 0; i < myModel.getRowCount(); i++) {
     if (oldSelection.contains(getItemAt(i))) {
       newSelection.add(i);
     }
   }
   TableUtil.selectRows(myEntryTable, newSelection.toNativeArray());
 }
示例#22
0
 private boolean checkDirty() {
   if (myEditor.getSoftWrapModel().isDirty()) {
     myDirty = true;
     return true;
   }
   if (myDirty) {
     int visibleLineCount = myEditor.getVisibleLineCount();
     int lineDiff = visibleLineCount - myLineWidths.size();
     if (lineDiff > 0) myLineWidths.add(new int[lineDiff]);
     else if (lineDiff < 0) myLineWidths.remove(visibleLineCount, -lineDiff);
     for (int i = 0; i < visibleLineCount; i++) {
       myLineWidths.set(i, UNKNOWN_WIDTH);
     }
     myDirty = false;
   }
   return false;
 }
  @Override
  public String getInstalledPluginNameByPath(Project project, @NotNull VirtualFile pluginPath) {
    String nameFromPluginXml = super.getInstalledPluginNameByPath(project, pluginPath);
    if (nameFromPluginXml != null) {
      return nameFromPluginXml;
    }

    VirtualFile pluginJson = pluginPath.findChild("plugin.json");
    if (pluginJson != null) {
      String pluginAndVersion = pluginPath.getName(); // pluginName-version

      TIntArrayList separatorIndexes = new TIntArrayList();
      int start = -1;
      while (true) {
        start = pluginAndVersion.indexOf('-', start + 1);
        if (start == -1) break;
        separatorIndexes.add(start);
      }

      if (separatorIndexes.size() == 1) {
        return pluginAndVersion.substring(0, separatorIndexes.get(0));
      }

      if (separatorIndexes.size() > 0) {
        String json;
        try {
          json = VfsUtil.loadText(pluginJson);
        } catch (IOException e) {
          return null;
        }

        for (int i = 0; i < separatorIndexes.size(); i++) {
          int idx = separatorIndexes.get(i);
          String name = pluginAndVersion.substring(0, idx);
          String version = pluginAndVersion.substring(idx + 1);

          if (hasValue(PLUGIN_NAME_JSON_PATTERN, json, name)
              && hasValue(PLUGIN_VERSION_JSON_PATTERN, json, version)) {
            return name;
          }
        }
      }
    }

    return null;
  }
  @Override
  public void addItems(List<ClasspathTableItem<?>> toAdd) {
    for (ClasspathTableItem<?> item : toAdd) {
      myModel.addRow(item);
    }
    TIntArrayList toSelect = new TIntArrayList();
    for (int i = myModel.getRowCount() - toAdd.size(); i < myModel.getRowCount(); i++) {
      toSelect.add(myEntryTable.convertRowIndexToView(i));
    }
    TableUtil.selectRows(myEntryTable, toSelect.toNativeArray());
    TableUtil.scrollSelectionToVisible(myEntryTable);

    final StructureConfigurableContext context =
        ModuleStructureConfigurable.getInstance(myState.getProject()).getContext();
    context
        .getDaemonAnalyzer()
        .queueUpdate(new ModuleProjectStructureElement(context, getRootModel().getModule()));
  }
示例#25
0
  private List index(int numEvents, EventStream es, TObjectIntHashMap predicateIndex) {
    TObjectIntHashMap omap = new TObjectIntHashMap();
    int outcomeCount = 0;
    List eventsToCompare = new ArrayList(numEvents);
    TIntArrayList indexedContext = new TIntArrayList();
    while (es.hasNext()) {
      Event ev = es.nextEvent();
      String[] econtext = ev.getContext();
      ComparableEvent ce;

      int ocID;
      String oc = ev.getOutcome();

      if (omap.containsKey(oc)) {
        ocID = omap.get(oc);
      } else {
        ocID = outcomeCount++;
        omap.put(oc, ocID);
      }

      for (int i = 0; i < econtext.length; i++) {
        String pred = econtext[i];
        if (predicateIndex.containsKey(pred)) {
          indexedContext.add(predicateIndex.get(pred));
        }
      }

      // drop events with no active features
      if (indexedContext.size() > 0) {
        ce = new ComparableEvent(ocID, indexedContext.toNativeArray());
        eventsToCompare.add(ce);
      } else {
        System.err.println(
            "Dropped event " + ev.getOutcome() + ":" + Arrays.asList(ev.getContext()));
      }
      // recycle the TIntArrayList
      indexedContext.resetQuick();
    }
    outcomeLabels = toIndexedStringArray(omap);
    predLabels = toIndexedStringArray(predicateIndex);
    return eventsToCompare;
  }
示例#26
0
  /**
   * It's possible that we need to expand quick doc control's width in order to provide better
   * visual representation (see http://youtrack.jetbrains.com/issue/IDEA-101425). This method
   * calculates that width expand.
   *
   * @param buttonWidth icon button's width
   * @param updatedText text which will be should at the quick doc control
   * @return width increase to apply to the target quick doc control (zero if no additional width
   *     increase is required)
   */
  private static int calculateWidthIncrease(int buttonWidth, String updatedText) {
    int maxLineWidth = 0;
    TIntArrayList lineWidths = new TIntArrayList();
    for (String lineText : StringUtil.split(updatedText, "<br/>")) {
      String html = HintUtil.prepareHintText(lineText, HintUtil.getInformationHint());
      int width = new JLabel(html).getPreferredSize().width;
      maxLineWidth = Math.max(maxLineWidth, width);
      lineWidths.add(width);
    }

    if (!lineWidths.isEmpty()) {
      int firstLineAvailableTrailingWidth = maxLineWidth - lineWidths.get(0);
      if (firstLineAvailableTrailingWidth >= buttonWidth) {
        return 0;
      } else {
        return buttonWidth - firstLineAvailableTrailingWidth;
      }
    }
    return 0;
  }
 private void queueUnresolvedFilesSinceLastRestart() {
   PersistentFS fs = PersistentFS.getInstance();
   int maxId = FSRecords.getMaxId();
   TIntArrayList list = new TIntArrayList();
   for (int id = fileIsResolved.nextClearBit(1);
       id >= 0 && id < maxId;
       id = fileIsResolved.nextClearBit(id + 1)) {
     int nextSetBit = fileIsResolved.nextSetBit(id);
     int endOfRun = Math.min(maxId, nextSetBit == -1 ? maxId : nextSetBit);
     do {
       VirtualFile virtualFile = fs.findFileById(id);
       if (queueIfNeeded(virtualFile, myProject)) {
         list.add(id);
       } else {
         fileIsResolved.set(id);
       }
     } while (++id < endOfRun);
   }
   log("Initially added to resolve " + toVfString(list.toNativeArray()));
 }
示例#28
0
 /**
  * Recursively searches the tree for the nearest entry. Other queries call execute() on an
  * IntProcedure when a matching entry is found; however nearest() must store the entry Ids as it
  * searches the tree, in case a nearer entry is found. Uses the member variable nearestIds to
  * store the nearest entry IDs.
  *
  * <p>[x] TODO rewrite this to be non-recursive?
  */
 private float nearest(Point p, Node n, float nearestDistance) {
   for (int i = 0; i < n.entryCount; i++) {
     float tempDistance = n.entries[i].distance(p);
     if (n.isLeaf()) { // for leaves, the distance is an actual nearest distance
       if (tempDistance < nearestDistance) {
         nearestDistance = tempDistance;
         nearestIds.clear();
       }
       if (tempDistance <= nearestDistance) {
         nearestIds.add(n.ids[i]);
       }
     } else { // for index nodes, only go into them if they potentially could have
       // a rectangle nearer than actualNearest
       if (tempDistance <= nearestDistance) {
         // search the child node
         nearestDistance = nearest(p, getNode(n.ids[i]), nearestDistance);
       }
     }
   }
   return nearestDistance;
 }
  private void storeIds(@NotNull ConcurrentIntObjectMap<int[]> fileToForwardIds) {
    int forwardSize = 0;
    int backwardSize = 0;
    final TIntObjectHashMap<TIntArrayList> fileToBackwardIds =
        new TIntObjectHashMap<TIntArrayList>(fileToForwardIds.size());
    for (ConcurrentIntObjectMap.IntEntry<int[]> entry : fileToForwardIds.entries()) {
      int fileId = entry.getKey();
      int[] forwardIds = entry.getValue();
      forwardSize += forwardIds.length;
      for (int forwardId : forwardIds) {
        TIntArrayList backIds = fileToBackwardIds.get(forwardId);
        if (backIds == null) {
          backIds = new TIntArrayList();
          fileToBackwardIds.put(forwardId, backIds);
        }
        backIds.add(fileId);
        backwardSize++;
      }
    }
    log("backwardSize = " + backwardSize);
    log("forwardSize = " + forwardSize);
    log("fileToForwardIds.size() = " + fileToForwardIds.size());
    log("fileToBackwardIds.size() = " + fileToBackwardIds.size());
    assert forwardSize == backwardSize;

    // wrap in read action so that sudden quit (in write action) would not interrupt us
    myApplication.runReadAction(
        () -> {
          if (!myApplication.isDisposed()) {
            fileToBackwardIds.forEachEntry(
                new TIntObjectProcedure<TIntArrayList>() {
                  @Override
                  public boolean execute(int fileId, TIntArrayList backIds) {
                    storage.addAll(fileId, backIds.toNativeArray());
                    return true;
                  }
                });
          }
        });
  }
  @NotNull
  protected List<HighlightInfo> doHighlighting() {
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();

    TIntArrayList toIgnore = new TIntArrayList();
    if (!doTestLineMarkers()) {
      toIgnore.add(Pass.UPDATE_OVERRIDEN_MARKERS);
      toIgnore.add(Pass.VISIBLE_LINE_MARKERS);
      toIgnore.add(Pass.LINE_MARKERS);
    }

    if (!doExternalValidation()) {
      toIgnore.add(Pass.EXTERNAL_TOOLS);
    }
    if (forceExternalValidation()) {
      toIgnore.add(Pass.LINE_MARKERS);
      toIgnore.add(Pass.LOCAL_INSPECTIONS);
      toIgnore.add(Pass.WHOLE_FILE_LOCAL_INSPECTIONS);
      toIgnore.add(Pass.POPUP_HINTS);
      toIgnore.add(Pass.UPDATE_ALL);
      toIgnore.add(Pass.UPDATE_OVERRIDEN_MARKERS);
      toIgnore.add(Pass.VISIBLE_LINE_MARKERS);
    }

    boolean canChange = canChangeDocumentDuringHighlighting();
    List<HighlightInfo> infos =
        CodeInsightTestFixtureImpl.instantiateAndRun(
            getFile(), getEditor(), toIgnore.toNativeArray(), canChange);

    if (!canChange) {
      Document document = getDocument(getFile());
      DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
      daemonCodeAnalyzer.getFileStatusMap().assertAllDirtyScopesAreNull(document);
    }

    return infos;
  }