mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 02:19:57 +02:00
implemented help jump to FPDoc context in unit
git-svn-id: trunk@5839 -
This commit is contained in:
parent
845b65c847
commit
19ea06abe4
@ -90,7 +90,7 @@ type
|
||||
FResourceTool: TResourceCodeTool;
|
||||
FSetPropertyVariablename: string;
|
||||
FSourceExtensions: string; // default is '.pp;.pas;.lpr;.dpr;.dpk'
|
||||
FSourceTools: TAVLTree; // tree of TCustomCodeTool
|
||||
FSourceTools: TAVLTree; // tree of TCustomCodeTool sorted for pointer
|
||||
FTabWidth: integer;
|
||||
FVisibleEditorLines: integer;
|
||||
FWriteExceptions: boolean;
|
||||
@ -163,6 +163,7 @@ type
|
||||
function FilenameHasSourceExt(const AFilename: string): boolean;
|
||||
function GetMainCode(Code: TCodeBuffer): TCodeBuffer;
|
||||
function GetIncludeCodeChain(Code: TCodeBuffer;
|
||||
RemoveFirstCodesWithoutTool: boolean;
|
||||
var ListOfCodeBuffer: TList): boolean;
|
||||
function FindCodeToolForSource(Code: TCodeBuffer): TCustomCodeTool;
|
||||
property OnSearchUsedUnit: TOnSearchUsedUnit
|
||||
@ -703,7 +704,7 @@ begin
|
||||
end;
|
||||
|
||||
function TCodeToolManager.GetIncludeCodeChain(Code: TCodeBuffer;
|
||||
var ListOfCodeBuffer: TList): boolean;
|
||||
RemoveFirstCodesWithoutTool: boolean; var ListOfCodeBuffer: TList): boolean;
|
||||
var
|
||||
OldCode: TCodeBuffer;
|
||||
begin
|
||||
@ -722,12 +723,27 @@ begin
|
||||
if Code=nil then exit;
|
||||
ListOfCodeBuffer.Insert(0,Code);
|
||||
end;
|
||||
|
||||
if (not FilenameHasSourceExt(Code.Filename)) then begin
|
||||
OldCode:=Code;
|
||||
Code:=FindCodeOfMainUnitHint(OldCode);
|
||||
if Code<>OldCode then
|
||||
ListOfCodeBuffer.Insert(0,Code);
|
||||
end;
|
||||
|
||||
if RemoveFirstCodesWithoutTool then begin
|
||||
while ListOfCodeBuffer.Count>0 do begin
|
||||
Code:=TCodeBuffer(ListOfCodeBuffer[0]);
|
||||
if FindCodeToolForSource(Code)<>nil then break;
|
||||
ListOfCodeBuffer.Delete(0);
|
||||
end;
|
||||
if ListOfCodeBuffer.Count=0 then begin
|
||||
ListOfCodeBuffer.Free;
|
||||
ListOfCodeBuffer:=nil;
|
||||
Result:=false;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCodeToolManager.FindCodeOfMainUnitHint(Code: TCodeBuffer
|
||||
@ -2756,12 +2772,12 @@ end;
|
||||
function TCodeToolManager.FindCodeToolForSource(Code: TCodeBuffer
|
||||
): TCustomCodeTool;
|
||||
var ANode: TAVLTreeNode;
|
||||
CurSrc, SearchedSrc: integer;
|
||||
CurSrc, SearchedSrc: Pointer;
|
||||
begin
|
||||
ANode:=FSourceTools.Root;
|
||||
SearchedSrc:=integer(Code);
|
||||
SearchedSrc:=Pointer(Code);
|
||||
while (ANode<>nil) do begin
|
||||
CurSrc:=integer(TCustomCodeTool(ANode.Data).Scanner.MainCode);
|
||||
CurSrc:=Pointer(TCustomCodeTool(ANode.Data).Scanner.MainCode);
|
||||
if CurSrc>SearchedSrc then
|
||||
ANode:=ANode.Left
|
||||
else if CurSrc<SearchedSrc then
|
||||
@ -2807,12 +2823,12 @@ begin
|
||||
Result.VisibleEditorLines:=FVisibleEditorLines;
|
||||
Result.JumpCentered:=FJumpCentered;
|
||||
Result.CursorBeyondEOL:=FCursorBeyondEOL;
|
||||
TFindDeclarationTool(Result).OnGetCodeToolForBuffer:=@OnGetCodeToolForBuffer;
|
||||
TFindDeclarationTool(Result).OnFindUsedUnit:=@DoOnFindUsedUnit;
|
||||
TFindDeclarationTool(Result).OnGetSrcPathForCompiledUnit:=@DoOnGetSrcPathForCompiledUnit;
|
||||
TCodeTool(Result).OnGetCodeToolForBuffer:=@OnGetCodeToolForBuffer;
|
||||
TCodeTool(Result).OnFindUsedUnit:=@DoOnFindUsedUnit;
|
||||
TCodeTool(Result).OnGetSrcPathForCompiledUnit:=@DoOnGetSrcPathForCompiledUnit;
|
||||
Result.OnSetGlobalWriteLock:=@OnToolSetWriteLock;
|
||||
Result.OnGetGlobalWriteLockInfo:=@OnToolGetWriteLockInfo;
|
||||
TFindDeclarationTool(Result).OnParserProgress:=@OnParserProgress;
|
||||
TCodeTool(Result).OnParserProgress:=@OnParserProgress;
|
||||
end;
|
||||
|
||||
procedure TCodeToolManager.SetAbortable(const AValue: boolean);
|
||||
|
@ -505,7 +505,7 @@ function THelpManager.ShowHelpForSourcePosition(const Filename: string;
|
||||
// add filename and all filenames of the include chain
|
||||
IncludeChain:=nil;
|
||||
try
|
||||
CodeToolBoss.GetIncludeCodeChain(ACodePos^.Code,IncludeChain);
|
||||
CodeToolBoss.GetIncludeCodeChain(ACodePos^.Code,true,IncludeChain);
|
||||
if IncludeChain=nil then begin
|
||||
debugln('WARNING: ConvertCodePosToPascalHelpContext IncludeChain=nil');
|
||||
exit;
|
||||
@ -519,7 +519,7 @@ function THelpManager.ShowHelpForSourcePosition(const Filename: string;
|
||||
// find code tool
|
||||
Tool:=CodeToolBoss.FindCodeToolForSource(MainCodeBuffer);
|
||||
if not (Tool is TCodeTool) then begin
|
||||
debugln('WARNING: ConvertCodePosToPascalHelpContext not (Tool is TCodeTool)');
|
||||
debugln('WARNING: ConvertCodePosToPascalHelpContext not (Tool is TCodeTool) MainCodeBuffer=',MainCodeBuffer.Filename);
|
||||
exit;
|
||||
end;
|
||||
// convert cursor position to clean position
|
||||
|
@ -46,6 +46,9 @@ var
|
||||
URL: String;
|
||||
TheBaseURL: String;
|
||||
Filename: String;
|
||||
i: Integer;
|
||||
Context: String;
|
||||
p: LongInt;
|
||||
begin
|
||||
if (Query is THelpQueryPascalContexts)
|
||||
and (NewNode.QueryItem is TPascalHelpContextList) then begin
|
||||
@ -58,20 +61,42 @@ begin
|
||||
DebugLn('TFPDocHTMLHelpDatabase.ShowHelp A Unitname=',Unitname,' NewNode.HelpType=',dbgs(ord(NewNode.HelpType)),' NewNode.Title=',NewNode.Title,' NewNode.URL=',NewNode.URL);
|
||||
if UnitName<>'' then begin
|
||||
|
||||
Filename:=UnitName+'/';
|
||||
// TODO: context in unit
|
||||
Filename:=Filename+'index.html';
|
||||
|
||||
// create FPDoc context
|
||||
Filename:='';
|
||||
for i:=0 to ContextList.Count-1 do begin
|
||||
Context:=lowercase(ContextList.List[i].Context);
|
||||
case ContextList.List[i].Descriptor of
|
||||
|
||||
pihcProperty,pihcVariable,pihcType,pihcConst:
|
||||
Filename:=Filename+Context+'.';
|
||||
|
||||
pihcProcedure: begin
|
||||
// chomp parameters ToDo: overloaded procs
|
||||
p:=System.Pos('(',Context);
|
||||
if p>0 then
|
||||
Context:=copy(Context,1,p-1);
|
||||
Filename:=Filename+Context+'.';
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
// default is index.html
|
||||
if Filename='' then Filename:='index.';
|
||||
|
||||
// FPDoc Html always has .html as extension
|
||||
Filename:=UnitName+'/'+Filename+'html';
|
||||
|
||||
TheBaseURL:='';
|
||||
if NewNode.URLValid then begin
|
||||
// the node has an URL => use only the path
|
||||
TheBaseURL:=NewNode.URL;
|
||||
debugln('A TheBaseURL=',TheBaseURL);
|
||||
//debugln('A TheBaseURL=',TheBaseURL);
|
||||
if (HelpDatabases<>nil) then
|
||||
HelpDatabases.SubstituteMacros(TheBaseURL);
|
||||
debugln('B TheBaseURL=',TheBaseURL);
|
||||
//debugln('B TheBaseURL=',TheBaseURL);
|
||||
TheBaseURL:=ExtractURLDirectory(TheBaseURL);
|
||||
debugln('C TheBaseURL=',TheBaseURL);
|
||||
//debugln('C TheBaseURL=',TheBaseURL);
|
||||
DebugLn('TFPDocHTMLHelpDatabase.ShowHelp Node Base URL TheBaseURL=',TheBaseURL);
|
||||
end;
|
||||
|
||||
|
@ -92,7 +92,7 @@ var
|
||||
Node: THelpNode;
|
||||
FullURL: String;
|
||||
begin
|
||||
DebugLn('THTMLHelpDatabase.ShowURL A URL="',URL,'" Title="',Title,'"');
|
||||
//DebugLn('THTMLHelpDatabase.ShowURL A URL="',URL,'" Title="',Title,'"');
|
||||
|
||||
// find HTML viewer
|
||||
Result:=FindViewer('text/html',ErrMsg,Viewer);
|
||||
@ -115,8 +115,6 @@ begin
|
||||
'"', '"', URLPath, '"']);
|
||||
exit;
|
||||
end;
|
||||
end else begin
|
||||
|
||||
end;
|
||||
FullURL:=CombineURL(URLType,URLPath,URLParams);
|
||||
debugln('THTMLHelpDatabase.ShowHelp B URL=',URL,' URLType=',URLType,' URLPath=',URLPath,' URLParams=',URLParams);
|
||||
|
@ -59,8 +59,7 @@ type
|
||||
pihcParameterList,
|
||||
pihcVariable,
|
||||
pihcType,
|
||||
pihcConst,
|
||||
pihcIdentifier
|
||||
pihcConst
|
||||
);
|
||||
TPascalHelpContext = record
|
||||
Descriptor: TPascalHelpContextType;
|
||||
@ -961,7 +960,7 @@ begin
|
||||
// check every pascal context
|
||||
for j:=0 to ListOfPascalHelpContextList.Count-1 do begin
|
||||
PascalContext:=TPascalHelpContextList(ListOfPascalHelpContextList[j]);
|
||||
debugln('THelpDatabase.GetNodesForPascalContexts A PascalContext.Count=',dbgs(PascalContext.Count));
|
||||
//debugln('THelpDatabase.GetNodesForPascalContexts A PascalContext.Count=',dbgs(PascalContext.Count));
|
||||
if (PascalContext.Count>0)
|
||||
and (PascalContext.List[0].Descriptor=pihcFilename) then begin
|
||||
// search file item
|
||||
@ -970,7 +969,7 @@ begin
|
||||
if not (SearchItem is THelpDBSISourceFile) then continue;
|
||||
FileItem:=THelpDBSISourceFile(SearchItem);
|
||||
Filename:=PascalContext.List[0].Context;
|
||||
debugln('THelpDatabase.GetNodesForPascalContexts B FileItem.ClassName=',FileItem.ClassName,' Filename=',Filename);
|
||||
//debugln('THelpDatabase.GetNodesForPascalContexts B FileItem.ClassName=',FileItem.ClassName,' Filename=',Filename);
|
||||
if (FileItem.FileMatches(Filename)) then begin
|
||||
FileItem.Node.QueryItem:=PascalContext;
|
||||
CreateListAndAdd(FileItem.Node,ListOfNodes,true);
|
||||
@ -1861,19 +1860,19 @@ var
|
||||
TheDirectory: String;
|
||||
begin
|
||||
Result:=false;
|
||||
debugln('THelpDBSISourceDirectory.FileMatches AFilename="',AFilename,'" FFilename="',FFilename,'"');
|
||||
//debugln('THelpDBSISourceDirectory.FileMatches AFilename="',AFilename,'" FFilename="',FFilename,'"');
|
||||
if (FFilename='') or (AFilename='') then exit;
|
||||
TheDirectory:=GetFullFilename;
|
||||
debugln('THelpDBSISourceDirectory.FileMatches TheDirectory="',TheDirectory,'" WithSubDirectories=',dbgs(WithSubDirectories));
|
||||
//debugln('THelpDBSISourceDirectory.FileMatches TheDirectory="',TheDirectory,'" WithSubDirectories=',dbgs(WithSubDirectories));
|
||||
if WithSubDirectories then begin
|
||||
if not FileIsInPath(AFilename,TheDirectory) then exit;
|
||||
end else begin
|
||||
if not FileIsInDirectory(AFilename,TheDirectory) then exit;
|
||||
end;
|
||||
debugln('THelpDBSISourceDirectory.FileMatches FileMask="',FileMask,'"');
|
||||
//debugln('THelpDBSISourceDirectory.FileMatches FileMask="',FileMask,'"');
|
||||
if (FileMask<>'')
|
||||
and (not FileInFilenameMasks(ExtractFilename(AFilename),FileMask)) then exit;
|
||||
debugln('THelpDBSISourceDirectory.FileMatches Success');
|
||||
//debugln('THelpDBSISourceDirectory.FileMatches Success');
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user