use of com.intellij.psi.impl.source.JavaDummyElement in project intellij-community by JetBrains.
the class PsiJavaParserFacadeImpl method createMethodFromText.
@NotNull
@Override
public PsiMethod createMethodFromText(@NotNull final String text, @Nullable final PsiElement context, final LanguageLevel level) throws IncorrectOperationException {
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, DECLARATION, level), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiMethod)) {
throw newException("Incorrect method '" + text + "'", holder);
}
return (PsiMethod) element;
}
use of com.intellij.psi.impl.source.JavaDummyElement 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.JavaDummyElement 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.JavaDummyElement 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.JavaDummyElement 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;
}
Aggregations