WriteToken() public method

public WriteToken ( ICSharpCode.NRefactory.CSharp.Role role, string token, object data ) : void
role ICSharpCode.NRefactory.CSharp.Role
token string
data object
return void
        public string Generate(ISymbol symbol)
        {
            if (symbol == null)
                throw new ArgumentNullException("symbol");

            StringWriter writer = new StringWriter();
            _writer = new TextWriterTokenWriter(writer);
            _policy = FormattingOptionsFactory.CreateMono();

            TypeSystemAstBuilder astBuilder = CreateAstBuilder();
            astBuilder.AlwaysUseShortTypeNames = true;
            AstNode node = astBuilder.ConvertSymbol(symbol);

            if (symbol is ITypeDefinition)
            {
                WriteTypeDeclarationName((ITypeDefinition)symbol, _writer, _policy);
            }
            else if (symbol is IMember)
            {
                WriteMemberDeclarationName((IMember)symbol, _writer, _policy);
            }
            else
            {
                _writer.WriteIdentifier(Identifier.Create(symbol.Name));
            }

            if (HasParameters(symbol))
            {
                _writer.WriteToken(symbol.SymbolKind == SymbolKind.Indexer ? Roles.LBracket : Roles.LPar, symbol.SymbolKind == SymbolKind.Indexer ? "[" : "(");
                IEnumerable<ParameterDeclaration> parameters = new List<ParameterDeclaration>(node.GetChildrenByRole(Roles.Parameter));
                if (symbol is IMethod && ((IMethod)symbol).IsExtensionMethod)
                {
                    parameters = parameters.Skip(1);
                }

                WriteCommaSeparatedList(parameters);
                _writer.WriteToken(symbol.SymbolKind == SymbolKind.Indexer ? Roles.RBracket : Roles.RPar, symbol.SymbolKind == SymbolKind.Indexer ? "]" : ")");
            }
            if (_includePlaceholders)
            {
                _writer.WriteToken(Roles.Text, "$0");
            }
            return writer.ToString();
        }
        public string ConvertSymbol(ISymbol symbol)
        {
            var stringWriter = new StringWriter();
            var astBuilder = new TypeSystemAstBuilder();
            astBuilder.AlwaysUseShortTypeNames = true;
            AstNode node = astBuilder.ConvertSymbol(symbol);
            var writer = new TextWriterTokenWriter (stringWriter);
            var rt = node.GetChildByRole (Roles.Type);
            if (!rt.IsNull)
            {
                rt.AcceptVisitor (new CSharpOutputVisitor (stringWriter, FormattingOptionsFactory.CreateMono()));

            }

            IProperty property = symbol as IProperty;
            if (property != null)
            {
                writer.Space ();
                writer.WriteToken (Roles.LBrace, "{");
                writer.Space ();
                if (property.CanGet)
                {
                    writer.WriteKeyword (PropertyDeclaration.GetKeywordRole, "get");
                    writer.WriteToken (Roles.Semicolon, ";");
                    writer.Space ();
                }
                if (property.CanSet)
                {
                    writer.WriteKeyword (PropertyDeclaration.SetKeywordRole, "set");
                    writer.WriteToken (Roles.Semicolon, ";");
                    writer.Space ();
                }
                writer.WriteToken (Roles.RBrace, "}");
            }
            return stringWriter.ToString();

            }