private static int packCommonFlags(final int access) { int flags = 0; if ((access & Opcodes.ACC_PRIVATE) != 0) { flags |= ModifierFlags.PRIVATE_MASK; } else if ((access & Opcodes.ACC_PROTECTED) != 0) { flags |= ModifierFlags.PROTECTED_MASK; } else if ((access & Opcodes.ACC_PUBLIC) != 0) { flags |= ModifierFlags.PUBLIC_MASK; } else { flags |= ModifierFlags.PACKAGE_LOCAL_MASK; } if ((access & Opcodes.ACC_STATIC) != 0) { flags |= ModifierFlags.STATIC_MASK; } if ((access & Opcodes.ACC_FINAL) != 0) { flags |= ModifierFlags.FINAL_MASK; } return flags; }
private static int packMethodFlags(final int access, boolean isInterface) { int flags = packCommonFlags(access); if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) { flags |= ModifierFlags.SYNCHRONIZED_MASK; } if ((access & Opcodes.ACC_NATIVE) != 0) { flags |= ModifierFlags.NATIVE_MASK; } if ((access & Opcodes.ACC_ABSTRACT) != 0) { flags |= ModifierFlags.ABSTRACT_MASK; } else if (isInterface && (access & Opcodes.ACC_STATIC) == 0) { flags |= ModifierFlags.DEFENDER_MASK; } if ((access & Opcodes.ACC_STRICT) != 0) { flags |= ModifierFlags.STRICTFP_MASK; } return flags; }
public void copyModifiers(@NotNull PsiModifierListOwner modifierOwner) { int mod = 0; PsiModifierList modifierList = modifierOwner.getModifierList(); if (modifierList != null) { if (modifierList instanceof GrLightModifierList) { mod = ((GrLightModifierList)modifierList).getModifiersAsInt(); } else { for (Object o : ModifierFlags.NAME_TO_MODIFIER_FLAG_MAP.keys()) { String modifier = (String)o; if (modifierList.hasExplicitModifier(modifier)) { mod |= GrModifierListImpl.NAME_TO_MODIFIER_FLAG_MAP.get(modifier); } } } } setModifiers(mod); }
private static int packMethodFlags(final int access, boolean isInterface) { int flags = packCommonFlags(access); if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) { flags |= ModifierFlags.SYNCHRONIZED_MASK; } if ((access & Opcodes.ACC_NATIVE) != 0) { flags |= ModifierFlags.NATIVE_MASK; } if ((access & Opcodes.ACC_ABSTRACT) != 0) { flags |= ModifierFlags.ABSTRACT_MASK; } else if (isInterface) { flags |= ModifierFlags.DEFENDER_MASK; } if ((access & Opcodes.ACC_STRICT) != 0) { flags |= ModifierFlags.STRICTFP_MASK; } return flags; }
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; }
private static int packClassFlags(final int access) { int flags = packCommonFlags(access); if ((access & Opcodes.ACC_ABSTRACT) != 0) { flags |= ModifierFlags.ABSTRACT_MASK; } return flags; }
private static int packFieldFlags(final int access) { int flags = packCommonFlags(access); if ((access & Opcodes.ACC_VOLATILE) != 0) { flags |= ModifierFlags.VOLATILE_MASK; } if ((access & Opcodes.ACC_TRANSIENT) != 0) { flags |= ModifierFlags.TRANSIENT_MASK; } return flags; }
private static int requiresFlags(int access) { int flags = 0; if(isSet(access, Opcodes.ACC_TRANSITIVE)) { flags |= ModifierFlags.TRANSITIVE_MASK; } if(isSet(access, Opcodes.ACC_STATIC_PHASE)) { flags |= ModifierFlags.STATIC_MASK; } return flags; }
private static int packCommonFlags(int access) { int flags = 0; if(isSet(access, Opcodes.ACC_PRIVATE)) { flags |= ModifierFlags.PRIVATE_MASK; } else if(isSet(access, Opcodes.ACC_PROTECTED)) { flags |= ModifierFlags.PROTECTED_MASK; } else if(isSet(access, Opcodes.ACC_PUBLIC)) { flags |= ModifierFlags.PUBLIC_MASK; } else { flags |= ModifierFlags.PACKAGE_LOCAL_MASK; } if(isSet(access, Opcodes.ACC_STATIC)) { flags |= ModifierFlags.STATIC_MASK; } if(isSet(access, Opcodes.ACC_FINAL)) { flags |= ModifierFlags.FINAL_MASK; } return flags; }
private static int packClassFlags(int access) { int flags = packCommonFlags(access); if(isSet(access, Opcodes.ACC_ABSTRACT)) { flags |= ModifierFlags.ABSTRACT_MASK; } return flags; }
private static int packFieldFlags(int access) { int flags = packCommonFlags(access); if(isSet(access, Opcodes.ACC_VOLATILE)) { flags |= ModifierFlags.VOLATILE_MASK; } if(isSet(access, Opcodes.ACC_TRANSIENT)) { flags |= ModifierFlags.TRANSIENT_MASK; } return flags; }
private static int packMethodFlags(int access, boolean isInterface) { int flags = packCommonFlags(access); if(isSet(access, Opcodes.ACC_SYNCHRONIZED)) { flags |= ModifierFlags.SYNCHRONIZED_MASK; } if(isSet(access, Opcodes.ACC_NATIVE)) { flags |= ModifierFlags.NATIVE_MASK; } if(isSet(access, Opcodes.ACC_STRICT)) { flags |= ModifierFlags.STRICTFP_MASK; } if(isSet(access, Opcodes.ACC_ABSTRACT)) { flags |= ModifierFlags.ABSTRACT_MASK; } else if(isInterface && !isSet(access, Opcodes.ACC_STATIC)) { flags |= ModifierFlags.DEFAULT_MASK; } return flags; }
@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; }
@Override public boolean hasModifierProperty(@NotNull String name) { return ModifierFlags.hasModifierProperty(name, getStub().getModifiersMask()); }
private static int moduleFlags(int access) { return isSet(access, Opcodes.ACC_OPEN) ? ModifierFlags.OPEN_MASK : 0; }