public void Execute()
        {
            string newText = syntaxEditor.Text;
            // Determine language by file extension.
            string ext = Path.GetExtension(syntaxEditor.Options.DocumentSaveOptions.CurrentFileName);

            ParserLanguageID lang_ID = ParserLanguage.FromFileExtension(ext);

            if (ext.ToLower() == ".lua")
            {
                lang_ID = ParserLanguageID.Basic;
            }
            else
            // Do not parse HTML or XML.
            if (lang_ID == ParserLanguageID.Html ||
                lang_ID == ParserLanguageID.Xml ||
                lang_ID == ParserLanguageID.None)
            {
                return;
            }
            // Use DevExpress.CodeParser to parse text into tokens.
            ITokenCategoryHelper tokenHelper = TokenCategoryHelperFactory.CreateHelper(lang_ID);
            TokenCollection      highlightTokens;

            highlightTokens = tokenHelper.GetTokens(newText);
            HighlightSyntax(highlightTokens);
        }
        public void Execute()
        {
            string newText = syntaxEditor.Text;
            // Determine the language by file extension.
            string           ext     = System.IO.Path.GetExtension(syntaxEditor.Options.DocumentSaveOptions.CurrentFileName);
            ParserLanguageID lang_ID = ParserLanguage.FromFileExtension(ext);

            // Do not parse HTML or XML.
            if (lang_ID == ParserLanguageID.Html ||
                lang_ID == ParserLanguageID.Xml ||
                lang_ID == ParserLanguageID.None)
            {
                return;
            }
            // Use DevExpress.CodeParser to parse text into tokens.
            ITokenCategoryHelper tokenHelper = TokenCategoryHelperFactory.CreateHelper(lang_ID);

            if (tokenHelper != null)
            {
                TokenCollection highlightTokens = tokenHelper.GetTokens(newText);
                if (highlightTokens != null && highlightTokens.Count > 0)
                {
                    HighlightSyntax(highlightTokens);
                }
            }
        }
Ejemplo n.º 3
0
        public void Execute()
        {
            string newText = syntaxEditor.Text;
            // Determine language by file extension.
            ParserLanguageID lang_ID;

            //string ext = System.IO.Path.GetExtension(syntaxEditor.Options.DocumentSaveOptions.CurrentFileName);
            if (_CurrentScript.Language == ScriptLanguage.CSharp)
            {
                lang_ID = ParserLanguage.FromFileExtension(".cs");
            }
            else
            {
                lang_ID = ParserLanguage.FromFileExtension(".vb");
            }

            // Do not parse HTML or XML.
            if (lang_ID == ParserLanguageID.Html ||
                lang_ID == ParserLanguageID.Xml ||
                lang_ID == ParserLanguageID.None)
            {
                return;
            }
            // Use DevExpress.CodeParser to parse text into tokens.
            ITokenCategoryHelper tokenHelper = TokenCategoryHelperFactory.CreateHelper(lang_ID);
            TokenCollection      highlightTokens;

            highlightTokens = tokenHelper.GetTokens(newText);
            HighlightSyntax(highlightTokens);
        }
        public void Execute()
        {
            string newText = syntaxEditor.Text;
            // Use DevExpress.CodeParser to parse text into tokens.
            ITokenCategoryHelper tokenHelper = TokenCategoryHelperFactory.CreateHelper(ParserLanguageID.Html);
            TokenCollection      highlightTokens;

            highlightTokens = tokenHelper.GetTokens(newText);
            HighlightSyntax(highlightTokens);
        }
Ejemplo n.º 5
0
        TokenCollection Parse(string code)
        {
            if (string.IsNullOrEmpty(code))
            {
                return(null);
            }
            ITokenCategoryHelper tokenizer = CreateTokenizer();

            if (tokenizer == null)
            {
                return(new TokenCollection());
            }
            return(tokenizer.GetTokens(code));
        }
Ejemplo n.º 6
0
        ITokenCategoryHelper CreateTokenizer()
        {
            string fileName = editor.Options.DocumentSaveOptions.CurrentFileName;

            if (String.IsNullOrEmpty(fileName))
            {
                return(null);
            }
            ITokenCategoryHelper result = TokenCategoryHelperFactory.CreateHelperForFileExtensions(Path.GetExtension(fileName));

            if (result != null)
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }
        private ITokenCategoryHelper CreateTokenizer()
        {
            string fileName = editor.Options.DocumentSaveOptions.CurrentFileName;
            string extenstion;

            if (String.IsNullOrEmpty(fileName))
            {
                extenstion = this.fileExtensionToHightlight;
            }
            else
            {
                extenstion = Path.GetExtension(fileName);
            }
            ITokenCategoryHelper result = TokenCategoryHelperFactory.CreateHelperForFileExtensions(extenstion);

            if (result != null)
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }