mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 16:40:13 +02:00
codetools: gatherlfm: fixed skipping binary data
This commit is contained in:
parent
7047edcb6f
commit
8576232676
@ -2863,7 +2863,7 @@ var
|
|||||||
procedure FindCandidates;
|
procedure FindCandidates;
|
||||||
var
|
var
|
||||||
s: String;
|
s: String;
|
||||||
LFMStream: TMemoryStream;
|
LFMStream, MemStream: TMemoryStream;
|
||||||
Parser: TParser;
|
Parser: TParser;
|
||||||
p: SizeInt;
|
p: SizeInt;
|
||||||
begin
|
begin
|
||||||
@ -2879,12 +2879,24 @@ var
|
|||||||
Parser := TParser.Create(LFMStream);
|
Parser := TParser.Create(LFMStream);
|
||||||
repeat
|
repeat
|
||||||
Parser.NextToken;
|
Parser.NextToken;
|
||||||
if Parser.Token=#0 then
|
case Parser.Token of
|
||||||
break
|
#0: break;
|
||||||
else if Parser.TokenSymbolIs(Identifier) then begin
|
toSymbol:
|
||||||
|
begin
|
||||||
p:=Parser.SourcePos+1-Length(Identifier);
|
p:=Parser.SourcePos+1-Length(Identifier);
|
||||||
Insert(p,IdentifierPositions,length(IdentifierPositions));
|
Insert(p,IdentifierPositions,length(IdentifierPositions));
|
||||||
end;
|
end;
|
||||||
|
'{':
|
||||||
|
begin
|
||||||
|
MemStream := TMemoryStream.Create;
|
||||||
|
try
|
||||||
|
Parser.HexToBinary(MemStream);
|
||||||
|
finally
|
||||||
|
MemStream.Free;
|
||||||
|
end;
|
||||||
|
Parser.NextToken;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
until false;
|
until false;
|
||||||
finally
|
finally
|
||||||
Parser.Free;
|
Parser.Free;
|
||||||
|
@ -50,6 +50,7 @@ type
|
|||||||
procedure LFMUnitname;
|
procedure LFMUnitname;
|
||||||
procedure LFM_RootUnitnameWrong;
|
procedure LFM_RootUnitnameWrong;
|
||||||
procedure LFM_ChildUnitnameWrong;
|
procedure LFM_ChildUnitnameWrong;
|
||||||
|
procedure LFM_BinaryData;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -111,9 +112,12 @@ begin
|
|||||||
' property OnClick: TNotifyEvent;',
|
' property OnClick: TNotifyEvent;',
|
||||||
' end;',
|
' end;',
|
||||||
'',
|
'',
|
||||||
|
' TBitmap = class(TPersistent)',
|
||||||
|
' end;',
|
||||||
' TButton = class(TControl)',
|
' TButton = class(TControl)',
|
||||||
' published',
|
' published',
|
||||||
' property Default: Boolean;',
|
' property Default: Boolean;',
|
||||||
|
' property Glyph: TBitmap;',
|
||||||
' end;',
|
' end;',
|
||||||
'',
|
'',
|
||||||
' TFormStyle = (fsNormal, fsMDIChild, fsMDIForm, fsStayOnTop, fsSplash, fsSystemStayOnTop);',
|
' 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)');
|
CheckLFMParseError(lfmeObjectIncompatible,CodeXYPosition(19,2,FLFMCode),'Controls expected, but Fool found. See unit1.pas(7,5)');
|
||||||
end;
|
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
|
initialization
|
||||||
RegisterTest(TTestLFMTrees);
|
RegisterTest(TTestLFMTrees);
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ type
|
|||||||
// rename also in lfm
|
// rename also in lfm
|
||||||
procedure TestRenameAlsoLFM_Variable;
|
procedure TestRenameAlsoLFM_Variable;
|
||||||
procedure TestRenameAlsoLFM_Event;
|
procedure TestRenameAlsoLFM_Event;
|
||||||
|
procedure TestRenameAlsoLFM_SkipBinaryData;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -2109,6 +2110,64 @@ begin
|
|||||||
end;
|
end;
|
||||||
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
|
initialization
|
||||||
RegisterTests([TTestRefactoring]);
|
RegisterTests([TTestRefactoring]);
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user