codetools: fixed complete event assignment

This commit is contained in:
mattias 2023-03-12 23:11:26 +01:00
parent d0a8be0821
commit c8ff4ec3ee

View File

@ -2044,15 +2044,9 @@ function TCodeCompletionCodeTool.CompleteEventAssignment(CleanCursorPos,
// check for semicolon at end of statement // check for semicolon at end of statement
MoveCursorToCleanPos(UserEventAtom.EndPos); MoveCursorToCleanPos(UserEventAtom.EndPos);
ReadNextAtom; ReadNextAtom;
if CurPos.Flag = cafRoundBracketOpen then if CurPos.Flag = cafRoundBracketOpen then begin
if Scanner.CompilerMode <> cmDELPHI then exit; // e.g. x:=sin(y); -> don't create an event
Exit // indeed it is assignment to function, e.g. x:=sin(y); end;
else begin
ReadNextAtom;
if CurPos.Flag <> cafRoundBracketClose then
Exit; // in Delhi mode empty brackets are allowed after method: OnClick:=FormCreate();
ReadNextAtom;
end;
if AtomIsChar(';') then if AtomIsChar(';') then
SemicolonPos:=CurPos.StartPos SemicolonPos:=CurPos.StartPos
else else
@ -2162,8 +2156,8 @@ function TCodeCompletionCodeTool.CompleteEventAssignment(CleanCursorPos,
end; end;
RValue:=AnEventName+';'; RValue:=AnEventName+';';
if (AddrOperatorPos>0) if (AddrOperatorPos<1)
or (Scanner.CompilerMode in [cmDelphi,cmDELPHIUNICODE]) and not (Scanner.CompilerMode in [cmDelphi,cmDELPHIUNICODE])
then then
RValue:='@'+RValue; RValue:='@'+RValue;
if (AddrOperatorPos>0) or (UserEventAtom.StartPos>0) then begin if (AddrOperatorPos>0) or (UserEventAtom.StartPos>0) then begin