How does BraceMatcher work?

Hello all, I am making good progress with my Clojure plugin.

I am currently debugging my Lexer and I want to test it with Brace matching.

I have implemented a Lexer, and a BraceMatcher. The icons on the files
change, so I think the FileType is registered. However, BraceMatching
doesn't happen, and breakpoints don't fire in my Lexer.

Can anyone describe how BraceMatcher and Lexer registration works?

I see that the BraceMatcher is registered as an extension like this...

... ]]>
...

How does it get invoked for the appropriate files, and how does it hook
up with the appropriate Lexer?

If you just wanted to do BraceMatching, how would you associate the file
extension, Lexer and BraceMatcher?

My guess is that the language=... string is matched with the getName()
of the FileType. Is that right? Is there anything else?

Thanks in advance
Peter


3 comments
Comment actions Permalink

Hello Peter,

Brace matching requires a Language instance. If you don't have any, the brace
matching will not work.

Make sure that your FileType is a LanguageFileType.

Hello all, I am making good progress with my Clojure plugin.

I am currently debugging my Lexer and I want to test it with Brace
matching.

I have implemented a Lexer, and a BraceMatcher. The icons on the
files change, so I think the FileType is registered. However,
BraceMatching doesn't happen, and breakpoints don't fire in my Lexer.

Can anyone describe how BraceMatcher and Lexer registration works?

I see that the BraceMatcher is registered as an extension like this...

<extensions defaultExtensionNs="com.intellij">
...
<lang.braceMatcher language="Groovy"
implementationClass="org.jetbrains.plugins.groovy.highlighter.GroovyBr
aceMatcher"/>
...

How does it get invoked for the appropriate files, and how does it
hook up with the appropriate Lexer?

If you just wanted to do BraceMatching, how would you associate the
file extension, Lexer and BraceMatcher?

My guess is that the language=... string is matched with the getName()
of the FileType. Is that right? Is there anything else?

Thanks in advance
Peter

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


0
Comment actions Permalink

Thanks Dmitry,

How is a Language registered?

I was just looking through the Groovy source. I found
GroovyLanguage.java, but I don't see anything in the plugin.xml. It
also does not seem to be referenced by the FileType or FileTypeLoader.

Thanks
Peter


Dmitry Jemerov wrote:

Hello Peter,

Brace matching requires a Language instance. If you don't have any, the
brace matching will not work.

Make sure that your FileType is a LanguageFileType.

>> Hello all, I am making good progress with my Clojure plugin.
>>
>> I am currently debugging my Lexer and I want to test it with Brace
>> matching.
>>
>> I have implemented a Lexer, and a BraceMatcher. The icons on the
>> files change, so I think the FileType is registered. However,
>> BraceMatching doesn't happen, and breakpoints don't fire in my Lexer.
>>
>> Can anyone describe how BraceMatcher and Lexer registration works?
>>
>> I see that the BraceMatcher is registered as an extension like this...
>>
>> >> ... >> > implementationClass="org.jetbrains.plugins.groovy.highlighter.GroovyBr >> aceMatcher"/> >> ... >> >> How does it get invoked for the appropriate files, and how does it >> hook up with the appropriate Lexer? >> >> If you just wanted to do BraceMatching, how would you associate the >> file extension, Lexer and BraceMatcher? >> >> My guess is that the language=... string is matched with the getName() >> of the FileType. Is that right? Is there anything else? >> >> Thanks in advance >>]]> Peter

0
Comment actions Permalink

Never mind, I figured it out.

For other n00bs... An instance of Language is passed to the FileType
constructor. The FileType is referenced by the FileTypeLoader. And the
FileTypeLoader is registered in the plugin.xml as a fileTypeFactory
extension.

Experts please correct me if I erred.

P


Peter Wolf wrote:

Thanks Dmitry,

How is a Language registered?

I was just looking through the Groovy source. I found
GroovyLanguage.java, but I don't see anything in the plugin.xml. It
also does not seem to be referenced by the FileType or FileTypeLoader.

Thanks
Peter


Dmitry Jemerov wrote:

>> Hello Peter,
>>
>> Brace matching requires a Language instance. If you don't have any,
>> the brace matching will not work.
>>
>> Make sure that your FileType is a LanguageFileType.
>>
>>> Hello all, I am making good progress with my Clojure plugin.
>>>
>>> I am currently debugging my Lexer and I want to test it with Brace
>>> matching.
>>>
>>> I have implemented a Lexer, and a BraceMatcher. The icons on the
>>> files change, so I think the FileType is registered. However,
>>> BraceMatching doesn't happen, and breakpoints don't fire in my Lexer.
>>>
>>> Can anyone describe how BraceMatcher and Lexer registration works?
>>>
>>> I see that the BraceMatcher is registered as an extension like this...
>>>
>>> >>> ... >>> >> implementationClass="org.jetbrains.plugins.groovy.highlighter.GroovyBr >>> aceMatcher"/> >>> ... >>> >>> How does it get invoked for the appropriate files, and how does it >>> hook up with the appropriate Lexer? >>> >>> If you just wanted to do BraceMatching, how would you associate the >>> file extension, Lexer and BraceMatcher? >>> >>> My guess is that the language=... string is matched with the getName() >>> of the FileType. Is that right? Is there anything else? >>> >>> Thanks in advance >>>]]> Peter

0

Please sign in to leave a comment.