How to highlight synthetic errors?

I'm writing a plugin which scans the currently open Java source file and
checks for semantic errors related to a particular API that we use. The
errors are not syntax errors that IDEA would pickup, so I need to be
able to highlight sections of the file as IDEA would for a syntax error.

I'm currently using MarkupModel.addRangeHighlighter and then setting the
error stripe marker color and tooltip text on the returned
RangeHighlighter but the tooltip text is not display when I hover over
the higlighted area, only over the error stripe in the gutter.

Is this the correct way to highlight errors?

Thanks,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919

15 comments
Comment actions Permalink

Gordon Tyler wrote:

I'm writing a plugin which scans the currently open Java source file and
checks for semantic errors related to a particular API that we use. The
errors are not syntax errors that IDEA would pickup, so I need to be
able to highlight sections of the file as IDEA would for a syntax error.

I'm currently using MarkupModel.addRangeHighlighter and then setting the
error stripe marker color and tooltip text on the returned
RangeHighlighter but the tooltip text is not display when I hover over
the higlighted area, only over the error stripe in the gutter.

Is this the correct way to highlight errors?

Thanks,
Gordon


This is not currenly avaliable via API unfortunately. The sure candidate for API extention.
The only thing I can suggest is to add a mouse listener to an editor and track mouse moved events yourself.

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

What about one or several inspections? That's what I use for highlighting errors concerning the usage of a particular API.

0
Comment actions Permalink

jonathan sauer wrote:

What about one or several inspections? That's what I use for highlighting errors concerning the usage of a particular API.


Is that available in 4.0?

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919

0
Comment actions Permalink

Gordon Tyler wrote:

jonathan sauer wrote:

>> What about one or several inspections? That's what I use for
>> highlighting errors concerning the usage of a particular API.


Is that available in 4.0?

Ciao,
Gordon

Yep

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

This is not currenly avaliable via API unfortunately. The sure candidate
for API extention.


Should I file a SCR?

The only thing I can suggest is to add a mouse listener to an editor and
track mouse moved events yourself.


That's what I'm doing, I'm calling setTooltipText on the Editor's
contentComponent but the delay for my tooltips to popup is longer than
IDEA's syntax error tooltips and my tooltips disappear after a few
seconds whereas IDEA's don't. Any suggestions on how to fix this?


--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919

0
Comment actions Permalink

Gordon Tyler wrote:

Maxim Shafirov (JetBrains) wrote:
Should I file a SCR?

Yes. But I think inspection API suites your need much closer.

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Em Fri, 28 May 2004 12:58:47 -0400, Gordon Tyler escreveu:

>> Yes. But I think inspection API suites your need much closer.


Okay. I'll have a look at that before I file a SCR.


Take a close look at the InspectionGadgets source code. As documentation
for OpenAPI is basically non-existent now (just method signatures), the
best (only) way to learn it is by examples.

I'm just puzzled at how Griffth could do all that without any docs...

--
Marcus Brito <pazu@animegaiden.com.br>


0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

Gordon Tyler wrote:

>> Maxim Shafirov (JetBrains) wrote:
>> Should I file a SCR?


Yes. But I think inspection API suites your need much closer.


Okay. I'll have a look at that before I file a SCR.

Thanks,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919

0
Comment actions Permalink

Marcus Brito wrote:
> As documentation for OpenAPI is basically non-existent now (just method signatures)
Some of quite rare "not the case" :)

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Em Fri, 28 May 2004 22:57:35 +0400, Maxim Shafirov (JetBrains) escreveu:

Some of quite rare "not the case" :)


My apologies, a very few classes are indeed documented :) Maybe my mind
got used to seeing just the signatures...

--
Marcus Brito <pazu@animegaiden.com.br>


0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

Gordon Tyler wrote:

>> jonathan sauer wrote:
>>
>>> What about one or several inspections? That's what I use for
>>> highlighting errors concerning the usage of a particular API.
>>
>> Is that available in 4.0?
>>

Yep


The inspections worked out very nicely. In fact, I've been able to
detect and report a wider variety of errors and provide a quickfix in
one case even.

Thanks,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919

0
Comment actions Permalink

Gordon Tyler wrote:

Maxim Shafirov (JetBrains) wrote:

>> Gordon Tyler wrote:
>>
>>> jonathan sauer wrote:
>>>
>>>> What about one or several inspections? That's what I use for
>>>> highlighting errors concerning the usage of a particular API.
>>>
>>>
>>> Is that available in 4.0?
>>>
>> Yep


The inspections worked out very nicely. In fact, I've been able to
detect and report a wider variety of errors and provide a quickfix in
one case even.

Thanks,
Gordon

If you'd include
inspection tag into plugin.xml directly under ]]> you'll be also able to use your inspections in an offline inspect tool
if that has any value for you.

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

If you'd include
<category>inspection</category>
tag into plugin.xml directly under <idea-plugin> you'll be also able to
use your inspections in an offline inspect tool if that has any value
for you.

Forgot to mention this only valid for Pallada

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

If you'd include
<category>inspection</category>
tag into plugin.xml directly under <idea-plugin> you'll be also able to
use your inspections in an offline inspect tool if that has any value
for you.


That reminds me of another question I had: I discovered that when a new
plugin with inspections is installed, the user has to go to the IDE
Settings -> Errors page and change all the inspections from "Do not
show" to "Show as error" or "Show as warning". Is it possible to have
new inspections (or a specific set) enabled by default?

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919

0
Comment actions Permalink

Gordon Tyler wrote:

Maxim Shafirov (JetBrains) wrote:

>> If you'd include
>> inspection >> tag into plugin.xml directly under you'll be also able >> to use your inspections in an offline inspect tool if that has any >>]]> value for you.


That reminds me of another question I had: I discovered that when a new
plugin with inspections is installed, the user has to go to the IDE
Settings -> Errors page and change all the inspections from "Do not
show" to "Show as error" or "Show as warning". Is it possible to have
new inspections (or a specific set) enabled by default?

Ciao,
Gordon

Yup, this stuff is not covered via API. Sure candidate for 5.0 API extention.

--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Please sign in to leave a comment.