use of com.intellij.psi.impl.source.tree.TreeElement in project intellij-community by JetBrains.
the class XmlDocumentImpl method addInternal.
@Override
public TreeElement addInternal(final TreeElement first, final ASTNode last, final ASTNode anchor, final Boolean before) {
final PomModel model = PomManager.getModel(getProject());
final XmlAspect aspect = model.getModelAspect(XmlAspect.class);
final TreeElement[] holder = new TreeElement[1];
try {
model.runTransaction(new PomTransactionBase(this, aspect) {
@Override
public PomModelEvent runInner() {
holder[0] = XmlDocumentImpl.super.addInternal(first, last, anchor, before);
return XmlDocumentChangedImpl.createXmlDocumentChanged(model, XmlDocumentImpl.this);
}
});
} catch (IncorrectOperationException ignored) {
}
return holder[0];
}
use of com.intellij.psi.impl.source.tree.TreeElement in project intellij-community by JetBrains.
the class XmlElementImpl method findElementByTokenType.
public XmlElement findElementByTokenType(final IElementType type) {
final XmlElement[] result = new XmlElement[1];
result[0] = null;
processElements(new PsiElementProcessor() {
@Override
public boolean execute(@NotNull PsiElement element) {
if (element instanceof TreeElement && ((ASTNode) element).getElementType() == type) {
result[0] = (XmlElement) element;
return false;
}
return true;
}
}, this);
return result[0];
}
use of com.intellij.psi.impl.source.tree.TreeElement in project intellij-community by JetBrains.
the class AbstractXmlBlock method findChildAfter.
@Nullable
protected static ASTNode findChildAfter(@NotNull final ASTNode child, final int endOffset) {
TreeElement fileNode = TreeUtil.getFileElement((TreeElement) child);
final LeafElement leaf = fileNode.findLeafElementAt(endOffset);
if (leaf != null && leaf.getStartOffset() == endOffset && endOffset > 0) {
return fileNode.findLeafElementAt(endOffset - 1);
}
return leaf;
}
use of com.intellij.psi.impl.source.tree.TreeElement in project intellij-elixir by KronicDeth.
the class BeamFileImpl method getMirror.
/**
* Returns the corresponding PSI element in a decompiled file created by IDEA from
* the library element.
*
* @return the counterpart of the element in decompiled file.
*/
@Override
public PsiElement getMirror() {
TreeElement mirrorTreeElement = mirrorFileElement;
if (mirrorTreeElement == null) {
synchronized (mirrorLock) {
mirrorTreeElement = mirrorFileElement;
if (mirrorTreeElement == null) {
VirtualFile file = getVirtualFile();
String fileName = file.getNameWithoutExtension() + ".ex";
final Document document = FileDocumentManager.getInstance().getDocument(file);
assert document != null : file.getUrl();
CharSequence mirrorText = document.getImmutableCharSequence();
PsiFileFactory factory = PsiFileFactory.getInstance(getManager().getProject());
PsiFile mirror = factory.createFileFromText(fileName, ElixirLanguage.INSTANCE, mirrorText, false, false);
mirrorTreeElement = SourceTreeToPsiMap.psiToTreeNotNull(mirror);
try {
final TreeElement finalMirrorTreeElement = mirrorTreeElement;
ProgressManager.getInstance().executeNonCancelableSection(new Runnable() {
public void run() {
setMirror(finalMirrorTreeElement);
putUserData(MODULE_DOCUMENT_LINK_KEY, document);
}
});
} catch (InvalidMirrorException e) {
//noinspection ThrowableResultOfMethodCallIgnored
LOGGER.error(file.getUrl(), e);
}
((PsiFileImpl) mirror).setOriginalFile(this);
mirrorFileElement = mirrorTreeElement;
}
}
}
return mirrorTreeElement.getPsi();
}
use of com.intellij.psi.impl.source.tree.TreeElement in project WebStormRequireJsPlugin by Fedott.
the class RequirejsProjectComponent method parsePackages.
private void parsePackages(TreeElement node) {
TokenSet tokenSet = TokenSet.create(JSElementTypes.OBJECT_LITERAL_EXPRESSION, JSElementTypes.LITERAL_EXPRESSION);
TreeElement packageNode = (TreeElement) node.findChildByType(tokenSet);
parsePackage(packageNode);
}
Aggregations