cody: Add "With" block

git-svn-id: trunk@32245 -
This commit is contained in:
mattias 2011-09-10 00:11:50 +00:00
parent be78a06cb3
commit 726fc93729
14 changed files with 179 additions and 10 deletions

2
.gitattributes vendored
View File

@ -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

View File

@ -1401,6 +1401,8 @@ var
i: Integer;
begin
Result:=true;
if (IdentifierStart<CleanStartPos) or (IdentifierEnd>CleanEndPos) 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;

View File

@ -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;

View File

@ -19,7 +19,7 @@
<Description Value="IDE extensions using Codetools."/>
<License Value="GPL2"/>
<Version Major="1" Minor="1"/>
<Files Count="10">
<Files Count="11">
<Item1>
<Filename Value="ppulistdlg.pas"/>
<UnitName Value="PPUListDlg"/>
@ -59,8 +59,12 @@
</Item9>
<Item10>
<Filename Value="codycopydeclaration.pas"/>
<UnitName Value="codycopydeclaration"/>
<UnitName Value="CodyCopyDeclaration"/>
</Item10>
<Item11>
<Filename Value="addwithblockdlg.pas"/>
<UnitName Value="addwithblockdlg"/>
</Item11>
</Files>
<LazDoc Paths="doc"/>
<i18n>
@ -68,20 +72,23 @@
<OutDir Value="languages"/>
</i18n>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="4">
<RequiredPkgs Count="5">
<Item1>
<PackageName Value="LCLBase"/>
<PackageName Value="LCL"/>
</Item1>
<Item2>
<PackageName Value="IDEIntf"/>
<PackageName Value="LCLBase"/>
</Item2>
<Item3>
<PackageName Value="CodeTools"/>
<PackageName Value="IDEIntf"/>
</Item3>
<Item4>
<PackageName Value="CodeTools"/>
</Item4>
<Item5>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True" Release="1"/>
</Item4>
</Item5>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>

View File

@ -9,7 +9,7 @@ interface
uses
PPUListDlg, CodyStrConsts, AddAssignMethodDlg, CodyCtrls, CodyFrm,
CodyRegistration, DeclareVarDlg, CodyUtils, CodyNodeInfoDlg,
CodyCopyDeclaration, LazarusPackageIntf;
CodyCopyDeclaration, AddWithBlockDlg, LazarusPackageIntf;
implementation

View File

@ -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 - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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';

View File

@ -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 ""

View File

@ -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 ""

View File

@ -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 ..."

View File

@ -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 ..."

View File

@ -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 ..."