@Override
	public void dispose() {
		favoritesUpdateManager.dispose();

		if (dtmService != null) {
			dtmService.removeDataTypeManagerChangeListener(adapter);
		}
		super.dispose();

		if (variableCommentDialog != null) {
			variableCommentDialog.close();
			variableCommentDialog = null;
		}
	}
The FunctionPlugin allows creation of a function from the current selection.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/FunctionPlugin.java