/// <summary>
 /// Creates an event symbol that can be used to describe an event declaration.
 /// </summary>
 public static IEventSymbol CreateEventSymbol(
     IList<AttributeData> attributes, Accessibility accessibility,
     DeclarationModifiers modifiers, ITypeSymbol type,
     IEventSymbol explicitInterfaceSymbol, string name,
     IMethodSymbol addMethod = null, IMethodSymbol removeMethod = null, IMethodSymbol raiseMethod = null)
 {
     var result = new CodeGenerationEventSymbol(null, attributes, accessibility, modifiers, type, explicitInterfaceSymbol, name, addMethod, removeMethod, raiseMethod);
     CodeGenerationEventInfo.Attach(result, modifiers.IsUnsafe);
     return result;
 }
 protected override void ReadSymbol(IEventSymbol eventSymbol)
 {
     var @event = new Event(eventSymbol.Type, eventSymbol.Name)
     {
         IsAbstract = eventSymbol.IsAbstract,
         IsOverride = eventSymbol.IsOverride,
         IsInternal = eventSymbol.DeclaredAccessibility.HasFlag(Accessibility.Internal),
         Documentation = new DocumentationComment(eventSymbol.GetDocumentationCommentXml())
     };
     _events.AddEvent(@event);
 }
Beispiel #3
0
 public override void VisitEvent(IEventSymbol symbol)
 {
     if (_finished || _symbolPredicate == null || _symbolPredicate(symbol))
     {
         AddDocumentForMember(symbol, true, new[]
         {
             Metadata.Create(MetadataKeys.SpecificKind, (k, m) => symbol.Kind.ToString()),
             Metadata.Create(MetadataKeys.Type, DocumentFor(symbol.Type)),
             Metadata.Create(MetadataKeys.Overridden, DocumentFor(symbol.OverriddenEvent))
         });
     }
 }
Beispiel #4
0
        private SDEvent GetParsedEvent(IEventSymbol eve)
        {
            var sdEvent = new SDEvent(eve.GetIdentifier())
            {
                Name = eve.Name,
                DeclaringType = _typeRefParser.GetParsedTypeReference(eve.ContainingType),
                Accessibility = eve.DeclaredAccessibility.ToString().ToLower(),
                Documentations = DocumentationParser.ParseDocumentation(eve)
            };

            ParserOptions.SDRepository.AddMember(sdEvent);
            return sdEvent;
        }
Beispiel #5
0
        internal static CompilationUnitSyntax AddEventTo(
            CompilationUnitSyntax destination,
            IEventSymbol @event,
            CodeGenerationOptions options,
            IList<bool> availableIndices)
        {
            var declaration = GenerateEventDeclaration(@event, CodeGenerationDestination.CompilationUnit, options);

            // Place the event depending on its shape.  Field style events go with fields, property
            // style events go with properties.  If there 
            var members = Insert(destination.Members, declaration, options, availableIndices,
                after: list => AfterMember(list, declaration), before: list => BeforeMember(list, declaration));
            return destination.WithMembers(members.ToSyntaxList());
        }
Beispiel #6
0
        internal static TypeDeclarationSyntax AddEventTo(
            TypeDeclarationSyntax destination,
            IEventSymbol @event,
            CodeGenerationOptions options,
            IList<bool> availableIndices)
        {
            var declaration = GenerateEventDeclaration(@event, GetDestination(destination), options);

            var members = Insert(destination.Members, declaration, options, availableIndices,
                after: list => AfterMember(list, declaration), before: list => BeforeMember(list, declaration));

            // Find the best place to put the field.  It should go after the last field if we already
            // have fields, or at the beginning of the file if we don't.

            return AddMembersTo(destination, members);
        }
