Java Code Examples for com.intellij.psi.impl.DebugUtil#checkTreeStructure()

The following examples show how to use com.intellij.psi.impl.DebugUtil#checkTreeStructure() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void rawRemove() {
  final TreeElement next = getTreeNext();
  final CompositeElement parent = getTreeParent();
  final TreeElement prev = getTreePrev();

  if (prev != null) {
    prev.setTreeNext(next);
  }
  else if (parent != null) {
    parent.setFirstChildNode(next);
  }

  if (next != null) {
    next.setTreePrev(prev);
  }
  else if (parent != null) {
    parent.setLastChildNode(prev);
  }

  DebugUtil.checkTreeStructure(parent);
  DebugUtil.checkTreeStructure(prev);
  DebugUtil.checkTreeStructure(next);

  invalidate();
}
 
Example 2
Source File: CompositeElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void rawAddChildrenWithoutNotifications(@Nonnull TreeElement first) {
  final TreeElement last = getLastChildNode();
  if (last == null) {
    TreeElement chainLast = rawSetParents(first, this);
    setFirstChildNode(first);
    setLastChildNode(chainLast);
  }
  else {
    last.rawInsertAfterMeWithoutNotifications(first);
  }

  DebugUtil.checkTreeStructure(this);
}
 
Example 3
Source File: TemplateDataElementType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public ASTNode parseContents(ASTNode chameleon) {
  final CharTable charTable = SharedImplUtil.findCharTableByTree(chameleon);
  final FileElement fileElement = TreeUtil.getFileElement((TreeElement)chameleon);
  final PsiFile psiFile = (PsiFile)fileElement.getPsi();
  PsiFile originalPsiFile = psiFile.getOriginalFile();

  final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)originalPsiFile.getViewProvider();

  final Language templateLanguage = getTemplateFileLanguage(viewProvider);
  final CharSequence sourceCode = chameleon.getChars();

  RangesCollector collector = new RangesCollector();
  final PsiFile templatePsiFile = createTemplateFile(psiFile, templateLanguage, sourceCode, viewProvider, collector);

  final FileElement templateFileElement = ((PsiFileImpl)templatePsiFile).calcTreeElement();

  DebugUtil.startPsiModification("template language parsing");
  try {
    prepareParsedTemplateFile(templateFileElement);
    insertOuters(templateFileElement, sourceCode, collector.myRanges, charTable);

    TreeElement childNode = templateFileElement.getFirstChildNode();

    DebugUtil.checkTreeStructure(templateFileElement);
    DebugUtil.checkTreeStructure(chameleon);
    if (fileElement != chameleon) {
      DebugUtil.checkTreeStructure(psiFile.getNode());
      DebugUtil.checkTreeStructure(originalPsiFile.getNode());
    }

    return childNode;
  }
  finally {
    DebugUtil.finishPsiModification();
  }
}