Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2011-05-30 17:48:54 -0400
committerJeff Johnston2011-05-30 17:49:25 -0400
commite9f1cb339c1dd033f1de6769686d3caab20a4cab (patch)
tree99156336cce27b625c0f600b2e516bd24cbba98d /libhover
parent008dc40850d93e58768fed7339f5b9903e3a454a (diff)
downloadorg.eclipse.linuxtools-e9f1cb339c1dd033f1de6769686d3caab20a4cab.tar.gz
org.eclipse.linuxtools-e9f1cb339c1dd033f1de6769686d3caab20a4cab.tar.xz
org.eclipse.linuxtools-e9f1cb339c1dd033f1de6769686d3caab20a4cab.zip
Add .devhelp2 support to devhelp libhover plug-in.
2011-05-30 Jeff Johnston <jjohnstn@redhat.com> Resolves: #347705 * src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/ParseDevHelp.java (DevHelpParser.parse): Default to use .devhelp2 files if found, then fall-back to .devhelp files. (DevHelpParser.parse): Add devhelp2 support.
Diffstat (limited to 'libhover')
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/ChangeLog7
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/ParseDevHelp.java100
2 files changed, 73 insertions, 34 deletions
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/ChangeLog b/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/ChangeLog
index a956fbace4..805d90f3e6 100644
--- a/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/ChangeLog
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/ChangeLog
@@ -1,3 +1,10 @@
+2011-05-30 Jeff Johnston <jjohnstn@redhat.com>
+
+ Resolves: #347705
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/ParseDevHelp.java (DevHelpParser.parse): Default
+ to use .devhelp2 files if found, then fall-back to .devhelp files.
+ (DevHelpParser.parse): Add devhelp2 support.
+
2011-03-31 Jeff Johnston <jjohnstn@redhat.com>
* Initial check-in. \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/ParseDevHelp.java b/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/ParseDevHelp.java
index 9c39f332d4..4e46ac1177 100644
--- a/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/ParseDevHelp.java
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.devhelp/src/org/eclipse/linuxtools/internal/cdt/libhover/devhelp/ParseDevHelp.java
@@ -338,8 +338,13 @@ public class ParseDevHelp {
return null;
monitor.setTaskName(LibHoverMessages.getFormattedString(PARSING_FMT_MSG,
new String[]{name}));
- parse(dirPath.append(name).append(name + ".devhelp").toOSString(), //$NON-NLS-1$
- monitor);
+ File f = new File(dirPath.append(name).append(name + ".devhelp2").toOSString());
+ if (f.exists())
+ parse(dirPath.append(name).append(name + ".devhelp2").toOSString(), //$NON-NLS-1$
+ monitor);
+ else
+ parse(dirPath.append(name).append(name + ".devhelp").toOSString(), //$NON-NLS-1$
+ monitor);
monitor.worked(1);
}
} catch (CoreException e) {
@@ -348,7 +353,35 @@ public class ParseDevHelp {
}
return libhover;
}
-
+
+ private void parseLink(Node link, Node name, IPath path, LibHoverInfo libhover) {
+ String linkValue = link.getNodeValue();
+ String[] linkParts = linkValue.split("#"); //$NON-NLS-1$
+ if (linkParts.length == 2) {
+ try {
+ String nameString = name.getNodeValue();
+ nameString = nameString.replaceAll("\\(.*\\);+", "").trim(); //$NON-NLS-1$ //$NON-NLS-2$
+ if (nameString.contains("::") || nameString.startsWith("enum ") //$NON-NLS-1$ //$NON-NLS-2$
+ || nameString.contains("\"")) //$NON-NLS-1$
+ return;
+ Reader reader = new FileReader(path.removeLastSegments(1).toOSString()
+ + "/" + linkParts[0]); //$NON-NLS-1$
+ Parser callback = new Parser(linkParts[1], nameString);
+ new ParserDelegator().parse(reader, callback, true);
+ FunctionInfo finfo = callback.getFunctionInfo();
+ if (finfo != null) {
+ if (debug)
+ System.out.println(callback.toString());
+ libhover.functions.put(callback.getFuncName(), callback.getFunctionInfo());
+ }
+ } catch (FileNotFoundException e1) {
+ // ignore
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+
public void parse(String fileName, IProgressMonitor monitor) {
try {
Path path = new Path(fileName);
@@ -374,36 +407,35 @@ public class ParseDevHelp {
if (language != null && !language.getNodeValue().equals("c"))
return;
}
- NodeList nl = doc.getElementsByTagName("function"); // $NON-NLS-1$
- for (int i = 0; i < nl.getLength(); ++i) {
- if (monitor.isCanceled())
- return;
- Node n = nl.item(i);
- NamedNodeMap m = n.getAttributes();
- Node name = m.getNamedItem("name"); // $NON-NLS-1$
- Node link = m.getNamedItem("link"); // $NON-NLS-1$
- if (link != null) {
- String linkValue = link.getNodeValue();
- String[] linkParts = linkValue.split("#"); //$NON-NLS-1$
- if (linkParts.length == 2) {
- try {
- String nameString = name.getNodeValue();
- nameString = nameString.replaceAll("\\(.*\\);+", "").trim(); //$NON-NLS-1$ //$NON-NLS-2$
- if (nameString.contains("::") || nameString.startsWith("enum ") //$NON-NLS-1$ //$NON-NLS-2$
- || nameString.contains("\"")) //$NON-NLS-1$
- continue;
- Reader reader = new FileReader(path.removeLastSegments(1).toOSString()
- + "/" + linkParts[0]); //$NON-NLS-1$
- Parser callback = new Parser(linkParts[1], nameString);
- new ParserDelegator().parse(reader, callback, true);
- FunctionInfo finfo = callback.getFunctionInfo();
- if (finfo != null) {
- if (debug)
- System.out.println(callback.toString());
- libhover.functions.put(callback.getFuncName(), callback.getFunctionInfo());
+ if (path.lastSegment().endsWith("devhelp")) {
+ NodeList nl = doc.getElementsByTagName("function"); // $NON-NLS-1$
+ for (int i = 0; i < nl.getLength(); ++i) {
+ if (monitor.isCanceled())
+ return;
+ Node n = nl.item(i);
+ NamedNodeMap m = n.getAttributes();
+ Node name = m.getNamedItem("name"); // $NON-NLS-1$
+ Node link = m.getNamedItem("link"); // $NON-NLS-1$
+ if (link != null) {
+ parseLink(link, name, path, libhover);
+ }
+ }
+ } else if (path.lastSegment().endsWith("devhelp2")) {
+ NodeList nl = doc.getElementsByTagName("keyword"); // $NON-NLS-1$
+ for (int i = 0; i < nl.getLength(); ++i) {
+ if (monitor.isCanceled())
+ return;
+ Node n = nl.item(i);
+ NamedNodeMap m = n.getAttributes();
+ Node type = m.getNamedItem("type"); // $NON-NLS-1$
+ if (type != null) {
+ String typeName = type.getNodeValue();
+ if (typeName.equals("function")) { //$NON-NLS-1$
+ Node name = m.getNamedItem("name"); // $NON-NLS-1$
+ Node link = m.getNamedItem("link"); // $NON-NLS-1$
+ if (link != null) {
+ parseLink(link, name, path, libhover);
}
- } catch (FileNotFoundException e1) {
- // ignore
}
}
}
@@ -437,13 +469,13 @@ public class ParseDevHelp {
public static void main(String[] args) {
String devhelpHtmlDirectory = args[0];
- DevHelpParser p = new DevHelpParser(devhelpHtmlDirectory);
+ DevHelpParser p = new DevHelpParser(devhelpHtmlDirectory, true);
File dir = new File(devhelpHtmlDirectory);
File[] files = dir.listFiles();
for (int i = 0; i < files.length; ++i) {
File f = files[i];
String name = f.getName();
- p.parse(f.getAbsolutePath() + "/" + name + ".devhelp", //$NON-NLS-1$ //$NON-NLS-2$
+ p.parse(f.getAbsolutePath() + "/" + name + ".devhelp2", //$NON-NLS-1$ //$NON-NLS-2$
new NullProgressMonitor());
}
LibHoverInfo hover = p.getLibHoverInfo();

Back to the top