codetools: scanning for comments in type nodes too

git-svn-id: trunk@16842 -
This commit is contained in:
mattias 2008-10-02 09:17:38 +00:00
parent 3e2ce6e7d3
commit e0a5b9322b
2 changed files with 45 additions and 19 deletions

View File

@ -7630,7 +7630,7 @@ end;
procedure TFindDeclarationTool.ValidateToolDependencies; procedure TFindDeclarationTool.ValidateToolDependencies;
begin begin
debugln(['TFindDeclarationTool.ValidateToolDependencies ',MainFilename]); //debugln(['TFindDeclarationTool.ValidateToolDependencies ',MainFilename]);
inherited ValidateToolDependencies; inherited ValidateToolDependencies;
CheckDependsOnNodeCaches; CheckDependsOnNodeCaches;
end; end;

View File

@ -3773,12 +3773,41 @@ function TStandardCodeTool.GetPasDocComments(const StartPos: TCodeXYPosition;
AddCodePosition(ListOfPCodeXYPosition,CodePos); AddCodePosition(ListOfPCodeXYPosition,CodePos);
end; end;
function Scan(StartPos, EndPos: integer): boolean;
var
p: LongInt;
begin
// read comments (start in front of node)
//DebugLn(['TStandardCodeTool.GetPasDocComments Scan Src=',copy(Src,StartPos,EndPos-StartPos)]);
p:=FindLineEndOrCodeInFrontOfPosition(StartPos,true);
while p<EndPos do begin
p:=FindNextComment(Src,p,EndPos);
if p>=EndPos then break;
//debugln(['TStandardCodeTool.GetPasDocComments Comment="',copy(Src,p,FindCommentEnd(Src,p,Scanner.NestedComments)-p),'"']);
if (p<StartPos) then begin
// comment in front of node
if not CommentBelongsToPrior(p) then
Add(p);
end else if (p<EndPos) then begin
// comment in the middle
Add(p);
end else begin
// comment behind
if CommentBelongsToPrior(p) then
Add(p);
end;
p:=FindCommentEnd(Src,p,Scanner.NestedComments);
end;
Result:=true;
end;
var var
CleanCursorPos: integer; CleanCursorPos: integer;
ANode: TCodeTreeNode; ANode: TCodeTreeNode;
p: LongInt; p: LongInt;
NextNode: TCodeTreeNode; NextNode: TCodeTreeNode;
EndPos: LongInt; EndPos: LongInt;
TypeNode: TCodeTreeNode;
begin begin
ListOfPCodeXYPosition:=nil; ListOfPCodeXYPosition:=nil;
Result:=false; Result:=false;
@ -3797,31 +3826,28 @@ begin
and (ANode.Parent<>nil) and (ANode.Parent.Desc=ctnProcedure) then and (ANode.Parent<>nil) and (ANode.Parent.Desc=ctnProcedure) then
ANode:=ANode.Parent; ANode:=ANode.Parent;
// add space behind node to scan range
NextNode:=ANode.Next; NextNode:=ANode.Next;
if NextNode<>nil then if NextNode<>nil then
EndPos:=NextNode.StartPos EndPos:=NextNode.StartPos
else else
EndPos:=ANode.EndPos; EndPos:=ANode.EndPos;
//DebugLn(['TStandardCodeTool.GetPasDocComments ',copy(Src,ANode.StartPos,ANode.EndPos-ANode.StartPos)]); // scan range for comments
// read comments (start in front of node) if not Scan(Anode.StartPos,EndPos) then exit;
p:=FindLineEndOrCodeInFrontOfPosition(ANode.StartPos,true);
while p<EndPos do begin if ANode.Desc in AllIdentifierDefinitions then begin
p:=FindNextComment(Src,p,EndPos); // scan behind type
if p>=EndPos then break; // for example: i: integer; // comment
if (p<ANode.StartPos) then begin TypeNode:=FindTypeNodeOfDefinition(ANode);
// comment in front of node if TypeNode<>nil then begin
if not CommentBelongsToPrior(p) then NextNode:=TypeNode.Next;
Add(p); if NextNode<>nil then
end else if (p<ANode.EndPos) then begin EndPos:=NextNode.StartPos
// comment in the middle else
Add(p); EndPos:=ANode.EndPos;
end else begin if not Scan(Anode.StartPos,EndPos) then exit;
// comment behind
if CommentBelongsToPrior(p) then
Add(p);
end; end;
p:=FindCommentEnd(Src,p,Scanner.NestedComments);
end; end;
Result:=true; Result:=true;
end; end;