Custom language confusion

Hi,

I'm playing around with building a custom language plugin. The instructions at:

http://confluence.jetbrains.net/display/IDEADEV/DevelopingCustomLanguagePluginsforIntelliJIDEA


has the following:


Syntax highlighting: The lexer is returned from the implementation of
the SyntaxHighlighterFactory interface which is
registed in the com.intellij.lang.syntaxHighlighterFactory extension point.

Building the syntax tree of a file: the lexer is expected to be
returned from ParserDefinition.createLexer(),
and the ParserDefinition interface is registered in the
com.intellij.lang.parserDefinition extension point.

according to my IntelliJ (10.5.1)
resources.jar!PlatformExtensionPoints.xml has all of the "extension
points" like "syntaxHighlighter" but I don't see "parserDefinition" in
that file.

Also, if I try to put a "" tag inside my
META-INF/plugin.xml my IntelliJ highlights it in red.

Apologies in advance if this question is a dumb one.

Thanks!
-Mike

11 comments
Comment actions Permalink

Oh yeah, the question part;)

How and where do I put the "parserDefinition" extension-thingie?


On 2011-08-26 23:17:22 +0000, Mike Jennings said:

Hi,

I'm playing around with building a custom language plugin. The instructions at:

http://confluence.jetbrains.net/display/IDEADEV/DevelopingCustomLanguagePluginsforIntelliJIDEA


has the following:


Syntax highlighting: The lexer is returned from the implementation of
the SyntaxHighlighterFactory interface which is
registed in the com.intellij.lang.syntaxHighlighterFactory extension point.

Building the syntax tree of a file: the lexer is expected to be
returned from ParserDefinition.createLexer(),
and the ParserDefinition interface is registered in the
com.intellij.lang.parserDefinition extension point.

according to my IntelliJ (10.5.1)
resources.jar!PlatformExtensionPoints.xml has all of the "extension
points" like "syntaxHighlighter" but I don't see "parserDefinition" in
that file.

Also, if I try to put a "<parserDefinition …>" tag inside my
META-INF/plugin.xml my IntelliJ highlights it in red.

Apologies in advance if this question is a dumb one.

Thanks!
-Mike



0
Comment actions Permalink

Oh yeah, the question part;)

How and where do I put the "parserDefinition" extension-thingie?

On 2011-08-26 23:17:22 +0000, Mike Jennings said:

Hi,

I'm playing around with building a custom language plugin. The instructions at:

http://confluence.jetbrains.net/display/IDEADEV/DevelopingCustomLanguagePluginsforIntelliJIDEA


has the following:


Syntax highlighting: The lexer is returned from the implementation of
the SyntaxHighlighterFactory interface which is
registed in the com.intellij.lang.syntaxHighlighterFactory extension point.

Building the syntax tree of a file: the lexer is expected to be
returned from ParserDefinition.createLexer(),
and the ParserDefinition interface is registered in the
com.intellij.lang.parserDefinition extension point.

according to my IntelliJ (10.5.1)
resources.jar!PlatformExtensionPoints.xml has all of the "extension
points" like "syntaxHighlighter" but I don't see "parserDefinition" in
that file.

Also, if I try to put a "<parserDefinition …>" tag inside my
META-INF/plugin.xml my IntelliJ highlights it in red.

Apologies in advance if this question is a dumb one.

Thanks!
-Mike



0
Comment actions Permalink

Hello Mike,

The platformExtensionPoints.xml does not contain all extension points - just
those which are defined by one of the modules inside the IntelliJ IDEA platform.
Also, the correct name of the extension point is "lang.parserDefinition"
and not simply "parserDefinition".

I'm playing around with building a custom language plugin. The
instructions at:

http://confluence.jetbrains.net/display/IDEADEV/DevelopingCustomLang
uagePluginsforIntelliJIDEA

has the following:

Syntax highlighting: The lexer is returned from the implementation of
the SyntaxHighlighterFactory interface which is
registed in the com.intellij.lang.syntaxHighlighterFactory extension
point.
Building the syntax tree of a file: the lexer is expected to be
returned from ParserDefinition.createLexer(),
and the ParserDefinition interface is registered in the
com.intellij.lang.parserDefinition extension point.
according to my IntelliJ (10.5.1)
resources.jar!PlatformExtensionPoints.xml has all of the "extension
points" like "syntaxHighlighter" but I don't see "parserDefinition" in
that file.

