diff --git a/components/codetools/definetemplates.pas b/components/codetools/definetemplates.pas index 48f1791aeb..f3c56fe10a 100644 --- a/components/codetools/definetemplates.pas +++ b/components/codetools/definetemplates.pas @@ -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 diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 71e72060b0..d439af91fe 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -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; diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index 85bb806e78..73f7d5b025 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -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;