IDE: code help: improved debug message

git-svn-id: trunk@53346 -
This commit is contained in:
mattias 2016-11-11 18:01:33 +00:00
parent a3235cd934
commit f9e5f4cbdf

View File

@ -1545,6 +1545,7 @@ end;
function TCodeHelpManager.GetFPDocFilenameForSource(SrcFilename: string; function TCodeHelpManager.GetFPDocFilenameForSource(SrcFilename: string;
ResolveIncludeFiles: Boolean; out CacheWasUsed: boolean; ResolveIncludeFiles: Boolean; out CacheWasUsed: boolean;
out AnOwner: TObject; CreateIfNotExists: boolean): string; out AnOwner: TObject; CreateIfNotExists: boolean): string;
{off $Define VerboseGetFPDocForSrc}
var var
FPDocName: String; FPDocName: String;
SearchedPaths: string; SearchedPaths: string;
@ -1557,8 +1558,18 @@ var
begin begin
Result:=false; Result:=false;
if Paths='' then exit; if Paths='' then exit;
if not IDEMacros.CreateAbsoluteSearchPath(Paths,BaseDir) then exit; {$IFDEF VerboseGetFPDocForSrc}
//DebugLn(['SearchInPath START ',Paths]); debugln(['GetFPDocFilenameForSource.SearchInPath unresolved Paths="',Paths,'" BaseDir="',BaseDir,'"']);
{$ENDIF}
if not IDEMacros.CreateAbsoluteSearchPath(Paths,BaseDir) then begin
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.SearchInPath invalid macro Paths="',Paths,'"']);
{$ENDIF}
exit;
end;
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.SearchInPath resolved Paths="',Paths,'"']);
{$ENDIF}
if Paths='' then exit; if Paths='' then exit;
p:=1; p:=1;
repeat repeat
@ -1569,6 +1580,9 @@ var
// not yet searched in this directory // not yet searched in this directory
SearchedPaths:=SearchedPaths+';'+CurPath; SearchedPaths:=SearchedPaths+';'+CurPath;
Filename:=AppendPathDelim(CurPath)+FPDocName; Filename:=AppendPathDelim(CurPath)+FPDocName;
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.SearchInPath try file="',Filename,'"']);
{$ENDIF}
if FileExistsCached(Filename) then exit(true); if FileExistsCached(Filename) then exit(true);
end; end;
end; end;
@ -1595,30 +1609,63 @@ var
PkgList:=PackageEditingInterface.GetOwnersOfUnit(SrcFilename); PkgList:=PackageEditingInterface.GetOwnersOfUnit(SrcFilename);
end; end;
// get all packages owning the file // get all packages owning the file
if PkgList=nil then exit; if PkgList=nil then begin
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckUnitOwners no owner for SrcFile="',SrcFilename,'"']);
{$ENDIF}
exit;
end;
try try
for i:=0 to PkgList.Count-1 do begin for i:=0 to PkgList.Count-1 do begin
//debugln(['CheckUnitOwners ',DbgSName(TObject(PkgList[i]))]); {$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckUnitOwners owner="',DbgSName(TObject(PkgList[i])),'"']);
{$ENDIF}
if TObject(PkgList[i]) is TLazProject then begin if TObject(PkgList[i]) is TLazProject then begin
AProject:=TLazProject(PkgList[i]); AProject:=TLazProject(PkgList[i]);
AnOwner:=AProject; AnOwner:=AProject;
if AProject.FPDocPaths='' then continue; if AProject.FPDocPaths='' then begin
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckUnitOwners project has no FPDocPaths "',AProject.ProjectInfoFile,'"']);
{$ENDIF}
continue;
end;
BaseDir:=ExtractFilePath(AProject.ProjectInfoFile); BaseDir:=ExtractFilePath(AProject.ProjectInfoFile);
if BaseDir='' then continue; if BaseDir='' then begin
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckUnitOwners project is virtual "',AProject.ProjectInfoFile,'"']);
{$ENDIF}
continue;
end;
// add fpdoc paths of project // add fpdoc paths of project
if SearchInPath(AProject.FPDocPaths,BaseDir,Filename) then if SearchInPath(AProject.FPDocPaths,BaseDir,Filename) then begin
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckUnitOwners found in project "',AProject.ProjectInfoFile,'" File="',Filename,'"']);
{$ENDIF}
exit(true); exit(true);
end;
end else if TObject(PkgList[i]) is TLazPackage then begin end else if TObject(PkgList[i]) is TLazPackage then begin
APackage:=TLazPackage(PkgList[i]); APackage:=TLazPackage(PkgList[i]);
AnOwner:=APackage; AnOwner:=APackage;
if APackage.FPDocPaths='' then continue; if APackage.FPDocPaths='' then begin
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckUnitOwners package has no FPDocPaths ',APackage.Name,' "',APackage.Filename,'"']);
{$ENDIF}
continue;
end;
BaseDir:=APackage.Directory; BaseDir:=APackage.Directory;
if BaseDir='' then continue; if BaseDir='' then begin
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckUnitOwners package is virtual "',APackage.Name,'"']);
{$ENDIF}
continue;
end;
// add fpdoc paths of package // add fpdoc paths of package
if SearchInPath(APackage.FPDocPaths,BaseDir,Filename) then begin if SearchInPath(APackage.FPDocPaths,BaseDir,Filename) then begin
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckUnitOwners found in package "',APackage.Filename,'" File="',Filename,'"']);
{$ENDIF}
exit(true); exit(true);
end else if AnOwner=nil then end;
AnOwner:=APackage;
end; end;
end; end;
finally finally
@ -1634,13 +1681,23 @@ var
// check IDE directories // check IDE directories
if IsIDESrcFile(SrcFilename) then begin if IsIDESrcFile(SrcFilename) then begin
AnOwner:=LazarusHelp; AnOwner:=LazarusHelp;
if SearchInPath(GetIDESrcFPDocPath,'',Filename) then {$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckIfInLazarus IsIDESrcFile "',SrcFilename,'"']);
{$ENDIF}
if SearchInPath(GetIDESrcFPDocPath,'',Filename) then begin
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckIfInLazarus found in IDE "',Filename,'"']);
{$ENDIF}
exit(true); exit(true);
end;
end; end;
// finally: check if in user directories // finally: check if in user directories
if SearchInPath(EnvironmentOptions.FPDocPaths,'',Filename) then if SearchInPath(EnvironmentOptions.FPDocPaths,'',Filename) then
begin begin
{$IFDEF VerboseGetFPDocForSrc}
debugln(['GetFPDocFilenameForSource.CheckIfInLazarus found in user files "',Filename,'"']);
{$ENDIF}
AnOwner:=nil; AnOwner:=nil;
exit(true); exit(true);
end; end;
@ -1667,7 +1724,9 @@ begin
if not FilenameIsPascalSource(SrcFilename) then if not FilenameIsPascalSource(SrcFilename) then
begin begin
{$IFDEF VerboseGetFPDocForSrc}
DebugLn(['TCodeHelpManager.GetFPDocFilenameForSource error: not a source file: "',SrcFilename,'"']); DebugLn(['TCodeHelpManager.GetFPDocFilenameForSource error: not a source file: "',SrcFilename,'"']);
{$ENDIF}
exit; exit;
end; end;
@ -1686,7 +1745,7 @@ begin
end; end;
CacheWasUsed:=false; CacheWasUsed:=false;
{$IFDEF VerboseCodeHelp} {$IF defined(VerboseCodeHelp) or defined(VerboseGetFPDocForSrc)}
DebugLn(['TCodeHelpManager.GetFPDocFilenameForSource searching SrcFilename=',SrcFilename]); DebugLn(['TCodeHelpManager.GetFPDocFilenameForSource searching SrcFilename=',SrcFilename]);
{$ENDIF} {$ENDIF}
@ -1700,8 +1759,17 @@ begin
// not found // not found
if AnOwner=nil then if AnOwner=nil then
DebugLn(['TCodeHelpManager.GetFPDocFilenameForSource Hint: file without owner: ',SrcFilename]) DebugLn(['TCodeHelpManager.GetFPDocFilenameForSource Hint: file without owner: ',SrcFilename])
else else if AnOwner is TLazProject then begin
debugln(['TCodeHelpManager.GetFPDocFilenameForSource Hint: Owner has no fpdoc paths: ',SrcFilename]); if TLazProject(AnOwner).FPDocPaths='' then
debugln(['TCodeHelpManager.GetFPDocFilenameForSource Hint: Owner (project) has no fpdoc paths: ',SrcFilename])
else
debugln(['TCodeHelpManager.GetFPDocFilenameForSource Hint: Owner (project) has no fpdoc file for: ',SrcFilename])
end else if AnOwner is TLazPackage then begin
if TLazPackage(AnOwner).FPDocPaths='' then
debugln(['TCodeHelpManager.GetFPDocFilenameForSource Hint: Owner (package ',TLazPackage(AnOwner).Name,') has no fpdoc paths: ',SrcFilename])
else
debugln(['TCodeHelpManager.GetFPDocFilenameForSource Hint: Owner (package ',TLazPackage(AnOwner).Name,') has no fpdoc file for: ',SrcFilename])
end;
end; end;
// save to cache // save to cache
@ -1717,11 +1785,11 @@ begin
if (Result='') and CreateIfNotExists then begin if (Result='') and CreateIfNotExists then begin
Result:=DoCreateFPDocFileForSource(SrcFilename,AnOwner); Result:=DoCreateFPDocFileForSource(SrcFilename,AnOwner);
end; end;
{$IFDEF VerboseCodeHelp} {$IF defined(VerboseCodeHelp) or defined(VerboseGetFPDocForSrc)}
DebugLn(['TCodeHelpManager.GetFPDocFilenameForSource SrcFilename="',SrcFilename,'" Result="',Result,'"']); DebugLn(['TCodeHelpManager.GetFPDocFilenameForSource SrcFilename="',SrcFilename,'" Result="',Result,'"']);
{$ENDIF} {$ENDIF}
end; end;
{$ifdef VerboseCodeHelp} {$IF defined(VerboseCodeHelp) or defined(VerboseGetFPDocForSrc)}
DebugLn(['TCodeHelpManager.GetFPDocFilenameForSource ',dbgsName(AnOwner)]); DebugLn(['TCodeHelpManager.GetFPDocFilenameForSource ',dbgsName(AnOwner)]);
{$endif} {$endif}
end; end;