Пример #1
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 }));
            }
        }
Пример #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;
 }
Пример #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;
 }
Пример #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);
 }
Пример #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
                });
            }
Пример #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
                });
            }
        }
Пример #7
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 }));
            }
        }