identifier completion: improved heuristic to recognize LValue

git-svn-id: trunk@9294 -
This commit is contained in:
mattias 2006-05-16 22:16:13 +00:00
parent c8920abb80
commit 47948ab39e
2 changed files with 8 additions and 3 deletions

View File

@ -122,7 +122,8 @@ type
TIdentifierListContextFlag = (
ilcfStartInStatement, // context starts in statements. e.g. between begin..end
ilcfStartIsLValue, // position is start of one statement. e.g. 'A:='
ilcfNeedsEndSemicolon // after context a semicolon is needed. e.g. 'A end'
ilcfNeedsEndSemicolon,// after context a semicolon is needed. e.g. 'A end'
ilcfIsExpression // is expression part of statement. e.g. 'if expr'
);
TIdentifierListContextFlags = set of TIdentifierListContextFlag;
@ -1242,6 +1243,11 @@ begin
CurrentIdentifierList.ContextFlags:=
CurrentIdentifierList.ContextFlags+[ilcfStartIsLValue];
end;
if UpAtomIs('IF') or UpAtomIs('FOR') or UpAtomIs('DO')
or UpAtomIs('CASE') or UpAtomIs('OF') then begin
CurrentIdentifierList.ContextFlags:=
CurrentIdentifierList.ContextFlags+[ilcfIsExpression];
end;
end;
end;
// context behind

View File

@ -383,9 +383,8 @@ begin
// add semicolon for statement ends
if (ilcfNeedsEndSemicolon in IdentList.ContextFlags) then begin
Result:=Result+';';
DebugLn('GetIdentCompletionValue ilcfStartIsLValue in IdentList.ContextFlags=',dbgs(ilcfStartIsLValue in IdentList.ContextFlags));
if (not CursorAtEnd) or IdentItem.HasChilds
or (ilcfStartIsLValue in IdentList.ContextFlags) then
or ([ilcfStartIsLValue,ilcfIsExpression]*IdentList.ContextFlags<>[]) then
inc(CursorToLeft);
end;
end;