Beispiel #7
0
        private SDEvent GetParsedEvent(IEventSymbol eve)
        {
            var syntaxReference = eve.DeclaringSyntaxReferences.Any() ? eve.DeclaringSyntaxReferences.Single() : null;
            var sdEvent = new SDEvent(eve.GetIdentifier())
            {
                Name = eve.Name,
                DeclaringType = _typeRefParser.GetParsedTypeReference(eve.ContainingType),
                Accessibility = eve.DeclaredAccessibility.ToString().ToLower(),
                Documentations = DocumentationParser.ParseDocumentation(eve),
                Region = syntaxReference != null ? new SDRegion
                {
                    Start = syntaxReference.Span.Start,
                    StartLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).StartLinePosition.Line + 1,
                    EndLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).EndLinePosition.Line + 1,
                    End = syntaxReference.Span.End,
                    FilePath = syntaxReference.SyntaxTree.FilePath,
                    Filename = Path.GetFileName(syntaxReference.SyntaxTree.FilePath)
                } : null
            };

            ParserOptions.SDRepository.AddMember(sdEvent);
            return sdEvent;
        }
        public static void Attach(IEventSymbol @event, bool isUnsafe)
        {
            var info = new CodeGenerationEventInfo(isUnsafe);

            s_eventToInfoMap.Add(@event, info);
        }
 public static void Attach(IEventSymbol @event, bool isUnsafe)
 {
     var info = new CodeGenerationEventInfo(isUnsafe);
     s_eventToInfoMap.Add(@event, info);
 }
Beispiel #10
0
 public static bool Equals(IEventSymbol _, IEventSymbol __) => throw new InvalidOperationException("This is hidden so that it is not called by accident.");
Beispiel #11
0
 internal bool IsCs2DslSymbol(IEventSymbol sym)
 {
     return(sym.ContainingAssembly == m_AssemblySymbol && !m_ExternTypes.ContainsKey(ClassInfo.SpecialGetFullTypeName(sym.ContainingType, true)));
 }
Beispiel #12
0
        private static async Task <GraphNode> GetOrCreateNodeForEventAsync(Graph graph, IEventSymbol eventSymbol, Solution solution, CancellationToken cancellationToken)
        {
            var id = await GraphNodeIdCreation.GetIdForMemberAsync(eventSymbol, solution, cancellationToken).ConfigureAwait(false);

            var node = graph.Nodes.GetOrCreate(id);

            node.AddCategory(CodeNodeCategories.Event);

            node[DgmlNodeProperties.Icon]        = IconHelper.GetIconName("Event", eventSymbol.DeclaredAccessibility);
            node[RoslynGraphProperties.TypeKind] = eventSymbol.ContainingType.TypeKind;

            return(node);
        }
Beispiel #13
0
 private string GetEventSyntax(IEventSymbol symbol, IFilterVisitor filterVisitor)
 {
     ExplicitInterfaceSpecifierSyntax eii = null;
     if (symbol.ExplicitInterfaceImplementations.Length > 0)
     {
         eii = SyntaxFactory.ExplicitInterfaceSpecifier(SyntaxFactory.ParseName(GetEiiContainerTypeName(symbol, filterVisitor)));
     }
     return RemoveBraces(
         SyntaxFactory.EventDeclaration(
             GetAttributes(symbol, filterVisitor),
             SyntaxFactory.TokenList(GetMemberModifiers(symbol)),
             SyntaxFactory.Token(SyntaxKind.EventKeyword),
             GetTypeSyntax(symbol.Type),
             eii,
             SyntaxFactory.Identifier(GetMemberName(symbol, filterVisitor)),
             SyntaxFactory.AccessorList()
         ).NormalizeWhitespace().ToString()
     );
 }
 internal static IEventSymbol CreateEventSymbol(
     IEventSymbol @event,
     IList<AttributeData> attributes = null,
     Accessibility? accessibility = null,
     DeclarationModifiers? modifiers = null,
     IEventSymbol explicitInterfaceSymbol = null,
     string name = null,
     IMethodSymbol addMethod = null,
     IMethodSymbol removeMethod = null)
 {
     return CodeGenerationSymbolFactory.CreateEventSymbol(
         attributes,
         accessibility ?? @event.DeclaredAccessibility,
         modifiers ?? @event.GetSymbolModifiers(),
         @event.Type,
         explicitInterfaceSymbol,
         name ?? @event.Name,
         addMethod,
         removeMethod);
 }
 public WrappedEventSymbol(IEventSymbol eventSymbol, bool canImplementImplicitly, IDocumentationCommentFormattingService docCommentFormattingService)
     : base(eventSymbol, canImplementImplicitly, docCommentFormattingService)
 {
     _symbol = eventSymbol;
 }
 public abstract SyntaxNode CreateEventDeclaration(IEventSymbol @event, CodeGenerationDestination destination, CodeGenerationOptions options);
