IDE: fixed GetPossibleOwnersOfUnit finding units in project directory

git-svn-id: trunk@35160 -
This commit is contained in:
mattias 2012-02-05 14:22:35 +00:00
parent 7f5a352702
commit dce2a00f90
8 changed files with 179 additions and 78 deletions

View File

@ -922,7 +922,6 @@ var
// it's a unit without package
if FLastHideOtherProjects then begin
// check if unit is in unit path of current owner
debugln(['AddItems AAA1 CurUnitPath="',CurUnitPath,'" Dir=',ExtractFilePath(Item.DUnit.Filename)]);
if CurUnitPath='' then continue;
Dir:=ExtractFilePath(Item.DUnit.Filename);
if (Dir<>'')
@ -1482,18 +1481,14 @@ begin
CurOwner:=nil;
CurUnitPath:='';
if CurMainFilename='' then exit;
debugln(['TCodyIdentifiersDlg.UpdateCurOwnerOfUnit CurMainFilename=',CurMainFilename]);
GetBest(PackageEditingInterface.GetOwnersOfUnit(CurMainFilename));
if CurOwner=nil then
GetBest(PackageEditingInterface.GetPossibleOwnersOfUnit(CurMainFilename,
[piosfExcludeOwned,piosfIncludeSourceDirectories]));
debugln(['TCodyIdentifiersDlg.UpdateCurOwnerOfUnit CurOwner=',DbgSName(CurOwner)]);
if CurOwner<>nil then begin
CompOpts:=GetCurOwnerCompilerOptions;
debugln(['TCodyIdentifiersDlg.UpdateCurOwnerOfUnit CompOpts=',DbgSName(CompOpts)]);
if CompOpts<>nil then
CurUnitPath:=CompOpts.GetUnitPath(false);
debugln(['TCodyIdentifiersDlg.UpdateCurOwnerOfUnit CurUnitPath="',CurUnitPath,'"']);
end;
end;

View File

