public static Pair<Integer, Integer> getWordBounds(JTextComponent textComponent, WordBoundsConfig wordBoundsConfig)
	{
		try
		{
			//int startPosition = textComponent.getCaretPosition();
			int startPosition = wordBoundsConfig.startingPosition;
			int endPosition = wordBoundsConfig.startingPosition;
                        ExpansionDirection expansionDirection = wordBoundsConfig.expansionDirection;
                        List wordSeparators =  wordBoundsConfig.wordSeparators;
			Document document = textComponent.getDocument();

			while (startPosition > 0 && (expansionDirection == ExpansionDirection.BOTH || expansionDirection == ExpansionDirection.LEFT))
			{
				startPosition--;
				char curChar = document.getText(startPosition, 1).charAt(0);

				if (wordSeparators.contains(curChar))
				{
					startPosition++;
					break;
				}
			}

			while (endPosition < document.getLength() && (expansionDirection == ExpansionDirection.BOTH || expansionDirection == ExpansionDirection.RIGHT))
			{
				char curChar = document.getText(endPosition, 1).charAt(0);
				if (wordSeparators.contains(curChar))
					break;
				endPosition++;
			}
			return new Pair<Integer, Integer>(startPosition, endPosition);
		}
		catch (BadLocationException ex)
		{
			throw new IndexOutOfBoundsException("Error getting word part location not found");
		}
	}