Beispiel #17
0
 private static IEnumerable<SyntaxToken> GetMemberModifiers(IEventSymbol symbol)
 {
     if (symbol.ContainingType.TypeKind != TypeKind.Interface)
     {
         switch (symbol.DeclaredAccessibility)
         {
             case Accessibility.Protected:
             case Accessibility.ProtectedOrInternal:
                 yield return SyntaxFactory.Token(SyntaxKind.ProtectedKeyword);
                 break;
             case Accessibility.Public:
                 yield return SyntaxFactory.Token(SyntaxKind.PublicKeyword);
                 break;
             case Accessibility.ProtectedAndInternal:
             case Accessibility.Internal:
             case Accessibility.Private:
             default:
                 break;
         }
     }
     if (symbol.IsStatic)
     {
         yield return SyntaxFactory.Token(SyntaxKind.StaticKeyword);
     }
     if (symbol.IsAbstract && symbol.ContainingType.TypeKind != TypeKind.Interface)
     {
         yield return SyntaxFactory.Token(SyntaxKind.AbstractKeyword);
     }
     if (symbol.IsVirtual)
     {
         yield return SyntaxFactory.Token(SyntaxKind.VirtualKeyword);
     }
     if (symbol.IsOverride)
     {
         yield return SyntaxFactory.Token(SyntaxKind.OverrideKeyword);
     }
     if (symbol.IsSealed)
     {
         yield return SyntaxFactory.Token(SyntaxKind.SealedKeyword);
     }
 }
        private string GetEventPrototype(IEventSymbol symbol, PrototypeFlags flags)
        {
            if ((flags & PrototypeFlags.Signature) != 0)
            {
                if (flags != PrototypeFlags.Signature)
                {
                    // vsCMPrototypeUniqueSignature can't be combined with anything else.
                    throw Exceptions.ThrowEInvalidArg();
                }

                // The unique signature is simply the node key.
                flags = PrototypeFlags.FullName | PrototypeFlags.Type;
            }

            var builder = new StringBuilder();

            AppendEventPrototype(builder, symbol, flags, symbol.Name);

            return builder.ToString();
        }
