diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index d38d412577..3798f422f5 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -2048,7 +2048,7 @@ var VarNameAtom, ProcNameAtom, ParameterIndex) then begin if VarNameAtom.StartPos=0 then ; - DebugLn(['TIdentCompletionTool.FindCodeContext.CheckContextIsParameter not in a parameter list']); + //DebugLn(['TIdentCompletionTool.FindCodeContext.CheckContextIsParameter not in a parameter list']); exit; end; //DebugLn('CheckContextIsParameter Variable=',GetAtom(VarNameAtom),' Proc=',GetAtom(ProcNameAtom),' ParameterIndex=',dbgs(ParameterIndex)); @@ -2115,7 +2115,7 @@ begin if CursorNode<>nil then begin if not CheckContextIsParameter(Result) then begin - DebugLn(['TIdentCompletionTool.FindCodeContext cursor not at parameter']); + //DebugLn(['TIdentCompletionTool.FindCodeContext cursor not at parameter']); exit; end; end; diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index 5ca308f621..52e08c9df6 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -1183,7 +1183,7 @@ var CloseBracket: char; procedure ReadPrefixModifier; begin // read parameter prefix modifier - if (UpAtomIs('VAR')) or (UpAtomIs('CONST')) + if UpAtomIs('VAR') or UpAtomIs('CONST') or (UpAtomIs('OUT') and (Scanner.CompilerMode in [cmOBJFPC,cmDELPHI,cmFPC])) then begin Desc:=ctnVarDefinition; @@ -1288,7 +1288,9 @@ begin // read default value ReadDefaultValue; end; - end else begin + end else if (CurPos.Flag in [cafSemicolon,cafRoundBracketClose, + cafEdgedBracketClose]) + then begin // no type -> variant if (phpCreateNodes in Attr) then begin CreateChildNode; @@ -1296,7 +1298,8 @@ begin CurNode.EndPos:=CurNode.StartPos; EndChildNode; end; - end; + end else + break; if (phpCreateNodes in Attr) then begin CurNode.EndPos:=CurPos.EndPos; EndChildNode; @@ -1340,6 +1343,7 @@ end; function TPascalParserTool.ReadParamType(ExceptionOnError, Extract: boolean; const Attr: TProcHeadAttributes): boolean; +// after reading, CurPos is the atom after the type var copying: boolean; IsArrayType: Boolean; @@ -1368,13 +1372,15 @@ begin if (phpCreateNodes in Attr) then begin CreateChildNode; CurNode.Desc:=ctnOfConstType; + end; + if not Extract then ReadNextAtom else ExtractNextAtom(copying,Attr); + if (phpCreateNodes in Attr) then begin + CurNode.EndPos:=CurPos.EndPos; + EndChildNode; + // close ctnOpenArrayType CurNode.EndPos:=CurPos.EndPos; EndChildNode; end; - if not Extract then - ReadNextAtom - else - ExtractNextAtom(copying,Attr); Result:=true; exit; end; @@ -1399,21 +1405,12 @@ begin CurNode.Desc:=ctnIdentifier; CurNode.EndPos:=CurPos.EndPos; end; - if not Extract then - ReadNextAtom - else - ExtractNextAtom(copying,Attr); + if not Extract then ReadNextAtom else ExtractNextAtom(copying,Attr); if CurPos.Flag=cafPoint then begin // first identifier was unitname -> read '.' + identifier - if not Extract then - ReadNextAtom - else - ExtractNextAtom(copying,Attr); + if not Extract then ReadNextAtom else ExtractNextAtom(copying,Attr); if not AtomIsIdentifier(ExceptionOnError) then exit; - if not Extract then - ReadNextAtom - else - ExtractNextAtom(copying,Attr); + if not Extract then ReadNextAtom else ExtractNextAtom(copying,Attr); end; if (phpCreateNodes in Attr) then EndChildNode;