Search in sources :

Example 1 with PsiJavaParserFacade

use of com.intellij.psi.PsiJavaParserFacade in project intellij-community by JetBrains.

the class PsiAnnotationStubImpl method getPsiElement.

@Override
public PsiAnnotation getPsiElement() {
    PsiAnnotation annotation = SoftReference.dereference(myParsedFromRepository);
    if (annotation != null)
        return annotation;
    String text = getText();
    try {
        PsiJavaParserFacade facade = JavaPsiFacade.getInstance(getProject()).getParserFacade();
        annotation = facade.createAnnotationFromText(text, getPsi());
        myParsedFromRepository = new SoftReference<>(annotation);
        return annotation;
    } catch (IncorrectOperationException e) {
        LOG.error("Bad annotation in repository!", e);
        return null;
    }
}
Also used : PsiJavaParserFacade(com.intellij.psi.PsiJavaParserFacade) IncorrectOperationException(com.intellij.util.IncorrectOperationException) PsiAnnotation(com.intellij.psi.PsiAnnotation)

Example 2 with PsiJavaParserFacade

use of com.intellij.psi.PsiJavaParserFacade in project intellij-community by JetBrains.

the class PsiImportStatementStubImpl method createReference.

@Nullable
private PsiJavaCodeReferenceElement createReference() {
    final String refText = getImportReferenceText();
    if (refText == null)
        return null;
    final PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(getProject()).getParserFacade();
    try {
        return parserFacade.createReferenceFromText(refText, getPsi());
    } catch (IncorrectOperationException e) {
        return null;
    }
}
Also used : PsiJavaParserFacade(com.intellij.psi.PsiJavaParserFacade) IncorrectOperationException(com.intellij.util.IncorrectOperationException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiJavaParserFacade (com.intellij.psi.PsiJavaParserFacade)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 PsiAnnotation (com.intellij.psi.PsiAnnotation)1 Nullable (org.jetbrains.annotations.Nullable)1