This file is indexed.

/usr/lib/lazarus/0.9.30.4/ide/useprojunitdlg.pas is in lazarus-src-0.9.30.4 0.9.30.4-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
 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
unit UseProjUnitDlg;

{$mode objfpc}{$H+}

interface

uses
  Classes, LCLProc, Forms, Controls, ComCtrls, StdCtrls, ExtCtrls, Buttons,
  ButtonPanel, Dialogs,
  SrcEditorIntf, LazIDEIntf, IDEImagesIntf, LazarusIDEStrConsts,
  ProjectIntf, Project, CodeCache, CodeToolManager;

type

  { TUseProjUnitDialog }

  TUseProjUnitDialog = class(TForm)
    ButtonPanel1: TButtonPanel;
    UnitsListBox: TListBox;
    SectionRadioGroup: TRadioGroup;
  private
    procedure AddItems(AItems: TStrings);
    function SelectFirst: string;
    function SelectedUnit: string;
    function InterfaceSelected: Boolean;
  public

  end; 

  function ShowUseProjUnitDialog: TModalResult;

implementation

{$R *.lfm}

function ShowUseProjUnitDialog: TModalResult;
var
  UseProjUnitDlg: TUseProjUnitDialog;
  SrcEdit: TSourceEditorInterface;
  Code: TCodeBuffer;
  CurFile: TUnitInfo;
  MainUsedUnits, ImplUsedUnits: TStrings;
  AvailUnits: TStringList;
  s: String;
  IsIntf, CTRes: Boolean;
begin
  Result:=mrOk;
  if not LazarusIDE.BeginCodeTools then exit;
  // get cursor position
  SrcEdit:=SourceEditorManagerIntf.ActiveEditor;
  if SrcEdit=nil then exit;
  Code:=TCodeBuffer(SrcEdit.CodeToolsBuffer);
  if Code=nil then exit;
  UseProjUnitDlg:=nil;
  MainUsedUnits:=nil;
  ImplUsedUnits:=nil;
  AvailUnits:=TStringList.Create;
  try
    if not CodeToolBoss.FindUsedUnitNames(Code,MainUsedUnits,ImplUsedUnits) then begin
      DebugLn(['ShowUseProjUnitDialog CodeToolBoss.FindUsedUnitNames failed']);
      LazarusIDE.DoJumpToCodeToolBossError;
      exit(mrCancel);
    end;
    TStringList(MainUsedUnits).CaseSensitive:=False;
    TStringList(ImplUsedUnits).CaseSensitive:=False;
    // Create dialog and add available unit names there.
    UseProjUnitDlg:=TUseProjUnitDialog.Create(nil);
    CurFile:=Project1.FirstPartOfProject;
    while CurFile<>nil do begin
      s:=CurFile.Unit_Name;
      if (MainUsedUnits.IndexOf(s)<0) and (ImplUsedUnits.IndexOf(s)<0) then
        AvailUnits.Add(s);
      CurFile:=CurFile.NextPartOfProject;
    end;
    // Show the dialog.
    if AvailUnits.Count>0 then begin
      AvailUnits.Sorted:=True;
      UseProjUnitDlg.AddItems(AvailUnits);
      UseProjUnitDlg.SelectFirst;
      if UseProjUnitDlg.ShowModal=mrOk then begin
        s:=UseProjUnitDlg.SelectedUnit;
        IsIntf:=UseProjUnitDlg.InterfaceSelected;
        if s<>'' then begin
          CTRes:=True;
          if IsIntf then
            CTRes:=CodeToolBoss.AddUnitToMainUsesSection(Code, s, '')
          else
            CTRes:=CodeToolBoss.AddUnitToImplementationUsesSection(Code, s, '');
          if not CTRes then begin
            LazarusIDE.DoJumpToCodeToolBossError;
            exit(mrCancel);
          end;
        end;
      end;
    end
    else
      ShowMessage('No unused items are available in this project.');
  finally
    CodeToolBoss.SourceCache.ClearAllSourceLogEntries;
    UseProjUnitDlg.Free;
    ImplUsedUnits.Free;
    MainUsedUnits.Free;
    AvailUnits.Free;
  end;
end;

{ TUseProjUnitDialog }

procedure TUseProjUnitDialog.AddItems(AItems: TStrings);
begin
  UnitsListBox.Items.Assign(AItems);
end;

function TUseProjUnitDialog.SelectFirst: string;
begin
  UnitsListBox.Selected[0]:=True;
end;

function TUseProjUnitDialog.SelectedUnit: string;
begin
  Result:=UnitsListBox.Items[UnitsListBox.ItemIndex];
end;

function TUseProjUnitDialog.InterfaceSelected: Boolean;
begin
  Result:=SectionRadioGroup.ItemIndex=0;
end;


end.