diff --git a/.gitattributes b/.gitattributes index 9d88f88ffe..1a0d3b8f21 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5463,7 +5463,6 @@ ide/miscoptions.pas svneol=native#text/pascal ide/modematrixopts.pas svneol=native#text/plain ide/mouseactiondialog.lfm svneol=native#text/plain ide/mouseactiondialog.pas svneol=native#text/pascal -ide/msgquickfixes.pas svneol=native#text/plain ide/msgvieweditor.lfm svneol=native#text/plain ide/msgvieweditor.pas svneol=native#text/pascal ide/multireplacedlg.lfm svneol=native#text/plain diff --git a/ide/checklfmdlg.pas b/ide/checklfmdlg.pas index e846b4e6e9..aa0f7c3aac 100644 --- a/ide/checklfmdlg.pas +++ b/ide/checklfmdlg.pas @@ -32,20 +32,17 @@ interface uses // FCL+LCL - Classes, SysUtils, Math, TypInfo, LCLProc, LResources, Forms, Controls, - Graphics, Dialogs, Buttons, StdCtrls, contnrs, + Classes, SysUtils, Math, TypInfo, contnrs, + LCLProc, LResources, Forms, Controls, + Graphics, Dialogs, Buttons, StdCtrls, ExtCtrls, // components SynHighlighterLFM, SynEdit, BasicCodeTools, CodeCache, CodeToolManager, SynEditMiscClasses, LFMTrees, // IDE - PropEdits, IDEDialogs, ComponentReg, PackageIntf, IDEWindowIntf, + IDEExternToolIntf, PackageIntf, IDEWindowIntf, PropEdits, PropEditUtils, IDEMsgIntf, + IDEDialogs, ComponentReg, CustomFormEditor, LazarusIDEStrConsts, - {$IFNDEF EnableOldExtTools} - IDEExternToolIntf, - {$ELSE} - {$ENDIF} - IDEProcs, IDEOptionDefs, EditorOptions, SourceMarks, ExtCtrls, JITForms, - PropEditUtils, IDEMsgIntf; + IDEProcs, IDEOptionDefs, EditorOptions, SourceMarks, JITForms; type @@ -419,14 +416,7 @@ begin if Code=nil then Code:=fPascalBuffer; Filename:=ExtractFilename(Code.Filename); - {$IFNDEF EnableOldExtTools} IDEMessagesWindow.AddCustomMessage(mluError,ErrorMessage,Filename,Y,X); - {$ELSE} - IDEMessagesWindow.AddMsg(Filename - +'('+IntToStr(Y)+','+IntToStr(X)+')' - +' Error: '+ErrorMessage, - ExtractFilePath(Code.Filename),-1); - {$ENDIF} Application.ProcessMessages; end; @@ -445,15 +435,8 @@ begin CurError:=fLFMTree.FirstError; Filename:=ExtractFilename(fLFMBuffer.Filename); while CurError<>nil do begin - {$IFNDEF EnableOldExtTools} IDEMessagesWindow.AddCustomMessage(mluError,CurError.ErrorMessage, Filename,CurError.Caret.Y,CurError.Caret.X); - {$ELSE} - IDEMessagesWindow.AddMsg(Filename - +'('+IntToStr(CurError.Caret.Y)+','+IntToStr(CurError.Caret.X)+')' - +' Error: '+CurError.ErrorMessage, - ExtractFilePath(fLFMBuffer.Filename),-1); - {$ENDIF} CurError:=CurError.NextError; end; Application.ProcessMessages; diff --git a/ide/codebrowser.pas b/ide/codebrowser.pas index 2357edb6c0..c85cb8191a 100644 --- a/ide/codebrowser.pas +++ b/ide/codebrowser.pas @@ -56,13 +56,7 @@ uses IDEExternToolIntf, // IDE Project, DialogProcs, PackageSystem, PackageDefs, LazarusIDEStrConsts, - IDEOptionDefs, - {$IFNDEF EnableOldExtTools} - etFPCMsgParser, - {$ELSE} - MsgQuickFixes, - {$ENDIF} - BasePkgManager, AddToProjectDlg, + IDEOptionDefs, etFPCMsgParser, BasePkgManager, AddToProjectDlg, EnvironmentOpts; @@ -376,7 +370,6 @@ type property IdleConnected: boolean read FIdleConnected write SetIdleConnected; end; -{$IFNDEF EnableOldExtTools} type { TQuickFixIdentifierNotFound_Search } @@ -387,17 +380,6 @@ type procedure CreateMenuItems(Fixes: TMsgQuickFixes); override; procedure QuickFix(Fixes: TMsgQuickFixes; Msg: TMessageLine); override; end; -{$ELSE} -type - { TQuickFixIdentifierNotFound_Search - add menu item to open codebrowser } - - TQuickFixIdentifierNotFound_Search = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; -{$ENDIF} var CodeBrowserView: TCodeBrowserView = nil; @@ -3209,8 +3191,6 @@ end; { TQuickFixIdentifierNotFound_Search } -{$IFNDEF EnableOldExtTools} - function TQuickFixIdentifierNotFound_Search.IsApplicable(Msg: TMessageLine; out Identifier: string): boolean; var @@ -3279,90 +3259,6 @@ begin CodeBrowserView.SetFilterToSimpleIdentifier(Identifier); IDEWindowCreators.ShowForm(CodeBrowserView,true); end; -{$ELSE} -constructor TQuickFixIdentifierNotFound_Search.Create; -begin - Name:='Search identifier: Error: Identifier not found "identifier"'; - Caption:=lisQuickFixSearchIdentifier; - Steps:=[imqfoMenuItem]; -end; - -function TQuickFixIdentifierNotFound_Search.IsApplicable(Line: TIDEMessageLine - ): boolean; -const - SearchStr = ') Error: Identifier not found "'; -var - Msg: String; - p: integer; - Code: TCodeBuffer; - Filename: string; - Caret: TPoint; -begin - Result:=false; - if (Line.Parts=nil) then exit; - Msg:=Line.Msg; - p:=System.Pos(SearchStr,Msg); - if p<1 then exit; - inc(p,length(SearchStr)); - Line.GetSourcePosition(Filename,Caret.Y,Caret.X); - if (Filename='') or (Caret.X<1) or (Caret.Y<1) then exit; - Code:=CodeToolBoss.LoadFile(Filename,true,false); - if Code=nil then exit; - Result:=true; -end; - -procedure TQuickFixIdentifierNotFound_Search.Execute( - const Msg: TIDEMessageLine; Step: TIMQuickFixStep); -var - Identifier: String; - CodeBuf: TCodeBuffer; - Filename, KnownFilename: string; - Caret: TPoint; -begin - if Step=imqfoMenuItem then begin - DebugLn(['TQuickFixIdentifierNotFound_Search.Execute Dir=',Msg.Directory,' Msg=',Msg.Msg,' Filename=',Msg.Parts.Values['Filename']]); - // get source position - // (FPC reports position right after the unknown identifier - // for example right after FilenameIsAbsolute) - if not GetMsgLineFile(Msg,CodeBuf,false) then exit; - Msg.GetSourcePosition(Filename,Caret.Y,Caret.X); - if not LazarusIDE.BeginCodeTools then begin - DebugLn(['TQuickFixIdentifierNotFound_Search.Execute failed because IDE busy']); - exit; - end; - - // get identifier - if not REMatches(Msg.Msg,'Error: Identifier not found "([a-z_0-9]+)"','I') then begin - DebugLn('TQuickFixIdentifierNotFound_Search invalid message ',Msg.Msg); - exit; - end; - Identifier:=REVar(1); - DebugLn(['TQuickFixIdentifierNotFound_Search.Execute Identifier=',Identifier]); - - if (Identifier='') or (not IsValidIdent(Identifier)) then begin - DebugLn(['TQuickFixIdentifierNotFound_Search.Execute not an identifier "',dbgstr(Identifier),'"']); - exit; - end; - - KnownFilename:= LazarusIDE.FindSourceFile(Filename, Project1.ProjectDirectory, - [fsfSearchForProject, fsfUseIncludePaths, fsfMapTempToVirtualFiles]); - - if (KnownFilename <> '') and (KnownFilename <> Filename) then begin - if LazarusIDE.DoOpenFileAndJumpToPos(KnownFilename,Caret,-1,-1,-1,OpnFlagsPlainFile)<>mrOk - then - if LazarusIDE.DoOpenFileAndJumpToPos(Filename,Caret,-1,-1,-1,OpnFlagsPlainFile)<>mrOk - then exit; - end - else - if LazarusIDE.DoOpenFileAndJumpToPos(Filename,Caret,-1,-1,-1,OpnFlagsPlainFile - )<>mrOk - then exit; - - // start code browser - ShowCodeBrowser(Identifier); - end; -end; -{$Endif EnableOldExtTools} end. diff --git a/ide/codehelp.pas b/ide/codehelp.pas index e94e1c7744..83d186186a 100644 --- a/ide/codehelp.pas +++ b/ide/codehelp.pas @@ -1410,13 +1410,8 @@ begin if ADocFile.DocErrorMsg<>'' then begin if not (chofQuiet in Flags) then begin // for example: Filename(y,x) Error: description - {$IFNDEF EnableOldExtTools} IDEMessagesWindow.AddCustomMessage(mluError,ADocFile.DocErrorMsg, ADocFile.CodeBuffer.Filename,0,0,'FPDoc'); - {$ELSE} - IDEMessagesWindow.AddMsg(ADocFile.DocErrorMsg, - ExtractFilePath(ADocFile.CodeBuffer.Filename),-1); - {$ENDIF} end; // no update needed exit(chprFailed); @@ -1457,12 +1452,8 @@ begin DebugLn(['TCodeHelpManager.LoadFPDocFile ',E.Message]); if not (chofQuiet in Flags) then begin // for example: Filename(y,x) Error: description - {$IFNDEF EnableOldExtTools} IDEMessagesWindow.AddCustomMessage(mluError,ADocFile.DocErrorMsg, CurFilename,0,0,'FPDoc'); - {$ELSE} - IDEMessagesWindow.AddMsg(ADocFile.DocErrorMsg,ExtractFilePath(CurFilename),-1); - {$ENDIF} end; end; on E: Exception do begin diff --git a/ide/etfpcmsgparser.pas b/ide/etfpcmsgparser.pas index 28384e75e2..51a9cfd843 100644 --- a/ide/etfpcmsgparser.pas +++ b/ide/etfpcmsgparser.pas @@ -25,8 +25,6 @@ } unit etFPCMsgParser; -{$IFDEF EnableOldExtTools}{$ERROR Wrong}{$ENDIF} - {$mode objfpc}{$H+} {off $DEFINE VerboseFPCMsgUnitNotFound} diff --git a/ide/etmakemsgparser.pas b/ide/etmakemsgparser.pas index 45cc53827b..2f662a0428 100644 --- a/ide/etmakemsgparser.pas +++ b/ide/etmakemsgparser.pas @@ -27,8 +27,6 @@ unit etMakeMsgParser; {$mode objfpc}{$H+} -{$IFDEF EnableOldExtTools}{$ERROR Wonrg}{$ENDIF} - interface uses diff --git a/ide/etmessageswnd.pas b/ide/etmessageswnd.pas index 59dac71440..eb0da1fc28 100644 --- a/ide/etmessageswnd.pas +++ b/ide/etmessageswnd.pas @@ -27,8 +27,6 @@ unit etMessagesWnd; {$mode objfpc}{$H+} -{$IFDEF EnableOldExtTools}{$Error Wrong}{$ENDIF} - interface uses diff --git a/ide/etsrceditmarks.pas b/ide/etsrceditmarks.pas index eecb8793bd..4b37a39881 100644 --- a/ide/etsrceditmarks.pas +++ b/ide/etsrceditmarks.pas @@ -27,8 +27,6 @@ unit etSrcEditMarks; {$mode objfpc}{$H+} -{$IFDEF EnableOldExtTools}{$Error Wrong}{$ENDIF} - {off $DEFINE VerboseETSrcChange} interface diff --git a/ide/exttooleditdlg.pas b/ide/exttooleditdlg.pas index a9ff70ef74..9c807416b9 100644 --- a/ide/exttooleditdlg.pas +++ b/ide/exttooleditdlg.pas @@ -45,15 +45,8 @@ uses StdCtrls, Dialogs, ExtCtrls, LCLProc, ButtonPanel, IDEExternToolIntf, IDEHelpIntf, PropEdits, IDEDialogs, IDECommands, FileProcs, TransferMacros, LazarusIDEStrConsts, EnvironmentOpts, KeyMapping, - IDEProcs - {$IFNDEF EnableOldExtTools} - ,LazConfigStorage, contnrs, IDEUtils - {$ELSE} - ,IDEMsgIntf, EditMsgScannersDlg - {$ENDIF} - ; + IDEProcs, LazConfigStorage, contnrs, IDEUtils; -{$IFNDEF EnableOldExtTools} const ExternalToolOptionsVersion = 3; // 3: changed ScanOutputForFPCMessages to scanner SubToolFPC @@ -145,22 +138,6 @@ type var ExternalUserTools: TExternalUserTools = nil; -{$ELSE} -type - { TExternalToolOptions } - - TExternalToolOptions = class(TIDEExternalToolOptions) - private - fKey: word; - fShift: TShiftState; - public - procedure Assign(Source: TPersistent); override; - procedure Clear; override; - // key and shift are loaded with the keymapping in the editoroptions - property Key: word read fKey write fKey; - property Shift: TShiftState read fShift write fShift; - end; -{$ENDIF} type { TExternalToolOptionDlg - the editor dialog for a single external tool } @@ -197,7 +174,7 @@ type procedure ScannersButtonClick(Sender: TObject); private fAllKeys: TKeyCommandRelationList; - fOptions: {$IFNDEF EnableOldExtTools}TExternalUserTool{$ELSE}TExternalToolOptions{$ENDIF}; + fOptions: TExternalUserTool; fTransferMacros: TTransferMacroList; fScanners: TStrings; fKeyBox: TShortCutGrabBox; @@ -208,17 +185,17 @@ type procedure UpdateButtons; function ScannersToString(List: TStrings): string; procedure SetComboBox(AComboBox: TComboBox; const AValue: string); - procedure SetOptions(TheOptions: {$IFNDEF EnableOldExtTools}TExternalUserTool{$ELSE}TExternalToolOptions{$ENDIF}); + procedure SetOptions(TheOptions: TExternalUserTool); procedure SetTransferMacros(TransferMacroList: TTransferMacroList); public - property Options: {$IFNDEF EnableOldExtTools}TExternalUserTool{$ELSE}TExternalToolOptions{$ENDIF} read fOptions write SetOptions; + property Options: TExternalUserTool read fOptions write SetOptions; property MacroList: TTransferMacroList read fTransferMacros write SetTransferMacros; end; function ShowExtToolOptionDlg(TransferMacroList: TTransferMacroList; - ExternalToolMenuItem: {$IFNDEF EnableOldExtTools}TExternalUserTool{$ELSE}TExternalToolOptions{$ENDIF}; + ExternalToolMenuItem: TExternalUserTool; AllKeys: TKeyCommandRelationList):TModalResult; implementation @@ -226,7 +203,7 @@ implementation {$R *.lfm} function ShowExtToolOptionDlg(TransferMacroList: TTransferMacroList; - ExternalToolMenuItem: {$IFNDEF EnableOldExtTools}TExternalUserTool{$ELSE}TExternalToolOptions{$ENDIF}; + ExternalToolMenuItem: TExternalUserTool; AllKeys: TKeyCommandRelationList):TModalResult; var ExternalToolOptionDlg: TExternalToolOptionDlg; @@ -245,7 +222,6 @@ begin end; end; -{$IFNDEF EnableOldExtTools} { TExternalUserTool } // inline @@ -672,28 +648,6 @@ begin end; end; end; -{$ELSE EnableOldExtTools} -{ TExternalToolOptions } - -procedure TExternalToolOptions.Assign(Source: TPersistent); -var - Src: TExternalToolOptions; -begin - if Source is TExternalToolOptions then begin - Src:=TExternalToolOptions(Source); - fKey:=Src.fKey; - fShift:=Src.fShift; - end; - inherited Assign(Source); -end; - -procedure TExternalToolOptions.Clear; -begin - fKey:=VK_UNKNOWN; - fShift:=[]; - inherited Clear; -end; -{$Endif EnableOldExtTools} { TExternalToolOptionDlg } @@ -705,13 +659,6 @@ End; procedure TExternalToolOptionDlg.ScannersButtonClick(Sender: TObject); begin - {$IFNDEF EnableOldExtTools} - {$ELSE} - if ShowEditMsgScannersDialog('Edit tool '+copy(TitleEdit.Text,1,20), - fScanners)=mrOk - then - UpdateButtons; - {$ENDIF} end; procedure TExternalToolOptionDlg.LoadFromOptions; @@ -722,13 +669,8 @@ begin WorkingDirEdit.Text:=fOptions.WorkingDirectory; fKeyBox.Key:=fOptions.Key; fKeyBox.ShiftState:=fOptions.Shift; - {$IFNDEF EnableOldExtTools} OptionScanOutputForFPCMessagesCheckBox.Checked:=fOptions.HasScanner[SubToolFPC]; OptionScanOutputForMakeMessagesCheckBox.Checked:=fOptions.HasScanner[SubToolMake]; - {$ELSE} - OptionScanOutputForFPCMessagesCheckBox.Checked:=fOptions.ScanOutputForFPCMessages; - OptionScanOutputForMakeMessagesCheckBox.Checked:=fOptions.ScanOutputForMakeMessages; - {$ENDIF} chkHideMainForm.Checked:=FOptions.HideMainForm; fScanners.Assign(fOptions.Scanners); UpdateButtons; @@ -743,28 +685,13 @@ begin fOptions.Key:=fKeyBox.Key; fOptions.Shift:=fKeyBox.ShiftState; FOptions.HideMainForm := chkHideMainForm.Checked; - {$IFNDEF EnableOldExtTools} fOptions.HasScanner[SubToolFPC]:=OptionScanOutputForFPCMessagesCheckBox.Checked; fOptions.HasScanner[SubToolMake]:=OptionScanOutputForMakeMessagesCheckBox.Checked; - {$ELSE} - fOptions.ScanOutputForFPCMessages:=OptionScanOutputForFPCMessagesCheckBox.Checked; - fOptions.ScanOutputForMakeMessages:=OptionScanOutputForMakeMessagesCheckBox.Checked; - fOptions.Scanners:=fScanners; - {$ENDIF} end; procedure TExternalToolOptionDlg.UpdateButtons; begin - {$IFNDEF EnableOldExtTools} ScannersButton.Visible:=false; - {$ELSE} - if IDEMsgScanners.Count>0 then begin - ScannersButton.Visible:=true; - ScannersButton.Caption:=Format(lisetEditCustomScanners, [ScannersToString(fScanners)]); - end else begin - ScannersButton.Visible:=false; - end; - {$ENDIF} end; function TExternalToolOptionDlg.ScannersToString(List: TStrings): string; @@ -834,7 +761,7 @@ begin ButtonPanel.HelpButton.Caption:=lisMenuHelp; ButtonPanel.CancelButton.Caption:=lisCancel; - fOptions:={$IFNDEF EnableOldExtTools}TExternalUserTool.Create(nil){$ELSE}TExternalToolOptions.Create{$ENDIF}; + fOptions:=TExternalUserTool.Create(nil); end; procedure TExternalToolOptionDlg.FormDestroy(Sender: TObject); @@ -848,7 +775,7 @@ begin LazarusHelp.ShowHelpForIDEControl(Self); end; -procedure TExternalToolOptionDlg.SetOptions(TheOptions: {$IFNDEF EnableOldExtTools}TExternalUserTool{$ELSE}TExternalToolOptions{$ENDIF}); +procedure TExternalToolOptionDlg.SetOptions(TheOptions: TExternalUserTool); begin if fOptions=TheOptions then exit; fOptions.Assign(TheOptions); @@ -1002,8 +929,6 @@ begin end; initialization - {$IFNDEF EnableOldExtTools} ExternalUserToolsClass := TExternalUserTools; - {$ENDIF} end. diff --git a/ide/findunitdlg.pas b/ide/findunitdlg.pas index a8c3439b80..a7eddb6ada 100644 --- a/ide/findunitdlg.pas +++ b/ide/findunitdlg.pas @@ -42,11 +42,7 @@ uses LazIDEIntf, TextTools, IDEMsgIntf, PackageIntf, IDEExternToolIntf, // IDE DialogProcs, PackageDefs, Project, IDEProcs, LazarusIDEStrConsts, - {$IFNDEF EnableOldExtTools} etFPCMsgParser, - {$ELSE} - MsgQuickFixes, - {$ENDIF} PackageLinks, PackageSystem, BasePkgManager; type @@ -118,7 +114,6 @@ type property MainOwnerName: string read FMainOwnerName; end; -{$IFNDEF EnableOldExtTools} type { TQuickFixUnitNotFound_Search - add menu item to open this search dialog } @@ -139,28 +134,6 @@ type function IsCodetoolsErrorIncludeFileNotFound(Msg: string; out IncludeFile: string): boolean; end; -{$ELSE} -type - { TQuickFixUnitNotFound_Search - add menu item to open this search dialog } - - TQuickFixUnitNotFound_Search = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; - - { TQuickFixIncludeNotFound_Search - add menu item to open this search dialog } - - TQuickFixIncludeNotFound_Search = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsCodetoolsErrorIncludeFileNotFound(Msg: string; - out IncludeFile: string): boolean; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; -{$ENDIF} procedure InitFindUnitQuickFixItems; @@ -174,7 +147,6 @@ begin // ToDo: implement RegisterIDEMsgQuickFix(TQuickFixIncludeNotFound_Search.Create); end; -{$IFNDEF EnableOldExtTools} { TQuickFixUnitNotFound_Search } function TQuickFixUnitNotFound_Search.IsApplicable(Msg: TMessageLine; out @@ -245,74 +217,6 @@ begin Dlg.Free; end; end; -{$ELSE EnableOldExtTools} -{ TQuickFixUnitNotFound_Search } - -constructor TQuickFixUnitNotFound_Search.Create; -begin - Name:='Search unit: Error: Can''t find unit Name'; - Caption:=lisSearchUnit; - Steps:=[imqfoMenuItem]; -end; - -function TQuickFixUnitNotFound_Search.IsApplicable(Line: TIDEMessageLine): boolean; -const - SearchStr = ') Fatal: Can''t find unit '; -var - Msg: String; - p: integer; -begin - Result:=false; - if (Line.Parts=nil) then exit; - Msg:=Line.Msg; - p:=System.Pos(SearchStr,Msg); - if p<1 then exit; - Result:=true; -end; - -procedure TQuickFixUnitNotFound_Search.Execute(const Msg: TIDEMessageLine; - Step: TIMQuickFixStep); -var - AnUnitName: String; - Dlg: TFindUnitDialog; - CodeBuf: TCodeBuffer; - Filename: string; - Caret: TPoint; -begin - if Step=imqfoMenuItem then begin - DebugLn(['TQuickFixUnitNotFound_Search.Execute ']); - // get source position - if not GetMsgLineFile(Msg,CodeBuf,false) then exit; - Msg.GetSourcePosition(Filename,Caret.Y,Caret.X); - if not LazarusIDE.BeginCodeTools then begin - DebugLn(['TQuickFixUnitNotFound_Search.Execute failed because IDE busy']); - exit; - end; - - // get unitname - if not REMatches(Msg.Msg,'Fatal: Can''t find unit ([a-z_0-9]+) ','I') then begin - DebugLn('TQuickFixUnitNotFound_Search invalid message ',Msg.Msg); - exit; - end; - AnUnitName:=REVar(1); - DebugLn(['TQuickFixUnitNotFound_Search.Execute Unit=',AnUnitName]); - - if (AnUnitName='') or (not IsValidIdent(AnUnitName)) then begin - DebugLn(['TQuickFixUnitNotFound_Search.Execute not an identifier "',dbgstr(AnUnitName),'"']); - exit; - end; - - // show dialog - Dlg:=TFindUnitDialog.Create(nil); - try - Dlg.InitWithMsg(Msg.Msg,CodeBuf,AnUnitName); - Dlg.ShowModal; - finally - Dlg.Free; - end; - end; -end; -{$ENDIF} { TFindUnitDialog } @@ -702,7 +606,6 @@ begin Caption:='Remove unit from uses clause'; end; -{$IFNDEF EnableOldExtTools} { TQuickFixIncludeNotFound_Search } function TQuickFixIncludeNotFound_Search.IsApplicable(Msg: TMessageLine; out @@ -766,61 +669,6 @@ begin end; end; -{$ELSE EnableOldExtTools} -constructor TQuickFixIncludeNotFound_Search.Create; -begin - Name:='Search include file: Error: include file not found'; - Caption:=lisSearchUnit; - Steps:=[imqfoMenuItem]; -end; - -function TQuickFixIncludeNotFound_Search.IsApplicable(Line: TIDEMessageLine - ): boolean; -var - Filename: string; -begin - Result:=IsCodetoolsErrorIncludeFileNotFound(Line.Msg,Filename) - and (Filename<>''); -end; - -procedure TQuickFixIncludeNotFound_Search.Execute(const Msg: TIDEMessageLine; - Step: TIMQuickFixStep); -var - CodeBuf: TCodeBuffer; - Filename, IncludeFilename: string; - Caret: TPoint; - Dlg: TFindUnitDialog; -begin - if Step=imqfoMenuItem then begin - DebugLn(['TQuickFixIncludeNotFound_Search.Execute ']); - // get source position - if not GetMsgLineFile(Msg,CodeBuf,false) then exit; - Msg.GetSourcePosition(Filename,Caret.Y,Caret.X); - if not LazarusIDE.BeginCodeTools then begin - DebugLn(['TQuickFixIncludeNotFound_Search.Execute failed because IDE busy']); - exit; - end; - - // get include file name - if not IsCodetoolsErrorIncludeFileNotFound(Msg.Msg,IncludeFilename) then - begin - DebugLn('TQuickFixIncludeNotFound_Search invalid message ',Msg.Msg); - exit; - end; - DebugLn(['TQuickFixIncludeNotFound_Search.Execute include file=',IncludeFilename]); - - // show dialog - Dlg:=TFindUnitDialog.Create(nil); - try - Dlg.InitWithMsg(Msg.Msg,CodeBuf,IncludeFilename); - Dlg.ShowModal; - finally - Dlg.Free; - end; - end; -end; -{$ENDIF} - function TQuickFixIncludeNotFound_Search.IsCodetoolsErrorIncludeFileNotFound( Msg: string; out IncludeFile: string): boolean; var diff --git a/ide/frames/compiler_messages_options.pas b/ide/frames/compiler_messages_options.pas index bbe118fbef..49bc99da34 100644 --- a/ide/frames/compiler_messages_options.pas +++ b/ide/frames/compiler_messages_options.pas @@ -8,11 +8,7 @@ uses Classes, SysUtils, FileUtil, LazFileCache, LazLoggerBase, ListFilterEdit, StdCtrls, CheckLst, Dialogs, IDEOptionsIntf, IDEMsgIntf, IDEExternToolIntf, MacroIntf, IDEDialogs, CompOptsIntf, CodeToolsFPCMsgs, CompilerOptions, - LazarusIDEStrConsts - {$IFNDEF EnableOldExtTools} - ,etFPCMsgParser - {$ENDIF} - ; + LazarusIDEStrConsts, etFPCMsgParser; type @@ -31,7 +27,7 @@ type procedure MsgFileBrowseButtonClick(Sender: TObject); procedure UseMsgFileCheckBoxChange(Sender: TObject); private - TempMessages: {$IFNDEF EnableOldExtTools}TCompilerMsgIDFlags{$ELSE}TCompilerMessagesList{$ENDIF}; + TempMessages: TCompilerMsgIDFlags; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; @@ -50,18 +46,10 @@ implementation { TCompilerMessagesOptionsFrame } procedure TCompilerMessagesOptionsFrame.chklistCompMsgItemClick(Sender: TObject; Index: integer); -{$IFNDEF EnableOldExtTools} var MsgId: Integer; -{$ELSE} -const - BoolToMessageState: array[Boolean] of TCompilerMessageState = (msOff, msOn); -var - m: TCompilerMessageConfig; -{$ENDIF} begin if (Index < 0) or (Index >= chklistCompMsg.Items.Count) then exit; - {$IFNDEF EnableOldExtTools} MsgId:=Integer(PtrUInt(Pointer(chklistCompMsg.Items.Objects[Index]))); if MsgId<=0 then exit; if chklistCompMsg.Checked[Index] then begin @@ -69,17 +57,9 @@ begin TempMessages[MsgId]:=cfvNone end else TempMessages[MsgId]:=cfvHide; - {$ELSE} - m := TCompilerMessageConfig(chklistCompMsg.Items.Objects[Index]); - if (m.DefIgnored <> chklistCompMsg.Checked[Index]) then - m.State := msDefault - else - m.State := BoolToMessageState[chklistCompMsg.Checked[Index]]; - {$ENDIF} end; function TCompilerMessagesOptionsFrame.CheckItem(Item: TObject): Boolean; -{$IFNDEF EnableOldExtTools} var MsgId: Integer; begin @@ -89,17 +69,6 @@ begin if MsgId<=0 then exit; Result:=TempMessages[MsgId]<>cfvHide; end; -{$ELSE} -var - m: TCompilerMessageConfig; -begin - m := Item as TCompilerMessageConfig; - if m.State = msDefault then - Result := not m.DefIgnored - else - Result := m.State = msOn; -end; -{$ENDIF} procedure TCompilerMessagesOptionsFrame.MsgFileBrowseButtonClick(Sender: TObject ); @@ -129,23 +98,14 @@ end; constructor TCompilerMessagesOptionsFrame.Create(TheOwner: TComponent); begin inherited Create(TheOwner); - {$IFNDEF EnableOldExtTools} TempMessages:=TCompilerMsgIDFlags.Create; UseMsgFileCheckBox.Visible:=false; MsgFileEdit.Visible:=false; MsgFileBrowseButton.Visible:=false; - {$ELSE} - TempMessages:=TCompilerMessagesList.Create; - {$ENDIF} end; destructor TCompilerMessagesOptionsFrame.Destroy; begin - {$IFNDEF EnableOldExtTools} - {$ELSE} - editMsgFilter.Items.Clear; - chklistCompMsg.Clear; - {$ENDIF} FreeAndNil(TempMessages); inherited Destroy; end; @@ -159,32 +119,21 @@ procedure TCompilerMessagesOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDia begin grpCompilerMessages.Caption:=dlgCompilerMessage; lblFilter.Caption:=lisFilter; - {$IFNDEF EnableOldExtTools} - {$ELSE} - UseMsgFileCheckBox.Caption:=lisUseMessageFile; - MsgFileBrowseButton.Caption:=lisPathEditBrowse; - {$ENDIF} end; procedure TCompilerMessagesOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions); var topidx: Integer; CompOpts: TBaseCompilerOptions; - {$IFNDEF EnableOldExtTools} FPCMsgFile: TFPCMsgFilePoolItem; i: Integer; Item: TFPCMsgItem; Urgency: TMessageLineUrgency; s: String; - {$ELSE} - i: integer; - m: TCompilerMessageConfig; - {$ENDIF} begin CompOpts:=AOptions as TBaseCompilerOptions; topidx := chklistCompMsg.TopIndex; - {$IFNDEF EnableOldExtTools} TempMessages.Assign(CompOpts.MessageFlags); editMsgFilter.Items.Clear; FPCMsgFile:=FPCMsgFilePool.LoadCurrentEnglishFile(true,nil); @@ -207,25 +156,6 @@ begin FPCMsgFilePool.UnloadFile(FPCMsgFile); end; end; - {$ELSE} - TempMessages.Assign(CompOpts.CompilerMessages); - UseMsgFileCheckBox.Checked:=CompOpts.UseMsgFile; - MsgFileEdit.Text:=CompOpts.MsgFileName; - MsgFileEdit.Enabled:=UseMsgFileCheckBox.Checked; - MsgFileBrowseButton.Enabled:=UseMsgFileCheckBox.Checked; - - // Copy data to filter component - editMsgFilter.Items.Clear; - for i := 0 to TempMessages.Count - 1 do - begin - m := TempMessages.Msg[i]; - case m.MsgType of - etHint: editMsgFilter.Items.AddObject('(H) '+m.MsgText, m); - etNote: editMsgFilter.Items.AddObject('(N) '+m.MsgText, m); - etWarning: editMsgFilter.Items.AddObject('(W) '+m.MsgText, m); - end; - end; - {$ENDIF} editMsgFilter.InvalidateFilter; chkListCompMsg.TopIndex := topidx; end; @@ -234,13 +164,7 @@ procedure TCompilerMessagesOptionsFrame.WriteSettings(AOptions: TAbstractIDEOpti begin with AOptions as TBaseCompilerOptions do begin - {$IFNDEF EnableOldExtTools} MessageFlags.Assign(TempMessages); - {$ELSE} - UseMsgFile:=UseMsgFileCheckBox.Checked; - MsgFileName:=MsgFileEdit.Text; - CompilerMessages.Assign(TempMessages); - {$ENDIF} end; end; diff --git a/ide/frames/compiler_verbosity_options.pas b/ide/frames/compiler_verbosity_options.pas index 51a2dc195e..451b58d5f2 100644 --- a/ide/frames/compiler_verbosity_options.pas +++ b/ide/frames/compiler_verbosity_options.pas @@ -53,16 +53,10 @@ begin Items.Add(dlgShowGeneralInfo + ' (-vi)'); Items.Add(dlgShowCompilingLineNumbers + ' (-vl)'); Items.Add(dlgShowCompiledProcedures + ' (-vp)'); - {$IFDEF EnableOldExtTools} - Items.Add(dlgShowFullFileNames + ' (-vb)'); - {$ENDIF} Items.Add(dlgShowConditionals + ' (-vc)'); Items.Add(dlgShowEverything + ' (-va)'); Items.Add(dlgShowExecutableInfo + ' (-vx)'); Items.Add(dlgShowSummary + ' ' + dlgPOIconDescNone); - {$IFDEF EnableOldExtTools} - Items.Add(dlgShowNothing + ' (-v0)'); - {$ENDIF} Items.Add(dlgHintsUnused + ' ' + dlgPOIconDescNone); Items.Add(dlgWriteFPCLogo + ' (-l)'); end; @@ -89,16 +83,10 @@ begin Checked[i] := ShowGenInfo; i+=1; Checked[i] := ShowLineNum; i+=1; Checked[i] := ShowCompProc; i+=1; - {$IFDEF EnableOldExtTools} - Checked[i] := ShowAllProcsOnError; i+=1; - {$ENDIF} Checked[i] := ShowCond; i+=1; Checked[i] := ShowAll; i+=1; Checked[i] := ShowExecInfo; i+=1; Checked[i] := ShowSummary; i+=1; - {$IFDEF EnableOldExtTools} - Checked[i] := ShowNothing; i+=1; - {$ENDIF} Checked[i] := ShowHintsForUnusedUnitsInMainSrc; i+=1; Checked[i] := WriteFPCLogo; i+=1; @@ -124,16 +112,10 @@ begin ShowGenInfo := Checked[i]; i+=1; ShowLineNum := Checked[i]; i+=1; ShowCompProc := Checked[i]; i+=1; - {$IFDEF EnableOldExtTools} - ShowAllProcsOnError := Checked[i]; i+=1; - {$ENDIF} ShowCond := Checked[i]; i+=1; ShowAll := Checked[i]; i+=1; ShowExecInfo := Checked[i]; i+=1; ShowSummary := Checked[i]; i+=1; - {$IFDEF EnableOldExtTools} - ShowNothing := Checked[i]; i+=1; - {$ENDIF} ShowHintsForUnusedUnitsInMainSrc := Checked[i]; i+=1; WriteFPCLogo := Checked[i]; i+=1; StopAfterErrCount := StrToIntDef(edtErrorCnt.Text, 1); diff --git a/ide/frames/files_options.pas b/ide/frames/files_options.pas index 4727ac5179..e52f45a044 100644 --- a/ide/frames/files_options.pas +++ b/ide/frames/files_options.pas @@ -221,13 +221,8 @@ begin MaxRecentOpenFilesLabel.Caption:=dlgMaxRecentFiles; MaxRecentProjectFilesLabel.Caption:=dlgMaxRecentProjs; OpenLastProjectAtStartCheckBox.Caption:=dlgQOpenLastPrj; - {$IFNDEF EnableOldExtTools} ShowCompileDialogCheckBox.Visible:=false; AutoCloseCompileDialogCheckBox.Visible:=false; - {$ELSE} - ShowCompileDialogCheckBox.Caption:=dlgQShowCompileDialog; - AutoCloseCompileDialogCheckBox.Caption:=dlgQAutoCloseCompileDialog; - {$ENDIF} LazarusDirLabel.Caption:=dlgLazarusDir; with LazarusDirComboBox.Items do begin diff --git a/ide/frames/msgwnd_options.pas b/ide/frames/msgwnd_options.pas index 51f1bbe779..8984b5ccde 100644 --- a/ide/frames/msgwnd_options.pas +++ b/ide/frames/msgwnd_options.pas @@ -167,10 +167,6 @@ begin fReady:=false; FDialog := ADialog; MWSetEditorColorsButton.Visible:=false; - {$IFNDEF EnableOldExtTools} - {$ELSE} - MWColorsGroupBox.Visible:=false; - {$ENDIF} end; procedure TMsgWndOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions); diff --git a/ide/ideoptiondefs.pas b/ide/ideoptiondefs.pas index 19a1c9467d..af50acb359 100644 --- a/ide/ideoptiondefs.pas +++ b/ide/ideoptiondefs.pas @@ -127,7 +127,7 @@ const 'JumpHistory', 'ComponentList' ); -{$IFNDEF EnableOldExtTools} + type TLMsgViewFilter = class; @@ -222,7 +222,6 @@ type function CompareFilterMsgType(FilterMsgType1, FilterMsgType2: Pointer): integer; function CompareLineAndFilterMsgType(MessageLine1, FilterMsgType1: Pointer): integer; -{$ENDIF} function CreateNiceWindowPosition(Width, Height: integer): TRect; function NonModalIDEFormIDToEnum(const FormID: string): TNonModalIDEWindow; @@ -323,7 +322,6 @@ begin Result:=TXMLOptionsStorage.Create(ConfigFilename,LoadFromDisk); end; -{$IFNDEF EnableOldExtTools} function CompareFilterMsgType(FilterMsgType1, FilterMsgType2: Pointer): integer; var Item1: TLMVFilterMsgType absolute FilterMsgType1; @@ -506,7 +504,6 @@ begin for i:=1 to Count do Filters[i-1].SaveToXMLConfig(XMLConfig,Path+'Filter'+IntToStr(i)+'/'); end; -{$ENDIF} { TXMLOptionsStorage } @@ -617,7 +614,6 @@ begin Result:=FXMLConfig.Filename; end; -{$IFNDEF EnableOldExtTools} { TLMVFilterMsgType } procedure TLMVFilterMsgType.SetMsgID(AValue: integer); @@ -964,7 +960,6 @@ begin E(IntToStr(i)); end; end; -{$ENDIF} initialization DefaultConfigClass:=TXMLOptionsStorage; diff --git a/ide/mainbase.pas b/ide/mainbase.pas index 224066d625..ed139dbfc0 100644 --- a/ide/mainbase.pas +++ b/ide/mainbase.pas @@ -63,12 +63,7 @@ uses IDECommands, IDEMsgIntf, IDEWindowIntf, // IDE LazConf, LazarusIDEStrConsts, ProjectDefs, Project, PublishModule, - BuildLazDialog, Compiler, ComponentReg, - {$IFNDEF EnableOldExtTools} - etMessagesWnd, - {$ELSE} - OutputFilter, MsgView, - {$ENDIF} + BuildLazDialog, Compiler, ComponentReg, etMessagesWnd, TransferMacros, ObjectInspector, PropEdits, IDEDefs, EnvironmentOpts, EditorOptions, CompilerOptions, KeyMapping, IDEProcs, Debugger, IDEOptionDefs, CodeToolsDefines, Splash, Designer, @@ -136,9 +131,6 @@ type procedure mnuCenterWindowItemClick(Sender: TObject); virtual; procedure mnuWindowSourceItemClick(Sender: TObject); virtual; - {$IFDEF EnableOldExtTools} - procedure ConnectOutputFilter; - {$ENDIF} procedure UpdateWindowMenu; public @@ -302,17 +294,6 @@ begin SourceEditorManager.ShowActiveWindowOnTop(True); end; -{$IFDEF EnableOldExtTools} -procedure TMainIDEBase.ConnectOutputFilter; -begin - TheOutputFilter.OnAddFilteredLine:=@MessagesView.AddMsg; - TheOutputFilter.OnReadLine:=@MessagesView.AddProgress; - TheOutputFilter.OnEndReading:=@MessagesView.CollectLineParts; - TheOutputFilter.OnBeginUpdate:=@MessagesView.BeginUpdateNotification; - TheOutputFilter.OnEndUpdate:=@MessagesView.EndUpdateNotification; -end; -{$ENDIF} - procedure TMainIDEBase.SetToolStatus(const AValue: TIDEToolStatus); begin if FToolStatus=AValue then exit; diff --git a/ide/msgquickfixes.pas b/ide/msgquickfixes.pas deleted file mode 100644 index 18345934a4..0000000000 --- a/ide/msgquickfixes.pas +++ /dev/null @@ -1,1201 +0,0 @@ -{ - *************************************************************************** - * * - * This source is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This code is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * General Public License for more details. * - * * - * A copy of the GNU General Public License is available on the World * - * Wide Web at . You can also * - * obtain it by writing to the Free Software Foundation, * - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * * - *************************************************************************** -} -(* - Author: Mattias Gaertner - - Abstract: - Defines the standard message Quick Fix menu items. - - ToDo: - - There is no method in an ancestor class to be overriden: - 1. option: if the ancestor has a function with the same name: update the parameter list - 2. option: remove the method - 3. option: add a virtual method to the ancestor - - complete function implementations with missing parameters - - private variable not used => remove - - Hint: Local variable "Path" does not seem to be initialized - auto add begin+end - Pointer:=nil - integer:=0 - string:='' - record: FillByte(p{%H-},SizeOf(p),0) - set:=[] - enum:=low(enum); - -*) -unit MsgQuickFixes; - -{$IFNDEF EnableOldExtTools} - {$ERROR deprecated} -{$ENDIF} - -{$mode objfpc}{$H+} - -interface - -uses - Classes, SysUtils, LCLProc, Controls, Dialogs, FileUtil, KeywordFuncLists, - BasicCodeTools, CodeTree, CodeAtom, CodeCache, CodeToolManager, - DirectoryCacher, FileProcs, IDEMsgIntf, TextTools, ProjectIntf, LazIDEIntf, - PackageIntf, IDEDialogs, AbstractsMethodsDlg, LazarusIDEStrConsts, - EnvironmentOpts; - -type - - { TQuickFixIdentifierNotFoundAddLocal } - - TQuickFixIdentifierNotFoundAddLocal = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; - - { TQuickFixUnitNotFoundPosition - improve message } - - TQuickFixUnitNotFoundPosition = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; - - { TQuickFixUnitNotFound_Remove - add menu item to remove unit from uses section } - - TQuickFixUnitNotFound_Remove = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; - - { TQuickFixErrorWhileCompilingResources_Hint - improve message } - - TQuickFixErrorWhileCompilingResources_Hint = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; - - { TQuickFixJumpToLinkerUndefinedReference } - - TQuickFixJumpToLinkerUndefinedReference = class(TIDEMsgQuickFixItem) - public - constructor Create; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; - - { TQuickFixClassWithAbstractMethods - Quick fix for example: - Warning: Constructing a class "TClassA" with abstract methods } - - TQuickFixClassWithAbstractMethods = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; - - { TQuickFixLocalVariableNotUsed_Remove } - - TQuickFixLocalVariableNotUsed_Remove = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; - - { TQuickFixHint_Hide } - - TQuickFixHint_Hide = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; - -procedure QuickFixParameterNotUsed(Sender: TObject; Step: TIMQuickFixStep; - Msg: TIDEMessageLine); -procedure QuickFixUnitNotUsed(Sender: TObject; Step: TIMQuickFixStep; - Msg: TIDEMessageLine); - -function GetMsgLineFile(Msg: TIDEMessageLine; - out CodeBuf: TCodeBuffer; Quiet: boolean): boolean; -function IsFileInIDESrcDir(Filename: string): boolean; - -procedure InitStandardIDEQuickFixItems; -procedure FreeStandardIDEQuickFixItems; - -implementation - -procedure ShowError(Msg: string); -begin - IDEMessageDialog('QuickFix error',Msg,mtError,[mbCancel]); -end; - -function IsIdentifierInCode(Code: TCodeBuffer; X,Y: integer; - Identifier, ErrorMsg: string): boolean; -var - p: integer; - IdentStart: integer; - IdentEnd: integer; -begin - Result:=false; - if Code=nil then begin - ShowError(ErrorMsg+' (Code=nil)'); - exit; - end; - Code.LineColToPosition(Y,X,p); - if p<1 then begin - ShowError(ErrorMsg+' (position outside of source'); - exit; - end; - GetIdentStartEndAtPosition(Code.Source,p,IdentStart,IdentEnd); - if SysUtils.CompareText(Identifier,copy(Code.Source,IdentStart,IdentEnd-IdentStart))<>0 - then begin - ShowError(ErrorMsg); - exit; - end; - Result:=true; -end; - -procedure QuickFixParameterNotUsed(Sender: TObject; Step: TIMQuickFixStep; - Msg: TIDEMessageLine); -begin - DebugLn('QuickFixParameterNotUsed '); -end; - -procedure QuickFixUnitNotUsed(Sender: TObject; Step: TIMQuickFixStep; - Msg: TIDEMessageLine); -var - CodeBuf: TCodeBuffer; - UnneededUnitname: String; - OldChange: Boolean; -begin - if Step<>imqfoMenuItem 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 - DebugLn('QuickFixUnitNotUsed invalid message ',Msg.Msg); - ShowError('QuickFix: UnitNotUsed invalid message '+Msg.Msg); - exit; - end; - UnneededUnitname:=REVar(1); - - // remove unit - if not LazarusIDE.BeginCodeTools then exit; - OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange; - LazarusIDE.OpenEditorsOnCodeToolChange:=true; - try - LazarusIDE.SaveSourceEditorChangesToCodeCache(nil); - if not CodeToolBoss.RemoveUnitFromAllUsesSections(CodeBuf,UnneededUnitname) - then begin - LazarusIDE.DoJumpToCodeToolBossError; - exit; - end; - finally - LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange; - end; - - // message fixed - Msg.Msg:=''; -end; - -function GetMsgLineFile(Msg: TIDEMessageLine; out CodeBuf: TCodeBuffer; - Quiet: boolean): boolean; -var - Filename: String; - TestDir: String; -begin - Result:=false; - CodeBuf:=nil; - if Msg.Parts=nil then begin - DebugLn('GetMsgLineFilename Msg.Parts=nil'); - if not Quiet then begin - IDEMessageDialog(lisCCOErrorCaption, - Format(lisMessageContainsNoFilePositionInformation, [LineEnding, Msg.Msg]), - mtError, [mbCancel]); - end; - exit; - end; - - Filename:=Msg.Parts.Values['Filename']; - TestDir:=LazarusIDE.GetTestBuildDirectory; - if (TestDir<>'') and (FileIsInDirectory(Filename,TestDir)) then - Filename:=ExtractFileName(Filename) - else if not FilenameIsAbsolute(Filename) then - Filename:=AppendPathDelim(Msg.Directory)+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.'); - if not Quiet then begin - IDEMessageDialog(lisCCOErrorCaption, - Format(lisUnableToLoadFile, [LineEnding, Filename]), mtError, [mbCancel]); - end; - exit; - end; - Result:=true; -end; - -function IsFileInIDESrcDir(Filename: string): boolean; -var - LazDir: String; -begin - Filename:=TrimFilename(Filename); - if not FilenameIsAbsolute(Filename) then exit(false); - LazDir:=AppendPathDelim(EnvironmentOptions.GetParsedLazarusDirectory); - Result:=FileIsInPath(Filename,LazDir+'ide') - or FileIsInPath(Filename,LazDir+'debugger') - or FileIsInPath(Filename,LazDir+'packager') - or FileIsInPath(Filename,LazDir+'converter') - or FileIsInPath(Filename,LazDir+'designer'); -end; - -procedure InitStandardIDEQuickFixItems; -begin - IDEMsgQuickFixes:=TIDEMsgQuickFixItems.Create; - - //RegisterIDEMsgQuickFix('Parameter xxx not used','Quick fix: Add dummy line', - // 'Parameter "[a-z_0-9]+" not used',nil,@QuickFixParameterNotUsed); - RegisterIDEMsgQuickFix('Unit xxx not used in yyy', lisQuickFixRemoveUnit, - 'Unit "[a-z_0-9]+" not used in [a-z_0-9]+',[imqfoMenuItem], - nil,@QuickFixUnitNotUsed); - - RegisterIDEMsgQuickFix(TQuickFixUnitNotFoundPosition.Create); - RegisterIDEMsgQuickFix(TQuickFixUnitNotFound_Remove.Create); - RegisterIDEMsgQuickFix(TQuickFixJumpToLinkerUndefinedReference.Create); - RegisterIDEMsgQuickFix(TQuickFixErrorWhileCompilingResources_Hint.Create); - RegisterIDEMsgQuickFix(TQuickFixClassWithAbstractMethods.Create); - RegisterIDEMsgQuickFix(TQuickFixIdentifierNotFoundAddLocal.Create); - RegisterIDEMsgQuickFix(TQuickFixLocalVariableNotUsed_Remove.Create); - RegisterIDEMsgQuickFix(TQuickFixHint_Hide.Create); -end; - -procedure FreeStandardIDEQuickFixItems; -begin - FreeThenNil(IDEMsgQuickFixes); -end; - -{ TQuickFixErrorWhileCompilingResources_Hint } - -constructor TQuickFixErrorWhileCompilingResources_Hint.Create; -begin - Name:='Improve error message: Error while compiling resources'; - Steps:=[imqfoImproveMessage]; -end; - -function TQuickFixErrorWhileCompilingResources_Hint.IsApplicable( - Line: TIDEMessageLine): boolean; -const - SearchStr = 'Error while compiling resources'; -var - Msg: String; - p: integer; -begin - Result:=false; - if (Line.Parts=nil) then exit; - Msg:=Line.Msg; - p:=System.Pos(SearchStr,Msg); - if p<1 then exit; - Result:=true; -end; - -procedure TQuickFixErrorWhileCompilingResources_Hint.Execute( - const Msg: TIDEMessageLine; Step: TIMQuickFixStep); -var - s: String; -begin - if Step<>imqfoImproveMessage then exit; - s:=Msg.Msg; - if s[length(s)]<>'.' then s+='.'; - s+=' Compile with -vd for more details. Check for duplicates.'; - Msg.Msg:=s; -end; - -{ TQuickFixUnitNotFoundPosition } - -constructor TQuickFixUnitNotFoundPosition.Create; -begin - Name:='Improve error position of: Fatal: Can''t find unit xxx'; - Steps:=[imqfoImproveMessage]; -end; - -function TQuickFixUnitNotFoundPosition.IsApplicable(Line: TIDEMessageLine - ): boolean; -var - Msg: String; -begin - if Line.Parts=nil then exit(false); - Msg:=Line.Msg; - Result:=(System.Pos(') Fatal: Can''t find unit ',Msg)>0) - or (System.Pos(') Fatal: Can not find unit ',Msg)>0) - or (System.Pos('Fatal: Can''t find unit ',Msg)=1) - or (System.Pos('Fatal: Can not find unit ',Msg)=1); -end; - -procedure TQuickFixUnitNotFoundPosition.Execute(const Msg: TIDEMessageLine; - Step: TIMQuickFixStep); -// for example: -// Fatal: Can't find unit Unit12 used by testunit1 -// /home/user/laz/main.pp(1,1) Fatal: Can't find unit lazreport used by lazarus - - procedure FixSourcePos(CodeBuf: TCodeBuffer; MissingUnitname: string; - var NewFilename: string; var Dir: string); - var - Caret: TCodeXYPosition; - Tool: TCodeTool; - InPos: Integer; - NamePos: Integer; - begin - {$IFDEF VerboseQuickFixUnitNotFoundPosition} - debugln(['TQuickFixUnitNotFoundPosition.Execute File=',CodeBuf.Filename]); - {$ENDIF} - 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); - Dir:=AppendPathDelim(TrimFilename(Msg.Directory)); - end; - end; - - procedure FindPPUInInstalledPkgs(MissingUnitname: string; - var PPUFilename, PkgName: string); - var - i: Integer; - Pkg: TIDEPackage; - DirCache: TCTDirectoryCache; - UnitOutDir: String; - begin - // search ppu in installed packages - for i:=0 to PackageEditingInterface.GetPackageCount-1 do begin - Pkg:=PackageEditingInterface.GetPackages(i); - if Pkg.AutoInstall=pitNope then continue; - UnitOutDir:=Pkg.LazCompilerOptions.GetUnitOutputDirectory(false); - //debugln(['TQuickFixUnitNotFoundPosition.Execute ',Pkg.Name,' UnitOutDir=',UnitOutDir]); - if FilenameIsAbsolute(UnitOutDir) then begin - DirCache:=CodeToolBoss.DirectoryCachePool.GetCache(UnitOutDir,true,false); - PPUFilename:=DirCache.FindFile(MissingUnitname+'.ppu',ctsfcLoUpCase); - //debugln(['TQuickFixUnitNotFoundPosition.Execute ShortPPU=',PPUFilename]); - if PPUFilename<>'' then begin - PkgName:=Pkg.Name; - PPUFilename:=AppendPathDelim(DirCache.Directory)+PPUFilename; - break; - end; - end; - end; - end; - - procedure FindPackage(MissingUnitname: string; var PkgName: string; - OnlyInstalled: boolean); - var - i: Integer; - Pkg: TIDEPackage; - j: Integer; - PkgFile: TLazPackageFile; - begin - if PkgName='' then begin - // search unit in installed packages - for i:=0 to PackageEditingInterface.GetPackageCount-1 do begin - Pkg:=PackageEditingInterface.GetPackages(i); - if OnlyInstalled and (Pkg.AutoInstall=pitNope) then continue; - if CompareTextCT(Pkg.Name,MissingUnitname)=0 then begin - PkgName:=Pkg.Name; - break; - end; - for j:=0 to Pkg.FileCount-1 do begin - PkgFile:=Pkg.Files[j]; - if not FilenameIsPascalUnit(PkgFile.Filename) then continue; - if CompareTextCT(ExtractFileNameOnly(PkgFile.Filename),MissingUnitname)<>0 - then continue; - PkgName:=Pkg.Name; - break; - end; - end; - end; - end; - -var - CodeBuf: TCodeBuffer; - MissingUnitname: String; - UsedByUnit: String; - NewFilename: String; // referencing unit - Dir: String; - PPUFilename: String; - s: String; - Filename: string; - Line: integer; - Col: integer; - PkgName: String; - OnlyInstalled: Boolean; - Owners: TFPList; - UsedByOwner: TObject; -begin - if Step<>imqfoImproveMessage then exit; - {$IFDEF VerboseQuickFixUnitNotFoundPosition} - DebugLn('QuickFixUnitNotFoundPosition START'); - {$ENDIF} - - if not REMatches(Msg.Msg,'Can(''t| not) find unit ([a-z_.0-9]+) used by ','I') - then begin - {$IFDEF VerboseQuickFixUnitNotFoundPosition} - DebugLn('QuickFixUnitNotFoundPosition invalid message ',Msg.Msg); - {$ENDIF} - exit; - end; - Dir:=AppendPathDelim(TrimFilename(Msg.Directory)); - if Dir='' then exit; - - Msg.GetSourcePosition(Filename,Line,Col); - Filename:=TrimFilename(Filename); - MissingUnitname:=REVar(2); - UsedByUnit:=''; - if REMatches(Msg.Msg,'Can(''t| not) find unit ([a-z_.0-9]+) used by ([a-z_.0-9]+)','I') - then begin - UsedByUnit:=REVar(3); - {$IFDEF VerboseQuickFixUnitNotFoundPosition} - debugln(['TQuickFixUnitNotFoundPosition.Execute Missing="',MissingUnitname,'" used by "',UsedByUnit,'"']); - {$ENDIF} - - if (CompareFilenames(ExtractFileName(Filename),'staticpackages.inc')=0) - and IsFileInIDESrcDir(Dir+'test') then begin - // common case: when building the IDE a package unit is missing - // staticpackages.inc(1,1) Fatal: Can't find unit sqldblaz used by Lazarus - // change to lazarus.pp(1,1) - NewFilename:=AppendPathDelim(EnvironmentOptions.GetParsedLazarusDirectory)+'ide'+PathDelim; - Msg.SetSourcePosition(NewFilename,1,1); - Msg.Msg:='lazarus.pp(1,1) Fatal: Can''t find a valid '+MissingUnitname+'.ppu'; - Dir:=AppendPathDelim(TrimFilename(Msg.Directory)); - end else if SysUtils.CompareText(ExtractFileNameOnly(Filename),UsedByUnit)<>0 - then begin - // the message belongs to another unit - NewFilename:=''; - if FilenameIsAbsolute(Dir) then - begin - // For example: /path/laz/main.pp(1,1) Fatal: Can't find unit lazreport used by lazarus - // => search source lazarus in directory - NewFilename:=CodeToolBoss.DirectoryCachePool.FindUnitInDirectory( - Dir,UsedByUnit,true); - end; - if NewFilename='' then begin - NewFilename:=LazarusIDE.FindUnitFile(UsedByUnit); - if NewFilename='' then begin - {$IFDEF VerboseQuickFixUnitNotFoundPosition} - DebugLn('QuickFixUnitNotFoundPosition unit not found: ',UsedByUnit); - {$ENDIF} - //ShowError('QuickFix: UnitNotFoundPosition unit not found: '+UsedByUnit); - end; - end; - end; - end; - - // load source - CodeBuf:=nil; - if (NewFilename='') and (FilenameIsAbsolute(Filename)) then - NewFilename:=Filename; - if NewFilename<>'' then begin - CodeBuf:=CodeToolBoss.LoadFile(NewFilename,false,false); - if CodeBuf=nil then begin - {$IFDEF VerboseQuickFixUnitNotFoundPosition} - DebugLn('QuickFixUnitNotFoundPosition unable to load unit: ',NewFilename); - {$ENDIF} - //ShowError('QuickFix: UnitNotFoundPosition unable to load unit: '+NewFilename); - end; - end else begin - {$IFDEF VerboseQuickFixUnitNotFoundPosition} - DebugLn('QuickFixUnitNotFoundPosition unable to locate UsedByUnit: ',UsedByUnit); - {$ENDIF} - end; - - // fix line and column - Owners:=nil; - UsedByOwner:=nil; - try - if CodeBuf<>nil then begin - FixSourcePos(CodeBuf,MissingUnitname,NewFilename,Dir); - Owners:=PackageEditingInterface.GetOwnersOfUnit(NewFilename); - if (Owners<>nil) and (Owners.Count>0) then - UsedByOwner:=TObject(Owners[0]); - end; - - // if the ppu is there then improve the message - {$IFDEF VerboseQuickFixUnitNotFoundPosition} - debugln(['TQuickFixUnitNotFoundPosition.Execute Dir=',Dir]); - {$ENDIF} - if FilenameIsAbsolute(Dir) then begin - PPUFilename:=CodeToolBoss.DirectoryCachePool.FindCompiledUnitInCompletePath( - Dir,MissingUnitname); - {$IFDEF VerboseQuickFixUnitNotFoundPosition} - debugln(['TQuickFixUnitNotFoundPosition.Execute PPUFilename=',PPUFilename,' IsFileInIDESrcDir=',IsFileInIDESrcDir(Dir+'test')]); - {$ENDIF} - PkgName:=''; - OnlyInstalled:=IsFileInIDESrcDir(Dir+'test'); - if OnlyInstalled and (PPUFilename='') then begin - FindPPUInInstalledPkgs(MissingUnitname,PPUFilename,PkgName); - end; - - FindPackage(MissingUnitname,PkgName,OnlyInstalled); - if PPUFilename<>'' then begin - // there is a ppu file in the unit path - if PPUFilename<>'' then begin - // there is a ppu file, but the compiler didn't like it - // => change message - s:=Format(lisCannotFind, [MissingUnitname]); - if UsedByUnit<>'' then - s+=Format(lisUsedBy, [UsedByUnit]); - s+=', PPU='+CreateRelativePath(PPUFilename,Dir); - if PkgName<>'' then - s+=Format(lisPackage3, [PkgName]); - end else if PkgName<>'' then begin - // ppu is missing, but the package is known - // => change message - s:=Format(lisCannotFindPP, [MissingUnitname]); - if UsedByUnit<>'' then - s+=Format(lisUsedBy, [UsedByUnit]); - s+=Format(lisMaybePackage, [PkgName]); - end; - end else begin - // there is no ppu file in the unit path - s:=Format(lisCannotFindUnit, [MissingUnitname]); - if UsedByUnit<>'' then - s+=Format(lisUsedBy, [UsedByUnit]); - if (UsedByOwner is TIDEPackage) - and (CompareTextCT(TIDEPackage(UsedByOwner).Name,PkgName)=0) then - begin - // two units of a package can not find each other - s+=Format(lisCheckSearchPathPackageTryACleanRebuildCheckImpleme, [TIDEPackage(UsedByOwner).Name]); - end else begin - if PkgName<>'' then - s+=Format(lischeckifpackageisinthedependencies, [PkgName]); - if UsedByOwner is TLazProject then - s+=lisoftheprojectinspector - else if UsedByOwner is TIDEPackage then - s+=Format(lisOfPackage, [TIDEPackage(UsedByOwner).Name]); - end; - s+='.'; - end; - Msg.GetSourcePosition(Filename,Line,Col); - Msg.Msg:=Format(lisFatal2, [CreateRelativePath(Filename, Msg.Directory), - IntToStr(Line), IntToStr(Col), s]); - {$IFDEF VerboseQuickFixUnitNotFoundPosition} - debugln(['TQuickFixUnitNotFoundPosition.Execute Msg.Msg="',Msg.Msg,'"']); - {$ENDIF} - end; - finally - Owners.Free; - end; -end; - -{ TQuickFixJumpToLinkerUndefinedReference } - -constructor TQuickFixJumpToLinkerUndefinedReference.Create; -var - re: String; -begin - Name:='Linker: undefined reference to'; - Steps:=[imqfoJump]; - re:='((.*:[0-9]+)?: .* `(.*)'')'; // e.g. some.inc:37: undefined reference to `DoesNotExist' - re+='|((.*)\(\.text.*?\): .* `([A-Z0-9_$]+)'':)'; // e.g. unit1.o(.text+0x1a): In function `SubProc': - re+='|((.*)\.o: .* `([A-Z0-9_$]+)'':)'; // e.g. unit1.o: In function `SubProc': - re:='^'+re+'$'; - RegExpression:=re; -end; - -procedure TQuickFixJumpToLinkerUndefinedReference.Execute(const Msg: TIDEMessageLine; - Step: TIMQuickFixStep); -{ Examples: - /usr/lib/fpc/2.1.1/units/i386-linux/gtk2/gtk2.o(.text+0xbba1): In function `GTK2_GTK_TYPE_CELL_RENDERER_COMBO$$LONGWORD': - : undefined reference to `gtk_cell_renderer_combo_get_type' - - unit1.o(.text+0x1a): In function `SubProc': - some.inc:37: undefined reference to `DoesNotExist' - - unit1.o(.text+0x3a):some.inc:48: undefined reference to `DoesNotExist' - - unit1.o: In function `SubProc': - some.inc:37: undefined reference to `DoesNotExist' -} -const - REFileIdentifier = '^(.*\.o)(\(\.text.*?\))?: .* `([a-zA-Z0-9_$]+)'':$'; - REOptFileLineIdentifier = '^(.*:[0-9]+)?: .* `(.*)''$'; - REFileLineIdentifier = '^(.*):([0-9]+): .* `(.*)''$'; - - procedure JumpTo(Line1, Line2: TIDEMessageLine); - var - Identifier: String; - Filename: String; - MangledFunction: String; - CurProject: TLazProject; - CodeBuf: TCodeBuffer; - NewCode: TCodeBuffer; - NewX, NewY, NewTopLine: integer; - AnUnitName: String; - SourceFilename: String; - SourceLine: Integer; - begin - DebugLn('TQuickFixLinkerUndefinedReference.JumpTo START'); - Debugln(' Line1=',Line1.Msg); - if Line2<>nil then - Debugln(' Line2=',Line2.Msg); - Filename:=''; - MangledFunction:=''; - Identifier:=''; - SourceFilename:=''; - SourceLine:=0; - if REMatches(Line1.Msg,REFileIdentifier) then - begin - // example: unit1.o(.text+0x1a): In function `SubProc': - Filename:=REVar(1); - MangledFunction:=REVar(3); - if (Line2<>nil) and REMatches(Line2.Msg,'^: .* `(.*)''$') then begin - // example: ": undefined reference to `gtk_cell_renderer_combo_get_type'" - Identifier:=REVar(1); - end else if (Line2<>nil) - and REMatches(Line2.Msg,REFileLineIdentifier) then begin - // example: unit1.pas:37: undefined reference to `DoesNotExist' - SourceFilename:=REVar(1); - SourceLine:=StrToIntDef(REVar(2),0); - Identifier:=REVar(3); - end else begin - DebugLn('TQuickFixLinkerUndefinedReference.JumpTo Line2 does not match: "',Line2.Msg,'"'); - exit; - end; - end - else if REMatches(Line1.Msg,'^(.*)\(\.text.*?\):(.*):([0-9]*): .* `([a-zA-Z0-9_$]+)'':$') - then begin - // example: unit1.o(.text+0x3a):unit1.pas:48: undefined reference to `DoesNotExist' - Filename:=REVar(1); - SourceFilename:=REVar(2); - SourceLine:=StrToIntDef(REVar(3),0); - Identifier:=REVar(4); - end - else if REMatches(Line1.Msg,REFileLineIdentifier) then - begin - // example: unit1.pas:48: undefined reference to `DoesNotExist' - Filename:=REVar(1); - SourceFilename:=Filename; - SourceLine:=StrToIntDef(REVar(2),0); - Identifier:=REVar(3); - end else begin - DebugLn('JumpTo Line1 does not match: "',Line1.Msg,'"'); - exit; - end; - Filename:=TrimFilename(Filename); // for example uni1.o - SourceFilename:=TrimFilename(SourceFilename); // for example wsimagelist.pp - // Beware: SourceFilename might be an include file - // Linker errors are emitted when compiling the project - // => search the unit of the .o file - DebugLn(['TQuickFixLinkerUndefinedReference.JumpTo Filename="',Filename,'" MangledFunction="',MangledFunction,'" Identifier="',Identifier,'" SourceFilename="',SourceFilename,'" SourceLine=',SourceLine]); - CurProject:=LazarusIDE.ActiveProject; - if CurProject=nil then begin - ShowError('QuickFix: LinkerUndefinedReference no project'); - exit; - end; - if (CurProject.MainFile=nil) then begin - ShowError('QuickFix: LinkerUndefinedReference no main file in project'); - exit; - end; - CodeBuf:=CodeToolBoss.LoadFile(CurProject.MainFile.Filename,true,false); - if (CodeBuf=nil) then begin - ShowError('QuickFix: LinkerUndefinedReference project main file has no source'); - exit; - end; - AnUnitName:=ExtractFilenameOnly(Filename); - CodeBuf:=CodeToolBoss.FindUnitSource(CodeBuf,AnUnitName,''); - if (CodeBuf=nil) then begin - ShowError('QuickFix: LinkerUndefinedReference unit not found: '+AnUnitName); - exit; - end; - if not CodeToolBoss.JumpToLinkerIdentifier(CodeBuf, - SourceFilename,SourceLine,MangledFunction,Identifier, - NewCode,NewX,NewY,NewTopLine) - then begin - if CodeToolBoss.ErrorCode<>nil then - LazarusIDE.DoJumpToCodeToolBossError - else - ShowError('QuickFix: LinkerUndefinedReference function not found: '+MangledFunction+' Identifier='+Identifier); - exit; - end; - LazarusIDE.DoOpenFileAndJumpToPos(NewCode.Filename,Point(NewX,NewY), - NewTopLine,-1,-1,[]); - end; - -var - MsgBefore: TIDEMessageLine; - MsgAfter: TIDEMessageLine; -begin - inherited Execute(Msg, Step); - if Step=imqfoJump then begin - DebugLn(['TQuickFixLinkerUndefinedReference.Execute ',Msg.Msg]); - MsgBefore:=nil; - if Msg.Position>0 then - MsgBefore:=IDEMessagesWindow[Msg.Position-1]; - MsgAfter:=nil; - if Msg.Position+1 unit1.o(.text+0x1a): In function `SubProc': - // some.inc:37: undefined reference to `DoesNotExist' - JumpTo(Msg,MsgAfter); - end - else if (MsgBefore<>nil) - and REMatches(MsgBefore.Msg,REFileIdentifier) - and REMatches(Msg.Msg,REOptFileLineIdentifier) then begin - // example: - // unit1.o(.text+0x1a): In function `SubProc': - // -> some.inc:37: undefined reference to `DoesNotExist' - JumpTo(MsgBefore,Msg) - end - else if REMatches(Msg.Msg,REFileLineIdentifier) then begin - // example: - // some.inc:37: undefined reference to `DoesNotExist' - JumpTo(Msg,nil); - end; - end; -end; - -{ TQuickFixClassWithAbstractMethods } - -constructor TQuickFixClassWithAbstractMethods.Create; -begin - Name:='Show abstract methods'; - Caption:=srkmecShowAbstractMethods; - Steps:=[imqfoMenuItem]; -end; - -function TQuickFixClassWithAbstractMethods.IsApplicable(Line: TIDEMessageLine - ): boolean; -begin - Result:=(Line.Parts<>nil) - and (System.Pos(') Warning: Constructing a class "',Line.Msg)>0) - and (System.Pos('" with abstract methods',Line.Msg)>0); -end; - -procedure TQuickFixClassWithAbstractMethods.Execute(const Msg: TIDEMessageLine; - Step: TIMQuickFixStep); -var - CodeBuf: TCodeBuffer; - Caret: TPoint; - Filename: string; - NewCode: TCodeBuffer; - NewX,NewY,NewTopLine: Integer; - Tool: TCodeTool; - CurClassName: String; -begin - if Step=imqfoMenuItem then begin - DebugLn(['TQuickFixClassWithAbstractMethods.Execute ']); - // get source position - // (FPC reports position right after the constructor call - // for example right after TStrings.Create) - if not GetMsgLineFile(Msg,CodeBuf,false) then exit; - Msg.GetSourcePosition(Filename,Caret.Y,Caret.X); - if not LazarusIDE.BeginCodeTools then begin - DebugLn(['TQuickFixClassWithAbstractMethods.Execute failed because IDE busy']); - exit; - end; - - // get class name - if not REMatches(Msg.Msg,'Warning: Constructing a class "([a-z_0-9]+)"','I') then begin - DebugLn('QuickFixClassWithAbstractMethods invalid message ',Msg.Msg); - ShowError('QuickFix: ClassWithAbstractMethods invalid message '+Msg.Msg); - exit; - end; - CurClassName:=REVar(1); - //DebugLn(['TQuickFixClassWithAbstractMethods.Execute Class=',CurClassName]); - - // find the class - - // build the tree - CodeToolBoss.Explore(CodeBuf,Tool,false,true); - if Tool=nil then begin - DebugLn(['TQuickFixClassWithAbstractMethods.Execute no tool for ',CodeBuf.Filename]); - ShowError('QuickFix: ClassWithAbstractMethods no tool for '+CodeBuf.Filename); - exit; - end; - - if not CodeToolBoss.FindDeclarationOfIdentifier(CodeBuf,Caret.X,Caret.Y, - @CurClassName[1],NewCode,NewX,NewY,NewTopLine) - then begin - if CodeToolBoss.ErrorMessage<>'' then begin - LazarusIDE.DoJumpToCodeToolBossError - end else begin - IDEMessageDialog('Class not found', - 'Class '+CurClassName+' not found at ' - +CodeBuf.Filename+'('+IntToStr(Caret.Y)+','+IntToStr(Caret.X)+')', - mtError,[mbCancel]); - end; - exit; - end; - //DebugLn(['TQuickFixClassWithAbstractMethods.Execute Declaration at ',NewCode.Filename,' ',NewX,',',NewY]); - - if LazarusIDE.DoOpenFileAndJumpToPos(NewCode.Filename, - Point(NewX,NewY),NewTopLine,-1,-1,[])<>mrOk - then begin - DebugLn(['TQuickFixClassWithAbstractMethods.Execute failed opening ',NewCode.Filename]); - ShowError('QuickFix: ClassWithAbstractMethods failed opening '+NewCode.Filename); - exit; - end; - - ShowAbstractMethodsDialog; - end; -end; - -{ TQuickFixIdentifierNotFoundAddLocal } - -constructor TQuickFixIdentifierNotFoundAddLocal.Create; -begin - Name:='Create local variable: Error: Identifier not found "identifier"'; - Caption:=lisQuickFixCreateLocalVariable; - Steps:=[imqfoMenuItem]; -end; - -function TQuickFixIdentifierNotFoundAddLocal.IsApplicable(Line: TIDEMessageLine - ): boolean; -// FPC gives position of end of identifier -const - SearchStr = ') Error: Identifier not found "'; -var - Filename: string; - Caret: TPoint; - Code: TCodeBuffer; - Tool: TCodeTool; - CleanPos: integer; - p: LongInt; - Msg: String; - Identifier: String; - Node: TCodeTreeNode; -begin - Result:=false; - if (Line.Parts=nil) then exit; - Msg:=Line.Msg; - p:=System.Pos(SearchStr,Msg); - if p<1 then exit; - inc(p,length(SearchStr)); - Line.GetSourcePosition(Filename,Caret.Y,Caret.X); - if (Filename='') or (Caret.X<1) or (Caret.Y<1) then exit; - Code:=CodeToolBoss.LoadFile(Filename,true,false); - if Code=nil then exit; - if not CodeToolBoss.Explore(Code,Tool,false) then exit; - if Tool.CaretToCleanPos(CodeXYPosition(Caret.X,Caret.Y,Code),CleanPos)<>0 then exit; - Node:=Tool.FindDeepestNodeAtPos(CleanPos,false); - if Node=nil then exit; - if not (Node.Desc in AllPascalStatements) then exit; - Tool.MoveCursorToCleanPos(CleanPos); - Tool.ReadPriorAtom; - Identifier:=GetIdentifier(@Msg[p]); - if not Tool.AtomIs(Identifier) then exit; - Tool.ReadPriorAtom; - if (Tool.CurPos.Flag in [cafPoint,cafRoundBracketClose,cafEdgedBracketClose, - cafEnd]) - then exit; - Result:=true; -end; - -procedure TQuickFixIdentifierNotFoundAddLocal.Execute(const Msg: TIDEMessageLine; - Step: TIMQuickFixStep); -var - Identifier: String; - CodeBuf: TCodeBuffer; - Filename: string; - Caret: TPoint; - NewCode: TCodeBuffer; - NewX, NewY, NewTopLine: integer; - Tool: TCodeTool; - CleanPos: integer; - CodeXY: TCodeXYPosition; -begin - if Step=imqfoMenuItem then begin - DebugLn(['TQuickFixIdentifierNotFoundAddLocal.Execute Dir=',Msg.Directory,' Msg=',Msg.Msg]); - // get source position - // (FPC reports position right after the unknown identifier - // for example right after FilenameIsAbsolute) - if not GetMsgLineFile(Msg,CodeBuf,false) then exit; - Msg.GetSourcePosition(Filename,Caret.Y,Caret.X); - - if not LazarusIDE.BeginCodeTools then begin - DebugLn(['TQuickFixIdentifierNotFoundAddLocal.Execute failed because IDE busy']); - exit; - end; - - if (Filename='') or (Caret.X<1) or (Caret.Y<1) then exit; - CodeBuf:=CodeToolBoss.LoadFile(Filename,true,false); - if CodeBuf=nil then exit; - if not CodeToolBoss.Explore(CodeBuf,Tool,false) then exit; - if Tool.CaretToCleanPos(CodeXYPosition(Caret.X,Caret.Y,CodeBuf),CleanPos)<>0 then exit; - if CleanPos>Tool.SrcLen then CleanPos:=Tool.SrcLen; - if (CleanPos>1) and (not IsIdentChar[Tool.Src[CleanPos]]) then dec(CleanPos); - Tool.MoveCursorToCleanPos(CleanPos); - Tool.ReadPriorAtom; - CleanPos:=Tool.CurPos.StartPos; - if CleanPos<1 then exit; - if not Tool.CleanPosToCaret(CleanPos,CodeXY) then exit; - - // get identifier - if not REMatches(Msg.Msg,'Error: Identifier not found "([a-z_0-9]+)"','I') then begin - DebugLn('TQuickFixIdentifierNotFoundAddLocal invalid message ',Msg.Msg); - ShowError('QuickFix: IdentifierNotFoundAddLocal invalid message '+Msg.Msg); - exit; - end; - Identifier:=REVar(1); - DebugLn(['TQuickFixIdentifierNotFoundAddLocal.Execute Identifier=',Identifier,' ',Dbgs(CodeXY)]); - - if not IsIdentifierInCode(CodeXY.Code,CodeXY.X,CodeXY.Y,Identifier, - Format(lisNotFoundInAtLineColumnMaybeTheMessageIsOutdated, [Identifier, - CodeBuf.Filename, IntToStr(Caret.Y), IntToStr(Caret.X), LineEnding])) - then exit; - - if not CodeToolBoss.CreateVariableForIdentifier(CodeXY.Code,CodeXY.X,CodeXY.Y,-1, - NewCode,NewX,NewY,NewTopLine) - then begin - LazarusIDE.DoJumpToCodeToolBossError; - exit; - end; - - // message fixed -> clean - Msg.Msg:=''; - end; -end; - -{ TQuickFixUnitNotFound_Remove } - -constructor TQuickFixUnitNotFound_Remove.Create; -begin - Name:='Search unit: Error: Can''t find unit Name'; - Caption:=lisRemoveUnitFromUsesSection; - Steps:=[imqfoMenuItem]; -end; - -function TQuickFixUnitNotFound_Remove.IsApplicable(Line: TIDEMessageLine - ): boolean; -var - Msg: String; -begin - if Line.Parts=nil then exit(false); - Msg:=Line.Msg; - Result:=(System.Pos(') Fatal: Can''t find unit ',Msg)>0) - or (System.Pos(') Fatal: Can not find unit ',Msg)>0); -end; - -procedure TQuickFixUnitNotFound_Remove.Execute(const Msg: TIDEMessageLine; - Step: TIMQuickFixStep); -var - CodeBuf: TCodeBuffer; - Filename: string; - Caret: TPoint; - AnUnitName: String; -begin - if Step=imqfoMenuItem then begin - DebugLn(['TQuickFixUnitNotFound_Remove.Execute ']); - // get source position - if not GetMsgLineFile(Msg,CodeBuf,false) then exit; - Msg.GetSourcePosition(Filename,Caret.Y,Caret.X); - if not LazarusIDE.BeginCodeTools then begin - DebugLn(['TQuickFixUnitNotFound_Remove.Execute failed because IDE busy']); - exit; - end; - - // get unitname - if not REMatches(Msg.Msg,'Fatal: Can(''t| not) find unit ([a-z_0-9]+) ','I') then begin - DebugLn('TQuickFixUnitNotFound_Remove invalid message ',Msg.Msg); - ShowError('QuickFix: UnitNotFound_Remove invalid message '+Msg.Msg); - exit; - end; - AnUnitName:=REVar(2); - DebugLn(['TQuickFixUnitNotFound_Remove.Execute Unit=',AnUnitName]); - - if (AnUnitName='') or (not IsValidIdent(AnUnitName)) then begin - DebugLn(['TQuickFixUnitNotFound_Remove.Execute not an identifier "',dbgstr(AnUnitName),'"']); - ShowError('QuickFix: UnitNotFound_Remove not an identifier "'+dbgstr(AnUnitName)+'"'); - exit; - end; - - if not CodeToolBoss.RemoveUnitFromAllUsesSections(CodeBuf,AnUnitName) then - begin - DebugLn(['TQuickFixUnitNotFound_Remove.Execute RemoveUnitFromAllUsesSections failed']); - LazarusIDE.DoJumpToCodeToolBossError; - exit; - end; - - // message fixed -> clean - Msg.Msg:=''; - end; -end; - -{ TQuickFixLocalVariableNotUsed_Remove } - -constructor TQuickFixLocalVariableNotUsed_Remove.Create; -begin - Name:='Remove local variable: Note: Local variable "x" not used'; - Caption:=lisRemoveLocalVariable2; - Steps:=[imqfoMenuItem]; -end; - -function TQuickFixLocalVariableNotUsed_Remove.IsApplicable(Line: TIDEMessageLine - ): boolean; -const - SearchStr1 = ') Note: Local variable "'; - SearchStr2 = '" not used'; -var - Msg: String; - StartPos: integer; - p: LongInt; - Variable: String; -begin - Result:=false; - if (Line.Parts=nil) then exit; - Msg:=Line.Msg; - //DebugLn(['TQuickFixLocalVariableNotUsed_Remove.IsApplicable Msg="',Msg,'" ',System.Pos(SearchStr1,Msg),' ',System.Pos(SearchStr2,Msg)]); - StartPos:=System.Pos(SearchStr1,Msg); - if StartPos<1 then exit; - inc(StartPos,length(SearchStr1)); - p:=StartPos; - while (p<=length(Msg)) and (Msg[p]<>'"') do inc(p); - if copy(Msg,p,length(SearchStr2))<>SearchStr2 then exit; - Variable:=copy(Msg,StartPos,p-StartPos); - if (Variable='') or not IsValidIdent(Variable) then exit; - Caption:=Format(lisRemoveLocalVariable, [Variable]); - Result:=true; -end; - -procedure TQuickFixLocalVariableNotUsed_Remove.Execute( - const Msg: TIDEMessageLine; Step: TIMQuickFixStep); -var - CodeBuf: TCodeBuffer; - Filename: string; - Caret: TPoint; - Variable: String; -begin - if Step=imqfoMenuItem then begin - DebugLn(['TQuickFixLocalVariableNotUsed_Remove.Execute ']); - // get source position - if not GetMsgLineFile(Msg,CodeBuf,false) then exit; - Msg.GetSourcePosition(Filename,Caret.Y,Caret.X); - if not LazarusIDE.BeginCodeTools then begin - DebugLn(['TQuickFixLocalVariableNotUsed_Remove.Execute failed because IDE busy']); - exit; - end; - - // get variables name - if not REMatches(Msg.Msg,'Note: Local variable "([a-z_0-9]+)" not used','I') - then begin - DebugLn('TQuickFixLocalVariableNotUsed_Remove invalid message ',Msg.Msg); - ShowError('QuickFix: LocalVariableNotUsed_Remove invalid message '+Msg.Msg); - exit; - end; - Variable:=REVar(1); - //DebugLn(['TQuickFixLocalVariableNotUsed_Remove.Execute Variable=',Variable]); - - // check if the variable is at that position - if not IsIdentifierInCode(CodeBuf,Caret.X,Caret.Y,Variable, - Format(lisNotFoundInAtLineColumnMaybeTheMessageIsOutdated, [Variable, - CodeBuf.Filename, IntToStr(Caret.Y), IntToStr(Caret.X), LineEnding])) - then exit; - - if not CodeToolBoss.RemoveIdentifierDefinition(CodeBuf,Caret.X,Caret.Y) then - begin - DebugLn(['TQuickFixLocalVariableNotUsed_Remove.Execute remove failed']); - LazarusIDE.DoJumpToCodeToolBossError; - exit; - end; - - // message fixed -> clean - Msg.Msg:=''; - end; -end; - -{ TQuickFixHint_Hide } - -constructor TQuickFixHint_Hide.Create; -begin - Name:='Hide hint, note or warning'; - Caption:=lisHideMessageViaDirective; - Steps:=[imqfoMenuItem]; -end; - -function TQuickFixHint_Hide.IsApplicable(Line: TIDEMessageLine): boolean; -var - MsgType: string; - Filename: string; - LineNumber, Column: integer; -begin - Result:=false; - if (Line.Parts=nil) then exit; - MsgType:=Line.Parts.Values['Type']; - if (MsgType<>'Hint') and (MsgType<>'Note') and (MsgType<>'Warning') then exit; - Line.GetSourcePosition(Filename,LineNumber,Column); - Result:=FilenameIsAbsolute(Filename) and (LineNumber>=1) and (Column>=1); -end; - -procedure TQuickFixHint_Hide.Execute(const Msg: TIDEMessageLine; - Step: TIMQuickFixStep); -var - CodeBuf: TCodeBuffer; - Filename: string; - Caret: TPoint; - p: integer; -begin - if Step=imqfoMenuItem then begin - DebugLn(['TQuickFixHint_Hide.Execute ']); - // get source position - if not GetMsgLineFile(Msg,CodeBuf,false) then exit; - Msg.GetSourcePosition(Filename,Caret.Y,Caret.X); - if not LazarusIDE.BeginCodeTools then begin - DebugLn(['TQuickFixHint_Hide.Execute failed because IDE busy']); - exit; - end; - - CodeBuf.LineColToPosition(Caret.Y,Caret.X,p); - if p<1 then begin - DebugLn(['TQuickFixHint_Hide.Execute failed because invalid line, column']); - IDEMessageDialog(lisCCOErrorCaption, - Format(lisInvalidLineColumnInMessage, [LineEnding, Msg.Msg]), - mtError, [mbCancel]); - exit; - end; - - CodeBuf.Insert(p,'{%H-}'); - end; -end; - -end. - diff --git a/ide/sourceeditor.pp b/ide/sourceeditor.pp index e5c888808c..6a62cd773d 100644 --- a/ide/sourceeditor.pp +++ b/ide/sourceeditor.pp @@ -64,13 +64,7 @@ uses IDEDialogs, LazarusIDEStrConsts, IDECommands, CompOptsIntf, EditorOptions, EnvironmentOpts, WordCompletion, FindReplaceDialog, IDEProcs, IDEOptionDefs, IDEHelpManager, MacroPromptDlg, TransferMacros, CodeContextForm, - SrcEditHintFrm, - {$IFNDEF EnableOldExtTools} - etMessagesWnd, etSrcEditMarks, - {$ELSE} - MsgView, - {$ENDIF} - InputHistory, + SrcEditHintFrm, etMessagesWnd, etSrcEditMarks, InputHistory, CodeMacroPrompt, CodeTemplatesDlg, CodeToolsOptions, SortSelectionDlg, EncloseSelectionDlg, ConDef, InvertAssignTool, SourceEditProcs, SourceMarks, CharacterMapDlg, SearchFrm, @@ -106,32 +100,6 @@ type hcmSoftKeepEOL // Soft Center (distance to screen edge) Caret, but keep EOL at right border ); - {$IFDEF EnableOldExtTools} - TOnLinesInsertedDeleted = procedure(Sender : TObject; - FirstLine,Count : Integer) of Object; - - { TSynEditPlugin1 } - - TSynEditPlugin1 = class(TLazSynEditPlugin) - private - FEnabled: Boolean; - FOnLinesInserted : TOnLinesInsertedDeleted; - FOnLinesDeleted : TOnLinesInsertedDeleted; - protected - Procedure LineCountChanged(Sender: TSynEditStrings; AIndex, ACount : Integer); - function OwnedByEditor: Boolean; override; - public - property OnLinesInserted : TOnLinesInsertedDeleted - read FOnLinesinserted write FOnLinesInserted; - property OnLinesDeleted : TOnLinesInsertedDeleted - read FOnLinesDeleted write FOnLinesDeleted; - property Enabled: Boolean read FEnabled write FEnabled; - - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - end; - {$ENDIF} - { TSourceEditCompletion } TSourceEditCompletion=class(TSynCompletion) @@ -253,13 +221,8 @@ type FEditor: TIDESynEditor; FTempCaret: TPoint; FTempTopLine: Integer; - {$IFNDEF EnableOldExtTools} FEditPlugin: TETSynPlugin; // used to update the "Messages Window" // when text is inserted/deleted - {$ELSE} - FEditPlugin: TSynEditPlugin1; // used to get the LinesInserted and - // LinesDeleted messages - {$ENDIF} FOnIfdefNodeStateRequest: TSynMarkupIfdefStateRequest; FLastIfDefNodeScannerStep: integer; @@ -356,12 +319,7 @@ type procedure StartIdentCompletionBox(JumpToError: boolean); procedure StartWordCompletionBox(JumpToError: boolean); - {$IFNDEF EnableOldExtTools} function IsFirstShared(Sender: TObject): boolean; - {$ELSE} - procedure LinesInserted(sender: TObject; FirstLine, Count: Integer); - procedure LinesDeleted(sender: TObject; FirstLine, Count: Integer); - {$ENDIF} function GetFilename: string; override; function GetEditorControl: TWinControl; override; @@ -889,9 +847,7 @@ type fProducers: TFPList; // list of TSourceMarklingProducer FChangeNotifyLists: Array [TsemChangeReason] of TMethodList; FHandlers: array[TSrcEditMangerHandlerType] of TMethodList; - {$IFNDEF EnableOldExtTools} FChangesQueuedForMsgWnd: TETMultiSrcChanges;// source editor changes waiting to be applied to the Messages window - {$ENDIF} function GetActiveSourceWindow: TSourceEditorWindowInterface; override; procedure SetActiveSourceWindow(const AValue: TSourceEditorWindowInterface); override; function GetSourceWindows(Index: integer): TSourceEditorWindowInterface; override; @@ -903,9 +859,7 @@ type function GetSourceEditors(Index: integer): TSourceEditorInterface; override; function GetUniqueSourceEditors(Index: integer): TSourceEditorInterface; override; function GetMarklingProducers(Index: integer): TSourceMarklingProducer; override; - {$IFNDEF EnableOldExtTools} procedure SyncMessageWnd(Sender: TObject); - {$ENDIF} public procedure BeginAutoFocusLock; procedure EndAutoFocusLock; @@ -1118,10 +1072,8 @@ type procedure OnSourceCompletionTimer(Sender: TObject); // marks procedure OnSourceMarksAction(AMark: TSourceMark; AAction: TMarksAction); - {$IFNDEF EnableOldExtTools} procedure OnSourceMarksGetSynEdit(Sender: TObject; aFilename: string; var aSynEdit: TSynEdit); - {$ENDIF} property CodeTemplateModul: TSynEditAutoComplete read FCodeTemplateModul write FCodeTemplateModul; // goto dialog @@ -2329,19 +2281,15 @@ var i: Integer; SrcEdit: TSourceEditor; SharedEdit: TSourceEditor; - {$IFNDEF EnableOldExtTools} ETChanges: TETSingleSrcChanges; - {$ENDIF} begin if FCodeBuffer = AValue then exit; if FCodeBuffer<>nil then begin - {$IFNDEF EnableOldExtTools} for i := 0 to FSharedEditorList.Count - 1 do begin SharedEdit := SharedEditors[i]; if SharedEdit.FEditPlugin<>nil then SharedEdit.FEditPlugin.Changes:=nil; end; - {$ENDIF} FCodeBuffer.RemoveChangeHook(@OnCodeBufferChanged); if FCodeBuffer.Scanner<>nil then DisconnectScanner(FCodeBuffer.Scanner); @@ -2375,7 +2323,6 @@ begin FCodeBuffer.AddChangeHook(@OnCodeBufferChanged); if FCodeBuffer.Scanner<>nil then ConnectScanner(FCodeBuffer.Scanner); - {$IFNDEF EnableOldExtTools} ETChanges := SourceEditorManager.FChangesQueuedForMsgWnd.GetChanges( FCodeBuffer.Filename,true); for i := 0 to FSharedEditorList.Count - 1 do begin @@ -2385,7 +2332,6 @@ begin end; if MessagesView<>nil then MessagesView.MessagesFrame1.CreateMarksForFile(SynEditor,FCodeBuffer.Filename,true); - {$ENDIF} if (FIgnoreCodeBufferLock <= 0) and (not FCodeBuffer.IsEqual(SynEditor.Lines)) then begin {$IFDEF IDE_DEBUG} @@ -2836,15 +2782,8 @@ Begin FEditor.Beautifier := ASharedEditor.EditorComponent.Beautifier; end; - {$IFNDEF EnableOldExtTools} FEditPlugin := TETSynPlugin.Create(FEditor); FEditPlugin.OnIsEnabled:=@IsFirstShared; - {$ELSE} - FEditPlugin := TSynEditPlugin1.Create(FEditor); - // IMPORTANT: when you add/remove events below, don't forget updating UnbindEditor - FEditPlugin.OnLinesInserted := @LinesInserted; - FEditPlugin.OnLinesDeleted := @LinesDeleted; - {$ENDIF} end; destructor TSourceEditor.Destroy; @@ -5664,32 +5603,11 @@ begin Result := FEditor.GetWordAtRowCol(ACaretPos); end; -{$IFNDEF EnableOldExtTools} function TSourceEditor.IsFirstShared(Sender: TObject): boolean; begin Result:=SharedEditors[0]=Self; end; -{$ELSE} -procedure TSourceEditor.LinesDeleted(sender: TObject; FirstLine, Count: Integer - ); -begin - // notify the notebook that lines were deleted. - // marks will use this to update themselves - if (Self = FSharedValues.SharedEditors[0]) then - MessagesView.SrcEditLinesInsertedDeleted(Filename,FirstLine,-Count); -end; - -procedure TSourceEditor.LinesInserted(sender: TObject; FirstLine, Count: Integer - ); -begin - // notify the notebook that lines were Inserted. - // marks will use this to update themselves - if (Self = FSharedValues.SharedEditors[0]) then - MessagesView.SrcEditLinesInsertedDeleted(Filename,FirstLine,Count); -end; -{$ENDIF} - procedure TSourceEditor.SetVisible(Value: boolean); begin if FVisible=Value then exit; @@ -5729,12 +5647,7 @@ begin TSynPluginSyncronizedEditBase(EditorComponent.Plugin[i]).OnDeactivate := nil; end; if FEditPlugin<>nil then begin - {$IFNDEF EnableOldExtTools} FEditPlugin.Enabled:=false; - {$ELSE} - FEditPlugin.OnLinesInserted := nil; - FEditPlugin.OnLinesDeleted := nil; - {$ENDIF} end; end; @@ -6359,12 +6272,10 @@ begin Marks[i].CreatePopupMenuItems(@AddUserDefinedPopupMenuItem); FreeMem(Marks); end; - {$IFNDEF EnableOldExtTools} if (EditorCaret.Y<=EditorComp.Lines.Count) and (MessagesView<>nil) then MessagesView.SourceEditorPopup(EditorComp.Marks.Line[EditorCaret.Y], EditorComp.LogicalCaretXY); - {$ENDIF} end; if Assigned(Manager.OnPopupMenu) then @@ -8375,10 +8286,8 @@ begin HintStr:=HintStr+CurHint; end; - {$IFNDEF EnableOldExtTools} if (MessagesView<>nil) then MessagesView.SourceEditorHint(MLine,HintStr); - {$ENDIF} end; if HintStr<>'' then @@ -8484,40 +8393,6 @@ begin Editors[i].ClearExecutionMarks; end; -{$IFDEF EnableOldExtTools} -{ TSynEditPlugin1 } - -constructor TSynEditPlugin1.Create(AOwner: TComponent); -Begin - inherited Create(AOwner); - FEnabled := True; - ViewedTextBuffer.AddChangeHandler(senrLineCount, @LineCountChanged); -end; - -destructor TSynEditPlugin1.Destroy; -begin - ViewedTextBuffer.RemoveChangeHandler(senrLineCount, @LineCountChanged); - inherited Destroy; -end; - -procedure TSynEditPlugin1.LineCountChanged(Sender: TSynEditStrings; AIndex, ACount: Integer); -begin - if not FEnabled then exit; - if ACount < 0 then begin - if Assigned(OnLinesDeleted) then - OnLinesDeleted(self, AIndex+1, -ACount); - end else begin - if Assigned(OnLinesInserted) then - OnLinesInserted(self, AIndex+1, ACount); - end; -end; - -function TSynEditPlugin1.OwnedByEditor: Boolean; -begin - Result := True; -end; -{$ENDIF} - //----------------------------------------------------------------------------- procedure InternalInit; @@ -8837,12 +8712,10 @@ begin Result:=TSourceMarklingProducer(fProducers[Index]); end; -{$IFNDEF EnableOldExtTools} procedure TSourceEditorManagerBase.SyncMessageWnd(Sender: TObject); begin MessagesView.MessagesFrame1.ApplyMultiSrcChanges(Sender as TETMultiSrcChanges); end; -{$ENDIF} procedure TSourceEditorManagerBase.BeginAutoFocusLock; begin @@ -9018,11 +8891,9 @@ begin FUpdateLock := 0; FActiveEditorLock := 0; fProducers := TFPList.Create; - {$IFNDEF EnableOldExtTools} FChangesQueuedForMsgWnd:=TETMultiSrcChanges.Create(Self); FChangesQueuedForMsgWnd.AutoSync:=true; FChangesQueuedForMsgWnd.OnSync:=@SyncMessageWnd; - {$ENDIF} inherited; end; @@ -9032,9 +8903,7 @@ var cr: TsemChangeReason; h: TSrcEditMangerHandlerType; begin - {$IFNDEF EnableOldExtTools} FreeAndNil(FChangesQueuedForMsgWnd); - {$ENDIF} for i:=MarklingProducerCount-1 downto 0 do MarklingProducers[i].Free; FreeAndNil(fProducers); @@ -10284,7 +10153,6 @@ begin Editor.UpdateExecutionSourceMark; end; -{$IFNDEF EnableOldExtTools} procedure TSourceEditorManager.OnSourceMarksGetSynEdit(Sender: TObject; aFilename: string; var aSynEdit: TSynEdit); var @@ -10294,7 +10162,6 @@ begin if SrcEdit=nil then exit; aSynEdit:=SrcEdit.EditorComponent; end; -{$ENDIF} function TSourceEditorManager.GotoDialog: TfrmGoto; begin @@ -10345,9 +10212,7 @@ begin // marks SourceEditorMarks:=TSourceMarks.Create(Self); SourceEditorMarks.OnAction:=@OnSourceMarksAction; - {$IFNDEF EnableOldExtTools} SourceEditorMarks.ExtToolsMarks.OnGetSynEditOfFile:=@OnSourceMarksGetSynEdit; - {$ENDIF} // HintWindow FHints := TIDEHintWindowManager.Create; diff --git a/ide/sourcemarks.pas b/ide/sourcemarks.pas index 9e29d16db8..5c93bf3917 100644 --- a/ide/sourcemarks.pas +++ b/ide/sourcemarks.pas @@ -41,11 +41,8 @@ uses Classes, SysUtils, AVL_Tree, Graphics, Controls, LCLProc, MenuIntf, SynEdit, SynEditMarks, SynEditMarkupGutterMark, - SrcEditorIntf - {$IFNDEF EnableOldExtTools} - , IDEExternToolIntf, etSrcEditMarks - {$ENDIF} - ; + SrcEditorIntf, IDEExternToolIntf, + etSrcEditMarks; type TAdditionalHilightAttribute = @@ -191,9 +188,7 @@ type FCurrentLineBreakPointImg: Integer; FCurrentLineImg: Integer; FCurrentLineDisabledBreakPointImg: Integer; - {$IFNDEF EnableOldExtTools} FExtToolsMarks: TETMarks; - {$ENDIF} FSourceLineImg: Integer; FImgList: TImageList; fInactiveBreakPointImg: Integer; @@ -233,9 +228,7 @@ type property ImgList: TImageList read FImgList write FImgList; property Items[Index: integer]: TSourceMark read GetItems; default; property OnAction: TMarksActionEvent read FOnAction write FOnAction; - {$IFNDEF EnableOldExtTools} property ExtToolsMarks: TETMarks read FExtToolsMarks; - {$ENDIF} public // icon index property ActiveBreakPointImg: Integer read fActiveBreakPointImg; @@ -540,13 +533,11 @@ end; procedure TSourceMarks.CreateImageList; var i: Integer; - {$IFNDEF EnableOldExtTools} ImgIDFatal: Integer; ImgIDError: Integer; ImgIDWarning: Integer; ImgIDNote: Integer; ImgIDHint: Integer; - {$ENDIF} begin // create default mark icons ImgList:=TImageList.Create(Self); @@ -580,7 +571,6 @@ begin // load source line FSourceLineImg:=AddImage('debugger_source_line'); - {$IFNDEF EnableOldExtTools} ExtToolsMarks.ImageList:=ImgList; ImgIDFatal:=AddImage('state11x11_fatal'); ImgIDError:=AddImage('state11x11_error'); @@ -600,7 +590,6 @@ begin ExtToolsMarks.MarkStyles[mluError].ImageIndex:=ImgIDError; ExtToolsMarks.MarkStyles[mluFatal].ImageIndex:=ImgIDFatal; ExtToolsMarks.MarkStyles[mluPanic].ImageIndex:=ImgIDFatal; - {$ENDIF} end; function TSourceMarks.FindFirstMarkNode(ASrcEditID: TObject; ALine: integer @@ -626,18 +615,14 @@ begin inherited Create(TheOwner); fItems:=TList.Create; fSortedItems:=TAVLTree.Create(@CompareSourceMarks); - {$IFNDEF EnableOldExtTools} FExtToolsMarks:=TETMarks.Create(nil); - {$ENDIF} CreateImageList; end; destructor TSourceMarks.Destroy; begin Clear; - {$IFNDEF EnableOldExtTools} FreeAndNil(FExtToolsMarks); - {$ENDIF} FreeThenNil(FItems); FreeThenNil(fSortedItems); inherited Destroy; diff --git a/ide/unitdependencies.pas b/ide/unitdependencies.pas index 68a5b5eb13..9a56f3ad32 100644 --- a/ide/unitdependencies.pas +++ b/ide/unitdependencies.pas @@ -39,9 +39,7 @@ uses Forms, Controls, ExtCtrls, ComCtrls, StdCtrls, Buttons, Dialogs, Menus, Clipbrd, LvlGraphCtrl, LazIDEIntf, ProjectIntf, IDEWindowIntf, PackageIntf, SrcEditorIntf, IDEImagesIntf, IDECommands, IDEDialogs, IDEMsgIntf, TextTools, - {$IFNDEF EnableOldExtTools} IDEExternToolIntf, - {$ENDIF} CodeToolManager, DefineTemplates, CodeToolsStructs, CTUnitGraph, CTUnitGroupGraph, FileProcs, CodeCache, LazarusIDEStrConsts, UnusedUnitsDlg; @@ -301,7 +299,6 @@ type write SetPendingUnitDependencyRoute; // list of unit names, missing links are automatically found end; -{$IFNDEF EnableOldExtTools} type { TQuickFixCircularUnitReference } @@ -312,18 +309,6 @@ type procedure CreateMenuItems(Fixes: TMsgQuickFixes); override; procedure QuickFix(Fixes: TMsgQuickFixes; Msg: TMessageLine); override; end; -{$ELSE} -type - - { TQuickFixCircularUnitReference } - - TQuickFixCircularUnitReference = class(TIDEMsgQuickFixItem) - public - constructor Create; - function IsApplicable(Line: TIDEMessageLine): boolean; override; - procedure Execute(const Msg: TIDEMessageLine; Step: TIMQuickFixStep); override; - end; -{$ENDIF} var UnitDependenciesWindow: TUnitDependenciesWindow; @@ -425,7 +410,6 @@ begin inherited Destroy; end; -{$IFNDEF EnableOldExtTools} { TQuickFixCircularUnitReference } function TQuickFixCircularUnitReference.IsApplicable(Msg: TMessageLine; out @@ -469,67 +453,6 @@ begin Path.Free; end; end; -{$ELSE} -{ TQuickFixCircularUnitReference } - -constructor TQuickFixCircularUnitReference.Create; -begin - Name:='Show unit dependencies'; - Caption:='Show unit dependencies'; - Steps:=[imqfoMenuItem]; -end; - -function TQuickFixCircularUnitReference.IsApplicable(Line: TIDEMessageLine - ): boolean; -const - SearchStr = ') Fatal: Circular unit reference between '; -var - Msg: String; - p: integer; - Code: TCodeBuffer; - Filename: string; - Caret: TPoint; -begin - Result:=false; - if (Line.Parts=nil) then exit; - Msg:=Line.Msg; - p:=System.Pos(SearchStr,Msg); - if p<1 then exit; - inc(p,length(SearchStr)); - Line.GetSourcePosition(Filename,Caret.Y,Caret.X); - if (Filename='') or (Caret.X<1) or (Caret.Y<1) then exit; - Code:=CodeToolBoss.LoadFile(Filename,true,false); - if Code=nil then exit; - Result:=true; -end; - -procedure TQuickFixCircularUnitReference.Execute(const Msg: TIDEMessageLine; - Step: TIMQuickFixStep); -var - UnitName1: String; - UnitName2: String; - Path: TStringList; -begin - if Step<>imqfoMenuItem then exit; - if not REMatches(Msg.Msg,'Fatal: Circular unit reference between ([a-z_0-9.]+) and ([a-z_0-9.]+)','I') - then begin - debugln(['TQuickFixCircularUnitReference.Execute invalid message ',Msg.Msg]); - exit; - end; - UnitName1:=REVar(1); - UnitName2:=REVar(2); - ShowUnitDependencies(true,true); - Path:=TStringList.Create; - try - Path.Add(UnitName1); - Path.Add(UnitName2); - Path.Add(UnitName1); - UnitDependenciesWindow.PendingUnitDependencyRoute:=Path; - finally - Path.Free; - end; -end; -{$ENDIF} { TUDNode }