/** * Logs the exception. Will throw a {@link RuntimeException} if {@link #debug} is set to <code>true</code>. * @since 2.0 */ protected void handleBadLocationException(BadLocationException e) { log.error(e.getMessage(), e); if (debug) throw new RuntimeException(e); }
private static CoreException wrapBadLocationException(BadLocationException e) { String message= e.getMessage(); if (message == null) message= "BadLocationException"; //$NON-NLS-1$ return new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IRefactoringCoreStatusCodes.BAD_LOCATION, message, e)); }
private static CoreException wrapBadLocationException(BadLocationException e) { String message= e.getMessage(); if (message == null) message= "BadLocationException"; //$NON-NLS-1$ return new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IRefactoringCoreStatusCodes.BAD_LOCATION, message, e)); }
@Override public void replace(int position, int length, String text) { try { fDocument.replace(position, length, text); } catch (BadLocationException e) { throw new IndexOutOfBoundsException(e.getMessage()); } }
@Override public char getChar(int position) { try { return fDocument.getChar(position); } catch (BadLocationException x) { throw new IndexOutOfBoundsException(x.getMessage()); } }
public static CoreException asCoreException(BadLocationException e) { String message= e.getMessage(); if (message == null) message= "BadLocationException"; //$NON-NLS-1$ return new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.BAD_LOCATION, message, e)); }
public static CoreException asCoreException(BadLocationException e) { String message= e.getMessage(); if (message == null) message= "BadLocationException"; //$NON-NLS-1$ return new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.BAD_LOCATION, message, e)); }
public void configureBackwardReader(IDocument document, int offset, boolean skipComments, boolean skipStrings) throws IOException { fDocument= document; fOffset= offset; fSkipComments= skipComments; fSkipStrings= skipStrings; fForward= false; try { fCachedLineNumber= fDocument.getLineOfOffset(fOffset); } catch (BadLocationException x) { throw new IOException(x.getMessage()); } }
public static CoreException asCoreException(BadLocationException e) { String message= e.getMessage(); if (message == null) message= "BadLocationException"; //$NON-NLS-1$ return new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.BAD_LOCATION, message, e)); }
public void configureBackwardReader(IDocument document, int offset, boolean skipComments, boolean skipStrings) throws IOException { fDocument= document; fOffset= offset; fSkipComments= skipComments; fSkipStrings= skipStrings; fForward= false; try { fCachedLineNumber= fDocument.getLineOfOffset(fOffset); } catch (BadLocationException x) { throw new IOException(x.getMessage()); } }
@Override public void append(String text) { try { fDocument.replace(fDocument.getLength(), 0, text); } catch (BadLocationException e) { throw new IndexOutOfBoundsException(e.getMessage()); } }
public int read() throws IOException { try { return fForward ? readForwards() : readBackwards(); } catch (BadLocationException x) { throw new IOException(x.getMessage()); } }
@Override public int read() throws IOException { try { return fForward ? readForwards() : readBackwards(); } catch (BadLocationException x) { throw new IOException(x.getMessage()); } }
@Override public int read() throws IOException { try { return fForward ? readForwards() : readBackwards(); } catch (BadLocationException x) { throw new IOException(x.getMessage()); } }
private void comment(IDocument document, int openCommentOffset, int closeCommentOffset) { try { document.replace(openCommentOffset, 0, OPEN_COMMENT); document.replace(closeCommentOffset, 0, CLOSE_COMMENT); removeOpenCloseComments(document, openCommentOffset + OPEN_COMMENT.length(), closeCommentOffset - openCommentOffset - CLOSE_COMMENT.length()); } catch (BadLocationException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); } }
@Override public void apply(IDocument document) { try { String variable= fVariable.getType().equals("dollar") ? "$$" : "${" + fVariable.getType() + '}'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ document.replace(fOffset, fLength, variable); fSelection= new Point(fOffset + variable.length(), 0); } catch (BadLocationException e) { Shell shell= fViewer.getTextWidget().getShell(); MessageDialog.openError(shell, TemplatesMessages.TemplateVariableProposal_error_title, e.getMessage()); } }
@Override public void apply(IDocument document) { try { String variable= fVariable.getType().equals("dollar") ? "$$" : "${" + fVariable.getType() + '}'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ document.replace(fOffset, fLength, variable); fSelection= new Point(fOffset + variable.length(), 0); } catch (BadLocationException e) { Shell shell= fViewer.getTextWidget().getShell(); MessageDialog.openError(shell, TemplatesMessages.TemplateVariableProposal_error_title, e.getMessage()); } }
private static Position createPosition(IDocument document, int offset) { Position start = new Position(); try { int lineOfOffset = document.getLineOfOffset(offset); start.setLine(Integer.valueOf(lineOfOffset)); start.setCharacter(Integer.valueOf(offset - document.getLineOffset(lineOfOffset))); } catch (BadLocationException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } return start; }
private void openErrorDialog(BadLocationException e) { Shell shell= getTextViewer().getTextWidget().getShell(); String message= e.getMessage(); MessageDialog.openError(shell, JavaTextMessages.FilledArgumentNamesMethodProposal_error_msg, message == null ? e.toString() : message); }
private IRegion getRegion(Range range, IDocument document) { try { int offset = document.getLineOffset(range.getStart().getLine()) + range.getStart().getCharacter(); int endOffset = document.getLineOffset(range.getEnd().getLine()) + range.getEnd().getCharacter(); int length = endOffset - offset; return new Region(offset, length); } catch (BadLocationException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } return null; }