codetools: replaced some var parmas with out params

git-svn-id: trunk@13248 -
This commit is contained in:
mattias 2007-12-09 11:07:51 +00:00
parent 2f1dae25aa
commit 108a310615
3 changed files with 45 additions and 17 deletions

View File

@ -341,15 +341,15 @@ type
// blocks (e.g. begin..end, case..end, try..finally..end, repeat..until)
function FindBlockCounterPart(Code: TCodeBuffer; X,Y: integer;
var NewCode: TCodeBuffer;
var NewX, NewY, NewTopLine: integer): boolean;
out NewCode: TCodeBuffer;
out NewX, NewY, NewTopLine: integer): boolean;
function FindBlockStart(Code: TCodeBuffer; X,Y: integer;
var NewCode: TCodeBuffer;
var NewX, NewY, NewTopLine: integer): boolean;
out NewCode: TCodeBuffer;
out NewX, NewY, NewTopLine: integer): boolean;
function GuessUnclosedBlock(Code: TCodeBuffer; X,Y: integer;
var NewCode: TCodeBuffer;
var NewX, NewY, NewTopLine: integer): boolean;
out NewCode: TCodeBuffer;
out NewX, NewY, NewTopLine: integer): boolean;
// method jumping
function JumpToMethod(Code: TCodeBuffer; X,Y: integer;
var NewCode: TCodeBuffer;
@ -2756,7 +2756,7 @@ begin
end;
function TCodeToolManager.FindBlockCounterPart(Code: TCodeBuffer;
X, Y: integer; var NewCode: TCodeBuffer; var NewX, NewY, NewTopLine: integer
X, Y: integer; out NewCode: TCodeBuffer; out NewX, NewY, NewTopLine: integer
): boolean;
var
CursorPos: TCodeXYPosition;
@ -2789,7 +2789,7 @@ begin
end;
function TCodeToolManager.FindBlockStart(Code: TCodeBuffer;
X, Y: integer; var NewCode: TCodeBuffer; var NewX, NewY, NewTopLine: integer
X, Y: integer; out NewCode: TCodeBuffer; out NewX, NewY, NewTopLine: integer
): boolean;
var
CursorPos: TCodeXYPosition;
@ -2822,7 +2822,7 @@ begin
end;
function TCodeToolManager.GuessUnclosedBlock(Code: TCodeBuffer; X, Y: integer;
var NewCode: TCodeBuffer; var NewX, NewY, NewTopLine: integer): boolean;
out NewCode: TCodeBuffer; out NewX, NewY, NewTopLine: integer): boolean;
var
CursorPos: TCodeXYPosition;
NewPos: TCodeXYPosition;

View File

@ -202,7 +202,7 @@ type
function GuessUnclosedBlock(const CursorPos: TCodeXYPosition;
out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean;
function FindBlockCleanBounds(const CursorPos: TCodeXYPosition;
var BlockCleanStart, BlockCleanEnd: integer): boolean;
out BlockCleanStart, BlockCleanEnd: integer): boolean;
// compiler directives
function GuessMisplacedIfdefEndif(const CursorPos: TCodeXYPosition;
@ -4523,13 +4523,15 @@ begin
end;
function TStandardCodeTool.FindBlockCleanBounds(
const CursorPos: TCodeXYPosition; var BlockCleanStart, BlockCleanEnd: integer
const CursorPos: TCodeXYPosition; out BlockCleanStart, BlockCleanEnd: integer
): boolean;
var
CleanCursorPos: integer;
BlockStartFound: Boolean;
begin
Result:=false;
BlockCleanStart:=0;
BlockCleanEnd:=0;
// scan code
BeginParsingAndGetCleanPos(true,false,CursorPos,CleanCursorPos);
// read word at cursor

View File

@ -33,9 +33,14 @@ interface
uses
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
ClipBrd, StdCtrls, Buttons, ExtCtrls, Menus, FileUtil,
SynEdit, SynHighlighterPas, SynEditAutoComplete, CodeToolManager, CodeCache,
KeywordFuncLists, BasicCodeTools, PascalParserTool,
// synedit
SynEdit, SynHighlighterPas, SynEditAutoComplete,
// codetools
CodeToolManager, CodeAtom, CodeCache, KeywordFuncLists, BasicCodeTools,
PascalParserTool,
// IDEIntf
IDECommands, TextTools, SrcEditorIntf, MenuIntf, IDEWindowIntf, LazIDEIntf,
// IDE
IDEProcs, InputHistory, LazarusIDEStrConsts, EditorOptions, CodeMacroSelect;
type
@ -405,18 +410,39 @@ end;
function CodeMacroAddMissingEnd(const Parameter: string;
InteractiveValue: TPersistent; SrcEdit: TSourceEditorInterface; var Value,
ErrorMsg: string): boolean;
{ checks if at current position a block end should be inserted
Examples:
No block end required:
begin|
end
repeat|
until
begin|
repeat
Block end required:
begin
begin|
end;
}
var
Line: String;
p: TPoint;
CodeBuf: TCodeBuffer;
CodeXYPos: TCodeXYPosition;
begin
Result:=true;
Value:='';
Line:=SrcEdit.CurrentLineText;
p:=SrcEdit.CursorTextXY;
if p.y<1 then exit;
CodeBuf:=SrcEdit.CodeToolsBuffer as TCodeBuffer;
if CodeBuf=nil then exit;
CodeXYPos.X:=p.x;
CodeXYPos.Y:=p.y;
CodeXYPos.Code:=SrcEdit.CodeToolsBuffer as TCodeBuffer;
if CodeXYPos.Code=nil then exit;
// ToDo
while (p.y<=SrcEdit.LineCount) do begin