[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Syntax coloring of new keywords

You need to override getId() in your language implementation.

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Sergey Smolov
Sent: Tuesday, October 18, 2011 14:11
To: CDT General developers list.
Subject: Re: [cdt-dev] Syntax coloring of new keywords

 

Ok, I've done it. But the main problem remains - no additional language appears in C++ project properties at Eclipse instance with embedded plugin. So, it does not help too.

I noticed only one strange moment: I have two "GNU C" items in languages list of Eclipse instance with embedded plugin, while in "usual" Eclipse I have only one. Looks like Eclipse tried to add my language, but the result was "GNU C". Rather strange, don't you think so?

18.10.2011 15:42, Leherbauer, Anton (Toni) пишет:

If you just want to add preprocessor directives, you are better off extending the scanner configuration by adding you directives like this:

       addPreprocessorKeyword(“my_directive”, IPreprocessorDirective.ppIgnore);

That way the preprocessor will ignore those directives. Highlighting for those directives should work automatically as long as you don’t override the ICLanguageKeywords methods and getAdapter().

Note that you should base your scanner configuration on GPPScannerExtensionConfiguration if your language is an extension to C++.

 

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Sergey Smolov
Sent: Tuesday, October 18, 2011 13:27
To: CDT General developers list.
Subject: Re: [cdt-dev] Syntax coloring of new keywords

 

Again thank you, but it does not help me. May be it is not enough for syntax highlight just to implement ICLanguageKeywords? For example, am I need to extend GNUScannerExtensionConfiguration too?

If true, can you tell me, what exaclty should I write in such extension?

18.10.2011 15:11, Leherbauer, Anton (Toni) пишет:

The implementation of getAdapter() does not look right.

If you override the ICLanguageKeywords methods, you should return “this” when the ICLanguageKeywords adapter is requested, like this:

 

       public Object getAdapter(Class adapter) {

              if (ICLanguageKeywords.class.equals(adapter))

                     return this;

              return super.getAdapter(adapter);

       }

 

HTH,

Toni

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Sergey Smolov
Sent: Tuesday, October 18, 2011 12:51
To: CDT General developers list.
Subject: Re: [cdt-dev] Syntax coloring of new keywords

 

Thank you for your quick answer!

I've added C++ content-types to my language. Now this part looks like:

<extension
         id="сppteskkeywords"
         name="C++ Language Extension"
         point="org.eclipse.cdt.core.language">
      <language
            class="cppteskpluginide.Keywords"
            id="CppTESKPluginIDE.language1"
            name="CppTesK C++">
      <contentType id="org.eclipse.cdt.core.cxxSource"/>
      <contentType id="org.eclipse.cdt.core.cxxHeader"/>
      </language>
   </extension>

Nevertheless, it does not work again - no item "CppTesK C++" in preference, no syntax highlight.
May be I miss something else?

17.10.2011 20:15, Eugene Ostroukhov пишет:

To me it looks like you did not associate your language with any particular content-type - you need to add content-type subelement to your language.

 

You can also use the "C/C++/Language Mapping" preference page to associate your language with particular file type.

On Oct 17, 2011, at 8:43 AM, Sergey Smolov <ssedai@xxxxxxxxx> wrote:

Hello, List!

My name is Sergey Smolov and I am need your help. My purpose is to make a syntax highlight for our extension of C++ language. This extension just contain about a one hundred of macro directives with different functionality.

For achieving such purpose I've started developing a plugin. Here is my "plugin.xml":

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         id="сppteskkeywords"
         name="CDT Language"
         point="org.eclipse.cdt.core.language">
      <language
            class="cppteskpluginide.Keywords"
            id="CppTESKPluginIDE.language1"
            name="CppTesKLanguage">
      </language>
   </extension>
</plugi

and here is class, that contains necessary keywords:

import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
import org.eclipse.cdt.core.model.ICLanguageKeywords;

public class Keywords extends GCCLanguage implements ICLanguageKeywords
{
   
    public Object getAdapter(Keywords keywords)
    {
        return getAdapter(this);
    }
      
    public String[] getKeywords()
    {
        String[] array = new String[14];
       
        / array elements initialization
       
        return array;
    }

  
    public String[] getBuiltinTypes()
    {
        String[] array = new String[4];
       
        / array elements initialization
       
        return array;
    }
   
    public String[] getPreprocessorKeywords()
    {
        String[] array = new String[152];

        // array elements initialization
       
        return array;
    }

The main problem is that it didn't work in proper way, so I'd like to ask you the following question: what is the way for adding new keywords and making them  highlighted like C++? May be I miss something?

You will be much obliged if you will help me.
Thanks in advance!



-- 
Sincerely yours,
Sergey Smolov
ISP RAS

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

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






-- 
Sincerely yours,
Sergey Smolov
ISP RAS
 
 
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev





-- 
Sincerely yours,
Sergey Smolov
ISP RAS
 
 
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev




-- 
Sincerely yours,
Sergey Smolov
ISP RAS