use of com.intellij.psi.impl.java.stubs.PsiAnnotationStub in project intellij-community by JetBrains.
the class TypeInfo method applyAnnotations.
@NotNull
public TypeInfo applyAnnotations(@NotNull StubBase<?> owner) {
PsiModifierListStub modifierList = (PsiModifierListStub) owner.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
if (modifierList == null)
return this;
List<PsiAnnotationStub> annotationStubs = null;
for (StubElement child : modifierList.getChildrenStubs()) {
if (!(child instanceof PsiAnnotationStub))
continue;
PsiAnnotationStub annotationStub = (PsiAnnotationStub) child;
if (PsiImplUtil.isTypeAnnotation(annotationStub.getPsiElement())) {
if (annotationStubs == null)
annotationStubs = new SmartList<>();
annotationStubs.add(annotationStub);
}
}
PsiAnnotationStub[] stubArray = PsiAnnotationStub.EMPTY_ARRAY;
if (annotationStubs != null)
stubArray = annotationStubs.toArray(new PsiAnnotationStub[annotationStubs.size()]);
return new TypeInfo(text, arrayCount, isEllipsis, stubArray);
}
use of com.intellij.psi.impl.java.stubs.PsiAnnotationStub in project intellij-community by JetBrains.
the class TypeInfo method createTypeText.
@Nullable
public static String createTypeText(@NotNull TypeInfo typeInfo) {
if (typeInfo == NULL || typeInfo.text == null) {
return null;
}
if (typeInfo.arrayCount == 0 && typeInfo.myAnnotationStubs.length == 0) {
return typeInfo.text;
}
StringBuilder buf = new StringBuilder();
for (PsiAnnotationStub stub : typeInfo.myAnnotationStubs) {
buf.append(stub.getText()).append(' ');
}
buf.append(typeInfo.text);
int arrayCount = typeInfo.isEllipsis ? typeInfo.arrayCount - 1 : typeInfo.arrayCount;
for (int i = 0; i < arrayCount; i++) {
buf.append("[]");
}
if (typeInfo.isEllipsis) {
buf.append("...");
}
return internFrequentType(buf.toString());
}
Aggregations