private Indentation applyAutoIndentation(int offset, String str) throws BadLocationException {
		// Prepare indentation container
		Indentation indentation = new Indentation();

		indentation.caretPos = -1; // Meaning that caret position is not changed
		indentation.text = str;

		// Apply auto indentation if it is enabled, and the new line character has been entered
		if (isAutoIndentEnabled() && str.equals("\n")) {

			// Save the current indentation for later, as it might change from here on
			int currentIndentation = getIndentationLengthFromOffset(offset);

			// Read the line content from the offset
			String line = getLineFromOffset(offset);

			// Calculate the end offset of the line
			int lineEndOffset = getElementFromOffset(offset).getStartOffset() + line.length();

			// Continue if the line has content and the offset is after the line end offset
			if (line.length() > 0 && offset >= lineEndOffset) {

				// Check/compose and return a body start indentation a '{' is found
				if (composeBodyStartIndentation(offset, line, indentation)) {
					return indentation;
				}
				// Check/compose and return a multiline comment start indentation if a '/*' is found
				if (composeMultilineCommentStartIndentation(offset, line, indentation)) {
					return indentation;
				}
				// Check/compose and return a continued multiline comment if a '*' is found inside a multiline comment
				if (composeMultilineCommentContinuedIndentation(offset, line, indentation)) {
					return indentation;
				}
				// Check/compose and return a multiline comment end indentation if a '*/' is found
				if (composeMultilineCommentEndIndentation(offset, line, indentation)) {
					return indentation;
				}
				// Extend the current indentation text based on the current indentation
				// Note: Will replace tabulator characters with spaces etc. if this must be done.
				indentation.text += getStartIndentation(currentIndentation); // FIXME
			}
		}
		return indentation;
	}