@ -1,30 +1,30 @@
object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
Left = 330
Height = 460
Height = 522
Top = 280
Width = 622
Width = 649
Caption = 'EditIDEMsgHelpDialog'
ClientHeight = 460
ClientWidth = 622
ClientHeight = 522
ClientWidth = 649
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '0.9.31'
object CurMsgGroupBox: TGroupBox
Left = 6
Height = 105
Top = 6
Width = 610
Top = 94
Width = 637
Align = alTop
BorderSpacing.Around = 6
Caption = 'CurMsgGroupBox'
ClientHeight = 89
ClientWidth = 606
ClientWidth = 633
TabOrder = 0
object CurMsgMemo: TMemo
Left = 0
Height = 89
Top = 0
Width = 606
Width = 633
Align = alClient
Lines.Strings = (
'CurMsgMemo'
@ -37,8 +37,8 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
object ButtonPanel1: TButtonPanel
Left = 6
Height = 42
Top = 412
Width = 610
Top = 474
Width = 637
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
@ -52,18 +52,18 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
end
object AllGroupBox: TGroupBox
Left = 6
Height = 289
Top = 117
Height = 263
Top = 205
Width = 277
Align = alLeft
BorderSpacing.Around = 6
Caption = 'AllGroupBox'
ClientHeight = 273
ClientHeight = 247
ClientWidth = 273
TabOrder = 2
object URLsListBox: TListBox
Left = 0
Height = 247
Height = 221
Top = 0
Width = 273
Align = alClient
@ -75,7 +75,7 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
object AddButton: TButton
Left = 0
Height = 26
Top = 247
Top = 221
Width = 273
Align = alBottom
AutoSize = True
@ -85,14 +85,14 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
end
object CurGroupBox: TGroupBox
Left = 300
Height = 289
Top = 117
Width = 316
Height = 263
Top = 205
Width = 343
Align = alClient
BorderSpacing.Around = 6
Caption = 'CurGroupBox'
ClientHeight = 273
ClientWidth = 312
ClientHeight = 247
ClientWidth = 339
TabOrder = 3
object DeleteButton: TButton
AnchorSideLeft.Control = CurGroupBox
@ -128,7 +128,7 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
Left = 76
Height = 24
Top = 6
Width = 230
Width = 257
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
TabOrder = 1
@ -143,7 +143,7 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
Left = 6
Height = 15
Top = 126
Width = 300
Width = 327
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
@ -161,7 +161,7 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
Left = 6
Height = 24
Top = 141
Width = 300
Width = 327
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Right = 6
@ -178,7 +178,7 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
Left = 6
Height = 15
Top = 36
Width = 300
Width = 327
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
@ -196,7 +196,7 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
Left = 6
Height = 24
Top = 51
Width = 300
Width = 327
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Right = 6
@ -213,7 +213,7 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
Left = 6
Height = 15
Top = 81
Width = 300
Width = 327
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
@ -231,7 +231,7 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
Left = 6
Height = 24
Top = 96
Width = 300
Width = 327
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Right = 6
@ -242,8 +242,70 @@ object EditIDEMsgHelpDialog: TEditIDEMsgHelpDialog
end
object Splitter1: TSplitter
Left = 289
Height = 289
Top = 117
Height = 263
Top = 205
Width = 5
end
object GlobalOptionsGroupBox: TGroupBox
Left = 6
Height = 82
Top = 6
Width = 637
Align = alTop
AutoSize = True
BorderSpacing.Around = 6
Caption = 'GlobalOptionsGroupBox'
ClientHeight = 66
ClientWidth = 633
TabOrder = 5
object FPCMsgFileLabel: TLabel
AnchorSideLeft.Control = GlobalOptionsGroupBox
AnchorSideTop.Control = FPCMsgFileEdit
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 11
Width = 92
BorderSpacing.Left = 6
Caption = 'FPCMsgFileLabel'
ParentColor = False
end
object FPCMsgFileEdit: TEdit
AnchorSideLeft.Control = FPCMsgFileLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GlobalOptionsGroupBox
Left = 104
Height = 24
Top = 6
Width = 283
BorderSpacing.Around = 6
TabOrder = 0
Text = 'FPCMsgFileEdit'
end
object AdditionsFileLabel: TLabel
AnchorSideLeft.Control = GlobalOptionsGroupBox
AnchorSideTop.Control = AdditionsFileEdit
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 41
Width = 100
BorderSpacing.Around = 6
Caption = 'AdditionsFileLabel'
ParentColor = False
end
object AdditionsFileEdit: TEdit
AnchorSideLeft.Control = AdditionsFileLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FPCMsgFileEdit
AnchorSideTop.Side = asrBottom
Left = 112
Height = 24
Top = 36
Width = 280
BorderSpacing.Around = 6
TabOrder = 1
Text = 'AdditionsFileEdit'
end
end
end

View File

@ -62,7 +62,8 @@ type
private
fAdditions: TMessageHelpAdditions;
FAdditionsChangeStep: integer;
FAdditionsFilename: string;
FAdditionsFile: string;
FDefaultAdditionsFile: string;
FFPCTranslationFile: string;
FDefaultNode: THelpNode;
FFoundComment: string;
@ -71,7 +72,7 @@ type
FMsgFileChangeStep: integer;
FMsgFilename: string;
function GetAdditions(Index: integer): TMessageHelpAddition;
procedure SetAdditionsFilename(AValue: string);
procedure SetAdditionsFile(AValue: string);
procedure SetFPCTranslationFile(const AValue: string);
procedure SetFoundComment(const AValue: string);
procedure SetLastMessage(const AValue: string);
@ -89,15 +90,20 @@ type
property DefaultNode: THelpNode read FDefaultNode;
property LastMessage: string read FLastMessage write SetLastMessage;
property FoundComment: string read FFoundComment write SetFoundComment;
// the FPC message file
function GetMsgFile: TFPCMsgFile;
property MsgFile: TFPCMsgFile read FMsgFile;
property MsgFilename: string read FMsgFilename;
property MsgFileChangeStep: integer read FMsgFileChangeStep;
// additional help for messages (they add an URL to the FPC comments)
function AdditionsCount: integer;
property Additions[Index: integer]: TMessageHelpAddition read GetAdditions;
property AdditionsFilename: string read FAdditionsFilename write SetAdditionsFilename;
property AdditionsChangeStep: integer read FAdditionsChangeStep;
property DefaultAdditionsFile: string read FDefaultAdditionsFile;
published
property AdditionsFile: string read FAdditionsFile write SetAdditionsFile;
property FPCTranslationFile: string read FFPCTranslationFile
write SetFPCTranslationFile;
end;
@ -106,11 +112,16 @@ type
TEditIDEMsgHelpDialog = class(TForm)
AddButton: TButton;
AdditionsFileEdit: TEdit;
AdditionsFileLabel: TLabel;
ButtonPanel1: TButtonPanel;
CurGroupBox: TGroupBox;
CurMsgGroupBox: TGroupBox;
CurMsgMemo: TMemo;
DeleteButton: TButton;
FPCMsgFileEdit: TEdit;
FPCMsgFileLabel: TLabel;
GlobalOptionsGroupBox: TGroupBox;
NameEdit: TEdit;
NameLabel: TLabel;
OnlyFPCMsgIDsLabel: TLabel;
@ -126,12 +137,26 @@ type
public
end;
function ShowMessageHelpEditor: TModalResult;
procedure CreateFPCMessagesHelpDB;
function AddFPCMessageHelpItem(const Title, URL, RegularExpression: string
): THelpDBIRegExprMessage;
implementation
function ShowMessageHelpEditor: TModalResult;
var
Editor: TEditIDEMsgHelpDialog;
begin
Editor:=TEditIDEMsgHelpDialog.Create(nil);
try
Result:=Editor.ShowModal;
finally
Editor.Free;
end;
end;
procedure CreateFPCMessagesHelpDB;
var
FPCHelp: TFPCMessagesHelpDatabase;
@ -207,10 +232,10 @@ begin
Result:=fAdditions[Index];
end;
procedure TFPCMessagesHelpDatabase.SetAdditionsFilename(AValue: string);
procedure TFPCMessagesHelpDatabase.SetAdditionsFile(AValue: string);
begin
if FAdditionsFilename=AValue then Exit;
FAdditionsFilename:=AValue;
if FAdditionsFile=AValue then Exit;
FAdditionsFile:=AValue;
FAdditionsChangeStep:=CTInvalidChangeStamp;
end;
@ -223,8 +248,10 @@ end;
constructor TFPCMessagesHelpDatabase.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FDefaultAdditionsFile:='$(LazarusDir)/docs/additionalmsghelp.xml';
fAdditions:=TMessageHelpAdditions.Create;
FAdditionsChangeStep:=CTInvalidChangeStamp;
FAdditionsFile:=DefaultAdditionsFile;
FMsgFileChangeStep:=CTInvalidChangeStamp;
FDefaultNode:=THelpNode.CreateURL(Self,'FPC messages: Appendix',
'http://lazarus-ccr.sourceforge.net/fpcdoc/user/userap3.html#x81-168000C');
@ -281,12 +308,14 @@ procedure TFPCMessagesHelpDatabase.Load(Storage: TConfigStorage);
begin
inherited Load(Storage);
FPCTranslationFile:=Storage.GetValue('FPCTranslationFile/Value','');
AdditionsFile:=Storage.GetValue('Additions/Filename',DefaultAdditionsFile);
end;
procedure TFPCMessagesHelpDatabase.Save(Storage: TConfigStorage);
begin
inherited Save(Storage);
Storage.SetDeleteValue('FPCTranslationFile/Value',FPCTranslationFile,'');
Storage.SetDeleteValue('Additions/Filename',AdditionsFile,DefaultAdditionsFile);
end;
function TFPCMessagesHelpDatabase.GetMsgFile: TFPCMsgFile;

View File

@ -168,11 +168,14 @@ type
{ TIDEHelpManager }
TIDEHelpManager = class(TBaseHelpManager)
procedure mnuSearchInFPDocFilesClick(Sender: TObject);
// help menu of the IDE menu bar
procedure mnuHelpAboutLazarusClicked(Sender: TObject);
procedure mnuHelpOnlineHelpClicked(Sender: TObject);
procedure mnuHelpReportBugClicked(Sender: TObject);
// fpdoc
procedure mnuSearchInFPDocFilesClick(Sender: TObject);
// messages
procedure mnuEditMessageHelpClick(Sender: TObject);
private
FFCLHelpDBPath: THelpBaseURLObject;
FMainHelpDB: THelpDatabase;
@ -1115,6 +1118,11 @@ begin
ShowFPDocFileSearch;
end;
procedure TIDEHelpManager.mnuEditMessageHelpClick(Sender: TObject);
begin
end;
procedure TIDEHelpManager.mnuHelpAboutLazarusClicked(Sender: TObject);
begin
ShowAboutForm;
@ -1301,6 +1309,8 @@ begin
{$IFDEF EnableFPDocSearch}
itmSearchInFPDocFiles.OnClick:=@mnuSearchInFPDocFilesClick;
{$ENDIF}
end;
end;

View File

@ -284,6 +284,7 @@ resourcestring
lisExpandAll = 'Expand All (*)';
lisCollapseAll = 'Collapse All (/)';
lisSaveAllMessagesToFile = 'Save All Messages to File';
lisEditHelp = 'Edit help';
lisMenuViewSearchResults = 'Search Results';
lisMenuViewAnchorEditor = 'Anchor Editor';
lisMenuViewTabOrder = 'Tab Order';

View File

@ -93,6 +93,7 @@ type
procedure CopyAllMenuItemClick(Sender: TObject);
procedure CopyAllAndHiddenMenuItemClick(Sender: TObject);
procedure CopyMenuItemClick(Sender: TObject);
procedure EditHelpMenuItemClick(Sender: TObject);
procedure FormDeactivate(Sender: TObject);
procedure HelpMenuItemClick(Sender: TObject);
procedure ClearMenuItemClick(Sender: TObject);
@ -193,13 +194,14 @@ type
var
MessagesView: TMessagesView = nil;
MsgQuickFixIDEMenuSection: TIDEMenuSection;
MsgClearIDEMenuCommand: TIDEMenuCommand;
MsgCopyIDEMenuCommand: TIDEMenuCommand;
MsgCopyAllIDEMenuCommand: TIDEMenuCommand;
MsgCopyAllAndHiddenIDEMenuCommand: TIDEMenuCommand;
MsgHelpIDEMenuCommand: TIDEMenuCommand;
MsgSaveAllToFileIDEMenuCommand: TIDEMenuCommand;
MsgQuickFixMenuSection: TIDEMenuSection;
MsgClearMenuItem: TIDEMenuCommand;
MsgCopyMenuItem: TIDEMenuCommand;
MsgCopyAllMenuItem: TIDEMenuCommand;
MsgCopyAllAndHiddenMenuItem: TIDEMenuCommand;
MsgHelpMenuItem: TIDEMenuCommand;
MsgEditHelpMenuItem: TIDEMenuCommand;
MsgSaveAllToFileMenuItem: TIDEMenuCommand;
const
MessagesMenuRootName = 'Messages';
@ -262,21 +264,16 @@ var
begin
MessagesMenuRoot := RegisterIDEMenuRoot(MessagesMenuRootName);
Path := MessagesMenuRoot.Name;
MsgQuickFixIDEMenuSection := RegisterIDEMenuSection(Path, 'Quick Fix');
MsgClearIDEMenuCommand :=
RegisterIDEMenuCommand(Path, 'Clear', lisUIDClear);
MsgCopyIDEMenuCommand := RegisterIDEMenuCommand(Path, 'Copy selected',
lisCopySelectedMessagesToClipboard);
MsgCopyAllIDEMenuCommand := RegisterIDEMenuCommand(Path, 'Copy all',
lisCopyAllShownMessagesToClipboard);
MsgCopyAllAndHiddenIDEMenuCommand := RegisterIDEMenuCommand(Path,
'Copy all, including hidden messages',
lisCopyAllShownAndHiddenMessagesToClipboard);
MsgHelpIDEMenuCommand := RegisterIDEMenuCommand(Path, 'Help',
lisPckEditHelp);
MsgSaveAllToFileIDEMenuCommand :=
RegisterIDEMenuCommand(Path, 'Copy selected',
lisSaveAllMessagesToFile);
MsgQuickFixMenuSection := RegisterIDEMenuSection(Path, 'Quick Fix');
MsgClearMenuItem := RegisterIDEMenuCommand(Path, 'Clear', lisUIDClear);
MsgCopyMenuItem := RegisterIDEMenuCommand(Path, 'Copy selected',lisCopySelectedMessagesToClipboard);
MsgCopyAllMenuItem := RegisterIDEMenuCommand(Path, 'Copy all',lisCopyAllShownMessagesToClipboard);
MsgCopyAllAndHiddenMenuItem := RegisterIDEMenuCommand(Path,
'Copy all, including hidden messages',lisCopyAllShownAndHiddenMessagesToClipboard);
MsgHelpMenuItem := RegisterIDEMenuCommand(Path, 'Help for message',lisPckEditHelp);
MsgEditHelpMenuItem := RegisterIDEMenuCommand(Path, 'Edit help for messages',lisEditHelp);
MsgSaveAllToFileMenuItem :=
RegisterIDEMenuCommand(Path, 'Copy selected',lisSaveAllMessagesToFile);
end;
function MessageLinesAsText(ListOfTLazMessageLine: TFPList): string;
@ -343,12 +340,13 @@ begin
MessagesMenuRoot.MenuItem := MainPopupMenu.Items;
//MainPopupMenu.Items.WriteDebugReport('TMessagesView.Create ');
MsgHelpIDEMenuCommand.OnClick := @HelpMenuItemClick;
MsgClearIDEMenuCommand.OnClick := @ClearMenuItemClick;
MsgCopyIDEMenuCommand.OnClick := @CopyMenuItemClick;
MsgCopyAllIDEMenuCommand.OnClick := @CopyAllMenuItemClick;
MsgCopyAllAndHiddenIDEMenuCommand.OnClick := @CopyAllAndHiddenMenuItemClick;
MsgSaveAllToFileIDEMenuCommand.OnClick := @SaveAllToFileMenuItemClick;
MsgHelpMenuItem.OnClick := @HelpMenuItemClick;
MsgEditHelpMenuItem.OnClick:=@EditHelpMenuItemClick;
MsgClearMenuItem.OnClick := @ClearMenuItemClick;
MsgCopyMenuItem.OnClick := @CopyMenuItemClick;
MsgCopyAllMenuItem.OnClick := @CopyAllMenuItemClick;
MsgCopyAllAndHiddenMenuItem.OnClick := @CopyAllAndHiddenMenuItemClick;
MsgSaveAllToFileMenuItem.OnClick := @SaveAllToFileMenuItemClick;
FMarklings:=TMessageViewMarklings.Create(Self);
SourceEditorManagerIntf.RegisterMarklingProducer(FMarklings);
@ -944,6 +942,11 @@ begin
Clipboard.AsText := GetSelectedMessagesAsText;
end;
procedure TMessagesView.EditHelpMenuItemClick(Sender: TObject);
begin
// ShowMessageHelpEditor;
end;
procedure TMessagesView.FormDeactivate(Sender: TObject);
begin
FLastSelectedIndex:=-1;
@ -979,7 +982,7 @@ var
QuickFixItem: TIDEMsgQuickFixItem;
Msg: TLazMessageLine;
begin
MsgQuickFixIDEMenuSection.Clear;
MsgQuickFixMenuSection.Clear;
Msg:=GetMessageLine;
FQuickFixItems.Clear;
if Msg<>nil then begin
@ -993,7 +996,7 @@ begin
end;
for i:=0 to FQuickFixItems.Count-1 do begin
QuickFixItem:=TIDEMsgQuickFixItem(FQuickFixItems[i]);
RegisterIDEMenuCommand(MsgQuickFixIDEMenuSection,
RegisterIDEMenuCommand(MsgQuickFixMenuSection,
QuickFixItem.Name,
QuickFixItem.Caption,
@OnQuickFixClick);

View File

@ -21,7 +21,7 @@ unit MacroIntf;
interface
uses
Classes, SysUtils, FileUtil;
Classes, SysUtils, LazFileUtils;
type
{ TIDEMacros - macros for paths and compiler settings }
@ -133,7 +133,7 @@ begin
BaseDir:=BaseDirectory;
if not SubstituteMacros(BaseDir) then exit(false);
Result:=SubstituteMacros(SearchPath);
SearchPath:=FileUtil.CreateAbsoluteSearchPath(SearchPath,BaseDir);
SearchPath:=MinimizeSearchPath(LazFileUtils.CreateAbsoluteSearchPath(SearchPath,BaseDir));
end;
end.

View File

@ -3131,11 +3131,12 @@ var
and (BaseDir<>'') then begin
// search in project source directories
ProjectDirs:=AProject.LazCompilerOptions.OtherUnitFiles+';.';
if not IDEMacros.CreateAbsoluteSearchPath(ProjectDirs,BaseDir) then exit;
if FindPathInSearchPath(PChar(SrcDir),length(SrcDir),
PChar(ProjectDirs),length(ProjectDirs))<>nil
then
Add:=true;
if IDEMacros.CreateAbsoluteSearchPath(ProjectDirs,BaseDir) then begin
if FindPathInSearchPath(PChar(SrcDir),length(SrcDir),
PChar(ProjectDirs),length(ProjectDirs))<>nil
then
Add:=true;
end;
end;
if Add then