From b95c6e569079d9726ec249ebccc38ce9ac81cdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Thu, 25 Jan 2024 15:41:31 +0100 Subject: [PATCH] fix Redundant null check "The variable item cannot be null at this location" --- .../internal/ui/editor/category/CategorySection.java | 12 +++++------- .../pde/internal/ui/editor/site/CategorySection.java | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/CategorySection.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/CategorySection.java index 216bb82879..1d7e568bf4 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/CategorySection.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/CategorySection.java @@ -259,18 +259,16 @@ public void dragOver(DropTargetEvent event) { */ @Override protected int determineLocation(DropTargetEvent event) { - if (!(event.item instanceof Item item)) { - return LOCATION_NONE; - } - Point coordinates = new Point(event.x, event.y); - coordinates = getViewer().getControl().toControl(coordinates); - if (item != null) { + if (event.item instanceof Item item) { + Point coordinates = new Point(event.x, event.y); + coordinates = getViewer().getControl().toControl(coordinates); Rectangle bounds = getBounds(item); if (bounds == null) { return LOCATION_NONE; } + return LOCATION_ON; } - return LOCATION_ON; + return LOCATION_NONE; } @Override diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/CategorySection.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/CategorySection.java index 9c2574674e..129a811fec 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/CategorySection.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/CategorySection.java @@ -218,18 +218,16 @@ public void dragOver(DropTargetEvent event) { */ @Override protected int determineLocation(DropTargetEvent event) { - if (!(event.item instanceof Item item)) { - return LOCATION_NONE; - } - Point coordinates = new Point(event.x, event.y); - coordinates = getViewer().getControl().toControl(coordinates); - if (item != null) { + if (event.item instanceof Item item) { + Point coordinates = new Point(event.x, event.y); + coordinates = getViewer().getControl().toControl(coordinates); Rectangle bounds = getBounds(item); if (bounds == null) { return LOCATION_NONE; } + return LOCATION_ON; } - return LOCATION_ON; + return LOCATION_NONE; } @Override