codetools: identifier completion: list used units

git-svn-id: trunk@24999 -
This commit is contained in:
mattias 2010-04-27 10:14:49 +00:00
parent ca57327310
commit e9d4b90835
3 changed files with 21 additions and 4 deletions

View File

@ -3300,7 +3300,7 @@ begin
if (CompilerPath='') or (not FileIsExecutable(CompilerPath)) then exit;
LastDefTempl:=nil;
// find all initial compiler macros and all unit paths
// -> ask compiler with the -vm -vt switch
// -> ask compiler with the -va switch
SetLength(Buf,1024);
Step:='Init';
try

View File

@ -5284,25 +5284,38 @@ var
NewCodeTool: TFindDeclarationTool;
OldFlags: TFindDeclarationFlags;
Node: TCodeTreeNode;
CollectResult: TIdentifierFoundResult;
begin
{$IFDEF CheckNodeTool}CheckNodeTool(UsesNode);{$ENDIF}
{$IFDEF ShowTriedParentContexts}
DebugLn(['TFindDeclarationTool.FindIdentifierInUsesSection ',MainFilename,' fdfIgnoreUsedUnits=',fdfIgnoreUsedUnits in Params.Flags]);
{$ENDIF}
Result:=false;
// first search in used unit names
if (Params.IdentifierTool=Self) then begin
Node:=UsesNode.LastChild;
while Node<>nil do begin
if CompareSrcIdentifiers(Node.StartPos,Params.Identifier) then begin
if (fdfCollect in Params.Flags) then begin
CollectResult:=DoOnIdentifierFound(Params,Node);
if CollectResult=ifrAbortSearch then begin
Result:=false;
exit;
end else if CollectResult=ifrSuccess then begin
Result:=true;
Params.SetResult(Self,Node);
exit;
end;
end else if CompareSrcIdentifiers(Node.StartPos,Params.Identifier) then begin
// the searched identifier was a uses AUnitName, point to the identifier in
// the uses section
Result:=true;
Params.SetResult(Self,Node,Node.StartPos);
Result:=true;
exit;
end;
Node:=Node.PriorBrother;
end;
end;
if not (fdfIgnoreUsedUnits in Params.Flags) then begin
// search in units
Node:=UsesNode.LastChild;

View File

@ -173,7 +173,7 @@ type
ilcfStartIsSubIdent, // atom in front is point
ilcfNeedsEndSemicolon, // after context a semicolon is needed. e.g. 'A| end'
ilcfNoEndSemicolon, // no semicolon after. E.g. 'A| else'
ilcfNeedsEndComma, // after context a comma is needed. e.g. 'sysutil| classes'
ilcfNeedsEndComma, // after context a comma is needed. e.g. 'uses sysutil| classes'
ilcfIsExpression, // is expression part of statement. e.g. 'if expr'
ilcfCanProcDeclaration,// context allows to declare a procedure/method
ilcfEndOfLine // atom at end of line
@ -1058,6 +1058,10 @@ begin
ctnRecordCase:
Ident:=@FoundContext.Tool.Src[Params.NewCleanPos];
ctnUseUnit:
if (FoundContext.Tool=Self) then begin
Ident:=@Src[FoundContext.Node.StartPos];
end;
end;
if Ident=nil then exit;