IDE: code help: fixed caching module owner

git-svn-id: trunk@15978 -
This commit is contained in:
mattias 2008-08-06 20:38:38 +00:00
parent b5a227e0d8
commit 6b0f252b00
2 changed files with 38 additions and 4 deletions

View File

@ -113,6 +113,7 @@ type
public public
SourceFilename: string; SourceFilename: string;
FPDocFilename: string; FPDocFilename: string;
FPDocFileOwner: TObject;
FPDocFilenameTimeStamp: integer; FPDocFilenameTimeStamp: integer;
FilesTimeStamp: integer; FilesTimeStamp: integer;
end; end;
@ -211,8 +212,9 @@ type
out AnOwner: TObject;// package or project out AnOwner: TObject;// package or project
CreateIfNotExists: boolean = false): string; CreateIfNotExists: boolean = false): string;
procedure GetFPDocFilenamesForSources(SrcFilenames: TStringToStringTree; procedure GetFPDocFilenamesForSources(SrcFilenames: TStringToStringTree;
ResolveIncludeFiles: boolean; ResolveIncludeFiles: boolean;
var FPDocFilenames: TStringToStringTree); var FPDocFilenames: TStringToStringTree // Names=Filename, Values=ModuleName
);
function FindModuleOwner(const Modulename: string): TObject; function FindModuleOwner(const Modulename: string): TObject;
function GetOwnerModuleName(TheOwner: TObject): string; function GetOwnerModuleName(TheOwner: TObject): string;
function ExpandFPDocLinkID(const LinkID, DefaultUnitName, function ExpandFPDocLinkID(const LinkID, DefaultUnitName,
@ -1255,6 +1257,7 @@ begin
MapEntry:=TCHSourceToFPDocFile(AVLNode.Data); MapEntry:=TCHSourceToFPDocFile(AVLNode.Data);
if (MapEntry.FPDocFilenameTimeStamp=CompilerParseStamp) if (MapEntry.FPDocFilenameTimeStamp=CompilerParseStamp)
and (MapEntry.FilesTimeStamp=FileStateCache.TimeStamp) then begin and (MapEntry.FilesTimeStamp=FileStateCache.TimeStamp) then begin
AnOwner:=MapEntry.FPDocFileOwner;
Result:=MapEntry.FPDocFilename; Result:=MapEntry.FPDocFilename;
exit; exit;
end; end;
@ -1284,6 +1287,7 @@ begin
end; end;
MapEntry.FPDocFilename:=Result; MapEntry.FPDocFilename:=Result;
MapEntry.FPDocFilenameTimeStamp:=CompilerParseStamp; MapEntry.FPDocFilenameTimeStamp:=CompilerParseStamp;
MapEntry.FPDocFileOwner:=AnOwner;
MapEntry.FilesTimeStamp:=FileStateCache.TimeStamp; MapEntry.FilesTimeStamp:=FileStateCache.TimeStamp;
finally finally
if (Result='') and CreateIfNotExists then begin if (Result='') and CreateIfNotExists then begin
@ -1317,7 +1321,7 @@ begin
if FPDocFilename<>'' then begin if FPDocFilename<>'' then begin
if FPDocFilenames=nil then if FPDocFilenames=nil then
FPDocFilenames:=CreateFilenameToStringTree; FPDocFilenames:=CreateFilenameToStringTree;
FPDocFilenames[FPDocFilename]:=SrcFilename; FPDocFilenames[FPDocFilename]:=GetOwnerModuleName(AnOwner);
end; end;
Node:=SrcFilenames.Tree.FindSuccessor(Node); Node:=SrcFilenames.Tree.FindSuccessor(Node);
end; end;
@ -1603,9 +1607,9 @@ begin
// find corresponding FPDoc file // find corresponding FPDoc file
CHElement.ElementUnitFileName:=CHElement.CodeContext.Tool.MainFilename; CHElement.ElementUnitFileName:=CHElement.CodeContext.Tool.MainFilename;
CHElement.ElementUnitName:=CHElement.CodeContext.Tool.GetSourceName(false); CHElement.ElementUnitName:=CHElement.CodeContext.Tool.GetSourceName(false);
AnOwner:=Self;
FPDocFilename:=GetFPDocFilenameForSource(CHElement.ElementUnitFileName, FPDocFilename:=GetFPDocFilenameForSource(CHElement.ElementUnitFileName,
false,CacheWasUsed,AnOwner); false,CacheWasUsed,AnOwner);
DebugLn(['TCodeHelpManager.GetElementChain ',dbgsName(AnOwner)]);
CHElement.ElementModuleName:=GetOwnerModuleName(AnOwner); CHElement.ElementModuleName:=GetOwnerModuleName(AnOwner);
//DebugLn(['TCodeHelpManager.GetElementChain FPDocFilename=',FPDocFilename]); //DebugLn(['TCodeHelpManager.GetElementChain FPDocFilename=',FPDocFilename]);
if (not CacheWasUsed) and (not Complete) then exit(chprParsing); if (not CacheWasUsed) and (not Complete) then exit(chprParsing);

View File

@ -94,6 +94,9 @@ procedure AddReferencesToResultView(DeclarationCode: TCodeBuffer;
function GatherFPDocReferences(PascalFiles: TStringList; function GatherFPDocReferences(PascalFiles: TStringList;
DeclarationCode: TCodeBuffer; const DeclarationCaretXY: TPoint; DeclarationCode: TCodeBuffer; const DeclarationCaretXY: TPoint;
var TreeOfPCodeXYPosition: TAVLTree): TModalResult; var TreeOfPCodeXYPosition: TAVLTree): TModalResult;
function GatherFPDocReferences(const ElementModuleName, ElementName,
FileModuleName, FPDocFilename: string;
var TreeOfPCodeXYPosition: TAVLTree): TModalResult;
implementation implementation
@ -277,6 +280,10 @@ var
Chain: TCodeHelpElementChain; Chain: TCodeHelpElementChain;
CHResult: TCodeHelpParseResult; CHResult: TCodeHelpParseResult;
CHElement: TCodeHelpElement; CHElement: TCodeHelpElement;
AVLNode: TAvgLvlTreeNode;
Item: PStringToStringItem;
FPDocFilename: String;
ModuleName: String;
begin begin
Result:=mrCancel; Result:=mrCancel;
PascalFilenames:=nil; PascalFilenames:=nil;
@ -303,6 +310,18 @@ begin
CHElement:=Chain[0]; CHElement:=Chain[0];
DebugLn(['GatherFPDocReferences ModuleName=',CHElement.ElementModuleName,' Name=',CHElement.ElementName]); DebugLn(['GatherFPDocReferences ModuleName=',CHElement.ElementModuleName,' Name=',CHElement.ElementName]);
// search FPDoc files
AVLNode:=FPDocFilenames.Tree.FindLowest;
while AVLNode<>nil do begin
Item:=PStringToStringItem(AVLNode.Data);
FPDocFilename:=Item^.Name;
ModuleName:=Item^.Value;
Result:=GatherFPDocReferences(CHElement.ElementModuleName,CHElement.ElementName,
ModuleName,FPDocFilename,TreeOfPCodeXYPosition);
if Result<>mrOk then exit;
AVLNode:=FPDocFilenames.Tree.FindSuccessor(AVLNode);
end;
Result:=mrOk; Result:=mrOk;
finally finally
PascalFilenames.Free; PascalFilenames.Free;
@ -312,6 +331,17 @@ begin
end; end;
end; end;
function GatherFPDocReferences(const ElementModuleName, ElementName,
FileModuleName, FPDocFilename: string; var TreeOfPCodeXYPosition: TAVLTree
): TModalResult;
begin
Result:=mrCancel;
DebugLn(['GatherFPDocReferences ElementModuleName=',ElementModuleName,
' ElementName=',ElementName,' FPDocFilename=',FPDocFilename,
' FileModuleName=',FileModuleName]);
Result:=mrOk;
end;
{ TFindRenameIdentifierDialog } { TFindRenameIdentifierDialog }
procedure TFindRenameIdentifierDialog.FindRenameIdentifierDialogCreate( procedure TFindRenameIdentifierDialog.FindRenameIdentifierDialogCreate(