class RubyLsp::Addon
def get(addon_name, *version_constraints)
the responsibility of the add-ons using this API to handle these errors appropriately.
current version does not satisfy the given version constraint, then IncompatibleApiError will be raised. It is
Important: if the add-on is not found, AddonNotFoundError will be raised. If the add-on is found, but its
other add-ons, this is the way to get access to that API.
Get a reference to another add-on object by name and version. If an add-on exports an API that can be used by
def get(addon_name, *version_constraints) if version_constraints.empty? raise IncompatibleApiError, "Must specify version constraints when accessing other add-ons" end addon = addons.find { |addon| addon.name == addon_name } raise AddonNotFoundError, "Could not find add-on '#{addon_name}'" unless addon version_object = Gem::Version.new(addon.version) unless version_constraints.all? { |constraint| Gem::Requirement.new(constraint).satisfied_by?(version_object) } raise IncompatibleApiError, "Constraints #{version_constraints.inspect} is incompatible with #{addon_name} version #{addon.version}" end addon end