mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-05 02:41:06 +02:00
codetools: first section of non class is public
git-svn-id: trunk@30621 -
This commit is contained in:
parent
19fd9eaf0d
commit
a76e3248bf
@ -6204,7 +6204,8 @@ end;
|
||||
|
||||
function TCodeCompletionCodeTool.InsertAllNewClassParts: boolean;
|
||||
var
|
||||
PublishedKeyWordNeeded: boolean;
|
||||
NewSectionKeyWordNeeded: boolean;
|
||||
NewSection: TPascalClassSection;
|
||||
|
||||
function GetTopMostPositionNode(Visibility: TPascalClassSection
|
||||
): TCodeTreeNode;
|
||||
@ -6303,12 +6304,12 @@ var
|
||||
NewClassSectionInsertPos[Visibility]:=ANode.StartPos
|
||||
else
|
||||
NewClassSectionInsertPos[Visibility]:=ANode.FirstChild.EndPos;
|
||||
if (not PublishedKeyWordNeeded)
|
||||
and (CompareNodeIdentChars(ANode,'PUBLISHED')<>0) then begin
|
||||
PublishedKeyWordNeeded:=true;
|
||||
NewClassSectionInsertPos[pcsPublished]:=
|
||||
if (not NewSectionKeyWordNeeded)
|
||||
and (CompareNodeIdentChars(ANode, UpperCase(PascalClassSectionKeywords[NewSection]))<>0) then begin
|
||||
NewSectionKeyWordNeeded:=true;
|
||||
NewClassSectionInsertPos[NewSection]:=
|
||||
NewClassSectionInsertPos[Visibility];
|
||||
NewClassSectionIndent[pcsPublished]:=
|
||||
NewClassSectionIndent[NewSection]:=
|
||||
NewClassSectionIndent[Visibility];
|
||||
end;
|
||||
end else begin
|
||||
@ -6351,7 +6352,11 @@ begin
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
PublishedKeyWordNeeded:=false;// 'published' keyword after first private section needed
|
||||
NewSectionKeyWordNeeded:=false;// 'published'/'public' keyword after first private section needed
|
||||
if CodeCompleteClassNode.Desc = ctnClass then
|
||||
NewSection := pcsPublished
|
||||
else
|
||||
NewSection := pcsPublic;
|
||||
|
||||
AddClassSection(pcsPrivate);
|
||||
InsertNewClassParts(ncpPrivateVars);
|
||||
@ -6361,16 +6366,24 @@ begin
|
||||
InsertNewClassParts(ncpProtectedVars);
|
||||
InsertNewClassParts(ncpProtectedProcs);
|
||||
|
||||
AddClassSection(pcsPublic);
|
||||
if NewSectionKeyWordNeeded and (NewSection = pcsPublic) then begin
|
||||
ASourceChangeCache.Replace(gtNewLine,gtNewLine,
|
||||
NewClassSectionInsertPos[NewSection],
|
||||
NewClassSectionInsertPos[NewSection],
|
||||
GetIndentStr(NewClassSectionIndent[NewSection])+
|
||||
ASourceChangeCache.BeautifyCodeOptions.BeautifyKeyWord(PascalClassSectionKeywords[NewSection]));
|
||||
end
|
||||
else
|
||||
AddClassSection(pcsPublic);
|
||||
InsertNewClassParts(ncpPublicVars);
|
||||
InsertNewClassParts(ncpPublicProcs);
|
||||
|
||||
if PublishedKeyWordNeeded then begin
|
||||
if NewSectionKeyWordNeeded and (NewSection = pcsPublished) then begin
|
||||
ASourceChangeCache.Replace(gtNewLine,gtNewLine,
|
||||
NewClassSectionInsertPos[pcsPublished],
|
||||
NewClassSectionInsertPos[pcsPublished],
|
||||
GetIndentStr(NewClassSectionIndent[pcsPublished])+
|
||||
ASourceChangeCache.BeautifyCodeOptions.BeautifyKeyWord('published'));
|
||||
NewClassSectionInsertPos[NewSection],
|
||||
NewClassSectionInsertPos[NewSection],
|
||||
GetIndentStr(NewClassSectionIndent[NewSection])+
|
||||
ASourceChangeCache.BeautifyCodeOptions.BeautifyKeyWord(PascalClassSectionKeywords[NewSection]));
|
||||
end;
|
||||
InsertNewClassParts(ncpPublishedVars);
|
||||
InsertNewClassParts(ncpPublishedProcs);
|
||||
|
@ -3765,9 +3765,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
// start the first class section (always published)
|
||||
// start the first class section (always published/public)
|
||||
CreateChildNode;
|
||||
CurNode.Desc:=ctnClassPublished;
|
||||
if ClassDesc = ctnClass then
|
||||
CurNode.Desc:=ctnClassPublished
|
||||
else
|
||||
CurNode.Desc:=ctnClassPublic;
|
||||
CurNode.StartPos:=LastAtoms.GetValueAt(0).EndPos;
|
||||
if CurPos.Flag=cafEdgedBracketOpen then
|
||||
ReadGUID;
|
||||
|
Loading…
Reference in New Issue
Block a user