Also, if I try to put a "<parserDefinition …>" tag inside my
META-INF/plugin.xml my IntelliJ highlights it in red.

Apologies in advance if this question is a dumb one.


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Dont forget to check out the PsiViewer plugin - it is extremely helpful once you get to the point where you are building a Psi tree.

0
Comment actions Permalink

Thanks for the clarification Dmitry!

So to use the com.intellij.lang. syntaxHighlighterFactory extension
point I just need a "syntaxHighlighter" tag in my xml, but to use the
com.intellij.lang. parserDefinition extension point I need a
"lang.parserDefinition" tag in my xml. Correct?

On 2011-08-27 12:20:16 +0000, Dmitry Jemerov said:

Hello Mike,

The platformExtensionPoints.xml does not contain all extension points -
just those which are defined by one of the modules inside the IntelliJ
IDEA platform. Also, the correct name of the extension point is
"lang.parserDefinition" and not simply "parserDefinition".

>> I'm playing around with building a custom language plugin. The
>> instructions at:
>>
>> http://confluence.jetbrains.net/display/IDEADEV/DevelopingCustomLang
>> uagePluginsforIntelliJIDEA
>>
>> has the following:
>>
>> Syntax highlighting: The lexer is returned from the implementation of
>> the SyntaxHighlighterFactory interface which is
>> registed in the com.intellij.lang.syntaxHighlighterFactory extension
>> point.
>> Building the syntax tree of a file: the lexer is expected to be
>> returned from ParserDefinition.createLexer(),
>> and the ParserDefinition interface is registered in the
>> com.intellij.lang.parserDefinition extension point.
>> according to my IntelliJ (10.5.1)
>> resources.jar!PlatformExtensionPoints.xml has all of the "extension
>> points" like "syntaxHighlighter" but I don't see "parserDefinition" in
>> that file.
>>
>> Also, if I try to put a " Apologies in advance if this question is a dumb one.


0
Comment actions Permalink

Thanks Jon!

I actually installed it, but I have no idea how to use it ;)

On 2011-08-28 16:39:09 +0000, Jon Akhtar said:

Dont forget to check out the PsiViewer plugin - it is extremely helpful
once you get to the point where you are building a Psi tree.

---
Original message URL: http://devnet.jetbrains.net/message/5317829#5317829



0
Comment actions Permalink

Hello Mike,

No. The syntaxHighlighterFactory is also "lang.syntaxHighlighterFactory".
Anything after "com.intellij" is a required part of the extension point name.

Thanks for the clarification Dmitry!

So to use the com.intellij.lang. syntaxHighlighterFactory extension
point I just need a "syntaxHighlighter" tag in my xml, but to use the
com.intellij.lang. parserDefinition extension point I need a
"lang.parserDefinition" tag in my xml. Correct?

On 2011-08-27 12:20:16 +0000, Dmitry Jemerov said:

>> Hello Mike,
>>
>> The platformExtensionPoints.xml does not contain all extension points
>> - just those which are defined by one of the modules inside the
>> IntelliJ IDEA platform. Also, the correct name of the extension point
>> is "lang.parserDefinition" and not simply "parserDefinition".
>>
>>> I'm playing around with building a custom language plugin. The
>>> instructions at:
>>>
>>> http://confluence.jetbrains.net/display/IDEADEV/DevelopingCustomLa
>>> ng uagePluginsforIntelliJIDEA
>>>
>>> has the following:
>>>
>>> Syntax highlighting: The lexer is returned from the implementation
>>> of
>>> the SyntaxHighlighterFactory interface which is
>>> registed in the com.intellij.lang.syntaxHighlighterFactory extension
>>> point.
>>> Building the syntax tree of a file: the lexer is expected to be
>>> returned from ParserDefinition.createLexer(),
>>> and the ParserDefinition interface is registered in the
>>> com.intellij.lang.parserDefinition extension point.
>>> according to my IntelliJ (10.5.1)
>>> resources.jar!PlatformExtensionPoints.xml has all of the "extension
>>> points" like "syntaxHighlighter" but I don't see "parserDefinition"
>>> in
>>> that file.
>>> Also, if I try to put a "

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Hi Dmitry,

If I put in "lang.syntaxHighlighterFactory" IDEA colours it red, but if
I put just "syntaxHighlighterFactory" IDEA colours it normally. Why
would that be?

Also, I use "fileTypeFactory" and not "lang.fileTypeFactory" and my
fileTypeFactory gets instantiated properly.

