mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-15 12:19:13 +02:00
codetools: TStandardCodeTool.UnitExistsInUsesSection: dotted name
git-svn-id: trunk@32106 -
This commit is contained in:
parent
9a357e6a34
commit
421f9a390f
@ -212,6 +212,7 @@ type
|
||||
procedure ReadPriorUsedUnit(out UnitNameRange, InAtom: TAtomPosition);
|
||||
function ExtractUsedUnitName(UseUnitNode: TCodeTreeNode;
|
||||
InFilename: PAnsiString = nil): string;
|
||||
function ReadAndCompareUsedUnit(const AnUnitName: string): boolean;
|
||||
|
||||
// comments
|
||||
function FindCommentInFront(const StartPos: TCodeXYPosition;
|
||||
@ -2583,6 +2584,40 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.ReadAndCompareUsedUnit(const AnUnitName: string
|
||||
): boolean;
|
||||
// after reading cursor is on atom behind unit name
|
||||
var
|
||||
p: PChar;
|
||||
begin
|
||||
Result:=false;
|
||||
if not IsDottedIdentifier(AnUnitName) then exit;
|
||||
p:=PChar(AnUnitName);
|
||||
repeat
|
||||
if not AtomIsIdentifier(false) then exit;
|
||||
if (p<>nil) then begin
|
||||
if CompareIdentifiers(p,@Src[CurPos.StartPos])=0 then
|
||||
inc(p,CurPos.EndPos-CurPos.StartPos)
|
||||
else
|
||||
p:=nil;
|
||||
end;
|
||||
ReadNextAtom;
|
||||
if CurPos.Flag<>cafPoint then begin
|
||||
// end of unit name
|
||||
Result:=(p<>nil) and (p^=#0);
|
||||
exit;
|
||||
end;
|
||||
// dot
|
||||
if (p<>nil) then begin
|
||||
if p='.' then
|
||||
inc(p)
|
||||
else
|
||||
p:=nil;
|
||||
end;
|
||||
ReadNextAtom;
|
||||
until false;
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.FindCommentInFront(const StartPos: TCodeXYPosition;
|
||||
const CommentText: string; InvokeBuildTree, SearchInParentNode,
|
||||
WithCommentBounds, CaseSensitive, IgnoreSpaces, CompareOnlyStart: boolean;
|
||||
|
@ -1019,8 +1019,6 @@ end;
|
||||
|
||||
function TStandardCodeTool.UnitExistsInUsesSection(UsesNode: TCodeTreeNode;
|
||||
const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean;
|
||||
var
|
||||
p: PChar;
|
||||
begin
|
||||
Result:=false;
|
||||
if (UsesNode=nil) or (not IsDottedIdentifier(AnUnitName)) then
|
||||
@ -1028,30 +1026,11 @@ begin
|
||||
MoveCursorToNodeStart(UsesNode);
|
||||
ReadNextAtom; // read 'uses'
|
||||
repeat
|
||||
p:=PChar(AnUnitName);
|
||||
ReadNextAtom; // read name
|
||||
if not AtomIsIdentifier(false) then exit;
|
||||
while CompareIdentifiers(@Src[CurPos.StartPos],p)=0 do begin
|
||||
inc(p,CurPos.EndPos-CurPos.StartPos);
|
||||
ReadNextAtom;
|
||||
if CurPos.Flag<>cafPoint then begin
|
||||
// end of unit name reached
|
||||
if p^=#0 then exit(true); // unit found
|
||||
break;
|
||||
end;
|
||||
// dot
|
||||
if p^<>'.' then begin
|
||||
// skip rest of unit name
|
||||
repeat
|
||||
ReadNextAtom;
|
||||
if not AtomIsIdentifier(false) then exit;
|
||||
ReadNextAtom;
|
||||
until CurPos.Flag<>cafPoint;
|
||||
break;
|
||||
end;
|
||||
inc(p);
|
||||
ReadNextAtom;
|
||||
if not AtomIsIdentifier(false) then exit;
|
||||
if ReadAndCompareUsedUnit(AnUnitName) then begin
|
||||
// unit found
|
||||
exit(true);
|
||||
end;
|
||||
if UpAtomIs('IN') then begin
|
||||
ReadNextAtom;
|
||||
|
Loading…
Reference in New Issue
Block a user