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.
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
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]);
It IS a bug, although it is not in jellytools.
not sure, if it is java or editor bug.
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.
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 :-)).
Editor module doesn't contain annotations api. The bug seems to be in jellytools as Honza said.
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.
Created attachment 8885 [details] This hack works, but it depends on java module
OK, it works. We can add it to EditorOperator. See attachment. There is only "indirect" dependence on JavaEditor.
Created attachment 8894 [details] Proposed EditorOperator.getAnnotations() method.
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?
Implemented in version 2.0.49.