IDE: codeexplorer: implemented ignoring some function calls when gathering constants

git-svn-id: trunk@19505 -
This commit is contained in:
mattias 2009-04-19 10:36:05 +00:00
parent f1645590fd
commit 1e362205e8
2 changed files with 68 additions and 35 deletions

View File

@ -95,8 +95,9 @@ const
'0', '0',
'1' '1'
); );
DefaultIgnoreFigConstInFuncs: array[1..14] of ansistring // Note: keep this asciiz DefaultIgnoreFigConstInFuncs: array[1..15] of ansistring // Note: keep this asciiz
= ( = (
'Assert',
'Debug', 'Debug',
'DebugLn', 'DebugLn',
'DbgOut', 'DbgOut',

View File

@ -1012,48 +1012,80 @@ var
TVNode: TTreeNode; TVNode: TTreeNode;
ProcNode: TCodeTreeNode; ProcNode: TCodeTreeNode;
OldPos: LongInt; OldPos: LongInt;
CurAtom, Last1Atom, Last2Atom: TCommonAtomFlag;
FuncName: string;
Atom: TAtomPosition;
begin begin
if (StartPos<1) or (StartPos>=EndPos) then exit; if (StartPos<1) or (StartPos>=EndPos) then exit;
Tool.MoveCursorToCleanPos(StartPos); Tool.MoveCursorToCleanPos(StartPos);
Last1Atom:=cafNone;
Last2Atom:=cafNone;
while Tool.CurPos.StartPos<EndPos do begin while Tool.CurPos.StartPos<EndPos do begin
if Tool.Src[Tool.CurPos.StartPos] in ['''','#','0'..'9','$','%'] then begin CurAtom:=cafNone;
// a constant case Tool.Src[Tool.CurPos.StartPos] of
if Tool.AtomIsEmptyStringConstant then begin '''','#','0'..'9','$','%':
// ignore empty string constant ''
end else if Tool.AtomIsCharConstant
and (not CodeExplorerOptions.FigureCharConst) then
begin begin
// ignore char constants // a constant
end else if CodeExplorerOptions.IgnoreFigureConstant(@Tool.Src[Tool.CurPos.StartPos]) if Tool.AtomIsEmptyStringConstant then begin
then begin // ignore empty string constant ''
// ignore user defined constants end else if Tool.AtomIsCharConstant
end else begin and (not CodeExplorerOptions.FigureCharConst) then
// add constant begin
Data:=TViewNodeData.Create(CodeNode); // ignore char constants
Data.Desc:=ctnConstant; end else if CodeExplorerOptions.IgnoreFigureConstant(@Tool.Src[Tool.CurPos.StartPos])
Data.SubDesc:=ctnsNone; then begin
Data.StartPos:=Tool.CurPos.StartPos; // ignore user defined constants
Data.EndPos:=Tool.CurPos.EndPos; end else begin
FigTVNode:=CreateFigureNode(Tool,cefcUnnamedConsts); // add constant
NodeText:=Tool.GetAtom; Data:=TViewNodeData.Create(CodeNode);
// add some context information Data.Desc:=ctnConstant;
ProcNode:=CodeNode; Data.SubDesc:=ctnsNone;
while (ProcNode<>nil) and (ProcNode.Desc<>ctnProcedure) do Data.StartPos:=Tool.CurPos.StartPos;
ProcNode:=ProcNode.Parent; Data.EndPos:=Tool.CurPos.EndPos;
if ProcNode<>nil then begin FigTVNode:=CreateFigureNode(Tool,cefcUnnamedConsts);
OldPos:=Tool.CurPos.EndPos; NodeText:=Tool.GetAtom;
NodeText:=Format(lisCEIn, [NodeText, Tool.ExtractProcName(ProcNode, [ // add some context information
phpWithoutClassName])]); ProcNode:=CodeNode;
Tool.MoveCursorToCleanPos(OldPos); 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; end;
NodeImageIndCex:=ImgIDConst;
TVNode:=CodeTreeview.Items.AddChild(FigTVNode,NodeText);
TVNode.Data:=Data;
TVNode.Text:=NodeText;
TVNode.ImageIndex:=NodeImageIndCex;
TVNode.SelectedIndex:=NodeImageIndCex;
end; end;
end; end;
// read next atom
Last2Atom:=Last1Atom;
Last1Atom:=CurAtom;
Tool.ReadNextAtom; Tool.ReadNextAtom;
end; end;
end; end;