@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); }
@Override @Nullable public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { if(isSet(access, Opcodes.ACC_SYNTHETIC)) { return null; } if(name == null) { return null; } byte flags = PsiFieldStubImpl.packFlags(isSet(access, Opcodes.ACC_ENUM), isSet(access, Opcodes.ACC_DEPRECATED), false, false); TypeInfo type = fieldType(desc, signature); String initializer = constToString(value, type.text, false, myMapping); PsiFieldStub stub = new PsiFieldStubImpl(myResult, name, type, initializer, flags); PsiModifierListStub modList = new PsiModifierListStubImpl(stub, packFieldFlags(access)); return new FieldAnnotationCollectingVisitor(modList, myMapping); }
private MethodAnnotationCollectingVisitor(PsiMethodStub owner, PsiModifierListStub modList, int ignoreCount, int paramIgnoreCount, int paramCount, PsiParameterStubImpl[] paramStubs, Function<String, String> mapping) { super(ASM_API); myOwner = owner; myModList = modList; myIgnoreCount = ignoreCount; myParamIgnoreCount = paramIgnoreCount; myParamCount = paramCount; myParamStubs = paramStubs; myMapping = mapping; }
public static boolean isStaticNonPrivateMember(@NotNull StubElement<?> stub) { StubElement<PsiModifierList> type = stub.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST); if(!(type instanceof PsiModifierListStub)) { return false; } int mask = ((PsiModifierListStub) type).getModifiersMask(); if(ModifierFlags.hasModifierProperty(PsiModifier.PRIVATE, mask)) { return false; } if(ModifierFlags.hasModifierProperty(PsiModifier.STATIC, mask)) { return true; } return stub instanceof PsiFieldStub && stub.getStubType() == JavaElementType.ENUM_CONSTANT || stub.getParentStub() instanceof PsiClassStub && ((PsiClassStub) stub.getParentStub()).isInterface(); }
private Set<String> calcExplicitModifiers() { Set<String> explicitModifiers = ContainerUtil.newHashSet(); PsiModifierListStub stub = getGreenStub(); if(stub != null) { int mask = stub.getModifiersMask(); for(int i = 0; i < 31; i++) { int flag = 1 << i; if(BitUtil.isSet(mask, flag)) { ContainerUtil.addIfNotNull(explicitModifiers, ModifierFlags.MODIFIER_FLAG_TO_NAME_MAP.get(flag)); } } } else { for(ASTNode child : getNode().getChildren(null)) { ContainerUtil.addIfNotNull(explicitModifiers, KEYWORD_TYPE_TO_NAME_MAP.get(child.getElementType())); } } return explicitModifiers; }
@Override public PsiModifierListStub getModList() { for (StubElement child : getChildrenStubs()) { if (child instanceof PsiModifierListStub) { return (PsiModifierListStub)child; } } return null; }
@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); }
@Override public PsiModifierListStub getModList() { for(StubElement child : getChildrenStubs()) { if(child instanceof PsiModifierListStub) { return (PsiModifierListStub) child; } } return null; }
@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); }
@Override public boolean hasExplicitModifier(@NotNull String name) { PsiModifierListStub stub = getGreenStub(); if(stub != null) { return BitUtil.isSet(stub.getModifiersMask(), ModifierFlags.NAME_TO_MODIFIER_FLAG_MAP.get(name)); } final CompositeElement tree = (CompositeElement) getNode(); final IElementType type = NAME_TO_KEYWORD_TYPE_MAP.get(name); return tree.findChildByType(type) != null; }
public ClsModifierListImpl(final PsiModifierListStub stub) { super(stub); }
public PsiModifierListImpl(final PsiModifierListStub stub) { super(stub, JavaStubElementTypes.MODIFIER_LIST); }
public ClsModifierListImpl(PsiModifierListStub stub) { super(stub); }
private FieldAnnotationCollectingVisitor(PsiModifierListStub modList, Function<String, String> mapping) { super(ASM_API); myModList = modList; myMapping = mapping; }