Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-02

Code Completion Templates

15 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner
to Donald Ziesig: Hi All! Could anyone point me at the file(s) containing the templates invoked with…

Donald Ziesig hat am 5. Februar 2013 um 23:16 geschrieben:

Show quoted text 13 lines
Hi All! Could anyone point me at the file(s) containing the templates invoked with Ctrl-Shift-C? Specifically I would like to replace the Set<Param> code that expands to: if(AValue=f<Param>) then exit; f<Param>=AValue; with Update(f<Param>,AValue); // Keeps track of modifications to the underlying object.

It's hard coded.
See components/codetools/codecompletion.pas around line 6730.

You can create a feature request or a patch to make this configurable.

Mattias

Reply by email

Donald Ziesig
to Mattias Gaertner
Mattias Gaertner wrote 28 lines
Donald Ziesig hat am 5. Februar 2013 um 23:16 geschrieben: > Hi All! > > Could anyone point me at the file(s) containing the templates invoked > with Ctrl-Shift-C? > > Specifically I would like to replace the Set<Param> code that expands to: > > if(AValue=f<Param>) then exit; > f<Param>=AValue; > > with > Update(f<Param>,AValue); // Keeps track of modifications to the > underlying object. It's hard coded. See components/codetools/codecompletion.pas around line 6730. You can create a feature request or a patch to make this configurable. Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Thanks,

I'll

Reply by email

Sven Barth
to Mattias Gaertner: Donald Ziesig hat am 5. Februar 2013 um 23:16 geschrieben: It's hard coded. See…
Mattias Gaertner wrote 20 lines
Donald Ziesig hat am 5. Februar 2013 um 23:16 geschrieben: > Hi All! > > Could anyone point me at the file(s) containing the templates invoked > with Ctrl-Shift-C? > > Specifically I would like to replace the Set<Param> code that expands to: > > if(AValue=f<Param>) then exit; > f<Param>=AValue; > > with > Update(f<Param>,AValue); // Keeps track of modifications to the > underlying object. It's hard coded. See components/codetools/codecompletion.pas around line 6730. You can create a feature request or a patch to make this configurable.

This has already been reported by me nearly three years ago: http://bugs.freepascal.org/view.php?id=15922

Regards,
Sven

Reply by email

Martin
to Sven Barth
Sven Barth wrote 5 lines
On 05.02.2013 18:30, Mattias Gaertner wrote: > Donald Ziesig hat am 5. Februar 2013 um 23:16 > geschrieben: >> Could anyone point me at the file(s) containing the templates invoked >> with Ctrl-Shift-C?

...

Show quoted text 5 lines
> It's hard coded. > See components/codetools/codecompletion.pas around line 6730. This has already been reported by me nearly three years ago: http://bugs.freepascal.org/view.php?id=15922

You can always create a macro (Lazarus 1.1 trunk)
http://wiki.lazarus.freepascal.org/Editor_Macros_PascalScript

begin
ecCompleteCode;
// check for "if AValu ...", in case completion did fail
// edit/replace text at caret
end;

and assign it to a key of your choice

Reply by email

Donald Ziesig

Hi All!

Could anyone point me at the file(s) containing the templates invoked with Ctrl-Shift-C?

Specifically I would like to replace the Set<Param> code that expands to:

if(AValue=f<Param>) then exit;
f<Param>=AValue;

with

   Update(f<Param>,AValue);  // Keeps track of modifications to the

underlying object.

Thanks,

Don Ziesig

Reply by email

Donald Ziesig
to Sven Barth: This has already been reported by me nearly three years ago:…
Sven Barth wrote 37 lines
On 05.02.2013 18:30, Mattias Gaertner wrote: > > Donald Ziesig hat am 5. Februar 2013 um 23:16 > geschrieben: >> Hi All! >> >> Could anyone point me at the file(s) containing the templates invoked >> with Ctrl-Shift-C? >> >> Specifically I would like to replace the Set<Param> code that >> expands to: >> >> if(AValue=f<Param>) then exit; >> f<Param>=AValue; >> >> with >> Update(f<Param>,AValue); // Keeps track of modifications to the >> underlying object. > > It's hard coded. > See components/codetools/codecompletion.pas around line 6730. > > You can create a feature request or a patch to make this configurable. This has already been reported by me nearly three years ago: http://bugs.freepascal.org/view.php?id=15922 Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Hi Again,

