private Point ensureLocationOnScreen(Point location) {

		Rectangle screenBounds = WindowUtilities.getScreenBounds(outputTextField);
		int screenWidth = screenBounds.width;
		int screenHeight = screenBounds.height;
		int myWidth = getWidth();
		int myHeight = getHeight();
		int textHeight = outputTextField.getHeight();

		// double-check the width of the completion
		if (getWidth() > screenWidth) {
			setSize(screenWidth, getHeight());
		}

		// Preferred location: lower and slightly to the right of the caret
		int offset = textHeight;
		Point newPoint = new Point(location.x + offset, location.y + offset);

		if (isOnScreen(screenBounds, newPoint)) {
			return newPoint; // nothing to do
		}

		//
		// our bounds using the given location do not fit on the screen
		//

		// does the right side of the window go off the right edge of the screen?
		Point testPoint = null;
		if (newPoint.x + myWidth > screenWidth) {

			// check for going off the bottom of the screen as well
			if (newPoint.y + myHeight > screenHeight) {
				// off the right and bottom of the screen; move above prompt
				testPoint = new Point(screenWidth - myWidth, newPoint.y - myHeight - offset);
			}
			else {
				// the bottom is fine, move to the left
				testPoint = new Point(screenWidth - myWidth, newPoint.y);
			}
		}
		// does the bottom of the window go off the bottom of the screen?
		else if (newPoint.y + myHeight > screenHeight) {
			testPoint = new Point(newPoint.x, screenHeight - myHeight - offset);
		}

		newPoint = validateLocation(screenBounds, testPoint, newPoint);
		return newPoint;
	}
Updates the completion list with the given completion mapping.

The format, as mentioned above, is:
"attribute" -> "substitution value"
If the substitution value is null, then that attribute will not be
selectable for substitution.

After updating the mapping, this Window then updates its size as
appropriate.

The Window also will attempt to move out of the way of the cursor/caret
in the textField.  However, if the caret's position had recently been
changed and the caret had not been repainted yet, then the caret's
location can be null.  In this case, the Window will not move.
You can avoid this condition by calling this method in a
SwingUtilities.invokeLater(Runnable).

@param list List of code completions
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/CodeCompletionWindow.java