<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Denis, Viacheslav,<div><br></div><div>Thanks for your replies. I'm going to look at checking if the created type really exists - I think it works: element.exist() returned false for the class 'A', I'm doing more testing today. </div><div>Otherwise, I'll skip events related to any 'package-info.java' resource. </div><div><br></div><div>Best regards,<br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">/Xavier<br><br><br></span>
</div>
<br><div><div>On Aug 1, 2012, at 2:42 AM, Denis Golovin wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<div bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Xavier,<br>
<br>
Looked through the code and didn't find better way to handle
annotation type resolution ether. <br>
I guess you can check compilation unit name and skip units with
name "package-info.java".<br>
<br>
Denis<br>
<br>
On 07/31/2012 01:46 PM, Viacheslav Kabanovich wrote:<br>
</div>
<blockquote cite="mid:50184409.1060108@exadel.com" type="cite">
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
Hello Xavier,<br>
<br>
This class is temporary created in a working copy that is
discarded in the same method in order to get IType as context for
resolution of referenced types. For example, package-info.java may
have this content<br>
<br>
@Named<br>
package cdi.test.alternative.case1;<br>
import javax.inject.*;<br>
<br>
Neither interface ICompilationUnit, nor IPackageDeclaration have
method resolveType(String) which is needed to resolve 'Named' into
'javax.inject.Named'. I could not find a better solution than
creating a temporary IType. It is never added to the actual Java
model of the project, it exists only in a working copy that is
discarded.<br>
<br>
Java model listeners may get the event on creating this type, but
they also should get the event on its discarding. <br>
<br>
Best regards,<br>
Slava<br>
<br>
On 07/31/2012 06:34 AM, Xavier Coulon wrote:
<blockquote cite="mid:1B10F1C7-54F9-4193-AB54-E02BBCADF64C@redhat.com" type="cite">Hello Daniel,
<div><br>
</div>
<div>As I'm trying to fix <a moz-do-not-send="true" href="https://issues.jboss.org/browse/JBIDE-12095">https://issues.jboss.org/browse/JBIDE-12095</a>,
I found something a bit strange in the CDIBuilderDelegate when
editing a 'package-info.java' file (just adding a space char):</div>
<div>At line 90, the CDIBuilderDelegate#build() method calls the
PackageDelegate#setPackage() method below which creates a
'class A {}' as shown below.</div>
<div><br>
</div>
<div style="margin: 0px; font: 11px Menlo;"><span style="color:
rgb(147, 16, 102);"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>public</b></span> <span style="color: rgb(147, 16, 102);"><b>void</b></span>
setPackage(IPackageDeclaration pkg, IRootDefinitionContext
context) {</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: rgb(33, 32, 200);">qualifiedName</span> =
pkg.getElementName();</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>IType
contextType = <span style="color: rgb(147, 16, 102);"><b>null</b></span>;</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>ICompilationUnit
u = <span style="color: rgb(147, 16, 102);"><b>null</b></span>;</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: rgb(147, 16, 102);"><b>if</b></span>(pkg.getParent()
<span style="color: rgb(147, 16, 102);"><b>instanceof</b></span>
ICompilationUnit) {</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: rgb(147, 16, 102);"><b>try</b></span> {</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>u
= ((ICompilationUnit)pkg.getParent()).getWorkingCopy(<span style="color: rgb(147, 16, 102);"><b>new</b></span>
NullProgressMonitor());</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>contextType
= u.createType(<span style="color: rgb(72, 44, 251);">"class A
{}"</span>, <span style="color: rgb(147, 16, 102);"><b>null</b></span>,
<span style="color: rgb(147, 16, 102);"><b>false</b></span>, <span style="color: rgb(147, 16, 102);"><b>new</b></span>
NullProgressMonitor());</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}
<span style="color: rgb(147, 16, 102);"><b>catch</b></span>
(JavaModelException e) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><span class="Apple-tab-span" style="white-space: pre;"> </span><br class="webkit-block-placeholder">
</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: rgb(147, 16, 102);"><b>super</b></span>.setAnnotatable(pkg,
contextType, context, 0);</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: rgb(147, 16, 102);"><b>if</b></span> (u != <span style="color: rgb(147, 16, 102);"><b>null</b></span>) {</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: rgb(147, 16, 102);"><b>try</b></span> {</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>u.discardWorkingCopy();</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}
<span style="color: rgb(147, 16, 102);"><b>catch</b></span>
(JavaModelException e) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><span class="Apple-tab-span" style="white-space: pre;"> </span><br class="webkit-block-placeholder">
</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="margin: 0px; font: 11px Menlo;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div><span class="Apple-style-span" style="font-family: Menlo;
font-size: 11px;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span class="Apple-style-span" style="font-family: Menlo;
font-size: 11px;">}</span> </div>
<div><br>
</div>
<div>The JAX-RS plugin catches an event for this type creation
but fails later. I can add some tests to verify that the type
really exist, but still, is this necessary (just asking, don't
take is bad) ?</div>
<div><br>
</div>
<div>Thanks.</div>
<div>Best regards,<br>
<div apple-content-edited="true"> /Xavier<br>
<br>
<br>
</div>
<br>
</div>
<pre wrap=""><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
jbosstools-dev mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:jbosstools-dev@lists.jboss.org">jbosstools-dev@lists.jboss.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/jbosstools-dev">https://lists.jboss.org/mailman/listinfo/jbosstools-dev</a></pre>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
jbosstools-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:jbosstools-dev@lists.jboss.org">jbosstools-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/jbosstools-dev">https://lists.jboss.org/mailman/listinfo/jbosstools-dev</a></pre>
</blockquote>
<br>
</div>
</blockquote></div><br></div></body></html>