codetools: fixed identifier completion in or behind empty string. Issue #26964

git-svn-id: trunk@63798 -
This commit is contained in:
pascal 2020-08-20 11:41:33 +00:00
parent 52b4b42968
commit 4787a58f27
2 changed files with 76 additions and 1 deletions

View File

@ -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);

View File

@ -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.