docs: @CheckForNull
      public static WorkItem getWorkItem(Object element) {
          if (element instanceof IResource) {
              IResource resource = (IResource) element;
              if (resource.getType() == IResource.FILE && !Util.isJavaArtifact(resource) || !resource.isAccessible()) {
                  // Ignore non java files or deleted/closed files/projects
                  return null;
              }
              return new WorkItem((IResource) element);
          }
          if (element instanceof IJavaElement) {
              return new WorkItem((IJavaElement) element);
          }
  
          if (element instanceof IAdaptable) {
              Object adapter = ((IAdaptable) element).getAdapter(IResource.class);
              if (adapter instanceof IResource) {
                  IResource resource = (IResource) adapter;
                  if (resource.getType() == IResource.FILE && !Util.isJavaArtifact(resource) || !resource.isAccessible()) {
                      // Ignore non java files or deleted/closed files/projects
                      return null;
                  }
                  return new WorkItem(resource);
              }
              adapter = ((IAdaptable) element).getAdapter(IPackageFragment.class);
              if (adapter instanceof IPackageFragment) {
                  return new WorkItem((IPackageFragment) adapter);
              }
              adapter = ((IAdaptable) element).getAdapter(IType.class);
              if (adapter instanceof IType) {
                  return new WorkItem((IType) adapter);
              }
          }
          return null;
      }