use of com.intellij.psi.impl.source.DummyHolder in project intellij-community by JetBrains.
the class PsiJavaParserFacadeImpl method createModuleFromText.
@NotNull
@Override
public PsiJavaModule createModuleFromText(@NotNull String text) throws IncorrectOperationException {
DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, MODULE, LanguageLevel.JDK_1_9), null);
PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiJavaModule))
throw new IncorrectOperationException("Incorrect module declaration '" + text + "'");
return (PsiJavaModule) element;
}
use of com.intellij.psi.impl.source.DummyHolder in project intellij-community by JetBrains.
the class PsiJavaParserFacadeImpl method createAnnotationFromText.
@NotNull
@Override
public PsiAnnotation createAnnotationFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, ANNOTATION, level(context)), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiAnnotation)) {
throw new IncorrectOperationException("Incorrect annotation '" + text + "'");
}
return (PsiAnnotation) element;
}
use of com.intellij.psi.impl.source.DummyHolder in project intellij-community by JetBrains.
the class PsiJavaParserFacadeImpl method createExpressionFromText.
@NotNull
@Override
public PsiExpression createExpressionFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, EXPRESSION, level(context)), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiExpression)) {
throw new IncorrectOperationException("Incorrect expression '" + text + "'");
}
return (PsiExpression) element;
}
use of com.intellij.psi.impl.source.DummyHolder in project intellij-community by JetBrains.
the class PsiJavaParserFacadeImpl method createStatementFromText.
@NotNull
@Override
public PsiStatement createStatementFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, STATEMENT, level(context)), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiStatement)) {
throw new IncorrectOperationException("Incorrect statement '" + text + "'");
}
return (PsiStatement) element;
}
use of com.intellij.psi.impl.source.DummyHolder in project intellij-community by JetBrains.
the class PsiJavaParserFacadeImpl method createReferenceFromText.
@NotNull
@Override
public PsiJavaCodeReferenceElement createReferenceFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
final boolean isStaticImport = context instanceof PsiImportStaticStatement && !((PsiImportStaticStatement) context).isOnDemand();
final boolean mayHaveDiamonds = context instanceof PsiNewExpression && PsiUtil.getLanguageLevel(context).isAtLeast(LanguageLevel.JDK_1_7);
final JavaParserUtil.ParserWrapper wrapper = isStaticImport ? STATIC_IMPORT_REF : mayHaveDiamonds ? DIAMOND_REF : REFERENCE;
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, wrapper, level(context)), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiJavaCodeReferenceElement)) {
throw new IncorrectOperationException("Incorrect reference '" + text + "'");
}
return (PsiJavaCodeReferenceElement) element;
}
Aggregations