use of org.eclipse.jface.text.BadLocationException in project che by eclipse.
the class JavaDocContext method getStart.
/*
* @see DocumentTemplateContext#getStart()
*/
@Override
public int getStart() {
if (fIsManaged && getCompletionLength() > 0)
return super.getStart();
try {
IDocument document = getDocument();
if (getCompletionLength() == 0) {
int start = getCompletionOffset();
if ((start != 0) && (document.getChar(start - 1) == HTML_TAG_END))
start--;
while ((start != 0) && Character.isUnicodeIdentifierPart(document.getChar(start - 1))) start--;
if ((start != 0) && Character.isUnicodeIdentifierStart(document.getChar(start - 1)))
start--;
// include html and javadoc tags
if ((start != 0) && ((document.getChar(start - 1) == HTML_TAG_BEGIN) || (document.getChar(start - 1) == JAVADOC_TAG_BEGIN))) {
start--;
}
return start;
}
int start = getCompletionOffset();
int end = getCompletionOffset() + getCompletionLength();
while (start != 0 && Character.isUnicodeIdentifierPart(document.getChar(start - 1))) start--;
while (start != end && Character.isWhitespace(document.getChar(start))) start++;
if (start == end)
start = getCompletionOffset();
return start;
} catch (BadLocationException e) {
return getCompletionOffset();
}
}
use of org.eclipse.jface.text.BadLocationException in project che by eclipse.
the class JavaDocContext method getKey.
/*
* @see org.eclipse.jdt.internal.corext.template.DocumentTemplateContext#getKey()
*/
@Override
public String getKey() {
if (getCompletionLength() == 0)
return super.getKey();
try {
IDocument document = getDocument();
int start = getStart();
int end = getCompletionOffset();
return start <= end ? document.get(start, end - start) : //$NON-NLS-1$
"";
} catch (BadLocationException e) {
return super.getKey();
}
}
use of org.eclipse.jface.text.BadLocationException in project che by eclipse.
the class JavaDocContext method getEnd.
/*
* @see org.eclipse.jdt.internal.corext.template.DocumentTemplateContext#getEnd()
*/
@Override
public int getEnd() {
if (fIsManaged || getCompletionLength() == 0)
return super.getEnd();
try {
IDocument document = getDocument();
int start = getCompletionOffset();
int end = getCompletionOffset() + getCompletionLength();
while (start != end && Character.isWhitespace(document.getChar(end - 1))) end--;
return end;
} catch (BadLocationException e) {
return super.getEnd();
}
}
use of org.eclipse.jface.text.BadLocationException in project che by eclipse.
the class JavaFormatter method format.
/**
* Formats the template buffer.
* @param buffer
* @param context
* @throws BadLocationException
*/
public void format(TemplateBuffer buffer, TemplateContext context) throws BadLocationException {
try {
VariableTracker tracker = new VariableTracker(buffer);
IDocument document = tracker.getDocument();
internalFormat(document, context);
convertLineDelimiters(document);
if (!(context instanceof JavaDocContext) && !isReplacedAreaEmpty(context))
trimStart(document);
tracker.updateBuffer();
} catch (MalformedTreeException e) {
throw new BadLocationException();
}
}
use of org.eclipse.jface.text.BadLocationException in project che by eclipse.
the class UndoDocumentChange method perform.
/**
* {@inheritDoc}
*/
public Change perform(IProgressMonitor pm) throws CoreException {
try {
UndoEdit redo = performEdits();
Change result = new UndoDocumentChange(getName(), fDocument, redo);
return result;
} catch (MalformedTreeException e) {
throw Changes.asCoreException(e);
} catch (BadLocationException e) {
throw Changes.asCoreException(e);
}
}
Aggregations