private Varnode[] getVarnodes(VariableOffset varOffset) {

		if (varOffset.isIndirect()) {
			return null;
		}

		boolean dataAccess = varOffset.isDataAccess();

		Variable variable = varOffset.getVariable();
		long offset = varOffset.getOffset();

		long absOffset = offset < 0 ? -offset : offset;
		if (absOffset > Integer.MAX_VALUE) {
			return null;
		}

		VariableStorage variableStorage = variable.getVariableStorage();
		if (variableStorage.size() <= 0) {
			return null; // invalid storage
		}

		DataType dt = variable.getDataType();

		int varnodeOffset = 0;
		int varnodeSize = 0;

		if (dt instanceof TypeDef) {
			dt = ((TypeDef) dt).getBaseDataType();
		}

		int intOff = (int) absOffset;
		while (intOff > 0 || (dataAccess && intOff == 0)) {
			if (dt instanceof TypeDef) {
				dt = ((TypeDef) dt).getBaseDataType();
			}
			if (dt instanceof Structure) {
				DataTypeComponent cdt = ((Structure) dt).getComponentAt(intOff);
				if (cdt == null) {
					break;
				}
				varnodeOffset += cdt.getOffset();
				intOff -= cdt.getOffset();
				dt = cdt.getDataType();
			}
			else {
				// Primitives, Unions and Arrays are treated as single varnode
				break;
			}
		}

		varnodeSize = dt.getLength();
		if (varnodeSize <= 0 || intOff > varnodeSize) {
			return null;
		}

		varnodeSize -= intOff;
		varnodeOffset += intOff;

		List<Varnode> varnodes = new ArrayList<>();
		for (Varnode v : variableStorage.getVarnodes()) {
			if (varnodeOffset >= v.getSize()) {
				varnodeOffset -= v.getSize();
				continue;
			}
			int size = Math.min(v.getSize(), varnodeSize);
			varnodeSize -= size;
			varnodes.add(new Varnode(v.getAddress().add(varnodeOffset), size));
			if (varnodeSize == 0) {
				break;
			}
			varnodeOffset = 0;
		}

		return varnodes.toArray(new Varnode[varnodes.size()]);
	}
Attempt to identify variable varnodes which correspond to this variable
reference.

@return array of varnodes or null if failed to identify
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingMiddleMouseHighlightProvider.java