Exemplo n.º 1
0
        private static void ApplySyntaxConfigurations(XmlElement syntaxElement)
        {
            // At this point, if the Syntax file really does exist it has already been added by LoadVimSyntaxFilesInFolder,
            // so all we're doing is applying configurations (description, aliases);

            string id = ReadAttributeOrDie(syntaxElement, "id");

            if (!SyntaxCatalog.m_syntaxesByIdOrAlias.ContainsKey(id))
            {
                return;
            }

            Syntax syntax = SyntaxCatalog.m_syntaxesByIdOrAlias[id];

            if (syntaxElement.HasAttribute("description"))
            {
                syntax.Description = ReadAttributeOrDie(syntaxElement, "description");
            }

            if (syntaxElement.HasChildNodes)
            {
                foreach (XmlElement alias in syntaxElement.GetElementsByTagName("alias"))
                {
                    SyntaxCatalog.AddAlias(alias.InnerText, syntax.Id);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Instantiates a new <see cref="Highlighter" /> using the specified syntax id and formatter.
        /// </summary>
        /// <param name="syntaxIdOrAlias">A syntax id that can be resolved via the <see cref="SyntaxCatalog" />.</param>
        /// <param name="formatter">The <see cref="ICodeFormatter">formatter</see> to be used for output generation.</param>
        public Highlighter(string syntaxIdOrAlias, ICodeFormatter formatter)
        {
            ArgumentValidator.ThrowIfNullOrEmpty(syntaxIdOrAlias, "syntaxIdOrAlias");
            ArgumentValidator.ThrowIfNull(formatter, "formatter");

            this.Init(SyntaxCatalog.GetSyntaxBy(syntaxIdOrAlias), formatter);
        }
Exemplo n.º 3
0
 private static void LoadVimSyntaxFilesInFolder()
 {
     foreach (FileInfo file in SyntaxDirectory.GetFiles("*.vim"))
     {
         string id        = Path.GetFileNameWithoutExtension(file.Name);
         Syntax newSyntax = new Syntax(id, id);
         SyntaxCatalog.Add(newSyntax);
     }
 }