Пример #1
0
  @NotNull
  public static Modality resolveModalityFromModifiers(
      @Nullable JetModifierList modifierList, @NotNull Modality defaultModality) {
    if (modifierList == null) return defaultModality;
    boolean hasAbstractModifier = modifierList.hasModifier(ABSTRACT_KEYWORD);
    boolean hasOverrideModifier = modifierList.hasModifier(OVERRIDE_KEYWORD);

    if (modifierList.hasModifier(SEALED_KEYWORD)) {
      return Modality.SEALED;
    }
    if (modifierList.hasModifier(OPEN_KEYWORD)) {
      if (hasAbstractModifier || defaultModality == Modality.ABSTRACT) {
        return Modality.ABSTRACT;
      }
      return Modality.OPEN;
    }
    if (hasAbstractModifier) {
      return Modality.ABSTRACT;
    }
    boolean hasFinalModifier = modifierList.hasModifier(FINAL_KEYWORD);
    if (hasOverrideModifier && !hasFinalModifier && !(defaultModality == Modality.ABSTRACT)) {
      return Modality.OPEN;
    }
    if (hasFinalModifier) {
      return Modality.FINAL;
    }
    return defaultModality;
  }
Пример #2
0
 public static Visibility resolveVisibilityFromModifiers(
     @Nullable JetModifierList modifierList, @NotNull Visibility defaultVisibility) {
   if (modifierList == null) return defaultVisibility;
   if (modifierList.hasModifier(PRIVATE_KEYWORD)) return Visibilities.PRIVATE;
   if (modifierList.hasModifier(PUBLIC_KEYWORD)) return Visibilities.PUBLIC;
   if (modifierList.hasModifier(PROTECTED_KEYWORD)) return Visibilities.PROTECTED;
   if (modifierList.hasModifier(INTERNAL_KEYWORD)) return Visibilities.INTERNAL;
   return defaultVisibility;
 }
Пример #3
0
 @NotNull
 public Map<JetModifierKeywordToken, PsiElement> getTokensCorrespondingToModifiers(
     @NotNull JetModifierList modifierList,
     @NotNull Collection<JetModifierKeywordToken> possibleModifiers) {
   Map<JetModifierKeywordToken, PsiElement> tokens = Maps.newHashMap();
   for (JetModifierKeywordToken modifier : possibleModifiers) {
     if (modifierList.hasModifier(modifier)) {
       tokens.put(modifier, modifierList.getModifier(modifier));
     }
   }
   return tokens;
 }
Пример #4
0
 public static boolean isInnerClass(@Nullable JetModifierList modifierList) {
   return modifierList != null && modifierList.hasModifier(INNER_KEYWORD);
 }