IDE: debugger: tool tip for symbol under cursor

git-svn-id: trunk@21980 -
This commit is contained in:
mattias 2009-10-02 08:48:32 +00:00
parent da3c455007
commit 8442f27d8c
4 changed files with 18 additions and 7 deletions

View File

@ -464,7 +464,7 @@ type
function ReplaceCode(Code: TCodeBuffer; StartX, StartY: integer;
EndX, EndY: integer; const NewCode: string): boolean;
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,
// local var assignment completion, event assignment completion
@ -2540,7 +2540,7 @@ begin
end;
function TCodeToolManager.ExtractOperand(Code: TCodeBuffer; X, Y: integer; out
Operand: string; WithAsOperator: boolean): boolean;
Operand: string; WithPostTokens, WithAsOperator: boolean): boolean;
var
CursorPos: TCodeXYPosition;
begin
@ -2554,7 +2554,8 @@ begin
CursorPos.Y:=Y;
CursorPos.Code:=Code;
try
Result:=FCurCodeTool.ExtractOperand(CursorPos,Operand,WithAsOperator);
Result:=FCurCodeTool.ExtractOperand(CursorPos,Operand,
WithPostTokens,WithAsOperator);
except
on e: Exception do HandleException(e);
end;

View File

@ -256,7 +256,7 @@ type
function GetStringConstAsFormatString(StartPos, EndPos: integer;
out FormatStringConstant, FormatParameters: string): boolean;
function ExtractOperand(const CursorPos: TCodeXYPosition;
out Operand: string; WithAsOperator: boolean): boolean;
out Operand: string; WithPostTokens, WithAsOperator: boolean): boolean;
// resource strings
function GatherResourceStringSections(const CursorPos: TCodeXYPosition;
@ -3496,7 +3496,7 @@ begin
end;
function TStandardCodeTool.ExtractOperand(const CursorPos: TCodeXYPosition; out
Operand: string; WithAsOperator: boolean): boolean;
Operand: string; WithPostTokens, WithAsOperator: boolean): boolean;
var
CleanPos: integer;
StartPos: LongInt;
@ -3504,11 +3504,18 @@ var
Node: TCodeTreeNode;
begin
Result:=false;
Operand:='';
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanPos,[]);
Node:=FindDeepestNodeAtPos(CleanPos,true);
StartPos:=FindStartOfTerm(CleanPos,NodeTermInType(Node));
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;
Operand:=ExtractCode(StartPos,EndPos,[phpCommentsToSpace]);
Result:=true;

View File

@ -13541,6 +13541,7 @@ begin
Expression := SrcEdit.GetText(True)
else
Expression := SrcEdit.GetOperandFromCaret(CaretPos);
DebugLn(['TMainIDE.OnSrcNotebookShowHintForSource Expression="',Expression,'"']);
if not DebugBoss.Evaluate(Expression, DebugEval) or (DebugEval = '') then
DebugEval := '???';
SmartHintStr := Expression + ' = ' + DebugEval;

View File

@ -3286,7 +3286,9 @@ end;
function TSourceEditor.GetOperandFromCaret(const ACaretPos: TPoint): String;
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);
end;