From 284c1e76acf41e235210e3d339b627f29a22beab Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 27 Nov 2011 00:29:34 +0000 Subject: [PATCH] cody: dictionary: hide units of other projects git-svn-id: trunk@33812 - --- .../codetools/ide/codyidentifiersdlg.pas | 59 +++++++++++-------- components/codetools/ide/codystrconsts.pas | 1 + .../ide/languages/codystrconsts.it.po | 4 ++ .../codetools/ide/languages/codystrconsts.po | 4 ++ .../ide/languages/codystrconsts.pt_BR.po | 4 ++ .../ide/languages/codystrconsts.ru.po | 4 ++ .../ide/languages/codystrconsts.uk.po | 4 ++ 7 files changed, 55 insertions(+), 25 deletions(-) diff --git a/components/codetools/ide/codyidentifiersdlg.pas b/components/codetools/ide/codyidentifiersdlg.pas index ab1b943098..f25b894e89 100644 --- a/components/codetools/ide/codyidentifiersdlg.pas +++ b/components/codetools/ide/codyidentifiersdlg.pas @@ -45,7 +45,7 @@ interface uses Classes, SysUtils, FileProcs, LResources, LCLProc, avl_tree, Forms, Controls, Graphics, Dialogs, ButtonPanel, StdCtrls, ExtCtrls, LCLType, - PackageIntf, LazIDEIntf, SrcEditorIntf, ProjectIntf, + PackageIntf, LazIDEIntf, SrcEditorIntf, ProjectIntf, CompOptsIntf, CodeCache, BasicCodeTools, CustomCodeTool, CodeToolManager, UnitDictionary, CodeTree, LinkScanner, DefineTemplates, CodyStrConsts, CodyUtils; @@ -144,7 +144,7 @@ type function GetFilterEditText: string; function FindSelectedItem(out Identifier, UnitFilename, GroupFilename: string): boolean; - procedure GetCurOwnerOfUnit; + procedure UpdateCurOwnerOfUnit; procedure AddToUsesSection; procedure UpdateTool; function GetFPCSrcDir(const Directory: string): string; @@ -160,10 +160,14 @@ type CurSrcEdit: TSourceEditorInterface; CurMainFilename: string; // if CurSrcEdit is an include file, then CurMainFilename<>CurSrcEdit.Filename CurMainCode: TCodeBuffer; + CurOwner: TObject; + CurUnitPath: String; // depends on CurOwner + NewIdentifier: string; NewUnitFilename: string; NewGroupFilename: string; + function Init: boolean; procedure UseIdentifier; property IdleConnected: boolean read FIdleConnected write SetIdleConnected; @@ -575,6 +579,7 @@ begin FNoFilterText:=crsFilter; FItems:=TStringList.Create; HideOtherProjectsCheckBox.Checked:=true; + HideOtherProjectsCheckBox.Caption:=crsHideUnitsOfOtherProjects; end; procedure TCodyIdentifiersDlg.HideOtherProjectsCheckBoxChange(Sender: TObject); @@ -625,7 +630,6 @@ end; procedure TCodyIdentifiersDlg.UpdateItemsList; var - Filter: String; Node: TAVLTreeNode; FilterP: PChar; sl: TStringList; @@ -636,11 +640,9 @@ var Group: TUDUnitGroup; FPCSrcDir: String; Dir: String; - UseGroup: Boolean; begin - Filter:=GetFilterEditText; - FLastFilter:=Filter; - FilterP:=PChar(Filter); + FLastFilter:=GetFilterEditText; + FilterP:=PChar(FLastFilter); FLastHideOtherProjects:=HideOtherProjectsCheckBox.Checked; @@ -660,30 +662,33 @@ begin GroupNode:=Item.DUnit.UnitGroups.FindLowest; while GroupNode<>nil do begin Group:=TUDUnitGroup(GroupNode.Data); - UseGroup:=false; + GroupNode:=Item.DUnit.UnitGroups.FindSuccessor(GroupNode); + if not FilenameIsAbsolute(Item.DUnit.Filename) then continue; if Group.Name='' then begin // it's a unit without package - UseGroup:=true + if FLastHideOtherProjects then begin + // check if unit is in unit path of current owner + if CurUnitPath='' then continue; + if FindPathInSearchPath(PChar(CurUnitPath),length(CurUnitPath), + PChar(CurUnitPath),length(CurUnitPath))=nil + then continue; + end; end else if Group.Name=PackageNameFPCSrcDir then begin // it's a FPC source directory // => check if it is the current one Dir:=ExtractFilePath(Group.Filename); - UseGroup:=CompareFilenames(Dir,FPCSrcDir)=0; + if CompareFilenames(Dir,FPCSrcDir)<>0 then continue; // ToDo: check if ppu is there end else if FileExistsCached(Group.Filename) then begin // lpk exists - UseGroup:=true; end; - if UseGroup then begin - s:=Item.Name+' in '+Item.DUnit.Name; - if Group.Name<>'' then - s:=s+' of '+Group.Name; - if FileExistsCached(Item.DUnit.Filename) then begin - FItems.Add(Item.Name+#10+Item.DUnit.Filename+#10+Group.Filename); - sl.Add(s); - end; + s:=Item.Name+' in '+Item.DUnit.Name; + if Group.Name<>'' then + s:=s+' of '+Group.Name; + if FileExistsCached(Item.DUnit.Filename) then begin + FItems.Add(Item.Name+#10+Item.DUnit.Filename+#10+Group.Filename); + sl.Add(s); end; - GroupNode:=Item.DUnit.UnitGroups.FindSuccessor(GroupNode); end; end; end; @@ -789,7 +794,7 @@ begin CurIdentifier:=copy(Line,CurIdentStart,CurIdentEnd-CurIdentStart); end; - GetCurOwnerOfUnit; + UpdateCurOwnerOfUnit; UpdateGeneralInfo; FLastFilter:='...'; // force one update if CurIdentifier='' then @@ -818,7 +823,7 @@ begin CurMainFilename:=CurSrcEdit.FileName; CurMainCode:=TCodeBuffer(CurSrcEdit.CodeToolsBuffer); end; - GetCurOwnerOfUnit; + UpdateCurOwnerOfUnit; if CurOwner<>nil then begin // ToDo: add dependency @@ -831,7 +836,7 @@ begin end; end; -procedure TCodyIdentifiersDlg.GetCurOwnerOfUnit; +procedure TCodyIdentifiersDlg.UpdateCurOwnerOfUnit; procedure GetBest(OwnerList: TFPList); var @@ -846,6 +851,8 @@ procedure TCodyIdentifiersDlg.GetCurOwnerOfUnit; OwnerList.Free; end; +var + CompOpts: TLazCompilerOptions; begin CurOwner:=nil; if CurMainFilename='' then exit; @@ -854,11 +861,13 @@ begin GetBest(PackageEditingInterface.GetPossibleOwnersOfUnit(CurMainFilename, [piosfIncludeSourceDirectories])); if CurOwner<>nil then begin + CompOpts:=nil; if CurOwner is TLazProject then begin - //TLazProject(CurOwner).LazCompilerOptions.GetUnitOutputDirectory(); + CompOpts:=TLazProject(CurOwner).LazCompilerOptions; end else if CurOwner is TIDEPackage then begin - //TIDEPackage(CurOwner); + CompOpts:=TIDEPackage(CurOwner).LazCompilerOptions; end; + CurUnitPath:=CompOpts.GetUnitPath(false); end; end; diff --git a/components/codetools/ide/codystrconsts.pas b/components/codetools/ide/codystrconsts.pas index c352b50d53..2d31b68b64 100644 --- a/components/codetools/ide/codystrconsts.pas +++ b/components/codetools/ide/codystrconsts.pas @@ -164,6 +164,7 @@ resourcestring crsOptions = 'Options'; crsRefresh = 'Refresh'; crsFilter = '(Filter)'; + crsHideUnitsOfOtherProjects = 'Hide units of other projects'; crsUseIdentifier = 'Use identifier'; crsAndMoreIdentifiers = '... and %s more identifiers'; crsCodyIdentifierDictionary = 'Cody Identifier Dictionary'; diff --git a/components/codetools/ide/languages/codystrconsts.it.po b/components/codetools/ide/languages/codystrconsts.it.po index 75f5e59276..6061de3eb0 100644 --- a/components/codetools/ide/languages/codystrconsts.it.po +++ b/components/codetools/ide/languages/codystrconsts.it.po @@ -262,6 +262,10 @@ msgstr "Gbyte" msgid "&Help" msgstr "" +#: codystrconsts.crshideunitsofotherprojects +msgid "Hide units of other projects" +msgstr "" + #: codystrconsts.crsinimplementation msgid "In implementation" msgstr "" diff --git a/components/codetools/ide/languages/codystrconsts.po b/components/codetools/ide/languages/codystrconsts.po index 0214b5bef7..1b980c809a 100644 --- a/components/codetools/ide/languages/codystrconsts.po +++ b/components/codetools/ide/languages/codystrconsts.po @@ -253,6 +253,10 @@ msgstr "" msgid "&Help" msgstr "" +#: codystrconsts.crshideunitsofotherprojects +msgid "Hide units of other projects" +msgstr "" + #: codystrconsts.crsinimplementation msgid "In implementation" msgstr "" diff --git a/components/codetools/ide/languages/codystrconsts.pt_BR.po b/components/codetools/ide/languages/codystrconsts.pt_BR.po index 1ff26886cf..4330ffd248 100644 --- a/components/codetools/ide/languages/codystrconsts.pt_BR.po +++ b/components/codetools/ide/languages/codystrconsts.pt_BR.po @@ -267,6 +267,10 @@ msgstr "Gbytes" msgid "&Help" msgstr "&Ajuda" +#: codystrconsts.crshideunitsofotherprojects +msgid "Hide units of other projects" +msgstr "" + #: codystrconsts.crsinimplementation msgid "In implementation" msgstr "Na implementação" diff --git a/components/codetools/ide/languages/codystrconsts.ru.po b/components/codetools/ide/languages/codystrconsts.ru.po index c24f99653e..741d90620e 100644 --- a/components/codetools/ide/languages/codystrconsts.ru.po +++ b/components/codetools/ide/languages/codystrconsts.ru.po @@ -267,6 +267,10 @@ msgstr "ГБ" msgid "&Help" msgstr "&Справка" +#: codystrconsts.crshideunitsofotherprojects +msgid "Hide units of other projects" +msgstr "" + #: codystrconsts.crsinimplementation msgid "In implementation" msgstr "В секции Implementation" diff --git a/components/codetools/ide/languages/codystrconsts.uk.po b/components/codetools/ide/languages/codystrconsts.uk.po index a6fff37f27..7807df9bbf 100644 --- a/components/codetools/ide/languages/codystrconsts.uk.po +++ b/components/codetools/ide/languages/codystrconsts.uk.po @@ -271,6 +271,10 @@ msgstr "ГБ" msgid "&Help" msgstr "&Довідка" +#: codystrconsts.crshideunitsofotherprojects +msgid "Hide units of other projects" +msgstr "" + #: codystrconsts.crsinimplementation msgid "In implementation" msgstr "В реалізації"