From f4e38dd8726b2078645f9677bdbea1089d678e78 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 7 Jun 2010 08:07:25 +0000 Subject: [PATCH] IDE: identifier completion: do not auto add assignment operator for array types git-svn-id: trunk@25960 - --- components/codetools/identcompletiontool.pas | 28 +++++++++++++++++++- ide/sourceeditprocs.pas | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index 025fae4228..f3bbbd05b8 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -88,7 +88,9 @@ type iliIsDestructor, iliIsDestructorValid, iliKeyword, - iliResultTypeValid + iliResultTypeValid, + iliHasIndexValid, + iliHasIndex ); TIdentListItemFlags = set of TIdentListItemFlag; @@ -143,6 +145,7 @@ type function CanBeAssigned: boolean; procedure UpdateBaseContext; function HasChilds: boolean; + function HasIndex: boolean; function IsFunction: boolean; function IsContructor: boolean; function IsDestructor: boolean; @@ -2723,6 +2726,29 @@ begin Result:=iliHasChilds in Flags; end; +function TIdentifierListItem.HasIndex: boolean; +// check if edged bracket can be used [] +var + ANode: TCodeTreeNode; +begin + if not (iliHasIndexValid in Flags) then begin + UpdateBaseContext; + if BaseExprType.Desc in (xtAllStringConvertibles+xtAllWideStringConvertibles) + then begin + // strings, widestrings and PChar + Include(Flags,iliHasIndex); + end else if (BaseExprType.Desc=xtContext) and (BaseExprType.Context.Node<>nil) + then begin + //debugln(['TIdentifierListItem.HasIndex ',BaseExprType.Context.Node.DescAsString]); + ANode:=BaseExprType.Context.Node; + case ANode.Desc of + ctnRangedArrayType,ctnOpenArrayType: Include(Flags,iliHasIndex); + end; + end; + end; + Result:=iliHasIndex in Flags; +end; + function TIdentifierListItem.IsFunction: boolean; var ANode: TCodeTreeNode; diff --git a/ide/sourceeditprocs.pas b/ide/sourceeditprocs.pas index 906ac52204..598b35d01a 100644 --- a/ide/sourceeditprocs.pas +++ b/ide/sourceeditprocs.pas @@ -622,6 +622,7 @@ begin and (ilcfStartOfStatement in IdentList.ContextFlags) and (ilcfEndOfLine in IdentList.ContextFlags) and (not IdentItem.HasChilds) + and (not IdentItem.HasIndex) and (not IdentList.StartUpAtomBehindIs(':=')) and (not IdentList.StartUpAtomBehindIs('(')) and (IdentItem.CanBeAssigned)