本文整理汇总了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);
}
}
}