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