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); } } }
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 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); }