eclipse-platform / eclipse.platform.text

8 stars 45 forks source link

NPEs with InlinedAnnotation if used in multiple viewers with different collapsed ranges #206

Closed mickaelistria closed 1 year ago

mickaelistria commented 1 year ago

This comes from https://github.com/redhat-developer/eclipseide-jdtls/issues/59 , with steps to reproduce using eclipseide-jdtls

When a file opened in an editor has some inlined annotations added, then they may become available to other editors/viewers because the annotation model can be shared. In case in the other viewer, the range differs because of different collapsed/expanded area and some part of the code mining rendering will then fail as they assume the annotation is still used in the same viewer and code is missing some guards. Eg

java.lang.NullPointerException: Cannot invoke "org.eclipse.jface.text.IRegion.getOffset()" because "widgetRange" is null
    at org.eclipse.jface.text.source.inlined.AbstractInlinedAnnotation.isFirstVisibleOffset(AbstractInlinedAnnotation.java:209)
    at org.eclipse.jface.text.source.inlined.InlinedAnnotationDrawingStrategy.draw(InlinedAnnotationDrawingStrategy.java:40)
    at org.eclipse.jface.text.source.AnnotationPainter.drawDecoration(AnnotationPainter.java:1421)
    at org.eclipse.jface.text.source.AnnotationPainter.handleDrawRequest(AnnotationPainter.java:1387)
    at org.eclipse.jface.text.source.AnnotationPainter.enablePainting(AnnotationPainter.java:484)
    at org.eclipse.jface.text.source.AnnotationPainter.updatePainting(AnnotationPainter.java:954)
    at org.eclipse.jface.text.source.AnnotationPainter.paint(AnnotationPainter.java:1639)
    at org.eclipse.ui.texteditor.SourceViewerDecorationSupport.updateAnnotationPainter(SourceViewerDecorationSupport.java:877)
    at org.eclipse.ui.texteditor.SourceViewerDecorationSupport.updateTextDecorations(SourceViewerDecorationSupport.java:306)
    at org.eclipse.ui.texteditor.SourceViewerDecorationSupport.install(SourceViewerDecorationSupport.java:269)
    at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.createPartControl(AbstractDecoratedTextEditor.java:447)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:158)
        ....