Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ve-dev] fieldname change and reload


Hi Janak,
        First and foremost the NPE should not be happening in the decoder. There was
a defect in 1.0.1.1 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=74862) where the
child bean (Button) was not being added to the EMF model before it was being added
as a child of the parent (Panel) - and because of this it gets NPE getting the proxy host.
I would strongly recommend to check with the latest 1.0.2 RC1 code base to recreate
the problem - even with SWT.

Questions:

1. Why is SimpleAttributeDecoderHelper.decode() be called by default if the
_expression_'s Decoder helper throws an NPE?
>> SimpleAttributeDecoderHelper is responsible for decoding/understanding

>> simple properties. It is used as a fail safe mechanism to try to understand
>> a statement. If any decoder helper fails to understand a statement, the
>> SimpleAttributeDecoderHelper is given a shot.
>> Ex: panel.setLayout(new GridBagLayout()); - Here setLayout() can have a
>> variable, a method, or a new() as its argument. First a helper capable of
>> understanding variables and methods is used. Since new GridBagLayout()
>> doesnt fit into both categories, a simple attribute is called which understands
>> the new()

2. Shouldn't SimpleAttributeDecoderHelper.decode() throw a CodeGenException
for the statement?

>> Exceptions and returning false play different roles in the snippet update process.
>> Throwing an exception basically means something very unexpected beyond the
>> scope of the update process has happened and a reload is necessary. Returning
>> false on the other hand signifies that the update mechanism could not genuinely
>> handle the update (could be an unsupported format) and lets the update process
>> continue.

3. SimpleAttributeDecoderHelper.decode() looks for assignment stmt or arg
count == 1. but in our case (set stmt above) it is neither an assignment and
nor does it have arg count = 1. What is the logic behind this? Is it not too
specific to Swing/SWT?
>> Currently SimpleAttributeDecoderHelper is capable of handling only one

>> argument - very primitive, simple and capable of handling most of the expressions
>> found in code. There was no necessity of it handling multiple argument expressions,
>> as specialized helpers were created for that purpose. A custom decoder helper
>> capable of handling multiple arguments could easily be made to override the
>> simple decoder.


4. The logic of model merge failure and subsequent forced reload relies on a
CodeGenException. Is this correct? If so it should be ensured that at every
point of failure during parsing of code a CodeGenException is thrown.
>> As explained in 2. exceptions are used to force reloads whereas returning

>> false represents incapability in handling the style of the _expression_. The reason
>> behind this is that there could be many expressions which VE would could be
>> incapable of handling (unsupported styles, syntax errors etc.), and we dont
>> want to reload just because we were not able to understand a statement - we
>> want to reload if we understand a statement and were seriously unable to update
>> the model.

Regards,
Sri.



"Janak Mulani" <janak.mulani@xxxxxxxxx>
Sent by: ve-dev-admin@xxxxxxxxxxx

12/05/2004 02:32 PM

Please respond to
ve-dev

To
<ve-dev@xxxxxxxxxxx>
cc
Subject
RE: [ve-dev] fieldname change and reload





Hi Sri,

Here are the details.

Scenario:
---------

SWT - A Shell contains a button. Rename the button.

VE 1.0.1 and Eclipse 3.0.1.

Issue
-----

There is an NPE in primAddControl() while parsing the exprn:

remBut = new Button(sShell, SWT.NONE);

VE tries to add the button to the shell, but the ProxyAdapter for the button
is null in Class:
ShellProxyAdapter(CompositeProxyAdapter).primAddControl(IJavaObjectInstance)
line: 123

IBeanProxyHost controlProxyHost =
BeanProxyUtilities.getBeanProxyHost(aControl);
((ControlProxyAdapter)controlProxyHost).setParentProxyHost(this);

Stack:
------

