<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 9: _getJavaModelElement has several shortcomings</title><link>https://sourceforge.net/p/jquery/bugs/9/</link><description>Recent changes to 9: _getJavaModelElement has several shortcomings</description><atom:link href="https://sourceforge.net/p/jquery/bugs/9/feed.rss" rel="self"/><language>en</language><lastBuildDate>Tue, 14 Apr 2009 10:46:12 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/jquery/bugs/9/feed.rss" rel="self" type="application/rss+xml"/><item><title>_getJavaModelElement has several shortcomings</title><link>https://sourceforge.net/p/jquery/bugs/9/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;1.&lt;br /&gt;
Method JQueryTyRuBaAPI#_getJavaModelElement(Object) does not work for inner classes/interfaces and their members. Parts like this:&lt;/p&gt;
&lt;p&gt;result = p.findType(getPackage(target), JQueryAPI.getElementLabel(target));&lt;/p&gt;
&lt;p&gt;should be replaced by&lt;/p&gt;
&lt;p&gt;result = p.findType(_getQualifiedElementLabel(target));&lt;/p&gt;
&lt;p&gt;where _getQualifiedElementLabel returns the qualified name of the targe. One could even consider to add getQualifiedElementLabel to the public API.&lt;/p&gt;
&lt;p&gt;private String _getQualifiedElementLabel(Object target) {&lt;br /&gt;
return _getStringProperty(target, "qname"); //works for classes/interfaces only&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;2.&lt;br /&gt;
The p.findType() call should not be used for fields and methods. According to the documentation it is only intended for types. So in the field and method section I suggest to replace&lt;/p&gt;
&lt;p&gt;IType t = p.findType(getPackage(target), getParent(target));&lt;/p&gt;
&lt;p&gt;with&lt;/p&gt;
&lt;p&gt;Object parent = getParent(target);  //changed the existing getParent method to return the real parent object, not just the name&lt;br /&gt;
String parentQualifiedName = _getQualifiedElementLabel(parent);&lt;br /&gt;
IType t = p.findType(parentQualifiedName);&lt;/p&gt;
&lt;p&gt;3.&lt;br /&gt;
Sometimes a false method is returned. Suppose there are 2 methods in a class: meth() and secondmeth().&lt;/p&gt;
&lt;p&gt;The following code might return secondmeth() if actually meth() is searched:&lt;br /&gt;
for (int i = 0; i &amp;lt; m.length; i++) {&lt;br /&gt;
if (getMethodName(m[i]).contains(mName)) {&lt;br /&gt;
result = m[i];&lt;br /&gt;
}&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;If there is no reason to check the method names with contains(), I suggest to replace it wit equals(), as in the fields section.&lt;br /&gt;
The complete (documented) changes can be found in the RuBaDoc project here on Sourceforge.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">A.B.</dc:creator><pubDate>Tue, 14 Apr 2009 10:46:12 -0000</pubDate><guid>https://sourceforge.net42002fcb24a7cdf41e58a1951af0ba7093dcf938</guid></item></channel></rss>