當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。