use of org.eclipse.linuxtools.cdt.libhover.FunctionInfo in project linuxtools by eclipse.
the class CXmlLibhoverGen method doGenerate.
@Override
protected LibHoverInfo doGenerate() {
LibHoverInfo hoverInfo = new LibHoverInfo();
// $NON-NLS-1$
NodeList nl = document.getElementsByTagName("construct");
for (int i = 0; i < nl.getLength(); ++i) {
Node n = nl.item(i);
NamedNodeMap m = n.getAttributes();
// $NON-NLS-1$
Node id = m.getNamedItem("id");
if (id != null && id.getNodeValue().startsWith("function-")) {
// $NON-NLS-1$
String name = id.getNodeValue().substring(9);
NodeList nl2 = n.getChildNodes();
for (int j = 0; j < nl2.getLength(); ++j) {
Node n2 = nl2.item(j);
if (n2.getNodeName().equals("function")) {
// $NON-NLS-1$
FunctionInfo f = getFunctionInfoFromNode(name, n2, document);
hoverInfo.functions.put(name, f);
}
}
}
}
return hoverInfo;
}
use of org.eclipse.linuxtools.cdt.libhover.FunctionInfo in project linuxtools by eclipse.
the class CXmlLibhoverGen method getFunctionInfoFromNode.
private FunctionInfo getFunctionInfoFromNode(String name, Node functionNode, Document document) {
FunctionInfo f = new FunctionInfo(name);
NamedNodeMap functionNodeMap = functionNode.getAttributes();
Node functionNodeReturntypeNode = functionNodeMap.item(0);
String functionNodeRtName = functionNodeReturntypeNode.getNodeName();
if (functionNodeRtName.equals("returntype")) {
// $NON-NLS-1$
// return type
String functionNodeRtValue = functionNodeReturntypeNode.getNodeValue();
f.setReturnType(functionNodeRtValue);
}
// returntype
NodeList kids = functionNode.getChildNodes();
for (int fnk = 0; fnk < kids.getLength(); fnk++) {
Node kid = kids.item(fnk);
String kidName = kid.getNodeName();
if (kidName.equals("prototype")) {
// $NON-NLS-1$
// prototype
String prototype = null;
NodeList parms = kid.getChildNodes();
for (int fnp = 0; fnp < parms.getLength(); fnp++) {
Node parm = parms.item(fnp);
String parmName = parm.getNodeName();
if (parmName.equals("parameter")) {
// $NON-NLS-1$
NamedNodeMap parmMap = parm.getAttributes();
Node parmNode = parmMap.item(0);
String parameter = parmNode.getNodeValue();
prototype = (null == prototype) ? parameter : prototype + ", " + // $NON-NLS-1$
parameter;
}
}
f.setPrototype(prototype);
} else if (kidName.equals("headers")) {
// $NON-NLS-1$
// headers
NodeList headers = kid.getChildNodes();
for (int fnh = 0; fnh < headers.getLength(); fnh++) {
Node header = headers.item(fnh);
String headerName = header.getNodeName();
if (headerName.equals("header")) {
// $NON-NLS-1$
NamedNodeMap headerMap = header.getAttributes();
Node headerNode = headerMap.item(0);
f.addHeader(headerNode.getNodeValue());
}
}
} else if (kidName.equals("groupsynopsis")) {
// $NON-NLS-1$
// group synopsis
NamedNodeMap attr = kid.getAttributes();
// $NON-NLS-1$
Node idnode = attr.getNamedItem("id");
String id = idnode.getNodeValue();
if (id != null) {
Element elem2 = document.getElementById(id);
if (null != elem2) {
// $NON-NLS-1$
NodeList synopsisNode = elem2.getElementsByTagName("synopsis");
if (null != synopsisNode && synopsisNode.getLength() > 0) {
Node synopsis = synopsisNode.item(0);
Node textNode = synopsis.getLastChild();
f.setDescription(textNode.getNodeValue());
}
}
}
} else if (kidName.equals("synopsis")) {
// $NON-NLS-1$
// synopsis
Node textNode = kid.getLastChild();
f.setDescription(textNode.getNodeValue());
}
}
return f;
}
Aggregations