use of com.intellij.psi.PsiAnnotation in project kotlin by JetBrains.
the class LightClassAnnotationsTest method doTest.
private void doTest(@NotNull String fqName) {
PsiClass psiClass = finder.findClass(fqName, GlobalSearchScope.allScope(getProject()));
if (!(psiClass instanceof KtLightClass)) {
throw new IllegalStateException("Not a light class: " + psiClass + " (" + fqName + ")");
}
PsiModifierList modifierList = psiClass.getModifierList();
assert modifierList != null : "No modifier list for " + psiClass.getText();
StringBuilder sb = new StringBuilder();
for (PsiAnnotation annotation : modifierList.getAnnotations()) {
sb.append(annotation.getText()).append("\n");
}
KotlinTestUtils.assertEqualsToFile(new File(testDir, getTestName(false) + ".annotations.txt"), sb.toString());
}
use of com.intellij.psi.PsiAnnotation in project kotlin by JetBrains.
the class PsiBasedExternalAnnotationResolver method findExternalAnnotation.
@Nullable
@Override
public JavaAnnotation findExternalAnnotation(@NotNull JavaAnnotationOwner owner, @NotNull FqName fqName) {
if (owner instanceof JavaModifierListOwnerImpl) {
PsiModifierListOwner psiOwner = ((JavaModifierListOwnerImpl) owner).getPsi();
PsiAnnotation psiAnnotation = ExternalAnnotationsManager.getInstance(psiOwner.getProject()).findExternalAnnotation(psiOwner, fqName.asString());
return psiAnnotation == null ? null : new JavaAnnotationImpl(psiAnnotation);
}
return null;
}
use of com.intellij.psi.PsiAnnotation in project intellij-community by JetBrains.
the class NullityAnnotationModifier method modifyLowerBoundAnnotations.
@Nullable
@Override
public TypeAnnotationProvider modifyLowerBoundAnnotations(@NotNull PsiType lowerBound, @NotNull PsiType upperBound) {
PsiAnnotation[] lowerAnnotations = lowerBound.getAnnotations();
PsiAnnotation nullable = findNullable(lowerAnnotations);
if (nullable != null && findNullable(upperBound.getAnnotations()) == null) {
return removeAnnotation(lowerAnnotations, nullable);
}
return null;
}
use of com.intellij.psi.PsiAnnotation 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;
}
}
use of com.intellij.psi.PsiAnnotation in project android by JetBrains.
the class ResolveTypedIntegerCommand method action.
@Override
public void action() {
// TODO: see if it is possible to cache this evaluation
// if (myIsEvaluated) return;
DebugProcess debugProcess = myEvaluationContext.getDebugProcess();
if (!(debugProcess instanceof DebugProcessImpl)) {
return;
}
final DebuggerContextImpl debuggerContext = ((DebugProcessImpl) debugProcess).getDebuggerContext();
PsiAnnotation annotation = ApplicationManager.getApplication().runReadAction(new Computable<PsiAnnotation>() {
@Override
public PsiAnnotation compute() {
try {
return getAnnotation(debuggerContext);
} catch (IndexNotReadyException e) {
return null;
}
}
});
if (annotation != null) {
ResourceIdResolver resolver = ServiceManager.getService(myEvaluationContext.getProject(), ResourceIdResolver.class);
DynamicResourceIdResolver resolver1 = new DynamicResourceIdResolver(myEvaluationContext, resolver);
myResult = AnnotationsRenderer.render(resolver1, annotation, ((IntegerValue) myValue).value());
}
evaluationResult("");
}
Aggregations