codetools: TStandardCodeTool.UsesSectionToUnitnames: dotted names

git-svn-id: trunk@32117 -
This commit is contained in:
mattias 2011-08-30 16:03:46 +00:00
parent 9f82460b7b
commit 5190b83a71
2 changed files with 28 additions and 26 deletions

View File

@ -2585,10 +2585,11 @@ begin
if CurPos.Flag<>cafPoint then break; if CurPos.Flag<>cafPoint then break;
ReadNextAtom; ReadNextAtom;
end; end;
if (InFilename<>nil) and (UpAtomIs('IN')) then begin if UpAtomIs('IN') then begin
ReadNextAtom; ReadNextAtom;
if not AtomIsStringConstant then exit; if not AtomIsStringConstant then exit;
InFilename^:=copy(Src,CurPos.StartPos+1,CurPos.EndPos-CurPos.StartPos-2); if InFilename<>nil then
InFilename^:=copy(Src,CurPos.StartPos+1,CurPos.EndPos-CurPos.StartPos-2);
ReadNextAtom; ReadNextAtom;
end; end;
end; end;

View File

@ -126,7 +126,7 @@ type
NormalUnits: TStrings; NormalUnits: TStrings;
UseContainsSection: boolean = false): boolean; UseContainsSection: boolean = false): boolean;
function UsesSectionToFilenames(UsesNode: TCodeTreeNode): TStrings; function UsesSectionToFilenames(UsesNode: TCodeTreeNode): TStrings;
function UsesSectionToUnitnames(UsesNode: TCodeTreeNode): TStrings; // ToDo: dotted function UsesSectionToUnitnames(UsesNode: TCodeTreeNode): TStrings;
function FindMissingUnits(var MissingUnits: TStrings; FixCase: boolean; function FindMissingUnits(var MissingUnits: TStrings; FixCase: boolean;
SearchImplementation: boolean; SearchImplementation: boolean;
SourceChangeCache: TSourceChangeCache): boolean; // ToDo: dotted SourceChangeCache: TSourceChangeCache): boolean; // ToDo: dotted
@ -1368,7 +1368,7 @@ begin
// source found => add filename to list // source found => add filename to list
FoundInUnits.AddObject(AnUnitName+' in '+AnUnitInFilename,NewCode); FoundInUnits.AddObject(AnUnitName+' in '+AnUnitInFilename,NewCode);
end; end;
end else begin end else if AnUnitName<>'' then begin
// the units without 'in' are 'Forms' or units added by the user // the units without 'in' are 'Forms' or units added by the user
NewCode:=FindUnitSource(AnUnitName,AnUnitInFilename,false); NewCode:=FindUnitSource(AnUnitName,AnUnitInFilename,false);
NormalUnits.AddObject(AnUnitName,NewCode); NormalUnits.AddObject(AnUnitName,NewCode);
@ -1401,19 +1401,21 @@ begin
while Node<>nil do begin while Node<>nil do begin
// read unit name // read unit name
AnUnitName:=ExtractUsedUnitName(Node,@AnUnitInFilename); AnUnitName:=ExtractUsedUnitName(Node,@AnUnitInFilename);
// find unit file if AnUnitName<>'' then begin
NewCode:=FindUnitSource(AnUnitName,AnUnitInFilename,false); // find unit file
if (NewCode=nil) then begin NewCode:=FindUnitSource(AnUnitName,AnUnitInFilename,false);
// no source found if (NewCode=nil) then begin
UnitFilename:=AnUnitName; // no source found
if AnUnitInFilename<>'' then UnitFilename:=AnUnitName;
UnitFilename:=UnitFilename+' in '+AnUnitInFilename; if AnUnitInFilename<>'' then
end else begin UnitFilename:=UnitFilename+' in '+AnUnitInFilename;
// source found end else begin
UnitFilename:=NewCode.Filename; // source found
UnitFilename:=NewCode.Filename;
end;
// add filename to list
Result.AddObject(UnitFilename,NewCode);
end; end;
// add filename to list
Result.AddObject(UnitFilename,NewCode);
Node:=Node.PriorBrother; Node:=Node.PriorBrother;
end; end;
end; end;
@ -1421,20 +1423,19 @@ end;
function TStandardCodeTool.UsesSectionToUnitnames(UsesNode: TCodeTreeNode function TStandardCodeTool.UsesSectionToUnitnames(UsesNode: TCodeTreeNode
): TStrings; ): TStrings;
var var
InAtom, UnitNameAtom: TAtomPosition;
AnUnitName: string; AnUnitName: string;
Node: TCodeTreeNode;
begin begin
Result:=TStringList.Create; Result:=TStringList.Create;
if UsesNode=nil then exit; if UsesNode=nil then exit;
MoveCursorToUsesEnd(UsesNode); Node:=UsesNode.LastChild;
repeat while Node<>nil do begin
// read prior unit name // read unit name
ReadPriorUsedUnit(UnitNameAtom, InAtom); AnUnitName:=ExtractUsedUnitName(Node);
AnUnitName:=GetAtom(UnitNameAtom); if AnUnitName<>'' then
Result.Add(AnUnitName); Result.Add(AnUnitName);
// read keyword 'uses' or comma Node:=Node.PriorBrother;
ReadPriorAtom; end;
until not AtomIsChar(',');
end; end;
function TStandardCodeTool.FindMissingUnits(var MissingUnits: TStrings; function TStandardCodeTool.FindMissingUnits(var MissingUnits: TStrings;