private void setPropertyOrIndexerModifiers(AccessorDeclarationNode accessor, EnumSet<Modifier> propertyModifiers,
                MethodBuilder methodBuilder) {
            var protectionSet = false;
            var isFinal = true;
            var modifiers = accessor.Modifiers;
            foreach (var mod in modifiers) {
                switch (mod) {
                case Public:
                    if (methodBuilder.IsPrivate || methodBuilder.IsProtected) {
                        context.addError(CompileErrorId.PublicProtectedPrivate, accessor);
                    } else {
                        methodBuilder.setPublic(true);
                        protectionSet = true;
                    }
                    break;

                case Private:
                    if (methodBuilder.IsPublic || methodBuilder.IsProtected) {
                        context.addError(CompileErrorId.PublicProtectedPrivate, accessor);
                    } else {
                        methodBuilder.setPrivate(true);
                        protectionSet = true;
                    }
                    isFinal = false;
                    break;
                    
                case Protected:
                    if (methodBuilder.IsPrivate || methodBuilder.IsPublic) {
                        context.addError(CompileErrorId.PublicProtectedPrivate, accessor);
                    } else {
                        methodBuilder.setProtected(true);
                        protectionSet = true;
                    }
                    break;
                default:
                    context.addError(CompileErrorId.UnexpectedModifier, accessor, mod.toString().toLowerCase());
                    break;
                }
            }
            foreach (var mod in propertyModifiers) {
                switch (mod) {
                case Public:
                    if (!protectionSet) {
                        methodBuilder.setPublic(true);
                    }
                    break;

                case Private:
                    if (methodBuilder.IsPublic || methodBuilder.IsProtected) {
                        context.addError(CompileErrorId.PublicProtectedPrivate, accessor);
                    } else {
                        if (!protectionSet) {
                            methodBuilder.setPrivate(true);
                        }
                    }
                    break;
                    
                case Protected:
                    if (methodBuilder.IsPublic) {
                        context.addError(CompileErrorId.PublicProtectedPrivate, accessor);
                    } else {
                        if (!protectionSet) {
                            methodBuilder.setProtected(true);
                        }
                    }
                    break;

                case Final:
                    methodBuilder.setFinal(true);
                    break;
                    
                case Abstract:
                    if (methodBuilder.IsFinal || methodBuilder.IsStatic) {
                        context.addError(CompileErrorId.FinalAbstractStaticMethod, accessor);
                    } else {
                        methodBuilder.setAbstract(true);
                    }
                    isFinal = false;
                    break;

                case Static:
                    if (methodBuilder.IsAbstract) {
                        context.addError(CompileErrorId.FinalAbstractStaticMethod, accessor);
                    } else {
                        methodBuilder.setStatic(true);
                    }
                    break;

                case Synchronized:
                    methodBuilder.setSynchronized(true);
                    break;

                case Native:
                    methodBuilder.setNative(true);
                    break;

                case Strictfp:
                    methodBuilder.setStrict(true);
                    break;

                case Virtual:
                case Override:
                    isFinal = false;
                    break;

                default:
                    context.addError(CompileErrorId.UnexpectedModifier, accessor, mod.toString().toLowerCase());
                    break;
                }
            }
            methodBuilder.setFinal(isFinal);
        }
 private void setMethodModifiers(MethodDeclarationNode methodDeclaration, MethodBuilder methodBuilder) {
     var isFinal = true;
     foreach (var modifier in methodDeclaration.Modifiers) {
         switch (modifier) {
         case Public:
             if (methodBuilder.IsPrivate || methodBuilder.IsProtected) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, methodDeclaration);
             } else {
                 methodBuilder.setPublic(true);
             }
             break;
             
         case Protected:
             if (methodBuilder.IsPrivate || methodBuilder.IsPublic) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, methodDeclaration);
             } else {
                 methodBuilder.setProtected(true);
             }
             break;
             
         case Private:
             if (methodBuilder.IsProtected || methodBuilder.IsPublic) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, methodDeclaration);
             } else {
                 methodBuilder.setPrivate(true);
                 isFinal = false;
             }
             break;
             
         case Final:
             if (methodBuilder.IsAbstract) {
                 context.addError(CompileErrorId.FinalAbstractStaticMethod, methodDeclaration);
             } else {
                 methodBuilder.setFinal(true);
             }
             break;
             
         case Abstract:
             if (methodBuilder.IsFinal || methodBuilder.IsStatic) {
                 context.addError(CompileErrorId.FinalAbstractStaticMethod, methodDeclaration);
             } else {
                 methodBuilder.setAbstract(true);
                 isFinal = false;
             }
             break;
             
         case Static:
             if (methodBuilder.IsAbstract) {
                 context.addError(CompileErrorId.FinalAbstractStaticMethod, methodDeclaration);
             } else {
                 methodBuilder.setStatic(true);
             }
             break;
             
         case Synchronized:
             methodBuilder.setSynchronized(true);
             break;
             
         case Native:
             methodBuilder.setNative(true);
             break;
             
         case Strictfp:
             methodBuilder.setStrict(true);
             break;
             
         case Virtual:
         case Override:
             // TODO: check if not private
             isFinal = false;
             break;
             
         default:
             context.addError(CompileErrorId.UnexpectedModifier, methodDeclaration, modifier.toString().toLowerCase());
             break;
         }
     }
     methodBuilder.setFinal(isFinal);
 }