This file is indexed.

/usr/share/gps/plug-ins/cross_references.py is in gnat-gps-common 5.3dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
""" Provides the tools for loading the cross-reference information in GPS.
"""

import GPS
import os.path

class Sqlite_Cross_References(object):
    """
    A python class to support the xref engine in GPS.
    This class takes care of running gnatinspect as needed to refresh the
    xref info.
    """

    xml = """<?xml version="1.0" ?><GPS>
<!-- This is an XML model for launching gnatinspect, the cross-references parser -->
<target-model name="gnatinspect" category="">
   <description>Launch cross-reference recompilation</description>
   <icon>gps-custom-build</icon>
   <command-line>
      <arg>gnatinspect</arg>
      <arg>-d</arg>
      <arg>--exit</arg>
      <arg>--db=gnatinspect.db</arg>
      <arg>--tracefile=%GPS/gnatinspect_traces.cfg</arg>
      <arg>--encoding=iso-8859-1</arg>
      <arg>%eL</arg>
      <arg>-P%PP</arg>
      <arg>%X</arg>
      <arg>%subdirsarg</arg>
   </command-line>
   <is-run>True</is-run>
   <switches command="">
   </switches>
</target-model>

<!-- Targets to launch cross-reference recompilation  -->
<target model="gnatinspect" category="_Project" name="Recompute _Xref info">
    <in-toolbar>FALSE</in-toolbar>
    <in-menu>FALSE</in-menu>
    <in-contextual-menus-for-projects>False</in-contextual-menus-for-projects>
    <icon>gps-compute-xref</icon>
    <launch-mode>MANUALLY_WITH_NO_DIALOG</launch-mode>
    <read-only>TRUE</read-only>
    <output-parsers>
        output_chopper
        utf_converter
        progress_parser
    </output-parsers>
    <command-line>
       <arg>gnatinspect</arg>
       <arg>-d</arg>
       <arg>--exit</arg>
       <arg>--db=gnatinspect.db</arg>
       <arg>--tracefile=%GPS/gnatinspect_traces.cfg</arg>
       <arg>--encoding=iso-8859-1</arg>
       <arg>-P%PP</arg>
       <arg>%X</arg>
       <arg>%subdirsarg</arg>
    </command-line>
</target>
</GPS>
"""

    def __init__(self):
        # Whether we trust that there are no links in the project hierarchy
        self.trusted_mode = True

        GPS.parse_xml(self.xml)
        GPS.Hook("project_view_changed").add(self.on_project_view_changed)
        GPS.Hook("compilation_finished").add(self.on_compilation_finished)
        GPS.Hook("gps_started").add(self.on_gps_started)
        GPS.Hook("preferences_changed").add(self.on_preferences_changed)
        self.gnatinspect_launch_registered = False

        # Initialize self.trusted_mode and other preferences
        self.on_preferences_changed(None)

    def recompute_xref(self):
        """ Launch recompilation of the cross references """

        # The project might not exist, for instance when GPS is loading the
        # default project in a directory

        if not os.path.exists(GPS.Project.root().file().name()):
            return

        # If we are already recomputing Xref info, do not launch another instance
        # of gnatinspect, but register one to be launched

        tasks = GPS.Task.list()

        if tasks:
            if "Recompute Xref info" in [t.name() for t in tasks]:
                self.gnatinspect_launch_registered = True
                return

        # We are about to launch gnatinspect
        self.gnatinspect_launch_registered = False
        target = GPS.BuildTarget("Recompute Xref info")

        extra_args = None
        if not self.trusted_mode:
            extra_args = "--symlinks"

        target.execute(synchronous=GPS.Logger("TESTSUITE").active, quiet=True, extra_args=extra_args)

    def on_compilation_finished(self, hook, category,
        target_name="", mode_name="", status=""):


        if (target_name in ["Compile File", "Build Main", "Build All", "Make",
               "Compile All Sources", "Build <current file>", "Custom Build..."]
            or category in ["Makefile"]):
            self.recompute_xref()

        if (self.gnatinspect_launch_registered
            and target_name == "Recompute Xref info"):
            # A launch of gnatinspect was registered while this one was
            # running: relaunch one now.

            self.recompute_xref()

    def on_project_view_changed(self, hook):
        self.recompute_xref()

    def on_preferences_changed(self, hook_name):
        self.trusted_mode = GPS.Preference("Prj-Editor-Trusted-Mode").get()

    def on_gps_started(self, hook):
        GPS.Menu.create("/Build/Recompute _Xref info",
             on_activate=lambda x : self.recompute_xref())

if GPS.Logger("ENTITIES.SQLITE").active:
    Sqlite_Cross_References()