Share

JQuery: Query-Based Java Code Browser

Tracker: Bugs

5 _getJavaModelElement has several shortcomings - ID: 2761612
Last Update: Tracker Item Submitted ( abartho )

1.
Method JQueryTyRuBaAPI#_getJavaModelElement(Object) does not work for inner
classes/interfaces and their members. Parts like this:

result = p.findType(getPackage(target),
JQueryAPI.getElementLabel(target));

should be replaced by

result = p.findType(_getQualifiedElementLabel(target));

where _getQualifiedElementLabel returns the qualified name of the targe.
One could even consider to add getQualifiedElementLabel to the public API.

private String _getQualifiedElementLabel(Object target) {
return _getStringProperty(target, "qname"); //works for classes/interfaces
only
}


2.
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

IType t = p.findType(getPackage(target), getParent(target));

with

Object parent = getParent(target); //changed the existing getParent method
to return the real parent object, not just the name
String parentQualifiedName = _getQualifiedElementLabel(parent);
IType t = p.findType(parentQualifiedName);

3.
Sometimes a false method is returned. Suppose there are 2 methods in a
class: meth() and secondmeth().

The following code might return secondmeth() if actually meth() is
searched:
for (int i = 0; i < m.length; i++) {
if (getMethodName(m[i]).contains(mName)) {
result = m[i];
}
}

If there is no reason to check the method names with contains(), I suggest
to replace it wit equals(), as in the fields section.
The complete (documented) changes can be found in the RuBaDoc project here
on Sourceforge.


A.B. ( abartho ) - 2009-04-14 10:46

5

Open

None

Nobody/Anonymous

Database

v4.0

Public


Comments




Log in to comment.

No follow-up comments have been posted.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.