This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 30551 - EditorOperator.getAnnotations() does not return Parser Annotations
Summary: EditorOperator.getAnnotations() does not return Parser Annotations
Status: CLOSED WONTFIX
Alias: None
Product: qa
Classification: Unclassified
Component: Jellytools (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P2 blocker (vote)
Assignee: issues@qa
URL:
Keywords: T9Y
Depends on:
Blocks:
 
Reported: 2003-01-31 15:58 UTC by Jan Becicka
Modified: 2003-02-19 13:27 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
This hack works, but it depends on java module (707 bytes, text/plain)
2003-02-11 09:46 UTC, Jan Becicka
Details
Proposed EditorOperator.getAnnotations() method. (1.46 KB, text/plain)
2003-02-11 13:18 UTC, Jiri Skrivanek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Becicka 2003-01-31 15:58:58 UTC
Create "TestFile" and make an error in it.
Parser Annotation appears.

Execute this:

EditorWindowOperator ewo = new EditorWindowOperator();
EditorOperator editor = ewo.getEditor("TestFile");
        
Object[] annots = editor.getAnnotations();
System.out.println("******" + annots.length + "
Annotations found");

Outpus is:
0 Annotations found
Comment 1 Jiri Skrivanek 2003-02-03 15:56:39 UTC
Annotations are taken from Line object by method getAnnotations() (see
below). I don't know why ParserAnnotation is not returned by that
method. Could you ask java module developer? I think it is not
jellytools bug, so changing resolution to wontfix.

        Document doc = txtEditorPane().getDocument();
        DataObject od =
(DataObject)doc.getProperty(Document.StreamDescriptionProperty);
        Line.Set set =
((LineCookie)od.getCookie(LineCookie.class)).getLineSet();
        Iterator iter = set.getLines().iterator();
        List result = new ArrayList();
        while(iter.hasNext()) {
            Method getAnnotations =
Annotatable.class.getDeclaredMethod("getAnnotations", null);
            getAnnotations.setAccessible(true);
           
result.addAll((List)getAnnotations.invoke((Line)iter.next(), null));
        }
        Object[] annots = result.toArray(new Annotation[0]);
Comment 2 Jan Becicka 2003-02-03 19:57:16 UTC
It IS a bug, although it is not in jellytools.
Comment 3 Jan Becicka 2003-02-03 19:58:19 UTC
not sure, if it is java or editor bug.
Comment 4 Tomas Hurka 2003-02-04 10:01:38 UTC
ParserAnnotation is ordinary annotation with one exception. It is part-line annotation. I guess this is problem in Editor and/or openide.text package. Reassigning. 
Comment 5 Jan Lahoda 2003-02-04 11:16:01 UTC
Hi,
    I see I should explain this a bit. There is no supported way to
get all annotations of a document (editor). The EditorOperator gets
the list of annotations using a small hack using reflection. It does
not use any kind of the API (because there is no API that provides
such information). It is getting the annotations out from
org.openide.text.Line and this probably does not contain annotations
created only for part of the line. In fact, this is not bug of neither
openide nor editor - the API simply does not exist and jellytools uses
a hack (shame on me).

I might be able to find a hack to get even part-line annotations from
OpenIDE (a bit more reflection), but it depends on DocumentLine
(probably all lines in the IDE are DocumentLines, but it is not sure).

The second possibility is to create (somewhere) a test-API (only for
test purposes) that would provide these information.

(Or, the EditorOperator.getAnnotations could claim it provides only
Line annotations :-)).
Comment 6 Martin Roskanin 2003-02-05 15:09:49 UTC
Editor module doesn't contain annotations api. The bug seems to be in
jellytools as Honza said.
Comment 7 Jiri Skrivanek 2003-02-06 10:34:14 UTC
We won't fix because editor don't have appropriate API. If someone
with knowledge of editor sources prepare a patch, we can integrate it.
Comment 8 Jan Becicka 2003-02-11 09:46:50 UTC
Created attachment 8885 [details]
This hack works, but it depends on java module
Comment 9 Jiri Skrivanek 2003-02-11 13:18:03 UTC
OK, it works. We can add it to EditorOperator. See attachment. There
is only "indirect" dependence on JavaEditor.
Comment 10 Jiri Skrivanek 2003-02-11 13:18:48 UTC
Created attachment 8894 [details]
Proposed EditorOperator.getAnnotations() method.
Comment 11 Jan Becicka 2003-02-11 14:28:54 UTC
OK. Go ahead. But what is the behavior if java module is not
installed? You should not rethrow the ClassNotFoundException as a
JemmyException, should you?
Comment 12 Jiri Skrivanek 2003-02-19 13:27:38 UTC
Implemented in version 2.0.49.