From 726fc93729ab8e07a401e183570724780763b8d3 Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 10 Sep 2011 00:11:50 +0000 Subject: [PATCH] cody: Add "With" block git-svn-id: trunk@32245 - --- .gitattributes | 2 ++ components/codetools/extractproctool.pas | 3 ++ .../codetools/ide/addassignmethoddlg.pas | 2 +- components/codetools/ide/addwithblock.lfm | 0 components/codetools/ide/addwithblock.pas | 0 components/codetools/ide/cody.lpk | 21 +++++++++----- components/codetools/ide/cody.pas | 2 +- components/codetools/ide/codyregistration.pas | 9 +++++- components/codetools/ide/codystrconsts.pas | 10 +++++++ .../ide/languages/codystrconsts.it.po | 28 +++++++++++++++++++ .../codetools/ide/languages/codystrconsts.po | 28 +++++++++++++++++++ .../ide/languages/codystrconsts.pt_BR.po | 28 +++++++++++++++++++ .../ide/languages/codystrconsts.ru.po | 28 +++++++++++++++++++ .../ide/languages/codystrconsts.uk.po | 28 +++++++++++++++++++ 14 files changed, 179 insertions(+), 10 deletions(-) create mode 100644 components/codetools/ide/addwithblock.lfm create mode 100644 components/codetools/ide/addwithblock.pas diff --git a/.gitattributes b/.gitattributes index 96564a7530..344aceebee 100644 --- a/.gitattributes +++ b/.gitattributes @@ -562,6 +562,8 @@ components/codetools/ide/Makefile.compiled svneol=native#text/plain components/codetools/ide/Makefile.fpc svneol=native#text/plain components/codetools/ide/addassignmethoddlg.lfm svneol=native#text/plain components/codetools/ide/addassignmethoddlg.pas svneol=native#text/plain +components/codetools/ide/addwithblock.lfm svneol=native#text/plain +components/codetools/ide/addwithblock.pas svneol=native#text/plain components/codetools/ide/cody.lpk svneol=native#text/plain components/codetools/ide/cody.pas svneol=native#text/pascal components/codetools/ide/codycopydeclaration.pas svneol=native#text/plain diff --git a/components/codetools/extractproctool.pas b/components/codetools/extractproctool.pas index d2ac3cbced..e051824ef8 100644 --- a/components/codetools/extractproctool.pas +++ b/components/codetools/extractproctool.pas @@ -1401,6 +1401,8 @@ var i: Integer; begin Result:=true; + if (IdentifierStartCleanEndPos) then + exit; if WithExpr<>'' then begin if CompareText(Identifier,WithExpr)=0 then begin if not SourceChangeCache.Replace(gtNone,gtNone, @@ -1493,6 +1495,7 @@ begin if not CheckIfRangeOnSameLevel(StartPos,EndPos,CleanStartPos,CleanEndPos, StartNode) then exit; //debugln(['TExtractProcTool.AddWithBlock ',SrcLen,' ',CleanStartPos,' ',CleanEndPos]); + //debugln(['TExtractProcTool.AddWithBlock Src="',copy(Src,CleanStartPos,CleanEndPos-CleanStartPos),'"']); MoveCursorToNodeStart(StartNode); if WithExpr<>'' then SourceChangeCache.MainScanner:=Scanner; diff --git a/components/codetools/ide/addassignmethoddlg.pas b/components/codetools/ide/addassignmethoddlg.pas index 3914846d40..b88b4a77f2 100644 --- a/components/codetools/ide/addassignmethoddlg.pas +++ b/components/codetools/ide/addassignmethoddlg.pas @@ -21,7 +21,7 @@ Author: Mattias Gaertner Abstract: - An IDE dialog to add a Assign method to a pascal class. + An IDE dialog to add an Assign method to a pascal class. } unit AddAssignMethodDlg; diff --git a/components/codetools/ide/addwithblock.lfm b/components/codetools/ide/addwithblock.lfm new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/codetools/ide/addwithblock.pas b/components/codetools/ide/addwithblock.pas new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/codetools/ide/cody.lpk b/components/codetools/ide/cody.lpk index ecc5db2334..a2ff3509b5 100644 --- a/components/codetools/ide/cody.lpk +++ b/components/codetools/ide/cody.lpk @@ -19,7 +19,7 @@ - + @@ -59,8 +59,12 @@ - + + + + + @@ -68,20 +72,23 @@ - + - + - + - + + + + - + diff --git a/components/codetools/ide/cody.pas b/components/codetools/ide/cody.pas index 123277d04e..a14973f05a 100644 --- a/components/codetools/ide/cody.pas +++ b/components/codetools/ide/cody.pas @@ -9,7 +9,7 @@ interface uses PPUListDlg, CodyStrConsts, AddAssignMethodDlg, CodyCtrls, CodyFrm, CodyRegistration, DeclareVarDlg, CodyUtils, CodyNodeInfoDlg, - CodyCopyDeclaration, LazarusPackageIntf; + CodyCopyDeclaration, AddWithBlockDlg, LazarusPackageIntf; implementation diff --git a/components/codetools/ide/codyregistration.pas b/components/codetools/ide/codyregistration.pas index 74235ee281..6ba891ae4c 100644 --- a/components/codetools/ide/codyregistration.pas +++ b/components/codetools/ide/codyregistration.pas @@ -32,7 +32,7 @@ interface uses Classes, SysUtils, LResources, Controls, IDECommands, MenuIntf, IDEWindowIntf, SrcEditorIntf, - CodyStrConsts, CodyCtrls, PPUListDlg, AddAssignMethodDlg, + CodyStrConsts, CodyCtrls, PPUListDlg, AddAssignMethodDlg, AddWithBlockDlg, CodyUtils, CodyNodeInfoDlg, CodyFrm, DeclareVarDlg, CodyCopyDeclaration; procedure Register; @@ -47,6 +47,7 @@ var PPUListCommand: TIDECommand; AddAssignMethodCommand: TIDECommand; ExplodeAWithBlockCommand: TIDECommand; + AddAWithBlockCommand: TIDECommand; InsertFileAtCursorCommand: TIDECommand; DeclareVariableCommand: TIDECommand; TVIconRes: TLResource; @@ -131,6 +132,12 @@ begin CleanIDEShortCut,CleanIDEShortCut,nil,@ExplodeAWithBlockCmd); RegisterIDEMenuCommand(SrcEditSubMenuRefactor, 'ExplodeAWithBlock', crsExplodeAWithBlock, nil, nil, ExplodeAWithBlockCommand); + // add a With block + AddAWithBlockCommand:=RegisterIDECommand(CmdCatCodeTools, 'AddAWithBlock', + crsAddAWithBlock, + CleanIDEShortCut,CleanIDEShortCut,nil,@ShowAddWithBlockDialog); + RegisterIDEMenuCommand(SrcEditSubMenuRefactor, 'AddAWithBlock', + crsAddAWithBlock, nil, nil, AddAWithBlockCommand); // IDE internals menu - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/codetools/ide/codystrconsts.pas b/components/codetools/ide/codystrconsts.pas index f463d67ab6..73d4430ea6 100644 --- a/components/codetools/ide/codystrconsts.pas +++ b/components/codetools/ide/codystrconsts.pas @@ -79,8 +79,18 @@ resourcestring crsCopyDeclarationToClipboard = 'Copy declaration to clipboard'; crsCutDeclarationToClipboard = 'Cut declaration to clipboard'; crsExplodeAWithBlock = 'Explode a "With" block'; + crsAddAWithBlock = 'Add a "With" block'; crsCWError = 'Error'; + crsPleaseSelectSomeCodeInTheSourceEditorForANewWithBl = 'Please select some ' + +'code in the Source Editor for a new "With" block. No candidate for a ' + +'with expression was found.'; + crsPleaseSelectSomeCodeInTheSourceEditor = 'Please select some code in the ' + +'Source Editor.'; + crsAddWithBlock = 'Add "With" Block'; + crsSelectExpression = 'Select expression'; + crsExpression = 'Expression'; + crsCount = 'Count'; crsPleasePlaceTheCursorOfTheSourceEditorOnAnIdentifie = 'Please place the ' +'cursor of the source editor on an identifier of a declaration.'; crsPleaseSpecifyAType = 'Please specify a type'; diff --git a/components/codetools/ide/languages/codystrconsts.it.po b/components/codetools/ide/languages/codystrconsts.it.po index e866f4b0e6..9162aefe83 100644 --- a/components/codetools/ide/languages/codystrconsts.it.po +++ b/components/codetools/ide/languages/codystrconsts.it.po @@ -18,10 +18,18 @@ msgstr "" msgid "Add Assign method ..." msgstr "" +#: codystrconsts.crsaddawithblock +msgid "Add a \"With\" block" +msgstr "" + #: codystrconsts.crsaddcallinherited msgid "Add call inherited" msgstr "" +#: codystrconsts.crsaddwithblock +msgid "Add \"With\" Block" +msgstr "" + #: codystrconsts.crsalreadydefined msgid "Already defined" msgstr "" @@ -150,6 +158,10 @@ msgstr "" msgid "Copy declaration to clipboard" msgstr "" +#: codystrconsts.crscount +msgid "Count" +msgstr "" + #: codystrconsts.crscuallfiles msgid "%s|All files (%s)|%s" msgstr "" @@ -210,6 +222,10 @@ msgstr "" msgid "Explode a \"With\" block" msgstr "" +#: codystrconsts.crsexpression +msgid "Expression" +msgstr "" + #: codystrconsts.crsfile msgid "File" msgstr "" @@ -314,6 +330,14 @@ msgstr "" msgid "Please place the cursor of the source editor on an identifier of a declaration." msgstr "" +#: codystrconsts.crspleaseselectsomecodeinthesourceeditor +msgid "Please select some code in the Source Editor." +msgstr "" + +#: codystrconsts.crspleaseselectsomecodeinthesourceeditorforanewwithbl +msgid "Please select some code in the Source Editor for a new \"With\" block. No candidate for a with expression was found." +msgstr "" + #: codystrconsts.crspleasespecifyalocation msgid "Please specify a location" msgstr "" @@ -366,6 +390,10 @@ msgstr "" msgid "searching ..." msgstr "Ricerca in corso..." +#: codystrconsts.crsselectexpression +msgid "Select expression" +msgstr "" + #: codystrconsts.crsshowcodetoolsnodeinfo msgid "Show CodeTools node info ..." msgstr "" diff --git a/components/codetools/ide/languages/codystrconsts.po b/components/codetools/ide/languages/codystrconsts.po index e3b9a1f17c..1707a15144 100644 --- a/components/codetools/ide/languages/codystrconsts.po +++ b/components/codetools/ide/languages/codystrconsts.po @@ -9,10 +9,18 @@ msgstr "" msgid "Add Assign method ..." msgstr "" +#: codystrconsts.crsaddawithblock +msgid "Add a \"With\" block" +msgstr "" + #: codystrconsts.crsaddcallinherited msgid "Add call inherited" msgstr "" +#: codystrconsts.crsaddwithblock +msgid "Add \"With\" Block" +msgstr "" + #: codystrconsts.crsalreadydefined msgid "Already defined" msgstr "" @@ -141,6 +149,10 @@ msgstr "" msgid "Copy declaration to clipboard" msgstr "" +#: codystrconsts.crscount +msgid "Count" +msgstr "" + #: codystrconsts.crscuallfiles msgid "%s|All files (%s)|%s" msgstr "" @@ -201,6 +213,10 @@ msgstr "" msgid "Explode a \"With\" block" msgstr "" +#: codystrconsts.crsexpression +msgid "Expression" +msgstr "" + #: codystrconsts.crsfile msgid "File" msgstr "" @@ -305,6 +321,14 @@ msgstr "" msgid "Please place the cursor of the source editor on an identifier of a declaration." msgstr "" +#: codystrconsts.crspleaseselectsomecodeinthesourceeditor +msgid "Please select some code in the Source Editor." +msgstr "" + +#: codystrconsts.crspleaseselectsomecodeinthesourceeditorforanewwithbl +msgid "Please select some code in the Source Editor for a new \"With\" block. No candidate for a with expression was found." +msgstr "" + #: codystrconsts.crspleasespecifyalocation msgid "Please specify a location" msgstr "" @@ -357,6 +381,10 @@ msgstr "" msgid "searching ..." msgstr "" +#: codystrconsts.crsselectexpression +msgid "Select expression" +msgstr "" + #: codystrconsts.crsshowcodetoolsnodeinfo msgid "Show CodeTools node info ..." msgstr "" diff --git a/components/codetools/ide/languages/codystrconsts.pt_BR.po b/components/codetools/ide/languages/codystrconsts.pt_BR.po index b2c779e21d..014f069c66 100644 --- a/components/codetools/ide/languages/codystrconsts.pt_BR.po +++ b/components/codetools/ide/languages/codystrconsts.pt_BR.po @@ -17,10 +17,18 @@ msgstr "Adicionar método \"Assign\"" msgid "Add Assign method ..." msgstr "Adicionar método \"Assign\" ..." +#: codystrconsts.crsaddawithblock +msgid "Add a \"With\" block" +msgstr "" + #: codystrconsts.crsaddcallinherited msgid "Add call inherited" msgstr "Adicionar chamada \"inherited\"" +#: codystrconsts.crsaddwithblock +msgid "Add \"With\" Block" +msgstr "" + #: codystrconsts.crsalreadydefined msgid "Already defined" msgstr "Já definido" @@ -149,6 +157,10 @@ msgstr "Informação Nó de Código" msgid "Copy declaration to clipboard" msgstr "Copiar declaração para área transferência" +#: codystrconsts.crscount +msgid "Count" +msgstr "" + #: codystrconsts.crscuallfiles msgid "%s|All files (%s)|%s" msgstr "%s|Todos arquivos (%s)|%s" @@ -209,6 +221,10 @@ msgstr "\"%s\" é uma palavra-chave." msgid "Explode a \"With\" block" msgstr "Expandir um bloco \"With\"" +#: codystrconsts.crsexpression +msgid "Expression" +msgstr "" + #: codystrconsts.crsfile msgid "File" msgstr "Arquivo" @@ -313,6 +329,14 @@ msgstr "Favor colocar o cursor do editor de código em um identificador na afirm msgid "Please place the cursor of the source editor on an identifier of a declaration." msgstr "Favor colocar o cursor do editor de código em um identificador da declaração." +#: codystrconsts.crspleaseselectsomecodeinthesourceeditor +msgid "Please select some code in the Source Editor." +msgstr "" + +#: codystrconsts.crspleaseselectsomecodeinthesourceeditorforanewwithbl +msgid "Please select some code in the Source Editor for a new \"With\" block. No candidate for a with expression was found." +msgstr "" + #: codystrconsts.crspleasespecifyalocation msgid "Please specify a location" msgstr "Favor especificar um local" @@ -365,6 +389,10 @@ msgstr "Relatório" msgid "searching ..." msgstr "localizando ..." +#: codystrconsts.crsselectexpression +msgid "Select expression" +msgstr "" + #: codystrconsts.crsshowcodetoolsnodeinfo msgid "Show CodeTools node info ..." msgstr "Exibir info do nó CodeTools ..." diff --git a/components/codetools/ide/languages/codystrconsts.ru.po b/components/codetools/ide/languages/codystrconsts.ru.po index 58791831a7..9cb9f92a4d 100644 --- a/components/codetools/ide/languages/codystrconsts.ru.po +++ b/components/codetools/ide/languages/codystrconsts.ru.po @@ -17,10 +17,18 @@ msgstr "Добавить метод Assign" msgid "Add Assign method ..." msgstr "Добавить метод Assign ..." +#: codystrconsts.crsaddawithblock +msgid "Add a \"With\" block" +msgstr "" + #: codystrconsts.crsaddcallinherited msgid "Add call inherited" msgstr "Добавить вызов унаследованного метода" +#: codystrconsts.crsaddwithblock +msgid "Add \"With\" Block" +msgstr "" + #: codystrconsts.crsalreadydefined msgid "Already defined" msgstr "Идентификатор уже объявлен" @@ -149,6 +157,10 @@ msgstr "Сведения об элементе кода" msgid "Copy declaration to clipboard" msgstr "Копировать объявление в буфер обмена" +#: codystrconsts.crscount +msgid "Count" +msgstr "" + #: codystrconsts.crscuallfiles msgid "%s|All files (%s)|%s" msgstr "%s|Все файлы (%s)|%s" @@ -209,6 +221,10 @@ msgstr "\"%s\" является ключевым словом." msgid "Explode a \"With\" block" msgstr "Раскрыть блок \"With\"" +#: codystrconsts.crsexpression +msgid "Expression" +msgstr "" + #: codystrconsts.crsfile msgid "File" msgstr "Файл" @@ -314,6 +330,14 @@ msgstr "Расположите курсор редактора исходног msgid "Please place the cursor of the source editor on an identifier of a declaration." msgstr "Расположите курсор редактора исходного кода на идентификаторе в объявлении." +#: codystrconsts.crspleaseselectsomecodeinthesourceeditor +msgid "Please select some code in the Source Editor." +msgstr "" + +#: codystrconsts.crspleaseselectsomecodeinthesourceeditorforanewwithbl +msgid "Please select some code in the Source Editor for a new \"With\" block. No candidate for a with expression was found." +msgstr "" + #: codystrconsts.crspleasespecifyalocation msgid "Please specify a location" msgstr "Укажите расположение" @@ -366,6 +390,10 @@ msgstr "Отчёт" msgid "searching ..." msgstr "поиск ..." +#: codystrconsts.crsselectexpression +msgid "Select expression" +msgstr "" + #: codystrconsts.crsshowcodetoolsnodeinfo msgid "Show CodeTools node info ..." msgstr "Показать сведения об элементе CodeTools ..." diff --git a/components/codetools/ide/languages/codystrconsts.uk.po b/components/codetools/ide/languages/codystrconsts.uk.po index c8f9d207d4..04b71c8560 100644 --- a/components/codetools/ide/languages/codystrconsts.uk.po +++ b/components/codetools/ide/languages/codystrconsts.uk.po @@ -17,10 +17,18 @@ msgstr "Додати метод Assign" msgid "Add Assign method ..." msgstr "Додати метод Assign ..." +#: codystrconsts.crsaddawithblock +msgid "Add a \"With\" block" +msgstr "" + #: codystrconsts.crsaddcallinherited msgid "Add call inherited" msgstr "Додати виклик успадкованого" +#: codystrconsts.crsaddwithblock +msgid "Add \"With\" Block" +msgstr "" + #: codystrconsts.crsalreadydefined msgid "Already defined" msgstr "Вже визначений" @@ -149,6 +157,10 @@ msgstr "Інформація про Вузол Коду" msgid "Copy declaration to clipboard" msgstr "Копіювати оголошення в буфер" +#: codystrconsts.crscount +msgid "Count" +msgstr "" + #: codystrconsts.crscuallfiles msgid "%s|All files (%s)|%s" msgstr "%s|Всі файли (%s)|%s" @@ -209,6 +221,10 @@ msgstr "\"%s\" це ключове слово." msgid "Explode a \"With\" block" msgstr "Зруйнувати блок \"With\"" +#: codystrconsts.crsexpression +msgid "Expression" +msgstr "" + #: codystrconsts.crsfile msgid "File" msgstr "Файл" @@ -313,6 +329,14 @@ msgstr "Встановіть курсор редактора початково msgid "Please place the cursor of the source editor on an identifier of a declaration." msgstr "Встановіть курсор редактора початкового коду на ідентифікатор в оголошенні." +#: codystrconsts.crspleaseselectsomecodeinthesourceeditor +msgid "Please select some code in the Source Editor." +msgstr "" + +#: codystrconsts.crspleaseselectsomecodeinthesourceeditorforanewwithbl +msgid "Please select some code in the Source Editor for a new \"With\" block. No candidate for a with expression was found." +msgstr "" + #: codystrconsts.crspleasespecifyalocation msgid "Please specify a location" msgstr "Вкажіть розміщення" @@ -365,6 +389,10 @@ msgstr "Звіт" msgid "searching ..." msgstr "пошук ..." +#: codystrconsts.crsselectexpression +msgid "Select expression" +msgstr "" + #: codystrconsts.crsshowcodetoolsnodeinfo msgid "Show CodeTools node info ..." msgstr "Показати інфо про вузол CodeTools ..."