mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-04 12:58:15 +02:00
cody: declare var: switch back to src
git-svn-id: trunk@30842 -
This commit is contained in:
parent
53866fee38
commit
78a0a9a879
@ -5439,7 +5439,7 @@ begin
|
||||
// apply the changes
|
||||
if not SourceChangeCache.Apply then
|
||||
RaiseException(ctsUnableToApplyChanges);
|
||||
exit;
|
||||
exit(true);
|
||||
end;
|
||||
Node:=Node.Parent;
|
||||
end;
|
||||
|
@ -34,7 +34,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, contnrs, LResources, Forms, Controls, Graphics,
|
||||
Dialogs, ButtonPanel, StdCtrls, ExtCtrls,
|
||||
IDEDialogs, LazIDEIntf,
|
||||
IDEDialogs, LazIDEIntf, SrcEditorIntf,
|
||||
FileProcs, CodeToolManager, FindDeclarationTool, CodeTree,
|
||||
KeywordFuncLists, BasicCodeTools, CodeAtom,
|
||||
CodyUtils, CodyStrConsts;
|
||||
@ -198,8 +198,6 @@ end;
|
||||
procedure TCodyDeclareVarDialog.OKButtonClick(Sender: TObject);
|
||||
var
|
||||
NewType: TCaption;
|
||||
Target: TCodyDeclareVarTarget;
|
||||
OldChange: boolean;
|
||||
begin
|
||||
NewType:=Trim(TypeEdit.Text);
|
||||
if NewType='' then begin
|
||||
@ -214,22 +212,6 @@ begin
|
||||
IDEMessageDialog('Error','Please specify a location',mtError,[mbCancel]);
|
||||
exit;
|
||||
end;
|
||||
Target:=TCodyDeclareVarTarget(Targets[WhereRadioGroup.ItemIndex]);
|
||||
|
||||
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
|
||||
try
|
||||
LazarusIDE.OpenEditorsOnCodeToolChange:=true;
|
||||
if not CodeToolBoss.DeclareVariable(Target.NodeStartPos.Code,
|
||||
Target.NodeStartPos.X,Target.NodeStartPos.Y,
|
||||
Identifier,RecommendedType,UnitOfType,Target.Visibility)
|
||||
then begin
|
||||
LazarusIDE.DoJumpToCodeToolBossError;
|
||||
ModalResult:=mrCancel;
|
||||
exit;
|
||||
end;
|
||||
finally
|
||||
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
|
||||
end;
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
@ -265,6 +247,9 @@ var
|
||||
Target: TCodyDeclareVarTarget;
|
||||
Context: TFindContext;
|
||||
i: Integer;
|
||||
OldChange: boolean;
|
||||
OldSrcEdit: TSourceEditorInterface;
|
||||
NewType: String;
|
||||
begin
|
||||
Result:=false;
|
||||
PossibleContexts:=nil;
|
||||
@ -274,10 +259,6 @@ begin
|
||||
RecommendedType,UnitOfType,PossibleContexts)
|
||||
then exit;
|
||||
|
||||
// ToDo: target interface
|
||||
// ToDo: target implementation
|
||||
// ToDo: target global (program)
|
||||
|
||||
if PossibleContexts<>nil then begin
|
||||
for i:=0 to PossibleContexts.Count-1 do begin
|
||||
Context:=PFindContext(PossibleContexts[i])^;
|
||||
@ -308,6 +289,32 @@ begin
|
||||
WhereRadioGroup.ItemIndex:=0;
|
||||
|
||||
Result:=ShowModal=mrOk;
|
||||
if Result then begin
|
||||
NewType:=Trim(TypeEdit.Text);
|
||||
Target:=TCodyDeclareVarTarget(Targets[WhereRadioGroup.ItemIndex]);
|
||||
|
||||
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
|
||||
try
|
||||
OldSrcEdit:=SourceEditorManagerIntf.ActiveEditor;
|
||||
LazarusIDE.OpenEditorsOnCodeToolChange:=true;
|
||||
if not CodeToolBoss.DeclareVariable(Target.NodeStartPos.Code,
|
||||
Target.NodeStartPos.X,Target.NodeStartPos.Y,
|
||||
Identifier,NewType,UnitOfType,Target.Visibility)
|
||||
then begin
|
||||
debugln(['TCodyDeclareVarDialog.Run Error']);
|
||||
LazarusIDE.DoJumpToCodeToolBossError;
|
||||
ModalResult:=mrCancel;
|
||||
exit;
|
||||
end;
|
||||
if Target.NodeStartPos.Code<>CodePos.Code then begin
|
||||
// declaration was in another unit => switch back to cursor
|
||||
//debugln(['TCodyDeclareVarDialog.OKButtonClick switching back to ',OldSrcEdit.FileName]);
|
||||
SourceEditorManagerIntf.ActiveEditor:=OldSrcEdit;
|
||||
end;
|
||||
finally
|
||||
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user