mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 15:25:07 +02:00
IDE: identifier completion: add do after with, issue #16850
git-svn-id: trunk@36991 -
This commit is contained in:
parent
d4e8790811
commit
15f4afc429
@ -188,6 +188,7 @@ type
|
||||
ilcfNeedsEndSemicolon, // after context a semicolon is needed. e.g. 'A| end'
|
||||
ilcfNoEndSemicolon, // no semicolon after. E.g. 'A| else'
|
||||
ilcfNeedsEndComma, // after context a comma is needed. e.g. 'uses sysutil| classes'
|
||||
ilcfNeedsDo, // after context a 'do' is needed. e.g. 'with Form1| do'
|
||||
ilcfIsExpression, // is expression part of statement. e.g. 'if expr'
|
||||
ilcfCanProcDeclaration,// context allows to declare a procedure/method
|
||||
ilcfEndOfLine // atom at end of line
|
||||
@ -243,9 +244,9 @@ type
|
||||
property Prefix: string read FPrefix write SetPrefix;
|
||||
property StartAtom: TAtomPosition read FStartAtom write FStartAtom;
|
||||
property StartAtomInFront: TAtomPosition
|
||||
read FStartAtomInFront write FStartAtomInFront;
|
||||
read FStartAtomInFront write FStartAtomInFront; // in front of variable, not only of identifier
|
||||
property StartAtomBehind: TAtomPosition
|
||||
read FStartAtomBehind write FStartAtomBehind;
|
||||
read FStartAtomBehind write FStartAtomBehind; // directly behind
|
||||
property StartBracketLvl: integer
|
||||
read FStartBracketLvl write FStartBracketLvl;
|
||||
property StartContext: TFindContext read FStartContext write FStartContext;
|
||||
@ -2365,6 +2366,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if CurrentIdentifierList.StartUpAtomInFrontIs('WITH')
|
||||
and (CurrentIdentifierList.StartAtomBehind.Flag<>cafComma)
|
||||
and (not CurrentIdentifierList.StartUpAtomBehindIs('DO')) then
|
||||
CurrentIdentifierList.ContextFlags:=
|
||||
CurrentIdentifierList.ContextFlags+[ilcfNeedsDo];
|
||||
end else begin
|
||||
// end of source
|
||||
CurrentIdentifierList.ContextFlags:=
|
||||
|
@ -52,6 +52,7 @@ type
|
||||
FClassHeaderComments: boolean;
|
||||
FClassImplementationComments: boolean;
|
||||
FFilename: string;
|
||||
FIdentComplAddDo: Boolean;
|
||||
FIdentComplAddParameterBrackets: boolean;
|
||||
FIdentComplReplaceIdentifier: boolean;
|
||||
FIdentComplShowHelp: boolean;
|
||||
@ -195,6 +196,7 @@ type
|
||||
write FIdentComplAddSemicolon;
|
||||
property IdentComplAddAssignOperator: Boolean read FIdentComplAddAssignOperator
|
||||
write FIdentComplAddAssignOperator;
|
||||
property IdentComplAddDo: Boolean read FIdentComplAddDo write FIdentComplAddDo;
|
||||
property IdentComplAutoStartAfterPoint: boolean read FIdentComplAutoStartAfterPoint
|
||||
write FIdentComplAutoStartAfterPoint;
|
||||
property IdentComplAddParameterBrackets: boolean
|
||||
@ -446,6 +448,8 @@ begin
|
||||
'CodeToolsOptions/IdentifierCompletion/AddSemicolon',true);
|
||||
FIdentComplAddAssignOperator:=XMLConfig.GetValue(
|
||||
'CodeToolsOptions/IdentifierCompletion/AddAssignOperator',true);
|
||||
FIdentComplAddDo:=XMLConfig.GetValue(
|
||||
'CodeToolsOptions/IdentifierCompletion/AddDo',true);
|
||||
FIdentComplAutoStartAfterPoint:=XMLConfig.GetValue(
|
||||
'CodeToolsOptions/IdentifierCompletion/AutoStartAfterPoint',true);
|
||||
FIdentComplAddParameterBrackets:=XMLConfig.GetValue(
|
||||
@ -574,6 +578,8 @@ begin
|
||||
FIdentComplAddSemicolon,true);
|
||||
XMLConfig.SetDeleteValue('CodeToolsOptions/IdentifierCompletion/AddAssignOperator',
|
||||
FIdentComplAddAssignOperator,true);
|
||||
XMLConfig.SetDeleteValue('CodeToolsOptions/IdentifierCompletion/AddDo',
|
||||
FIdentComplAddDo,true);
|
||||
XMLConfig.SetDeleteValue('CodeToolsOptions/IdentifierCompletion/AutoStartAfterPoint',
|
||||
FIdentComplAutoStartAfterPoint,true);
|
||||
XMLConfig.SetDeleteValue('CodeToolsOptions/IdentifierCompletion/AutoAddParameterBrackets',
|
||||
@ -676,6 +682,7 @@ begin
|
||||
// identifier completion
|
||||
FIdentComplAddSemicolon:=CodeToolsOpts.FIdentComplAddSemicolon;
|
||||
FIdentComplAddAssignOperator:=CodeToolsOpts.FIdentComplAddAssignOperator;
|
||||
FIdentComplAddDo:=CodeToolsOpts.FIdentComplAddDo;
|
||||
FIdentComplAutoStartAfterPoint:=CodeToolsOpts.FIdentComplAutoStartAfterPoint;
|
||||
FIdentComplAddParameterBrackets:=CodeToolsOpts.FIdentComplAddParameterBrackets;
|
||||
FIdentComplReplaceIdentifier:=CodeToolsOpts.FIdentComplReplaceIdentifier;
|
||||
@ -727,6 +734,7 @@ begin
|
||||
// identifier completion
|
||||
FIdentComplAddSemicolon:=true;
|
||||
FIdentComplAddAssignOperator:=true;
|
||||
FIdentComplAddDo:=true;
|
||||
FIdentComplAutoStartAfterPoint:=true;
|
||||
FIdentComplAddParameterBrackets:=true;
|
||||
FIdentComplReplaceIdentifier:=true;
|
||||
@ -793,6 +801,7 @@ begin
|
||||
// identifier completion
|
||||
and (FIdentComplAddSemicolon=CodeToolsOpts.FIdentComplAddSemicolon)
|
||||
and (FIdentComplAddAssignOperator=CodeToolsOpts.FIdentComplAddAssignOperator)
|
||||
and (FIdentComplAddDo=CodeToolsOpts.FIdentComplAddDo)
|
||||
and (FIdentComplAutoStartAfterPoint=CodeToolsOpts.FIdentComplAutoStartAfterPoint)
|
||||
and (FIdentComplAddParameterBrackets=CodeToolsOpts.FIdentComplAddParameterBrackets)
|
||||
and (FIdentComplReplaceIdentifier=CodeToolsOpts.FIdentComplReplaceIdentifier)
|
||||
|
@ -1,5 +1,7 @@
|
||||
inherited CodetoolsIndentifierCompletionOptionsFrame: TCodetoolsIndentifierCompletionOptionsFrame
|
||||
object CodetoolsIndentifierCompletionOptionsFrame: TCodetoolsIndentifierCompletionOptionsFrame
|
||||
Left = 0
|
||||
Height = 300
|
||||
Top = 0
|
||||
Width = 400
|
||||
ClientHeight = 300
|
||||
ClientWidth = 400
|
||||
@ -7,75 +9,75 @@ inherited CodetoolsIndentifierCompletionOptionsFrame: TCodetoolsIndentifierCompl
|
||||
Visible = False
|
||||
DesignLeft = 651
|
||||
DesignTop = 262
|
||||
object ICAddSemicolonCheckBox: TCheckBox[0]
|
||||
object ICAddSemicolonCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 6
|
||||
Height = 18
|
||||
Height = 22
|
||||
Top = 6
|
||||
Width = 185
|
||||
Width = 168
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'ICAddSemicolonCheckBox'
|
||||
TabOrder = 0
|
||||
end
|
||||
object ICAddAssignOperatorCheckBox: TCheckBox[1]
|
||||
object ICAddAssignOperatorCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = ICAddSemicolonCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 30
|
||||
Width = 219
|
||||
Height = 22
|
||||
Top = 34
|
||||
Width = 195
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'ICAddAssignOperatorCheckBox'
|
||||
TabOrder = 1
|
||||
end
|
||||
object ICAutoStartAfterPointCheckBox: TCheckBox[2]
|
||||
object ICAutoStartAfterPointCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = ICAddAssignOperatorCheckBox
|
||||
AnchorSideTop.Control = ICAddDoCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 54
|
||||
Width = 217
|
||||
Height = 22
|
||||
Top = 90
|
||||
Width = 194
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'ICAutoStartAfterPointCheckBox'
|
||||
TabOrder = 2
|
||||
end
|
||||
object ICAutoAddParameterBracketsCheckBox: TCheckBox[3]
|
||||
object ICAutoAddParameterBracketsCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = ICAutoStartAfterPointCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 78
|
||||
Width = 267
|
||||
Height = 22
|
||||
Top = 118
|
||||
Width = 240
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'ICAutoAddParameterBracketsCheckBox'
|
||||
TabOrder = 3
|
||||
end
|
||||
object ICShowHelpCheckBox: TCheckBox[4]
|
||||
object ICShowHelpCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = ICAddSemicolonCheckBox
|
||||
AnchorSideTop.Control = ICReplaceCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 146
|
||||
Width = 157
|
||||
Height = 22
|
||||
Top = 194
|
||||
Width = 144
|
||||
BorderSpacing.Top = 20
|
||||
Caption = 'ICShowHelpCheckBox'
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object ICReplaceCheckBox: TCheckBox[5]
|
||||
object ICReplaceCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = ICAddSemicolonCheckBox
|
||||
AnchorSideTop.Control = ICAutoAddParameterBracketsCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 108
|
||||
Width = 144
|
||||
Height = 22
|
||||
Top = 152
|
||||
Width = 134
|
||||
BorderSpacing.Top = 12
|
||||
BorderSpacing.Bottom = 6
|
||||
Caption = 'ICReplaceCheckBox'
|
||||
@ -83,4 +85,15 @@ inherited CodetoolsIndentifierCompletionOptionsFrame: TCodetoolsIndentifierCompl
|
||||
ShowHint = True
|
||||
TabOrder = 5
|
||||
end
|
||||
object ICAddDoCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = ICAddSemicolonCheckBox
|
||||
AnchorSideTop.Control = ICAddAssignOperatorCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 22
|
||||
Top = 62
|
||||
Width = 125
|
||||
Caption = 'ICAddDoCheckBox'
|
||||
TabOrder = 6
|
||||
end
|
||||
end
|
||||
|
@ -33,6 +33,7 @@ type
|
||||
{ TCodetoolsIndentifierCompletionOptionsFrame }
|
||||
|
||||
TCodetoolsIndentifierCompletionOptionsFrame = class(TAbstractIDEOptionsEditor)
|
||||
ICAddDoCheckBox: TCheckBox;
|
||||
ICAutoAddParameterBracketsCheckBox: TCheckBox;
|
||||
ICAutoStartAfterPointCheckBox: TCheckBox;
|
||||
ICAddAssignOperatorCheckBox: TCheckBox;
|
||||
@ -64,6 +65,7 @@ procedure TCodetoolsIndentifierCompletionOptionsFrame.Setup(
|
||||
begin
|
||||
ICAddSemicolonCheckBox.Caption:=dlgAddSemicolon;
|
||||
ICAddAssignOperatorCheckBox.Caption:=dlgAddAssignmentOperator;
|
||||
ICAddDoCheckBox.Caption:=lisAddKeywordDo;
|
||||
ICAutoStartAfterPointCheckBox.Caption:=lisAutomaticallyInvokeAfterPoint;
|
||||
ICAutoAddParameterBracketsCheckBox.Caption:=lisAddParameterBrackets;
|
||||
ICReplaceCheckBox.Caption:=lisReplaceWholeIdentifier;
|
||||
@ -79,6 +81,7 @@ begin
|
||||
begin
|
||||
ICAddSemicolonCheckBox.Checked := IdentComplAddSemicolon;
|
||||
ICAddAssignOperatorCheckBox.Checked := IdentComplAddAssignOperator;
|
||||
ICAddDoCheckBox.Checked := IdentComplAddDo;
|
||||
ICAutoStartAfterPointCheckBox.Checked := IdentComplAutoStartAfterPoint;
|
||||
ICAutoAddParameterBracketsCheckBox.Checked:=IdentComplAddParameterBrackets;
|
||||
ICReplaceCheckBox.Checked:=IdentComplReplaceIdentifier;
|
||||
@ -93,6 +96,7 @@ begin
|
||||
begin
|
||||
IdentComplAddSemicolon := ICAddSemicolonCheckBox.Checked;
|
||||
IdentComplAddAssignOperator := ICAddAssignOperatorCheckBox.Checked;
|
||||
IdentComplAddDo := ICAddDoCheckBox.Checked;
|
||||
IdentComplAutoStartAfterPoint := ICAutoStartAfterPointCheckBox.Checked;
|
||||
IdentComplAddParameterBrackets:=ICAutoAddParameterBracketsCheckBox.Checked;
|
||||
IdentComplReplaceIdentifier:=ICReplaceCheckBox.Checked;
|
||||
|
@ -1831,6 +1831,7 @@ resourcestring
|
||||
dlgWRDPreview = 'Preview';
|
||||
dlgAddSemicolon = 'Add semicolon';
|
||||
dlgAddAssignmentOperator = 'Add assignment operator :=';
|
||||
lisAddKeywordDo = 'Add keyword "do"';
|
||||
|
||||
dlgUserSchemeError = 'Failed to load user-scheme file %s';
|
||||
|
||||
|
@ -551,6 +551,7 @@ var
|
||||
Line: string;
|
||||
Indent: LongInt;
|
||||
StartContextPos: TCodeXYPosition;
|
||||
s: String;
|
||||
begin
|
||||
Result:='';
|
||||
CursorToLeft:=0;
|
||||
@ -608,7 +609,7 @@ begin
|
||||
and (not IdentList.StartUpAtomBehindIs('('))
|
||||
and (not IdentList.StartUpAtomInFrontIs('@'))
|
||||
and (IdentItem.ParamNameList<>'') then begin
|
||||
Result:=Result+'()';
|
||||
Result+='()';
|
||||
inc(CursorToLeft);
|
||||
CursorAtEnd:=false;
|
||||
end;
|
||||
@ -619,7 +620,7 @@ begin
|
||||
and CodeToolsOpts.IdentComplAddParameterBrackets
|
||||
and (ilcfStartInStatement in IdentList.ContextFlags)
|
||||
and (not IdentList.StartUpAtomBehindIs('[')) then begin
|
||||
Result:=Result+'[]';
|
||||
Result+='[]';
|
||||
inc(CursorToLeft);
|
||||
CursorAtEnd:=false;
|
||||
end;
|
||||
@ -691,24 +692,33 @@ begin
|
||||
and CodeToolsOpts.IdentComplAddAssignOperator then begin
|
||||
if (atIdentifier in CodeToolsOpts.DoInsertSpaceAfter)
|
||||
or (atSymbol in CodeToolsOpts.DoInsertSpaceInFront) then
|
||||
Result:=Result+' ';
|
||||
Result:=Result+':=';
|
||||
Result+=' ';
|
||||
Result+=':=';
|
||||
if (atSymbol in CodeToolsOpts.DoInsertSpaceAfter) then
|
||||
Result:=Result+' ';
|
||||
Result+=' ';
|
||||
end;
|
||||
|
||||
// add last typed character (that ended the identifier completion and starts a new token)
|
||||
if AddChar<>'' then
|
||||
Result:=Result+AddChar;
|
||||
Result+=AddChar;
|
||||
|
||||
if CanAddComma
|
||||
and (ilcfNeedsEndComma in IdentList.ContextFlags) then
|
||||
begin
|
||||
Result:=Result+',';
|
||||
Result+=',';
|
||||
end;
|
||||
|
||||
if (IdentItem.GetDesc=ctnUseUnit) and (AddChar<>'.') then begin
|
||||
Result:=Result+'.';
|
||||
// ToDo: check if there is already a point
|
||||
Result+='.';
|
||||
end;
|
||||
|
||||
// add 'do'
|
||||
if CodeToolsOpts.IdentComplAddDo and (AddChar='')
|
||||
and (ilcfNeedsDo in IdentList.ContextFlags) then begin
|
||||
s:=' '+CodeToolBoss.SourceChangeCache.BeautifyCodeOptions.BeautifyKeyWord('do');
|
||||
Result+=s;
|
||||
inc(CursorToLeft,length(s));
|
||||
end;
|
||||
|
||||
// add semicolon for statement ends
|
||||
@ -720,7 +730,7 @@ begin
|
||||
or ((ilcfStartInStatement in IdentList.ContextFlags)
|
||||
and (IdentItem.GetDesc=ctnProcedure))
|
||||
then begin
|
||||
Result:=Result+';';
|
||||
Result+=';';
|
||||
if (CursorToLeft=0) and (IdentItem.GetDesc=ctnProcedure)
|
||||
and (not IdentItem.IsFunction) then begin
|
||||
// a procedure call without parameters
|
||||
|
Loading…
Reference in New Issue
Block a user