mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-23 20:00:03 +01:00
IDE: cleaned up msg quickfixes
git-svn-id: trunk@36464 -
This commit is contained in:
parent
972e7f61ff
commit
a3b86d11f7
@ -366,7 +366,7 @@ type
|
|||||||
property UpdateNeeded: boolean read FUpdateNeeded write SetUpdateNeeded;
|
property UpdateNeeded: boolean read FUpdateNeeded write SetUpdateNeeded;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQuickFixIdentifierNotFound_Search }
|
{ TQuickFixIdentifierNotFound_Search - add menu item to open codebrowser }
|
||||||
|
|
||||||
TQuickFixIdentifierNotFound_Search = class(TIDEMsgQuickFixItem)
|
TQuickFixIdentifierNotFound_Search = class(TIDEMsgQuickFixItem)
|
||||||
public
|
public
|
||||||
@ -3244,7 +3244,7 @@ begin
|
|||||||
// get source position
|
// get source position
|
||||||
// (FPC reports position right after the unknown identifier
|
// (FPC reports position right after the unknown identifier
|
||||||
// for example right after FilenameIsAbsolute)
|
// for example right after FilenameIsAbsolute)
|
||||||
if not GetMsgLineFilename(Msg,CodeBuf,false) then exit;
|
if not GetMsgLineFile(Msg,CodeBuf,false) then exit;
|
||||||
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
||||||
if not LazarusIDE.BeginCodeTools then begin
|
if not LazarusIDE.BeginCodeTools then begin
|
||||||
DebugLn(['TQuickFixIdentifierNotFound_Search.Execute failed because IDE busy']);
|
DebugLn(['TQuickFixIdentifierNotFound_Search.Execute failed because IDE busy']);
|
||||||
|
|||||||
@ -113,7 +113,7 @@ type
|
|||||||
property MainOwnerName: string read FMainOwnerName;
|
property MainOwnerName: string read FMainOwnerName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQuickFixUnitNotFound_Search }
|
{ TQuickFixUnitNotFound_Search - add menu item to open this search dialog }
|
||||||
|
|
||||||
TQuickFixUnitNotFound_Search = class(TIDEMsgQuickFixItem)
|
TQuickFixUnitNotFound_Search = class(TIDEMsgQuickFixItem)
|
||||||
public
|
public
|
||||||
@ -122,7 +122,7 @@ type
|
|||||||
procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override;
|
procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQuickFixIncludeNotFound_Search }
|
{ TQuickFixIncludeNotFound_Search - add menu item to open this search dialog }
|
||||||
|
|
||||||
TQuickFixIncludeNotFound_Search = class(TIDEMsgQuickFixItem)
|
TQuickFixIncludeNotFound_Search = class(TIDEMsgQuickFixItem)
|
||||||
public
|
public
|
||||||
@ -180,7 +180,7 @@ begin
|
|||||||
if Step=imqfoMenuItem then begin
|
if Step=imqfoMenuItem then begin
|
||||||
DebugLn(['TQuickFixUnitNotFound_Search.Execute ']);
|
DebugLn(['TQuickFixUnitNotFound_Search.Execute ']);
|
||||||
// get source position
|
// get source position
|
||||||
if not GetMsgLineFilename(Msg,CodeBuf,false) then exit;
|
if not GetMsgLineFile(Msg,CodeBuf,false) then exit;
|
||||||
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
||||||
if not LazarusIDE.BeginCodeTools then begin
|
if not LazarusIDE.BeginCodeTools then begin
|
||||||
DebugLn(['TQuickFixUnitNotFound_Search.Execute failed because IDE busy']);
|
DebugLn(['TQuickFixUnitNotFound_Search.Execute failed because IDE busy']);
|
||||||
@ -650,7 +650,7 @@ begin
|
|||||||
if Step=imqfoMenuItem then begin
|
if Step=imqfoMenuItem then begin
|
||||||
DebugLn(['TQuickFixIncludeNotFound_Search.Execute ']);
|
DebugLn(['TQuickFixIncludeNotFound_Search.Execute ']);
|
||||||
// get source position
|
// get source position
|
||||||
if not GetMsgLineFilename(Msg,CodeBuf,false) then exit;
|
if not GetMsgLineFile(Msg,CodeBuf,false) then exit;
|
||||||
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
||||||
if not LazarusIDE.BeginCodeTools then begin
|
if not LazarusIDE.BeginCodeTools then begin
|
||||||
DebugLn(['TQuickFixIncludeNotFound_Search.Execute failed because IDE busy']);
|
DebugLn(['TQuickFixIncludeNotFound_Search.Execute failed because IDE busy']);
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
2. option: remove the method
|
2. option: remove the method
|
||||||
3. option: add a virtual method to the ancestor
|
3. option: add a virtual method to the ancestor
|
||||||
- complete function implementations with missing parameters
|
- complete function implementations with missing parameters
|
||||||
|
- private variable not used => remove
|
||||||
|
|
||||||
}
|
}
|
||||||
unit MsgQuickFixes;
|
unit MsgQuickFixes;
|
||||||
@ -54,7 +55,7 @@ type
|
|||||||
procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override;
|
procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQuickFixUnitNotFoundPosition }
|
{ TQuickFixUnitNotFoundPosition - improve message }
|
||||||
|
|
||||||
TQuickFixUnitNotFoundPosition = class(TIDEMsgQuickFixItem)
|
TQuickFixUnitNotFoundPosition = class(TIDEMsgQuickFixItem)
|
||||||
public
|
public
|
||||||
@ -63,7 +64,7 @@ type
|
|||||||
procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override;
|
procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQuickFixUnitNotFound_Remove }
|
{ TQuickFixUnitNotFound_Remove - add menu item to remove unit from uses section }
|
||||||
|
|
||||||
TQuickFixUnitNotFound_Remove = class(TIDEMsgQuickFixItem)
|
TQuickFixUnitNotFound_Remove = class(TIDEMsgQuickFixItem)
|
||||||
public
|
public
|
||||||
@ -114,8 +115,8 @@ procedure QuickFixParameterNotUsed(Sender: TObject; Step: TIMQuickFixStep;
|
|||||||
procedure QuickFixUnitNotUsed(Sender: TObject; Step: TIMQuickFixStep;
|
procedure QuickFixUnitNotUsed(Sender: TObject; Step: TIMQuickFixStep;
|
||||||
Msg: TIDEMessageLine);
|
Msg: TIDEMessageLine);
|
||||||
|
|
||||||
function GetMsgLineFilename(Msg: TIDEMessageLine;
|
function GetMsgLineFile(Msg: TIDEMessageLine;
|
||||||
out CodeBuf: TCodeBuffer; Quiet: boolean): boolean;
|
out CodeBuf: TCodeBuffer; Quiet: boolean): boolean;
|
||||||
|
|
||||||
procedure InitStandardIDEQuickFixItems;
|
procedure InitStandardIDEQuickFixItems;
|
||||||
procedure FreeStandardIDEQuickFixItems;
|
procedure FreeStandardIDEQuickFixItems;
|
||||||
@ -167,7 +168,7 @@ var
|
|||||||
OldChange: Boolean;
|
OldChange: Boolean;
|
||||||
begin
|
begin
|
||||||
if Step<>imqfoMenuItem then exit;
|
if Step<>imqfoMenuItem then exit;
|
||||||
if not GetMsgLineFilename(Msg,CodeBuf,false) then exit;
|
if not GetMsgLineFile(Msg,CodeBuf,false) then exit;
|
||||||
|
|
||||||
if not REMatches(Msg.Msg,'Unit "([a-z_0-9]+)" not used','I') then begin
|
if not REMatches(Msg.Msg,'Unit "([a-z_0-9]+)" not used','I') then begin
|
||||||
DebugLn('QuickFixUnitNotUsed invalid message ',Msg.Msg);
|
DebugLn('QuickFixUnitNotUsed invalid message ',Msg.Msg);
|
||||||
@ -195,7 +196,7 @@ begin
|
|||||||
Msg.Msg:='';
|
Msg.Msg:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetMsgLineFilename(Msg: TIDEMessageLine; out CodeBuf: TCodeBuffer;
|
function GetMsgLineFile(Msg: TIDEMessageLine; out CodeBuf: TCodeBuffer;
|
||||||
Quiet: boolean): boolean;
|
Quiet: boolean): boolean;
|
||||||
var
|
var
|
||||||
Filename: String;
|
Filename: String;
|
||||||
@ -294,6 +295,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
MissingUnitname:=REVar(1);
|
MissingUnitname:=REVar(1);
|
||||||
|
CodeBuf:=nil;
|
||||||
if REMatches(Msg.Msg,'Can''t find unit ([a-z_.0-9]+) used by ([a-z_.0-9]+)','I')
|
if REMatches(Msg.Msg,'Can''t find unit ([a-z_.0-9]+) used by ([a-z_.0-9]+)','I')
|
||||||
then begin
|
then begin
|
||||||
UsedByUnit:=REVar(2);
|
UsedByUnit:=REVar(2);
|
||||||
@ -314,37 +316,39 @@ begin
|
|||||||
if NewFilename='' then begin
|
if NewFilename='' then begin
|
||||||
DebugLn('QuickFixUnitNotFoundPosition unit not found: ',UsedByUnit);
|
DebugLn('QuickFixUnitNotFoundPosition unit not found: ',UsedByUnit);
|
||||||
//ShowError('QuickFix: UnitNotFoundPosition unit not found: '+UsedByUnit);
|
//ShowError('QuickFix: UnitNotFoundPosition unit not found: '+UsedByUnit);
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
CodeBuf:=CodeToolBoss.LoadFile(NewFilename,false,false);
|
if NewFilename<>'' then begin
|
||||||
if CodeBuf=nil then begin
|
CodeBuf:=CodeToolBoss.LoadFile(NewFilename,false,false);
|
||||||
DebugLn('QuickFixUnitNotFoundPosition unable to load unit: ',NewFilename);
|
if CodeBuf=nil then begin
|
||||||
//ShowError('QuickFix: UnitNotFoundPosition unable to load unit: '+NewFilename);
|
DebugLn('QuickFixUnitNotFoundPosition unable to load unit: ',NewFilename);
|
||||||
exit;
|
//ShowError('QuickFix: UnitNotFoundPosition unable to load unit: '+NewFilename);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if CodeBuf=nil then exit;
|
if CodeBuf<>nil then begin
|
||||||
|
debugln(['TQuickFixUnitNotFoundPosition.Execute File=',CodeBuf.Filename]);
|
||||||
|
LazarusIDE.SaveSourceEditorChangesToCodeCache(nil);
|
||||||
|
if not CodeToolBoss.FindUnitInAllUsesSections(CodeBuf,MissingUnitname,NamePos,InPos)
|
||||||
|
then begin
|
||||||
|
DebugLn('QuickFixUnitNotFoundPosition failed due to syntax errors or '+MissingUnitname+' is not used in '+CodeBuf.Filename);
|
||||||
|
//LazarusIDE.DoJumpToCodeToolBossError;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
Tool:=CodeToolBoss.CurCodeTool;
|
||||||
|
if Tool=nil then exit;
|
||||||
|
if not Tool.CleanPosToCaret(NamePos,Caret) then exit;
|
||||||
|
if (Caret.X>0) and (Caret.Y>0) then begin
|
||||||
|
//DebugLn('QuickFixUnitNotFoundPosition Line=',dbgs(Line),' Col=',dbgs(Col));
|
||||||
|
NewFilename:=Caret.Code.Filename;
|
||||||
|
if (Msg.Directory<>'') and (FilenameIsAbsolute(Msg.Directory)) then
|
||||||
|
NewFilename:=CreateRelativePath(NewFilename,Msg.Directory);
|
||||||
|
Msg.SetSourcePosition(NewFilename,Caret.Y,Caret.X);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
debugln(['TQuickFixUnitNotFoundPosition.Execute File=',CodeBuf.Filename]);
|
|
||||||
LazarusIDE.SaveSourceEditorChangesToCodeCache(nil);
|
|
||||||
if not CodeToolBoss.FindUnitInAllUsesSections(CodeBuf,MissingUnitname,NamePos,InPos)
|
|
||||||
then begin
|
|
||||||
DebugLn('QuickFixUnitNotFoundPosition failed due to syntax errors or '+MissingUnitname+' is not used in '+CodeBuf.Filename);
|
|
||||||
//LazarusIDE.DoJumpToCodeToolBossError;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
Tool:=CodeToolBoss.CurCodeTool;
|
|
||||||
if Tool=nil then exit;
|
|
||||||
if not Tool.CleanPosToCaret(NamePos,Caret) then exit;
|
|
||||||
if (Caret.X>0) and (Caret.Y>0) then begin
|
|
||||||
//DebugLn('QuickFixUnitNotFoundPosition Line=',dbgs(Line),' Col=',dbgs(Col));
|
|
||||||
NewFilename:=Caret.Code.Filename;
|
|
||||||
if (Msg.Directory<>'') and (FilenameIsAbsolute(Msg.Directory)) then
|
|
||||||
NewFilename:=CreateRelativePath(NewFilename,Msg.Directory);
|
|
||||||
Msg.SetSourcePosition(NewFilename,Caret.Y,Caret.X);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQuickFixLinkerUndefinedReference }
|
{ TQuickFixLinkerUndefinedReference }
|
||||||
@ -508,7 +512,7 @@ begin
|
|||||||
// get source position
|
// get source position
|
||||||
// (FPC reports position right after the constructor call
|
// (FPC reports position right after the constructor call
|
||||||
// for example right after TStrings.Create)
|
// for example right after TStrings.Create)
|
||||||
if not GetMsgLineFilename(Msg,CodeBuf,false) then exit;
|
if not GetMsgLineFile(Msg,CodeBuf,false) then exit;
|
||||||
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
||||||
if not LazarusIDE.BeginCodeTools then begin
|
if not LazarusIDE.BeginCodeTools then begin
|
||||||
DebugLn(['TQuickFixClassWithAbstractMethods.Execute failed because IDE busy']);
|
DebugLn(['TQuickFixClassWithAbstractMethods.Execute failed because IDE busy']);
|
||||||
@ -630,7 +634,7 @@ begin
|
|||||||
// get source position
|
// get source position
|
||||||
// (FPC reports position right after the unknown identifier
|
// (FPC reports position right after the unknown identifier
|
||||||
// for example right after FilenameIsAbsolute)
|
// for example right after FilenameIsAbsolute)
|
||||||
if not GetMsgLineFilename(Msg,CodeBuf,false) then exit;
|
if not GetMsgLineFile(Msg,CodeBuf,false) then exit;
|
||||||
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
||||||
|
|
||||||
if not LazarusIDE.BeginCodeTools then begin
|
if not LazarusIDE.BeginCodeTools then begin
|
||||||
@ -714,7 +718,7 @@ begin
|
|||||||
if Step=imqfoMenuItem then begin
|
if Step=imqfoMenuItem then begin
|
||||||
DebugLn(['TQuickFixUnitNotFound_Remove.Execute ']);
|
DebugLn(['TQuickFixUnitNotFound_Remove.Execute ']);
|
||||||
// get source position
|
// get source position
|
||||||
if not GetMsgLineFilename(Msg,CodeBuf,false) then exit;
|
if not GetMsgLineFile(Msg,CodeBuf,false) then exit;
|
||||||
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
||||||
if not LazarusIDE.BeginCodeTools then begin
|
if not LazarusIDE.BeginCodeTools then begin
|
||||||
DebugLn(['TQuickFixUnitNotFound_Remove.Execute failed because IDE busy']);
|
DebugLn(['TQuickFixUnitNotFound_Remove.Execute failed because IDE busy']);
|
||||||
@ -795,7 +799,7 @@ begin
|
|||||||
if Step=imqfoMenuItem then begin
|
if Step=imqfoMenuItem then begin
|
||||||
DebugLn(['TQuickFixLocalVariableNotUsed_Remove.Execute ']);
|
DebugLn(['TQuickFixLocalVariableNotUsed_Remove.Execute ']);
|
||||||
// get source position
|
// get source position
|
||||||
if not GetMsgLineFilename(Msg,CodeBuf,false) then exit;
|
if not GetMsgLineFile(Msg,CodeBuf,false) then exit;
|
||||||
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
||||||
if not LazarusIDE.BeginCodeTools then begin
|
if not LazarusIDE.BeginCodeTools then begin
|
||||||
DebugLn(['TQuickFixLocalVariableNotUsed_Remove.Execute failed because IDE busy']);
|
DebugLn(['TQuickFixLocalVariableNotUsed_Remove.Execute failed because IDE busy']);
|
||||||
@ -865,7 +869,7 @@ begin
|
|||||||
if Step=imqfoMenuItem then begin
|
if Step=imqfoMenuItem then begin
|
||||||
DebugLn(['TQuickFixHint_Hide.Execute ']);
|
DebugLn(['TQuickFixHint_Hide.Execute ']);
|
||||||
// get source position
|
// get source position
|
||||||
if not GetMsgLineFilename(Msg,CodeBuf,false) then exit;
|
if not GetMsgLineFile(Msg,CodeBuf,false) then exit;
|
||||||
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
Msg.GetSourcePosition(Filename,Caret.Y,Caret.X);
|
||||||
if not LazarusIDE.BeginCodeTools then begin
|
if not LazarusIDE.BeginCodeTools then begin
|
||||||
DebugLn(['TQuickFixHint_Hide.Execute failed because IDE busy']);
|
DebugLn(['TQuickFixHint_Hide.Execute failed because IDE busy']);
|
||||||
|
|||||||
@ -579,6 +579,8 @@ begin
|
|||||||
Parts.Values['Line']:=IntToStr(LineNumber);
|
Parts.Values['Line']:=IntToStr(LineNumber);
|
||||||
if Column>0 then
|
if Column>0 then
|
||||||
Parts.Values['Column']:=IntToStr(Column);
|
Parts.Values['Column']:=IntToStr(Column);
|
||||||
|
if ExtractFilePath(Filename)<>'' then
|
||||||
|
Directory:=ExtractFilePath(Filename);
|
||||||
end;
|
end;
|
||||||
BracketOpenPos:=System.Pos('(',Msg);
|
BracketOpenPos:=System.Pos('(',Msg);
|
||||||
if (BracketOpenPos>0) then begin
|
if (BracketOpenPos>0) then begin
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user