コード例 #1
0
        public SyntaxTokenCollection Format(DelegateSyntax syntax)
        {
            SyntaxTokenCollection tokens = new SyntaxTokenCollection();

            tokens.AddRange(FormatVisibility(syntax));
            tokens.Add(Constants.Space);
            tokens.Add(new SyntaxToken("Delegate", SyntaxTokens.Keyword));
            tokens.Add(Constants.Space);
            if (IsMethodFunction(syntax.GetReturnType()))
            {
                tokens.Add(Constants.KeywordFunction);
            }
            else
            {
                tokens.Add(Constants.KeywordSub);
            }
            tokens.Add(Constants.Space);
            tokens.Add(new SyntaxToken(syntax.GetIdentifier(), SyntaxTokens.Text));
            tokens.AddRange(FormatParameters(syntax.Method));

            // Add the generic details of the delegate
            if (_syntax.Class.IsGeneric)
            {
                List <GenericTypeRef> genericTypes = _syntax.GetGenericParameters();
                tokens.AddRange(FormatGenericParameters(genericTypes));
            }

            if (this.IsMethodFunction(syntax.GetReturnType()))
            {
                tokens.Add(Constants.Space);
                tokens.Add(Constants.KeywordAs);
                tokens.Add(Constants.Space);
                tokens.AddRange(FormatReturnType(syntax));
            }

            return(tokens);
        }
コード例 #2
0
 public List <SyntaxToken> FormatReturnType(DelegateSyntax syntax)
 {
     return(FormatTypeDetails(syntax.GetReturnType()));
 }