Skip to main content

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

Thank you, it helps a bit, but not at all.
I've overrided getId() and getName() in my language and new language appears now in the list. But when I try to make an association it fails.
Here is error log:

Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
    at org.eclipse.cdt.internal.ui.language.ProjectLanguageMappingWidget$3.handleEvent(ProjectLanguageMappingWidget.java:157)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
    at org.eclipse.jface.window.Window.open(Window.java:801)
    at org.eclipse.ui.dialogs.PropertyDialogAction.run(PropertyDialogAction.java:158)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386)


18.10.2011 16:38, Leherbauer, Anton (Toni) пишет:

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
_______________________________________________ cdt-dev mailing list cdt-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/cdt-dev


-- 
Sincerely yours,
Sergey Smolov
ISP RAS

Back to the top