.NET Framework Developer Center > .NET Development Forums > Microsoft SQL Server Modeling > Keyword colouring not working in May 2009 CTP
Ask a questionAsk a question
 

Proposed AnswerKeyword colouring not working in May 2009 CTP

  • Thursday, October 15, 2009 7:19 PMsinghhome Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I am using Build 3.0.1803.10 on WIN 7.
    Even though I have used classification attribute in my grammar, but my texts are not coloured in the DSL text.

    Regards
    singhhome

All Replies

  • Thursday, October 15, 2009 8:21 PMNeil MacIntoshMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello singhhome,

    To help us reproduce the problem, would it be possible for you to post your grammar, showing the classification attributes and a sample of input text that is not being coloured?

    Thanks,

    Neil.
  • Sunday, October 18, 2009 6:24 AMsinghhome Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Neil,

    I am trying the msdn sample from http://msdn.microsoft.com/en-us/library/dd548006.aspx

    Regards

    singhhome
  • Wednesday, October 21, 2009 10:42 PMJaime AlvaMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Singhhome,

    I tried the sample and it looks to work OK, perhaps an error previous to the use of "Classification" is causing not to see the bolded (coloured) keywords. To rule anything like that out, you may want to try this "Classification" only sample first (Just in case, I have bolded words the same way as intellipad does):

    DSL Input:

    StartContent
       This part is the content
    EndContent

    DSL Grammar:

    module Sample.Attribute.Classification
    {
      language ReportBundle
      {
        syntax Main = tStart any* tEnd;
       
        @{Classification{"Keyword"}}
        token tStart = "StartContent";
       
        @{Classification{"Keyword"}}
        token tEnd = "EndContent";
       
      }
    }

    -> Your output will look like a long column of double quoted charactes corresponding to the content part of the DSL input.

    Also you may want to make sure you have saved your grammar file with the MG extension and that you using the interactive mode (follows steps on figure2 of the sample you are trying)

    Hope this helps,
    -Jaime.

    -Jaime.
  • Sunday, October 25, 2009 9:00 AMsinghhome Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    HI  Jaime,

    I tried your sample, but still it is not colouring the keywords (it's just making it bold in black font color). I am able to see the mgraph with contents.

    Regards
    singhhome
  • Tuesday, October 27, 2009 7:36 AMMiguel.LlopisMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    Hi Singhhome,

    Both you and Jaime are right. Intellipad is colouring the keywords in the DSL input. Actually, it is making them bold in black font color. And that is because... yes! Bold black font color is the default colouring for keywords that the Intellipad team chose :)

    How could you change it? It is pretty easy, you just need to redefine the color and/or font-style to be applied. You can even make it more sophisticated, in a way that you could have different keyword categories, and colour them in a different way for better readability.

    To do the latter, you will need to follow these three steps:

    1.  Add a new ClassificationType to [Oslo SDK]\Bin\Settings\ClassificationTypes.xcml

                 <act:Export Type='mvstc:ClassificationTypeDefinition'>
                      <ls:ClassificationType Name='MyKeywords.TypeA' DerivesFrom='text' />
                 </act:Export>

    2. Add a new ClassificationFormat to [Oslo SDK]\Bin\Settings\ClassificationFormats.xcml, for the ClassificationType you just created:

                  <act:Export Name='{}{Microsoft.Intellipad}ClassificationFormat'>
                       <ls:ClassificationFormat Name='MyKeywords.TypeA'
                                 FontFamily='Consolas'
                                 Foreground='#FFcc3333'
                                 FontWeight='Bold'/>
                  </act:Export>

    3. In your grammar add a Classification attribute to the token you want the formatting applied to, such as:

                  @{Classification{"MyKeywords.TypeA"}}
                  token tStart = "StartContent";

    Note: You will need to restart Intellipad to make it "refresh" these changes, or (this is a tip) press the following key combination from inside the editor: "CTRL + ALT + F5", to make it reload the environment without closing it.

    Hope this makes it a bit more clear,
    M.
  • Tuesday, October 27, 2009 7:37 PMsinghhome Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    Thanks Miguel,

    But still it is not working for me!!! Can i send you my code and settings file?

    Regards
    singhhome
  • Wednesday, October 28, 2009 7:32 AMMiguel.LlopisMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Could you please attach both into this thread?

    Thanks,
    M.
  • Wednesday, October 28, 2009 6:35 PMJaime AlvaMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Singhhome, Miguel and I synced-up and the question is now been asked to the product team - we will update you.

    Nice catch! - Thx,
    -Jaime.


    -Jaime.
  • Wednesday, November 11, 2009 5:26 AMNeil MacIntoshMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello singhhome,

    I have had a closer look at the MSDN sample, and you have uncovered a bug in it!

    The sample uses invalid syntax for the classification attribute. The classification attribute uses "hard" brackets: [], not "curly" brackets: {}, as the sample shows in some code.

    To demonstrate, if we rework Jaime's minimal sample from above using the correct syntax, it looks like this:

    module Sample.Attribute.Classification
    {
      language ReportBundle
      {
        syntax Main = tStart any* tEnd;
       
        @{Classification["Keyword"]}
        token tStart = "StartContent";
       
        @{Classification["Keyword"]}
        token tEnd = "EndContent";
       
      }
    }

    If you make this change to the MSDN sample source code, then keyword colouring should work correctly for you.

    And if you find Intellipad's default "grayscale" color scheme not to your taste (I prefer something a bit more colourful myself), then Miguel's suggestion on modifying the classification formats for Intellipad is exactly what you need.

    Hope that helps,

    Neil.
    • Proposed As Answer byNeil MacIntoshMSFTWednesday, November 11, 2009 5:27 AM
    • Unproposed As Answer bysinghhome Thursday, November 12, 2009 7:23 AM
    •  
  • Thursday, November 12, 2009 7:25 AMsinghhome Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi neil,

    Thanks for your reply, but still it is not working. Now I am not even getting the default bold/black highlithing for key words
    below is my grammar and sample text

    grammar -
    @{Classification{"Comment"}} 
    token MultiLineComment = '/*' any* '*/';       


    DSL Text-

    /* this is comment */


    the above text is not highlited/colured.

    Regards



    singhhome
  • Thursday, November 12, 2009 9:29 AMMiguel.LlopisMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    Hi Singhome,



    Note this was wrong as Neil pointed:

    @{Classification{"Comment"}

    Correct syntax:

    @{Classification["Comment"]


    Please let us know if that works.

    Thanks,
    M.
  • Thursday, November 12, 2009 10:54 AMsinghhome Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    HI Miguel,

    My bad, i copied the old one in the post. But i have tried @{Classification["Comment"]}  also,
    but still colouring is not working.


    --ClassificationType.xcml --
      <act:Export Type='mvstc:ClassificationTypeDefinition'>
        <ls:ClassificationType Name='MyComment' DerivesFrom='text' />
      </act:Export>

    --classificationFOrmats.xcml---
      <act:Export Name='{}{Microsoft.Intellipad}ClassificationFormat'>
        <ls:ClassificationFormat Name='MyComment'
                                 FontFamily='Georgia'
                                 Foreground='#FFEEFF'
                                 FontSize='13'
                                 FontWeight='Bold' />
      </act:Export>

    --DSL text --
    /* this is comment */

    --Grammar--
    @{Classification["MyComment"]}
            token MultiLineComment = '/*' any* '*/';       


    Regards
    singhhome