下面列出了org.eclipse.jface.text.BadLocationException#getMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public ICompletionProposal[] computeCompletionProposals( ITextViewer textViewer, int documentOffset){
IDocument document = textViewer.getDocument();
int currOffset = documentOffset - 1;
try {
String currWord = "";
char currChar;
while (currOffset > 0 && !Character.isWhitespace(currChar = document.getChar(currOffset))) {
currWord = currChar + currWord;
currOffset--;
}
List suggestions = wordTracker.suggest(currWord);
ICompletionProposal[] proposals = null;
if (suggestions.size() > 0) {
proposals = buildProposals(suggestions, currWord, documentOffset - currWord.length());
lastError = null;
}
return proposals;
} catch (BadLocationException e) {
e.printStackTrace();
lastError = e.getMessage();
return null;
}
}
@Override
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
List<IMarker> markers;
try {
markers = getMarkersFor(invocationContext.getSourceViewer(), invocationContext.getOffset());
} catch (BadLocationException e) {
errorMessage = e.getMessage();
return new ICompletionProposal[0];
}
List<MarkerResolutionProposal> result = markers.stream() //
.flatMap(e -> generators.stream()
.flatMap(generator -> Stream.of(generator.getResolutions(e))
.map(m -> new MarkerResolutionProposal(e, m, invocationContext.getSourceViewer()))))
.collect(Collectors.toList());
return result.toArray(new ICompletionProposal[result.size()]);
}
@Override
public void append(String text) {
try {
fDocument.replace(fDocument.getLength(), 0, 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());
}
}
@Override
public String getText(int offset, int length) throws IndexOutOfBoundsException {
try {
return fDocument.get(offset, length);
} catch (BadLocationException x) {
throw new IndexOutOfBoundsException(x.getMessage());
}
}
@Override
public void replace(int position, int length, String text) {
try {
fDocument.replace(position, length, text);
} catch (BadLocationException e) {
throw new IndexOutOfBoundsException(e.getMessage());
}
}
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 int read() throws IOException {
try {
return fForward ? readForwards() : readBackwards();
} catch (BadLocationException x) {
throw new IOException(x.getMessage());
}
}
private boolean isSelectionInAdapter(ICoreTextSelection selection, IASTNodeAdapter<? extends SimpleNode> adapter) {
int startOffSet = selection.getOffset();
int endOffSet = selection.getOffset() + selection.getLength();
try {
int lastLine = adapter.getNodeLastLine() - 1;
int adapterStartOffset = doc.getLineOffset(adapter.getNodeFirstLine(false) - 1) + adapter.getNodeIndent();
int adapterEndOffset = doc.getLineOffset(lastLine) + doc.getLineLength(lastLine);
return (adapterStartOffset <= startOffSet && adapterEndOffset >= endOffSet);
} catch (BadLocationException e) {
throw new RuntimeException("Internal error, bad location exception" + e.getMessage());
}
}
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 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);
}