use of com.intellij.psi.impl.source.tree.TreeElement in project intellij-community by JetBrains.
the class CodeEditUtil method removeChildren.
public static void removeChildren(ASTNode parent, @NotNull ASTNode first, @NotNull ASTNode last) {
final boolean tailingElement = last.getStartOffset() + last.getTextLength() == parent.getStartOffset() + parent.getTextLength();
final boolean forceReformat = needToForceReformat(parent, first, last);
saveWhitespacesInfo(first);
TreeElement child = (TreeElement) first;
while (child != null) {
//checkForOuters(child);
if (child == last)
break;
child = child.getTreeNext();
}
assert child == last : last + " is not a successor of " + first + " in the .getTreeNext() chain";
final ASTNode prevLeaf = TreeUtil.prevLeaf(first);
final ASTNode nextLeaf = TreeUtil.nextLeaf(first);
parent.removeRange(first, last.getTreeNext());
ASTNode nextLeafToAdjust = nextLeaf;
if (nextLeafToAdjust != null && prevLeaf != null && nextLeafToAdjust.getTreeParent() == null) {
//next element has invalidated
nextLeafToAdjust = prevLeaf.getTreeNext();
}
makePlaceHolderBetweenTokens(prevLeaf, nextLeafToAdjust, forceReformat, tailingElement);
}
use of com.intellij.psi.impl.source.tree.TreeElement in project intellij-community by JetBrains.
the class PsiFileFactoryImpl method markGenerated.
public static void markGenerated(PsiElement element) {
final TreeElement node = (TreeElement) element.getNode();
assert node != null;
node.acceptTree(new GeneratedMarkerVisitor());
}
use of com.intellij.psi.impl.source.tree.TreeElement in project intellij-community by JetBrains.
the class PsiDirectoryImpl method updateAddedFile.
private static void updateAddedFile(@NotNull PsiFile copyPsi) throws IncorrectOperationException {
final UpdateAddedFileProcessor processor = UpdateAddedFileProcessor.forElement(copyPsi);
if (processor != null) {
final TreeElement tree = (TreeElement) SourceTreeToPsiMap.psiElementToTree(copyPsi);
if (tree != null) {
ChangeUtil.encodeInformation(tree);
}
processor.update(copyPsi, null);
if (tree != null) {
ChangeUtil.decodeInformation(tree);
}
}
}
use of com.intellij.psi.impl.source.tree.TreeElement in project intellij-community by JetBrains.
the class LowLevelSearchUtil method processElementsAtOffsets.
static boolean processElementsAtOffsets(@NotNull PsiElement scope, @NotNull StringSearcher searcher, boolean processInjectedPsi, @NotNull ProgressIndicator progress, int[] offsetsInScope, @NotNull TextOccurenceProcessor processor) {
if (offsetsInScope.length == 0)
return true;
Project project = scope.getProject();
TreeElement lastElement = null;
for (int offset : offsetsInScope) {
progress.checkCanceled();
lastElement = processTreeUp(project, processor, scope, searcher, offset, processInjectedPsi, progress, lastElement);
if (lastElement == null)
return false;
}
return true;
}
use of com.intellij.psi.impl.source.tree.TreeElement in project intellij-community by JetBrains.
the class LowLevelSearchUtil method findNextLeafElementAt.
private static TreeElement findNextLeafElementAt(ASTNode scopeNode, TreeElement last, int offset) {
int offsetR = offset;
if (last != null) {
offsetR -= last.getStartOffset() - scopeNode.getStartOffset() + last.getTextLength();
while (offsetR >= 0) {
TreeElement next = last.getTreeNext();
if (next == null) {
last = last.getTreeParent();
continue;
}
int length = next.getTextLength();
offsetR -= length;
last = next;
}
scopeNode = last;
offsetR += scopeNode.getTextLength();
}
return (LeafElement) scopeNode.findLeafElementAt(offsetR);
}
Aggregations