Java Code Examples for org.eclipse.jface.text.BadLocationException#getLocalizedMessage()

The following examples show how to use org.eclipse.jface.text.BadLocationException#getLocalizedMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompositeParserScanner.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Symbol nextToken() throws IOException, Exception
{
	IToken token = fTokenScanner.nextToken();
	while (isIgnored(token))
	{
		token = fTokenScanner.nextToken();
	}

	int offset = fTokenScanner.getTokenOffset();
	int length = fTokenScanner.getTokenLength();
	if (token.isEOF())
	{
		return createSymbol(offset, offset, "", token); //$NON-NLS-1$
	}

	try
	{
		String text = fDocument.get(offset, length);
		return createSymbol(offset, offset + length - 1, text, token);
	}
	catch (BadLocationException e)
	{
		throw new Scanner.Exception(e.getLocalizedMessage());
	}
}
 
Example 2
Source File: DTDScanner.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * createSymbol
 * 
 * @param data
 * @return
 * @throws Exception
 */
protected Symbol createSymbol(Object data) throws Exception
{
	DTDParserScanner scanner;
	IDocument document;

	if (this._nestedScanners.size() > 0)
	{
		scanner = this._nestedScanners.peek();
		document = scanner.getDocument();
	}
	else
	{
		scanner = this._sourceScanner;
		document = this._document;
	}

	int offset = scanner.getTokenOffset();
	int length = scanner.getTokenLength();
	DTDTokenType type = (data == null) ? DTDTokenType.EOF : (DTDTokenType) data;

	try
	{
		int totalLength = document.getLength();

		if (offset > totalLength)
		{
			offset = totalLength;
		}
		if (length == -1)
		{
			length = 0;
		}

		return new Symbol(type.getIndex(), offset, offset + length - 1, document.get(offset, length));
	}
	catch (BadLocationException e)
	{
		throw new Scanner.Exception(e.getLocalizedMessage());
	}
}