Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » null text generated in editor plugin.xml
null text generated in editor plugin.xml [message #1399069] Sat, 12 July 2014 01:30 Go to next message
Alain Picard is currently offline Alain PicardFriend
Messages: 266
Registered: July 2009
Senior Member
I have discovered what appears to be a bug.

When I generate my editor code, my plugin.xml gets a number of null text fragments all over the place.

I ran in debug and found that this happens during the mergePluginXML in AbstractGeneratorAdapter.

What ends up happening is that the oldExtension.content is set to null here (see arrow):
else
{
  // If the new match has the same non-null generation key.
  //
  ExtensionData newExtension = newExtensions.get(index);
  if (oldExtension.generated != null && oldExtension.generated.equals(newExtension.generated))
  {
    // Set up the old extension up to pull the new content.
    //
-->  oldExtension.content = newExtension.content;
  }

  // Set up the new extension to block it being pushed.
  //
  newExtension.content = null;


I'm not sure about the full validity of the pattern here, but the root cause is that the regex used is not foolproof.
We have this regex:
EXTENSION_POINT_PATTERN = Pattern.compile("[ \t]*<extension[^>]+point\\s*=['\"]([^'\"]+)['\"].*?(?:id|class)\\s*=\\s*['\"]([^'\"]+)['\"].*?</extension>[ \t]*(\n\r|\r\n|\n|\r)", Pattern.DOTALL);


and the extension key is based on the extension point and the id (group 1 and 2 in the regex).

But I have the following in my plugin.xml which causes duplicate matches since the id used is not the correct one, since it picks up the id from the category which is not unique:
   <extension point="org.eclipse.ui.newWizards">
      <!-- @generated ba -->
      <category
            id="org.eclipse.emf.ecore.Wizard.category.ID"
            name="%_UI_Wizard_category"/>
      <wizard
            id="com.castortech.iris.models.ecore.ba.process.presentation.ProcessModelWizardID"
            name="%_UI_ProcessModelWizard_label"
            class="com.castortech.iris.models.ecore.ba.process.presentation.ProcessModelWizard"
            category="org.eclipse.emf.ecore.Wizard.category.ID"
            icon="icons/full/obj16/ProcessModelFile.gif">
         <description>%_UI_ProcessModelWizard_description</description>
         <selection class="org.eclipse.core.resources.IResource"/>
      </wizard>
   </extension>


So what is the solution here? Is a regex really appropriate ?

Please advise.

Cheers,
Alain
Re: null text generated in editor plugin.xml [message #1399980 is a reply to message #1399069] Sun, 13 July 2014 13:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Alain,

Comments below.

On 12/07/2014 3:30 AM, Alain Picard wrote:
> I have discovered what appears to be a bug.
>
> When I generate my editor code, my plugin.xml gets a number of null
> text fragments all over the place.
I see. I know someone else mentioned that a while back, but I've never
seen that...
>
> I ran in debug and found that this happens during the mergePluginXML
> in AbstractGeneratorAdapter.
>
> What ends up happening is that the oldExtension.content is set to null
> here (see arrow):
>
> else
> {
> // If the new match has the same non-null generation key.
> //
> ExtensionData newExtension = newExtensions.get(index);
> if (oldExtension.generated != null &&
> oldExtension.generated.equals(newExtension.generated))
> {
> // Set up the old extension up to pull the new content.
> //
> --> oldExtension.content = newExtension.content;
> }
>
> // Set up the new extension to block it being pushed.
> //
> newExtension.content = null;
>
>
> I'm not sure about the full validity of the pattern here, but the root
> cause is that the regex used is not foolproof.
> We have this regex:
>
> EXTENSION_POINT_PATTERN = Pattern.compile("[
> \t]*<extension[^>]+point\\s*=['\"]([^'\"]+)['\"].*?(?:id|class)\\s*=\\s*['\"]([^'\"]+)['\"].*?</extension>[
> \t]*(\n\r|\r\n|\n|\r)", Pattern.DOTALL);
>
>
> and the extension key is based on the extension point and the id
> (group 1 and 2 in the regex).
I see.
>
> But I have the following in my plugin.xml which causes duplicate
> matches since the id used is not the correct one, since it picks up
> the id from the category which is not unique:
>
> <extension point="org.eclipse.ui.newWizards">
> <!-- @generated ba -->
> <category
> id="org.eclipse.emf.ecore.Wizard.category.ID"
> name="%_UI_Wizard_category"/>
> <wizard
> id="com.castortech.iris.models.ecore.ba.process.presentation.ProcessModelWizardID"
> name="%_UI_ProcessModelWizard_label"
> class="com.castortech.iris.models.ecore.ba.process.presentation.ProcessModelWizard"
> category="org.eclipse.emf.ecore.Wizard.category.ID"
> icon="icons/full/obj16/ProcessModelFile.gif">
> <description>%_UI_ProcessModelWizard_description</description>
> <selection class="org.eclipse.core.resources.IResource"/>
> </wizard>
> </extension>
>
>
> So what is the solution here?
Is there more than one newWizards in the same plugin.xml?
> Is a regex really appropriate ?
Processing XML would be better, but it's much harder to avoid messing up
the whole file, i.e., reordering all attributes alphabetically which DOM
serializers are always so happy to do.
> Please advise.
Please open a bugzilla with a sample that reproduces the problem.
>
> Cheers,
> Alain


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: null text generated in editor plugin.xml [message #1400044 is a reply to message #1399980] Sun, 13 July 2014 16:18 Go to previous message
Alain Picard is currently offline Alain PicardFriend
Messages: 266
Registered: July 2009
Senior Member
Ed,

Yes there are multiple, one for each package.

I've opened a bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=439485

Thanks
Alain
Previous Topic:[XCORE] How To Design Question: How to model extensible single instances
Next Topic:Sending and receiving XMIResources over network
Goto Forum:
  


Current Time: Fri Apr 19 06:05:38 GMT 2024

Powered by FUDForum. Page generated in 0.02388 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top