Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Disable AutoCorrect for Keywords in Syntax Editor
posted

Hi,

I've created a custom language for Syntax Editor but I face a small problem after providing manually the Keyword list. Whenever I type a keyword text is replaced to the correct keyword. So for example we have a keyword "Using" but if I type in the Editor text "using" it gets replaced after losing focus or hitting enter even this is inside of string.

Our compiler code is case sensitive and it is OK from this point. However we did not covered this text as part of text and this should not change any text inside of text string with quotations.

I see here two options:

  • Disable the auto correction for keywords and do not highlight the keyword if not matching on case sensitive
  • Add additional Comments formatting to cover double quoted text exclusion from validation of these keywords inside

Keyword added to the grammar by this code:


var grammar = PlainTextLanguage.Instance.Grammar.Clone();

new MyLanguageSyntax().SyntaxElements.Cast().ToList().ForEach(element => {

grammar.LexerStates.DefaultLexerState.Symbols.Insert(0, element.Keyword, element.Keyword, TerminalSymbolComparison.LiteralIgnoreCase).LanguageElement = LanguageElement.ContextSensitiveKeyword; });

return new CustomLanguage(grammar);

How can I turn this auto correct feature for SyntaxEditor?

Or how to add the string handling? An example of code with 1st occurrence is OK but second one should be untouched:

Using XName(Application.Interfaces.ITest, Application.TestImplementation)

function Target(xName value)
<
 <A "Text using value">
 <A value.Property>
 >

  • 25665
    Verified Answer
    Offline posted

    Hello Tomas,

    Thank you for contacting Infragistics!

    To achieve the behavior you want you are going to have to modify your regex. You are going to have to make it more specific/constricting.