ShellProxyAdapter(CompositeProxyAdapter).primAddControl(IJavaObjectInstance)
line: 122
ShellProxyAdapter(CompositeProxyAdapter).addControl(IJavaObjectInstance,
int) line: 99
ShellProxyAdapter(CompositeProxyAdapter).applied(EStructuralFeature, Object,
int) line: 53
ShellProxyAdapter(BeanProxyAdapter).notifyChanged(Notification) line: 118
JavaObjectInstance(BasicNotifierImpl).eNotify(Notification) line: 225
EcoreEList$Dynamic(EcoreEList).dispatchNotification(Notification) line: 211
EcoreEList$Dynamic(NotifyingListImpl).addUnique(int, Object) line: 344
EcoreEList$Dynamic(BasicEList).add(int, Object) line: 644
SWTConstructorDecoderHelper.createControlFeature() line: 131
SWTConstructorDecoderHelper.decode() line: 157
SWTControlDecoder(AbstractExpressionDecoder).decode() line: 144
CodeExpressionRef.decodeExpression() line: 292
BDMMerger.createNewExpression(CodeExpressionRef, CodeMethodRef, boolean)
line: 710
BDMMerger.addNewExpression(CodeExpressionRef) line: 728
BDMMerger.processExpressions(Collection, Collection) line: 578
BDMMerger.updateBeanPartRegularExpressions() line: 857
BDMMerger.mergeAllBeans() line: 784
BDMMerger.merge() line: 92
JavaSourceTranslator$SharedToLocalUpdater.merge(IBeanDeclModel,
IBeanDeclModel, ICancelMonitor) line: 388
JavaSourceTranslator$SharedToLocalUpdater.handleParseable(CompilationUnit,
ICompilationUnit, ICancelMonitor) line: 434
JavaSourceTranslator$SharedToLocalUpdater.run(Display, ICompilationUnit,
ICodegenLockManager, List, ICancelMonitor) line: 503
StrategyWorker.run() line: 115
Thread.run() line: 534
-----

The NPE is caught in SWTControlDecoder(AbstractExpressionDecoder).decode()
line: 146:

try {
                result = fhelper.decode();
} catch (Exception e) {
                JavaVEPlugin.log(e.getMessage(), Level.FINEST);
}
----

So the SimpleAttributeDecoderHelper.decode() is called.

It Throws a CodeGen exception SimpleAttributeDecoderHelper.addFeature()
line: 289:

PropertyDecorator pd = fFmapper.getDecorator();
if (pd == null)
    throw new CodeGenException("Invalid PropertyDecorator"); //$NON-NLS-1$

-------

This CodeGenException is caught by
BDMMerger.addNewExpression(CodeExpressionRef) line: 732

                CodeExpressionRef newExp = createNewExpression(updateExp,
                          mainMethod,
                          !updateExp.isStateSet
                         (CodeExpressionRef.STATE_NO_MODEL));
} catch (CodeGenException e) {
                JavaVEPlugin.log(e, Level.WARNING) ;
                return false;
}

-----

It returns false implying that merger failed and reload is required in
JavaSourceTranslator$SharedToLocalUpdater.run(Display, ICompilationUnit,
ICodegenLockManager, List, ICancelMonitor) line: 503:

                                                                                                                      reloadRequired = reloadRequired || !handleParseable(ast,
fWorkingCopy, monitor);
                                                                                                                      fireParseError(false);
                                                                                                     }

                                                                                                     ....

                                                                                                     if(reloadRequired){
                                                                                                                      Reload(disp, monitor);
                                                                                                     }

-----

This forces reload; the model is built again and the image on the canvas is
refreshed corectly (button is shown within the shell).

-------

The case of ULC:
---------------

In the case of ULC, while decoding the _expression_:

boxpane.set(0, 0, 1, 1, com.ulcjava.base.shared.IDefaults.BOX_LEFT_CENTER,
getButton());

where,

boxpane = a BoxPane
getButton() = returns the ULC Button whose field name is being changed and
hence the getter method name is being changed.

set method= adds the button to the boxpane with constraints
0,0,1,1,BOX_LEFT_CENTER.
---


While adding the button to the boxpane, the ProxyAdapter for Button is not
found and there is an NPE. So the SimpleAttributeDecoderHelper.decode() is
called.

But it does not throw a CodeGenException but instead returns false:

if ((exp instanceof Assignment) ||
                ((exp instanceof MethodInvocation) &&
((MethodInvocation)exp).arguments().size() == 1))
                return (addFeature());
