mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 01:16:18 +02:00
Codetools: move similar functions dealing with unit name together.
git-svn-id: trunk@41591 -
This commit is contained in:
parent
6c7d3d2d5b
commit
35b4131a89
@ -207,11 +207,11 @@ type
|
||||
Attr: TProcHeadAttributes): string;
|
||||
|
||||
// module sections
|
||||
function ExtractSourceName: string;
|
||||
function GetSourceNamePos(var NamePos: TAtomPosition): boolean;
|
||||
function GetSourceName(DoBuildTree: boolean = true): string;
|
||||
function GetSourceType: TCodeTreeNodeDesc;
|
||||
function GetSourceNamePos(var NamePos: TAtomPosition): boolean;
|
||||
function PositionInSourceName(CleanPos: integer): boolean;
|
||||
function ExtractSourceName: string;
|
||||
|
||||
// uses sections
|
||||
procedure MoveCursorToUsesStart(UsesNode: TCodeTreeNode);
|
||||
@ -2107,27 +2107,6 @@ begin
|
||||
Result:=ctnNone;
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.GetSourceNamePos(var NamePos: TAtomPosition): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
NamePos.StartPos:=-1;
|
||||
if Tree.Root=nil then exit;
|
||||
MoveCursorToNodeStart(Tree.Root);
|
||||
ReadNextAtom; // read source type 'program', 'unit' ...
|
||||
if (Tree.Root.Desc=ctnProgram) and (not UpAtomIs('PROGRAM')) then exit;
|
||||
ReadNextAtom; // read name
|
||||
if not AtomIsIdentifier then exit;
|
||||
NamePos:=CurPos;
|
||||
Result:=true;
|
||||
ReadNextAtom;
|
||||
while CurPos.Flag=cafPoint do begin
|
||||
ReadNextAtom;
|
||||
if not AtomIsIdentifier then exit;
|
||||
NamePos.EndPos:=CurPos.EndPos;
|
||||
ReadNextAtom;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.PositionInSourceName(CleanPos: integer): boolean;
|
||||
var
|
||||
NamePos: TAtomPosition;
|
||||
@ -2165,6 +2144,36 @@ begin
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.GetSourceNamePos(var NamePos: TAtomPosition): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
NamePos.StartPos:=-1;
|
||||
if Tree.Root=nil then exit;
|
||||
MoveCursorToNodeStart(Tree.Root);
|
||||
ReadNextAtom; // read source type 'program', 'unit' ...
|
||||
if (Tree.Root.Desc=ctnProgram) and (not UpAtomIs('PROGRAM')) then exit;
|
||||
ReadNextAtom; // read name
|
||||
if not AtomIsIdentifier then exit;
|
||||
NamePos:=CurPos;
|
||||
Result:=true;
|
||||
ReadNextAtom;
|
||||
while CurPos.Flag=cafPoint do begin
|
||||
ReadNextAtom;
|
||||
if not AtomIsIdentifier then exit;
|
||||
NamePos.EndPos:=CurPos.EndPos;
|
||||
ReadNextAtom;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.GetSourceName(DoBuildTree: boolean): string;
|
||||
begin
|
||||
Result:='';
|
||||
if DoBuildTree then
|
||||
BuildTree(lsrSourceName);
|
||||
CachedSourceName:=ExtractSourceName;
|
||||
Result:=CachedSourceName;
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.NodeIsInAMethod(Node: TCodeTreeNode): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
@ -2574,15 +2583,6 @@ begin
|
||||
Result:=ExtractBrackets(CurPos.StartPos,Attr);
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.GetSourceName(DoBuildTree: boolean): string;
|
||||
begin
|
||||
Result:='';
|
||||
if DoBuildTree then
|
||||
BuildTree(lsrSourceName);
|
||||
CachedSourceName:=ExtractSourceName;
|
||||
Result:=CachedSourceName;
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.PropertyIsDefault(PropertyNode: TCodeTreeNode): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
|
Loading…
Reference in New Issue
Block a user