Codetools & LazUtils: Replace const string arrays with RTTI value and WriteStr()

git-svn-id: trunk@34757 -
This commit is contained in:
juha 2012-01-15 23:50:39 +00:00
parent c3637f3879
commit 03d1306b86
3 changed files with 21 additions and 60 deletions

View File

@ -1543,12 +1543,10 @@ function TExtractProcTool.ScanNodesForVariables(const StartPos,
): boolean;
type
TParameterType = (ptNone, ptConst, ptVar, ptOut, ptNoSpecifier);
{$IFDEF CTDebug}
const
ParameterTypeNames: array[TParameterType] of string = (
'ptNone', 'ptConst', 'ptVar', 'ptOut', 'ptNoSpecifier');
{$ENDIF}
var
{$IFDEF CTDebug}
s: string;
{$ENDIF}
VarCandidates: TAVLTree; // tree of PChar
procedure ScanForLocalVariables(Node: TCodeTreeNode);
@ -1571,9 +1569,9 @@ var
ProcVar: TExtractedProcVariable;
begin
{$IFDEF CTDebug}
WriteStr(s, ParameterType);
DebugLn(['AddVariableToTree A Ident=',GetIdentifier(@Src[VarNode.StartPos]),
' IsInSelection=',dbgs(IsInSelection),
' ParameterType=',ParameterTypeNames[ParameterType]]);
' IsInSelection=',dbgs(IsInSelection),' ParameterType=',s]);
{$ENDIF}
if VarTree=nil then exit;

View File

@ -184,31 +184,6 @@ const
fdfDefaultForExpressions = [fdfSearchInParentNodes, fdfSearchInAncestors,
fdfExceptionOnNotFound,fdfIgnoreCurContextNode];
// for nicer output
FindDeclarationFlagNames: array[TFindDeclarationFlag] of string = (
'fdfSearchInAncestors',
'fdfSearchInParentNodes',
'fdfIgnoreCurContextNode',
'fdfIgnoreUsedUnits',
'fdfSearchForward',
'fdfExceptionOnNotFound',
'fdfExceptionOnPredefinedIdent',
'fdfIgnoreClassVisibility',
'fdfIgnoreMissingParams',
'fdfOnlyCompatibleProc',
'fdfIgnoreOverloadedProcs',
'fdfFindVariable',
'fdfFunctionResult',
'fdfEnumIdentifier',
'fdfFindChilds',
'fdfSkipClassForward',
'fdfCollect',
'fdfTopLvlResolving',
'fdfDoNotCache',
'fdfExtractOperand',
'fdfPropertyResolving'
);
type
// flags/states for result
TFoundDeclarationFlag = (
@ -216,11 +191,6 @@ type
);
TFoundDeclarationFlags = set of TFoundDeclarationFlag;
const
FoundDeclarationFlagNames: array[TFoundDeclarationFlag] of string = (
'fodDoNotCache'
);
//----------------------------------------------------------------------------
type
TFindDeclarationParams = class;
@ -934,30 +904,34 @@ function dbgs(const Flags: TFoundDeclarationFlags): string; overload;
implementation
function dbgs(
const Flags: TFindDeclarationFlags): string;
var Flag: TFindDeclarationFlag;
function dbgs(const Flags: TFindDeclarationFlags): string;
var
Flag: TFindDeclarationFlag;
s: string;
begin
Result:='';
for Flag:=Low(TFindDeclarationFlag) to High(TFindDeclarationFlag) do begin
if Flag in Flags then begin
if Result<>'' then
Result:=Result+', ';
Result:=Result+FindDeclarationFlagNames[Flag];
WriteStr(s, Flag);
Result:=Result+s;
end;
end;
end;
function dbgs(
const Flags: TFoundDeclarationFlags): string;
var Flag: TFoundDeclarationFlag;
function dbgs(const Flags: TFoundDeclarationFlags): string;
var
Flag: TFoundDeclarationFlag;
s: string;
begin
Result:='';
for Flag:=Low(TFoundDeclarationFlag) to High(TFoundDeclarationFlag) do begin
if Flag in Flags then begin
if Result<>'' then
Result:=Result+', ';
Result:=Result+FoundDeclarationFlagNames[Flag];
WriteStr(s, Flag);
Result:=Result+s;
end;
end;
end;

View File

@ -97,19 +97,6 @@ procedure InvalidateFileStateCache(const Filename: string = ''); inline;
function CompareFileStateItems(Data1, Data2: Pointer): integer;
function CompareFilenameWithFileStateCacheItem(Key, Data: Pointer): integer;
const
FileStateCacheItemFlagNames: array[TFileStateCacheItemFlag] of string = (
'fsciExists',
'fsciDirectory',
'fsciReadable',
'fsciWritable',
'fsciDirectoryReadable',
'fsciDirectoryWritable',
'fsciText',
'fsciExecutable',
'fsciAge'
);
const
LUInvalidChangeStamp = Low(integer);
LUInvalidChangeStamp64 = Low(int64); // using a value outside integer to spot wrong types early
@ -256,7 +243,8 @@ begin
Include(AFile.FFlags,AFlag)
else
Exclude(AFile.FFlags,AFlag);
//debugln('TFileStateCache.SetFlag AFile.Filename=',AFile.Filename,' ',FileStateCacheItemFlagNames[AFlag],'=',dbgs(AFlag in AFile.FFlags),' Valid=',dbgs(AFlag in AFile.FTestedFlags));
//WriteStr(s, AFlag);
//debugln('TFileStateCache.SetFlag AFile.Filename=',AFile.Filename,' ',s,'=',dbgs(AFlag in AFile.FFlags),' Valid=',dbgs(AFlag in AFile.FTestedFlags));
end;
constructor TFileStateCache.Create;
@ -446,7 +434,8 @@ begin
Result:=false;
FlagIsSet:=false;
end;
//debugln('TFileStateCache.Check Filename=',Filename,' AFile.Filename=',AFile.Filename,' ',FileStateCacheItemFlagNames[AFlag],'=',dbgs(FlagIsSet),' Valid=',dbgs(Result));
//WriteStr(s, AFlag);
//debugln('TFileStateCache.Check Filename=',Filename,' AFile.Filename=',AFile.Filename,' ',s,'=',dbgs(FlagIsSet),' Valid=',dbgs(Result));
end;
procedure TFileStateCache.WriteDebugReport;