private void setFunction(Listing listing, Address addr, CodeUnitInfo info) {
		Function function = listing.getFunctionAt(addr);
		if (function == null) {
			return;
		}

		String fnName = info.getFunctionName();
		if (fnName != null) {
			try {
				function.setName(fnName, info.getPrimarySymbolSource());
			}
			catch (DuplicateNameException e) {
				messages.append("Could not set function name--duplicate name: " + fnName)
						.append('\n');
			}
			catch (InvalidInputException e) {
				// shouldn't happen
			}
		}

//        String[] functionComments = info.getFunctionComments();
//        if (functionComments != null) {
//            StringBuffer sb = new StringBuffer();
//            for (int i=0; i<functionComments.length; i++) {
//                sb.append(functionComments[i]);
//                if (i <functionComments.length-1) {
//                    sb.append("\n");
//                }
//            }
//            String comment = sb.toString();
//        	String oldComment = function.getComment();
//        	if (oldComment != null && oldComment.length() != 0) {
//        		comment = oldComment + "\n" + comment;
//        	}
//            function.setComment(comment);
//        }

		String[] stackVarNames = info.getStackVariableNames();
		if (stackVarNames.length != 0) {
			String[] stackVarComments = info.getStackVariableComments();
			SourceType[] stackVarSources = info.getStackVariableSources();
			int[] stackOffsets = info.getStackOffsets();
			int[] stackVarFirstUseOffsets = info.getStackVarFirstUseOffsets();

			Variable[] stackVars = function.getVariables(VariableFilter.STACK_VARIABLE_FILTER);

			for (int i = 0; i < stackOffsets.length; i++) {
				Variable var = findStackVar(stackVars, stackOffsets[i], stackVarFirstUseOffsets[i]);
				if (var != null) {
					try {
						var.setName(stackVarNames[i], stackVarSources[i]);
					}
					catch (DuplicateNameException e) {
						messages.append(
							"Could not set stack variable name--duplicate name: " + fnName)
								.append('\n');
					}
					catch (InvalidInputException e) {
						// shouldn't happen
					}
					if (stackVarComments[i] != null) {
						var.setComment(stackVarComments[i]);
					}
				}
			}
		}

		String[] varNames = info.getVariableNames();
		if (varNames.length != 0) {
			String[] varComments = info.getVariableComments();
			SourceType[] varSources = info.getVariableSources();
			Address[] varAddrs = info.getVarAddresses();
			int[] regVarFirstUseOffsets = info.getVarFirstUseOffsets();

			Variable[] vars = function.getAllVariables();

			for (int i = 0; i < varAddrs.length; i++) {
				Variable var = findVar(vars, varAddrs[i], regVarFirstUseOffsets[i]);
				if (var != null) {
					try {
						var.setName(varNames[i], varSources[i]);
					}
					catch (DuplicateNameException e) {
						messages.append("Could not set variable name--duplicate name: " + fnName)
								.append('\n');
					}
					catch (InvalidInputException e) {
						// shouldn't happen
					}
					if (varComments[i] != null) {
						var.setComment(varComments[i]);
					}
				}
			}
		}
	}
Get the original function info and save it off in the undoMap;
set the function info using the new info object.
@param listing listing
@param addr address of where to look for a function
@param info new info to use
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/comments/CodeUnitInfoPasteCmd.java