codetools: fixed adding published method into implicit first published section

git-svn-id: trunk@22941 -
This commit is contained in:
mattias 2009-12-03 11:29:47 +00:00
parent 5cdcfd3451
commit 2f778c1f3b
3 changed files with 20 additions and 12 deletions

View File

@ -268,12 +268,12 @@ type
out Graph: TCodeGraph; OnlyInterface: boolean): boolean;
procedure WriteCodeGraphDebugReport(Graph: TCodeGraph);
function FindEmptyMethods(CursorPos: TCodeXYPosition;
const AClassName: string;
const AClassName: string; // can be ''
const Sections: TPascalClassSections;
ListOfPCodeXYPosition: TFPList;
out AllEmpty: boolean): boolean;
function FindEmptyMethods(CursorPos: TCodeXYPosition;
const AClassName: string;
const AClassName: string; // can be ''
const Sections: TPascalClassSections;
CodeTreeNodeExtensions: TAVLTree;
out AllEmpty: boolean): boolean;
@ -5727,7 +5727,7 @@ begin
ANode:=ANode.NextBrother;
end;
end;
// find a nice position between similar siblings
case ASourceChangeCache.BeautifyCodeOptions.ClassPartInsertPolicy of
@ -5789,7 +5789,7 @@ begin
end;
end
end;
if InsertNode<>nil then begin
// for variable lists: a,b,c: integer
@ -5826,7 +5826,14 @@ begin
Indent:=GetLineIndent(Src,ClassSectionNode.StartPos)
+ASourceChangeCache.BeautifyCodeOptions.Indent;
InsertPos:=ClassSectionNode.StartPos;
if (ClassSectionNode.Desc in (AllClassBaseSections+AllClassTypeSections))
if (ClassSectionNode.Desc=ctnClassPublished)
and (CompareIdentifiers(@Src[ClassSectionNode.StartPos],'published')<>0)
then begin
// the first published section has no keyword
if ClassSectionNode.NextBrother<>nil then
Indent:=GetLineIndent(Src,ClassSectionNode.StartPos)
+ASourceChangeCache.BeautifyCodeOptions.Indent;
end else if (ClassSectionNode.Desc in (AllClassBaseSections+AllClassTypeSections))
then begin
// skip keyword
MoveCursorToCleanPos(InsertPos);

View File

@ -370,9 +370,9 @@ type
// method jumping
function JumpToMethod(Code: TCodeBuffer; X,Y: integer;
var NewCode: TCodeBuffer;
var NewX, NewY, NewTopLine: integer;
var RevertableJump: boolean): boolean;
out NewCode: TCodeBuffer;
out NewX, NewY, NewTopLine: integer;
out RevertableJump: boolean): boolean;
// find declaration
function FindDeclaration(Code: TCodeBuffer; X,Y: integer;
@ -504,7 +504,8 @@ type
function ReplaceAllTypeCastFunctions(Code: TCodeBuffer): boolean;
function FixForwardDefinitions(Code: TCodeBuffer): boolean;
function FindEmptyMethods(Code: TCodeBuffer;
const AClassName: string; X,Y: integer;
const AClassName: string; // can be ''
X,Y: integer;
const Sections: TPascalClassSections;
ListOfPCodeXYPosition: TFPList;
out AllEmpty: boolean): boolean;
@ -1696,8 +1697,8 @@ begin
end;
function TCodeToolManager.JumpToMethod(Code: TCodeBuffer; X,Y: integer;
var NewCode: TCodeBuffer; var NewX, NewY, NewTopLine: integer;
var RevertableJump: boolean): boolean;
out NewCode: TCodeBuffer; out NewX, NewY, NewTopLine: integer;
out RevertableJump: boolean): boolean;
var
CursorPos: TCodeXYPosition;
NewPos: TCodeXYPosition;

View File

@ -62,7 +62,7 @@ begin
end else begin
raise Exception.Create('Adding method failed');
end;
// Example 2: adding methods directly, but several at a time
AClassName:='TMyClass';
if not CodeToolBoss.InitClassCompletion(Code,UpperCase(AClassName),Tool) then