mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 11:59:20 +02:00
codetools: improved smarthints, show definition, patch #28610, from Ondrej Pokorny
git-svn-id: trunk@49740 -
This commit is contained in:
parent
f3124b5751
commit
f9f232ea0b
@ -861,7 +861,7 @@ type
|
|||||||
function FindSmartHint(const CursorPos: TCodeXYPosition;
|
function FindSmartHint(const CursorPos: TCodeXYPosition;
|
||||||
Flags: TFindSmartFlags = DefaultFindSmartHintFlags): string;
|
Flags: TFindSmartFlags = DefaultFindSmartHintFlags): string;
|
||||||
function GetSmartHint(Node: TCodeTreeNode; XYPos: TCodeXYPosition;
|
function GetSmartHint(Node: TCodeTreeNode; XYPos: TCodeXYPosition;
|
||||||
WithPosition: boolean): string;
|
WithPosition: boolean; WithDefinition: boolean = True): string;
|
||||||
|
|
||||||
function BaseTypeOfNodeHasSubIdents(ANode: TCodeTreeNode): boolean;
|
function BaseTypeOfNodeHasSubIdents(ANode: TCodeTreeNode): boolean;
|
||||||
function FindBaseTypeOfNode(Params: TFindDeclarationParams;
|
function FindBaseTypeOfNode(Params: TFindDeclarationParams;
|
||||||
@ -2653,7 +2653,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TFindDeclarationTool.GetSmartHint(Node: TCodeTreeNode;
|
function TFindDeclarationTool.GetSmartHint(Node: TCodeTreeNode;
|
||||||
XYPos: TCodeXYPosition; WithPosition: boolean): string;
|
XYPos: TCodeXYPosition; WithPosition: boolean; WithDefinition: boolean
|
||||||
|
): string;
|
||||||
|
|
||||||
function ReadIdentifierWithDots: String;
|
function ReadIdentifierWithDots: String;
|
||||||
begin
|
begin
|
||||||
@ -2677,6 +2678,10 @@ var
|
|||||||
Tool: TFindDeclarationTool;
|
Tool: TFindDeclarationTool;
|
||||||
HelperForNode: TCodeTreeNode;
|
HelperForNode: TCodeTreeNode;
|
||||||
SubNode: TCodeTreeNode;
|
SubNode: TCodeTreeNode;
|
||||||
|
CTExprType: TExpressionType;
|
||||||
|
CTXYPos: TCodeXYPosition;
|
||||||
|
CTTopLine: integer;
|
||||||
|
CTCursorPos: TCodeXYPosition;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
|
|
||||||
@ -2734,6 +2739,7 @@ begin
|
|||||||
|
|
||||||
Result:=Result+ExtractDefinitionName(Node);
|
Result:=Result+ExtractDefinitionName(Node);
|
||||||
TypeNode:=FindTypeNodeOfDefinition(Node);
|
TypeNode:=FindTypeNodeOfDefinition(Node);
|
||||||
|
if not WithDefinition then Result := '';
|
||||||
if TypeNode<>nil then begin
|
if TypeNode<>nil then begin
|
||||||
case Node.Desc of
|
case Node.Desc of
|
||||||
ctnTypeDefinition, ctnGenericType:
|
ctnTypeDefinition, ctnGenericType:
|
||||||
@ -2752,6 +2758,14 @@ begin
|
|||||||
ctnPointertype, ctnRangeType, ctnFileType, ctnclassOfType:
|
ctnPointertype, ctnRangeType, ctnFileType, ctnclassOfType:
|
||||||
begin
|
begin
|
||||||
Result += ExtractNode(TypeNode, [phpCommentsToSpace]);
|
Result += ExtractNode(TypeNode, [phpCommentsToSpace]);
|
||||||
|
|
||||||
|
if
|
||||||
|
CleanPosToCaret(TypeNode.StartPos,CTCursorPos) and
|
||||||
|
FindDeclaration(CTCursorPos,
|
||||||
|
DefaultFindSmartHintFlags+[fsfSearchSourceName],CTExprType,CTXYPos,CTTopLine) and
|
||||||
|
not((CTExprType.Desc=xtContext) and (CTExprType.Context.Node=nil) and (CTExprType.Context.Tool=nil))
|
||||||
|
then
|
||||||
|
Result += CTExprType.Context.Tool.GetSmartHint(CTExprType.Context.Node, CTXYPos, False, False);
|
||||||
end;
|
end;
|
||||||
ctnClass, ctnClassInterface, ctnDispinterface,
|
ctnClass, ctnClassInterface, ctnDispinterface,
|
||||||
ctnClassHelper, ctnTypeHelper, ctnRecordHelper,
|
ctnClassHelper, ctnTypeHelper, ctnRecordHelper,
|
||||||
@ -2803,7 +2817,16 @@ begin
|
|||||||
Result+=copy(NodeStr,1,50);
|
Result+=copy(NodeStr,1,50);
|
||||||
end;
|
end;
|
||||||
ctnEnumerationType:
|
ctnEnumerationType:
|
||||||
Result += 'enum';
|
begin
|
||||||
|
if Assigned(Node.FirstChild) then
|
||||||
|
begin
|
||||||
|
NodeStr:=ExtractCode(Node.FirstChild.StartPos,Node.FirstChild.EndPos,[phpCommentsToSpace]);
|
||||||
|
if Length(NodeStr) > 50 then
|
||||||
|
NodeStr:=Copy(NodeStr, 1, 50) + ' ...';
|
||||||
|
Result += NodeStr;
|
||||||
|
end else
|
||||||
|
Result += 'enum';
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
case Node.Desc of
|
case Node.Desc of
|
||||||
|
Loading…
Reference in New Issue
Block a user