This file is indexed.

/usr/share/gps/library/gnatpp_switches.py is in gnat-gps-common 5.0-6.

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
"""If this plug-in is enabled, provides automatic setting of Ada reformatting
   preferences based on gnatpp switches as set in the project file.

   For example, if gnatpp switch -i4 is set, then the
   Editor/Ada/Default indentation preference is set to 4

   Note that some gnatpp switches have no direct equivalence (and vice-versa),
   in which case they are ignored.
"""



import GPS

def set_pref(f,name,val):
  GPS.Preference(name).set(val, False)
  GPS.Logger("gnatpp").log("convert " + f + " into " + name + "=" + str(val))

def project_recomputed (hook_name):
  s = GPS.Project.root().get_attribute_as_list \
        ("default_switches", package="pretty_printer", index="ada")

  if s == []:
    GPS.Logger("gnatpp").log ("no gnatpp switches, exit")
    return

  compact_layout = True
  indent_level = 3
  GPS.Preference ("Ada-Auto-Indentation").set ("Extended", False)
  GPS.Preference ("Ada-Casing-Policy").set ("On_The_Fly", False)
  GPS.Preference ("Ada-Format-Operators").set (True, False)

  for f in s:
    if f == "-A0":
      set_pref(f, "Ada-Align-On-Colons", False)
    elif f == "-A1":
      set_pref(f, "Ada-Align-On-Colons", True)
    elif f == "-A4":
      set_pref(f, "Ada-Align-On-Arrows", True)
    elif f[0:2] == "-i":
      indent_level = int(f[2:])
      set_pref(f, "Ada-Indent-Level", indent_level)
    elif f[0:3] == "-cl":
      set_pref(f, "Ada-Continuation-Level", int(f[3:]))
    elif f == "-kL":
      set_pref(f, "Ada-Reserved-Casing", "Lower")
    elif f == "-kU":
      set_pref(f, "Ada-Reserved-Casing", "Upper")
    elif f == "-nD":
      set_pref(f, "Ada-Ident-Casing", "Unchanged")
    elif f == "-nU":
      set_pref(f, "Ada-Ident-Casing", "Upper")
    elif f == "-nL":
      set_pref(f, "Ada-Ident-Casing", "Lower")
    elif f == "-nM":
      set_pref(f, "Ada-Ident-Casing", "Smart_Mixed")
    elif f == "-c0":
      set_pref(f, "Ada-Indent-Comments", False)
    elif f == "-c4":
      set_pref(f, "Ada-Indent-Comments", True)
    elif f == "-l3":
      compact_layout = False
    elif f[0:2] == "-M":
      set_pref(f, "Src-Editor-Highlight-Column", int(f[2:]))
    else:
      GPS.Logger("gnatpp").log ("ignore switch " + f)

  if not compact_layout:
    set_pref("-l3", "Ada-Record-Level", indent_level)

GPS.Hook ("project_view_changed").add (project_recomputed)