mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 12:00:29 +02:00
IDE+codetools: ExtractOperand: added WithoutTrailingPoints
git-svn-id: trunk@21985 -
This commit is contained in:
parent
1803fc05ff
commit
1ffd720917
@ -464,7 +464,8 @@ 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; WithPostTokens, WithAsOperator: boolean): boolean;
|
out Operand: string; WithPostTokens, WithAsOperator,
|
||||||
|
WithoutTrailingPoints: 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 +2541,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TCodeToolManager.ExtractOperand(Code: TCodeBuffer; X, Y: integer; out
|
function TCodeToolManager.ExtractOperand(Code: TCodeBuffer; X, Y: integer; out
|
||||||
Operand: string; WithPostTokens, WithAsOperator: boolean): boolean;
|
Operand: string; WithPostTokens, WithAsOperator,
|
||||||
|
WithoutTrailingPoints: boolean): boolean;
|
||||||
var
|
var
|
||||||
CursorPos: TCodeXYPosition;
|
CursorPos: TCodeXYPosition;
|
||||||
begin
|
begin
|
||||||
@ -2555,7 +2557,7 @@ begin
|
|||||||
CursorPos.Code:=Code;
|
CursorPos.Code:=Code;
|
||||||
try
|
try
|
||||||
Result:=FCurCodeTool.ExtractOperand(CursorPos,Operand,
|
Result:=FCurCodeTool.ExtractOperand(CursorPos,Operand,
|
||||||
WithPostTokens,WithAsOperator);
|
WithPostTokens,WithAsOperator,WithoutTrailingPoints);
|
||||||
except
|
except
|
||||||
on e: Exception do HandleException(e);
|
on e: Exception do HandleException(e);
|
||||||
end;
|
end;
|
||||||
|
@ -256,7 +256,8 @@ 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; WithPostTokens, WithAsOperator: boolean): boolean;
|
out Operand: string; WithPostTokens, WithAsOperator,
|
||||||
|
WithoutTrailingPoints: boolean): boolean;
|
||||||
|
|
||||||
// resource strings
|
// resource strings
|
||||||
function GatherResourceStringSections(const CursorPos: TCodeXYPosition;
|
function GatherResourceStringSections(const CursorPos: TCodeXYPosition;
|
||||||
@ -3496,7 +3497,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TStandardCodeTool.ExtractOperand(const CursorPos: TCodeXYPosition; out
|
function TStandardCodeTool.ExtractOperand(const CursorPos: TCodeXYPosition; out
|
||||||
Operand: string; WithPostTokens, WithAsOperator: boolean): boolean;
|
Operand: string; WithPostTokens, WithAsOperator,
|
||||||
|
WithoutTrailingPoints: boolean): boolean;
|
||||||
var
|
var
|
||||||
CleanPos: integer;
|
CleanPos: integer;
|
||||||
StartPos: LongInt;
|
StartPos: LongInt;
|
||||||
@ -3521,6 +3523,10 @@ begin
|
|||||||
if EndPos<1 then exit;
|
if EndPos<1 then exit;
|
||||||
DebugLn(['TStandardCodeTool.ExtractOperand "',dbgstr(copy(Src,StartPos,EndPOs-StartPos)),'"']);
|
DebugLn(['TStandardCodeTool.ExtractOperand "',dbgstr(copy(Src,StartPos,EndPOs-StartPos)),'"']);
|
||||||
Operand:=ExtractCode(StartPos,EndPos,[phpCommentsToSpace]);
|
Operand:=ExtractCode(StartPos,EndPos,[phpCommentsToSpace]);
|
||||||
|
if WithoutTrailingPoints then begin
|
||||||
|
while (Operand<>'') and (Operand[length(Operand)]='.') do
|
||||||
|
Operand:=copy(Operand,1,length(Operand)-1);
|
||||||
|
end;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -3287,7 +3287,7 @@ 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,
|
if not CodeToolBoss.ExtractOperand(CodeBuffer, ACaretPos.X, ACaretPos.Y,
|
||||||
Result, False, False)
|
Result, False, False, true)
|
||||||
then
|
then
|
||||||
Result := GetWordFromCaret(ACaretPos);
|
Result := GetWordFromCaret(ACaretPos);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user