Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365368 - [xtend] Show escaped methods in content assist.
Summary: [xtend] Show escaped methods in content assist.
Status: CLOSED FIXED
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 381983 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-12-01 17:47 EST by McKinley CLA
Modified: 2017-10-31 11:24 EDT (History)
5 users (show)

See Also:
sven.efftinge: kepler+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description McKinley CLA 2011-12-01 17:47:28 EST
Build Identifier: 2.2.0

While using the Querydsl sql API, which has methods named 'as' (as in the sql alias expression) the 'as' method are invisible to Xtend. The 'as' method call is highlighted as the Xtend 'as' keyword, of course. How can I use this method without creating a wrapper in Java?

Reproducible: Always

Steps to Reproduce:
See above
Comment 1 Jan Koehnlein CLA 2011-12-01 18:24:29 EST
Did you try quoting it with a '^' in the Xtend code?
Comment 2 McKinley CLA 2011-12-02 01:53:51 EST
That works, but 'as' is not show in code completion. It should be shown and if possible, the '^' inserted if 'as' is selected from content assist. Also, '^' does not have a very high-profile placement in the documentation. I did not know about it until you suggested it. Now I see it is mentioned here: http://www.eclipse.org/Xtext/documentation/2_1_0/02-Xtend_Classes_Functions.php#imports

Thanks for your help with the escaping.

(In reply to comment #1)
> Did you try quoting it with a '^' in the Xtend code?
Comment 3 Sebastian Zarnekow CLA 2011-12-02 09:48:45 EST
ContentAssist should show the escaped version if there is no alternative, e.g.

Object#getClass should not be shortened to ^class in CA (event though it's valid) while Something#extension() can only be proposed as ^extension
Comment 4 Sebastian Zarnekow CLA 2012-01-31 06:00:18 EST
The missing proposal is probably caused by 

java.lang.ClassCastException: org.eclipse.xtext.xbase.impl.XBlockExpressionImpl cannot be cast to org.eclipse.xtext.xtend2.xtend2.XtendClass
	at org.eclipse.xtext.xtend2.ui.contentassist.Xtend2ProposalProvider.completeClass_Members(Xtend2ProposalProvider.java:151)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.invokeMethod(AbstractJavaBasedContentProposalProvider.java:271)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.completeAssignment(AbstractJavaBasedContentProposalProvider.java:185)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.caseAssignment(AbstractContentProposalProvider.java:66)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.caseAssignment(AbstractContentProposalProvider.java:1)
	at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:164)
	at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:70)
	at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:58)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.accept(AbstractContentProposalProvider.java:71)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider.createProposals(AbstractContentProposalProvider.java:108)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.createProposals(AbstractJavaBasedContentProposalProvider.java:246)
	at org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer.exec(CompletionProposalComputer.java:51)
	at org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer.exec(CompletionProposalComputer.java:1)
	at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:32)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:78)
	at org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor.computeCompletionProposals(XtextContentAssistProcessor.java:68)
	at org.eclipse.xtext.ui.editor.contentassist.RepeatedContentAssistProcessor.computeCompletionProposals(RepeatedContentAssistProcessor.java:73)
	at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1830)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:556)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:553)
Comment 5 Sebastian Zarnekow CLA 2012-01-31 06:48:51 EST
Turns out that the exception is not the causer of the problem.
Comment 6 Sven Efftinge CLA 2012-11-08 08:54:35 EST
*** Bug 381983 has been marked as a duplicate of this bug. ***
Comment 7 McKinley CLA 2013-02-20 03:36:05 EST
I checked in 2.4 and did not see .^as in content assist. I think this is important because it will turn into an infamous FAQ if it does not. Also, I think

1) .^as should show alphabetically with other .a properties, not at the top
2) .^as should show in content assist even if you start to type .a and not .^a

Thanks
Comment 8 Anton Kosyakov CLA 2013-02-21 11:48:06 EST
See gerrit https://git.eclipse.org/r/#/c/10572/
Comment 9 Sven Efftinge CLA 2013-02-21 12:20:23 EST
approved and submitted. Thanks, Anton
Comment 10 McKinley CLA 2013-03-05 16:17:48 EST
This is improved in 2.4.0.v201303050101, but it has a problem still.

It behaves like this now:

obj.[aaa, as, bbb]
obj.^[as]
obj.a[aaa]

The last item should behave:

obj.a[aaa, as]

If it doesn't behave this way, many people will type obj.a[...] and not see 'as' in the content assist. They may assume that Xtend does not support existing Java APIs. They should be spared the confusion.
Comment 11 Sebastian Zarnekow CLA 2013-03-07 07:10:12 EST
Pushed to master
Comment 12 Eclipse Webmaster CLA 2017-10-31 11:24:30 EDT
Requested via bug 522520.

-M.