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

View File

@ -184,31 +184,6 @@ const
fdfDefaultForExpressions = [fdfSearchInParentNodes, fdfSearchInAncestors, fdfDefaultForExpressions = [fdfSearchInParentNodes, fdfSearchInAncestors,
fdfExceptionOnNotFound,fdfIgnoreCurContextNode]; 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 type
// flags/states for result // flags/states for result
TFoundDeclarationFlag = ( TFoundDeclarationFlag = (
@ -216,11 +191,6 @@ type
); );
TFoundDeclarationFlags = set of TFoundDeclarationFlag; TFoundDeclarationFlags = set of TFoundDeclarationFlag;
const
FoundDeclarationFlagNames: array[TFoundDeclarationFlag] of string = (
'fodDoNotCache'
);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
type type
TFindDeclarationParams = class; TFindDeclarationParams = class;
@ -934,30 +904,34 @@ function dbgs(const Flags: TFoundDeclarationFlags): string; overload;
implementation implementation
function dbgs( function dbgs(const Flags: TFindDeclarationFlags): string;
const Flags: TFindDeclarationFlags): string; var
var Flag: TFindDeclarationFlag; Flag: TFindDeclarationFlag;
s: string;
begin begin
Result:=''; Result:='';
for Flag:=Low(TFindDeclarationFlag) to High(TFindDeclarationFlag) do begin for Flag:=Low(TFindDeclarationFlag) to High(TFindDeclarationFlag) do begin
if Flag in Flags then begin if Flag in Flags then begin
if Result<>'' then if Result<>'' then
Result:=Result+', '; Result:=Result+', ';
Result:=Result+FindDeclarationFlagNames[Flag]; WriteStr(s, Flag);
Result:=Result+s;
end; end;
end; end;
end; end;
function dbgs( function dbgs(const Flags: TFoundDeclarationFlags): string;
const Flags: TFoundDeclarationFlags): string; var
var Flag: TFoundDeclarationFlag; Flag: TFoundDeclarationFlag;
s: string;
begin begin
Result:=''; Result:='';
for Flag:=Low(TFoundDeclarationFlag) to High(TFoundDeclarationFlag) do begin for Flag:=Low(TFoundDeclarationFlag) to High(TFoundDeclarationFlag) do begin
if Flag in Flags then begin if Flag in Flags then begin
if Result<>'' then if Result<>'' then
Result:=Result+', '; Result:=Result+', ';
Result:=Result+FoundDeclarationFlagNames[Flag]; WriteStr(s, Flag);
Result:=Result+s;
end; end;
end; end;
end; end;

View File

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