Codetools: Fix a problem with event handler generation caused by r33955 #ce5458acf2. Issue #20813

git-svn-id: trunk@33964 -
This commit is contained in:
juha 2011-12-04 23:25:46 +00:00
parent 719c2296c9
commit a1d1d88896
2 changed files with 40 additions and 24 deletions

View File

@ -7067,7 +7067,6 @@ begin
finally finally
Params.Free; Params.Free;
end; end;
end;
ProcCode:=ExtractProcHead(ProcNode,[phpWithStart,phpAddClassname, ProcCode:=ExtractProcHead(ProcNode,[phpWithStart,phpAddClassname,
phpWithVarModifiers,phpWithParameterNames, phpWithVarModifiers,phpWithParameterNames,
phpWithResultType,phpWithCallingSpecs]); phpWithResultType,phpWithCallingSpecs]);
@ -7087,6 +7086,7 @@ begin
ProcCode:=ProcCode+Beauty.LineEnd+'begin'+Beauty.LineEnd+FullCall+Beauty.LineEnd+'end;'; ProcCode:=ProcCode+Beauty.LineEnd+'begin'+Beauty.LineEnd+FullCall+Beauty.LineEnd+'end;';
ProcCode:=Beauty.BeautifyProc(ProcCode,0,false); ProcCode:=Beauty.BeautifyProc(ProcCode,0,false);
ANodeExt.ExtTxt3:=ProcCode; ANodeExt.ExtTxt3:=ProcCode;
end;
end; end;
function TCodeCompletionCodeTool.CreateMissingProcBodies: boolean; function TCodeCompletionCodeTool.CreateMissingProcBodies: boolean;
@ -7126,6 +7126,23 @@ var
end; end;
end; end;
procedure CreateCodeForMissingProcBody(TheNodeExt: TCodeTreeNodeExtension;
Indent: integer);
var
ANode: TCodeTreeNode;
ProcCode: string;
begin
CheckForOverrideAndAddInheritedCode(TheNodeExt);
if (TheNodeExt.ExtTxt1='') and (TheNodeExt.ExtTxt3='') then begin
ANode:=TheNodeExt.Node;
if (ANode<>nil) and (ANode.Desc=ctnProcedure) then begin
ProcCode:=ExtractProcHead(ANode,ProcAttrDefToBody);
TheNodeExt.ExtTxt3:=ASourceChangeCache.BeautifyCodeOptions.BeautifyProc(
ProcCode,Indent,true);
end;
end;
end;
var var
ProcBodyNodes, ClassProcs: TAVLTree; ProcBodyNodes, ClassProcs: TAVLTree;
ANodeExt, ANodeExt2: TCodeTreeNodeExtension; ANodeExt, ANodeExt2: TCodeTreeNodeExtension;
@ -7562,7 +7579,7 @@ begin
MissingNode:=ClassProcs.FindHighest; MissingNode:=ClassProcs.FindHighest;
while (MissingNode<>nil) do begin while (MissingNode<>nil) do begin
ANodeExt:=TCodeTreeNodeExtension(MissingNode.Data); ANodeExt:=TCodeTreeNodeExtension(MissingNode.Data);
CheckForOverrideAndAddInheritedCode(ANodeExt); CreateCodeForMissingProcBody(ANodeExt,Indent);
InsertProcBody(ANodeExt,InsertPos,Indent); InsertProcBody(ANodeExt,InsertPos,Indent);
MissingNode:=ClassProcs.FindPrecessor(MissingNode); MissingNode:=ClassProcs.FindPrecessor(MissingNode);
end; end;
@ -7652,7 +7669,7 @@ begin
end; end;
end; end;
end; end;
CheckForOverrideAndAddInheritedCode(ANodeExt); CreateCodeForMissingProcBody(ANodeExt,Indent);
InsertProcBody(ANodeExt,InsertPos,Indent); InsertProcBody(ANodeExt,InsertPos,Indent);
end; end;
MissingNode:=ClassProcs.FindPrecessor(MissingNode); MissingNode:=ClassProcs.FindPrecessor(MissingNode);

View File

@ -1467,7 +1467,7 @@ begin
NewNode:=CursorNode; NewNode:=CursorNode;
CleanCursorPos:=GetIdentStartPosition(Src,CleanCursorPos); CleanCursorPos:=GetIdentStartPosition(Src,CleanCursorPos);
if CursorNode.Desc=ctnVarDefinition then begin if CursorNode.Desc=ctnVarDefinition then begin
// if this is is a parameter, try to find the corresponding declaration // if this is a parameter, try to find the corresponding declaration
NewNode:=FindCorrespondingProcParamNode(NewNode); NewNode:=FindCorrespondingProcParamNode(NewNode);
if (NewNode<>nil) and (NewNode.StartPos<CursorNode.StartPos) then if (NewNode<>nil) and (NewNode.StartPos<CursorNode.StartPos) then
CleanCursorPos:=NewNode.StartPos CleanCursorPos:=NewNode.StartPos
@ -5450,8 +5450,7 @@ begin
if (WithVarExpr.Desc<>xtContext) if (WithVarExpr.Desc<>xtContext)
or (WithVarExpr.Context.Node=nil) or (WithVarExpr.Context.Node=nil)
or (WithVarExpr.Context.Node=OldInput.ContextNode) or (WithVarExpr.Context.Node=OldInput.ContextNode)
or (not (WithVarExpr.Context.Node.Desc or (not (WithVarExpr.Context.Node.Desc in (AllClasses+[ctnEnumerationType])))
in (AllClasses+[ctnEnumerationType])))
then begin then begin
MoveCursorToCleanPos(WithVarNode.StartPos); MoveCursorToCleanPos(WithVarNode.StartPos);
RaiseException(ctsExprTypeMustBeClassOrRecord); RaiseException(ctsExprTypeMustBeClassOrRecord);