use of com.intellij.psi.impl.source.DummyHolder in project intellij-community by JetBrains.
the class PsiJavaParserFacadeImpl method createFieldFromText.
@NotNull
@Override
public PsiField createFieldFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, DECLARATION, level(context)), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiField)) {
throw new IncorrectOperationException("Incorrect field '" + text + "'");
}
return (PsiField) element;
}
use of com.intellij.psi.impl.source.DummyHolder in project intellij-community by JetBrains.
the class PsiJavaParserFacadeImpl method createParameterFromText.
@NotNull
@Override
public PsiParameter createParameterFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, PARAMETER, level(context)), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiParameter)) {
throw new IncorrectOperationException("Incorrect parameter '" + text + "'");
}
return (PsiParameter) element;
}
use of com.intellij.psi.impl.source.DummyHolder in project intellij-community by JetBrains.
the class PsiJavaParserFacadeImpl method createCodeBlockFromText.
@NotNull
@Override
public PsiCodeBlock createCodeBlockFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, CODE_BLOCK, level(context), true), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiCodeBlock)) {
throw new IncorrectOperationException("Incorrect code block '" + text + "'");
}
return (PsiCodeBlock) element;
}
use of com.intellij.psi.impl.source.DummyHolder in project intellij-community by JetBrains.
the class PsiJavaParserFacadeImpl method createEnumConstantFromText.
@NotNull
@Override
public PsiEnumConstant createEnumConstantFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, ENUM_CONSTANT, level(context)), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiEnumConstant)) {
throw new IncorrectOperationException("Incorrect enum constant '" + text + "'");
}
return (PsiEnumConstant) element;
}
use of com.intellij.psi.impl.source.DummyHolder in project intellij-community by JetBrains.
the class ClsParsingUtil method createMemberValueFromText.
public static PsiAnnotationMemberValue createMemberValueFromText(@NotNull String text, @NotNull PsiManager manager, @NotNull ClsElementImpl parent) {
LanguageLevel level = PsiUtil.getLanguageLevel(parent);
DummyHolder holder = DummyHolderFactory.createHolder(manager, new JavaDummyElement(text, ANNOTATION_VALUE, level), null);
PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiAnnotationMemberValue)) {
LOG.error("Could not parse initializer:'" + text + "'");
return null;
}
return getMemberValue(element, parent);
}
Aggregations