<?xml version="1.0" ?>

<!--  This file adds support for AdaControl -->
<AdaControl>

 <!--  Rules syntax -->
 <Language>
  <Name>AdaControl</Name>
  <Body_Suffix>.aru</Body_Suffix> <!-- Without this, GPS will complain “Warning, no source files for adacontrol” -->
  <Extension>.aru</Extension>
  <Keywords>^(check|clear|count|go|help|inhibit|message|quit|search|source|set)\b</Keywords>

  <Context>
   <New_Line_Comment_Start>--|#</New_Line_Comment_Start>
   <String_Delimiter>&quot;</String_Delimiter>
   <Can_Indent>False</Can_Indent>
   <Syntax_Highlighting>True</Syntax_Highlighting>
   <Case_Sensitive>False</Case_Sensitive>
  </Context>

  <Categories>
   <Category>
    <Name>procedure</Name>
    <Pattern>^[ \t]*[ \t]*?(check|search|count)[ \t]+(\w+)</Pattern>
    <Index>2</Index>
   </Category>
   <Category>
    <Name>procedure</Name>
    <Pattern>^[ \t]*((\w+|".*"):)[ \t]*?(check|search|count)[ \t]+(\w+)</Pattern>
    <Index>2</Index>
   </Category>
  </Categories>

 </Language>

 <!--  Preferences  -->
 <preference name="force-save"
             page="AdaControl"
             label="Auto save files"
             default="False"
             type="boolean"
             tip="Save all files without asking before each run of AdaControl"/>

 <preference name="delete-trees"
             page="AdaControl"
             label="Delete trees"
             default="False"
             type="boolean"
             tip="Delete all tree files after each run of AdaControl"/>

 <preference name="delete-ali"
             page="AdaControl"
             label="Delete .ali files with tree files"
             default="False"
             type="boolean"
             tip="Delete also .ali files whenever the tree files are deleted"/>

 <preference name="separate-rules"
             page="AdaControl"
             label="Use separate categories"
             default="False"
             type="boolean"
             tip="Make a category for each rule in the locations window"/>

 <preference name="display-run"
            page="AdaControl"
            label="Display AdaControl run"
            default="False"
               type="boolean"
               tip="Displays AdaControl command line and results in Messages window"/>

 <preference name="button-target"
               page="AdaControl"
               label="Buttons operate on"
               default="1"
               type="choices" >
                  <choice>Current File</choice>
                  <choice>Root Project</choice>
                  <choice>Units from List</choice>
 </preference>

 <preference name="help-format"
             page="AdaControl"
             label="Help on rule"
             default="1"
             type="choices" >
                <choice>Pop-up</choice>
                <choice>User Guide</choice>
 </preference>

 <preference name="max-errors"
             page="AdaControl"
             label="Max allowed error messages"
             tip="Maximum number of error messages allowed before cancelling run (0=no limit)"
             default="0"
             minimum="0"
             maximum="10000"
             type="integer" />

 <preference name="max-messages"
             page="AdaControl"
             label="Max allowed messages (all kinds)"
             tip="Maximum number of messages allowed before cancelling run (0=no limit)"
             default="0"
             minimum="0"
             maximum="10000"
             type="integer" />


 <!--  Tool  -->
 <tool name="AdaControl" package="Ide">
  <language>Ada</language>

  <switches lines="4" columns="2" separator="&#32;">
   <title line="1" column="1" column-span="2"> Files </title>
   <field line="1" column="1"
     label="Rules file" switch="-f" separator="&#32;" as-file="true" />
   <field line="1" column="1"
     label="Units file" switch="-@" separator="&#32;" as-file="true" />
   <field line="1" column="1"
     label=".adp project file" switch="-p" separator="&#32;" as-file="true" />

   <title line="1" column="2" column-span="0"></title>

   <title line="2" column="1"> Processing </title>
   <check line="2" column="1" label="Recursive mode" switch="-r"
    tip="Process recursively all units the given units depend on"/>
   <check line="2" column="1" label="Ignore local deactivation" switch="-i"
    tip="Ignore local deactivation tags in source file"/>
   <check line="2" column="1" label="Process specs only" switch="-s"/>
   <check line="2" column="1" label="Compilation unit mode" switch="-u"
    tip="Treat all source names as compilation units even if they look like file names"/>

   <title line="2" column="2"> Debug </title>
   <check line="2" column="2" label="Debug messages" switch="-d"
    tip="Displays debug information (not useful for normal user)"/>
   <check line="2" column="2" label="Halt on error" switch="-x"
    tip="Terminate AdaControl if a fatal error is encountered"/>

   <title line="3" column="1" column-span="2"> Output </title>
   <check line="3" column="1" label="Display only errors" switch="-E"
    tip="Print only errors (Check)"/>
   <check line="3" column="1" label="Warnings as errors" switch="-e"
    tip="Treat warnings (Search) as errors (Check)"/>
   <combo line="3" column="1" label="Statistics" switch="-S" separator="&#32;" noswitch="0"
    tip="Define the statistics displayed in the Message window at the end or the run">
    <combo-entry label="None"                      value="0" />
    <combo-entry label="Errors and warnings count" value="1" />
    <combo-entry label="Report untriggered rules"  value="2" />
    <combo-entry label="Full rules statistics"     value="3" />
   </combo>
   <radio line="3" column="1">
     <radio-entry label="Send results to GPS"
        tip="Send the output to the locations window in GPS"/>
     <radio-entry label="Send results to File"
        tip="Send the output to a file (file name below is required)"
        switch="-NOGPS" />
     <radio-entry label="Send results to File and GPS"
        tip="Send the output to a file and load it into locations window"
        switch="-GPS" />
   </radio>
   <field line="3" column="1"
     label="File name" switch="-o" separator="&#32;" as-file="true" />
   <combo line="3" column="1" label="File format" switch="-F" noswitch="0"
    tip="Define the output format when destination is file">
    <combo-entry label="Gnat, short file names"   value="gnat_short" />
    <combo-entry label="Gnat, long file names"    value="gnat" />
    <combo-entry label="CSV, short file names"    value="csv_short" />
    <combo-entry label="CSV, long file names"     value="csv" />
    <combo-entry label="CSVX, short file names"   value="csvx_short" />
    <combo-entry label="CSVX, long file names"    value="csvx" />
    <combo-entry label="Source, short file names" value="source_short" />
    <combo-entry label="Source, long file names"  value="source" />
   </combo>

   <title line="3" column="2" column-span="0"></title>

   <title line="4" column="1" column-span="2">ASIS</title>
   <field line="4" column="1"
     label="ASIS options" switch="--" separator="&#32;"/>

   <title line="4" column="2" column-span="0"></title>

