mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 06:17:14 +02:00
Converter: after codetools exception, insert '&' before every '.'+reserved word instead of only '.type'. Part of issue #23552
git-svn-id: trunk@42156 -
This commit is contained in:
parent
8816386294
commit
7d5074bd8c
@ -142,23 +142,27 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TCodeToolLink.DummyReplacements: Boolean;
|
function TCodeToolLink.DummyReplacements: Boolean;
|
||||||
// If Codetools cannot parse the code, do dummy replacement of some known problematic
|
// If Codetools cannot parse the code, do dummy replacement for all reserved words:
|
||||||
// syntax, currently only OleVariant.type. Most Codetools functions cannot
|
// '.'+ReservedWord -> '.&'+ReservedWord, needed for OleVariant.
|
||||||
// be used because the code is invalid, but TSourceChangeCache.ReplaceEx works.
|
// Most Codetools functions cannot be used because the code is invalid,
|
||||||
const
|
// but TSourceChangeCache.ReplaceEx works.
|
||||||
ReplString = '.type';
|
|
||||||
var
|
var
|
||||||
p: Integer;
|
p, i: Integer;
|
||||||
|
s: string;
|
||||||
begin
|
begin
|
||||||
p:=1;
|
// Reserved words are in WordIsKeyWord list in CodeTools.
|
||||||
repeat
|
for i:=0 to WordIsKeyWord.Count-1 do begin
|
||||||
// find next '.type'
|
s:='.'+LowerCase(WordIsKeyWord.GetItem(i).KeyWord);
|
||||||
p:=PosEx(ReplString,fCode.Source,p);
|
p:=1;
|
||||||
if p<1 then break;
|
repeat
|
||||||
if not fSrcCache.ReplaceEx(gtNone,gtNone,1,1,fCode,p+1,p+1,'&') then
|
p:=PosEx(s,fCode.Source,p); // find next '.'+ReservedWord
|
||||||
Exit(False);
|
if p<1 then break;
|
||||||
inc(p,length(ReplString));
|
if not fSrcCache.ReplaceEx(gtNone,gtNone,1,1,fCode,p+1,p+1,'&') then
|
||||||
until false;
|
Exit(False);
|
||||||
|
inc(p,length(s));
|
||||||
|
until false;
|
||||||
|
end;
|
||||||
|
// Apply the changes in buffer
|
||||||
if not fSrcCache.Apply then
|
if not fSrcCache.Apply then
|
||||||
Exit(False);
|
Exit(False);
|
||||||
Result:=True;
|
Result:=True;
|
||||||
|
Loading…
Reference in New Issue
Block a user