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