| Summary: | [serializer][generator] ambiguous type references in AbstractXyzSemanticSerializer | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Knut Wannheden <knut.wannheden> | ||||
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> | ||||
| Status: | CLOSED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | moritz.eysholdt, sebastian.zarnekow | ||||
| Version: | 2.0.0 | Flags: | moritz.eysholdt:
indigo+
|
||||
| Target Milestone: | RC2 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Knut Wannheden
Created attachment 195421 [details]
simple patch
Simple patch solving the problem by using qualified names everywhere except for the Ecore package interfaces.
Reproducable with org.eclipse.xtext.generator.ecore.SubTestLanguage and org.eclipse.xtext.parsetree.reconstr.SimpleReconstrTestLanguage pushed to master. All types are now imported explicitly. Excellent! Just to make sure: Does this really also solve the corner case where an EClass name conflicts with a Java class from package java.lang? E.g. "Package" as mentioned or "Override". If we want to keep simple names I suggest we integrate with the EMF code generation utilities for this. See CodeGenUtil#isJavaDefaultType() and GenPackage#getJavaLangConflicts() et al. (In reply to comment #4) > Excellent! > > Just to make sure: Does this really also solve the corner case where an EClass > name conflicts with a Java class from package java.lang? E.g. "Package" as > mentioned or "Override". > > If we want to keep simple names I suggest we integrate with the EMF code > generation utilities for this. See CodeGenUtil#isJavaDefaultType() and > GenPackage#getJavaLangConflicts() et al. good point, I wasn't aware of CodeGenUtil#isJavaDefaultType(). I've improved the generator to always use a type's qualified name if (CodeGenUtil#isJavaDefaultType(simpleName) == true). The imports and sequence_* methods are now correctly generated but the corresponding type casts must also be qualified in the cases as the unqualified type reference will otherwise refer to the wrong type. The same of course applies when the conflicting type is a type of package java.lang. Example grammar to reproduce both these problems: grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals import "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.ecore" as xbase generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" Model returns XExpression: greetings+=Greeting* overrides+=Override; Greeting returns xbase::XExpression : {xbase::XExpression} 'Hello'; Override : {Override} 'Bye'; fixed, once again. hopefully I didn't miss anything this time. Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |