Bug 15589

Summary: code assist adds extra semicolons in import type declarations
Product: [Eclipse Project] JDT Reporter: Luc Bourlier <eclipse>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: lrozenblyum, oxvalley, stephan.herrmann
Version: 2.0Keywords: noteworthy
Target Milestone: 4.15 M3   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/157519
https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=470c18c006bd18cd7dc63747acf5b23da275d723
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=7819cf0adee7f552aa09935578c327ed58fb38cd
Whiteboard:

Description Luc Bourlier CLA 2002-05-08 19:03:43 EDT
1. open a compilation unit.
2. put the cursor at the end of a import type line, just before the semicolon.
3. hit [CTRL SPACE], select the right type if necessary, the code is completed
and a simecolon is added, even if there is already one.
Comment 1 Erich Gamma CLA 2002-05-11 06:29:57 EDT
we insert the completion proposal we get from code assist.
Code assist should check whether there is already a semicolon before adding 
one. 

Moving to JDT CORE
Comment 2 Philipe Mulet CLA 2002-05-13 06:14:29 EDT
Nice to have
Comment 3 Philipe Mulet CLA 2002-06-11 08:25:47 EDT
Defer
Comment 4 Philipe Mulet CLA 2002-06-11 08:38:21 EDT
Defer
Comment 5 Philipe Mulet CLA 2002-06-11 08:39:33 EDT
Defer
Comment 6 Eclipse Webmaster CLA 2009-08-30 02:43:20 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.
Comment 7 Eclipse Genie CLA 2020-02-11 15:04:29 EST
New Gerrit change created: https://git.eclipse.org/r/157519
Comment 8 Stephan Herrmann CLA 2020-02-11 15:08:35 EST
(In reply to Eclipse Genie from comment #7)
> New Gerrit change created: https://git.eclipse.org/r/157519

Wow, it's risen from the dead :)

Not inserting the duplicate ';' is easy. Unfortunately JDT/UI meanwhile abuses presence of a terminating ';' to detect if a proposal is an import proposal, when deciding whether or not to insert type arguments.
I'm preparing for a better solution in JDT/UI by setting a new token location, as CompletionContext.TL_IN_IMPORT;

Change for JDT/UI leveraging TL_IN_IMPORT is coming in a minute. Unfortunately, both have to be released at the same time to avoid test failures.
Comment 9 Stephan Herrmann CLA 2020-02-11 15:09:37 EST
*** Bug 392897 has been marked as a duplicate of this bug. ***
Comment 11 Stephan Herrmann CLA 2020-02-11 17:13:24 EST
I directly pushed corresponding changes in JDT/UI via https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=7819cf0adee7f552aa09935578c327ed58fb38cd

Locally JDT/UI tests ran fine (except for some unrelated intermittent hick-ups).

Here we switch strategy in FillArgumentNamesCompletionProposalCollector from looking for ';' towards using the new constant CompletionContext.TL_IN_IMPORT.

Additionally, I added some tests to CodeCompletionTest to ensure the expected replacement behavior.

Released for 4.15 M3