Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365159 - [xbase] Allow fully qualified static imports.
Summary: [xbase] Allow fully qualified static imports.
Status: VERIFIED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.5.0   Edit
Hardware: All All
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: v2.6
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-30 01:30 EST by McKinley CLA
Modified: 2014-05-13 07:30 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description McKinley CLA 2011-11-30 01:30:21 EST
Build Identifier: 

Example:
import static extension org.apache.http.util.EntityUtils.consume swallow
import static extension org.apache.http.util.EntityUtils.toString(HttpEntity) consumeToString
import static extension org.apache.http.util.EntityUtils.toString(HttpEntity, String) consumeToString

Instead of
import static extension org.apache.http.util.EntityUtils.*

Usage:
...
response1.entity.swallow
println(response2.entity.consumeToString)
println(response3.entity.consumeToString("UTF-8"))

Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2014-02-21 11:14:00 EST
We'll do it with the same semantics as Java, e.g. no aliasing, no explicit signatures.

Things to consider:

Overloaded named static imports,
Duplicate static import validation,
Organize imports,
Unused imports,
Content assist in the import section,
Static member scoping
Comment 2 Sebastian Zarnekow CLA 2014-02-21 11:14:54 EST
(In reply to Sebastian Zarnekow from comment #1)

> Static member scoping

That is, an explicit import of valueOf(String) from java.lang.Integer has a higher priority than a wildcard import of the form import static java.lang.String.*
Comment 3 Sebastian Zarnekow CLA 2014-02-21 11:17:01 EST
Same for extension imports
Comment 4 Sebastian Zarnekow CLA 2014-02-21 11:19:17 EST
Another thing is the validation of the member name, the imported type has to have at least one visible static member with the given simple name
Comment 5 Sebastian Zarnekow CLA 2014-03-03 18:29:34 EST
I didn't try this but giving it some thought, the syntactic ambiguity (discussed offline) seems to be resolvable with this grammar rules:

XImportDeclaration: 
	'import' (
		(static?='static' extension?='extension'? importedType=[JvmDeclaredType|QualifiedNameInStaticImport] (wildcard?='*' | memberName=ValidID) 
		| importedType=[JvmDeclaredType|QualifiedName] 
		| importedNamespace=QualifiedNameWithWildcard) ';'?
;

QualifiedNameInStaticImport:
  (ValidID '.')+
;
Comment 6 Anton Kosyakov CLA 2014-03-11 04:57:11 EDT
pushed to review: https://git.eclipse.org/r/23176
Comment 7 Stefan Oehme CLA 2014-05-13 07:30:34 EDT
Works except for some minor issue described in Bug 434730