Bug 436074 - Stronger indication when snippet cannot be applied at current cursor position
Summary: Stronger indication when snippet cannot be applied at current cursor position
Status: ASSIGNED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Recommenders (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Yasett Acurana CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2014-05-28 10:51 EDT by Marcel Bruch CLA
Modified: 2019-07-24 14:35 EDT (History)
3 users (show)

See Also:


Attachments
Warning displayed when the cursor position does not permit to insert snippets. (44.18 KB, image/png)
2016-04-11 12:01 EDT, Yasett Acurana CLA
no flags Details
Demo of pseudopropsal with warning (22.45 KB, image/png)
2016-04-26 11:16 EDT, Yasett Acurana CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel Bruch CLA 2014-05-28 10:51:19 EDT
When triggering snipmatch behind a dot as in the snippet below, the selected template is not applied (tested with junit template).




void zip() throws Exception {
        ZipFile file = new ZipFile(new File(""));
        file.|<snipmatch>
        
    }
Comment 1 Johannes Dorn CLA 2014-05-28 10:54:23 EDT
This behavior is known. 
A snippet/or template cannot be applied at this position by either snipmatch or the template completion.

To inform the user about this, the preview windows starts with a message:
 // XXX Cannot apply snippet at cursor position
 // FIXME Reposition cursor
Comment 2 Marcel Bruch CLA 2014-05-28 11:05:11 EDT
Okay, i read the comment but didn't get it :)
Maybe the comment should be rewritten for dump users like me?
Comment 3 Andreas Sewe CLA 2014-06-10 07:00:35 EDT
(In reply to Marcel Bruch from comment #2)
> Okay, i read the comment but didn't get it :)
> Maybe the comment should be rewritten for dump users like me?

Maybe a stronger indication is needed? What about a light red background instead of the "Javadoc yellow" for the popup whenever the proposal cannot be applied (+ the comment that explains what's going on)?

Anyway, postponing this for 2.2. What's the best UX needs some more discussion.
Comment 4 Andreas Sewe CLA 2016-04-07 03:47:49 EDT
(In reply to Andreas Sewe from comment #3)
> (In reply to Marcel Bruch from comment #2)
> > Okay, i read the comment but didn't get it :)
> > Maybe the comment should be rewritten for dump users like me?
> 
> Maybe a stronger indication is needed? What about a light red background
> instead of the "Javadoc yellow" for the popup whenever the proposal cannot
> be applied (+ the comment that explains what's going on)?
> 
> Anyway, postponing this for 2.2. What's the best UX needs some more
> discussion.

The behavior in comment 0 has changed in the meantime. Right now we don't display snippets that cannot be evaluated at all at a position like

  file.<snipmatch>

Now, this is also not ideal, as the user might have entered search terms that do return results; they just cannot be inserted at the current position.

I think the best UX would be to add a pseudo-proposal (possibly with a different coloring) to the list of results (at the bottom) stating

  42 snippets matched your query but cannot be inserted at the current cursor position. Please reposition your cursor and try again.

@Yasett: It would be great if you could give this a try. I suggest starting with a breakpoint in SnippetProposal.isValid() so you can get a feel when a proposals validity is checked.
Comment 5 Yasett Acurana CLA 2016-04-11 11:58:24 EDT
(In reply to Andreas Sewe from comment #4)
> @Yasett: It would be great if you could give this a try. I suggest starting
> with a breakpoint in SnippetProposal.isValid() so you can get a feel when a
> proposals validity is checked.

Hi,

I have been reading the source code of the completion engine, to get a better understanding of how proposals are computed, displayed and validated.

I attached a screenshot of what I have in mind at this point. Any thoughts on it?
Comment 6 Yasett Acurana CLA 2016-04-11 12:01:45 EDT
Created attachment 260859 [details]
Warning displayed when the cursor position does not permit to insert snippets.
Comment 7 Andreas Sewe CLA 2016-04-11 13:21:55 EDT
(In reply to Yasett Acurana from comment #5)
> (In reply to Andreas Sewe from comment #4)
> > @Yasett: It would be great if you could give this a try. I suggest starting
> > with a breakpoint in SnippetProposal.isValid() so you can get a feel when a
> > proposals validity is checked.
> 
> Hi,
> 
> I have been reading the source code of the completion engine, to get a
> better understanding of how proposals are computed, displayed and validated.
> 
> I attached a screenshot of what I have in mind at this point. Any thoughts
> on it?

That looks great. I don't think you can implement it exactly as shown, as your warning cannot be a multi-line string.

That being said, a single-line warning like

  8 more matches cannot be inserted at cursor position

with a longer tooltip to fully explain the sitatuon would work great. BTW, that tooltip should not use a monospace code font, but look more like the "Code Recommenders is enabled" proposal's tooltip.
Comment 8 Johannes Dorn CLA 2016-04-26 03:12:17 EDT
I agree, this looks very nice. Since a multiline proposal isn't possible, i would very much like to see this suggestion implemented with the modifications outlined by Andreas.

@Yasett: Would you like to to implement that solution?
Comment 9 Yasett Acurana CLA 2016-04-26 11:16:40 EDT
Created attachment 261259 [details]
Demo of pseudopropsal with warning
Comment 10 Yasett Acurana CLA 2016-04-26 11:18:31 EDT
(In reply to Johannes Dorn from comment #8)
> I agree, this looks very nice. Since a multiline proposal isn't possible, i
> would very much like to see this suggestion implemented with the
> modifications outlined by Andreas.
> 
> @Yasett: Would you like to to implement that solution?

Hi :)

I've been working on this, I just attached a screenshot of how it looks now.

I am testing the solution and will submit a patchset as soon as I finish.
Comment 11 Andreas Sewe CLA 2016-04-26 12:39:09 EDT
(In reply to Yasett Acurana from comment #10)
> (In reply to Johannes Dorn from comment #8)
> > I agree, this looks very nice. Since a multiline proposal isn't possible, i
> > would very much like to see this suggestion implemented with the
> > modifications outlined by Andreas.
> > 
> > @Yasett: Would you like to to implement that solution?
> 
> Hi :)
> 
> I've been working on this, I just attached a screenshot of how it looks now.

Looks very nice.

> I am testing the solution and will submit a patchset as soon as I finish.

Looking forward to it. Shall I set the target milestone to 2.3.2? ;-)
Comment 12 Eclipse Genie CLA 2016-04-28 18:48:00 EDT
New Gerrit change created: https://git.eclipse.org/r/71650
Comment 13 Andreas Sewe CLA 2016-05-12 08:17:39 EDT
(In reply to Eclipse Genie from comment #12)
> New Gerrit change created: https://git.eclipse.org/r/71650

That change does not only add an error message but also changes behavior. We need to discuss this (in Gerrit).