mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 14:16:12 +02:00
codetools: GetSmartHint: show anonymous arrays
git-svn-id: trunk@37104 -
This commit is contained in:
parent
5f3801e1ee
commit
d18e8e49d3
@ -20,7 +20,7 @@
|
|||||||
***************************************************************************
|
***************************************************************************
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
Example, how to setup the codetools, load a pascal unit and list of classes
|
Example, how to setup the codetools, load a pascal unit and list all classes
|
||||||
defined in the interface.
|
defined in the interface.
|
||||||
}
|
}
|
||||||
program ListInterfaceClasses;
|
program ListInterfaceClasses;
|
||||||
|
@ -2209,7 +2209,6 @@ begin
|
|||||||
if Node.Parent<>nil then begin
|
if Node.Parent<>nil then begin
|
||||||
ANode:=Node.Parent;
|
ANode:=Node.Parent;
|
||||||
while ANode<>nil do begin
|
while ANode<>nil do begin
|
||||||
if ANode.Desc in AllClassSections then begin
|
|
||||||
case ANode.Desc of
|
case ANode.Desc of
|
||||||
ctnClassPrivate:
|
ctnClassPrivate:
|
||||||
Result+='private ';
|
Result+='private ';
|
||||||
@ -2224,8 +2223,6 @@ begin
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end else if ANode.Desc in ([ctnParameterList]+AllClasses) then
|
|
||||||
break;
|
|
||||||
ANode:=ANode.Parent;
|
ANode:=ANode.Parent;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2250,7 +2247,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// add class name
|
// add class name
|
||||||
ClassStr := ExtractClassName(Node.Parent, False, true);
|
ClassStr := ExtractClassPath(Node.Parent);
|
||||||
if ClassStr <> '' then Result += ClassStr + '.';
|
if ClassStr <> '' then Result += ClassStr + '.';
|
||||||
|
|
||||||
Result:=Result+ExtractDefinitionName(Node);
|
Result:=Result+ExtractDefinitionName(Node);
|
||||||
@ -2296,7 +2293,7 @@ begin
|
|||||||
case Node.Desc of
|
case Node.Desc of
|
||||||
ctnConstDefinition:
|
ctnConstDefinition:
|
||||||
begin
|
begin
|
||||||
DebugLn('TFindDeclarationTool.FindSmartHint const without subnode "',ExtractNode(Node,[]),'"');
|
DebugLn('TFindDeclarationTool.GetSmartHint const without subnode "',ExtractNode(Node,[]),'"');
|
||||||
NodeStr:=ExtractCode(Node.StartPos
|
NodeStr:=ExtractCode(Node.StartPos
|
||||||
+GetIdentLen(@Src[Node.StartPos]),
|
+GetIdentLen(@Src[Node.StartPos]),
|
||||||
Node.EndPos,[phpCommentsToSpace]);
|
Node.EndPos,[phpCommentsToSpace]);
|
||||||
@ -2396,7 +2393,7 @@ begin
|
|||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
DebugLn('ToDo: TFindDeclarationTool.FindSmartHint ',Node.DescAsString);
|
DebugLn('ToDo: TFindDeclarationTool.GetSmartHint ',Node.DescAsString);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if WithPosition then begin
|
if WithPosition then begin
|
||||||
|
@ -141,8 +141,9 @@ type
|
|||||||
function NodeIsResultType(Node: TCodeTreeNode): boolean;
|
function NodeIsResultType(Node: TCodeTreeNode): boolean;
|
||||||
|
|
||||||
// classes
|
// classes
|
||||||
function ExtractClassName(ClassNode: TCodeTreeNode;
|
function ExtractClassName(Node: TCodeTreeNode;
|
||||||
InUpperCase: boolean; WithParents: boolean = true): string;
|
InUpperCase: boolean; WithParents: boolean = true): string;
|
||||||
|
function ExtractClassPath(Node: TCodeTreeNode): string;
|
||||||
function ExtractClassInheritance(ClassNode: TCodeTreeNode;
|
function ExtractClassInheritance(ClassNode: TCodeTreeNode;
|
||||||
Attr: TProcHeadAttributes): string;
|
Attr: TProcHeadAttributes): string;
|
||||||
function FindClassNode(StartNode: TCodeTreeNode;
|
function FindClassNode(StartNode: TCodeTreeNode;
|
||||||
@ -586,30 +587,74 @@ begin
|
|||||||
Result:=Result+';';
|
Result:=Result+';';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPascalReaderTool.ExtractClassName(ClassNode: TCodeTreeNode;
|
function TPascalReaderTool.ExtractClassName(Node: TCodeTreeNode;
|
||||||
InUpperCase: boolean; WithParents: boolean): string;
|
InUpperCase: boolean; WithParents: boolean): string;
|
||||||
|
var
|
||||||
|
InArray: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
while ClassNode<>nil do begin
|
while Node<>nil do begin
|
||||||
if ClassNode.Desc in [ctnTypeDefinition,ctnGenericType] then begin
|
case Node.Desc of
|
||||||
if Result<>'' then Result:='.'+Result;
|
ctnTypeDefinition,ctnGenericType:
|
||||||
if ClassNode.Desc=ctnTypeDefinition then
|
|
||||||
Result:=GetIdentifier(@Src[ClassNode.StartPos])+Result
|
|
||||||
else if ClassNode.FirstChild<>nil then
|
|
||||||
begin
|
begin
|
||||||
if (Scanner.CompilerMode = cmDELPHI) and (ClassNode.Desc = ctnGenericType) then
|
if Result<>'' then Result:='.'+Result;
|
||||||
Result := Result + ExtractNode(ClassNode.FirstChild.NextBrother, []);
|
if Node.Desc=ctnTypeDefinition then
|
||||||
Result:=GetIdentifier(@Src[ClassNode.FirstChild.StartPos])+Result;
|
Result:=GetIdentifier(@Src[Node.StartPos])+Result
|
||||||
|
else if Node.FirstChild<>nil then
|
||||||
|
begin
|
||||||
|
if (Scanner.CompilerMode = cmDELPHI) and (Node.Desc = ctnGenericType) then
|
||||||
|
Result := Result + ExtractNode(Node.FirstChild.NextBrother, []);
|
||||||
|
Result:=GetIdentifier(@Src[Node.FirstChild.StartPos])+Result;
|
||||||
end;
|
end;
|
||||||
if not WithParents then break;
|
if not WithParents then break;
|
||||||
end;
|
end;
|
||||||
ClassNode:=ClassNode.Parent;
|
ctnParameterList:
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
Node:=Node.Parent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if InUpperCase then
|
if InUpperCase then
|
||||||
Result:=UpperCaseStr(Result);
|
Result:=UpperCaseStr(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPascalReaderTool.ExtractClassPath(Node: TCodeTreeNode): string;
|
||||||
|
var
|
||||||
|
InArray: Boolean;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
InArray:=false;
|
||||||
|
while Node<>nil do begin
|
||||||
|
case Node.Desc of
|
||||||
|
ctnTypeDefinition,ctnGenericType:
|
||||||
|
begin
|
||||||
|
if Result<>'' then Result:='.'+Result;
|
||||||
|
if Node.Desc=ctnTypeDefinition then
|
||||||
|
Result:=GetIdentifier(@Src[Node.StartPos])+Result
|
||||||
|
else if Node.FirstChild<>nil then
|
||||||
|
begin
|
||||||
|
if (Scanner.CompilerMode = cmDELPHI) and (Node.Desc = ctnGenericType) then
|
||||||
|
Result := Result + ExtractNode(Node.FirstChild.NextBrother, []);
|
||||||
|
Result:=GetIdentifier(@Src[Node.FirstChild.StartPos])+Result;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
ctnParameterList:
|
||||||
|
break;
|
||||||
|
ctnRangedArrayType, ctnOpenArrayType:
|
||||||
|
begin
|
||||||
|
InArray := True;
|
||||||
|
Result := '[]' + Result;
|
||||||
|
end;
|
||||||
|
ctnVarDefinition:
|
||||||
|
if InArray then begin
|
||||||
|
Result := GetIdentifier(@Src[Node.StartPos]) + Result;
|
||||||
|
InArray := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Node:=Node.Parent;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TPascalReaderTool.ExtractClassInheritance(
|
function TPascalReaderTool.ExtractClassInheritance(
|
||||||
ClassNode: TCodeTreeNode; Attr: TProcHeadAttributes): string;
|
ClassNode: TCodeTreeNode; Attr: TProcHeadAttributes): string;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user