mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 16:41:28 +02:00
IDE+codetools: identifier completion: adding semicolon after procedure
git-svn-id: trunk@15844 -
This commit is contained in:
parent
f9bfbe18fd
commit
4e326a4448
@ -151,6 +151,7 @@ type
|
||||
ilcfStartInStatement, // context starts in statements. e.g. between begin..end
|
||||
ilcfStartIsLValue, // position is start of one statement. e.g. 'A|:=', does not check if A can be assigned
|
||||
ilcfNeedsEndSemicolon, // after context a semicolon is needed. e.g. 'A| end'
|
||||
ilcfNoEndSemicolon, // no semicolon after. E.g. 'A| else'
|
||||
ilcfIsExpression, // is expression part of statement. e.g. 'if expr'
|
||||
ilcfCanProcDeclaration // context allows to declare a procedure/method
|
||||
);
|
||||
@ -1542,16 +1543,23 @@ begin
|
||||
if (CurrentIdentifierList.StartBracketLvl=0)
|
||||
and (not (ilcfStartIsLValue in CurrentIdentifierList.ContextFlags))
|
||||
then begin
|
||||
// check if end needs semicolon
|
||||
// check if a semicolon is needed at the end
|
||||
if (CurPos.Flag=cafWord)
|
||||
and (UpAtomIs('ELSE')
|
||||
or UpAtomIs('THEN')
|
||||
or UpAtomIs('DO')
|
||||
or UpAtomIs('TO')
|
||||
or UpAtomIs('OF'))
|
||||
then begin
|
||||
// do not add semicolon
|
||||
CurrentIdentifierList.ContextFlags:=
|
||||
CurrentIdentifierList.ContextFlags+[ilcfNoEndSemicolon];
|
||||
end
|
||||
else
|
||||
if (CurPos.Flag in [cafEnd,cafBegin])
|
||||
or WordIsBlockKeyWord.DoItUpperCase(UpperSrc,
|
||||
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos)
|
||||
or ((CurPos.Flag=cafWord)
|
||||
and (not UpAtomIs('ELSE'))
|
||||
and (not UpAtomIs('THEN'))
|
||||
and (not UpAtomIs('DO'))
|
||||
and (not UpAtomIs('TO'))
|
||||
and (not UpAtomIs('OF'))
|
||||
and (not PositionsInSameLine(Src,IdentEndPos,CurPos.StartPos)))
|
||||
then begin
|
||||
// add semicolon
|
||||
|
@ -410,6 +410,7 @@ var
|
||||
CursorAtEnd: boolean;
|
||||
ProcModifierPos: LongInt;
|
||||
ProcHeadFlags: TProcHeadAttributes;
|
||||
CanAddSemicolon: Boolean;
|
||||
begin
|
||||
Result:='';
|
||||
CursorToLeft:=0;
|
||||
@ -417,6 +418,7 @@ begin
|
||||
ValueType:=icvIdentifier;
|
||||
Index:=aCompletion.Position;
|
||||
IdentList:=CodeToolBoss.IdentifierList;
|
||||
CanAddSemicolon:=CodeToolsOpts.IdentComplAddSemicolon;
|
||||
|
||||
IdentItem:=IdentList.FilteredItems[Index];
|
||||
if IdentItem=nil then exit;
|
||||
@ -496,6 +498,7 @@ begin
|
||||
Result:=TrimLeft(CodeToolBoss.SourceChangeCache
|
||||
.BeautifyCodeOptions.BeautifyProc(
|
||||
Result,CodeToolBoss.IdentifierList.StartContextPos.X,false));
|
||||
CanAddSemicolon:=false;
|
||||
end;
|
||||
|
||||
icvUnitName:
|
||||
@ -532,10 +535,15 @@ begin
|
||||
Result:=Result+AddChar;
|
||||
|
||||
// add semicolon for statement ends
|
||||
if (ilcfNeedsEndSemicolon in IdentList.ContextFlags)
|
||||
and CodeToolsOpts.IdentComplAddSemicolon then begin
|
||||
Result:=Result+';';
|
||||
inc(CursorToLeft);
|
||||
if CanAddSemicolon
|
||||
and (not (ilcfNoEndSemicolon in IdentList.ContextFlags))
|
||||
then begin
|
||||
if (ilcfNeedsEndSemicolon in IdentList.ContextFlags)
|
||||
or (IdentItem.GetDesc=ctnProcedure)
|
||||
then begin
|
||||
Result:=Result+';';
|
||||
inc(CursorToLeft);
|
||||
end;
|
||||
end;
|
||||
|
||||
//DebugLn(['GetIdentCompletionValue END Result="',Result,'"']);
|
||||
|
Loading…
Reference in New Issue
Block a user