I have almost finished a patch that uses an xml file, a new unit and mods to codecompletion.pas to implement configurable code completion.

I have a few questions remaining:

1) What is the preferred way to specify the name and location of the xml file? I spent several hours trying to access PrimaryConfigPath or SecondaryConfigPath from my unit which is in the codetools package. Right now I am testing with a hard-coded path/file name.

2) What is the preferred way to submit the patch? (In my previous life, before retirement, all I had to do was submit my code to the Quality Control unit and wait for their inevitable nasty-grams; the classic of which was "What is this thing called a 'state machine' you have in your code?" ;-) ).

3) I have a separate program to parse the xml file and detect any possible syntax errors before Lazarus tries to load it. Where should I put that?

Thanks,

Don Ziesig

Reply by email

Sven Barth
to Donald Ziesig
Donald Ziesig wrote 5 lines
2) What is the preferred way to submit the patch? (In my previous life, before retirement, all I had to do was submit my code to the Quality Control unit and wait for their inevitable nasty-grams; the classic of which was "What is this thing called a 'state machine' you have in your code?" ;-) ).

Attach it to the bug report I mentioned above (and maybe write a comment explaining your patch). The "inevitable nasty-grams" will then follow as well :P

Regard,
Sven

Reply by email

Mattias Gaertner
to Donald Ziesig: I have almost finished a patch that uses an xml file, a new unit and mods to…
Show quoted text 10 lines
[...] I have almost finished a patch that uses an xml file, a new unit and mods to codecompletion.pas to implement configurable code completion. I have a few questions remaining: 1) What is the preferred way to specify the name and location of the xml file? I spent several hours trying to access PrimaryConfigPath or SecondaryConfigPath from my unit which is in the codetools package. Right now I am testing with a hard-coded path/file name.

You can add those options to the existing options. See ide/codetoolsoptions.pas

Show quoted text 5 lines
2) What is the preferred way to submit the patch? (In my previous life, before retirement, all I had to do was submit my code to the Quality Control unit and wait for their inevitable nasty-grams; the classic of which was "What is this thing called a 'state machine' you have in your code?" ;-) ).

Attach it to
http://bugs.freepascal.org/view.php?id=15922

3) I have a separate program to parse the xml file and detect any possible syntax errors before Lazarus tries to load it. Where should I put that?

What kind of syntax errors? For the xml or for the pascal snippets?

Mattias

Reply by email

Donald Ziesig
to Mattias Gaertner
Mattias Gaertner wrote 29 lines
On Sun, 10 Feb 2013 20:45:49 -0500 Donald Ziesig wrote: > [...] > I have almost finished a patch that uses an xml file, a new unit and > mods to codecompletion.pas to implement configurable code completion. > > I have a few questions remaining: > > 1) What is the preferred way to specify the name and location of the xml > file? I spent several hours trying to access PrimaryConfigPath or > SecondaryConfigPath from my unit which is in the codetools package. > Right now I am testing with a hard-coded path/file name. You can add those options to the existing options. See ide/codetoolsoptions.pas > 2) What is the preferred way to submit the patch? (In my previous life, > before retirement, all I had to do was submit my code to the Quality > Control unit and wait for their inevitable nasty-grams; the classic of > which was "What is this thing called a 'state machine' you have in your > code?" ;-) ). Attach it to http://bugs.freepascal.org/view.php?id=15922 > 3) I have a separate program to parse the xml file and detect any > possible syntax errors before Lazarus tries to load it. Where should I > put that? What kind of syntax errors? For the xml or for the pascal snippets?

For the xml. I'm leaving the pascal as an exercise for the student ;-) .

Don

Reply by email

Mattias Gaertner
to Donald Ziesig
Show quoted text 6 lines
[...] >> 3) I have a separate program to parse the xml file and detect any >> possible syntax errors before Lazarus tries to load it. Where should I >> put that? > What kind of syntax errors? For the xml or for the pascal snippets? For the xml. I'm leaving the pascal as an exercise for the student ;-) .

The xml is parsed by the xml reader. It has error messages for syntax errors. The IDE writes them only to stdout. This was never a problem, because the xml file is written by the IDE, so there are no syntax errors.

Mattias

Reply by email

