Search in sources :

Example 1 with PsiModifierListStub

use of com.intellij.psi.impl.java.stubs.PsiModifierListStub in project intellij-community by JetBrains.

the class PsiModifierListImpl method calcExplicitModifiers.

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;
}
Also used : PsiModifierListStub(com.intellij.psi.impl.java.stubs.PsiModifierListStub) ASTNode(com.intellij.lang.ASTNode)

Example 2 with PsiModifierListStub

use of com.intellij.psi.impl.java.stubs.PsiModifierListStub 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);
}
Also used : PsiAnnotationStub(com.intellij.psi.impl.java.stubs.PsiAnnotationStub) PsiModifierListStub(com.intellij.psi.impl.java.stubs.PsiModifierListStub) StubElement(com.intellij.psi.stubs.StubElement) SmartList(com.intellij.util.SmartList) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with PsiModifierListStub

use of com.intellij.psi.impl.java.stubs.PsiModifierListStub in project intellij-community by JetBrains.

the class PsiModifierListImpl method hasExplicitModifier.

@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;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiModifierListStub(com.intellij.psi.impl.java.stubs.PsiModifierListStub) CompositeElement(com.intellij.psi.impl.source.tree.CompositeElement)

Aggregations

PsiModifierListStub (com.intellij.psi.impl.java.stubs.PsiModifierListStub)3 ASTNode (com.intellij.lang.ASTNode)1 PsiAnnotationStub (com.intellij.psi.impl.java.stubs.PsiAnnotationStub)1 CompositeElement (com.intellij.psi.impl.source.tree.CompositeElement)1 StubElement (com.intellij.psi.stubs.StubElement)1 IElementType (com.intellij.psi.tree.IElementType)1 SmartList (com.intellij.util.SmartList)1 NotNull (org.jetbrains.annotations.NotNull)1