mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-27 11:50:26 +02:00
IDE: implemented showing FPDoc short descriptions in code hints
git-svn-id: trunk@12992 -
This commit is contained in:
parent
8fe6b5f1fd
commit
49285e8ca1
@ -200,7 +200,7 @@ begin
|
|||||||
|
|
||||||
CacheWasUsed:=false;
|
CacheWasUsed:=false;
|
||||||
|
|
||||||
DebugLn(['TDeclarationInheritanceCache.FindDeclarations searching ',Code.Filename,'(X=',X,',Y=',Y,')']);
|
//DebugLn(['TDeclarationInheritanceCache.FindDeclarations searching ',Code.Filename,'(X=',X,',Y=',Y,')']);
|
||||||
|
|
||||||
// ask the codetools
|
// ask the codetools
|
||||||
if OnFindDeclarations(Code,X,Y,ListOfPCodeXYPosition,[])
|
if OnFindDeclarations(Code,X,Y,ListOfPCodeXYPosition,[])
|
||||||
@ -223,8 +223,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
FCurrent.Add(Item);
|
FCurrent.Add(Item);
|
||||||
|
|
||||||
if ListOfPCodeXYPosition<>nil then
|
if ListOfPCodeXYPosition<>nil then DebugLn(['TDeclarationInheritanceCache.FindDeclarations ',ListOfPCodeXYPositionToStr(ListOfPCodeXYPosition)]);
|
||||||
DebugLn(['TDeclarationInheritanceCache.FindDeclarations ',ListOfPCodeXYPositionToStr(ListOfPCodeXYPosition)]);
|
|
||||||
|
|
||||||
// clean up cache a bit
|
// clean up cache a bit
|
||||||
CleanCache(5);
|
CleanCache(5);
|
||||||
@ -249,7 +248,7 @@ end;
|
|||||||
|
|
||||||
destructor TDeclarationInheritanceCacheItem.Destroy;
|
destructor TDeclarationInheritanceCacheItem.Destroy;
|
||||||
begin
|
begin
|
||||||
FreeListOfPFindContext(ListOfPCodeXYPosition);
|
FreeListOfPCodeXYPosition(ListOfPCodeXYPosition);
|
||||||
ListOfPCodeXYPosition:=nil;
|
ListOfPCodeXYPosition:=nil;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
@ -34,8 +34,8 @@ type
|
|||||||
|
|
||||||
procedure ReadXMLFile(var ADoc: TXMLDocument; const AFilename: String); overload;
|
procedure ReadXMLFile(var ADoc: TXMLDocument; const AFilename: String); overload;
|
||||||
procedure ReadXMLFile(var ADoc: TXMLDocument; var f: File); overload;
|
procedure ReadXMLFile(var ADoc: TXMLDocument; var f: File); overload;
|
||||||
procedure ReadXMLFile(var ADoc: TXMLDocument; var f: TStream); overload;
|
procedure ReadXMLFile(var ADoc: TXMLDocument; f: TStream); overload;
|
||||||
procedure ReadXMLFile(var ADoc: TXMLDocument; var f: TStream; const AFilename: String); overload;
|
procedure ReadXMLFile(var ADoc: TXMLDocument; f: TStream; const AFilename: String); overload;
|
||||||
|
|
||||||
procedure ReadXMLFragment(AParentNode: TDOMNode; const AFilename: String); overload;
|
procedure ReadXMLFragment(AParentNode: TDOMNode; const AFilename: String); overload;
|
||||||
procedure ReadXMLFragment(AParentNode: TDOMNode; var f: File); overload;
|
procedure ReadXMLFragment(AParentNode: TDOMNode; var f: File); overload;
|
||||||
@ -1376,7 +1376,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ReadXMLFile(var ADoc: TXMLDocument; var f: TStream; const AFilename: String);
|
procedure ReadXMLFile(var ADoc: TXMLDocument; f: TStream; const AFilename: String);
|
||||||
var
|
var
|
||||||
reader: TXMLReader;
|
reader: TXMLReader;
|
||||||
buf: PChar;
|
buf: PChar;
|
||||||
@ -1400,7 +1400,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ReadXMLFile(var ADoc: TXMLDocument; var f: TStream);
|
procedure ReadXMLFile(var ADoc: TXMLDocument; f: TStream);
|
||||||
begin
|
begin
|
||||||
ReadXMLFile(ADoc, f, '<Stream>');
|
ReadXMLFile(ADoc, f, '<Stream>');
|
||||||
end;
|
end;
|
||||||
|
@ -49,6 +49,17 @@ type
|
|||||||
|
|
||||||
TFPDocNode = array [TFPDocItem] of String;
|
TFPDocNode = array [TFPDocItem] of String;
|
||||||
|
|
||||||
|
const
|
||||||
|
FPDocItemNames: array[TFPDocItem] of shortstring = (
|
||||||
|
'short',
|
||||||
|
'descr',
|
||||||
|
'errors',
|
||||||
|
'seealso',
|
||||||
|
'example'
|
||||||
|
);
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
{ TLazFPDocFile }
|
{ TLazFPDocFile }
|
||||||
|
|
||||||
TLazFPDocFile = class
|
TLazFPDocFile = class
|
||||||
@ -625,7 +636,7 @@ begin
|
|||||||
Chain:=nil;
|
Chain:=nil;
|
||||||
ListOfPCodeXYPosition:=nil;
|
ListOfPCodeXYPosition:=nil;
|
||||||
try
|
try
|
||||||
DebugLn(['TLazDocManager.GetElementChain GetDeclarationChain...']);
|
//DebugLn(['TLazDocManager.GetElementChain GetDeclarationChain...']);
|
||||||
// get the declaration chain
|
// get the declaration chain
|
||||||
Result:=GetDeclarationChain(Code,X,Y,ListOfPCodeXYPosition,CacheWasUsed);
|
Result:=GetDeclarationChain(Code,X,Y,ListOfPCodeXYPosition,CacheWasUsed);
|
||||||
if Result<>ldprSuccess then exit;
|
if Result<>ldprSuccess then exit;
|
||||||
@ -641,7 +652,7 @@ begin
|
|||||||
for i:=0 to ListOfPCodeXYPosition.Count-1 do begin
|
for i:=0 to ListOfPCodeXYPosition.Count-1 do begin
|
||||||
// get source position of declaration
|
// get source position of declaration
|
||||||
CodePos:=PCodeXYPosition(ListOfPCodeXYPosition[i]);
|
CodePos:=PCodeXYPosition(ListOfPCodeXYPosition[i]);
|
||||||
DebugLn(['TLazDocManager.GetElementChain i=',i,' X=',CodePos^.X,' Y=',CodePos^.Y]);
|
//DebugLn(['TLazDocManager.GetElementChain i=',i,' X=',CodePos^.X,' Y=',CodePos^.Y]);
|
||||||
if (CodePos=nil) or (CodePos^.Code=nil) or (CodePos^.X<1) or (CodePos^.Y<1)
|
if (CodePos=nil) or (CodePos^.Code=nil) or (CodePos^.X<1) or (CodePos^.Y<1)
|
||||||
then begin
|
then begin
|
||||||
DebugLn(['TLazDocManager.GetElementChain i=',i,' invalid CodePos']);
|
DebugLn(['TLazDocManager.GetElementChain i=',i,' invalid CodePos']);
|
||||||
@ -679,12 +690,12 @@ begin
|
|||||||
LDElement:=Chain.Add;
|
LDElement:=Chain.Add;
|
||||||
LDElement.CodeContext.Tool:=CurTool;
|
LDElement.CodeContext.Tool:=CurTool;
|
||||||
LDElement.CodeContext.Node:=Node;
|
LDElement.CodeContext.Node:=Node;
|
||||||
DebugLn(['TLazDocManager.GetElementChain i=',i,' CodeContext=',FindContextToString(LDElement.CodeContext)]);
|
//DebugLn(['TLazDocManager.GetElementChain i=',i,' CodeContext=',FindContextToString(LDElement.CodeContext)]);
|
||||||
|
|
||||||
// find corresponding FPDoc file
|
// find corresponding FPDoc file
|
||||||
SrcFilename:=LDElement.CodeContext.Tool.MainFilename;
|
SrcFilename:=LDElement.CodeContext.Tool.MainFilename;
|
||||||
FPDocFilename:=GetFPDocFilenameForSource(SrcFilename,false,CacheWasUsed);
|
FPDocFilename:=GetFPDocFilenameForSource(SrcFilename,false,CacheWasUsed);
|
||||||
DebugLn(['TLazDocManager.GetElementChain FPDocFilename=',FPDocFilename]);
|
//DebugLn(['TLazDocManager.GetElementChain FPDocFilename=',FPDocFilename]);
|
||||||
if (not CacheWasUsed) and (not Complete) then exit(ldprParsing);
|
if (not CacheWasUsed) and (not Complete) then exit(ldprParsing);
|
||||||
|
|
||||||
if FPDocFilename<>'' then begin
|
if FPDocFilename<>'' then begin
|
||||||
@ -701,18 +712,17 @@ begin
|
|||||||
// get fpdoc element path
|
// get fpdoc element path
|
||||||
LDElement.ElementName:=CodeNodeToElementName(LDElement.CodeContext.Tool,
|
LDElement.ElementName:=CodeNodeToElementName(LDElement.CodeContext.Tool,
|
||||||
LDElement.CodeContext.Node);
|
LDElement.CodeContext.Node);
|
||||||
DebugLn(['TLazDocManager.GetElementChain i=',i,' Element=',LDElement.ElementName]);
|
//DebugLn(['TLazDocManager.GetElementChain i=',i,' Element=',LDElement.ElementName]);
|
||||||
// get fpdoc node
|
// get fpdoc node
|
||||||
if (LDElement.FPDocFile<>nil) and (LDElement.ElementName<>'') then begin
|
if (LDElement.FPDocFile<>nil) and (LDElement.ElementName<>'') then begin
|
||||||
LDElement.ElementNode:=
|
LDElement.ElementNode:=
|
||||||
LDElement.FPDocFile.GetElementWithName(LDElement.ElementName);
|
LDElement.FPDocFile.GetElementWithName(LDElement.ElementName);
|
||||||
end;
|
end;
|
||||||
DebugLn(['TLazDocManager.GetElementChain ElementNode=',LDElement.ElementNode<>nil]);
|
//DebugLn(['TLazDocManager.GetElementChain ElementNode=',LDElement.ElementNode<>nil]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result:=ldprSuccess;
|
Result:=ldprSuccess;
|
||||||
finally
|
finally
|
||||||
FreeListOfPFindContext(ListOfPCodeXYPosition);
|
|
||||||
if Result<>ldprSuccess then
|
if Result<>ldprSuccess then
|
||||||
FreeAndNil(Chain);
|
FreeAndNil(Chain);
|
||||||
end;
|
end;
|
||||||
@ -744,14 +754,15 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
Item: TLazDocElement;
|
Item: TLazDocElement;
|
||||||
NodeValues: TFPDocNode;
|
NodeValues: TFPDocNode;
|
||||||
|
f: TFPDocItem;
|
||||||
begin
|
begin
|
||||||
DebugLn(['TLazDocManager.GetHint ',Code.Filename,' ',X,',',Y]);
|
//DebugLn(['TLazDocManager.GetHint ',Code.Filename,' ',X,',',Y]);
|
||||||
Hint:=CodeToolBoss.FindSmartHint(Code,X,Y);
|
Hint:=CodeToolBoss.FindSmartHint(Code,X,Y);
|
||||||
|
|
||||||
CacheWasUsed:=true;
|
CacheWasUsed:=true;
|
||||||
Chain:=nil;
|
Chain:=nil;
|
||||||
try
|
try
|
||||||
DebugLn(['TLazDocManager.GetHint GetElementChain...']);
|
//DebugLn(['TLazDocManager.GetHint GetElementChain...']);
|
||||||
Result:=GetElementChain(Code,X,Y,Complete,Chain,CacheWasUsed);
|
Result:=GetElementChain(Code,X,Y,Complete,Chain,CacheWasUsed);
|
||||||
if EndNow(Result) then exit;
|
if EndNow(Result) then exit;
|
||||||
|
|
||||||
@ -761,16 +772,20 @@ begin
|
|||||||
DebugLn(['TLazDocManager.GetHint ',i,' Element=',Item.ElementName]);
|
DebugLn(['TLazDocManager.GetHint ',i,' Element=',Item.ElementName]);
|
||||||
if Item.ElementNode=nil then continue;
|
if Item.ElementNode=nil then continue;
|
||||||
NodeValues:=Item.FPDocFile.GetValuesFromNode(Item.ElementNode);
|
NodeValues:=Item.FPDocFile.GetValuesFromNode(Item.ElementNode);
|
||||||
|
for f:=Low(TFPDocItem) to High(TFPDocItem) do
|
||||||
|
DebugLn(['TLazDocManager.GetHint ',FPDocItemNames[f],' ',NodeValues[f]]);
|
||||||
if NodeValues[fpdiShort]<>'' then begin
|
if NodeValues[fpdiShort]<>'' then begin
|
||||||
Hint:=Hint+#13#13+Item.ElementName+#13
|
Hint:=Hint+#13#13+Item.ElementName+#13
|
||||||
+NodeValues[fpdiShort];
|
+NodeValues[fpdiShort];
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Result:=ldprFailed;
|
Result:=ldprSuccess;
|
||||||
finally
|
finally
|
||||||
Chain.Free;
|
Chain.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
DebugLn(['TLazDocManager.GetHint END Hint="',Hint,'"']);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazDocManager.FreeDocs;
|
procedure TLazDocManager.FreeDocs;
|
||||||
|
Loading…
Reference in New Issue
Block a user