mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-19 19:29:31 +01:00
extended class completion for generic classes
git-svn-id: trunk@8369 -
This commit is contained in:
parent
10bbedf011
commit
9ff3525add
@ -225,7 +225,8 @@ begin
|
|||||||
FCompletingStartNode:=FCodeCompleteClassNode.FirstChild;
|
FCompletingStartNode:=FCodeCompleteClassNode.FirstChild;
|
||||||
while (FCompletingStartNode<>nil) and (FCompletingStartNode.FirstChild=nil) do
|
while (FCompletingStartNode<>nil) and (FCompletingStartNode.FirstChild=nil) do
|
||||||
FCompletingStartNode:=FCompletingStartNode.NextBrother;
|
FCompletingStartNode:=FCompletingStartNode.NextBrother;
|
||||||
if FCompletingStartNode<>nil then FCompletingStartNode:=FCompletingStartNode.FirstChild;
|
if FCompletingStartNode<>nil then
|
||||||
|
FCompletingStartNode:=FCompletingStartNode.FirstChild;
|
||||||
JumpToProcName:='';
|
JumpToProcName:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1747,8 +1748,11 @@ begin
|
|||||||
// find the start of the class (the position in front of the class name)
|
// find the start of the class (the position in front of the class name)
|
||||||
ClassNode:=CodeCompleteClassNode;
|
ClassNode:=CodeCompleteClassNode;
|
||||||
if ClassNode=nil then exit;
|
if ClassNode=nil then exit;
|
||||||
ClassIdentifierNode:=ClassNode.Parent;
|
ClassIdentifierNode:=ClassNode.GetNodeOfType(ctnTypeDefinition);
|
||||||
if ClassIdentifierNode=nil then exit;
|
if ClassIdentifierNode=nil then begin
|
||||||
|
DebugLn('TCodeCompletionCodeTool.InsertClassHeaderComment WARNING: class without name');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
if not CleanPosToCaret(ClassIdentifierNode.StartPos,StartPos) then exit;
|
if not CleanPosToCaret(ClassIdentifierNode.StartPos,StartPos) then exit;
|
||||||
Code:=ExtractIdentifier(ClassIdentifierNode.StartPos);
|
Code:=ExtractIdentifier(ClassIdentifierNode.StartPos);
|
||||||
|
|
||||||
@ -1909,10 +1913,7 @@ var
|
|||||||
|
|
||||||
procedure GatherExistingClassProcBodies;
|
procedure GatherExistingClassProcBodies;
|
||||||
begin
|
begin
|
||||||
TypeSectionNode:=FCodeCompleteClassNode.Parent;
|
TypeSectionNode:=FCodeCompleteClassNode.GetNodeOfType(ctnTypeSection);
|
||||||
if (TypeSectionNode<>nil) and (TypeSectionNode.Parent<>nil)
|
|
||||||
and (TypeSectionNode.Parent.Desc=ctnTypeSection) then
|
|
||||||
TypeSectionNode:=TypeSectionNode.Parent;
|
|
||||||
ClassProcs:=nil;
|
ClassProcs:=nil;
|
||||||
ProcBodyNodes:=GatherProcNodes(TypeSectionNode,
|
ProcBodyNodes:=GatherProcNodes(TypeSectionNode,
|
||||||
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
|
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
|
||||||
@ -2002,7 +2003,7 @@ var
|
|||||||
end else begin
|
end else begin
|
||||||
// class is not in interface section
|
// class is not in interface section
|
||||||
// -> insert at the end of the type section
|
// -> insert at the end of the type section
|
||||||
ANode:=FCodeCompleteClassNode.Parent; // type definition
|
ANode:=FCodeCompleteClassNode.GetNodeOfType(ctnTypeDefinition);
|
||||||
if ANode=nil then
|
if ANode=nil then
|
||||||
RaiseException(ctsClassNodeWithoutParentNode);
|
RaiseException(ctsClassNodeWithoutParentNode);
|
||||||
if ANode.Parent.Desc=ctnTypeSection then
|
if ANode.Parent.Desc=ctnTypeSection then
|
||||||
@ -2056,7 +2057,7 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
TheClassName:=ExtractClassName(FCodeCompleteClassNode,false);
|
TheClassName:=ExtractClassName(FCodeCompleteClassNode,false);
|
||||||
|
|
||||||
// gather existing class proc definitions
|
// gather existing proc definitions in the class
|
||||||
ClassProcs:=GatherProcNodes(FCompletingStartNode,
|
ClassProcs:=GatherProcNodes(FCompletingStartNode,
|
||||||
[phpInUpperCase,phpAddClassName],
|
[phpInUpperCase,phpAddClassName],
|
||||||
ExtractClassName(FCodeCompleteClassNode,true));
|
ExtractClassName(FCodeCompleteClassNode,true));
|
||||||
@ -2326,7 +2327,7 @@ var CleanCursorPos, Indent, insertPos: integer;
|
|||||||
FindClassNode(CursorNode,CurClassName,true,false);
|
FindClassNode(CursorNode,CurClassName,true,false);
|
||||||
if FCodeCompleteClassNode=nil then
|
if FCodeCompleteClassNode=nil then
|
||||||
RaiseException('oops, I lost your class');
|
RaiseException('oops, I lost your class');
|
||||||
ANode:=FCodeCompleteClassNode.Parent;
|
ANode:=FCodeCompleteClassNode.GetNodeOfType(ctnTypeDefinition);
|
||||||
if ANode=nil then
|
if ANode=nil then
|
||||||
RaiseException(ctsClassNodeWithoutParentNode);
|
RaiseException(ctsClassNodeWithoutParentNode);
|
||||||
if (ANode.Parent<>nil) and (ANode.Parent.Desc=ctnTypeSection) then
|
if (ANode.Parent<>nil) and (ANode.Parent.Desc=ctnTypeSection) then
|
||||||
@ -2788,9 +2789,7 @@ begin
|
|||||||
if ImplementationNode=nil then ImplementationNode:=Tree.Root;
|
if ImplementationNode=nil then ImplementationNode:=Tree.Root;
|
||||||
|
|
||||||
// test if in a class
|
// test if in a class
|
||||||
AClassNode:=CursorNode;
|
AClassNode:=CursorNode.GetNodeOfType(ctnClass);
|
||||||
while (AClassNode<>nil) and (AClassNode.Desc<>ctnClass) do
|
|
||||||
AClassNode:=AClassNode.Parent;
|
|
||||||
if AClassNode<>nil then begin
|
if AClassNode<>nil then begin
|
||||||
CompleteClass;
|
CompleteClass;
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ program TGeneric2;
|
|||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
type
|
type
|
||||||
TList = generic(T) class(TObject)
|
TList =generic(T) class(TObject)
|
||||||
data : T;
|
data : T;
|
||||||
procedure Add(item: T);
|
procedure Add(item: T);
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -465,6 +465,8 @@ begin
|
|||||||
if ClassNode<>nil then begin
|
if ClassNode<>nil then begin
|
||||||
if ClassNode.Desc=ctnClass then begin
|
if ClassNode.Desc=ctnClass then begin
|
||||||
ClassNode:=ClassNode.Parent;
|
ClassNode:=ClassNode.Parent;
|
||||||
|
if (ClassNode<>nil) and (ClassNode.Desc=ctnGenericType) then
|
||||||
|
ClassNode:=ClassNode.Parent;
|
||||||
if ClassNode=nil then begin
|
if ClassNode=nil then begin
|
||||||
Result:='';
|
Result:='';
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user