MG: added uni dependencies

git-svn-id: trunk@3339 -
This commit is contained in:
lazarus 2002-09-14 07:05:15 +00:00
parent 75eead7d4a
commit 7c2bb90b7b
6 changed files with 57 additions and 3 deletions

View File

@ -247,6 +247,8 @@ type
const NewUnitName, NewUnitInFile: string): boolean;
function RemoveUnitFromAllUsesSections(Code: TCodeBuffer;
const AnUnitName: string): boolean;
function FindUsedUnits(Code: TCodeBuffer; var MainUsesSection,
ImplementationUsesSection: TStrings): boolean;
// resources
function FindLFMFileName(Code: TCodeBuffer): string;
@ -1140,6 +1142,22 @@ begin
end;
end;
function TCodeToolManager.FindUsedUnits(Code: TCodeBuffer; var MainUsesSection,
ImplementationUsesSection: TStrings): boolean;
begin
Result:=false;
{$IFDEF CTDEBUG}
writeln('TCodeToolManager.FindUsedUnits A ',Code.Filename);
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.FindUsedUnits(MainUsesSection,
ImplementationUsesSection);
except
on e: Exception do Result:=HandleException(e);
end;
end;
function TCodeToolManager.FindLFMFileName(Code: TCodeBuffer): string;
var LinkIndex: integer;
CurCode: TCodeBuffer;

View File

@ -2555,7 +2555,7 @@ begin
if (fdfIgnoreUsedUnits in Params.Flags) then begin
if CompareSrcIdentifiers(UnitNameAtom.StartPos,Params.Identifier) then
begin
// the searched identifier was a uses unitname, but since the unit
// the searched identifier was a uses unitname, but because the unit
// should not be opened, point to identifier in the uses section
Result:=true;
Params.SetResult(Self,UsesNode,UnitNameAtom.StartPos);

View File

@ -87,6 +87,8 @@ type
SourceChangeCache: TSourceChangeCache): boolean;
function RemoveUnitFromAllUsesSections(const UpperUnitName: string;
SourceChangeCache: TSourceChangeCache): boolean;
function FindUsedUnits(var MainUsesSection,
ImplementationUsesSection: TStrings): boolean;
// lazarus resources
function FindNextIncludeInInitialization(
@ -517,6 +519,29 @@ begin
end;
end;
function TStandardCodeTool.FindUsedUnits(var MainUsesSection,
ImplementationUsesSection: TStrings): boolean;
function UsesSectionToStrings(ANode: TCodeTreeNode): TStrings;
begin
Result:=TStringList.Create;
if ANode=nil then exit;
end;
var
MainUsesNode, ImplementatioUsesNode: TCodeTreeNode;
begin
// find the uses sections
BuildTree(false);
MainUsesNode:=FindMainUsesSection;
ImplementatioUsesNode:=FindImplementationUsesSection;
// create lists
MainUsesSection:=UsesSectionToStrings(MainUsesNode);
ImplementationUsesSection:=UsesSectionToStrings(ImplementatioUsesNode);
Result:=true;
end;
function TStandardCodeTool.FindNextIncludeInInitialization(
var LinkIndex: integer): TCodeBuffer;
// LinkIndex < 0 -> search first

View File

@ -126,8 +126,9 @@ const
ecToggleDebuggerOut = ecUserFirst + 308;
ecViewUnits = ecUserFirst + 309;
ecViewForms = ecUserFirst + 310;
ecToggleLocals = ecUserFirst + 311;
ecToggleCallStack = ecUserFirst + 312;
ecViewUnitDependencies = ecUserFirst + 311;
ecToggleLocals = ecUserFirst + 312;
ecToggleCallStack = ecUserFirst + 313;
ecBuild = ecUserFirst + 400;
ecRun = ecUserFirst + 401;
@ -564,6 +565,7 @@ begin
ecToggleCallStack: Result := 'view call stack';
ecViewUnits: Result:= 'view units';
ecViewForms: Result:= 'view forms';
ecViewUnitDependencies: Result:= 'view unit dependencies';
// codetools
ecWordCompletion: Result:= 'word completion';
@ -1382,6 +1384,7 @@ begin
Add(C,'Toggle view Debugger Output',ecToggleDebuggerOut,VK_UNKNOWN,[],VK_UNKNOWN,[]);
Add(C,'View Units',ecViewUnits,VK_F12,[ssCtrl],VK_UNKNOWN,[]);
Add(C,'View Forms',ecViewForms,VK_F12,[ssShift],VK_UNKNOWN,[]);
Add(C,'View Unit Dependencies',ecViewUnitDependencies,VK_UNKNOWN,[],VK_UNKNOWN,[]);
Add(C,'Focus to source editor',ecJumpToEditor,VK_UNKNOWN,[],VK_UNKNOWN,[]);
Add(C,'Toggle between Unit and Form',ecToggleFormUnit,VK_F12,[],VK_UNKNOWN,[]);

View File

@ -156,6 +156,7 @@ resourcestring
lisMenuViewCodeExplorer = 'Code Explorer';
lisMenuViewUnits = 'Units...';
lisMenuViewForms = 'Forms...';
lisMenuViewUnitDependencies = 'Unit Dependencies ...';
lisMenuViewToggleFormUnit = 'Toggle form/unit view';
lisMenuViewMessages = 'Messages';
lisMenuDebugWindows = 'Debug windows';

View File

@ -195,6 +195,7 @@ type
itmViewUnits : TMenuItem;
itmViewCodeExplorer : TMenuItem;
itmViewForms : TMenuItem;
itmViewUnitDependencies : TMenuItem;
itmViewMessage : TMenuItem;
itmViewDebugWindows: TMenuItem;
itmViewWatches: TMenuItem;
@ -756,6 +757,11 @@ begin
itmViewForms.Caption := lisMenuViewForms;
mnuView.Add(itmViewForms);
itmViewUnitDependencies := TMenuItem.Create(Self);
itmViewUnitDependencies.Name:='itmViewUnitDependencies';
itmViewUnitDependencies.Caption := lisMenuViewUnitDependencies;
mnuView.Add(itmViewUnitDependencies);
mnuView.Add(CreateMenuSeparator);
itmViewToggleFormUnit := TMenuItem.Create(Self);
@ -1061,6 +1067,7 @@ begin
itmViewProject.ShortCut:=CommandToShortCut(ecToggleProjectExpl);
itmViewUnits.ShortCut:=CommandToShortCut(ecViewUnits);
itmViewCodeExplorer.ShortCut:=CommandToShortCut(ecToggleCodeExpl);
itmViewUnitDependencies.ShortCut:=CommandToShortCut(ecViewUnitDependencies);
itmViewForms.ShortCut:=CommandToShortCut(ecViewForms);
itmViewToggleFormUnit.ShortCut:=CommandToShortCut(ecToggleFormUnit);
itmViewMessage.ShortCut:=CommandToShortCut(ecToggleMessages);