IDE: Formatting.

git-svn-id: trunk@55308 -
This commit is contained in:
juha 2017-06-10 16:30:21 +00:00
parent 412bf43f42
commit 99f4b40a94
2 changed files with 71 additions and 67 deletions

View File

@ -17,8 +17,12 @@ unit IDEHelpIntf;
interface
uses
Classes, SysUtils, types, LCLProc, Forms, Controls, HelpIntfs, LazHelpIntf,
LMessages, LCLType, TextTools, Graphics, LCLIntf;
Classes, Types, SysUtils, strutils,
// LCL
LMessages, LCLType, LCLProc, Forms, Controls, Graphics,
HelpIntfs, LazHelpIntf, LCLIntf,
// IdeIntf
TextTools;
type
{ THelpDBIRegExprMessage
@ -374,8 +378,8 @@ function THintWindowManager.ShowHint(ScreenPos: TPoint; TheHint: string;
HintTextWindow.HintRect := HintWinRect; // Adds borders.
if MouseOffset then
HintTextWindow.OffsetHintRect(ScreenPos)
else
HintTextWindow.OffsetHintRect(ScreenPos, 0, True, False); // shrink height only for fixed (no MouseOffset) hints
else // shrink height only for fixed (no MouseOffset) hints
HintTextWindow.OffsetHintRect(ScreenPos, 0, True, False);
HintTextWindow.ActivateHint(TheHint);
end;
@ -389,9 +393,9 @@ function THintWindowManager.ShowHint(ScreenPos: TPoint; TheHint: string;
HintRenderWindow.Font := HintFont;
HtmlHelpProvider.BaseURL:=FBaseURL;
ms:=TMemoryStream.Create;
try
if TheHint<>'' then
ms.Write(TheHint[1],length(TheHint));
try // TheHint<>'' is checked earlier.
Assert(TheHint<>'', 'THintWindowManager.ShowHint: TheHint is empty');
ms.Write(TheHint[1],length(TheHint));
ms.Position:=0;
HtmlHelpProvider.ControlIntf.SetHTMLContent(ms,'');
finally

View File

@ -11063,8 +11063,10 @@ procedure TMainIDE.SrcNotebookShowHintForSource(SrcEdit: TSourceEditor;
Result := False;
InStr := False;
for i := 1 to Length(Expr) do begin
if Expr[i] = '''' then InStr := not InStr;
for i := 1 to Length(Expr) do
begin
if Expr[i] = '''' then
InStr := not InStr;
if (not InStr) and (Expr[i] in [';', ':']) then exit; // can not be an expression
// Todo: Maybe check for keywords: If Then Begin End ...
end;
@ -11094,7 +11096,8 @@ begin
debugln('[TMainIDE.OnSrcNotebookShowHintForSource] ************ ',ActiveUnitInfo.Source.Filename,' X=',CaretPos.X,' Y=',CaretPos.Y);
{$ENDIF}
HasHint:=false;
if EditorOpts.AutoToolTipSymbTools then begin
if EditorOpts.AutoToolTipSymbTools then
begin
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.OnSrcNotebookShowHintForSource A');{$ENDIF}
if TIDEHelpManager(HelpBoss).GetHintForSourcePosition(ActiveUnitInfo.Filename,
CaretPos,BaseURL,SmartHintStr,
@ -11103,66 +11106,63 @@ begin
HasHint:=true;
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.OnSrcNotebookShowHintForSource B');{$ENDIF}
end;
case ToolStatus of
itDebugger: begin
if EditorOpts.AutoToolTipExprEval then begin
if SrcEdit.SelectionAvailable and SrcEdit.CaretInSelection(CaretPos) then begin
Expression := SrcEdit.GetText(True);
if not CheckExpressionIsValid(Expression) then
Expression := '';
end
else
Expression := SrcEdit.GetOperandFromCaret(CaretPos);
if Expression='' then exit;
//DebugLn(['TMainIDE.OnSrcNotebookShowHintForSource Expression="',Expression,'"']);
DBGType:=nil;
DBGTypeDerefer:=nil;
Opts := [];
if EditorOpts.DbgHintAutoTypeCastClass
then Opts := [defClassAutoCast];
DebugEval:='';
if DebugBoss.Evaluate(Expression, DebugEval, DBGType, Opts) and not (DebugEval = '') then
if (ToolStatus = itDebugger) and EditorOpts.AutoToolTipExprEval then
begin
if SrcEdit.SelectionAvailable and SrcEdit.CaretInSelection(CaretPos) then
begin
Expression := SrcEdit.GetText(True);
if not CheckExpressionIsValid(Expression) then
Expression := '';
end
else
Expression := SrcEdit.GetOperandFromCaret(CaretPos);
if Expression='' then exit;
//DebugLn(['TMainIDE.OnSrcNotebookShowHintForSource Expression="',Expression,'"']);
DBGType:=nil;
DBGTypeDerefer:=nil;
Opts := [];
if EditorOpts.DbgHintAutoTypeCastClass
then Opts := [defClassAutoCast];
DebugEval:='';
if DebugBoss.Evaluate(Expression, DebugEval, DBGType, Opts) and not (DebugEval = '') then
begin
// deference a pointer - maybe it is a class
if Assigned(DBGType) and (DBGType.Kind in [skPointer]) and
not( StringCase(Lowercase(DBGType.TypeName), ['char', 'character', 'ansistring']) in [0..2] )
then
begin
if DBGType.Value.AsPointer <> nil then
begin
// deference a pointer - maybe it is a class
if Assigned(DBGType) and (DBGType.Kind in [skPointer]) and
not( StringCase(Lowercase(DBGType.TypeName), ['char', 'character', 'ansistring']) in [0..2] )
then
DebugEvalDerefer:='';
if DebugBoss.Evaluate(Expression + '^', DebugEvalDerefer, DBGTypeDerefer, Opts) then
begin
if DBGType.Value.AsPointer <> nil then
begin
DebugEvalDerefer:='';
if DebugBoss.Evaluate(Expression + '^', DebugEvalDerefer, DBGTypeDerefer, Opts) then
begin
if Assigned(DBGTypeDerefer) and
( (DBGTypeDerefer.Kind <> skPointer) or
(StringCase(Lowercase(DBGTypeDerefer.TypeName), ['char', 'character', 'ansistring']) in [0..2])
)
then
DebugEval := DebugEval + ' = ' + DebugEvalDerefer;
end;
end;
end else
DebugEval := DebugBoss.FormatValue(DBGType, DebugEval);
end else
DebugEval := '???';
FreeAndNil(DBGType);
FreeAndNil(DBGTypeDerefer);
HasHint:=true;
Expression := Expression + ' = ' + DebugEval;
if SmartHintStr<>'' then begin
p:=System.Pos('<body>',lowercase(SmartHintStr));
if p>0 then begin
Insert('<div class="debuggerhint">'
+CodeHelpBoss.TextToHTML(Expression)+'</div><br>',
SmartHintStr,p+length('<body>'));
end else begin
SmartHintStr:=Expression+LineEnding+LineEnding+SmartHintStr;
if Assigned(DBGTypeDerefer) and
( (DBGTypeDerefer.Kind <> skPointer) or
(StringCase(Lowercase(DBGTypeDerefer.TypeName), ['char', 'character', 'ansistring']) in [0..2])
)
then
DebugEval := DebugEval + ' = ' + DebugEvalDerefer;
end;
end else
SmartHintStr:=Expression;
end;
end;
end;
end else
DebugEval := DebugBoss.FormatValue(DBGType, DebugEval);
end else
DebugEval := '???';
FreeAndNil(DBGType);
FreeAndNil(DBGTypeDerefer);
HasHint:=true;
Expression := Expression + ' = ' + DebugEval;
if SmartHintStr<>'' then
begin
p:=System.Pos('<body>',lowercase(SmartHintStr));
if p>0 then
Insert('<div class="debuggerhint">'+CodeHelpBoss.TextToHTML(Expression)+'</div><br>',
SmartHintStr, p+length('<body>'))
else
SmartHintStr:=Expression+LineEnding+LineEnding+SmartHintStr;
end else
SmartHintStr:=Expression;
end;
if HasHint then