Bug 100808 - [assist] Wrong replace range for package proposals if there is no line termination
Summary: [assist] Wrong replace range for package proposals if there is no line termin...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 100795 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-20 09:30 EDT by Tom Hofmann CLA
Modified: 2005-09-26 09:27 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (1.21 KB, text/plain)
2005-06-23 06:20 EDT, David Audel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2005-06-20 09:30:25 EDT
3.1-RC2 test pass

See bug 100795 for details.
- have an empty .java file with the contents below (no line termination) 
- invoke code assist at the end of the first line

"package org."

The reported completion proposals specify a replace range of [8, 13), while the
document length is only 12. 

Note that if there is a trailing space or a newline, the correct replace range
is reported: [8, 12)

Since jdt-ui does not check the replace ranges, we run into the IAE of
StyledText eventually (see bug 100795 for the trace).
Comment 1 Dani Megert CLA 2005-06-21 11:18:22 EDT
If this is an easy fix it would be nice to have it in 3.1. We proposed a more
general fix in bug 100795 but this was turned down (see bug 100795 comment 6)
and instead proposed to add a workaround for just this bug. I am against this
and vote for adding the workaround/fix directly at the source.
Comment 2 Dani Megert CLA 2005-06-21 11:22:39 EDT
*** Bug 100795 has been marked as a duplicate of this bug. ***
Comment 3 Philipe Mulet CLA 2005-06-23 05:56:05 EDT
Scenario does not qualify for a stop ship defects. However symptoms are bad
enough to make it a candidate for 3.1.1.
Comment 4 Philipe Mulet CLA 2005-06-23 06:00:16 EDT
Not all completions at end of file are broken, e.g. the following works:

public class ZZ {
	{
		Object o = o.<CODEASSIST HERE>
Comment 5 Philipe Mulet CLA 2005-06-23 06:01:11 EDT
It needs override mode to misbehave, which isn't a default mode.
Comment 6 David Audel CLA 2005-06-23 06:20:58 EDT
Created attachment 23830 [details]
Proposed patch

The support to extend the end of the empty completion token must be removed
when the CompletionScanner in outside the source range (if the currentPosition
is outside source range, there is no token after this point)
Comment 7 David Audel CLA 2005-07-04 10:34:47 EDT
Fix released and test added.
  CompletionTests#testCompletionEmptyToken2()
  
Comment 8 Olivier Thomann CLA 2005-08-09 09:51:30 EDT
Verified in 3.2M1 (I20050808-2000)
Comment 9 Maxime Daniel CLA 2005-09-26 07:37:53 EDT
Verified for 3.1.1 using build M20050923-1430.