mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-01-04 18:30:32 +01:00
codetools: fixed ExtractFuncResultType for complex types and class operator
This commit is contained in:
parent
6f72566182
commit
dfb7c2bd04
@ -70,14 +70,14 @@ interface
|
||||
{$I codetools.inc}
|
||||
|
||||
{off $DEFINE CTDEBUG}
|
||||
{$DEFINE VerboseCompletionAdds}
|
||||
{off $DEFINE VerboseCompletionAdds}
|
||||
{off $DEFINE VerboseUpdateProcBodySignatures}
|
||||
{off $DEFINE VerboseCompleteMethod}
|
||||
{off $DEFINE VerboseCreateMissingClassProcBodies}
|
||||
{off $DEFINE VerboseCompleteLocalVarAssign}
|
||||
{off $DEFINE VerboseCompleteEventAssign}
|
||||
{off $DEFINE EnableCodeCompleteTemplates}
|
||||
{$DEFINE VerboseGetPossibleInitsForVariable}
|
||||
{off $DEFINE VerboseGetPossibleInitsForVariable}
|
||||
{off $DEFINE VerboseGuessTypeOfIdentifier}
|
||||
|
||||
uses
|
||||
@ -9417,7 +9417,7 @@ begin
|
||||
RaiseException(20170421201833,'oops, I lost your class');
|
||||
ProcNode:=FindProcNode(CursorNode,FJumpToProcHead,[phpInUpperCase,phpIgnoreForwards]);
|
||||
if ProcNode=nil then begin
|
||||
debugln(['TCodeCompletionCodeTool.ApplyChangesAndJumpToFirstNewProc Proc="',FJumpToProcHead.Name,'"']);
|
||||
debugln(['TCodeCompletionCodeTool.ApplyChangesAndJumpToFirstNewProc Proc="',FJumpToProcHead.Name,'":"',FJumpToProcHead.ResultType,'" ',dbgs(FJumpToProcHead.Group)]);
|
||||
RaiseException(20170421201835,ctsNewProcBodyNotFound);
|
||||
end;
|
||||
Result:=FindJumpPointInProcNode(ProcNode,NewPos,NewTopLine, BlockTopLine, BlockBottomLine);
|
||||
|
||||
@ -839,6 +839,7 @@ begin
|
||||
Txt:=CurProcName;
|
||||
Flags:=Ord(ExtractProcedureGroup(ANode));
|
||||
if TPascalMethodGroup(Flags)=mgClassOperator then
|
||||
// for class operator the result type is part of the signature
|
||||
ExtTxt4:=ExtractFuncResultType(ANode,Attr);
|
||||
end;
|
||||
Result.Add(NewNodeExt);
|
||||
|
||||
@ -1346,6 +1346,7 @@ function TPascalParserTool.KeyWordFuncClassMethod: boolean;
|
||||
class operator Inc(Rec: TRec1): TRec1;
|
||||
class operator Initialize(var Rec: TRec1);
|
||||
class operator Finalize(var Rec: TRec1);
|
||||
class operator +(a,b:T):W; inline;
|
||||
|
||||
proc specifiers without parameters:
|
||||
stdcall, virtual, abstract, dynamic, overload, override, cdecl, inline,
|
||||
@ -1407,7 +1408,7 @@ begin
|
||||
ReadNextAtom;
|
||||
if IsGeneric or (Scanner.CompilerMode in [cmDELPHI,cmDELPHIUNICODE]) then
|
||||
ReadGenericParamList(IsGeneric,true);
|
||||
if (CurPos.Flag<>cafPoint) then begin
|
||||
if (CurPos.Flag<>cafPoint) or (pphIsOperator in ParseAttr) then begin
|
||||
// read rest
|
||||
ReadTilProcedureHeadEnd(ParseAttr,HasForwardModifier);
|
||||
end else begin
|
||||
@ -1777,7 +1778,7 @@ function TPascalParserTool.ReadTilProcedureHeadEnd(
|
||||
procedure Intf.Method = ImplementingMethodName;
|
||||
function CommitUrlCacheEntry; // only Delphi
|
||||
procedure MacProcName(c: char; ...); external;
|
||||
operator + (dp1: TPoint; dp2: TPoint) dps: TPoint;
|
||||
operator + (dp1: TPoint; dp2: TPoint) dps: TPoint; inline;
|
||||
Add('Inc(Rec: TRec1): TRec1;
|
||||
generic function RandomFrom<T>(const AValues:array of T):T;
|
||||
|
||||
|
||||
@ -312,6 +312,8 @@ type
|
||||
procedure CalcMemSize(Stats: TCTMemStats); override;
|
||||
end;
|
||||
|
||||
function dbgs(Group: TPascalMethodGroup): string; overload;
|
||||
|
||||
function CompareMethodHeaders(
|
||||
const Method1Name: string; Method1Group: TPascalMethodGroup; const Method1ResultType: string;
|
||||
const Method2Name: string; Method2Group: TPascalMethodGroup; const Method2ResultType: string): Integer; overload;
|
||||
@ -324,6 +326,11 @@ function CompareCodeTreeNodeExtMethodHeaders(NodeData1, NodeData2: pointer): int
|
||||
|
||||
implementation
|
||||
|
||||
function dbgs(Group: TPascalMethodGroup): string;
|
||||
begin
|
||||
str(Group,Result);
|
||||
end;
|
||||
|
||||
function CompareMethodHeaders(const Method1Name: string;
|
||||
Method1Group: TPascalMethodGroup; const Method1ResultType: string;
|
||||
const Method2Name: string; Method2Group: TPascalMethodGroup;
|
||||
@ -2880,25 +2887,20 @@ end;
|
||||
|
||||
function TPascalReaderTool.ExtractFuncResultType(ProcNode: TCodeTreeNode;
|
||||
Attr: TProcHeadAttributes): string;
|
||||
var
|
||||
aNode: TCodeTreeNode;
|
||||
begin
|
||||
Result := '';
|
||||
if (ProcNode=nil) then exit;
|
||||
if ProcNode.Desc=ctnProcedure then
|
||||
ProcNode:=ProcNode.FirstChild;
|
||||
if (ProcNode=nil) or(ProcNode.Desc<>ctnProcedureHead) then
|
||||
if (ProcNode=nil) or (ProcNode.Desc<>ctnProcedureHead) then
|
||||
Exit;
|
||||
MoveCursorToCleanPos(ProcNode.EndPos);
|
||||
CurNode:=ProcNode;
|
||||
ReadPriorAtom;
|
||||
if CurPos.Flag<>cafSemicolon then
|
||||
Exit;
|
||||
ReadPriorAtom;
|
||||
if CurPos.Flag<>cafWord then
|
||||
Exit;
|
||||
if phpInUpperCase in Attr then
|
||||
Result := GetUpAtom
|
||||
else
|
||||
Result := GetAtom;
|
||||
aNode:=ProcNode.LastChild;
|
||||
if aNode=nil then exit;
|
||||
if aNode.Desc in [ctnIdentifier,ctnSpecialize] then begin
|
||||
Result:=ExtractNode(aNode,Attr);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.ExtractDefinitionName(DefinitionNode: TCodeTreeNode
|
||||
|
||||
Loading…
Reference in New Issue
Block a user