</switches>
 </tool>


 <!--  Actions  -->
<action name="Check_File_File">
  <filter_and>
    <filter language="ada" />
    <filter shell_cmd="adactl.rules_file_defined()" shell_lang="python" />
  </filter_and>

  <shell lang="Python" show-command="false" output="">adactl.run("file", "current")</shell>
</action>

<action name="Check_Project_File">
  <filter shell_cmd="adactl.rules_file_defined()" shell_lang="python" />
  <shell lang="Python" show-command="false" output="">adactl.run("file", "project")</shell>
</action>

<action name="Check_Units_File">
  <filter_and>
    <filter shell_cmd="adactl.units_file_defined()" shell_lang="python" />
    <filter shell_cmd="adactl.rules_file_defined()" shell_lang="python" />
  </filter_and>
  <shell lang="Python" show-command="false" output="">adactl.run("file", "list")</shell>
</action>

<action name="Check_Unknown_File">
   <shell lang="Python" show-command="false" output="">adactl.run("file", "")</shell>
</action>

<action name="Check_File_Ask">
  <filter language="ada" />
  <shell lang="Python" show-command="false" output="">adactl.run("ask", "current")</shell>
</action>

<action name="Check_Project_Ask">
  <shell lang="Python" show-command="false" output="">adactl.run("ask", "project")</shell>
</action>

