implemented Quick Fix system

git-svn-id: trunk@8782 -
This commit is contained in:
mattias 2006-02-20 18:55:36 +00:00
parent d437ea67e0
commit 7f659b2099
11 changed files with 189 additions and 89 deletions

View File

@ -1,5 +1,3 @@
{ Dies ist eine automatisch erzeugte Lazarus-Ressourcendatei }
LazarusResources.Add('TMainForm','FORMDATA',[ LazarusResources.Add('TMainForm','FORMDATA',[
'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3'$'#1#6'Height'#3','#1#3'Top'#3#209#0 'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3'$'#1#6'Height'#3','#1#3'Top'#3#209#0
+#5'Width'#3#144#1#18'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'#3'+' +#5'Width'#3#144#1#18'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'#3'+'

View File

@ -1,5 +1,3 @@
{ Dies ist eine automatisch erzeugte Lazarus-Ressourcendatei }
LazarusResources.Add('TDockFormX','FORMDATA',[ LazarusResources.Add('TDockFormX','FORMDATA',[
'TPF0'#10'TDockFormX'#9'DockFormX'#4'Left'#3#234#1#6'Height'#2''#3'Top'#3#215 'TPF0'#10'TDockFormX'#9'DockFormX'#4'Left'#3#234#1#6'Height'#2''#3'Top'#3#215
+#0#5'Width'#3#224#0#18'HorzScrollBar.Page'#3#223#0#18'VertScrollBar.Page'#2 +#0#5'Width'#3#224#0#18'HorzScrollBar.Page'#3#223#0#18'VertScrollBar.Page'#2

View File

@ -2953,6 +2953,7 @@ resourcestring
lisPOSaveInIDEConfigDirectory = 'Save in IDE config directory'; lisPOSaveInIDEConfigDirectory = 'Save in IDE config directory';
lisPODoNotSaveAnySessionInfo = 'Do not save any session info'; lisPODoNotSaveAnySessionInfo = 'Do not save any session info';
lisPOSaveSessionInformationIn = 'Save session information in'; lisPOSaveSessionInformationIn = 'Save session information in';
lisMVSaveMessagesToFileTxt = 'Save messages to file (*.txt)';
implementation implementation
end. end.

View File

@ -30,11 +30,14 @@ unit MsgQuickFixes;
interface interface
uses uses
Classes, SysUtils, LCLProc, MsgIntf, LazarusIDEStrConsts; Classes, SysUtils, LCLProc, MsgIntf, TextTools, LazarusIDEStrConsts,
LazIDEIntf, CodeCache, CodeToolManager;
procedure QuickFixParameterNotUsed(Sender: TObject; Msg: TIDEMessageLine); procedure QuickFixParameterNotUsed(Sender: TObject; Msg: TIDEMessageLine);
procedure QuickFixUnitNotUsed(Sender: TObject; Msg: TIDEMessageLine); procedure QuickFixUnitNotUsed(Sender: TObject; Msg: TIDEMessageLine);
function GetMsgLineFilename(Msg: TIDEMessageLine;
out CodeBuf: TCodeBuffer): boolean;
procedure InitStandardIDEQuickFixItems; procedure InitStandardIDEQuickFixItems;
procedure FreeStandardIDEQuickFixItems; procedure FreeStandardIDEQuickFixItems;
@ -47,8 +50,46 @@ begin
end; end;
procedure QuickFixUnitNotUsed(Sender: TObject; Msg: TIDEMessageLine); procedure QuickFixUnitNotUsed(Sender: TObject; Msg: TIDEMessageLine);
var
CodeBuf: TCodeBuffer;
UnneededUnitname: String;
begin begin
DebugLn('QuickFixUnitNotUsed '); if not GetMsgLineFilename(Msg,CodeBuf) then exit;
if not REMatches(Msg.Msg,'Unit "([a-z_0-9]+)" not used','I') then begin
DebugLn('QuickFixUnitNotUsed invalid message ',Msg.Msg);
exit;
end;
UnneededUnitname:=REVar(1);
// remove unit
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1);
if not CodeToolBoss.RemoveUnitFromAllUsesSections(CodeBuf,UnneededUnitname)
then begin
LazarusIDE.DoJumpToCodeToolBossError;
end;
end;
function GetMsgLineFilename(Msg: TIDEMessageLine; out CodeBuf: TCodeBuffer
): boolean;
var
Filename: String;
begin
Result:=false;
CodeBuf:=nil;
if Msg.Parts=nil then begin
DebugLn('GetMsgLineFilename Msg.Parts=nil');
exit;
end;
Filename:=Msg.Parts.Values['Filename'];
DebugLn('GetMsgLineFilename Filename=',Filename,' ',Msg.Parts.Text);
CodeBuf:=CodeToolBoss.LoadFile(Filename,false,false);
if CodeBuf=nil then begin
DebugLn('GetMsgLineFilename Filename "',Filename,'" not found.');
exit;
end;
Result:=true;
end; end;
procedure InitStandardIDEQuickFixItems; procedure InitStandardIDEQuickFixItems;

View File

@ -1,5 +1,11 @@
object MessagesView: TMessagesView object MessagesView: TMessagesView
ActiveControl = MessageView Left = 262
Height = 79
Top = 518
Width = 722
HorzScrollBar.Page = 721
VertScrollBar.Page = 78
ActiveControl = MessageListBox
BorderStyle = bsSizeToolWin BorderStyle = bsSizeToolWin
Caption = 'MessagesView' Caption = 'MessagesView'
ClientHeight = 79 ClientHeight = 79
@ -7,22 +13,16 @@ object MessagesView: TMessagesView
KeyPreview = True KeyPreview = True
OnDeactivate = FormDeactivate OnDeactivate = FormDeactivate
OnKeyDown = MessagesViewKeyDown OnKeyDown = MessagesViewKeyDown
PixelsPerInch = 112 PixelsPerInch = 95
HorzScrollBar.Page = 721 object MessageListBox: TListBox
VertScrollBar.Page = 78
Left = 262
Height = 79 Height = 79
Top = 518
Width = 722 Width = 722
object MessageView: TListBox
Align = alClient Align = alClient
MultiSelect = True MultiSelect = True
OnExit = MessageViewExit OnExit = MessageViewExit
PopupMenu = MainPopupMenu PopupMenu = MainPopupMenu
TabOrder = 0 TabOrder = 0
TopIndex = -1 TopIndex = -1
Height = 79
Width = 722
end end
object MainPopupMenu: TPopupMenu object MainPopupMenu: TPopupMenu
OnPopup = MainPopupMenuPopup OnPopup = MainPopupMenuPopup

View File

@ -1,14 +1,14 @@
{ This is an automatically generated lazarus resource file } { This is an automatically generated lazarus resource file }
LazarusResources.Add('TMessagesView','FORMDATA',[ LazarusResources.Add('TMessagesView','FORMDATA',[
'TPF0'#13'TMessagesView'#12'MessagesView'#13'ActiveControl'#7#11'MessageView' 'TPF0'#13'TMessagesView'#12'MessagesView'#4'Left'#3#6#1#6'Height'#2'O'#3'Top'
+#11'BorderStyle'#7#13'bsSizeToolWin'#7'Caption'#6#12'MessagesView'#12'Client' +#3#6#2#5'Width'#3#210#2#18'HorzScrollBar.Page'#3#209#2#18'VertScrollBar.Page'
+'Height'#2'O'#11'ClientWidth'#3#210#2#10'KeyPreview'#9#12'OnDeactivate'#7#14 +#2'N'#13'ActiveControl'#7#14'MessageListBox'#11'BorderStyle'#7#13'bsSizeTool'
+'FormDeactivate'#9'OnKeyDown'#7#19'MessagesViewKeyDown'#13'PixelsPerInch'#2 +'Win'#7'Caption'#6#12'MessagesView'#12'ClientHeight'#2'O'#11'ClientWidth'#3
+'p'#18'HorzScrollBar.Page'#3#209#2#18'VertScrollBar.Page'#2'N'#4'Left'#3#6#1 +#210#2#10'KeyPreview'#9#12'OnDeactivate'#7#14'FormDeactivate'#9'OnKeyDown'#7
+#6'Height'#2'O'#3'Top'#3#6#2#5'Width'#3#210#2#0#8'TListBox'#11'MessageView'#5 +#19'MessagesViewKeyDown'#13'PixelsPerInch'#2'_'#0#8'TListBox'#14'MessageList'
+'Align'#7#8'alClient'#11'MultiSelect'#9#6'OnExit'#7#15'MessageViewExit'#9'Po' +'Box'#6'Height'#2'O'#5'Width'#3#210#2#5'Align'#7#8'alClient'#11'MultiSelect'
+'pupMenu'#7#13'MainPopupMenu'#8'TabOrder'#2#0#8'TopIndex'#2#255#6'Height'#2 +#9#6'OnExit'#7#15'MessageViewExit'#9'PopupMenu'#7#13'MainPopupMenu'#8'TabOrd'
+'O'#5'Width'#3#210#2#0#0#10'TPopupMenu'#13'MainPopupMenu'#7'OnPopup'#7#18'Ma' +'er'#2#0#8'TopIndex'#2#255#0#0#10'TPopupMenu'#13'MainPopupMenu'#7'OnPopup'#7
+'inPopupMenuPopup'#4'left'#2'.'#3'top'#2')'#0#0#0 +#18'MainPopupMenuPopup'#4'left'#2'.'#3'top'#2')'#0#0#0
]); ]);

View File

@ -63,7 +63,7 @@ type
{ TMessagesView } { TMessagesView }
TMessagesView = class(TForm) TMessagesView = class(TForm)
MessageView: TListBox; MessageListBox: TListBox;
MainPopupMenu: TPopupMenu; MainPopupMenu: TPopupMenu;
procedure CopyAllMenuItemClick(Sender: TObject); procedure CopyAllMenuItemClick(Sender: TObject);
procedure CopyAllAndHiddenMenuItemClick(Sender: TObject); procedure CopyAllAndHiddenMenuItemClick(Sender: TObject);
@ -221,8 +221,8 @@ begin
FLastSelectedIndex := -1; FLastSelectedIndex := -1;
Caption := lisMenuViewMessages; Caption := lisMenuViewMessages;
MessageView.Style := lbOwnerDrawFixed; MessageListBox.Style := lbOwnerDrawFixed;
MessageView.OnDrawItem := @MessageViewDrawItem; MessageListBox.OnDrawItem := @MessageViewDrawItem;
// assign the root TMenuItem to the registered menu root. // assign the root TMenuItem to the registered menu root.
// This will automatically create all registered items // This will automatically create all registered items
@ -260,7 +260,7 @@ begin
VisibleIndex := Line.VisiblePosition; VisibleIndex := Line.VisiblePosition;
if VisibleIndex >= 0 then if VisibleIndex >= 0 then
begin begin
MessageView.Items.Delete(VisibleIndex); MessageListBox.Items.Delete(VisibleIndex);
FVisibleItems.Delete(VisibleIndex); FVisibleItems.Delete(VisibleIndex);
end; end;
Line.Free; Line.Free;
@ -282,14 +282,26 @@ procedure TMessagesView.Add(const Msg, CurDir: string;
var var
NewMsg: TIDEMessageLine; NewMsg: TIDEMessageLine;
i: integer; i: integer;
LastItem: TIDEMessageLine;
begin begin
NewMsg:=nil;
if ItemCount>0 then begin
LastItem:=Items[ItemCount-1];
if LastItem.OriginalIndex=OriginalIndex then begin
// already added
NewMsg:=LastItem;
end;
end;
if NewMsg=nil then begin
NewMsg := TIDEMessageLine.Create; NewMsg := TIDEMessageLine.Create;
FItems.Add(NewMsg);
end;
NewMsg.Msg := Msg; NewMsg.Msg := Msg;
NewMsg.Directory := CurDir; NewMsg.Directory := CurDir;
NewMsg.Position := FItems.Count; NewMsg.Position := FItems.Count;
NewMsg.OriginalIndex := OriginalIndex; NewMsg.OriginalIndex := OriginalIndex;
//DebugLn('TMessagesView.Add FItems.Count=',dbgs(FItems.Count),' OriginalIndex=',dbgs(OriginalIndex)); //DebugLn('TMessagesView.Add FItems.Count=',dbgs(FItems.Count),' OriginalIndex=',dbgs(OriginalIndex));
FItems.Add(NewMsg);
if VisibleLine then if VisibleLine then
begin begin
@ -299,15 +311,15 @@ begin
i := FVisibleItems.Count - 1; i := FVisibleItems.Count - 1;
VisibleItems[i].VisiblePosition := -1; VisibleItems[i].VisiblePosition := -1;
FVisibleItems.Delete(i); FVisibleItems.Delete(i);
MessageView.Items[i] := Msg; MessageListBox.Items[i] := Msg;
end end
else begin else begin
MessageView.Items.Add(Msg)// add line MessageListBox.Items.Add(Msg)// add line
end; end;
NewMsg.VisiblePosition := FVisibleItems.Count; NewMsg.VisiblePosition := FVisibleItems.Count;
FVisibleItems.Add(NewMsg); FVisibleItems.Add(NewMsg);
FLastLineIsProgress := ProgressLine; FLastLineIsProgress := ProgressLine;
MessageView.TopIndex := MessageView.Items.Count - 1; MessageListBox.TopIndex := MessageListBox.Items.Count - 1;
end; end;
end; end;
@ -329,28 +341,56 @@ end;
procedure TMessagesView.CollectLineParts(Sender: TObject; procedure TMessagesView.CollectLineParts(Sender: TObject;
SrcLines: TIDEMessageLineList); SrcLines: TIDEMessageLineList);
{function MsgAsString(Msg: TIDEMessageLine): string;
begin
Result:=Msg.Msg;
if Msg.Parts<>nil then
Result:=Result+' '+Msg.Parts.Text;
end;}
var var
i: Integer; i: Integer;
SrcLine: TIDEMessageLine; SrcLine: TIDEMessageLine;
DestLine: TIDEMessageLine; DestLine: TIDEMessageLine;
StartOriginalIndex: LongInt;
DestIndex: Integer;
begin begin
//DebugLn('TMessagesView.CollectLineParts ',dbgsName(Sender),' ',dbgsName(SrcLines)); //DebugLn('TMessagesView.CollectLineParts ',dbgsName(Sender),' ',dbgsName(SrcLines));
if Sender=nil then ; if Sender=nil then ;
if SrcLines=nil then exit; if (SrcLines=nil) or (SrcLines.Count=0) then exit;
StartOriginalIndex:=SrcLines[0].OriginalIndex;
DestIndex:=ItemCount-1;
while (DestIndex>=0) and (Items[DestIndex].OriginalIndex<>StartOriginalIndex) do
dec(DestIndex);
for i:=0 to SrcLines.Count-1 do begin for i:=0 to SrcLines.Count-1 do begin
SrcLine:=SrcLines[i]; SrcLine:=SrcLines[i];
DestLine:=Items[i]; if DestIndex>=FItems.Count then break;
DestLine:=Items[DestIndex];
if (SrcLine.OriginalIndex=DestLine.OriginalIndex) then begin if (SrcLine.OriginalIndex=DestLine.OriginalIndex) then begin
if SrcLine.Parts<>nil then begin if SrcLine.Parts<>nil then begin
if DestLine.Parts=nil then if DestLine.Parts=nil then
DestLine.Parts:=TStringList.Create; DestLine.Parts:=TStringList.Create;
DestLine.Parts.Assign(SrcLine.Parts); DestLine.Parts.Assign(SrcLine.Parts);
//DebugLn('TMessagesView.CollectLineParts i=',dbgs(i),' Parts=',DestLine.Parts.Text);
end else if DestLine.Parts<>nil then end else if DestLine.Parts<>nil then
DestLine.Parts.Clear; DestLine.Parts.Clear;
end else begin end else begin
//DebugLn('TMessagesView.CollectLineParts WARNING: ',dbgs(SrcLine.OriginalIndex),'<>',dbgs(DestLine.OriginalIndex)); DebugLn('TMessagesView.CollectLineParts WARNING: ',dbgs(SrcLine.OriginalIndex),'<>',dbgs(DestLine.OriginalIndex),' SrcLine=',SrcLine.Msg);
end; end;
inc(DestIndex);
end; end;
{for i:=0 to SrcLines.Count-1 do begin
SrcLine:=SrcLines[i];
DebugLn('TMessagesView.CollectLineParts i=',dbgs(i),' SrcLine=',MsgAsString(SrcLine));
end;
for i:=0 to ItemCount-1 do begin
DestLine:=Items[i];
DebugLn('TMessagesView.CollectLineParts i=',dbgs(i),' DestLine=',MsgAsString(DestLine));
end;}
end; end;
procedure TMessagesView.ClearTillLastSeparator; procedure TMessagesView.ClearTillLastSeparator;
@ -372,8 +412,8 @@ end;
procedure TMessagesView.ShowTopMessage; procedure TMessagesView.ShowTopMessage;
begin begin
if MessageView.Items.Count > 0 then if MessageListBox.Items.Count > 0 then
MessageView.TopIndex := 0; MessageListBox.TopIndex := 0;
end; end;
function TMessagesView.MsgCount: integer; function TMessagesView.MsgCount: integer;
@ -406,24 +446,24 @@ begin
else else
Line.VisiblePosition := -1; Line.VisiblePosition := -1;
end; end;
// rebuild MessageView.Items // rebuild MessageListBox.Items
MessageView.Items.BeginUpdate; MessageListBox.Items.BeginUpdate;
for i := 0 to FVisibleItems.Count - 1 do for i := 0 to FVisibleItems.Count - 1 do
begin begin
Line := VisibleItems[i]; Line := VisibleItems[i];
if MessageView.Items.Count > i then if MessageListBox.Items.Count > i then
MessageView.Items[i] := Line.Msg MessageListBox.Items[i] := Line.Msg
else else
MessageView.Items.Add(Line.Msg); MessageListBox.Items.Add(Line.Msg);
end; end;
while MessageView.Items.Count > FVisibleItems.Count do while MessageListBox.Items.Count > FVisibleItems.Count do
MessageView.Items.Delete(MessageView.Items.Count - 1); MessageListBox.Items.Delete(MessageListBox.Items.Count - 1);
MessageView.Items.EndUpdate; MessageListBox.Items.EndUpdate;
end; end;
procedure TMessagesView.SaveMessagesToFile(const Filename: string); procedure TMessagesView.SaveMessagesToFile(const Filename: string);
begin begin
SaveStringToFile(Filename, MessageView.Items.Text, []); SaveStringToFile(Filename, MessageListBox.Items.Text, []);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -435,10 +475,10 @@ begin
exit; exit;
FLastLineIsProgress := False; FLastLineIsProgress := False;
ClearItems; ClearItems;
if not Assigned(MessageView.OnClick) then if not Assigned(MessageListBox.OnClick) then
MessageView.OnClick := @MessageViewClicked; MessageListBox.OnClick := @MessageViewClicked;
if not Assigned(MessageView.OnDblClick) then if not Assigned(MessageListBox.OnDblClick) then
MessageView.OnDblClick := @MessageViewDblClicked; MessageListBox.OnDblClick := @MessageViewDblClicked;
end; end;
procedure TMessagesView.GetVisibleMessageAt(Index: integer; procedure TMessagesView.GetVisibleMessageAt(Index: integer;
@ -447,11 +487,11 @@ begin
// consistency checks // consistency checks
if (Index < 0) then if (Index < 0) then
RaiseException('TMessagesView.GetVisibleMessageAt'); RaiseException('TMessagesView.GetVisibleMessageAt');
if MessageView.Items.Count <= Index then if MessageListBox.Items.Count <= Index then
RaiseException('TMessagesView.GetVisibleMessageAt'); RaiseException('TMessagesView.GetVisibleMessageAt');
if (FItems = nil) then if (FVisibleItems = nil) then
RaiseException('TMessagesView.GetVisibleMessageAt'); RaiseException('TMessagesView.GetVisibleMessageAt');
if (FItems.Count <= Index) then if (FVisibleItems.Count <= Index) then
RaiseException('TMessagesView.GetVisibleMessageAt'); RaiseException('TMessagesView.GetVisibleMessageAt');
Msg := VisibleItems[Index].Msg; Msg := VisibleItems[Index].Msg;
MsgDirectory := VisibleItems[Index].Directory; MsgDirectory := VisibleItems[Index].Directory;
@ -478,7 +518,7 @@ begin
TObject(FItems[i]).Free; TObject(FItems[i]).Free;
FItems.Clear; FItems.Clear;
FVisibleItems.Clear; FVisibleItems.Clear;
MessageView.Clear; MessageListBox.Clear;
end; end;
function TMessagesView.ItemCount: integer; function TMessagesView.ItemCount: integer;
@ -497,8 +537,8 @@ end;
function TMessagesView.GetMessage: string; function TMessagesView.GetMessage: string;
begin begin
Result := ''; Result := '';
if (MessageView.Items.Count > 0) and (MessageView.SelCount > 0) then if (MessageListBox.Items.Count > 0) and (MessageListBox.SelCount > 0) then
Result := MessageView.Items.Strings[GetSelectedLineIndex]; Result := MessageListBox.Items.Strings[GetSelectedLineIndex];
end; end;
function TMessagesView.GetMessageLine: TIDEMessageLine; function TMessagesView.GetMessageLine: TIDEMessageLine;
@ -525,7 +565,7 @@ end;
procedure TMessagesView.CopyAllMenuItemClick(Sender: TObject); procedure TMessagesView.CopyAllMenuItemClick(Sender: TObject);
begin begin
Clipboard.AsText := MessageView.Items.Text; Clipboard.AsText := MessageListBox.Items.Text;
end; end;
procedure TMessagesView.CopyAllAndHiddenMenuItemClick(Sender: TObject); procedure TMessagesView.CopyAllAndHiddenMenuItemClick(Sender: TObject);
@ -535,9 +575,9 @@ end;
procedure TMessagesView.CopyMenuItemClick(Sender: TObject); procedure TMessagesView.CopyMenuItemClick(Sender: TObject);
begin begin
if MessageView.ItemIndex < 0 then if MessageListBox.ItemIndex < 0 then
exit; exit;
Clipboard.AsText := MessageView.GetSelectedText; Clipboard.AsText := MessageListBox.GetSelectedText;
end; end;
procedure TMessagesView.FormDeactivate(Sender: TObject); procedure TMessagesView.FormDeactivate(Sender: TObject);
@ -563,7 +603,7 @@ begin
if Msg<>nil then begin if Msg<>nil then begin
for j:=0 to IDEMsgQuickFixes.Count-1 do begin for j:=0 to IDEMsgQuickFixes.Count-1 do begin
QuickFixItem:=IDEMsgQuickFixes[j]; QuickFixItem:=IDEMsgQuickFixes[j];
DebugLn('TMessagesView.MainPopupMenuPopup "',Msg.Msg,'" ',QuickFixItem.Name); //DebugLn('TMessagesView.MainPopupMenuPopup "',Msg.Msg,'" ',QuickFixItem.Name);
if QuickFixItem.IsApplicable(Msg) then begin if QuickFixItem.IsApplicable(Msg) then begin
FQuickFixItems.Add(QuickFixItem); FQuickFixItems.Add(QuickFixItem);
end; end;
@ -610,22 +650,22 @@ const
clMsgNote = clGreen; clMsgNote = clGreen;
cLeftSpacer = 3; cLeftSpacer = 3;
begin begin
MessageView.Canvas.FillRect(ARect); MessageListBox.Canvas.FillRect(ARect);
TheText := MessageView.Items[Index]; TheText := MessageListBox.Items[Index];
cl := MessageView.Canvas.Font.Color; // save original color cl := MessageListBox.Canvas.Font.Color; // save original color
{ Only use custom colors if not selected, otherwise it is difficult to read } { Only use custom colors if not selected, otherwise it is difficult to read }
if not (odSelected in State) if not (odSelected in State)
then begin then begin
if Pos(cNote, TheText) > 0 if Pos(cNote, TheText) > 0
then MessageView.Canvas.Font.Color := clMsgNote then MessageListBox.Canvas.Font.Color := clMsgNote
else if Pos(cHint, TheText) > 0 else if Pos(cHint, TheText) > 0
then MessageView.Canvas.Font.Color := clMsgHint then MessageListBox.Canvas.Font.Color := clMsgHint
end; end;
MessageView.Canvas.TextOut(ARect.Left + cLeftSpacer, ARect.Top + 1, TheText); MessageListBox.Canvas.TextOut(ARect.Left + cLeftSpacer, ARect.Top + 1, TheText);
MessageView.Canvas.Font.Color := cl; // restore original color MessageListBox.Canvas.Font.Color := cl; // restore original color
end; end;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -637,7 +677,7 @@ begin
SaveDialog := TSaveDialog.Create(nil); SaveDialog := TSaveDialog.Create(nil);
try try
InputHistories.ApplyFileDialogSettings(SaveDialog); InputHistories.ApplyFileDialogSettings(SaveDialog);
SaveDialog.Title := 'Save messages to file (*.txt)'; SaveDialog.Title := lisMVSaveMessagesToFileTxt;
SaveDialog.Options := SaveDialog.Options + [ofPathMustExist]; SaveDialog.Options := SaveDialog.Options + [ofPathMustExist];
if SaveDialog.Execute then if SaveDialog.Execute then
begin begin
@ -659,6 +699,7 @@ var
Msg: TIDEMessageLine; Msg: TIDEMessageLine;
begin begin
Msg:=GetMessageLine; Msg:=GetMessageLine;
if Msg=nil then exit;
for i:=0 to FQuickFixItems.Count-1 do begin for i:=0 to FQuickFixItems.Count-1 do begin
QuickFixItem:=TIDEMsgQuickFixItem(FQuickFixItems[i]); QuickFixItem:=TIDEMsgQuickFixItem(FQuickFixItems[i]);
if QuickFixItem.Caption=(Sender as TIDEMenuItem).Caption then begin if QuickFixItem.Caption=(Sender as TIDEMenuItem).Caption then begin
@ -687,9 +728,9 @@ var
I: integer; I: integer;
begin begin
Result := -1; Result := -1;
if (MessageView.Items.Count > 0) and (MessageView.SelCount > 0) then if (MessageListBox.Items.Count > 0) and (MessageListBox.SelCount > 0) then
for i := 0 to MessageView.Items.Count - 1 do for i := 0 to MessageListBox.Items.Count - 1 do
if MessageView.Selected[I] then if MessageListBox.Selected[I] then
begin begin
Result := I; Result := I;
Break; Break;
@ -701,7 +742,7 @@ begin
if FLastLineIsProgress = AValue then if FLastLineIsProgress = AValue then
exit; exit;
if FLastLineIsProgress then if FLastLineIsProgress then
MessageView.Items.Delete(MessageView.Items.Count - 1); MessageListBox.Items.Delete(MessageListBox.Items.Count - 1);
FLastLineIsProgress := AValue; FLastLineIsProgress := AValue;
end; end;
@ -709,7 +750,7 @@ procedure TMessagesView.DoSelectionChange;
var var
NewSelectedIndex: LongInt; NewSelectedIndex: LongInt;
begin begin
if (MessageView.Items.Count > 0) and (MessageView.SelCount > 0) then begin if (MessageListBox.Items.Count > 0) and (MessageListBox.SelCount > 0) then begin
NewSelectedIndex:=GetSelectedLineIndex; NewSelectedIndex:=GetSelectedLineIndex;
if NewSelectedIndex<>FLastSelectedIndex then begin if NewSelectedIndex<>FLastSelectedIndex then begin
FLastSelectedIndex:=NewSelectedIndex; FLastSelectedIndex:=NewSelectedIndex;
@ -721,8 +762,8 @@ end;
procedure TMessagesView.SetSelectedLineIndex(const AValue: integer); procedure TMessagesView.SetSelectedLineIndex(const AValue: integer);
begin begin
MessageView.ItemIndex := AValue; MessageListBox.ItemIndex := AValue;
MessageView.TopIndex := MessageView.ItemIndex; MessageListBox.TopIndex := MessageListBox.ItemIndex;
end; end;
initialization initialization

View File

@ -328,12 +328,12 @@ var i, j, FilenameEndPos: integer;
CurFilenameLen: Integer; CurFilenameLen: Integer;
CurCompHistLen: Integer; CurCompHistLen: Integer;
MainSrcFilename: String; MainSrcFilename: String;
NewFilename: String;
LineNumberStartPos: LongInt; LineNumberStartPos: LongInt;
ColumnNumberStartPos: LongInt; ColumnNumberStartPos: LongInt;
ColumnNumberEndPos: LongInt; ColumnNumberEndPos: LongInt;
MessageStartPos: Integer; MessageStartPos: Integer;
LineNumberEndPos: LongInt; LineNumberEndPos: LongInt;
AbsFilename: String;
function CheckForCompilingState: boolean; function CheckForCompilingState: boolean;
var var
@ -687,12 +687,18 @@ begin
// make filenames absolute if wanted // make filenames absolute if wanted
Filename:=copy(Msg,1,FilenameEndPos); Filename:=copy(Msg,1,FilenameEndPos);
if FilenameIsAbsolute(Filename) then begin
AbsFilename:=Filename;
end else begin
AbsFilename:=TrimFilename(fCurrentDirectory+Filename);
if not FileExists(AbsFilename) then begin
AbsFilename:='';
end;
end;
if (ofoMakeFilenamesAbsolute in Options) then begin if (ofoMakeFilenamesAbsolute in Options) then begin
if not FilenameIsAbsolute(Filename) then begin if (AbsFilename<>'') and (AbsFilename<>Filename) then begin
NewFilename:=TrimFilename(fCurrentDirectory+Filename); Filename:=AbsFilename;
if FileExists(NewFilename) then Msg:=Filename+copy(Msg,FilenameEndPos+1,length(Msg)-FilenameEndPos);
Msg:=NewFilename
+copy(Msg,FilenameEndPos+1,length(Msg)-FilenameEndPos);
end; end;
end else begin end else begin
if FileIsInPath(Filename,fCurrentDirectory) then begin if FileIsInPath(Filename,fCurrentDirectory) then begin
@ -700,6 +706,10 @@ begin
Msg:=Filename+copy(Msg,FilenameEndPos+1,length(Msg)-FilenameEndPos); Msg:=Filename+copy(Msg,FilenameEndPos+1,length(Msg)-FilenameEndPos);
end; end;
end; end;
//DebugLn('TOutputFilter.ReadFPCompilerLine AbsFilename=',AbsFilename,' Filename=',Filename,' Dir=',fCurrentDirectory);
if AbsFilename<>'' then
CurrentMessageParts.Values['Filename']:=AbsFilename
else
CurrentMessageParts.Values['Filename']:=Filename; CurrentMessageParts.Values['Filename']:=Filename;
// add line // add line

View File

@ -52,6 +52,7 @@ type
Creates the following lines in Parts: Creates the following lines in Parts:
Stage=FPC Stage=FPC
Type=Warning Type=Warning
Filename=/path/unit1.pas
Line=21 Line=21
Column=3 Column=3
Message=unit buttons not used Message=unit buttons not used
@ -124,6 +125,7 @@ type
procedure SetRegExpression(const AValue: string); procedure SetRegExpression(const AValue: string);
procedure SetRegExprModifiers(const AValue: string); procedure SetRegExprModifiers(const AValue: string);
public public
constructor Create;
procedure Execute(const Msg: TIDEMessageLine); virtual; procedure Execute(const Msg: TIDEMessageLine); virtual;
function IsApplicable(Line: TIDEMessageLine): boolean; virtual; function IsApplicable(Line: TIDEMessageLine): boolean; virtual;
public public
@ -218,6 +220,11 @@ begin
FRegExprModifiers:=AValue; FRegExprModifiers:=AValue;
end; end;
constructor TIDEMsgQuickFixItem.Create;
begin
FRegExprModifiers:='I';
end;
procedure TIDEMsgQuickFixItem.Execute(const Msg: TIDEMessageLine); procedure TIDEMsgQuickFixItem.Execute(const Msg: TIDEMessageLine);
begin begin
if Assigned(OnExecuteMethod) then if Assigned(OnExecuteMethod) then
@ -230,6 +237,7 @@ function TIDEMsgQuickFixItem.IsApplicable(Line: TIDEMessageLine): boolean;
begin begin
Result:=false; Result:=false;
if RegExpression='' then exit; if RegExpression='' then exit;
//DebugLn('TIDEMsgQuickFixItem.IsApplicable Line.Msg="',Line.Msg,'" RegExpression="',RegExpression,'"');
Result:=REMatches(Line.Msg,RegExpression,RegExprModifiers); Result:=REMatches(Line.Msg,RegExpression,RegExprModifiers);
end; end;
@ -296,7 +304,10 @@ end;
function TIDEMsgQuickFixItems.NewName(const StartValue: string): string; function TIDEMsgQuickFixItems.NewName(const StartValue: string): string;
begin begin
Result:=StartValue;
if IndexOfName(Result)<0 then exit;
Result:=CreateFirstIdentifier(StartValue); Result:=CreateFirstIdentifier(StartValue);
//DebugLn('TIDEMsgQuickFixItems.NewName Result="',Result,'" StartValue="',StartValue,'"');
while IndexOfName(Result)>=0 do while IndexOfName(Result)>=0 do
Result:=CreateNextIdentifier(Result); Result:=CreateNextIdentifier(Result);
end; end;

View File

@ -71,7 +71,7 @@ var
function REMatches(const TheText, RegExpr: string; function REMatches(const TheText, RegExpr: string;
const ModifierStr: string = ''): boolean; const ModifierStr: string = ''): boolean;
function REVar(Index: Integer): string; function REVar(Index: Integer): string; // 1 is the first
procedure REVarPos(Index: Integer; var MatchStart, MatchLength: integer); procedure REVarPos(Index: Integer; var MatchStart, MatchLength: integer);
function REVarCount: Integer; function REVarCount: Integer;
function REReplace(const TheText, FindRegExpr, ReplaceRegExpr: string; function REReplace(const TheText, FindRegExpr, ReplaceRegExpr: string;

View File

@ -140,7 +140,7 @@ end;
procedure TAsyncProcess.Execute; procedure TAsyncProcess.Execute;
begin begin
inherited; inherited Execute;
if poUsePipes in Options then if poUsePipes in Options then
FPipeHandler := AddPipeEventHandler(Output.Handle, @HandlePipeInput, 0); FPipeHandler := AddPipeEventHandler(Output.Handle, @HandlePipeInput, 0);