mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 13:19:52 +02:00
codetools: identifier completion: list used units
git-svn-id: trunk@24999 -
This commit is contained in:
parent
ca57327310
commit
e9d4b90835
@ -3300,7 +3300,7 @@ begin
|
|||||||
if (CompilerPath='') or (not FileIsExecutable(CompilerPath)) then exit;
|
if (CompilerPath='') or (not FileIsExecutable(CompilerPath)) then exit;
|
||||||
LastDefTempl:=nil;
|
LastDefTempl:=nil;
|
||||||
// find all initial compiler macros and all unit paths
|
// 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);
|
SetLength(Buf,1024);
|
||||||
Step:='Init';
|
Step:='Init';
|
||||||
try
|
try
|
||||||
|
@ -5284,25 +5284,38 @@ var
|
|||||||
NewCodeTool: TFindDeclarationTool;
|
NewCodeTool: TFindDeclarationTool;
|
||||||
OldFlags: TFindDeclarationFlags;
|
OldFlags: TFindDeclarationFlags;
|
||||||
Node: TCodeTreeNode;
|
Node: TCodeTreeNode;
|
||||||
|
CollectResult: TIdentifierFoundResult;
|
||||||
begin
|
begin
|
||||||
{$IFDEF CheckNodeTool}CheckNodeTool(UsesNode);{$ENDIF}
|
{$IFDEF CheckNodeTool}CheckNodeTool(UsesNode);{$ENDIF}
|
||||||
{$IFDEF ShowTriedParentContexts}
|
{$IFDEF ShowTriedParentContexts}
|
||||||
DebugLn(['TFindDeclarationTool.FindIdentifierInUsesSection ',MainFilename,' fdfIgnoreUsedUnits=',fdfIgnoreUsedUnits in Params.Flags]);
|
DebugLn(['TFindDeclarationTool.FindIdentifierInUsesSection ',MainFilename,' fdfIgnoreUsedUnits=',fdfIgnoreUsedUnits in Params.Flags]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
// first search in used unit names
|
||||||
if (Params.IdentifierTool=Self) then begin
|
if (Params.IdentifierTool=Self) then begin
|
||||||
Node:=UsesNode.LastChild;
|
Node:=UsesNode.LastChild;
|
||||||
while Node<>nil do begin
|
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 searched identifier was a uses AUnitName, point to the identifier in
|
||||||
// the uses section
|
// the uses section
|
||||||
Result:=true;
|
|
||||||
Params.SetResult(Self,Node,Node.StartPos);
|
Params.SetResult(Self,Node,Node.StartPos);
|
||||||
|
Result:=true;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
Node:=Node.PriorBrother;
|
Node:=Node.PriorBrother;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not (fdfIgnoreUsedUnits in Params.Flags) then begin
|
if not (fdfIgnoreUsedUnits in Params.Flags) then begin
|
||||||
// search in units
|
// search in units
|
||||||
Node:=UsesNode.LastChild;
|
Node:=UsesNode.LastChild;
|
||||||
|
@ -173,7 +173,7 @@ type
|
|||||||
ilcfStartIsSubIdent, // atom in front is point
|
ilcfStartIsSubIdent, // atom in front is point
|
||||||
ilcfNeedsEndSemicolon, // after context a semicolon is needed. e.g. 'A| end'
|
ilcfNeedsEndSemicolon, // after context a semicolon is needed. e.g. 'A| end'
|
||||||
ilcfNoEndSemicolon, // no semicolon after. E.g. 'A| else'
|
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'
|
ilcfIsExpression, // is expression part of statement. e.g. 'if expr'
|
||||||
ilcfCanProcDeclaration,// context allows to declare a procedure/method
|
ilcfCanProcDeclaration,// context allows to declare a procedure/method
|
||||||
ilcfEndOfLine // atom at end of line
|
ilcfEndOfLine // atom at end of line
|
||||||
@ -1058,6 +1058,10 @@ begin
|
|||||||
ctnRecordCase:
|
ctnRecordCase:
|
||||||
Ident:=@FoundContext.Tool.Src[Params.NewCleanPos];
|
Ident:=@FoundContext.Tool.Src[Params.NewCleanPos];
|
||||||
|
|
||||||
|
ctnUseUnit:
|
||||||
|
if (FoundContext.Tool=Self) then begin
|
||||||
|
Ident:=@Src[FoundContext.Node.StartPos];
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
if Ident=nil then exit;
|
if Ident=nil then exit;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user