Donald Ziesig
to Mattias Gaertner
Mattias Gaertner wrote 13 lines
On Mon, 11 Feb 2013 15:50:47 -0500 Donald Ziesig wrote: > [...] >>> 3) I have a separate program to parse the xml file and detect any >>> possible syntax errors before Lazarus tries to load it. Where should I >>> put that? >> What kind of syntax errors? For the xml or for the pascal snippets? > For the xml. I'm leaving the pascal as an exercise for the student ;-) . The xml is parsed by the xml reader. It has error messages for syntax errors. The IDE writes them only to stdout. This was never a problem, because the xml file is written by the IDE, so there are no syntax errors.

Hmmm. In my code, the XML reader detects, and the IDE writes XML errors to stdout as you say. I haven't implemented a GUI to generate the XML. (Yet). Right now, if the author of the XML makes an error, he had better be watching stdout while the XML loads so he can catch the errors. I will catch the syntax errors with a handler that puts up a message box for now to make them visible to the user.

I want to get the snippet generation fully implemented and tested first (it is almost done) before I get fancy with a GUI.

Any suggestions will be appreciated.

Thanks,

Don

Reply by email

Mattias Gaertner
to Donald Ziesig
Show quoted text 12 lines
[...] Hmmm. In my code, the XML reader detects, and the IDE writes XML errors to stdout as you say. I haven't implemented a GUI to generate the XML. (Yet). Right now, if the author of the XML makes an error, he had better be watching stdout while the XML loads so he can catch the errors. I will catch the syntax errors with a handler that puts up a message box for now to make them visible to the user. I want to get the snippet generation fully implemented and tested first (it is almost done) before I get fancy with a GUI. Any suggestions will be appreciated.

There are already several frames about options for codetools. Extend an existing one or add a new one.

Mattias

Reply by email

Donald Ziesig
to Mattias Gaertner
Mattias Gaertner wrote 27 lines
On Mon, 11 Feb 2013 21:43:03 -0500 Donald Ziesig wrote: > [...] > Hmmm. In my code, the XML reader detects, and the IDE writes XML errors > to stdout as you say. I haven't implemented a GUI to generate the XML. > (Yet). Right now, if the author of the XML makes an error, he had > better be watching stdout while the XML loads so he can catch the > errors. I will catch the syntax errors with a handler that puts up a > message box for now to make them visible to the user. > > I want to get the snippet generation fully implemented and tested first > (it is almost done) before I get fancy with a GUI. > > Any suggestions will be appreciated. There are already several frames about options for codetools. Extend an existing one or add a new one. Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

I extended the TCodetoolsClassCompletionOptionsFrame and added the template expander data in TCodeToolsOptions. I can see the data being saved and restored appropriately in codetoolsoptions.xml.

I have spent the whole morning trying to find the route I must use to get the data in TCodeToolsOptions (which now contains the path to the template file) into my TemplateExpander unit (which is in the uses clause of codecompletiontool.pas).

The following code from my TemplateExpander unit fails at compilation:

uses
   CodeToolOptions;

because the compiler can't find the file.

What do I need to do to make that unit visible in my code? It seems to have something to do with packages, but after reading the docs, I still don't know where to look.

Thanks,

Don Ziesig

Reply by email

Howard Page-Clark
to Donald Ziesig
Donald Ziesig wrote 6 lines
The following code from my TemplateExpander unit fails at compilation: uses CodeToolOptions; because the compiler can't find the file.

Assuming CodeTools has been added as a dependency for your project, I think you also need to add in the Project Options dialog in the Compiler Options | Paths page, in the dropdown field labelled "Other unit files(-Fu) (delimiter is semicolon)"
the following macro
$(LazarusDir)\units\$(TargetCPU)-$(TargetOS)\$(LCLWidgetType)

Reply by email

Mattias Gaertner
to Donald Ziesig: I extended the TCodetoolsClassCompletionOptionsFrame and added the template expander data…
Show quoted text 17 lines
On 02/12/2013 03:36 AM, Mattias Gaertner wrote: [...] I extended the TCodetoolsClassCompletionOptionsFrame and added the template expander data in TCodeToolsOptions. I can see the data being saved and restored appropriately in codetoolsoptions.xml. I have spent the whole morning trying to find the route I must use to get the data in TCodeToolsOptions (which now contains the path to the template file) into my TemplateExpander unit (which is in the uses clause of codecompletiontool.pas). The following code from my TemplateExpander unit fails at compilation: uses CodeToolOptions; because the compiler can't find the file.

That is a unit of the IDE itself. It can not be accessed by installed packages.
I think these new options can be added to the IDE. They don't need an extra package.

Mattias

Reply by email