コード例 #1
0
 @Override
 public void rawAddChildrenWithoutNotifications(@NotNull TreeElement first) {
   if (myText() != null) {
     LOG.error("Mutating collapsed chameleon");
   }
   super.rawAddChildrenWithoutNotifications(first);
 }
コード例 #2
0
  private void ensureParsed() {
    if (!ourParsingAllowed) {
      LOG.error("Parsing not allowed!!!");
    }
    CharSequence text = myText();
    if (text == null) return;

    if (TreeUtil.getFileElement(this) == null) {
      LOG.error("Chameleons must not be parsed till they're in file tree: " + this);
    }

    ApplicationManager.getApplication().assertReadAccessAllowed();

    DebugUtil.startPsiModification("lazy-parsing");
    try {
      ILazyParseableElementType type = (ILazyParseableElementType) getElementType();
      ASTNode parsedNode = type.parseContents(this);

      if (parsedNode == null && text.length() > 0) {
        CharSequence diagText = ApplicationManager.getApplication().isInternal() ? text : "";
        LOG.error(
            "No parse for a non-empty string: "
                + diagText
                + "; type="
                + LogUtil.objectAndClass(type));
      }

      synchronized (lock) {
        if (myText == null) return;
        if (rawFirstChild() != null) {
          LOG.error("Reentrant parsing?");
        }

        myText = null;

        if (parsedNode == null) return;
        super.rawAddChildrenWithoutNotifications((TreeElement) parsedNode);
      }
    } finally {
      DebugUtil.finishPsiModification();
    }

    if (!Boolean.TRUE.equals(ourSuppressEagerPsiCreation.get())) {
      // create PSI all at once, to reduce contention of PsiLock in CompositeElement.getPsi()
      // create PSI outside the 'lock' since this method grabs PSI_LOCK and deadlock is possible
      // when someone else locks in the other order.
      createAllChildrenPsiIfNecessary();
    }
  }