public override void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration)
        {
            if (customEventDeclaration.HasModifier(Modifiers.Abstract))
            {
                return;
            }

            bool isStatic = customEventDeclaration.HasModifier(Modifiers.Static);

            IDictionary <string, List <EntityDeclaration> > dict = isStatic
                ? CurrentType.StaticProperties
                : CurrentType.InstanceProperties;

            var key = customEventDeclaration.Name;



            if (dict.ContainsKey(key))
            {
                dict[key].Add(customEventDeclaration);
            }
            else
            {
                dict.Add(key, new List <EntityDeclaration>(new[] { customEventDeclaration }));
            }
        }
Beispiel #2
0
 private OverloadsCollection(IEmitter emitter, CustomEventDeclaration eventDeclaration, bool remove)
 {
     this.Emitter          = emitter;
     this.Name             = eventDeclaration.Name;
     this.JsName           = Helpers.GetEventRef(eventDeclaration, emitter, remove, true);
     this.Inherit          = !eventDeclaration.HasModifier(Modifiers.Static);
     this.CancelChangeCase = true;
     this.IsSetter         = remove;
     this.Static           = eventDeclaration.HasModifier(Modifiers.Static);
     this.Member           = this.FindMember(eventDeclaration);
     this.TypeDefinition   = this.Member.DeclaringTypeDefinition;
     this.Type             = this.Member.DeclaringType;
     this.InitMembers();
     this.Emitter.OverloadsCache[eventDeclaration.GetHashCode().ToString()] = this;
 }
Beispiel #3
0
 private OverloadsCollection(IEmitter emitter, CustomEventDeclaration eventDeclaration, bool remove)
 {
     this.Emitter = emitter;
     this.Name = eventDeclaration.Name;
     this.JsName = Helpers.GetEventRef(eventDeclaration, emitter, remove, true);
     this.AltJsName = Helpers.GetEventRef(eventDeclaration, emitter, !remove, true);
     this.Inherit = !eventDeclaration.HasModifier(Modifiers.Static);
     this.CancelChangeCase = true;
     this.IsSetter = remove;
     this.Static = eventDeclaration.HasModifier(Modifiers.Static);
     this.Member = this.FindMember(eventDeclaration);
     this.TypeDefinition = this.Member.DeclaringTypeDefinition;
     this.Type = this.Member.DeclaringType;
     this.InitMembers();
     this.Emitter.OverloadsCache[eventDeclaration.GetHashCode().ToString() + remove.GetHashCode().ToString()] = this;
 }
Beispiel #4
0
 private OverloadsCollection(IEmitter emitter, CustomEventDeclaration eventDeclaration, bool remove)
 {
     this.Emitter        = emitter;
     this.Name           = eventDeclaration.Name;
     this.JsName         = Helpers.GetEventRef(eventDeclaration, emitter, remove, true);
     this.AltJsName      = Helpers.GetEventRef(eventDeclaration, emitter, !remove, true);
     this.FieldJsName    = emitter.GetEntityName(eventDeclaration);
     this.Inherit        = !eventDeclaration.HasModifier(Modifiers.Static);
     this.IsSetter       = remove;
     this.Static         = eventDeclaration.HasModifier(Modifiers.Static);
     this.Member         = this.FindMember(eventDeclaration);
     this.FieldJsName    = Helpers.GetEventRef(this.Member, emitter, true, true, true, false, true);;
     this.TypeDefinition = this.Member.DeclaringTypeDefinition;
     this.Type           = this.Member.DeclaringType;
     this.InitMembers();
     this.Emitter.Cache.AddNode(eventDeclaration, remove, this);
 }
Beispiel #5
0
            public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
            {
                if (eventDeclaration.HasModifier(Modifiers.Static) ||
                    eventDeclaration.HasModifier(Modifiers.Virtual) ||
                    eventDeclaration.HasModifier(Modifiers.Override) ||
                    eventDeclaration.HasModifier(Modifiers.New) ||
                    eventDeclaration.Attributes.Any())
                {
                    return;
                }

                if (IsEmpty(eventDeclaration.RemoveAccessor) && IsEmpty(eventDeclaration.AddAccessor))
                {
                    return;
                }


                var resolved = ctx.Resolve(eventDeclaration) as MemberResolveResult;

                if (resolved == null || SkipMember(resolved.Member))
                {
                    return;
                }
                var isImplementingInterface = resolved.Member.ImplementedInterfaceMembers.Any();

                if (isImplementingInterface)
                {
                    return;
                }

                if (!eventDeclaration.AddAccessor.IsNull && StaticVisitor.UsesNotStaticMember(ctx, eventDeclaration.AddAccessor.Body) ||
                    !eventDeclaration.RemoveAccessor.IsNull && StaticVisitor.UsesNotStaticMember(ctx, eventDeclaration.RemoveAccessor.Body))
                {
                    return;
                }

                AddIssue(new CodeIssue(eventDeclaration.NameToken.StartLocation, eventDeclaration.NameToken.EndLocation,
                                       string.Format(ctx.TranslateString("Event '{0}' can be made static."), eventDeclaration.Name),
                                       string.Format(ctx.TranslateString("Make '{0}' static"), eventDeclaration.Name),
                                       script => script.ChangeModifier(eventDeclaration, eventDeclaration.Modifiers | Modifiers.Static))
                {
                    IssueMarker = IssueMarker.DottedLine
                });
            }
Beispiel #6
0
        public override void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration)
        {
            if (customEventDeclaration.HasModifier(Modifiers.Abstract))
            {
                return;
            }

            bool isStatic = customEventDeclaration.HasModifier(Modifiers.Static);

            IDictionary <string, List <EntityDeclaration> > dict = isStatic
                ? CurrentType.StaticProperties
                : CurrentType.InstanceProperties;

            var key = customEventDeclaration.Name;

            if (dict.ContainsKey(key))
            {
                dict[key].Add(customEventDeclaration);
            }
            else
            {
                dict.Add(key, new List <EntityDeclaration>(new[] { customEventDeclaration }));
            }

            var rr = this.Resolver.ResolveNode(customEventDeclaration, null) as MemberResolveResult;

            if (OverloadsCollection.NeedCreateAlias(rr))
            {
                var config = rr.Member.IsStatic
                ? CurrentType.StaticConfig
                : CurrentType.InstanceConfig;
                config.Alias.Add(new TypeConfigItem {
                    Entity = customEventDeclaration
                });
            }
        }
        public override void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration)
        {
            if (customEventDeclaration.HasModifier(Modifiers.Abstract))
            {
                return;
            }

            bool isStatic = customEventDeclaration.HasModifier(Modifiers.Static);

            IDictionary<string, List<EntityDeclaration>> dict = isStatic
                ? CurrentType.StaticProperties
                : CurrentType.InstanceProperties;

            var key = customEventDeclaration.Name;

            if (dict.ContainsKey(key))
                {
                dict[key].Add(customEventDeclaration);
                }
                else
                {
                dict.Add(key, new List<EntityDeclaration>(new[] { customEventDeclaration }));
            }
        }