Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 473956 - Textview getNextOffset throws exceptions if a bad offset is provided
Summary: Textview getNextOffset throws exceptions if a bad offset is provided
Status: CLOSED WONTFIX
Alias: None
Product: Orion
Classification: ECD
Component: Editor (show other bugs)
Version: 9.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 10.0   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-30 13:38 EDT by Curtis Windatt CLA
Modified: 2017-01-10 15:39 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Curtis Windatt CLA 2015-07-30 13:38:49 EDT
Working on Bug 456715.  The offsets I am getting don't match up because of the collapsed comments.  I know I need to adjust the offsets based on the projection model, but we should also not be throwing exceptions for bad arguments.

I have a JS file with two functions, each with collapsed JSDoc comments.  When hovering I get a 'can't find property length of null exception.  There are a couple of issues that we could fix to be more resilient.

1) At line 1499 we call model.getLineAtOffset().  The current implementation will return a lineIndex of -5 which goes against its JSDoc.

2) We use the returned lineIndex of -5 without checking whether it is valid, so _getNextOffset_W3C():1501 will throw an exception because the lineText will be null.

3) getNextOffset(), the public method the tooltip uses, does not specify its behaviour for bad offsets or edge cases (ex: finding the previous word to offset 0).  If the unit option is 'line' and the next offset it out of range, it will return -1.  In other cases I suspect it would return the current offset or throw an exception.
Comment 1 Curtis Windatt CLA 2015-07-30 13:40:46 EDT
Silenio, can you take a look at this and think about what the best approach would be?  I can provide a patch with my simple checks that prevent it from blowing up, but I think you will have a better fix in mind.
Comment 2 Michael Rennie CLA 2017-01-10 15:39:01 EST
Closing as part of a mass clean up of inactive bugs. Please reopen if this problem still occurs or is relevant to you. For more details see:

https://dev.eclipse.org/mhonarc/lists/orion-dev/msg04002.html