Beispiel #19
0
 private static string GetEiiContainerTypeName(IEventSymbol symbol, IFilterVisitor filterVisitor)
 {
     if (symbol.ExplicitInterfaceImplementations.Length == 0)
     {
         return null;
     }
     for (int i = 0; i < symbol.ExplicitInterfaceImplementations.Length; i++)
     {
         if (filterVisitor.CanVisitApi(symbol.ExplicitInterfaceImplementations[i]))
         {
             return NameVisitorCreator.GetCSharp(NameOptions.UseAlias | NameOptions.WithGenericParameter).GetName(symbol.ExplicitInterfaceImplementations[i].ContainingType);
         }
     }
     Debug.Fail("Should not be here!");
     return null;
 }
        private void AppendEventPrototype(StringBuilder builder, IEventSymbol symbol, PrototypeFlags flags, string baseName)
        {
            if ((flags & PrototypeFlags.Type) != 0)
            {
                builder.Append(GetAsStringForCodeTypeRef(symbol.Type));

                if ((flags & PrototypeFlags.NameMask) != PrototypeFlags.NoName)
                {
                    builder.Append(' ');
                }
            }

            switch (flags & PrototypeFlags.NameMask)
            {
                case PrototypeFlags.FullName:
                    AppendTypeNamePrototype(builder, includeNamespaces: true, includeGenerics: false, symbol: symbol.ContainingSymbol);
                    builder.Append('.');
                    goto case PrototypeFlags.BaseName;

                case PrototypeFlags.TypeName:
                    AppendTypeNamePrototype(builder, includeNamespaces: false, includeGenerics: true, symbol: symbol.ContainingSymbol);
                    builder.Append('.');
                    goto case PrototypeFlags.BaseName;

                case PrototypeFlags.BaseName:
                    builder.Append(baseName);
                    break;
            }
        }
 public override SyntaxNode CreateEventDeclaration(
     IEventSymbol @event, CodeGenerationDestination destination, CodeGenerationOptions options)
 {
     return(EventGenerator.GenerateEventDeclaration(@event, destination, options));
 }
Beispiel #22
0
 /// <summary>
 /// Field-like events can be used as fields in types that can access private
 /// members of the declaring type of the event.
 /// </summary>
 public new bool IsEventUsableAsField(int position, IEventSymbol eventSymbol)
 {
     var csymbol = (EventSymbol)eventSymbol;
     return !ReferenceEquals(eventSymbol, null) && csymbol.HasAssociatedField && this.IsAccessible(position, csymbol.AssociatedField); //calls CheckAndAdjustPosition
 }
Beispiel #23
0
 public bool IsMatch(IEventSymbol symbol)
 {
     return(GetReason(symbol) == SymbolFilterReason.None);
 }
Beispiel #24
0
 protected sealed override bool IsEventUsableAsFieldCore(int position, IEventSymbol symbol)
 {
     return this.IsEventUsableAsField(position, symbol.EnsureCSharpSymbolOrNull<IEventSymbol, EventSymbol>("symbol"));
 }
 internal EventSymbolKey(IEventSymbol symbol, Visitor visitor)
 {
     this.containerKey = GetOrCreate(symbol.ContainingType, visitor);
     this.metadataName = symbol.MetadataName;
 }
 private static bool CheckTypeParameterInEvent(ITypeParameterSymbol typeParameter, VarianceKind variance,
     IEventSymbol @event)
 {
     return CanTypeParameterBeVariant(
         typeParameter, variance,
         @event.Type,
         false,
         true,
         @event);
 }
 public static bool GetIsUnsafe(IEventSymbol @event)
 {
     return GetIsUnsafe(GetInfo(@event));
 }
Beispiel #28
0
 /// <summary>
 /// Field-like events can be used as fields in types that can access private
 /// members of the declaring type of the event.
 /// </summary>
 /// <remarks>
 /// Always false for VB events.
 /// </remarks>
 public bool IsEventUsableAsField(int position, IEventSymbol eventSymbol)
 {
     return IsEventUsableAsFieldCore(position, eventSymbol);
 }
 public static bool GetIsUnsafe(IEventSymbol @event)
 {
     return(GetIsUnsafe(GetInfo(@event)));
 }
Beispiel #30
0
 /// <summary>
 /// Field-like events can be used as fields in types that can access private
 /// members of the declaring type of the event.
 /// </summary>
 /// <remarks>
 /// Always false for VB events.
 /// </remarks>
 protected abstract bool IsEventUsableAsFieldCore(int position, IEventSymbol eventSymbol);
 protected abstract TDeclarationNode AddEvent <TDeclarationNode>(TDeclarationNode destination, IEventSymbol @event, CodeGenerationOptions options, IList <bool> availableIndices) where TDeclarationNode : SyntaxNode;
