private boolean checkVariableReference(Navigatable navigatable, CodeUnit codeUnit,
			OperandFieldLocation loc, GoToService goToService) {

		if (!(codeUnit instanceof Instruction)) {
			return false;
		}

		if (goToExplicitOperandVariable(navigatable, loc, goToService)) {
			return true;
		}

		Program p = codeUnit.getProgram();
		Address cuAddr = codeUnit.getMinAddress();
		Function function = p.getFunctionManager().getFunctionContaining(cuAddr);
		if (function == null) {
			return false;
		}

		if (goToRegisterVariable(navigatable, codeUnit, loc, goToService)) {
			return true;
		}

		Reference reference = codeUnit.getPrimaryReference(loc.getOperandIndex());
		if (reference == null) {
			return false;
		}

		Variable variable = p.getFunctionManager().getReferencedVariable(cuAddr,
			reference.getToAddress(), 0, reference.getReferenceType().isRead());
		if (variable != null) {
			ProgramLocation pl =
				new VariableNameFieldLocation(navigatable.getProgram(), variable, 0);
			goToService.goTo(navigatable, pl, navigatable.getProgram());
			return true;
		}

		if (reference.isStackReference()) {
			ProgramLocation pl = new FunctionSignatureFieldLocation(p, function.getEntryPoint(),
				null, 0, function.getPrototypeString(false, false));
			goToService.goTo(navigatable, pl, navigatable.getProgram());
			return true;
		}
		return false;
	}
A handler to process {@link OperandFieldLocation} mouse clicks.
Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldMouseHandler.java