From 35b4131a89b82f705c917130a262df4403db0772 Mon Sep 17 00:00:00 2001 From: juha Date: Sat, 8 Jun 2013 16:32:31 +0000 Subject: [PATCH] Codetools: move similar functions dealing with unit name together. git-svn-id: trunk@41591 - --- components/codetools/pascalreadertool.pas | 64 +++++++++++------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/components/codetools/pascalreadertool.pas b/components/codetools/pascalreadertool.pas index be6d5da8d1..f5893a08ed 100644 --- a/components/codetools/pascalreadertool.pas +++ b/components/codetools/pascalreadertool.pas @@ -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;