当前位置: 首页>>代码示例>>Java>>正文


Java BlockTreeNode类代码示例

本文整理汇总了Java中com.intellij.internal.psiView.formattingblocks.BlockTreeNode的典型用法代码示例。如果您正苦于以下问题:Java BlockTreeNode类的具体用法?Java BlockTreeNode怎么用?Java BlockTreeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BlockTreeNode类属于com.intellij.internal.psiView.formattingblocks包,在下文中一共展示了BlockTreeNode类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectBlockNode

import com.intellij.internal.psiView.formattingblocks.BlockTreeNode; //导入依赖的package包/类
private void selectBlockNode(@Nullable BlockTreeNode currentBlockNode) {
  if (myBlockTreeBuilder == null) return;
  if (currentBlockNode != null) {
    myIgnoreBlockTreeSelectionMarker++;
    myBlockTreeBuilder.select(currentBlockNode, new Runnable() {
      @Override
      public void run() {
        // hope this is always called!
        assert myIgnoreBlockTreeSelectionMarker > 0;
        myIgnoreBlockTreeSelectionMarker--;
      }
    });
  }
  else {
    myIgnoreBlockTreeSelectionMarker++;
    try {
      myBlockTree.getSelectionModel().clearSelection();
    }
    finally {
      assert myIgnoreBlockTreeSelectionMarker > 0;
      myIgnoreBlockTreeSelectionMarker--;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PsiViewerDialog.java

示例2: findBlockNode

import com.intellij.internal.psiView.formattingblocks.BlockTreeNode; //导入依赖的package包/类
@Nullable
private BlockTreeNode findBlockNode(TextRange range, boolean selectParentIfNotFound) {
  final BlockTreeBuilder builder = myBlockTreeBuilder;
  if (builder == null || !myBlockStructurePanel.isVisible()) {
    return null;
  }

  AbstractTreeStructure treeStructure = builder.getTreeStructure();
  if (treeStructure == null) return null;
  BlockTreeNode node = (BlockTreeNode)treeStructure.getRootElement();
  main_loop:
  while (true) {
    if (node.getBlock().getTextRange().equals(range)) {
      return node;
    }

    for (BlockTreeNode child : node.getChildren()) {
      if (child.getBlock().getTextRange().contains(range)) {
        node = child;
        continue main_loop;
      }
    }
    return selectParentIfNotFound ? node : null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PsiViewerDialog.java

示例3: initMap

import com.intellij.internal.psiView.formattingblocks.BlockTreeNode; //导入依赖的package包/类
private void initMap(BlockTreeNode rootBlockNode, PsiElement psiEl) {
    PsiElement currentElem = null;
    if (rootBlockNode.getBlock() instanceof ASTBlock) {
      ASTNode node = ((ASTBlock)rootBlockNode.getBlock()).getNode();
      if (node != null) {
        currentElem = node.getPsi();
      }
    }
    if (currentElem == null) {
      currentElem =
        InjectedLanguageUtil
          .findElementAtNoCommit(psiEl.getContainingFile(), rootBlockNode.getBlock().getTextRange().getStartOffset());
    }
    myPsiToBlockMap.put(currentElem, rootBlockNode);

//nested PSI elements with same ranges will be mapped to one blockNode
//    assert currentElem != null;      //for Scala-language plugin etc it can be null, because formatterBlocks is not instance of ASTBlock
    TextRange curTextRange = currentElem.getTextRange();
    PsiElement parentElem = currentElem.getParent();
    while (parentElem != null && parentElem.getTextRange().equals(curTextRange)) {
      myPsiToBlockMap.put(parentElem, rootBlockNode);
      parentElem = parentElem.getParent();
    }
    for (BlockTreeNode block : rootBlockNode.getChildren()) {
      initMap(block, psiEl);
    }
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:PsiViewerDialog.java

示例4: valueChanged

import com.intellij.internal.psiView.formattingblocks.BlockTreeNode; //导入依赖的package包/类
@Override
public void valueChanged(@NotNull TreeSelectionEvent e) {
  if (!myEditor.getDocument().getText().equals(myLastParsedText) || myBlockTree.hasFocus()) return;
  TreePath path = myPsiTree.getSelectionPath();
  clearSelection();
  if (path != null) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    if (!(node.getUserObject() instanceof ViewerNodeDescriptor)) return;
    ViewerNodeDescriptor descriptor = (ViewerNodeDescriptor)node.getUserObject();
    Object elementObject = descriptor.getElement();
    final PsiElement element = elementObject instanceof PsiElement
                               ? (PsiElement)elementObject
                               : elementObject instanceof ASTNode ? ((ASTNode)elementObject).getPsi() : null;
    if (element != null) {
      TextRange rangeInHostFile = InjectedLanguageManager.getInstance(myProject).injectedToHost(element, element.getTextRange());
      int start = rangeInHostFile.getStartOffset();
      int end = rangeInHostFile.getEndOffset();
      final ViewerTreeStructure treeStructure = (ViewerTreeStructure)myPsiTreeBuilder.getTreeStructure();
      PsiElement rootPsiElement = treeStructure.getRootPsiElement();
      if (rootPsiElement != null) {
        int baseOffset = rootPsiElement.getTextRange().getStartOffset();
        start -= baseOffset;
        end -= baseOffset;
      }
      final int textLength = myEditor.getDocument().getTextLength();
      if (end <= textLength) {
        myHighlighter = myEditor.getMarkupModel().addRangeHighlighter(start, end, HighlighterLayer.LAST, myAttributes, HighlighterTargetArea.EXACT_RANGE);
        if (myPsiTree.hasFocus()) {
          myEditor.getCaretModel().moveToOffset(start);
          myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
        }
      }
      if (myBlockTreeBuilder != null && myPsiTree.hasFocus()) {
        BlockTreeNode currentBlockNode = findBlockNode(element);
        if (currentBlockNode != null) {
          selectBlockNode(currentBlockNode);
        }
      }
      updateReferences(element);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:PsiViewerDialog.java

示例5: valueChanged

import com.intellij.internal.psiView.formattingblocks.BlockTreeNode; //导入依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent e) {
  if (!myEditor.getDocument().getText().equals(myLastParsedText) || myBlockTree.hasFocus()) return;
  TreePath path = myPsiTree.getSelectionPath();
  clearSelection();
  if (path != null) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    if (!(node.getUserObject() instanceof ViewerNodeDescriptor)) return;
    ViewerNodeDescriptor descriptor = (ViewerNodeDescriptor)node.getUserObject();
    Object elementObject = descriptor.getElement();
    final PsiElement element = elementObject instanceof PsiElement
                               ? (PsiElement)elementObject
                               : elementObject instanceof ASTNode ? ((ASTNode)elementObject).getPsi() : null;
    if (element != null) {
      TextRange rangeInHostFile = InjectedLanguageManager.getInstance(myProject).injectedToHost(element, element.getTextRange());
      int start = rangeInHostFile.getStartOffset();
      int end = rangeInHostFile.getEndOffset();
      final ViewerTreeStructure treeStructure = (ViewerTreeStructure)myPsiTreeBuilder.getTreeStructure();
      PsiElement rootPsiElement = treeStructure.getRootPsiElement();
      if (rootPsiElement != null) {
        int baseOffset = rootPsiElement.getTextRange().getStartOffset();
        start -= baseOffset;
        end -= baseOffset;
      }
      final int textLength = myEditor.getDocument().getTextLength();
      if (end <= textLength) {
        myHighlighter = myEditor.getMarkupModel().addRangeHighlighter(start, end, HighlighterLayer.LAST, myAttributes, HighlighterTargetArea.EXACT_RANGE);
          updateIntersectHighlighter(start, end);

        if (myPsiTree.hasFocus()) {
          myEditor.getCaretModel().moveToOffset(start);
          myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
        }
      }
      if (myBlockTreeBuilder != null && myPsiTree.hasFocus()) {
        BlockTreeNode currentBlockNode = findBlockNode(element);
        if (currentBlockNode != null) {
          selectBlockNode(currentBlockNode);
        }
      }
      updateReferences(element);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:45,代码来源:PsiViewerDialog.java


注:本文中的com.intellij.internal.psiView.formattingblocks.BlockTreeNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。