Skip to content

Commit

Permalink
Avoid unhandled NPEs in FoldingReconcilerStrategy
Browse files Browse the repository at this point in the history
The exception below is printed to standard error every time a generic
editor diff contribution is used in compare editor for target files. I
assume it never worked as designed with TargetPlatformFoldingReconciler,
so just add a NPE guard to prevent unhandled exceptions / printouts.

```
Exception in thread
"org.eclipse.pde.internal.genericeditor.target.extension.reconciler.folding.TargetPlatformFoldingReconciler"
java.lang.NullPointerException: Cannot invoke
"org.eclipse.jface.text.source.projection.ProjectionViewer.getProjectionAnnotationModel()"
because "this.projectionViewer" is null
	at org.eclipse.pde.internal.genericeditor.target.extension.reconciler.folding.FoldingReconcilerStrategy.initialReconcile(FoldingReconcilerStrategy.java:63)
	at org.eclipse.jface.text.reconciler.Reconciler.initialProcess(Reconciler.java:223)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:177)
```

See eclipse-platform/eclipse.platform.ui#1798
  • Loading branch information
iloveeclipse committed Apr 9, 2024
1 parent 11de65c commit a2762f9
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public void reconcile(IRegion partition) {

@Override
public void initialReconcile() {
if (projectionViewer == null || document == null) {
return;
}
ProjectionAnnotationModel projectionAnnotationModel = projectionViewer.getProjectionAnnotationModel();
if (document.get().equals(oldDocument) || projectionAnnotationModel == null)
return;
Expand Down

0 comments on commit a2762f9

Please sign in to comment.