<action name="Check_Units_Ask">
  <filter shell_cmd="adactl.units_file_defined()" shell_lang="python" />
  <shell lang="Python" show-command="false" output="">adactl.run("ask", "list")</shell>
</action>

<action name="Check_Unknown_Ask">
  <shell lang="Python" show-command="false" output="">adactl.run("ask", "")</shell>
</action>

<action name="Check_AdaCtl">
  <filter language="AdaControl" />
  <shell lang="Python" show-command="false" output="">adactl.run("check", "")</shell>
</action>

<action name="Get_Units" show-command="false" output="none">
  <filter shell_cmd="adactl.units_file_defined()" shell_lang="python" />
  <shell lang="python">adactl.get_units_file()</shell>
  <shell> File %1</shell>
  <shell> EditorBuffer.get %1</shell>
  <shell> EditorBuffer.views %1</shell>
  <shell> MDI.get_by_child %1</shell>
  <shell> MDIWindow.raise_window %1</shell>
 </action>

<action name="Get_Rules" show-command="false" output="none">
  <filter shell_cmd="adactl.rules_file_defined()" shell_lang="python" />
  <shell lang="python">adactl.get_file("-f")</shell>
  <shell> File %1</shell>
  <shell> EditorBuffer.get %1</shell>
  <shell> EditorBuffer.views %1</shell>
  <shell> MDI.get_by_child %1</shell>
  <shell> MDIWindow.raise_window %1</shell>
</action>

<action name="Del_Tree">
  <shell lang="python" show-command="false" output="none">adactl.del_tree(confirm=True)</shell>
</action>

<action name="Create_adp">
  <shell lang="python" show-command="false" output="">adactl.create_adp()</shell>
</action>

<action name="Load_Result">
  <shell lang="python" show-command="false" output="none">adactl.load_result()</shell>
</action>

 <action name="Create_units">
  <shell lang="python" show-command="false" output="">adactl.create_units()</shell>
 </action>

<action name="About">
  <shell lang="python" show-command="false" output="none">adactl.about()</shell>
</action>

<!--  Submenus  -->
<submenu before="About">
  <title>/Help/AdaControl</title>

  <menu action="About">
     <title>About</title>
  </menu>

</submenu>

<submenu before="Help">
  <title>/AdaControl</title>

  <menu action="Check_File_File">
     <title>Control Current File (rules file)</title>
  </menu>

  <menu action="Check_Project_File">
     <title>Control Root Project (rules file)</title>
  </menu>

  <menu action="Check_Units_File">
     <title>Control Units from List (rules file)</title>
  </menu>

  <menu />

  <menu action="Check_File_Ask">
     <title>Control Current File (interactive)</title>
  </menu>

  <menu action="Check_Project_Ask">
     <title>Control Root Project (interactive)</title>
  </menu>

  <menu action="Check_Units_Ask">
     <title>Control Units from List (interactive)</title>
  </menu>

  <menu />

  <menu action="Check_AdaCtl">
     <title>Check Rules File Syntax</title>
  </menu>

  <menu action="Get_Rules">
     <title>Open rules file</title>
  </menu>

  <menu action="Get_Units">
     <title>Open units file</title>
  </menu>

  <menu action="Load_Result">
     <title>Load results file</title>
  </menu>

  <menu />

  <menu action="Create_units">
     <title>Create units file</title>
  </menu>

  <menu action="Create_adp">
     <title>Create .adp project</title>
  </menu>

  <menu action="Del_Tree">
     <title>Delete Tree Files</title>
  </menu>

</submenu>

<!--  Documentation  -->

<documentation_file>
  <name>adacontrol_ug.html</name>
  <descr>AdaControl User Guide</descr>
  <category>AdaControl</category>
  <menu before="About">/Help/AdaControl/User Guide</menu>
</documentation_file>

<documentation_file>
  <name>adacontrol_pm.html</name>
  <descr>AdaControl Programmer Manual</descr>
  <category>AdaControl</category>
  <menu before="About">/Help/AdaControl/Programmer Manual</menu>
</documentation_file>

</AdaControl>

