From ef465ef95fc50948d3c41c5e4b6a478e8d285ab0 Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 30 Aug 2011 15:58:33 +0000 Subject: [PATCH] codetools: TStandardCodeTool.FindDelphiProjectUnits: dotted names git-svn-id: trunk@32115 - --- components/codetools/pascalreadertool.pas | 2 ++ components/codetools/stdcodetools.pas | 27 ++++++----------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/components/codetools/pascalreadertool.pas b/components/codetools/pascalreadertool.pas index 6bc7efee54..1144cd924e 100644 --- a/components/codetools/pascalreadertool.pas +++ b/components/codetools/pascalreadertool.pas @@ -2571,6 +2571,7 @@ end; function TPascalReaderTool.ExtractUsedUnitName(UseUnitNode: TCodeTreeNode; InFilename: PAnsiString): string; +// after reading CurPos is on atom behind, i.e. comma or semicolon begin Result:=''; if InFilename<>nil then InFilename^:=''; @@ -2588,6 +2589,7 @@ begin ReadNextAtom; if not AtomIsStringConstant then exit; InFilename^:=copy(Src,CurPos.StartPos+1,CurPos.EndPos-CurPos.StartPos-2); + ReadNextAtom; end; end; diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index 3c7ae044db..2b23e3c36f 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -1337,33 +1337,26 @@ end; function TStandardCodeTool.FindDelphiProjectUnits(var FoundInUnits, MissingInUnits, NormalUnits: TStrings; UseContainsSection: boolean): boolean; var - InAtom, UnitNameAtom: TAtomPosition; AnUnitName, AnUnitInFilename: string; NewCode: TCodeBuffer; UsesNode: TCodeTreeNode; + Node: TCodeTreeNode; begin Result:=false; FoundInUnits:=nil; MissingInUnits:=nil; NormalUnits:=nil; - DebugLn('TStandardCodeTool.FindDelphiProjectUnits UseContainsSection=',dbgs(UseContainsSection)); // find the uses sections - BuildTree(lsrEnd); + BuildTree(lsrMainUsesSectionEnd); UsesNode:=FindMainUsesSection(UseContainsSection); if UsesNode=nil then exit; - MoveCursorToUsesStart(UsesNode); FoundInUnits:=TStringList.Create; MissingInUnits:=TStringList.Create; NormalUnits:=TStringList.Create; - repeat + Node:=UsesNode.FirstChild; + while Node<>nil do begin // read next unit name - ReadNextUsedUnit(UnitNameAtom, InAtom); - AnUnitName:=GetAtom(UnitNameAtom); - if InAtom.StartPos>0 then begin - AnUnitInFilename:=copy(Src,InAtom.StartPos+1, - InAtom.EndPos-InAtom.StartPos-2); - end else - AnUnitInFilename:=''; + AnUnitName:=ExtractUsedUnitName(Node,@AnUnitInFilename); // find unit file if AnUnitInFilename<>'' then begin // An 'in' unit => Delphi project file @@ -1380,14 +1373,8 @@ begin NewCode:=FindUnitSource(AnUnitName,AnUnitInFilename,false); NormalUnits.AddObject(AnUnitName,NewCode); end; - if CurPos.Flag=cafComma then begin - // read next unit name - ReadNextAtom; - end else if CurPos.Flag=cafSemicolon then begin - break; - end else - RaiseExceptionFmt(ctsStrExpectedButAtomFound,[';',GetAtom]); - until false; + Node:=Node.NextBrother; + end; Result:=true; end;