mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-01 18:16:00 +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:
|
||||
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.
|
||||
}
|
||||
program ListInterfaceClasses;
|
||||
|
@ -2209,23 +2209,20 @@ begin
|
||||
if Node.Parent<>nil then begin
|
||||
ANode:=Node.Parent;
|
||||
while ANode<>nil do begin
|
||||
if ANode.Desc in AllClassSections then begin
|
||||
case ANode.Desc of
|
||||
ctnClassPrivate:
|
||||
Result+='private ';
|
||||
ctnClassProtected:
|
||||
Result+='protected ';
|
||||
ctnClassPublic:
|
||||
Result+='public ';
|
||||
ctnClassPublished:
|
||||
Result+='published ';
|
||||
ctnClassClassVar:
|
||||
Result+='class ';
|
||||
else
|
||||
break;
|
||||
end;
|
||||
end else if ANode.Desc in ([ctnParameterList]+AllClasses) then
|
||||
case ANode.Desc of
|
||||
ctnClassPrivate:
|
||||
Result+='private ';
|
||||
ctnClassProtected:
|
||||
Result+='protected ';
|
||||
ctnClassPublic:
|
||||
Result+='public ';
|
||||
ctnClassPublished:
|
||||
Result+='published ';
|
||||
ctnClassClassVar:
|
||||
Result+='class ';
|
||||
else
|
||||
break;
|
||||
end;
|
||||
ANode:=ANode.Parent;
|
||||
end;
|
||||
end;
|
||||
@ -2250,7 +2247,7 @@ begin
|
||||
end;
|
||||
|
||||
// add class name
|
||||
ClassStr := ExtractClassName(Node.Parent, False, true);
|
||||
ClassStr := ExtractClassPath(Node.Parent);
|
||||
if ClassStr <> '' then Result += ClassStr + '.';
|
||||
|
||||
Result:=Result+ExtractDefinitionName(Node);
|
||||
@ -2296,7 +2293,7 @@ begin
|
||||
case Node.Desc of
|
||||
ctnConstDefinition:
|
||||
begin
|
||||
DebugLn('TFindDeclarationTool.FindSmartHint const without subnode "',ExtractNode(Node,[]),'"');
|
||||
DebugLn('TFindDeclarationTool.GetSmartHint const without subnode "',ExtractNode(Node,[]),'"');
|
||||
NodeStr:=ExtractCode(Node.StartPos
|
||||
+GetIdentLen(@Src[Node.StartPos]),
|
||||
Node.EndPos,[phpCommentsToSpace]);
|
||||
@ -2396,7 +2393,7 @@ begin
|
||||
end
|
||||
|
||||
else
|
||||
DebugLn('ToDo: TFindDeclarationTool.FindSmartHint ',Node.DescAsString);
|
||||
DebugLn('ToDo: TFindDeclarationTool.GetSmartHint ',Node.DescAsString);
|
||||
end;
|
||||
end;
|
||||
if WithPosition then begin
|
||||
|
@ -141,8 +141,9 @@ type
|
||||
function NodeIsResultType(Node: TCodeTreeNode): boolean;
|
||||
|
||||
// classes
|
||||
function ExtractClassName(ClassNode: TCodeTreeNode;
|
||||
function ExtractClassName(Node: TCodeTreeNode;
|
||||
InUpperCase: boolean; WithParents: boolean = true): string;
|
||||
function ExtractClassPath(Node: TCodeTreeNode): string;
|
||||
function ExtractClassInheritance(ClassNode: TCodeTreeNode;
|
||||
Attr: TProcHeadAttributes): string;
|
||||
function FindClassNode(StartNode: TCodeTreeNode;
|
||||
@ -586,30 +587,74 @@ begin
|
||||
Result:=Result+';';
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.ExtractClassName(ClassNode: TCodeTreeNode;
|
||||
function TPascalReaderTool.ExtractClassName(Node: TCodeTreeNode;
|
||||
InUpperCase: boolean; WithParents: boolean): string;
|
||||
var
|
||||
InArray: Boolean;
|
||||
begin
|
||||
Result:='';
|
||||
while ClassNode<>nil do begin
|
||||
if ClassNode.Desc in [ctnTypeDefinition,ctnGenericType] then begin
|
||||
if Result<>'' then Result:='.'+Result;
|
||||
if ClassNode.Desc=ctnTypeDefinition then
|
||||
Result:=GetIdentifier(@Src[ClassNode.StartPos])+Result
|
||||
else if ClassNode.FirstChild<>nil then
|
||||
while Node<>nil do begin
|
||||
case Node.Desc of
|
||||
ctnTypeDefinition,ctnGenericType:
|
||||
begin
|
||||
if (Scanner.CompilerMode = cmDELPHI) and (ClassNode.Desc = ctnGenericType) then
|
||||
Result := Result + ExtractNode(ClassNode.FirstChild.NextBrother, []);
|
||||
Result:=GetIdentifier(@Src[ClassNode.FirstChild.StartPos])+Result;
|
||||
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;
|
||||
if not WithParents then break;
|
||||
end;
|
||||
if not WithParents then break;
|
||||
ctnParameterList:
|
||||
break;
|
||||
end;
|
||||
ClassNode:=ClassNode.Parent;
|
||||
Node:=Node.Parent;
|
||||
end;
|
||||
|
||||
if InUpperCase then
|
||||
Result:=UpperCaseStr(Result);
|
||||
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(
|
||||
ClassNode: TCodeTreeNode; Attr: TProcHeadAttributes): string;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user