IDE: implemented showing FPDoc short descriptions in code hints

git-svn-id: trunk@12992 -
This commit is contained in:
mattias 2007-11-23 20:26:16 +00:00
parent 8fe6b5f1fd
commit 49285e8ca1
3 changed files with 32 additions and 18 deletions

View File

@ -200,7 +200,7 @@ begin
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
if OnFindDeclarations(Code,X,Y,ListOfPCodeXYPosition,[])
@ -223,8 +223,7 @@ begin
end;
FCurrent.Add(Item);
if ListOfPCodeXYPosition<>nil then
DebugLn(['TDeclarationInheritanceCache.FindDeclarations ',ListOfPCodeXYPositionToStr(ListOfPCodeXYPosition)]);
if ListOfPCodeXYPosition<>nil then DebugLn(['TDeclarationInheritanceCache.FindDeclarations ',ListOfPCodeXYPositionToStr(ListOfPCodeXYPosition)]);
// clean up cache a bit
CleanCache(5);
@ -249,7 +248,7 @@ end;
destructor TDeclarationInheritanceCacheItem.Destroy;
begin
FreeListOfPFindContext(ListOfPCodeXYPosition);
FreeListOfPCodeXYPosition(ListOfPCodeXYPosition);
ListOfPCodeXYPosition:=nil;
inherited Destroy;
end;

View File

@ -34,8 +34,8 @@ type
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: TStream); overload;
procedure ReadXMLFile(var ADoc: TXMLDocument; var f: TStream; const AFilename: String); overload;
procedure ReadXMLFile(var ADoc: TXMLDocument; f: TStream); overload;
procedure ReadXMLFile(var ADoc: TXMLDocument; f: TStream; const AFilename: String); overload;
procedure ReadXMLFragment(AParentNode: TDOMNode; const AFilename: String); overload;
procedure ReadXMLFragment(AParentNode: TDOMNode; var f: File); overload;
@ -1376,7 +1376,7 @@ begin
end;
end;
procedure ReadXMLFile(var ADoc: TXMLDocument; var f: TStream; const AFilename: String);
procedure ReadXMLFile(var ADoc: TXMLDocument; f: TStream; const AFilename: String);
var
reader: TXMLReader;
buf: PChar;
@ -1400,7 +1400,7 @@ begin
end;
end;
procedure ReadXMLFile(var ADoc: TXMLDocument; var f: TStream);
procedure ReadXMLFile(var ADoc: TXMLDocument; f: TStream);
begin
ReadXMLFile(ADoc, f, '<Stream>');
end;

View File

@ -48,6 +48,17 @@ type
);
TFPDocNode = array [TFPDocItem] of String;
const
FPDocItemNames: array[TFPDocItem] of shortstring = (
'short',
'descr',
'errors',
'seealso',
'example'
);
type
{ TLazFPDocFile }
@ -625,7 +636,7 @@ begin
Chain:=nil;
ListOfPCodeXYPosition:=nil;
try
DebugLn(['TLazDocManager.GetElementChain GetDeclarationChain...']);
//DebugLn(['TLazDocManager.GetElementChain GetDeclarationChain...']);
// get the declaration chain
Result:=GetDeclarationChain(Code,X,Y,ListOfPCodeXYPosition,CacheWasUsed);
if Result<>ldprSuccess then exit;
@ -641,7 +652,7 @@ begin
for i:=0 to ListOfPCodeXYPosition.Count-1 do begin
// get source position of declaration
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)
then begin
DebugLn(['TLazDocManager.GetElementChain i=',i,' invalid CodePos']);
@ -679,12 +690,12 @@ begin
LDElement:=Chain.Add;
LDElement.CodeContext.Tool:=CurTool;
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
SrcFilename:=LDElement.CodeContext.Tool.MainFilename;
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 FPDocFilename<>'' then begin
@ -701,18 +712,17 @@ begin
// get fpdoc element path
LDElement.ElementName:=CodeNodeToElementName(LDElement.CodeContext.Tool,
LDElement.CodeContext.Node);
DebugLn(['TLazDocManager.GetElementChain i=',i,' Element=',LDElement.ElementName]);
//DebugLn(['TLazDocManager.GetElementChain i=',i,' Element=',LDElement.ElementName]);
// get fpdoc node
if (LDElement.FPDocFile<>nil) and (LDElement.ElementName<>'') then begin
LDElement.ElementNode:=
LDElement.FPDocFile.GetElementWithName(LDElement.ElementName);
end;
DebugLn(['TLazDocManager.GetElementChain ElementNode=',LDElement.ElementNode<>nil]);
//DebugLn(['TLazDocManager.GetElementChain ElementNode=',LDElement.ElementNode<>nil]);
end;
Result:=ldprSuccess;
finally
FreeListOfPFindContext(ListOfPCodeXYPosition);
if Result<>ldprSuccess then
FreeAndNil(Chain);
end;
@ -744,14 +754,15 @@ var
i: Integer;
Item: TLazDocElement;
NodeValues: TFPDocNode;
f: TFPDocItem;
begin
DebugLn(['TLazDocManager.GetHint ',Code.Filename,' ',X,',',Y]);
//DebugLn(['TLazDocManager.GetHint ',Code.Filename,' ',X,',',Y]);
Hint:=CodeToolBoss.FindSmartHint(Code,X,Y);
CacheWasUsed:=true;
Chain:=nil;
try
DebugLn(['TLazDocManager.GetHint GetElementChain...']);
//DebugLn(['TLazDocManager.GetHint GetElementChain...']);
Result:=GetElementChain(Code,X,Y,Complete,Chain,CacheWasUsed);
if EndNow(Result) then exit;
@ -761,16 +772,20 @@ begin
DebugLn(['TLazDocManager.GetHint ',i,' Element=',Item.ElementName]);
if Item.ElementNode=nil then continue;
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
Hint:=Hint+#13#13+Item.ElementName+#13
+NodeValues[fpdiShort];
end;
end;
end;
Result:=ldprFailed;
Result:=ldprSuccess;
finally
Chain.Free;
end;
DebugLn(['TLazDocManager.GetHint END Hint="',Hint,'"']);
end;
procedure TLazDocManager.FreeDocs;