Beispiel #32
0
 public WrappedEventSymbol(IEventSymbol eventSymbol, bool canImplementImplicitly, IDocumentationCommentFormattingService docCommentFormattingService)
     : base(eventSymbol, canImplementImplicitly, docCommentFormattingService)
 {
     _symbol = eventSymbol;
 }
Beispiel #33
0
 public override IEntity VisitEvent(IEventSymbol symbol) => Event.Create(cx, symbol);
Beispiel #34
0
 /// <summary>
 /// Create a new solution where the declaration of the destination symbol has an additional event of the same signature as the specified event symbol.
 /// Returns the document in the new solution where the destination symbol is declared.
 /// </summary>
 public static Task <Document> AddEventDeclarationAsync(Solution solution, INamedTypeSymbol destination, IEventSymbol @event, CodeGenerationOptions options = default(CodeGenerationOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     return(GetCodeGenerationService(solution.Workspace, destination.Language).AddEventAsync(solution, destination, @event, options, cancellationToken));
 }
Beispiel #35
0
        public override void GenerateEvent(IEventSymbol symbol, MetadataItem item, SymbolVisitorAdapter adapter)
        {
            base.GenerateEvent(symbol, item, adapter);

            var modifiers = new List<string>();
            if (symbol.ContainingType.TypeKind != TypeKind.Interface)
            {
                var visiblity = GetVisiblity(symbol.DeclaredAccessibility);
                if (visiblity != null)
                {
                    modifiers.Add(visiblity);
                }
                if (symbol.IsStatic)
                {
                    modifiers.Add("static");
                }
                if (symbol.IsAbstract)
                {
                    modifiers.Add("abstract");
                }
                if (symbol.IsOverride)
                {
                    modifiers.Add("override");
                }
                if (symbol.IsVirtual && symbol.IsSealed)
                {
                }
                else if (symbol.IsVirtual)
                {
                    modifiers.Add("virtual");
                }
                else if (symbol.IsSealed)
                {
                    modifiers.Add("sealed");
                }
            }
            item.Modifiers[SyntaxLanguage.CSharp] = modifiers;
        }
Beispiel #36
0
 /// <summary>
 /// Returns a newly created event declaration node from the provided event.
 /// </summary>
 public static SyntaxNode CreateEventDeclaration(IEventSymbol @event, Workspace workspace, CodeGenerationDestination destination = CodeGenerationDestination.Unspecified, CodeGenerationOptions options = null)
 {
     return(GetCodeGenerationService(workspace, @event.Language).CreateEventDeclaration(@event, destination, options));
 }
Beispiel #37
0
 private static string GetMemberName(IEventSymbol symbol, IFilterVisitor filterVisitor)
 {
     string name = symbol.Name;
     if (symbol.ExplicitInterfaceImplementations.Length == 0)
     {
         return symbol.Name;
     }
     for (int i = 0; i < symbol.ExplicitInterfaceImplementations.Length; i++)
     {
         if (filterVisitor.CanVisitApi(symbol.ExplicitInterfaceImplementations[i]))
         {
             return symbol.ExplicitInterfaceImplementations[i].Name;
         }
     }
     Debug.Fail("Should not be here!");
     return symbol.Name;
 }
Beispiel #38
0
 /// <summary>
 /// Create a new declaration node with an event declaration of the same signature as the specified symbol added to it.
 /// </summary>
 public static TDeclarationNode AddEventDeclaration <TDeclarationNode>(TDeclarationNode destination, IEventSymbol @event, Workspace workspace, CodeGenerationOptions options = default(CodeGenerationOptions)) where TDeclarationNode : SyntaxNode
 {
     return(GetCodeGenerationService(workspace, destination.Language).AddEvent(destination, @event, options));
 }
Beispiel #39
0
 private int CombineHashCodes(IEventSymbol x, int currentHash)
 {
     return
         (Hash.Combine(x.Name,
                       GetHashCode(x.ContainingSymbol, currentHash)));
 }
 public Task <Document> AddEventAsync(Solution solution, INamedTypeSymbol destination, IEventSymbol @event, CodeGenerationOptions options, CancellationToken cancellationToken)
 {
     return(GetEditAsync(
                solution,
                destination,
                (t, opts, ai) => AddEvent(t, @event, opts, ai),
                options,
                new[] { @event },
                cancellationToken));
 }
 protected abstract void BuildEventDeclaration(IEventSymbol eventSymbol, _VSOBJDESCOPTIONS options);
Beispiel #42
0
 private bool HaveSameReturnType(IEventSymbol ev1, IEventSymbol ev2)
 {
     return(this.SignatureTypeEquivalenceComparer.Equals(ev1.Type, ev2.Type));
 }
        protected override TDeclarationNode AddEvent <TDeclarationNode>(TDeclarationNode destination, IEventSymbol @event, CodeGenerationOptions options, IList <bool> availableIndices)
        {
            CheckDeclarationNode <TypeDeclarationSyntax>(destination);

            return(Cast <TDeclarationNode>(EventGenerator.AddEventTo(Cast <TypeDeclarationSyntax>(destination), @event, options, availableIndices)));
        }
Beispiel #44
0
 private bool HaveSameSignature(IEventSymbol event1, IEventSymbol event2, bool caseSensitive)
 {
     return(IdentifiersMatch(event1.Name, event2.Name, caseSensitive));
 }
 public override object VisitEvent(IEventSymbol eventSymbol)
 {
     WriteType(SymbolKeyType.Event);
     EventSymbolKey.Create(eventSymbol, this);
     return(null);
 }
		//		public TooltipInformation GetAliasedNamespaceTooltip (AliasNamespaceResolveResult resolveResult)
		//		{
		//			var result = new TooltipInformation ();
		//			result.SignatureMarkup = GetMarkup (resolveResult.Namespace);
		//			result.AddCategory (GettextCatalog.GetString ("Alias information"), GettextCatalog.GetString ("Resolved using alias '{0}'", resolveResult.Alias));
		//			return result;
		//		}
		//
		//		public TooltipInformation GetAliasedTypeTooltip (AliasTypeResolveResult resolveResult)
		//		{
		//			var result = new TooltipInformation ();
		//			result.SignatureMarkup = GetTypeMarkup (resolveResult.Type, true);
		//			result.AddCategory (GettextCatalog.GetString ("Alias information"), GettextCatalog.GetString ("Resolved using alias '{0}'", resolveResult.Alias));
		//			return result;
		//		}

		string GetEventMarkup (IEventSymbol evt)
		{
			if (evt == null)
				throw new ArgumentNullException ("evt");
			var result = new StringBuilder ();
			AppendModifiers (result, evt);
			result.Append (Highlight ("event ", colorStyle.KeywordModifiers));
			result.Append (GetTypeReferenceString (evt.Type));
			if (BreakLineAfterReturnType) {
				result.AppendLine ();
			} else {
				result.Append (" ");
			}

			AppendExplicitInterfaces (result, evt.ExplicitInterfaceImplementations.Cast<ISymbol> ());
			result.Append (HighlightSemantically (FilterEntityName (evt.Name), colorStyle.UserEventDeclaration));
			return result.ToString ();
		}
Beispiel #47
0
        public override void VisitEventDeclaration(EventDeclarationSyntax node)
        {
            var          ci      = m_ClassInfoStack.Peek();
            IEventSymbol declSym = m_Model.GetDeclaredSymbol(node);

            if (null != declSym)
            {
                string require = ClassInfo.GetAttributeArgument <string>(declSym, "Cs2Lua.RequireAttribute", 0);
                if (!string.IsNullOrEmpty(require))
                {
                    SymbolTable.Instance.AddRequire(ci.Key, require);
                }
                if (ClassInfo.HasAttribute(declSym, "Cs2Lua.IgnoreAttribute"))
                {
                    return;
                }
                if (declSym.IsAbstract)
                {
                    return;
                }
            }

            StringBuilder curBuilder = ci.CurrentCodeBuilder;

            if (declSym.IsStatic)
            {
                ci.CurrentCodeBuilder = ci.StaticFunctionCodeBuilder;
            }
            else
            {
                ci.CurrentCodeBuilder = ci.InstanceFunctionCodeBuilder;
            }
            foreach (var accessor in node.AccessorList.Accessors)
            {
                var sym = m_Model.GetDeclaredSymbol(accessor);
                if (null != sym)
                {
                    var mi = new MethodInfo();
                    mi.Init(sym, accessor);
                    m_MethodInfoStack.Push(mi);

                    string manglingName = NameMangling(sym);
                    string keyword      = accessor.Keyword.Text;
                    string paramStr     = string.Join(", ", mi.ParamNames.ToArray());
                    if (!declSym.IsStatic)
                    {
                        if (string.IsNullOrEmpty(paramStr))
                        {
                            paramStr = "this";
                        }
                        else
                        {
                            paramStr = "this, " + paramStr;
                        }
                    }
                    CodeBuilder.AppendFormat("{0}{1} = function({2})", GetIndentString(), manglingName, paramStr);
                    CodeBuilder.AppendLine();
                    ++m_Indent;
                    bool   isStatic    = declSym.IsStatic;
                    string luaModule   = ClassInfo.GetAttributeArgument <string>(sym, "Cs2Lua.TranslateToAttribute", 0);
                    string luaFuncName = ClassInfo.GetAttributeArgument <string>(sym, "Cs2Lua.TranslateToAttribute", 1);
                    if (!string.IsNullOrEmpty(luaModule) || !string.IsNullOrEmpty(luaFuncName))
                    {
                        if (!string.IsNullOrEmpty(luaModule))
                        {
                            SymbolTable.Instance.AddRequire(ci.Key, luaModule);
                        }
                        if (sym.ReturnsVoid && mi.ReturnParamNames.Count <= 0)
                        {
                            CodeBuilder.AppendFormat("{0}{1}({2}", GetIndentString(), luaFuncName, isStatic ? string.Empty : "this");
                        }
                        else
                        {
                            CodeBuilder.AppendFormat("{0}return {1}({2}", GetIndentString(), luaFuncName, isStatic ? string.Empty : "this");
                        }
                        if (mi.ParamNames.Count > 0)
                        {
                            if (!isStatic)
                            {
                                CodeBuilder.Append(", ");
                            }
                            CodeBuilder.Append(string.Join(", ", mi.ParamNames.ToArray()));
                        }
                        CodeBuilder.AppendLine(");");
                    }
                    else if (null != accessor.Body)
                    {
                        if (mi.ValueParams.Count > 0)
                        {
                            OutputWrapValueParams(CodeBuilder, mi);
                        }
                        VisitBlock(accessor.Body);
                    }
                    --m_Indent;
                    CodeBuilder.AppendFormat("{0}end,", GetIndentString());
                    CodeBuilder.AppendLine();

                    m_MethodInfoStack.Pop();
                }
            }
            ci.CurrentCodeBuilder = curBuilder;

            CodeBuilder.AppendFormat("{0}{1} = {{", GetIndentString(), SymbolTable.GetEventName(declSym));
            CodeBuilder.AppendLine();
            ++m_Indent;
            foreach (var accessor in node.AccessorList.Accessors)
            {
                var sym = m_Model.GetDeclaredSymbol(accessor);
                if (null != sym)
                {
                    string manglingName = NameMangling(sym);
                    string keyword      = accessor.Keyword.Text;
                    CodeBuilder.AppendFormat("{0}{1} = {2}.{3},", GetIndentString(), keyword, declSym.IsStatic ? "static_methods" : "instance_methods", manglingName);
                    CodeBuilder.AppendLine();
                }
            }
            --m_Indent;
            CodeBuilder.AppendFormat("{0}", GetIndentString());
            CodeBuilder.AppendLine("},");
        }
Beispiel #48
0
 public virtual void VisitEvent(IEventSymbol symbol)
 {
     DefaultVisit(symbol);
 }
Beispiel #49
0
 public virtual TResult?VisitEvent(IEventSymbol symbol)
 {
     return(DefaultVisit(symbol));
 }
Beispiel #50
0
 private bool HaveSameReturnType(IEventSymbol ev1, IEventSymbol ev2)
 {
     return this.SignatureTypeEquivalenceComparer.Equals(ev1.Type, ev2.Type);
 }
 public static IEventSymbol OverrideEvent(
     this SyntaxGenerator codeFactory,
     IEventSymbol overriddenEvent,
     DeclarationModifiers modifiers,
     INamedTypeSymbol newContainingType)
 {
     return CodeGenerationSymbolFactory.CreateEventSymbol(
         overriddenEvent,
         attributes: null,
         accessibility: overriddenEvent.ComputeResultantAccessibility(newContainingType),
         modifiers: modifiers,
         explicitInterfaceSymbol: null,
         name: overriddenEvent.Name);
 }
Beispiel #52
0
 private bool HaveSameSignature(IEventSymbol event1, IEventSymbol event2, bool caseSensitive)
 {
     return IdentifiersMatch(event1.Name, event2.Name, caseSensitive);
 }
 private static CodeGenerationEventInfo GetInfo(IEventSymbol @event)
 {
     CodeGenerationEventInfo info;
     s_eventToInfoMap.TryGetValue(@event, out info);
     return info;
 }
 public static void Create(IEventSymbol symbol, SymbolKeyWriter visitor)
 {
     visitor.WriteString(symbol.MetadataName);
     visitor.WriteSymbolKey(symbol.ContainingType);
 }
Beispiel #55
0
        public sealed override void VisitEvent(IEventSymbol symbol)
        {
            Visit(symbol.Type);

            Visit(symbol.ContainingSymbol);
        }
 public static void Create(IEventSymbol symbol, SymbolKeyWriter visitor)
 {
     visitor.WriteString(symbol.MetadataName);
     visitor.WriteSymbolKey(symbol.ContainingType);
 }
 private static CodeGenerationEventInfo GetInfo(IEventSymbol @event)
 {
     s_eventToInfoMap.TryGetValue(@event, out var info);
     return(info);
 }
 private bool EventsAreEquivalent(IEventSymbol x, IEventSymbol y, Dictionary <INamedTypeSymbol, INamedTypeSymbol> equivalentTypesWithDifferingAssemblies)
 {
     return
         (x.Name == y.Name &&
          AreEquivalent(x.ContainingSymbol, y.ContainingSymbol, equivalentTypesWithDifferingAssemblies));
 }
Beispiel #59
0
 public override void VisitEvent(IEventSymbol symbol)
 {
     if (_finished || _symbolPredicate == null || _symbolPredicate(symbol))
     {
         AddDocumentForMember(symbol, true, new MetadataItems
         {
             new MetadataItem(CodeAnalysisKeys.SpecificKind, (k, m) => symbol.Kind.ToString()),
             new MetadataItem(CodeAnalysisKeys.Type, DocumentFor(symbol.Type)),
             new MetadataItem(CodeAnalysisKeys.OverriddenMethod, DocumentFor(symbol.OverriddenEvent)),
             new MetadataItem(CodeAnalysisKeys.Accessibility, (k, m) => symbol.DeclaredAccessibility.ToString())
         });
     }
 }
 public TDeclarationNode AddEvent <TDeclarationNode>(TDeclarationNode destination, IEventSymbol @event, CodeGenerationOptions options, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
 {
     return(AddEvent(destination, @event, options ?? CodeGenerationOptions.Default, GetAvailableInsertionIndices(destination, cancellationToken)));
 }