codetools: TStandardCodeTool.FindDelphiProjectUnits: dotted names

git-svn-id: trunk@32115 -
This commit is contained in:
mattias 2011-08-30 15:58:33 +00:00
parent 14cca12943
commit ef465ef95f
2 changed files with 9 additions and 20 deletions

View File

@ -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;

View File

@ -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;