Java Code Examples for com.intellij.psi.impl.DebugUtil#CHECK_INSIDE_ATOMIC_ACTION_ENABLED

The following examples show how to use com.intellij.psi.impl.DebugUtil#CHECK_INSIDE_ATOMIC_ACTION_ENABLED . 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: CompositeElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public ASTNode findChildByType(@Nonnull IElementType type) {
  if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED) {
    assertReadAccessAllowed();
  }

  for (ASTNode element = getFirstChildNode(); element != null; element = element.getTreeNext()) {
    if (element.getElementType() == type) return element;
  }
  return null;
}
 
Example 2
Source File: CompositeElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public ASTNode findChildByType(@Nonnull IElementType type, ASTNode anchor) {
  if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED) {
    assertReadAccessAllowed();
  }

  return TreeUtil.findSibling(anchor, type);
}
 
Example 3
Source File: CompositeElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public ASTNode findChildByType(@Nonnull TokenSet types) {
  if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED) {
    assertReadAccessAllowed();
  }
  for (ASTNode element = getFirstChildNode(); element != null; element = element.getTreeNext()) {
    if (types.contains(element.getElementType())) return element;
  }
  return null;
}
 
Example 4
Source File: CompositeElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public ASTNode findChildByType(@Nonnull TokenSet typesSet, ASTNode anchor) {
  if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED) {
    assertReadAccessAllowed();
  }
  return TreeUtil.findSibling(anchor, typesSet);
}
 
Example 5
Source File: TreeElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public final int getStartOffsetInParent() {
  if (myParent == null) return -1;
  int offsetInParent = myStartOffsetInParent;
  if (offsetInParent != -1) return offsetInParent;

  if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED) {
    assertReadAccessAllowed();
  }

  TreeElement cur = this;
  while (true) {
    TreeElement prev = cur.getTreePrev();
    if (prev == null) break;
    cur = prev;
    offsetInParent = cur.myStartOffsetInParent;
    if (offsetInParent != -1) break;
  }

  if (offsetInParent == -1) {
    cur.myStartOffsetInParent = offsetInParent = 0;
  }

  while (cur != this) {
    TreeElement next = cur.getTreeNext();
    offsetInParent += cur.getTextLength();
    next.myStartOffsetInParent = offsetInParent;
    cur = next;
  }
  return offsetInParent;
}
 
Example 6
Source File: TreeUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static ASTNode findChildBackward(ASTNode parent, IElementType type) {
  if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED) {
    ApplicationManager.getApplication().assertReadAccessAllowed();
  }
  for (ASTNode element = parent.getLastChildNode(); element != null; element = element.getTreePrev()) {
    if (element.getElementType() == type) return element;
  }
  return null;
}
 
Example 7
Source File: PsiPackageBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Override
public String getName() {
  if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED) {
    ApplicationManager.getApplication().assertReadAccessAllowed();
  }
  if (myQualifiedName.isEmpty()) return null;
  int index = myQualifiedName.lastIndexOf('.');
  if (index < 0) {
    return myQualifiedName;
  }
  else {
    return myQualifiedName.substring(index + 1);
  }
}