public ClsAnnotationImpl(final PsiAnnotationStub stub) { super(stub); myReferenceElement = new AtomicNotNullLazyValue<ClsJavaCodeReferenceElementImpl>() { @NotNull @Override protected ClsJavaCodeReferenceElementImpl compute() { String annotationText = getStub().getText(); int index = annotationText.indexOf('('); String refText = index > 0 ? annotationText.substring(1, index) : annotationText.substring(1); return new ClsJavaCodeReferenceElementImpl(ClsAnnotationImpl.this, refText); } }; myParameterList = new AtomicNotNullLazyValue<ClsAnnotationParameterListImpl>() { @NotNull @Override protected ClsAnnotationParameterListImpl compute() { PsiNameValuePair[] attrs = getStub().getText().indexOf('(') > 0 ? PsiTreeUtil.getRequiredChildOfType(getStub().getPsiElement(), PsiAnnotationParameterList.class).getAttributes() : PsiNameValuePair.EMPTY_ARRAY; return new ClsAnnotationParameterListImpl(ClsAnnotationImpl.this, attrs); } }; }
@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<PsiAnnotationStub>(); 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); }
public ClsAnnotationImpl(final PsiAnnotationStub stub) { super(stub); myReferenceElement = new AtomicNotNullLazyValue<ClsJavaCodeReferenceElementImpl>() { @NotNull @Override protected ClsJavaCodeReferenceElementImpl compute() { String text = PsiTreeUtil.getRequiredChildOfType(getStub().getPsiElement(), PsiJavaCodeReferenceElement.class).getText(); return new ClsJavaCodeReferenceElementImpl(ClsAnnotationImpl.this, text); } }; myParameterList = new AtomicNotNullLazyValue<ClsAnnotationParameterListImpl>() { @NotNull @Override protected ClsAnnotationParameterListImpl compute() { PsiAnnotationParameterList paramList = PsiTreeUtil.getRequiredChildOfType(getStub().getPsiElement(), PsiAnnotationParameterList.class); return new ClsAnnotationParameterListImpl(ClsAnnotationImpl.this, paramList.getAttributes()); } }; }
@NotNull public static TypeInfo readTYPE(@NotNull StubInputStream record) throws IOException { int flags = 0xFF & record.readByte(); if(flags == FREQUENT_INDEX_MASK) { return NULL; } int frequentIndex = FREQUENT_INDEX_MASK & flags; byte arrayCount = isSet(flags, HAS_ARRAY_COUNT) ? record.readByte() : 0; boolean hasEllipsis = isSet(flags, HAS_ELLIPSIS); String text = frequentIndex == 0 ? StringRef.toString(record.readName()) : ourIndexFrequentType[frequentIndex]; return new TypeInfo(text, arrayCount, hasEllipsis, PsiAnnotationStub.EMPTY_ARRAY); }
@Override @NotNull public List<PsiAnnotationStub> getAnnotations() { List<StubElement> children = getChildrenStubs(); return ContainerUtil.mapNotNull(children, new Function<StubElement, PsiAnnotationStub>() { @Override public PsiAnnotationStub fun(StubElement stubElement) { return stubElement instanceof PsiAnnotationStub ? (PsiAnnotationStub)stubElement : null; } }); }
@NotNull public static TypeInfo readTYPE(@NotNull StubInputStream record) throws IOException { int flags = 0xFF & record.readByte(); if (flags == FREQUENT_INDEX_MASK) { return NULL; } int frequentIndex = FREQUENT_INDEX_MASK & flags; byte arrayCount = isSet(flags, HAS_ARRAY_COUNT) ? record.readByte() : 0; boolean hasEllipsis = isSet(flags, HAS_ELLIPSIS); String text = frequentIndex == 0 ? StringRef.toString(record.readName()) : ourIndexFrequentType[frequentIndex]; return new TypeInfo(text, arrayCount, hasEllipsis, PsiAnnotationStub.EMPTY_ARRAY); }
@Override public PsiJavaCodeReferenceElement getNameReferenceElement() { PsiAnnotationStub stub = getStub(); if (stub != null) { return PsiTreeUtil.getRequiredChildOfType(stub.getPsiElement(), PsiJavaCodeReferenceElement.class); } return PsiTreeUtil.getChildOfType(this, PsiJavaCodeReferenceElement.class); }
@NotNull public TypeInfo applyAnnotations(@NotNull StubBase<?> owner) { PsiModifierListStub modifierList = (PsiModifierListStub)owner.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST); if (modifierList == null) return this; List<PsiAnnotationStub> annotationStubs = ContainerUtil.newArrayList(); for (StubElement child : modifierList.getChildrenStubs()) { if (!(child instanceof PsiAnnotationStub)) continue; PsiAnnotationStub annotationStub = (PsiAnnotationStub)child; if (PsiImplUtil.findApplicableTarget(annotationStub.getPsiElement(), TargetType.TYPE_USE) == TargetType.TYPE_USE) { annotationStubs.add(annotationStub); } } return new TypeInfo(text, arrayCount, isEllipsis, annotationStubs); }
@NotNull public static TypeInfo readTYPE(@NotNull StubInputStream record) throws IOException { int flags = 0xFF & record.readByte(); if (flags == FREQUENT_INDEX_MASK) { return NULL; } int frequentIndex = FREQUENT_INDEX_MASK & flags; byte arrayCount = isSet(flags, HAS_ARRAY_COUNT) ? record.readByte() : 0; boolean hasEllipsis = isSet(flags, HAS_ELLIPSIS); StringRef text = frequentIndex == 0 ? record.readName() : StringRef.fromString(ourIndexFrequentType[frequentIndex]); return new TypeInfo(text, arrayCount, hasEllipsis, ContainerUtil.<PsiAnnotationStub>emptyList()); }
public TypeInfo(String text, byte arrayCount, boolean ellipsis, @NotNull PsiAnnotationStub[] annotationStubs) { this.text = text == null ? null : internFrequentType(text); this.arrayCount = arrayCount; this.isEllipsis = ellipsis; myAnnotationStubs = annotationStubs; }
@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<PsiAnnotationStub>(); } 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); }
public PsiAnnotationImpl(final PsiAnnotationStub stub) { super(stub, JavaStubElementTypes.ANNOTATION); }
public TypeInfo(String text, byte arrayCount, boolean ellipsis, @NotNull List<PsiAnnotationStub> annotationStubs) { this(StringRef.fromString(text == null ? null : internFrequentType(text)), arrayCount, ellipsis, annotationStubs); }
private TypeInfo(StringRef text, byte arrayCount, boolean isEllipsis, @NotNull List<PsiAnnotationStub> annotationStubs) { this.text = text; this.arrayCount = arrayCount; this.isEllipsis = isEllipsis; myAnnotationStubs = annotationStubs; }
@Override public PsiJavaCodeReferenceElement getNameReferenceElement() { PsiAnnotationStub stub = getStub(); return PsiTreeUtil.getChildOfType(stub != null ? stub.getPsiElement() : this, PsiJavaCodeReferenceElement.class); }