Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Extend the C language Content Assist in Eclipse to support custom commands

If you register the modified DefaultMultilineCommentAutoEditStrategy for “__c_multiline_comment”, it won’t be called outside of multi-line comments.

As |* does not introduce a multiline comment, it is not called. You would need to register it for ICDocument.DEFAULT_CONTENT_TYPE.

 

Yes, ICPartitions.C_PREPROCESSOR is the content-type to use if the strategy is to be called inside #pragma directives.

 

Cheers,

Toni

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Lambros Petrou
Sent: Tuesday, June 05, 2012 18:06
To: CDT General developers list.
Subject: Re: [cdt-dev] Extend the C language Content Assist in Eclipse to support custom commands

 

Ok I looked at IAutoEditStrategy and the  DefaultMultilineCommentAutoEditStrategy. I made some changes to the Default one ( just for testing reasons ) and instead of ' /* ' I am using ' |* ' for my comments and I have used the ' prependAutoEditStrategy() ' method in my context text viewer when my plugin is enabled to load my strategy successfully. I have println() inside so I know when it's called.

The problem is that my strategy does not get called when I type in |* but only in normal comments /*. Is there any other place I should change to enable the custom strategy ?

In addition back to my problem, the contentType I should use is the C_PREPROCESSOR correct ?


On 5 June 2012 16:16, Lambros Petrou <lambrospower@xxxxxxxx> wrote:

Thank you. I am going to look into that. By programmatically you mean what exactly ? I believe like : At the first call of my plugin to get the TextViewer of the editor instance and add my strategy ? ( Is there a special function that adds it ? )

Thanks

 

On 5 June 2012 14:41, Leherbauer, Anton (Toni) <Anton.Leherbauer@xxxxxxxxxxxxx> wrote:

This sounds like an IAutoEditStrategy. See e.g. DefaultMultilineCommentAutoEditStrategy which closes a multiline comment when pressing enter after /*.

Unfortunately you cannot add such a strategy via plugin.xml. You would need to add it programmatically to the underlying TextViewer of each C/C++ editor instance.

 

Toni

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Lambros Petrou
Sent: Tuesday, June 05, 2012 13:01


To: CDT General developers list.
Subject: Re: [cdt-dev] Extend the C language Content Assist in Eclipse to support custom commands

 

Ok,

I finally got it and it works quite good. I just extended the DefaultProposalFilter to filter the ditor to just show my proposals and I implemented the ICompletionProposalComputer in order to create a list with the ICompletionProposals.

In this class I just use String manipulation to find the matching proposals to be listed and I do not use anything like the DOM or AST structures. Is there any problem with that later on ? It works for now perfectly.

I want to add another feature now and I cannot find any resource for it apart from templates. Some of the pragmas I have consist of a " starting " command and they have a " closing " command, like the braces in a for loop.

How can I add the possibility, when the pragma is finished and he presses ENTER while being at the end of the " starting " command to leave a blank line and autoinsert the " closing " command ? ( if I can move the cursor in between them it would be good but not required, at the moment ).

The main requirement right now is that Auto-closing when the user presses ENTER and the only way I found is by templates but it wouldn't work here because the " starting " command is not standard so a template with one structure will not have a match. I am going to check which " closing " command should be inserted but I just need that trigger when the ENTER is pressed.

Thank you.

On 22 May 2012 10:11, Leherbauer, Anton (Toni) <Anton.Leherbauer@xxxxxxxxxxxxx> wrote:

One possible trap is that you need to export the package of your class such that it can be instantiated by cdt.ui.

You can do this on the Runtime tab of the plugin manifest editor.

 

Toni

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Lambros Petrou
Sent: Monday, May 21, 2012 18:49
To: CDT General developers list.
Subject: Re: [cdt-dev] Extend the C language Content Assist in Eclipse to support custom commands

 

Yes, I have been looking at  InclusionProposalComputer  since your reply and I have a draft ready but it seems there is a probem. How can I check if my plugin is enabled and i use, because I am trying the pragmas and nothing comes up in the suggestions.

 

My plugin.xml is like this:

 

<?xml version="1.0" encoding="UTF-8"?>

<?eclipse version="3.4"?>

<plugin>

 

<extension

          id="DDMPragmasProposalComputer"

          point="org.eclipse.cdt.ui.completionProposalComputer">

       <completionProposalComputer

             categoryId="org.eclipse.cdt.ui.parserProposalCategory"

             class="ddmcontentassistance.DDMPragmasProposalComputer">

          <partition type="__c_preprocessor"/>

       </completionProposalComputer>

    </extension>

 

</plugin>

 

Thank you.

 

On 21 May 2012 09:57, Leherbauer, Anton (Toni) <Anton.Leherbauer@xxxxxxxxxxxxx> wrote:

Hi,

 

I’d suggest to look into the extension point “org.eclipse.cdt.ui.completionProposalComputer”.

All internal completion proposal computers are in fact implementations of this extension point.

The “InclusionProposalComputer” class and its plugin.xml extension snippet might provide some boilerplate code to get you started.

 

HTH

Toni

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Lambros Petrou
Sent: Sunday, May 20, 2012 19:17
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] Extend the C language Content Assist in Eclipse to support custom commands

 

I am trying to extend the C/C++ language in Eclipse CDT in order to have auto-complete (Content Assist) for some custom commands ( mostly pragmas ).

Let's say I have the command: #pragma IAM THE_CUSTOM_COMMAND var1 var2

I' d like to make a plugin in order to have the ability the moment I type in #pragma and then SPACE to show the possible commands I have like when I am using regular functions. And if I press enter on one of the suggestions the whole command should be pasted with the default values in the variables.

I tried reading in the Eclipse FAQ and found many tutorials online but I only found how to make a completely new editor supporting my commands.

I just need to add 20-30 pragmas like this in the CDT editor currently being used in Eclipse.

I read that there is an Extension Point for CDT Language and if I could make an extension for that it would be sufficient but I haven't found a tutorial explaining this.

Is there any way to add these commands to the CDT Editor with the Auto-complete functionality I want without making my own editor ? The language we use is C and we have these pragmas and this feature would be great since we use them a lot.

Thank you all.


 

--

Lambros Petrou

 

 


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev



 

--

Lambros Petrou

 

 


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev




--

Lambros Petrou

 

 


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev




--

Lambros Petrou

 

 




--

Lambros Petrou

 

 


Back to the top