<?xml version="1.0" ?>
<!--  Adds support for GNAT's gnatmetric tool

      The gnatmetric tool computes software metrics on Ada code. This is
      a command line provided with the GNAT compiler.
      This package integrates it into GPS:
         - menu /Tools/Compute metrics for root project
         - menu /Tools/Compute metrics for current file
      The result of gnatmetric is displayed in a graphical tree for easy
      browsing.
-->

<GPS>
  <action name="metrics project" category="Metrics" >
     <filter_and>
       <filter id="Project only" />
       <filter language="ada" />
     </filter_and>
     <description>Run GNAT Metrics on a project</description>
     <shell show-command="false">Editor.save</shell>
     <shell output="none">Project.root</shell>
     <shell output="none">Project.get_attribute_as_string %1 "gnat" "ide"</shell>
     <shell>echo %1 metric -x "%pps"</shell>
     <external
      server="tools_server"
      progress-regexp="completed (\d+) out of (\d+).*"
      progress-current="1"
      progress-final="2"
      progress-hide="true">%2 metric -dd -x "%pps"</external>
     <shell>Locations.parse "%1" metrics</shell>
     <shell show-command="false" output="none">XMLViewer.create_metric "Metrics (%p)"</shell>
     <shell show-command="false">XMLViewer.parse %1 metrix.xml</shell>
  </action>

  <action name="metrics root project"  category="Metrics">
     <description>Run GNAT Metrics on a root project</description>
     <shell show-command="false">Editor.save</shell>
     <shell output="none">Project.root</shell>
     <shell output="none">Project.get_attribute_as_string %1 "gnat" "ide"</shell>
     <shell>echo %1 metric -x "%PPs"</shell>
     <external
      server="tools_server"
      progress-regexp="completed (\d+) out of (\d+).*"
      progress-current="1"
      progress-final="2"
      progress-hide="true">%2 metric -dd -x "%PPs"</external>
     <shell>Locations.parse "%1" metrics</shell>
     <shell show-command="false" output="none">XMLViewer.create_metric "Metrics (%P)"</shell>
     <shell show-command="false">XMLViewer.parse %1 metrix.xml</shell>
  </action>

  <action name="metrics file" category="Metrics" >
     <filter_and>
       <filter id="File" />
       <filter language="ada" />
     </filter_and>
     <description>Run GNAT Metrics on a single file</description>
     <shell show-command="false">Editor.save</shell>
     <shell output="none">Project.root</shell>
     <shell output="none">Project.get_attribute_as_string %1 "gnat" "ide"</shell>
     <shell>echo %1 metric -x "%pps" "%F"</shell>
     <external server="tools_server">%2 metric -x "%pps" "%F"</external>
     <shell>Locations.parse "%1" metrics</shell>
     <shell show-command="false" output="none">XMLViewer.create_metric "Metrics (%f)"</shell>
     <shell show-command="false">XMLViewer.parse %1 metrix.xml</shell>
  </action>

  <contextual action="metrics project" >
     <title>Compute metrics for %p</title>
  </contextual>
  <contextual action="metrics file" >
     <title>Compute metrics for %f</title>
  </contextual>

  <submenu>
    <title>Tools</title>
    <submenu after="Macro">
      <title>_Metrics</title>
      <menu action="metrics root project">
        <title>Compute metrics for root _project</title>
      </menu>
      <menu action="metrics file">
        <title>Compute metrics for current _file</title>
      </menu>
    </submenu>
  </submenu>

</GPS>
