From 47948ab39ec4b3d62dd6a5675c7dd071a13506f4 Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 16 May 2006 22:16:13 +0000 Subject: [PATCH] identifier completion: improved heuristic to recognize LValue git-svn-id: trunk@9294 - --- components/codetools/identcompletiontool.pas | 8 +++++++- ide/sourceeditprocs.pas | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index 00948128a6..2380073fa0 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -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 diff --git a/ide/sourceeditprocs.pas b/ide/sourceeditprocs.pas index 838b05eb52..0516de674a 100644 --- a/ide/sourceeditprocs.pas +++ b/ide/sourceeditprocs.pas @@ -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;