<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to 9: _getJavaModelElement has several shortcomings</title><link href="https://sourceforge.net/p/jquery/bugs/9/" rel="alternate"/><link href="https://sourceforge.net/p/jquery/bugs/9/feed.atom" rel="self"/><id>https://sourceforge.net/p/jquery/bugs/9/</id><updated>2009-04-14T10:46:12Z</updated><subtitle>Recent changes to 9: _getJavaModelElement has several shortcomings</subtitle><entry><title>_getJavaModelElement has several shortcomings</title><link href="https://sourceforge.net/p/jquery/bugs/9/" rel="alternate"/><published>2009-04-14T10:46:12Z</published><updated>2009-04-14T10:46:12Z</updated><author><name>A.B.</name><uri>https://sourceforge.net/u/abartho/</uri></author><id>https://sourceforge.net42002fcb24a7cdf41e58a1951af0ba7093dcf938</id><summary type="html">&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;</summary></entry></feed>