Also, I noticed in com.intellij.lang.java.JavaLanguage that a syntax
highlighter seems to be registered in the constructor via:

  public JavaLanguage() {
    super("JAVA", "text/java", "application/x-java", "text/x-java");
   
SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this,
new SyntaxHighlighterFactory() {
      @NotNull
      public SyntaxHighlighter getSyntaxHighlighter(final Project
project, final VirtualFile virtualFile) {
        return new JavaFileHighlighter(
          virtualFile != null ?
LanguageLevelUtil.getLanguageLevelForFile(virtualFile) :
LanguageLevel.HIGHEST);
      }
    });
  }

Is that the same as registering it via XML? Is this the preferred way
to register a syntax highlighter?

Thanks in advance for any help!
-Mike

On 2011-08-29 10:25:56 +0000, Dmitry Jemerov said:

Hello Mike,

No. The syntaxHighlighterFactory is also
"lang.syntaxHighlighterFactory". Anything after "com.intellij" is a
required part of the extension point name.

>> Thanks for the clarification Dmitry!
>>
>> So to use the com.intellij.lang. syntaxHighlighterFactory extension
>> point I just need a "syntaxHighlighter" tag in my xml, but to use the
>> com.intellij.lang. parserDefinition extension point I need a
>> "lang.parserDefinition" tag in my xml. Correct?
>>
>> On 2011-08-27 12:20:16 +0000, Dmitry Jemerov said:
>>
>>> Hello Mike,
>>>
>>> The platformExtensionPoints.xml does not contain all extension points
>>> - just those which are defined by one of the modules inside the
>>> IntelliJ IDEA platform. Also, the correct name of the extension point
>>> is "lang.parserDefinition" and not simply "parserDefinition".
>>>
>>>> I'm playing around with building a custom language plugin. The
>>>> instructions at:
>>>>
>>>> http://confluence.jetbrains.net/display/IDEADEV/DevelopingCustomLa
>>>> ng uagePluginsforIntelliJIDEA
>>>>
>>>> has the following:
>>>>
>>>> Syntax highlighting: The lexer is returned from the implementation
>>>> of
>>>> the SyntaxHighlighterFactory interface which is
>>>> registed in the com.intellij.lang.syntaxHighlighterFactory extension
>>>> point.
>>>> Building the syntax tree of a file: the lexer is expected to be
>>>> returned from ParserDefinition.createLexer(),
>>>> and the ParserDefinition interface is registered in the
>>>> com.intellij.lang.parserDefinition extension point.
>>>> according to my IntelliJ (10.5.1)
>>>> resources.jar!PlatformExtensionPoints.xml has all of the "extension
>>>> points" like "syntaxHighlighter" but I don't see "parserDefinition"
>>>> in
>>>> that file.
>>>> Also, if I try to put a " Apologies in advance if this question is a dumb one.


0
Comment actions Permalink

btw, perhaps it was just confusion.

There is:

lang.syntaxHighlighterFactory  


and

syntaxHighlighter


and I use lang.syntaxHighlighterFactory, I believe it is the newer implementation, and I think it tries to make sure to always use the same instance of your Lexer.

as for

fileTypeFactory


I think that is it. There is no lang version of it that I can find., perhaps you saw fileType.fileViewProviderFactory instead.

Anyways - it is so much easier to start with a working plugin that you can understand - groovy is really sophisticated when I started to write my Language plugin i had 5-6 examples I was working from.

0
Comment actions Permalink

Thanks for the clarification Jon!

A bit more documentation would be nice though.

Thanks again!
-Mike

On 2011-09-05 20:03:43 +0000, Jon Akhtar said:

btw, perhaps it was just confusion.

There is:

*lang.syntaxHighlighterFactory *


and

syntaxHighlighter


and I use lang.syntaxHighlighterFactory, I believe it is the newer
implementation, and I think it tries to make sure to always use the
same instance of your Lexer.

as for

fileTypeFactory
>


I think that is it. There is no lang version of it that I can find.,
perhaps you saw fileType.fileViewProviderFactory instead.

Anyways - it is so much easier to start with a working plugin that you
can understand - groovy is really sophisticated when I started to write
my Language plugin i had 5-6 examples I was working from.

---
Original message URL: http://devnet.jetbrains.net/message/5318534#5318534



0
Comment actions Permalink

The documentation is the source really. That is something that you will have to get used to.

You can always ask questions here. Dmitry is really good about answering them

0

Please sign in to leave a comment.