IDE: quickfixes: auto open changed units, bug #32284

git-svn-id: branches/fixes_1_8@55700 -
This commit is contained in:
mattias 2017-08-19 13:13:46 +00:00
parent 10cd94e815
commit a1d014b662
2 changed files with 72 additions and 32 deletions

View File

@ -95,7 +95,7 @@ type
procedure QuickFix({%H-}Fixes: TMsgQuickFixes; Msg: TMessageLine); override; procedure QuickFix({%H-}Fixes: TMsgQuickFixes; Msg: TMessageLine); override;
end; end;
{ TQuickFixUnitNotFound_Remove } { TQuickFixUnitNotFound_Remove, also "unit not used" }
TQuickFixUnitNotFound_Remove = class(TMsgQuickFix) TQuickFixUnitNotFound_Remove = class(TMsgQuickFix)
public public
@ -327,6 +327,7 @@ var
Tool: TCodeTool; Tool: TCodeTool;
Code: TCodeBuffer; Code: TCodeBuffer;
Comment: String; Comment: String;
OldChange: Boolean;
begin begin
if not IsApplicable(Msg,MsgID,Tool) then exit; if not IsApplicable(Msg,MsgID,Tool) then exit;
@ -341,6 +342,9 @@ begin
exit; exit;
end; end;
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
LazarusIDE.OpenEditorsOnCodeToolChange:=true;
try
Comment:=' : '+TIDEFPCParser.GetFPCMsgPattern(Msg); Comment:=' : '+TIDEFPCParser.GetFPCMsgPattern(Msg);
if not CodeToolBoss.AddUnitWarnDirective(Code,IntToStr(MsgID),Comment,true) then if not CodeToolBoss.AddUnitWarnDirective(Code,IntToStr(MsgID),Comment,true) then
begin begin
@ -348,6 +352,9 @@ begin
LazarusIDE.DoJumpToCodeToolBossError; LazarusIDE.DoJumpToCodeToolBossError;
exit; exit;
end; end;
finally
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
end;
// success // success
Msg.MarkFixed; Msg.MarkFixed;
@ -626,6 +633,7 @@ procedure TQuickFixLocalVariableNotUsed_Remove.QuickFix(Fixes: TMsgQuickFixes;
var var
Identifier: String; Identifier: String;
Code: TCodeBuffer; Code: TCodeBuffer;
OldChange: Boolean;
begin begin
if not IsApplicable(Msg,Identifier) then exit; if not IsApplicable(Msg,Identifier) then exit;
@ -637,12 +645,18 @@ begin
Code:=CodeToolBoss.LoadFile(Msg.GetFullFilename,true,false); Code:=CodeToolBoss.LoadFile(Msg.GetFullFilename,true,false);
if Code=nil then exit; if Code=nil then exit;
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
LazarusIDE.OpenEditorsOnCodeToolChange:=true;
try
if not CodeToolBoss.RemoveIdentifierDefinition(Code,Msg.Column,Msg.Line) then if not CodeToolBoss.RemoveIdentifierDefinition(Code,Msg.Column,Msg.Line) then
begin begin
DebugLn(['TQuickFixLocalVariableNotUsed_Remove remove failed']); DebugLn(['TQuickFixLocalVariableNotUsed_Remove remove failed']);
LazarusIDE.DoJumpToCodeToolBossError; LazarusIDE.DoJumpToCodeToolBossError;
exit; exit;
end; end;
finally
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
end;
// message fixed // message fixed
Msg.MarkFixed; Msg.MarkFixed;
@ -789,6 +803,7 @@ var
MissingUnitName: string; MissingUnitName: string;
SrcUnitName: string; SrcUnitName: string;
Code: TCodeBuffer; Code: TCodeBuffer;
OldChange: Boolean;
begin begin
if not IsApplicable(Msg,MissingUnitName,SrcUnitName) then begin if not IsApplicable(Msg,MissingUnitName,SrcUnitName) then begin
debugln(['TQuickFixUnitNotFound_Remove.QuickFix invalid message ',Msg.Msg]); debugln(['TQuickFixUnitNotFound_Remove.QuickFix invalid message ',Msg.Msg]);
@ -803,6 +818,9 @@ begin
Code:=CodeToolBoss.LoadFile(Msg.GetFullFilename,true,false); Code:=CodeToolBoss.LoadFile(Msg.GetFullFilename,true,false);
if Code=nil then exit; if Code=nil then exit;
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
LazarusIDE.OpenEditorsOnCodeToolChange:=true;
try
if not CodeToolBoss.RemoveUnitFromAllUsesSections(Code,MissingUnitName) then if not CodeToolBoss.RemoveUnitFromAllUsesSections(Code,MissingUnitName) then
begin begin
DebugLn(['TQuickFixUnitNotFound_Remove RemoveUnitFromAllUsesSections failed']); DebugLn(['TQuickFixUnitNotFound_Remove RemoveUnitFromAllUsesSections failed']);
@ -812,6 +830,9 @@ begin
// success // success
Msg.MarkFixed; Msg.MarkFixed;
finally
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
end;
end; end;
{ TQuickFixIdentifierNotFoundAddLocal } { TQuickFixIdentifierNotFoundAddLocal }
@ -868,6 +889,7 @@ var
NewX: integer; NewX: integer;
NewY: integer; NewY: integer;
NewTopLine: integer; NewTopLine: integer;
OldChange: Boolean;
begin begin
if not IsApplicable(Msg,Identifier) then exit; if not IsApplicable(Msg,Identifier) then exit;
@ -879,12 +901,18 @@ begin
Code:=CodeToolBoss.LoadFile(Msg.GetFullFilename,true,false); Code:=CodeToolBoss.LoadFile(Msg.GetFullFilename,true,false);
if Code=nil then exit; if Code=nil then exit;
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
LazarusIDE.OpenEditorsOnCodeToolChange:=true;
try
if not CodeToolBoss.CreateVariableForIdentifier(Code,Msg.Column,Msg.Line,-1, if not CodeToolBoss.CreateVariableForIdentifier(Code,Msg.Column,Msg.Line,-1,
NewCode,NewX,NewY,NewTopLine,False) NewCode,NewX,NewY,NewTopLine,False)
then begin then begin
LazarusIDE.DoJumpToCodeToolBossError; LazarusIDE.DoJumpToCodeToolBossError;
exit; exit;
end; end;
finally
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
end;
// success // success
Msg.MarkFixed; Msg.MarkFixed;
@ -929,7 +957,10 @@ var
Tree: TAvlTree; Tree: TAvlTree;
Node: TAvlTreeNode; Node: TAvlTreeNode;
i: Integer; i: Integer;
OldChange: Boolean;
begin begin
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
LazarusIDE.OpenEditorsOnCodeToolChange:=true;
Tree:=TAvlTree.Create(@CompareMsgLinesSrcPos); Tree:=TAvlTree.Create(@CompareMsgLinesSrcPos);
try try
// get all messages to hide and sort them for position // get all messages to hide and sort them for position
@ -957,6 +988,7 @@ begin
Node:=Node.Precessor; Node:=Node.Precessor;
end; end;
finally finally
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
Tree.Free; Tree.Free;
end; end;
end; end;

View File

@ -120,7 +120,12 @@ begin
end; end;
procedure TQFInitLocalVarDialog.ButtonPanel1OKButtonClick(Sender: TObject); procedure TQFInitLocalVarDialog.ButtonPanel1OKButtonClick(Sender: TObject);
var
OldChange: Boolean;
begin begin
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
LazarusIDE.OpenEditorsOnCodeToolChange:=true;
try
if CodeToolBoss.InsertStatements( if CodeToolBoss.InsertStatements(
TInsertStatementPosDescription(InsertPositions[Max(0,WhereRadioGroup.ItemIndex)]), TInsertStatementPosDescription(InsertPositions[Max(0,WhereRadioGroup.ItemIndex)]),
Statements[Max(0,ValueRadioGroup.ItemIndex)]) Statements[Max(0,ValueRadioGroup.ItemIndex)])
@ -129,6 +134,9 @@ begin
end else begin end else begin
ModalResult:=mrAbort; ModalResult:=mrAbort;
end; end;
finally
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
end;
end; end;
procedure TQFInitLocalVarDialog.Init(TheStatements: TStrings; procedure TQFInitLocalVarDialog.Init(TheStatements: TStrings;