From 19ea06abe43a34f5085384d23523795e11cdfc2e Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 23 Aug 2004 15:49:18 +0000 Subject: [PATCH] implemented help jump to FPDoc context in unit git-svn-id: trunk@5839 - --- components/codetools/codetoolmanager.pas | 34 +++++++++++++++------ ide/helpmanager.pas | 4 +-- ideintf/helpfpdoc.pas | 39 +++++++++++++++++++----- ideintf/helphtml.pas | 4 +-- ideintf/helpintf.pas | 15 +++++---- 5 files changed, 67 insertions(+), 29 deletions(-) diff --git a/components/codetools/codetoolmanager.pas b/components/codetools/codetoolmanager.pas index 2205be517b..8a4d7954fc 100644 --- a/components/codetools/codetoolmanager.pas +++ b/components/codetools/codetoolmanager.pas @@ -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 CurSrc0 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; diff --git a/ideintf/helphtml.pas b/ideintf/helphtml.pas index 3fc37e7f09..e4331d5218 100644 --- a/ideintf/helphtml.pas +++ b/ideintf/helphtml.pas @@ -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); diff --git a/ideintf/helpintf.pas b/ideintf/helpintf.pas index 9e5c9eb67e..08efead766 100644 --- a/ideintf/helpintf.pas +++ b/ideintf/helpintf.pas @@ -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;