Skip to content

Commit

Permalink
Fix NullPointerException in MavenSelectionHintsTask
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Nov 21, 2022
1 parent 67393d2 commit 51764b8
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 51764b8

Please sign in to comment.