Geertjan's Blog

  • December 3, 2006

Creating Error Annotations in NetBeans IDE (Part 2)

Geertjan Wielenga
Product Manager
In yesterday's annotation, the entire line where the error occurred was highlighted. I spent a lot of time and frustration working out how to, instead of the whole line, highlight just the erroneous word itself. In the end, this saved me. I knew I had to use Line.Part somehow, but I didn't know how exactly. And it turns out you can get the part from the line itself, by passing the column and length of the word. Here's the result:

However, what confuses me is that in the XML file that defines the annotation, the type seems irrelevant. Whether I set line or linepart, the linepart annotation above works fine. This seems very strange. To give an idea of what such an XML file looks like, have a look at the verification package in the Wicket module. There editor hints are also provided. It all seems pretty tricky and I'm glad Petr Pisl contributed all that code, because I certainly would not have been able to do it. (I will blog about the annotation DTD soon, in the coming blogs in this series about error annotations.)

Last night Roumen and I had an excellent time with Paris, Marco, Panos, and Panos's wife. We started at a very traditional Greek restaurant, with food and ouzo (for me) and a traditional Greek band singing about love and pain (according to Panos). For me, the highlight of the evening was, definitely, the part where we were all doing the traditional Greek circle dance, with Paris shouting "left!" in my right ear and Roumen attached to my left shoulder as we swept around and around in front of everyone in the restaurant. Another highlight was Marco doing a traditional Greek dance, very passionate and moving. There may have been many more highlights last night, but I discovered that two bottles of ouzo causes a memory leak of several hours, which have been wiped from my hard disk completely. But, anyway, it was really a fantastic evening that I will remember for a long time, apart from the last several deleted hours...

Join the discussion

Comments ( 4 )
  • Rohan Sunday, December 3, 2006
    Any way by which we could have multi line annotation?
  • Geertjan Sunday, December 3, 2006
    You mean that you want every error in a document to be annotated at the same time? That should be possible because that's how it works in the IDE. If you have multiple errors in your code, all the lines where the errors occur are highlighted simultaneously. Or do you mean something different?
  • Rohan Ranade Monday, December 4, 2006
    No. Let me explain. I hope you remember this tool that I had blogged about The Review Tool.
    The user selects a line and an annotation is added. But sometimes reviewers need to pass comments on a bunch of lines. I wanted to highlight all the selected lines with a single annotation. But though Netbeans provides an annotation for a single line, as well as part of a line, I did not find anything for a multi line annotation (an annotation that spans across multiple lines)
    Thanks and Regards,
  • Geertjan Monday, December 4, 2006
    I don't think that's possible. The Line class is for a line and the Line.Part is for part of a line. I think you should create an RFE for this in issuezilla.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.