From 1e362205e8c3a5f71f1e12a52b64985db313daeb Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 19 Apr 2009 10:36:05 +0000 Subject: [PATCH] IDE: codeexplorer: implemented ignoring some function calls when gathering constants git-svn-id: trunk@19505 - --- ide/codeexplopts.pas | 3 +- ide/codeexplorer.pas | 100 ++++++++++++++++++++++++++++--------------- 2 files changed, 68 insertions(+), 35 deletions(-) diff --git a/ide/codeexplopts.pas b/ide/codeexplopts.pas index 1646343ad6..fea763ca09 100644 --- a/ide/codeexplopts.pas +++ b/ide/codeexplopts.pas @@ -95,8 +95,9 @@ const '0', '1' ); - DefaultIgnoreFigConstInFuncs: array[1..14] of ansistring // Note: keep this asciiz + DefaultIgnoreFigConstInFuncs: array[1..15] of ansistring // Note: keep this asciiz = ( + 'Assert', 'Debug', 'DebugLn', 'DbgOut', diff --git a/ide/codeexplorer.pas b/ide/codeexplorer.pas index 8379580241..d44fc9e208 100644 --- a/ide/codeexplorer.pas +++ b/ide/codeexplorer.pas @@ -1012,48 +1012,80 @@ var TVNode: TTreeNode; ProcNode: TCodeTreeNode; OldPos: LongInt; + CurAtom, Last1Atom, Last2Atom: TCommonAtomFlag; + FuncName: string; + Atom: TAtomPosition; begin if (StartPos<1) or (StartPos>=EndPos) then exit; Tool.MoveCursorToCleanPos(StartPos); + Last1Atom:=cafNone; + Last2Atom:=cafNone; while Tool.CurPos.StartPosnil) and (ProcNode.Desc<>ctnProcedure) do - ProcNode:=ProcNode.Parent; - if ProcNode<>nil then begin - OldPos:=Tool.CurPos.EndPos; - NodeText:=Format(lisCEIn, [NodeText, Tool.ExtractProcName(ProcNode, [ - phpWithoutClassName])]); - Tool.MoveCursorToCleanPos(OldPos); + // a constant + if Tool.AtomIsEmptyStringConstant then begin + // ignore empty string constant '' + end else if Tool.AtomIsCharConstant + and (not CodeExplorerOptions.FigureCharConst) then + begin + // ignore char constants + end else if CodeExplorerOptions.IgnoreFigureConstant(@Tool.Src[Tool.CurPos.StartPos]) + then begin + // ignore user defined constants + end else begin + // add constant + Data:=TViewNodeData.Create(CodeNode); + Data.Desc:=ctnConstant; + Data.SubDesc:=ctnsNone; + Data.StartPos:=Tool.CurPos.StartPos; + Data.EndPos:=Tool.CurPos.EndPos; + FigTVNode:=CreateFigureNode(Tool,cefcUnnamedConsts); + NodeText:=Tool.GetAtom; + // add some context information + ProcNode:=CodeNode; + while (ProcNode<>nil) and (ProcNode.Desc<>ctnProcedure) do + ProcNode:=ProcNode.Parent; + if ProcNode<>nil then begin + OldPos:=Tool.CurPos.EndPos; + NodeText:=Format(lisCEIn, [NodeText, Tool.ExtractProcName(ProcNode, [ + phpWithoutClassName])]); + Tool.MoveCursorToCleanPos(OldPos); + end; + NodeImageIndCex:=ImgIDConst; + TVNode:=CodeTreeview.Items.AddChild(FigTVNode,NodeText); + TVNode.Data:=Data; + TVNode.Text:=NodeText; + TVNode.ImageIndex:=NodeImageIndCex; + TVNode.SelectedIndex:=NodeImageIndCex; + end; + end; + + '.': + CurAtom:=cafPoint; + + '_','a'..'z','A'..'Z': + CurAtom:=cafWord; + + '(','[': + if Last1Atom=cafWord then + begin + Atom:=Tool.LastAtoms.GetValueAt(0); + FuncName:=copy(Tool.Src,Atom.StartPos,Atom.EndPos-Atom.StartPos); + if Last2Atom=cafPoint then + FuncName:='.'+FuncName; + if CodeExplorerOptions.IgnoreFigConstInFunc(FuncName) then + begin + // skip this function call + Tool.ReadTilBracketClose(false); end; - NodeImageIndCex:=ImgIDConst; - TVNode:=CodeTreeview.Items.AddChild(FigTVNode,NodeText); - TVNode.Data:=Data; - TVNode.Text:=NodeText; - TVNode.ImageIndex:=NodeImageIndCex; - TVNode.SelectedIndex:=NodeImageIndCex; end; end; + // read next atom + Last2Atom:=Last1Atom; + Last1Atom:=CurAtom; Tool.ReadNextAtom; end; end;