From 7d34128f786288cb38870606eb56517e02b935a2 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 24 Jun 2013 12:06:05 +0000 Subject: [PATCH] codetools: fixed class completion for properties with constant index git-svn-id: trunk@41864 - --- components/codetools/codecompletiontool.pas | 24 +++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index e39bab84a1..48374bea3b 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -6312,7 +6312,7 @@ type var Parts: array[TPropPart] of TAtomPosition; - PartIsAtom: array[TPropPart] of boolean; + PartIsAtom: array[TPropPart] of boolean; // is single identifier procedure ReadSimpleSpec(SpecWord, SpecParam: TPropPart); // allowed after simple specifier like 'read': @@ -6428,6 +6428,8 @@ var end; procedure ReadIndexSpecifier; + var + Last: TAtomPosition; begin if UpAtomIs('INDEX') then begin if Parts[ppIndexWord].StartPos>=1 then @@ -6439,7 +6441,8 @@ var RaiseExceptionFmt(ctsIndexParameterExpectedButAtomFound,[GetAtom]); Parts[ppIndex].StartPos:=CurPos.StartPos; ReadConstant(true,false,[]); - Parts[ppIndex].EndPos:=LastAtoms.GetValueAt(0).EndPos; + Last:=LastAtoms.GetValueAt(0); + Parts[ppIndex].EndPos:=Last.EndPos; PartIsAtom[ppIndex]:=false; end; end; @@ -6508,6 +6511,21 @@ var RaiseExceptionFmt(ctsStrExpectedButAtomFound,[';',GetAtom]); end; end; + + procedure ResolveIndexType; + var + ExprType: TExpressionType; + Params: TFindDeclarationParams; + begin + Params:=TFindDeclarationParams.Create; + try + Params.Flags:=fdfDefaultForExpressions; + Params.ContextNode:=PropNode; + IndexType:=FindTermTypeAsString(Parts[ppIndex],Params,ExprType); + finally + Params.Free; + end; + end; procedure CompleteReadSpecifier; var @@ -6923,6 +6941,8 @@ begin // complete property BeautifyCodeOpts:=ASourceChangeCache.BeautifyCodeOptions; if CodeCompleteClassNode.Desc <> ctnDispinterface then begin + if Parts[ppIndex].StartPos>0 then + ResolveIndexType; CompleteReadSpecifier; CompleteWriteSpecifier; CompleteStoredSpecifier;