mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 20:21:04 +02:00
IDE: debugger: tool tip for symbol under cursor
git-svn-id: trunk@21980 -
This commit is contained in:
parent
da3c455007
commit
8442f27d8c
@ -464,7 +464,7 @@ type
|
|||||||
function ReplaceCode(Code: TCodeBuffer; StartX, StartY: integer;
|
function ReplaceCode(Code: TCodeBuffer; StartX, StartY: integer;
|
||||||
EndX, EndY: integer; const NewCode: string): boolean;
|
EndX, EndY: integer; const NewCode: string): boolean;
|
||||||
function ExtractOperand(Code: TCodeBuffer; X,Y: integer;
|
function ExtractOperand(Code: TCodeBuffer; X,Y: integer;
|
||||||
out Operand: string; WithAsOperator: boolean): boolean;
|
out Operand: string; WithPostTokens, WithAsOperator: boolean): boolean;
|
||||||
|
|
||||||
// code completion = auto class completion, auto forward proc completion,
|
// code completion = auto class completion, auto forward proc completion,
|
||||||
// local var assignment completion, event assignment completion
|
// local var assignment completion, event assignment completion
|
||||||
@ -2540,7 +2540,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TCodeToolManager.ExtractOperand(Code: TCodeBuffer; X, Y: integer; out
|
function TCodeToolManager.ExtractOperand(Code: TCodeBuffer; X, Y: integer; out
|
||||||
Operand: string; WithAsOperator: boolean): boolean;
|
Operand: string; WithPostTokens, WithAsOperator: boolean): boolean;
|
||||||
var
|
var
|
||||||
CursorPos: TCodeXYPosition;
|
CursorPos: TCodeXYPosition;
|
||||||
begin
|
begin
|
||||||
@ -2554,7 +2554,8 @@ begin
|
|||||||
CursorPos.Y:=Y;
|
CursorPos.Y:=Y;
|
||||||
CursorPos.Code:=Code;
|
CursorPos.Code:=Code;
|
||||||
try
|
try
|
||||||
Result:=FCurCodeTool.ExtractOperand(CursorPos,Operand,WithAsOperator);
|
Result:=FCurCodeTool.ExtractOperand(CursorPos,Operand,
|
||||||
|
WithPostTokens,WithAsOperator);
|
||||||
except
|
except
|
||||||
on e: Exception do HandleException(e);
|
on e: Exception do HandleException(e);
|
||||||
end;
|
end;
|
||||||
|
@ -256,7 +256,7 @@ type
|
|||||||
function GetStringConstAsFormatString(StartPos, EndPos: integer;
|
function GetStringConstAsFormatString(StartPos, EndPos: integer;
|
||||||
out FormatStringConstant, FormatParameters: string): boolean;
|
out FormatStringConstant, FormatParameters: string): boolean;
|
||||||
function ExtractOperand(const CursorPos: TCodeXYPosition;
|
function ExtractOperand(const CursorPos: TCodeXYPosition;
|
||||||
out Operand: string; WithAsOperator: boolean): boolean;
|
out Operand: string; WithPostTokens, WithAsOperator: boolean): boolean;
|
||||||
|
|
||||||
// resource strings
|
// resource strings
|
||||||
function GatherResourceStringSections(const CursorPos: TCodeXYPosition;
|
function GatherResourceStringSections(const CursorPos: TCodeXYPosition;
|
||||||
@ -3496,7 +3496,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TStandardCodeTool.ExtractOperand(const CursorPos: TCodeXYPosition; out
|
function TStandardCodeTool.ExtractOperand(const CursorPos: TCodeXYPosition; out
|
||||||
Operand: string; WithAsOperator: boolean): boolean;
|
Operand: string; WithPostTokens, WithAsOperator: boolean): boolean;
|
||||||
var
|
var
|
||||||
CleanPos: integer;
|
CleanPos: integer;
|
||||||
StartPos: LongInt;
|
StartPos: LongInt;
|
||||||
@ -3504,11 +3504,18 @@ var
|
|||||||
Node: TCodeTreeNode;
|
Node: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
Operand:='';
|
||||||
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanPos,[]);
|
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanPos,[]);
|
||||||
Node:=FindDeepestNodeAtPos(CleanPos,true);
|
Node:=FindDeepestNodeAtPos(CleanPos,true);
|
||||||
StartPos:=FindStartOfTerm(CleanPos,NodeTermInType(Node));
|
StartPos:=FindStartOfTerm(CleanPos,NodeTermInType(Node));
|
||||||
if StartPos<1 then exit;
|
if StartPos<1 then exit;
|
||||||
EndPos:=FindEndOfTerm(CleanPos,false,WithAsOperator);
|
if WithPostTokens then
|
||||||
|
EndPos:=FindEndOfTerm(CleanPos,false,WithAsOperator)
|
||||||
|
else begin
|
||||||
|
MoveCursorToCleanPos(CleanPos);
|
||||||
|
ReadNextAtom;
|
||||||
|
EndPos:=CurPos.EndPos;
|
||||||
|
end;
|
||||||
if EndPos<1 then exit;
|
if EndPos<1 then exit;
|
||||||
Operand:=ExtractCode(StartPos,EndPos,[phpCommentsToSpace]);
|
Operand:=ExtractCode(StartPos,EndPos,[phpCommentsToSpace]);
|
||||||
Result:=true;
|
Result:=true;
|
||||||
|
@ -13541,6 +13541,7 @@ begin
|
|||||||
Expression := SrcEdit.GetText(True)
|
Expression := SrcEdit.GetText(True)
|
||||||
else
|
else
|
||||||
Expression := SrcEdit.GetOperandFromCaret(CaretPos);
|
Expression := SrcEdit.GetOperandFromCaret(CaretPos);
|
||||||
|
DebugLn(['TMainIDE.OnSrcNotebookShowHintForSource Expression="',Expression,'"']);
|
||||||
if not DebugBoss.Evaluate(Expression, DebugEval) or (DebugEval = '') then
|
if not DebugBoss.Evaluate(Expression, DebugEval) or (DebugEval = '') then
|
||||||
DebugEval := '???';
|
DebugEval := '???';
|
||||||
SmartHintStr := Expression + ' = ' + DebugEval;
|
SmartHintStr := Expression + ' = ' + DebugEval;
|
||||||
|
@ -3286,7 +3286,9 @@ end;
|
|||||||
|
|
||||||
function TSourceEditor.GetOperandFromCaret(const ACaretPos: TPoint): String;
|
function TSourceEditor.GetOperandFromCaret(const ACaretPos: TPoint): String;
|
||||||
begin
|
begin
|
||||||
if not CodeToolBoss.ExtractOperand(CodeBuffer, ACaretPos.X, ACaretPos.Y, Result, False) then
|
if not CodeToolBoss.ExtractOperand(CodeBuffer, ACaretPos.X, ACaretPos.Y,
|
||||||
|
Result, False, False)
|
||||||
|
then
|
||||||
Result := GetWordFromCaret(ACaretPos);
|
Result := GetWordFromCaret(ACaretPos);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user