mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-15 11:39:27 +02:00
codetools: fixed identifier completion in or behind empty string. Issue #26964
git-svn-id: trunk@63798 -
This commit is contained in:
parent
52b4b42968
commit
4787a58f27
@ -8796,7 +8796,7 @@ begin
|
||||
Result:=EndPos;
|
||||
end else begin
|
||||
// the next atom is the start of the variable
|
||||
if (not (NextAtomType in [vatSpace,vatIdentifier,vatPreDefIdentifier,
|
||||
if (not (NextAtomType in [vatSpace,vatIdentifier,vatPreDefIdentifier,vatStringConstant,
|
||||
vatRoundBracketClose,vatEdgedBracketClose,vatAddrOp])) then
|
||||
begin
|
||||
MoveCursorToCleanPos(NextAtom.StartPos);
|
||||
|
@ -47,6 +47,9 @@ type
|
||||
procedure Test_FindCodeContext_ProcParams_NoClosingBracket;
|
||||
procedure Test_FindCodeContext_ProcTypeParams;
|
||||
procedure Test_FindCodeContext_AttributeParams;
|
||||
procedure Test_GatherIdentifiers_ProcParams_String1;
|
||||
procedure Test_GatherIdentifiers_ProcParams_String2;
|
||||
procedure Test_GatherIdentifiers_ProcParams_String3;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -239,6 +242,78 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestIdentCompletion.Test_GatherIdentifiers_ProcParams_String1;
|
||||
var
|
||||
SrcMark: TFDMarker;
|
||||
CursorPos: TCodeXYPosition;
|
||||
CodeContexts: TCodeContextInfo;
|
||||
begin
|
||||
StartProgram;
|
||||
Add([
|
||||
'begin',
|
||||
' writeln({#c}'''');',
|
||||
'end.']);
|
||||
ParseSimpleMarkers(Code);
|
||||
SrcMark:=FindMarker('c','#');
|
||||
AssertNotNull('missing src marker #c',SrcMark);
|
||||
MainTool.CleanPosToCaret(SrcMark.CleanPos,CursorPos);
|
||||
CodeContexts:=nil;
|
||||
try
|
||||
CodeToolBoss.GatherIdentifiers(Code,CursorPos.X,CursorPos.Y);
|
||||
AssertTrue('CodeToolBoss.GatherIdentifiers: '+CodeToolBoss.ErrorMessage,CodeToolBoss.ErrorId=0);
|
||||
finally
|
||||
CodeContexts.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestIdentCompletion.Test_GatherIdentifiers_ProcParams_String2;
|
||||
var
|
||||
SrcMark: TFDMarker;
|
||||
CursorPos: TCodeXYPosition;
|
||||
CodeContexts: TCodeContextInfo;
|
||||
begin
|
||||
StartProgram;
|
||||
Add([
|
||||
'begin',
|
||||
' writeln({#c}'''');',
|
||||
'end.']);
|
||||
ParseSimpleMarkers(Code);
|
||||
SrcMark:=FindMarker('c','#');
|
||||
AssertNotNull('missing src marker #c',SrcMark);
|
||||
MainTool.CleanPosToCaret(SrcMark.CleanPos+1,CursorPos);
|
||||
CodeContexts:=nil;
|
||||
try
|
||||
CodeToolBoss.GatherIdentifiers(Code,CursorPos.X,CursorPos.Y);
|
||||
AssertTrue('CodeToolBoss.GatherIdentifiers: '+CodeToolBoss.ErrorMessage,CodeToolBoss.ErrorId=0);
|
||||
finally
|
||||
CodeContexts.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestIdentCompletion.Test_GatherIdentifiers_ProcParams_String3;
|
||||
var
|
||||
SrcMark: TFDMarker;
|
||||
CursorPos: TCodeXYPosition;
|
||||
CodeContexts: TCodeContextInfo;
|
||||
begin
|
||||
StartProgram;
|
||||
Add([
|
||||
'begin',
|
||||
' writeln(''''{#c});',
|
||||
'end.']);
|
||||
ParseSimpleMarkers(Code);
|
||||
SrcMark:=FindMarker('c','#');
|
||||
AssertNotNull('missing src marker #c',SrcMark);
|
||||
MainTool.CleanPosToCaret(SrcMark.CleanPos,CursorPos);
|
||||
CodeContexts:=nil;
|
||||
try
|
||||
CodeToolBoss.GatherIdentifiers(Code,CursorPos.X,CursorPos.Y);
|
||||
AssertTrue('CodeToolBoss.GatherIdentifiers: '+CodeToolBoss.ErrorMessage,CodeToolBoss.ErrorId=0);
|
||||
finally
|
||||
CodeContexts.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterTests([TTestIdentCompletion]);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user