@Nullable
	public AstResolveResult adapt(@Nonnull Resolution resolution, @Nonnull Model target) {
		if (resolution.isUnknown())
			return null;
		else if (resolution instanceof ClassResolution classResolution) {
			String name = classResolution.getClassEntry().getName();
			ClassPathNode path = workspace.findClass(name);
			if (path == null)
				return null;

			// If the target *is the class* then it is a declaration.
			if (target instanceof ClassModel && target.resolve(this).matches(resolution))
				return AstResolveResult.declared(path);

			// If the target is within a method body, it is always a reference.
			// Same for:
			//  - Contents of annotation expressions like "@MyAnno(foo = bar)"
			//  - Contents of assignments in places like fields
			//  - Contents of type names
			//    - The class name is just a name model, not a type model so
			if (target.getParentOfType(MethodBodyModel.class) != null)
				return AstResolveResult.reference(path);
			if (target.getParentOfType(AnnotationExpressionModel.class) != null)
				return AstResolveResult.reference(path);
			if (target.getParentOfType(AssignmentExpressionModel.class) != null)
				return AstResolveResult.reference(path);
			if (target.getParentOfType(TypeModel.class) != null)
				return AstResolveResult.reference(path);

			ClassModel parentClassDeclaration = target.getParentOfType(ClassModel.class);
			if (parentClassDeclaration != null && parentClassDeclaration.resolve(this).matches(resolution))
				return AstResolveResult.declared(path);
			return AstResolveResult.reference(path);
		} else if (resolution instanceof FieldResolution fieldResolution) {
			String ownerName = fieldResolution.getOwnerEntry().getName();
			ClassPathNode ownerPath = workspace.findClass(ownerName);
			if (ownerPath == null)
				return null;
			FieldEntry fieldEntry = fieldResolution.getFieldEntry();
			ClassMemberPathNode fieldPath = ownerPath.child(fieldEntry.getName(), fieldEntry.getDescriptor());
			if (fieldPath == null)
				return null;

			// Determine if it's a declaration or reference.
			//  - Check if any declared class's fields have the target model in their range
			for (ClassModel declaredClass : getUnit().getRecursiveChildrenOfType(ClassModel.class))
				for (VariableModel field : declaredClass.getFields())
					if (field.getRange().isWithin(target.getRange().begin()))
						return AstResolveResult.declared(fieldPath);

			return AstResolveResult.reference(fieldPath);
		} else if (resolution instanceof MethodResolution methodResolution) {
			String ownerName = methodResolution.getOwnerEntry().getName();
			ClassPathNode ownerPath = workspace.findClass(ownerName);
			if (ownerPath == null)
				return null;
			MethodEntry methodEntry = methodResolution.getMethodEntry();
			ClassMemberPathNode methodPath = ownerPath.child(methodEntry.getName(), methodEntry.getDescriptor());
			if (methodPath == null)
				return null;

			// Determine if it's a declaration or reference.
			//  - Check if any declared class's methods have the target model in their range (the name and such, not the body)
			for (ClassModel declaredClass : getUnit().getRecursiveChildrenOfType(ClassModel.class))
				if (declaredClass.resolve(this) instanceof ClassResolution declaredClassResolution && declaredClassResolution.matches(methodResolution.getOwnerResolution()))
					if (methodResolution.matches(declaredClassResolution.getDeclaredMemberResolution(methodEntry)))
						return AstResolveResult.declared(methodPath);
			return AstResolveResult.reference(methodPath);
		} else if (resolution instanceof MultiMemberResolution multiMemberResolution) {
			// Used in static star import contexts such as 'Math.*' or single method static imports such as 'Math.min'.
			// For stars, yield the class. For single members, yield the member.
			List<ClassMemberPair> memberEntries = multiMemberResolution.getMemberEntries();
			ClassMemberPair firstMember = memberEntries.getFirst();
			String firstClassName = firstMember.ownerEntry().getName();
			if (memberEntries.size() == 1) {
				// Single member
				return adapt(Resolutions.ofMember(firstMember), target);
			} else if (memberEntries.size() > 1) {
				// Multiple members
				ClassPathNode path = workspace.findClass(firstClassName);
				if (path != null)
					return AstResolveResult.reference(path);
			}
		} else if (resolution instanceof MultiClassResolution multiClassResolution) {
			// Used in start import contexts such as 'java.util.*' so yield the package they're all residing within.
			String firstClassName = multiClassResolution.getClassEntries().getFirst().getName();
			int slashIndex = firstClassName.lastIndexOf('/');
			if (slashIndex > 0) {
				String packageName = firstClassName.substring(0, slashIndex);
				DirectoryPathNode path = workspace.findPackage(packageName);
				if (path != null)
					return AstResolveResult.reference(path);
			}
		} else if (resolution instanceof PackageResolution packageResolution) {
			String packageName = packageResolution.getPackageName();
			if (packageName != null) {
				DirectoryPathNode path = workspace.findPackage(packageName);
				if (path != null)
					return AstResolveResult.reference(path);
			}
		}

		return null;
	}
@param resolution
		Resolution to adapt.
@param target
		Target model that was the item being resolved.

@return Our mapped resolution result which points to a path in the workspace for the resolved content.
recaf-core/src/main/java/software/coley/recaf/services/source/ResolverAdapter.java