custom language plugin

 hey guys,

I decided to make a plugin for the css-like language following this instruction  http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/prerequisites.html but im not sure i understand how to add new language class to the sources. i created new java class and didnt find where extend it from class com.intellij.lang.Language doesnt exist. Also the empty project doesnt start. Please help)) im noob in intellij and java.

13 comments
Comment actions Permalink
Official comment

`com.intellij.lang.Language` is part of SDK that you should configure as it's said at http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/prerequisites.html.

After that, you should create an IntelliJ IDEA Plugin project and set created SDK for it.

You share attach `.idea` directory of your project, so I'll tell you what exactly is wrong with it.

Comment actions Permalink

thanks, idea has been compiled. where should i put <fileTypeFactory implementation="com.simpleplugin.SimpleFileTypeFactory"/> ? is this some xml?

0
Comment actions Permalink

Yes, there is plugin.xml file that is generated on creating project

0
Comment actions Permalink

Thanks, i have added it to the plugin.xml, but my file extension is still not suppoting... could you please review the code at https://github.com/iklubov/ideaPlugin? Also the @override,  Icon and String classes are highlighting with red in the editor, maybe you know the reason? thanks.

0
Comment actions Permalink

First of all, your extension IS supported. How did you decide that it isn't?

In the second, there is an exception in log:

 

```
ERROR: Icon cannot be found in 'icons/jar-gray.png', aClass='class ussPlugin.UssIcons'
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:132)
at com.intellij.openapi.util.IconLoader.getIcon(IconLoader.java:144)
at com.intellij.openapi.util.IconLoader.getIcon(IconLoader.java:112)
at ussPlugin.UssIcons.<clinit>(UssIcons.java:7)
at ussPlugin.UssFileType.getIcon(UssFileType.java:39)
at com.intellij.ide.presentation.VirtualFilePresentation.getIconImpl(VirtualFilePresentation.java:46)
at com.intellij.util.IconUtil.getIcon(IconUtil.java:172)
at com.intellij.openapi.fileEditor.impl.EditorWindow.getFileIcon(EditorWindow.java:871)
at com.intellij.openapi.fileEditor.impl.EditorWindow.updateFileIcon(EditorWindow.java:848)
at com.intellij.openapi.fileEditor.impl.EditorsSplitters.updateFileIconImmediately(EditorsSplitters.java:354)
at com.intellij.openapi.fileEditor.impl.EditorsSplitters.lambda$updateFileIconLater$2(EditorsSplitters.java:366)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:223)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:386)
at com.intellij.openapi.application.TransactionGuardImpl$6.run(TransactionGuardImpl.java:315)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:408)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:397)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:809)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:646)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
```

Which brings us to incorrect `IconLoader.getIcon` call. The '/' is missing at the start.

0
Comment actions Permalink

sorry, i havent got such exception on executing my plugin. maybe i didnt configure sdks in the right way,but i did it just like in the tutorial.

0
Comment actions Permalink

The question is still valid.

> First of all, your extension IS supported. How did you decide that it isn't?

 

> i did it just like in the tutorial.

As I said, you didn't. Have you tried the solution I've suggested?

0
Comment actions Permalink

i decided so because icon near my file hasnt been changed. and yes, i tried your solution. 

0
Comment actions Permalink

It's better to check whether the new file type is appeared in Settings | Editor | File types.

Anyway, the source code is completely correct and works. If you provide more info on how you compile and run the plugin and check whether it works, maybe I can help with this.

0
Comment actions Permalink

Some classes and override instructions cannot be resolved by the editor. Maybe this is a reason?

Also can send you screenshots of my project settings. Could you tell me which of them do you need? Sorry for inconvience. 

File type doesnt appear in the file types folder

Thanks

0
Comment actions Permalink

> Some classes and override instructions cannot be resolved by the editor. Maybe this is a reason?

 

It is, for sure. But how did you run debug IDE instance if you cannot compile the project?

 

Anyway, just check 'File | Project Structure | SDKs | IntelliJ IDEA Community... | Internal Java Platform ', it should point to your JDK.

0
Comment actions Permalink

the project compiles and runs ok, though these classes are highlighted red

this is my project sdk structure

and this is my jdk

 

 

0
Comment actions Permalink

I have no idea why JDK-classes is highlighted, but since the project is compiled and run, I don't see how it can affect anything. You can try invoke 'File | Invalidate Caches' though.

As for adding a file type, the project at https://github.com/iklubov/ideaPlugin is configured right and works fine for me.

You can attach logs (Help | Show Log), maybe there is something suspicious. If not, I can suggest only recreate JDK and IDEA SDK and project.

0

Please sign in to leave a comment.