mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 15:09:28 +02:00
IDE: quickfixes: use first fit
git-svn-id: trunk@45314 -
This commit is contained in:
parent
6198e17b19
commit
22d2d30164
@ -389,7 +389,7 @@ var
|
||||
Identifier: string;
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to Fixes.Count-1 do begin
|
||||
for i:=0 to Fixes.LineCount-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,Identifier) then continue;
|
||||
Fixes.AddMenuItem(Self,Msg,'Show Cody Dictionary for "'+Identifier+'"');
|
||||
@ -401,16 +401,11 @@ procedure TQuickFixIdentifierNotFoundShowDictionary.QuickFix(
|
||||
Fixes: TMsgQuickFixes; Msg: TMessageLine);
|
||||
var
|
||||
Identifier: string;
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to Fixes.Count-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,Identifier) then continue;
|
||||
if LazarusIDE.DoOpenFileAndJumpToPos(Msg.GetFullFilename,
|
||||
Point(Msg.Column,Msg.Line),-1,-1,-1,[])<>mrOk then exit;
|
||||
ShowUnitDictionaryDialog(nil);
|
||||
exit;
|
||||
end;
|
||||
if not IsApplicable(Msg,Identifier) then exit;
|
||||
if LazarusIDE.DoOpenFileAndJumpToPos(Msg.GetFullFilename,
|
||||
Point(Msg.Column,Msg.Line),-1,-1,-1,[])<>mrOk then exit;
|
||||
ShowUnitDictionaryDialog(nil);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
@ -3246,11 +3246,14 @@ procedure TQuickFixIdentifierNotFound_Search.CreateMenuItems(
|
||||
var
|
||||
Msg: TMessageLine;
|
||||
Identifier: string;
|
||||
i: Integer;
|
||||
begin
|
||||
if Fixes.LineCount<>1 then exit;
|
||||
Msg:=Fixes.Lines[0];
|
||||
if not IsApplicable(Msg,Identifier) then exit;
|
||||
Fixes.AddMenuItem(Self,Msg,lisQuickFixSearchIdentifier);
|
||||
for i:=0 to Fixes.LineCount-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,Identifier) then continue;
|
||||
Fixes.AddMenuItem(Self,Msg,lisQuickFixSearchIdentifier);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQuickFixIdentifierNotFound_Search.QuickFix(Fixes: TMsgQuickFixes;
|
||||
|
@ -70,7 +70,7 @@ type
|
||||
|
||||
TQuickFixIdentifierNotFoundAddLocal = class(TMsgQuickFix)
|
||||
public
|
||||
function IsApplicable(Msg: TMessageLine): boolean;
|
||||
function IsApplicable(Msg: TMessageLine; out Identifier: string): boolean;
|
||||
procedure CreateMenuItems(Fixes: TMsgQuickFixes); override;
|
||||
procedure QuickFix(Fixes: TMsgQuickFixes; Msg: TMessageLine); override;
|
||||
end;
|
||||
@ -213,11 +213,14 @@ procedure TQuickFixLocalVariableNotUsed_Remove.CreateMenuItems(
|
||||
var
|
||||
Msg: TMessageLine;
|
||||
Identifier: String;
|
||||
i: Integer;
|
||||
begin
|
||||
if Fixes.LineCount<>1 then exit;
|
||||
Msg:=Fixes.Lines[0];
|
||||
if not IsApplicable(Msg,Identifier) then exit;
|
||||
Fixes.AddMenuItem(Self,Msg,'Remove local variable "'+Identifier+'"');
|
||||
for i:=0 to Fixes.LineCount-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,Identifier) then continue;
|
||||
Fixes.AddMenuItem(Self,Msg,'Remove local variable "'+Identifier+'"');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQuickFixLocalVariableNotUsed_Remove.QuickFix(Fixes: TMsgQuickFixes;
|
||||
@ -271,11 +274,14 @@ var
|
||||
Msg: TMessageLine;
|
||||
aClassName: string;
|
||||
aMethodName: string;
|
||||
i: Integer;
|
||||
begin
|
||||
if Fixes.LineCount<>1 then exit;
|
||||
Msg:=Fixes.Lines[0];
|
||||
if not IsApplicable(Msg,aClassName,aMethodName) then exit;
|
||||
Fixes.AddMenuItem(Self,Msg,'Show abstract methods of "'+aClassName+'"');
|
||||
for i:=0 to Fixes.LineCount-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,aClassName,aMethodName) then continue;
|
||||
Fixes.AddMenuItem(Self,Msg,'Show abstract methods of "'+aClassName+'"');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQuickFixClassWithAbstractMethods.QuickFix(Fixes: TMsgQuickFixes;
|
||||
@ -365,11 +371,14 @@ var
|
||||
Msg: TMessageLine;
|
||||
MissingUnitName: string;
|
||||
UsedByUnit: string;
|
||||
i: Integer;
|
||||
begin
|
||||
if Fixes.LineCount<>1 then exit;
|
||||
Msg:=Fixes.Lines[0];
|
||||
if not IsApplicable(Msg,MissingUnitName,UsedByUnit) then exit;
|
||||
Fixes.AddMenuItem(Self,Msg,'Remove uses "'+MissingUnitName+'"');
|
||||
for i:=0 to Fixes.LineCount-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,MissingUnitName,UsedByUnit) then continue;
|
||||
Fixes.AddMenuItem(Self,Msg,'Remove uses "'+MissingUnitName+'"');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQuickFixUnitNotFound_Remove.QuickFix(Fixes: TMsgQuickFixes;
|
||||
@ -405,17 +414,17 @@ end;
|
||||
|
||||
{ TQuickFixIdentifierNotFoundAddLocal }
|
||||
|
||||
function TQuickFixIdentifierNotFoundAddLocal.IsApplicable(Msg: TMessageLine
|
||||
): boolean;
|
||||
function TQuickFixIdentifierNotFoundAddLocal.IsApplicable(Msg: TMessageLine;
|
||||
out Identifier: string): boolean;
|
||||
var
|
||||
Code: TCodeBuffer;
|
||||
Tool: TCodeTool;
|
||||
CleanPos: integer;
|
||||
Node: TCodeTreeNode;
|
||||
Identifier: String;
|
||||
Dummy: string;
|
||||
begin
|
||||
Result:=false;
|
||||
Identifier:='';
|
||||
// check: identifier not found "$1"
|
||||
if not IDEFPCParser.MsgLineIsId(Msg,5000,Identifier,Dummy) then
|
||||
exit;
|
||||
@ -445,14 +454,15 @@ procedure TQuickFixIdentifierNotFoundAddLocal.CreateMenuItems(
|
||||
var
|
||||
Msg: TMessageLine;
|
||||
Identifier: String;
|
||||
i: Integer;
|
||||
begin
|
||||
if Fixes.LineCount<>1 then exit;
|
||||
Msg:=Fixes.Lines[0];
|
||||
if not IsApplicable(Msg) then exit;
|
||||
Identifier:=IDEFPCParser.GetFPCMsgValue1(Msg);
|
||||
if Identifier='' then exit;
|
||||
Fixes.AddMenuItem(Self,Msg,'Create local variable "'+Identifier+'"');
|
||||
// ToDo: add private/public variable
|
||||
for i:=0 to Fixes.LineCount-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,Identifier) then continue;
|
||||
Fixes.AddMenuItem(Self,Msg,'Create local variable "'+Identifier+'"');
|
||||
// ToDo: add private/public variable
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQuickFixIdentifierNotFoundAddLocal.QuickFix(Fixes: TMsgQuickFixes;
|
||||
@ -465,9 +475,7 @@ var
|
||||
NewY: integer;
|
||||
NewTopLine: integer;
|
||||
begin
|
||||
if Msg=nil then exit;
|
||||
Identifier:=IDEFPCParser.GetFPCMsgValue1(Msg);
|
||||
if Identifier='' then exit;
|
||||
if not IsApplicable(Msg,Identifier) then exit;
|
||||
|
||||
if not LazarusIDE.BeginCodeTools then begin
|
||||
DebugLn(['TQuickFixIdentifierNotFoundAddLocal.Execute failed because IDE busy']);
|
||||
|
@ -198,11 +198,14 @@ var
|
||||
Msg: TMessageLine;
|
||||
MissingUnit: string;
|
||||
UsedByUnit: string;
|
||||
i: Integer;
|
||||
begin
|
||||
if Fixes.LineCount<>1 then exit;
|
||||
Msg:=Fixes.Lines[0];
|
||||
if not IsApplicable(Msg,MissingUnit,UsedByUnit) then exit;
|
||||
Fixes.AddMenuItem(Self,Msg,'Search Unit "'+MissingUnit+'"');
|
||||
for i:=0 to Fixes.LineCount-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,MissingUnit,UsedByUnit) then continue;
|
||||
Fixes.AddMenuItem(Self,Msg,'Search Unit "'+MissingUnit+'"');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQuickFixUnitNotFound_Search.QuickFix(Fixes: TMsgQuickFixes;
|
||||
@ -721,11 +724,14 @@ procedure TQuickFixIncludeNotFound_Search.CreateMenuItems(Fixes: TMsgQuickFixes
|
||||
var
|
||||
IncludeFile: string;
|
||||
Msg: TMessageLine;
|
||||
i: Integer;
|
||||
begin
|
||||
if Fixes.LineCount<>1 then exit;
|
||||
Msg:=Fixes.Lines[0];
|
||||
if not IsApplicable(Msg,IncludeFile) then exit;
|
||||
Fixes.AddMenuItem(Self,Msg,'Search Include File "'+ExtractFilename(IncludeFile)+'"');
|
||||
for i:=0 to Fixes.LineCount-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,IncludeFile) then continue;
|
||||
Fixes.AddMenuItem(Self,Msg,'Search Include File "'+ExtractFilename(IncludeFile)+'"');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQuickFixIncludeNotFound_Search.QuickFix(Fixes: TMsgQuickFixes;
|
||||
|
@ -430,11 +430,14 @@ var
|
||||
Msg: TMessageLine;
|
||||
Unitname1: string;
|
||||
Unitname2: string;
|
||||
i: Integer;
|
||||
begin
|
||||
if Fixes.LineCount<>1 then exit;
|
||||
Msg:=Fixes.Lines[0];
|
||||
if not IsApplicable(Msg,Unitname1,Unitname2) then exit;
|
||||
Fixes.AddMenuItem(Self,Msg,'Explore message "checksum changed"');
|
||||
for i:=0 to Fixes.LineCount-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,Unitname1,Unitname2) then continue;
|
||||
Fixes.AddMenuItem(Self,Msg,'Explore message "checksum changed"');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQuickFixRecompilingChecksumChanged.QuickFix(Fixes: TMsgQuickFixes;
|
||||
@ -444,7 +447,6 @@ var
|
||||
Unit2: String;
|
||||
Dlg: TInspectChksumChgDialog;
|
||||
begin
|
||||
debugln(['TQuickFixRecompilingChecksumChanged.Execute ']);
|
||||
if not IsApplicable(Msg,Unit1,Unit2) then exit;
|
||||
debugln(['TQuickFixRecompilingChecksumChanged.Execute Unit1=',REVar(1),', checksum changed for Unit2=',REVar(2)]);
|
||||
Dlg:=TInspectChksumChgDialog.Create(nil);
|
||||
|
@ -440,11 +440,14 @@ var
|
||||
Msg: TMessageLine;
|
||||
Unitname1: string;
|
||||
Unitname2: string;
|
||||
i: Integer;
|
||||
begin
|
||||
if Fixes.LineCount<>1 then exit;
|
||||
Msg:=Fixes.Lines[0];
|
||||
if not IsApplicable(Msg,Unitname1,Unitname2) then exit;
|
||||
Fixes.AddMenuItem(Self,Msg,'Show unit dependencies');
|
||||
for i:=0 to Fixes.LineCount-1 do begin
|
||||
Msg:=Fixes.Lines[i];
|
||||
if not IsApplicable(Msg,Unitname1,Unitname2) then continue;
|
||||
Fixes.AddMenuItem(Self,Msg,'Show unit dependencies');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TQuickFixCircularUnitReference.QuickFix(Fixes: TMsgQuickFixes;
|
||||
|
Loading…
Reference in New Issue
Block a user