Skip to content

Commit

Permalink
Merge pull request #4994 from jglick/MavenSelectionHintsTask-NPE
Browse files Browse the repository at this point in the history
Fix `NullPointerException` in `MavenSelectionHintsTask`
  • Loading branch information
sdedic authored Nov 23, 2022
2 parents cf0ccc0 + 51764b8 commit 4e3c7f4
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javax.swing.text.Document;
import javax.swing.text.Position;
import javax.swing.text.StyledDocument;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.project.FileOwnerQuery;
import org.netbeans.api.project.Project;
import org.netbeans.modules.maven.hints.pom.spi.SelectionPOMFixProvider;
Expand Down Expand Up @@ -68,17 +69,18 @@ public void run(MavenResult result, SchedulerEvent event) {
List<ErrorDescription> errors = computeErrors(result, ss, se, cursorEvent.getCaretOffset());
HintsController.setErrors(result.getPomFile(), PomModelUtils.LAYER_POM_SELECTION, errors);
}


@NonNull
static List<ErrorDescription> computeErrors(MavenResult result, int ss, int se, int co) {
final List<ErrorDescription> errors = new ArrayList<>();
FileObject fo = result.getPomFile();
Project project = FileOwnerQuery.getOwner(fo);
Document document = result.getSnapshot().getSource().getDocument(false);
if (fo == null || project == null || project.getProjectDirectory() != fo.getParent()) {
// ?? pom file ought to form a project!
return null;
return errors;
}
final POMModel model = result.getProjectModel();
final List<ErrorDescription> errors = new ArrayList<ErrorDescription>();
// clear selection hints in case of an error; validation errors are handled by
// MavenFileHintsTask.
StyledDocument styled = null;
Expand Down

0 comments on commit 4e3c7f4

Please sign in to comment.