mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 21:55:56 +02:00
codetools: gatherlfm: fixed skipping binary data
This commit is contained in:
parent
7047edcb6f
commit
8576232676
@ -2863,7 +2863,7 @@ var
|
||||
procedure FindCandidates;
|
||||
var
|
||||
s: String;
|
||||
LFMStream: TMemoryStream;
|
||||
LFMStream, MemStream: TMemoryStream;
|
||||
Parser: TParser;
|
||||
p: SizeInt;
|
||||
begin
|
||||
@ -2879,12 +2879,24 @@ var
|
||||
Parser := TParser.Create(LFMStream);
|
||||
repeat
|
||||
Parser.NextToken;
|
||||
if Parser.Token=#0 then
|
||||
break
|
||||
else if Parser.TokenSymbolIs(Identifier) then begin
|
||||
case Parser.Token of
|
||||
#0: break;
|
||||
toSymbol:
|
||||
begin
|
||||
p:=Parser.SourcePos+1-Length(Identifier);
|
||||
Insert(p,IdentifierPositions,length(IdentifierPositions));
|
||||
end;
|
||||
'{':
|
||||
begin
|
||||
MemStream := TMemoryStream.Create;
|
||||
try
|
||||
Parser.HexToBinary(MemStream);
|
||||
finally
|
||||
MemStream.Free;
|
||||
end;
|
||||
Parser.NextToken;
|
||||
end;
|
||||
end;
|
||||
until false;
|
||||
finally
|
||||
Parser.Free;
|
||||
|
@ -50,6 +50,7 @@ type
|
||||
procedure LFMUnitname;
|
||||
procedure LFM_RootUnitnameWrong;
|
||||
procedure LFM_ChildUnitnameWrong;
|
||||
procedure LFM_BinaryData;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -111,9 +112,12 @@ begin
|
||||
' property OnClick: TNotifyEvent;',
|
||||
' end;',
|
||||
'',
|
||||
' TBitmap = class(TPersistent)',
|
||||
' end;',
|
||||
' TButton = class(TControl)',
|
||||
' published',
|
||||
' property Default: Boolean;',
|
||||
' property Glyph: TBitmap;',
|
||||
' end;',
|
||||
'',
|
||||
' TFormStyle = (fsNormal, fsMDIChild, fsMDIForm, fsStayOnTop, fsSplash, fsSystemStayOnTop);',
|
||||
@ -340,6 +344,25 @@ begin
|
||||
CheckLFMParseError(lfmeObjectIncompatible,CodeXYPosition(19,2,FLFMCode),'Controls expected, but Fool found. See unit1.pas(7,5)');
|
||||
end;
|
||||
|
||||
procedure TTestLFMTrees.LFM_BinaryData;
|
||||
begin
|
||||
AddControls;
|
||||
AddFormUnit(['Button1: TButton']);
|
||||
FLFMCode:=AddSource('unit1.lfm',LinesToStr([
|
||||
'object Form1: TForm1',
|
||||
' object Button1: TButton',
|
||||
' Glyph.Data = {',
|
||||
' 36040000424D3604000000000000360000002800000010000000100000000100',
|
||||
' 49EE000000000004000064000000640000000000000000000000000000000000',
|
||||
' }',
|
||||
' Caption = ''ClickMe''',
|
||||
' Default = True',
|
||||
' end',
|
||||
'end'
|
||||
]));
|
||||
CheckLFMParseError(lfmeIdentifierNotFound,CodeXYPosition(11,3,FLFMCode),'identifier Data not found in class "TBitmap"');
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterTest(TTestLFMTrees);
|
||||
|
||||
|
@ -89,6 +89,7 @@ type
|
||||
// rename also in lfm
|
||||
procedure TestRenameAlsoLFM_Variable;
|
||||
procedure TestRenameAlsoLFM_Event;
|
||||
procedure TestRenameAlsoLFM_SkipBinaryData;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -2109,6 +2110,64 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestRefactoring.TestRenameAlsoLFM_SkipBinaryData;
|
||||
var
|
||||
Test1LFM, RedUnit: TCodeBuffer;
|
||||
begin
|
||||
RedUnit:=CodeToolBoss.CreateFile('red.pas');
|
||||
Test1LFM:=CodeToolBoss.CreateFile(ChangeFileExt(Code.Filename,'.lfm'));
|
||||
try
|
||||
RedUnit.Source:='unit Red;'+LineEnding
|
||||
+'interface'+LineEnding
|
||||
+'type'+LineEnding
|
||||
+' TForm = class'+LineEnding
|
||||
+' end;'+LineEnding
|
||||
+' TBitmap = class'+LineEnding
|
||||
+' end;'+LineEnding
|
||||
+' TButton = class'+LineEnding
|
||||
+' published'+LineEnding
|
||||
+' property Glyph: TBitmap;'+LineEnding
|
||||
+' end;'+LineEnding
|
||||
+'implementation'+LineEnding
|
||||
+'end.';
|
||||
|
||||
Test1LFM.Source:=LinesToStr([
|
||||
'object Form1: TForm1',
|
||||
' object Button1: TButton',
|
||||
' Glyph.Data = {',
|
||||
' 36040000424D3604000000000000360000002800000010000000100000000100',
|
||||
' 49EE000000000004000064000000640000000000000000000000000000000000',
|
||||
' }',
|
||||
' end',
|
||||
'end']);
|
||||
|
||||
Add(['unit Test1;',
|
||||
'{$mode objfpc}{$H+}',
|
||||
'interface',
|
||||
'uses red;',
|
||||
'type',
|
||||
' TForm1 = class(TForm)',
|
||||
' Button1{#Rename}: TButton;',
|
||||
' end;',
|
||||
'implementation',
|
||||
'end.']);
|
||||
RenameReferences('OkBtn',frfAllLFM);
|
||||
CheckDiff(Test1LFM,[
|
||||
'object Form1: TForm1',
|
||||
' object OkBtn: TButton',
|
||||
' Glyph.Data = {',
|
||||
' 36040000424D3604000000000000360000002800000010000000100000000100',
|
||||
' 49EE000000000004000064000000640000000000000000000000000000000000',
|
||||
' }',
|
||||
' end',
|
||||
'end']);
|
||||
|
||||
finally
|
||||
RedUnit.IsDeleted:=true;
|
||||
Test1LFM.IsDeleted:=true;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterTests([TTestRefactoring]);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user