本文整理匯總了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--;
}
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}