BasicExtendedMetaData.demandRegistry delegation [message #1032720] |
Wed, 03 April 2013 06:41  |
Eclipse User |
|
|
|
Hi Ed
While trying to debug a UML profile issue I started watching
BasicExtendedMetaData.demandPackage and was surprised to see a demand
package being created for http://www.eclipse.org/2008/Xtext. This occurs
when opening an Xtext editor loads its grammar file. The demand package
is needed because the demand package registry does not delegate to the
global registry. Is this intentional or an oversight?
Regards
Ed Willink
|
|
|
|
|
Re: BasicExtendedMetaData.demandRegistry delegation [message #1032818 is a reply to message #1032805] |
Wed, 03 April 2013 09:19  |
Eclipse User |
|
|
|
Ed,
Comments below.
On 03/04/2013 3:01 PM, Ed Willink wrote:
> Hi Ed
>
> Yes, you're right, there is a preceding getPackage() guarding the
> delegateRegistry usage..
>
> The failure to use the already initialized XtextPackageImpl is because
> BasicExtendedMetaData.registry doesn't delegate.
>
> XMLContentHandlerImpl initializes it as
>
> ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(new
> EPackageRegistryImpl());
>
> Is this intentional or an oversight?
Yes, the content handlers just want to do simple XML processing to
determine things like the namespace of the root element in the
document. They don't want to do any "real" processing of the document
and don't want to create any real instances of any models.
>
> Regards
>
> Ed Willink
>
> On 03/04/2013 12:56, Ed Merks wrote:
>> Ed,
>>
>> The API is documented like this:
>>
>> /**
>> * Returns a package from the demand package registry, creating it
>> (with a document root class) if necessary.
>> */
>> EPackage demandPackage(String namespace);
>>
>> So yes, it should demand create a new package or reuse a previously
>> demand created package. It should not consult any other registry.
>>
>> If you look at the callers, it's generally is things like
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleMissingPackage(String) where
>> the resource set's registry or global registry have already been
>> consulted or like this in the QName support in XMLHelper:
>>
>> ePackage = extendedMetaData.getPackage(namespace);
>> if (ePackage == null)
>> {
>> ePackage = extendedMetaData.demandPackage(namespace);
>> }
>>
>>
>> On 03/04/2013 12:41 PM, Ed Willink wrote:
>>> Hi Ed
>>>
>>> While trying to debug a UML profile issue I started watching
>>> BasicExtendedMetaData.demandPackage and was surprised to see a
>>> demand package being created for http://www.eclipse.org/2008/Xtext.
>>> This occurs when opening an Xtext editor loads its grammar file. The
>>> demand package is needed because the demand package registry does
>>> not delegate to the global registry. Is this intentional or an
>>> oversight?
>>>
>>> Regards
>>>
>>> Ed Willink
>>
>
|
|
|
Powered by
FUDForum. Page generated in 0.08691 seconds