IDE+codetools: identifier completion: show constructor/destructo from Paul, bug #13215

git-svn-id: trunk@18783 -
This commit is contained in:
mattias 2009-02-20 21:23:15 +00:00
parent cf81a4cbf8
commit 22c61b805d
3 changed files with 69 additions and 12 deletions

View File

@ -81,7 +81,11 @@ type
iliIsAbstractMethodValid,
iliParamListValid,
iliNodeValid,
iliNodeHashValid
iliNodeHashValid,
iliIsConstructor,
iliIsConstructorValid,
iliIsDestructor,
iliIsDestructorValid
);
TIdentListItemFlags = set of TIdentListItemFlag;
@ -131,6 +135,8 @@ type
procedure UpdateBaseContext;
function HasChilds: boolean;
function IsFunction: boolean;
function IsContructor: boolean;
function IsDestructor: boolean;
function IsAbstractMethod: boolean;
function TryIsAbstractMethod: boolean;
procedure Clear;
@ -2046,13 +2052,42 @@ function TIdentifierListItem.IsFunction: boolean;
var
ANode: TCodeTreeNode;
begin
if not (iliIsFunctionValid in Flags) then begin
ANode:=Node;
if (ANode<>nil) and Tool.NodeIsFunction(ANode) then
Include(Flags,iliIsFunction);
Include(Flags,iliIsFunctionValid);
if not (iliIsFunctionValid in Flags) then
begin
ANode := Node;
if (ANode <> nil) and Tool.NodeIsFunction(ANode) then
Include(Flags, iliIsFunction);
Include(Flags, iliIsFunctionValid);
end;
Result:=iliIsFunction in Flags;
Result := iliIsFunction in Flags;
end;
function TIdentifierListItem.IsContructor: boolean;
var
ANode: TCodeTreeNode;
begin
if not (iliIsConstructorValid in Flags) then
begin
ANode := Node;
if (ANode <> nil) and Tool.NodeIsConstructor(ANode) then
Include(Flags, iliIsConstructor);
Include(Flags, iliIsConstructorValid);
end;
Result := iliIsConstructor in Flags;
end;
function TIdentifierListItem.IsDestructor: boolean;
var
ANode: TCodeTreeNode;
begin
if not (iliIsDestructorValid in Flags) then
begin
ANode := Node;
if (ANode <> nil) and Tool.NodeIsDestructor(ANode) then
Include(Flags, iliIsDestructor);
Include(Flags, iliIsDestructorValid);
end;
Result := iliIsDestructor in Flags;
end;
function TIdentifierListItem.IsAbstractMethod: boolean;

View File

@ -108,6 +108,7 @@ type
function NodeIsMethodBody(ProcNode: TCodeTreeNode): boolean;
function NodeIsFunction(ProcNode: TCodeTreeNode): boolean;
function NodeIsConstructor(ProcNode: TCodeTreeNode): boolean;
function NodeIsDestructor(ProcNode: TCodeTreeNode): boolean;
function NodeIsForwardProc(ProcNode: TCodeTreeNode): boolean;
// classes
@ -1548,6 +1549,18 @@ begin
Result:=UpAtomIs('CONSTRUCTOR');
end;
function TPascalReaderTool.NodeIsDestructor(ProcNode: TCodeTreeNode): boolean;
begin
Result:=false;
if (ProcNode=nil) then exit;
if ProcNode.Desc=ctnProcedureHead then
ProcNode:=ProcNode.Parent;
if ProcNode.Desc<>ctnProcedure then exit;
MoveCursorToNodeStart(ProcNode);
ReadNextAtom;
Result:=UpAtomIs('DESTRUCTOR');
end;
function TPascalReaderTool.NodeIsForwardProc(ProcNode: TCodeTreeNode): boolean;
begin
Result:=false;

View File

@ -256,12 +256,21 @@ begin
ctnProcedure:
begin
if IdentItem.IsFunction then begin
if IdentItem.IsFunction then
begin
AColor:=clTeal;
s:='function';
end else begin
end
else
begin
AColor:=clNavy;
s:='procedure';
if IdentItem.IsContructor then
s := 'constructor'
else
if IdentItem.IsDestructor then
s := 'destructor'
else
s:='procedure';
end;
if IdentItem.TryIsAbstractMethod then
AColor:=clRed;
@ -292,10 +301,10 @@ begin
SetFontColor(AColor);
if MeasureOnly then
Inc(Result.X, ACanvas.TextWidth('procedure '))
Inc(Result.X, ACanvas.TextWidth('constructor '))
else
ACanvas.TextOut(x+1,y,s);
inc(x,ACanvas.TextWidth('procedure '));
inc(x,ACanvas.TextWidth('constructor '));
if x>MaxX then exit;
// paint the identifier