[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jdt-ui-dev] Location in editor problems when source is folded
|
Hi Per,
Technical questions and discussions about using eclipse and eclipse-based
tools, and developing plug-in tools should be posted to the newsgroups.
Mailing lists at eclipse.org are intended for use by developers actually
working on or otherwise contributing to day-to-day development. The
development mailing lists are the way design and implementation issues are
discussed and decisions voted on by the committers.
Having said that, you need to convert forth and back between document model offsets and display offsets. See ITextViewerExtension5 and search for its usage in the eclipse code base.
-tom
Per Bovbjerg wrote:
Hope this isn't to tediuos a question, here goes:
I have made a plugin that displays some information on top of a method
int he editor when I get an event.
The following code works fine when nothing is folding in the editor,
but if I fold a long list of import statements the location returned
by this code is off by quite a bit, and in some cases I get an "Index
out of bounds" from StyledText.getLocationAtOffset(int offset).
Snippet:
if (mElement instanceof IMethod) {
IMethod method = (IMethod) mElement;
Point methodP = new Point(0, 0);
try {
int offset = method.getSourceRange().getOffset();
int methodOffset = method.getNameRange().getOffset();
Point p = mSt.getLocationAtOffset(offset);
methodP = mSt.getLocationAtOffset(methodOffset);
methodP.x = p.x;
methodP.y -= getTag().getBounds().height;
getTag().setLocation(methodP);
} catch (JavaModelException e) {
log.error(ACView.getPrefix() + "Error setting
position", e);
}
}
Info:
mElement is of type IJavaElement
and I have checked for:
mElement.getElementType() == IJavaElement.METHOD
mSt is off type StyledText.
Im a bit unsure of how Im supposed to handle folding in the editor, or
am I doing something totally wrong?
Any help is much appreciated on how I always retrieve the correct
possition of the element.
/Per
------------------------------------------------------------------------
_______________________________________________
jdt-ui-dev mailing list
jdt-ui-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jdt-ui-dev