else {
                CodeGenUtil.logParsingError(fExpr.toString(),
fbeanPart.getInitMethod().getMethodName(), "Invalid Format",false) ;
//$NON-NLS-1$
                return (false);
}

-----

Since there is no CodeGenException, the merger is assumed to be successful
and subsequently there is no reload in
JavaSourceTranslator$SharedToLocalUpdater.run(Display, ICompilationUnit,
ICodegenLockManager, List, ICancelMonitor).

Because no reload is done, the button is shown outside of the boxpane. Then
we do a manual reload, the code is parsed again, the model is built, and the
canavs is refreshed correctly with button in the boxpane.

----

Questions:

1. Why is SimpleAttributeDecoderHelper.decode() be called by default if the
_expression_'s Decoder helper throws an NPE?

2. Shouldn't SimpleAttributeDecoderHelper.decode() throw a CodeGenException
for the statement?

3. SimpleAttributeDecoderHelper.decode() looks for assignment stmt or arg
count == 1. but in our case (set stmt above) it is neither an assignment and
nor does it have arg count = 1. What is the logic behind this? Is it not too
specific to Swing/SWT?

4. The logic of model merge failure and subsequent forced reload relies on a
CodeGenException. Is this correct? If so it should be ensured that at every
point of failure during parsing of code a CodeGenException is thrown.

-----------

I hope the above explanation helps you to track down the problem.

Thanks and regards,

Janak




-----Original Message-----
From: ve-dev-admin@xxxxxxxxxxx [mailto:ve-dev-admin@xxxxxxxxxxx]On Behalf Of
Srimanth Gunturi
Sent: Wednesday, December 01, 2004 3:45 AM
To: ve-dev@xxxxxxxxxxx
Subject: Re: [ve-dev] fieldname change and reload



Hello Janak,
       When one renames a component (foo->bar) in the source, the update
mechanism being at a
low level treats it as a removal of the bean 'foo' and the addition of bean
'bar'. Now regarding a reload,
if the update mechanism found that it was not able to merge a change into
the visual (exception, failing
condition etc.) it performs a reload from scratch. It looks like when you
had the null proxy adapter for the
ULCButton, the merge mechanism didnt think it was a failed update and
happily went on without a reload -
the consequence of which was that you didnt see a ULCButton. In the case of
SWT the NPE might have
happened at a different place/stage such that the update mechanism knew of a
problem and called the
reload from scratch. I would be thankful if you could provide like a stack
trace of where this problem
seems to be occuring in VE so that we can correct it.
Regards,
Sri.




"Janak Mulani" <janak.mulani@xxxxxxxxx>
Sent by: ve-dev-admin@xxxxxxxxxxx
11/29/2004 10:41 AM Please respond to
ve-dev

To"ve-Dev@Eclipse. Org" <ve-dev@xxxxxxxxxxx>
cc
Subject[ve-dev] fieldname change and reload







Dear VE Team,

With your help and guidance we are almost ready with our release. We really
appreciate your help and thank you for the same.

However, there is one problem:

Scenario:

We have a container (ULCBoxPane) and a ULCButton in it.

If we rename the fieldname for ULCButton, VE does refresh children by
reparsing the code. However, while reparsing and adding the child
(ULCButton) to the container (ULCBoxPane), it is not able to find the
ProxyAdapter for ULCButton and neither it is able to create it
(eInternalResource() returns null because eDirectResource is null for the
button eobject and even the eInternalContainer is null).

It seems that button is removed from the model but not added back.

Could you please tell why the PA is not created during the reload after
rename of fieldname?

We need to do an explicit reload to see the button within the container
after rename. This time again, during the reload while adding the child, it
doesnot find ProxyAdapter, however it is able to create it from the
eContainer's resource.

This behavior has been observed for both VE 1.0.1 and VE 1.0.1.1.


While debugging SWT:

I saw similar behavior, PA in primAddControl is null and there is an
exception. However, the model is built subsequently and the canvas is
repainted correctly.

What is it that is triggreing auto reload in the case of SWT? Are we missing
something?

Thanks and regards,

Janak


_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/ve-dev

_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/ve-dev


Back to the top