codetools: local variable assignment completion: parsing string constant with old TP style character constants, bug #19260

git-svn-id: trunk@30559 -
This commit is contained in:
mattias 2011-05-05 20:08:42 +00:00
parent 6913c9315d
commit be30cfeca4
2 changed files with 48 additions and 29 deletions

View File

@ -820,51 +820,60 @@ begin
end; end;
function TCustomCodeTool.AtomIsStringConstant: boolean; function TCustomCodeTool.AtomIsStringConstant: boolean;
var
p: PChar;
begin begin
Result:=(CurPos.StartPos<=SrcLen) if CurPos.StartPos>SrcLen then exit(false);
and (Src[CurPos.StartPos] in ['''','#']); p:=@Src[CurPos.StartPos];
Result:=(p^ in ['''','#']) or ((p^='^') and (p[1] in ['A'..'Z']));
end; end;
function TCustomCodeTool.AtomIsCharConstant: boolean; function TCustomCodeTool.AtomIsCharConstant: boolean;
var i: integer; var
p: LongInt; p: PChar;
begin begin
Result:=false; Result:=false;
p:=CurPos.StartPos; if (CurPos.StartPos<=SrcLen) then begin
if (p<=SrcLen) then begin p:=@Src[CurPos.StartPos];
case Src[p] of case p^ of
'#': '#':
begin begin
i:=p+1; inc(p);
if (i<=SrcLen) then begin if IsNumberChar[p^] then begin
if IsNumberChar[Src[i]] then begin // decimal
// decimal while IsNumberChar[p^] do
while (i<=SrcLen) and (IsNumberChar[Src[i]]) do inc(p);
inc(i); end else if p^='$' then begin
end else if Src[i]='$' then begin // hexadecimal
// hexadecimal while IsHexNumberChar[p^] do
while (i<=SrcLen) and (IsHexNumberChar[Src[i]]) do inc(p);
inc(i);
end;
if (i<=SrcLen)
and (not (Src[i] in ['''','#'])) then
Result:=true;
end; end;
end; end;
'''': '''':
begin begin
if (p+2<=SrcLen) and (Src[p+1]<>'''') inc(p);
and (Src[p+2]='''') then begin if p^='''' then begin
// a single char // could be ''''
if (p+2<SrcLen) if (p[1]<>'''') or (p[2]<>'''') then exit;
and (not (Src[p+3] in ['''','#'])) then inc(p,3);
Result:=true; end else begin
// could be 'a'
if p[1]<>'''' then exit;
inc(p,2);
end; end;
end; end;
'^':
begin
if not (p[1] in ['A'..'Z']) then exit;
inc(p,2);
end;
end; end;
// check that no second character is following
Result:=not (p^ in ['''','#','^']);
end; end;
end; end;
@ -1093,6 +1102,7 @@ begin
end; end;
'''','#': '''','#':
begin begin
// string constant
while true do begin while true do begin
case p^ of case p^ of
#0: #0:
@ -1139,6 +1149,12 @@ begin
end; end;
end; end;
end; end;
'^':
begin
inc(p);
if not (p^ in ['A'..'Z']) then break;
inc(p);
end;
else else
break; break;
end; end;

View File

@ -7377,7 +7377,10 @@ begin
Result.Desc:=xtChar Result.Desc:=xtChar
else else
Result.Desc:=xtConstString; Result.Desc:=xtConstString;
MoveCursorToCleanPos(CurPos.EndPos); if Src[CurPos.StartPos]='^' then
MoveCursorToCleanPos(CurPos.StartPos+2) // e.g. ^M
else
MoveCursorToCleanPos(CurPos.EndPos);
end end
else if AtomIsNumber then begin else if AtomIsNumber then begin
// ordinal or real constant // ordinal or real constant