@Nonnull
	private Range extractRelevantRange(@Nonnull Model model, @Nonnull String source) {
		if (model instanceof ClassModel classModel) {
			// The class model is often the FULL range of the file, and we only want the named section.
			String name = classModel.getName();
			int begin = classModel.getRange().begin();
			int end = source.indexOf(name, begin) + name.length();
			if (end < begin)
				return Range.UNKNOWN;
			return new Range(begin, end);
		} else if (model instanceof VariableModel variableModel) {
			// The variable range should include only the variable name.
			// The name doesn't have an associated model, but is after the declared type.
			String name = variableModel.getName();
			int begin = variableModel.getType().getRange().end();

			// Enum constants don't have an AST model for their type, so the range is "unknown".
			// If we're confident this is an enum constant, then we'll make the beginning range the start of the field name instead.
			if (begin == -1) {
				ClassModel declaringClass = variableModel.getParentOfType(ClassModel.class);
				if (declaringClass != null) {
					if (declaringClass.resolve(resolver) instanceof ClassResolution declaringResolution
							&& AccessFlag.isEnum(declaringResolution.getClassEntry().getAccess())) {
						Resolution type = variableModel.getType().resolve(resolver);
						if (type.matches(declaringResolution)) {
							begin = variableModel.getRange().begin();
						}
					}
				}
			}

			int end = source.indexOf(name, begin) + name.length();
			if (end < begin)
				return Range.UNKNOWN;
			return new Range(begin, end);
		} else if (model instanceof MethodModel methodModel) {
			// The method range should include only the method name.
			// The name doesn't have an associated model, but is between the return type and first '(' for parameters.
			String name = methodModel.getName();
			int begin = name.equals("<init>") ? methodModel.getRange().begin() : methodModel.getReturnType().getRange().end();
			int end = source.indexOf('(', begin);
			if (end < begin)
				return Range.UNKNOWN;
			return new Range(begin, end);
		} else if (model instanceof NameHoldingModel nameHoldingModel) {
			// If the holder has an associated model, yield that model's range.
			if (nameHoldingModel.getNameModel() != null && !nameHoldingModel.getNameModel().getRange().isUnknown())
				return nameHoldingModel.getNameModel().getRange();

			// Otherwise limit the size of the range based on the first appearance of the named model's name
			// starting from its reported range beginning point. Also limit by the source length.
			String name = nameHoldingModel.getName();
			Range range = nameHoldingModel.getRange();
			int nameBegin = source.indexOf(name, range.begin());
			int nameEnd = Math.min(nameBegin + name.length(), source.length());
			return new Range(nameBegin, nameEnd);
		}

		return model.getRange();
	}
@return Modified source code based on the provided mappings.
recaf-core/src/main/java/software/coley/recaf/services/source/AstMapper.java