Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Overholt2011-02-28 03:12:53 +0000
committerAndrew Overholt2011-02-28 03:12:53 +0000
commit3ebedfbfca945e023c292dbde119602f1e1f160c (patch)
tree56be0cbf92cba968f7033b340726b81d77fb2d2c
parent64538c827345a597a22cbfeac14b1d4813670756 (diff)
parentf12486ef4e4fd423d0d06055019063b8509ef2e4 (diff)
downloadorg.eclipse.linuxtools-3ebedfbfca945e023c292dbde119602f1e1f160c.tar.gz
org.eclipse.linuxtools-3ebedfbfca945e023c292dbde119602f1e1f160c.tar.xz
org.eclipse.linuxtools-3ebedfbfca945e023c292dbde119602f1e1f160c.zip
Merge libhover 0.6.0
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover-feature/ChangeLog74
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover-feature/build.properties4
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover-feature/feature.properties138
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover-feature/feature.xml59
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover-feature/license.html107
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.glibc/ChangeLog42
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.glibc/META-INF/MANIFEST.MF9
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.glibc/build.properties6
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.glibc/plugin.properties12
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.glibc/plugin.xml23
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/ChangeLog33
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/META-INF/MANIFEST.MF9
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/build.properties6
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/plugin.properties12
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/ChangeLog33
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/about.html26
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/build.properties7
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/plugin.properties12
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/src/org/eclipse/linuxtools/cdt/libhover/libstdcxx/DoxygenCPPInfo.java537
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/ChangeLog37
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/build.properties4
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/feature.properties138
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/feature.xml34
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/license.html107
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.newlib/ChangeLog32
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.newlib/plugin.properties12
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/.classpath6
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/.project17
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/ChangeLog55
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/README12
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/build.xml15
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseAutoconfTexinfo.java645
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseAutomakeTexinfo.java661
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseGlibcTexinfo.java881
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseNewlibTexinfo.java564
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/TexinfoUtils.java733
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover/ChangeLog196
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover/META-INF/MANIFEST.MF21
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover/about.html26
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover/build.properties10
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover/plugin.properties14
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover/plugin.xml12
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/cdt/libhover/LibhoverPlugin.java79
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/cdt/libhover/MemberInfo.java133
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/internal/cdt/libhover/LibHover.java575
-rw-r--r--libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/internal/cdt/libhover/LibHoverLibrary.java218
46 files changed, 6386 insertions, 0 deletions
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover-feature/ChangeLog b/libhover/org.eclipse.linuxtools.cdt.libhover-feature/ChangeLog
new file mode 100644
index 0000000000..ceb0d5cc18
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover-feature/ChangeLog
@@ -0,0 +1,74 @@
+2010-05-18 Andrew Overholt <overholt@redhat.com>
+
+ * feature.properties: Fix provider name.
+
+2010-04-26 Andrew Overholt <overholt@redhat.com>
+
+ * feature.properties: Match consistent license text (bug #306627). Update
+ copyright year.
+ * license.html: New file. HTML version of SUA (bug #306627).
+ * build.properties: Include license.html.
+ * about.html: Remove.
+ * feature.xml: Use licenseURL property instead of explicit URL.
+
+2010-04-12 Andrew Overholt <overholt@redhat.com>
+
+ * feature.properties: Match consistent license text (bug #306627).
+
+2010-02-08 Andrew Overholt <overholt@redhat.com>
+
+ * feature.properties: Capitalize "library" in featureName.
+
+2009-11-10 Andrew Overholt <overholt@redhat.com>
+
+ * feature.properties: Make featureName a bit more user-friendly.
+
+2009-08-07 Jeff Johnston <jjohnstn@redhat.com>
+
+ * feature.xml: Remove newlib as included feature.
+
+2009-08-05 Andrew Overholt <overholt@redhat.com>
+
+ * feature.xml: Rename to org.eclipse.linuxtools.cdt.libhover.
+
+2009-05-19 Andrew Overholt <overholt@redhat.com>
+
+ Bug #273931
+
+ * feature.properties: Change provider from Eclipse.org to Eclipse.
+
+2009-05-11 Jeff Johnston <jjohnstn@redhat.com>
+
+ * feature.xml: Bump up to 0.2.0. Add libhover newlib feature as
+ optional included feature. Add libhover libstdcxx plugin.
+
+2009-01-15 Jeff Johnston <jjohnstn@redhat.com>
+
+ * feature.xml: Bump up to 0.1.1.
+
+2009-01-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ * feature.xml: Add .qualifier to version id.
+
+2009-01-06 Andrew Overholt <overholt@redhat.com>
+
+ * feature.xml: 1.0.0 -> 0.1.0. Add update site information.
+ * build.properties: Add feature.properties and epl-v10.html.
+
+2008-10-31 Andrew Overholt <overholt@redhat.com>
+
+ * feature.xml: Use feature.properties. Add "(Incubation)".
+ * feature.properties: Initial checkin.
+ * epl-v10.html: Likewise.
+
+2008-10-16 Jeff Johnston <jjohnstn@redhat.com>
+
+ * feature.xml: Add org.eclipse.linuxtools.cdt.libhover.library_docs plugin.
+ Also change org.eclipse.linuxtools.cdt.libhover.glibc reference to be plugin
+ instead of fragment.
+
+2008-10-14 Jeff Johnston <jjohnstn@redhat.com>
+
+ * feature.xml: Initial check-in.
+ * about.html: Ditto.
+ * build.properties: Ditto.
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover-feature/build.properties b/libhover/org.eclipse.linuxtools.cdt.libhover-feature/build.properties
new file mode 100644
index 0000000000..b74af86fe4
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover-feature/build.properties
@@ -0,0 +1,4 @@
+bin.includes = feature.xml,\
+ feature.properties,\
+ epl-v10.html,\
+ license.html
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover-feature/feature.properties b/libhover/org.eclipse.linuxtools.cdt.libhover-feature/feature.properties
new file mode 100644
index 0000000000..4e97962f79
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover-feature/feature.properties
@@ -0,0 +1,138 @@
+#################################################################################
+# Copyright (c) 2008 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Red Hat Incorporated - initial API and implementation
+#################################################################################
+featureName=C/C++ Library API Documentation Hover Help (Incubation)
+description=Plugins for C/C++ library hover help.
+provider=Eclipse Linux Tools
+copyright=Copyright 2008, 2009, 2010 Red Hat, Inc.
+licenseURL=license.html
+license=\
+Eclipse Foundation Software User Agreement\n\
+April 14, 2010\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
+OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
+USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
+AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
+NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
+AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
+AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
+OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
+OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the\n\
+Eclipse Foundation is provided to you under the terms and conditions of\n\
+the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\
+provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
+For purposes of the EPL, "Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code,\n\
+documentation and other files maintained in the Eclipse Foundation source code\n\
+repository ("Repository") in software modules ("Modules") and made available\n\
+as downloadable archives ("Downloads").\n\
+\n\
+ - Content may be structured and packaged into modules to facilitate delivering,\n\
+ extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
+ plug-in fragments ("Fragments"), and features ("Features").\n\
+ - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\
+ in a directory named "plugins".\n\
+ - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
+ Each Feature may be packaged as a sub-directory in a directory named "features".\n\
+ Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
+ numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
+ - Features may also include other Features ("Included Features"). Within a Feature, files\n\
+ named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be\n\
+contained in files named "about.html" ("Abouts"). The terms and\n\
+conditions governing Features and Included Features should be contained\n\
+in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
+Licenses may be located in any directory of a Download or Module\n\
+including, but not limited to the following locations:\n\
+\n\
+ - The top-level (root) directory\n\
+ - Plug-in and Fragment directories\n\
+ - Inside Plug-ins and Fragments packaged as JARs\n\
+ - Sub-directories of the directory named "src" of certain Plug-ins\n\
+ - Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
+Provisioning Technology (as defined below), you must agree to a license ("Feature \n\
+Update License") during the installation process. If the Feature contains\n\
+Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform\n\
+you where you can locate them. Feature Update Licenses may be found in\n\
+the "license" property of files named "feature.properties" found within a Feature.\n\
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\
+terms and conditions (or references to such terms and conditions) that\n\
+govern your use of the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\
+TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
+SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+ - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
+ - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
+ - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
+ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
+ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
+TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\
+is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
+govern that particular Content.\n\
+\n\
+\n\Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which include,\n\
+but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\
+the purpose of allowing users to install software, documentation, information and/or\n\
+other materials (collectively "Installable Software"). This capability is provided with\n\
+the intent of allowing such users to install, extend and update Eclipse-based products.\n\
+Information about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install Installable Software.\n\
+You shall be responsible for enabling the applicable license agreements relating to the\n\
+Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\
+in accordance with the Specification. By using Provisioning Technology in such a manner and\n\
+making it available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the following:\n\
+\n\
+ 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\
+ the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\
+ extending or updating the functionality of an Eclipse-based product.\n\
+ 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\
+ Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\
+ 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\
+ govern the use of the Installable Software ("Installable Software Agreement") and such\n\
+ Installable Software Agreement shall be accessed from the Target Machine in accordance\n\
+ with the Specification. Such Installable Software Agreement must inform the user of the\n\
+ terms and conditions that govern the Installable Software and must solicit acceptance by\n\
+ the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\
+ indication of agreement by the user, the provisioning Technology will complete installation\n\
+ of the Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are\n\
+currently may have restrictions on the import, possession, and use,\n\
+and/or re-export to another country, of encryption software. BEFORE\n\
+using any encryption software, please check the country's laws,\n\
+regulations and policies concerning the import, possession, or use, and\n\
+re-export of encryption software, to see if this is permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover-feature/feature.xml b/libhover/org.eclipse.linuxtools.cdt.libhover-feature/feature.xml
new file mode 100644
index 0000000000..4525993d9a
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover-feature/feature.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.eclipse.linuxtools.cdt.libhover"
+ label="%featureName"
+ version="0.2.0.qualifier"
+ provider-name="%provider">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <url>
+ <update label="Linux Tools Update Site" url="http://download.eclipse.org/technology/linuxtools/update"/>
+ </url>
+
+ <requires>
+ <import plugin="org.eclipse.ui" version="3.4.0" match="compatible"/>
+ <import plugin="org.eclipse.core.runtime" version="3.4.0" match="compatible"/>
+ <import plugin="org.eclipse.core.resources" version="3.4.0" match="compatible"/>
+ <import plugin="org.eclipse.help" version="3.3.100" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.cdt.ui" version="5.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.core.filesystem" version="1.2.0" match="greaterOrEqual"/>
+ </requires>
+
+ <plugin
+ id="org.eclipse.linuxtools.cdt.libhover"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.cdt.libhover.library_docs"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.cdt.libhover.glibc"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
+ <plugin
+ id="org.eclipse.linuxtools.cdt.libhover.libstdcxx"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover-feature/license.html b/libhover/org.eclipse.linuxtools.cdt.libhover-feature/license.html
new file mode 100644
index 0000000000..c184ca36a9
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover-feature/license.html
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Foundation Software User Agreement</title>
+</head>
+
+<body lang="EN-US">
+<h2>Eclipse Foundation Software User Agreement</h2>
+<p>April 14, 2010</p>
+
+<h3>Usage Of Content</h3>
+
+<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
+ (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
+ CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
+ OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
+ NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
+ CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
+
+<h3>Applicable Licenses</h3>
+
+<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
+ (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+ For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
+ repository (&quot;Repository&quot;) in software modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
+
+<ul>
+ <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
+ <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
+ <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
+ and/or Fragments associated with that Feature.</li>
+ <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
+</ul>
+
+<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
+Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
+including, but not limited to the following locations:</p>
+
+<ul>
+ <li>The top-level (root) directory</li>
+ <li>Plug-in and Fragment directories</li>
+ <li>Inside Plug-ins and Fragments packaged as JARs</li>
+ <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
+ <li>Feature directories</li>
+</ul>
+
+<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license (&quot;Feature Update License&quot;) during the
+installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
+inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
+that directory.</p>
+
+<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
+
+<ul>
+ <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
+ <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
+ <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
+ <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
+ <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
+</ul>
+
+<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
+contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
+
+
+<h3>Use of Provisioning Technology</h3>
+
+<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
+ Update Manager (&quot;Provisioning Technology&quot;) for the purpose of allowing users to install software, documentation, information and/or
+ other materials (collectively &quot;Installable Software&quot;). This capability is provided with the intent of allowing such users to
+ install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a
+ href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a>
+ (&quot;Specification&quot;).</p>
+
+<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
+ applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
+ in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
+ Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p>
+
+<ol>
+ <li>A series of actions may occur (&quot;Provisioning Process&quot;) in which a user may execute the Provisioning Technology
+ on a machine (&quot;Target Machine&quot;) with the intent of installing, extending or updating the functionality of an Eclipse-based
+ product.</li>
+ <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
+ accessed and copied to the Target Machine.</li>
+ <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
+ Software (&quot;Installable Software Agreement&quot;) and such Installable Software Agreement shall be accessed from the Target
+ Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
+ the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
+ indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li>
+</ol>
+
+<h3>Cryptography</h3>
+
+<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
+ another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
+ possession, or use, and re-export of encryption software, to see if this is permitted.</p>
+
+<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p>
+</body>
+</html>
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/ChangeLog b/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/ChangeLog
new file mode 100644
index 0000000000..7201d35f18
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/ChangeLog
@@ -0,0 +1,42 @@
+2009-08-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ Resolves #285867
+ * plugin.properties: Change Provider to Eclipse instead of Eclipse.org.
+
+2009-02-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ * META-INF/MANIFEST.MF: Bump up version to 1.0.1.
+ * plugin.xml: Change to use new libhover library interface which requires
+ the location of a serialized LibHoverInfo instance rather than an xml document.
+
+2009-01-15 Jeff Johnston <jjohnstn@redhat.com>
+
+ * META-INF/MANIFEST.MF: Add .qualifier to version.
+
+2008-11-03 Andrew Overholt <overholt@redhat.com>
+
+ * build.properties: Add plugin.properties.
+
+2008-10-31 Andrew Overholt <overholt@redhat.com>
+
+ * plugin.properties: Initial checkin.
+ * META-INF/MANIFEST.MF: Use plugin.properties. Add "(Incubation)".
+
+2008-10-22 Jeff Johnston <jjohnstn@redhat.com>
+
+ * plugin.xml: Modify library name which shows up in the Project properties C/C++ General
+ Documentation page.
+
+2008-10-16 Jeff Johnston <jjohnstn@redhat.com>
+
+ * build.properties: Add toc.xml to binary build files.
+
+2008-10-15 Jeff Johnston <jjohnstn@redhat.com>
+
+ * fragment.xml: Removed.
+ * plugin.xml: New file.
+ * build.properties: Specify about.html in src build.
+ * META-INF/MANIFEST.MF: Require org.eclipse.linuxtools.cdt.libhover.library-docs
+ instead of org.eclipse.linuxtools.cdt.autotools-docs.
+ * toc.xml: Change to use moreclibdocs anchor instead of moregnutools
+ anchor which is in autotools-docs.
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/META-INF/MANIFEST.MF b/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..29e9546217
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.linuxtools.cdt.libhover.glibc;singleton:=true
+Bundle-Version: 1.0.1.qualifier
+Bundle-Vendor: %provider
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.linuxtools.cdt.libhover.library_docs;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/build.properties b/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/build.properties
new file mode 100644
index 0000000000..25f40f9cef
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/build.properties
@@ -0,0 +1,6 @@
+bin.includes = META-INF/,\
+ plugin.xml,\
+ toc.xml,\
+ about.html,\
+ plugin.properties
+src.includes = about.html
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/plugin.properties b/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/plugin.properties
new file mode 100644
index 0000000000..47221bacb2
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2008 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Red Hat Incorporated - initial API and implementation
+#################################################################################
+bundleName=Glibc Libhover (Incubation)
+provider=Eclipse Linux Tools \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/plugin.xml b/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/plugin.xml
new file mode 100644
index 0000000000..4556b44f00
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.glibc/plugin.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ id="library"
+ name="Glibc C Library"
+ point="org.eclipse.linuxtools.cdt.libhover.library">
+ <library
+ docs="http://www.gnu.org/software/libc/manual/html_node/index.html"
+ location="http://www.sourceware.org/eclipse/libhover/glibc-2.7-2.libhover"
+ name="glibc library"
+ type="C">
+ </library>
+ </extension>
+ <extension
+ point="org.eclipse.help.toc">
+ <toc
+ file="toc.xml"
+ primary="false">
+ </toc>
+ </extension>
+
+</plugin>
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/ChangeLog b/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/ChangeLog
new file mode 100644
index 0000000000..71d4d7fa0b
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/ChangeLog
@@ -0,0 +1,33 @@
+2010-06-14 Andrew Overholt <overholt@redhat.com>
+
+ * build.properties: Add about.html to binary build.
+
+2009-08-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ Resolves #285867
+ * plugin.properties: Change Provider to Eclipse instead of Eclipse.org.
+
+2009-01-15 Jeff Johnston <jjohnstn@redhat.com>
+
+ * META-INF/MANIFEST.MF: Add .qualifier to version and bump to 1.0.1.
+
+2008-11-03 Jeff Johnston <jjohnstn@redhat.com>
+
+ * build.properties: Remove doc.zip.
+ * doc.zip: Removed.
+
+2008-11-03 Andrew Overholt <overholt@redhat.com>
+
+ * build.properties: Add plugin.properties.
+
+2008-10-31 Andrew Overholt <overholt@redhat.com>
+
+ * plugin.properties: Initial import.
+ * META-INF/MANIFEST.MF: Use plugin.propeties. Add "(Incubation)".
+
+2008-10-15 Jeff Johnston <jjohnstn@redhat.com>
+
+ * toc.xml: Initial release.
+ * doc.zip: Ditto.
+ * plugin.xml: Ditto.
+ * about.html: Ditto. \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/META-INF/MANIFEST.MF b/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..f5fd146af1
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.linuxtools.cdt.libhover.library_docs;singleton:=true
+Bundle-Version: 1.0.1.qualifier
+Bundle-Vendor: %provider
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.help
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/build.properties b/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/build.properties
new file mode 100644
index 0000000000..d193508857
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/build.properties
@@ -0,0 +1,6 @@
+bin.includes = META-INF/,\
+ plugin.xml,\
+ toc.xml,\
+ plugin.properties,\
+ about.html
+
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/plugin.properties b/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/plugin.properties
new file mode 100644
index 0000000000..37063b74e2
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.library-docs/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2008 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Red Hat Incorporated - initial API and implementation
+#################################################################################
+bundleName=Libhover C/C++ Library Documentation Plug-in (Incubation)
+provider=Eclipse Linux Tools \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/ChangeLog b/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/ChangeLog
new file mode 100644
index 0000000000..ae928bb42d
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/ChangeLog
@@ -0,0 +1,33 @@
+2009-08-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ Resolves #285867
+ * plugin.properties: Change Provider to Eclipse instead of Eclipse.org.
+
+2009-08-05 Jeff Johnston <jjohnstn@redhat.com>
+
+ * plugin.properties: New file to fill in bundlename and provider.
+
+2009-05-08 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/org/eclipse/linuxtools/cdt/libhover/libstdcxx/DoxygenCPPInfo.java (getParameters):
+ New method.
+ (getReturn): Ditto.
+ (buildDoxygenCPPInfo): Add code to get detailed description and break this up into
+ parameters and return value. For return type, use refid to find a referenced class.
+ (getElementText): Fix to be recursive.
+
+2009-02-10 Jeff Johnston <jjohnstn@redhat.com>
+
+ * .project: New file.
+ * toc.xml: Add missing toc file referenced by plugin.
+
+2009-02-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ * plugin.xml: Initial creation.
+ * plugin.properties: Ditto.
+ * toc.xml: Ditto.
+ * build.properties: Ditto.
+ * META-INF/MANIFEST.MF: Ditto.
+ * about.html: Ditto.
+ * src/org/eclipse/linuxtools/cdt/libhover/libstdcxx/DoxygenCPPInfo.java: New file
+ for creating serialized LibHover info from libstdc++ Doxygen xml documentation. \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/about.html b/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/about.html
new file mode 100644
index 0000000000..23506a4bae
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/about.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/build.properties b/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/build.properties
new file mode 100644
index 0000000000..628824f7ab
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/build.properties
@@ -0,0 +1,7 @@
+bin.includes = META-INF/,\
+ plugin.xml,\
+ toc.xml,\
+ about.html,\
+ plugin.properties
+src.includes = about.html,\
+ src/
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/plugin.properties b/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/plugin.properties
new file mode 100644
index 0000000000..f041f39c8f
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2009 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Red Hat Incorporated - initial API and implementation
+#################################################################################
+bundleName=Libstdc++ Libhover (Incubation)
+provider=Eclipse Linux Tools \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/src/org/eclipse/linuxtools/cdt/libhover/libstdcxx/DoxygenCPPInfo.java b/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/src/org/eclipse/linuxtools/cdt/libhover/libstdcxx/DoxygenCPPInfo.java
new file mode 100644
index 0000000000..bb139e83a2
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.libstdcxx/src/org/eclipse/linuxtools/cdt/libhover/libstdcxx/DoxygenCPPInfo.java
@@ -0,0 +1,537 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.cdt.libhover.libstdcxx;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.linuxtools.cdt.libhover.LibHoverInfo;
+import org.eclipse.linuxtools.cdt.libhover.ClassInfo;
+import org.eclipse.linuxtools.cdt.libhover.MemberInfo;
+import org.eclipse.linuxtools.cdt.libhover.TypedefInfo;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+
+public class DoxygenCPPInfo {
+
+ private Document document;
+ private LibHoverInfo cppInfo = new LibHoverInfo();
+ private HashMap<String, ClassInfo> classesById = new HashMap<String, ClassInfo>();
+
+ public DoxygenCPPInfo(Document document) {
+ this.document = document;
+ }
+
+ public Document getDocument() {
+ return document;
+ }
+
+ private String[] getTypedefTypes(String def) {
+ String[] result = null;
+ if (def.startsWith("typedef ")) { // $NON-NLS-1$
+ int startIndex = 8;
+ int count = 0;
+ int i = def.length() - 1;
+ // To break up types, we look for first blank outside of a template, working backwards.
+ // We need to work backwards because the transformed type may contain actual numeric parameters
+ // which could use the shift operators and we won't know whether they are shift operators or
+ // template specifiers without some actual parsing.
+ while (i >= 0) {
+ char ch = def.charAt(i);
+ if (ch == '<') {
+ --count;
+ }
+ else if (ch == '>') {
+ ++count;
+ }
+ // We look at last blank not in a template as being the delimeter between
+ // type name and definition.
+ if (count == 0 && ch == ' ') {
+ startIndex = i + 1;
+ break;
+ }
+ --i;
+ }
+ result = new String[2];
+ result[1] = def.substring(startIndex);
+ // Following is a bit of a hack knowing the docs don't add the namespace when the transformed
+ // type is in the same space
+ int namespace = result[1].indexOf("::"); // $NON-NLS-1$
+ if (namespace < 0)
+ result[0] = def.substring(8, startIndex).trim();
+ else
+ result[0] = result[1].substring(0, namespace) + "::" + def.substring(8, startIndex).trim(); // $NON-NLS-1$
+ }
+ return result;
+ }
+
+ private String getElementText(Node node) {
+ StringBuffer d = new StringBuffer();
+ NodeList nl = node.getChildNodes();
+ for (int x = 0; x < nl.getLength(); ++x) {
+ Node text = nl.item(x);
+ if (text.getNodeType() == Node.TEXT_NODE)
+ d.append(text.getNodeValue());
+ else
+ d.append(getElementText(text));
+ }
+ return d.toString();
+ }
+
+ public ClassInfo getClassInfo(String className) {
+ String typedefName = className.replaceAll("<.*>", "<>"); // $NON-NLS-1$ // $NON-NLS-2$
+ TypedefInfo typedef = cppInfo.typedefs.get(typedefName);
+ if (typedef != null) {
+ className = typedef.getTransformedType(className); // Reset class name to typedef transformation
+ }
+ int index = className.indexOf('<');
+ // Check if it is a template reference.
+ if (index != -1) {
+ // It is. We want to see if there are partial specific templates
+ // and we choose the first match. If nothing matches our particular
+ // case, we fall back on the initial generic template.
+ ClassInfo info = cppInfo.classes.get(className.substring(0, index));
+ if (info == null)
+ return null;
+ ArrayList<ClassInfo> children = info.getChildren();
+ if (children != null && children.size() > 0) {
+ for (int x = 0; x < children.size(); ++x) {
+ ClassInfo child = children.get(x);
+ if (className.matches(child.getClassName())) {
+ info = child;
+ break;
+ }
+ }
+ }
+ return info;
+ }
+ // Otherwise no template, just fetch the class info directly.
+ return cppInfo.classes.get(className);
+ }
+
+ public void buildDoxygenCPPInfo(String fileName) {
+ try {
+ // Create a hash table of all the class nodes mapped by class name. Trim any template info
+ // for the class name key value.
+ NodeList nl = getDocument().getElementsByTagName("compounddef"); // $NON-NLS-1$
+ for (int i = 0; i < nl.getLength(); ++i) {
+ Node n = nl.item(i);
+ NamedNodeMap attrs = n.getAttributes();
+ Node kind = attrs.getNamedItem("kind"); // $NON-NLS-1$
+ Node id = attrs.getNamedItem("id"); // $NON-NLS-1$
+ Node prot = attrs.getNamedItem("prot"); // $NON-NLS-1$
+ // We are only interested in cataloging public classes.
+ if (id != null && prot != null && prot.getNodeValue().equals("public") // $NON-NLS-1$
+ && kind != null && kind.getNodeValue().equals("class")) { // $NON-NLS-1$
+ NodeList nl2 = n.getChildNodes();
+ ClassInfo d = null;
+ String hashName = null;
+ for (int j = 0; j < nl2.getLength(); ++j) {
+ Node n2 = nl2.item(j);
+ String name2 = n2.getNodeName();
+ if (name2.equals("compoundname")) { // $NON-NLS-1$
+ String text = n2.getTextContent();
+ if (text != null && !text.equals("")) {
+ String className = text;
+ text = text.replaceAll("<\\s*", "<"); // $NON-NLS-1$ // $NON-NLS-2$
+ text = text.replaceAll("\\s*>", ">"); // $NON-NLS-1$ // $NON-NLS-2$
+ int index = text.indexOf('<');
+ hashName = text;
+ if (index > 0)
+ hashName = text.substring(0, index);
+ d = new ClassInfo(className, id.getNodeValue(), n);
+ classesById.put(id.getNodeValue(), d);
+ ClassInfo e = cppInfo.classes.get(hashName);
+ if (e != null) { /* We are dealing with a partial specific template...add it to list */
+ if (!d.areTemplateParmsFilled())
+ d.setTemplateParms(getTemplateParms(n));
+ String[] templateParms = d.getTemplateParms();
+ // For each template parameter, replace with a generic regex so later we can compare
+ // and identify a match (e.g. A<_a, _b> and A<char, _b> are defined and we have an instance
+ // of A<char, int>. We want to to match with A<char, _b> and replace all occurrences of "_b"
+ // with "int". For speed, we assume that the template parameter is not a subset of any
+ // other variable (e.g. if _A is used, there is no __A or _AB). If this proves untrue in
+ // any instance, more refinement of the initial value to replace will be required.
+ for (int k = 0; k < templateParms.length; ++k) {
+ text = text.replaceAll(templateParms[k], "[a-zA-Z0-9_: *]+"); // $NON-NLS-1$
+ }
+ d.setClassName(text);
+ e.addTemplate(d);
+ }
+ else
+ cppInfo.classes.put(hashName, d);
+ }
+ } else if (name2.equals("templateparamlist")) {
+ ArrayList<String> templates = new ArrayList<String>();
+ NodeList params = n2.getChildNodes();
+ int paramsLength = params.getLength();
+ for (int j2 = 0; j2 < paramsLength; ++j2) {
+ Node n3 = params.item(j2);
+ if (n3.getNodeName().equals("param")) {
+ NodeList types = n3.getChildNodes();
+ int typesLength = types.getLength();
+ for (int j3 = 0; j3 < typesLength; ++j3) {
+ Node n4 = types.item(j3);
+ if (n4.getNodeName().equals("declname")) {
+ templates.add(getElementText(n4));
+ }
+ }
+ }
+ }
+ String[] templateNames = new String[templates.size()];
+ d.setTemplateParms(templates.toArray(templateNames));
+ } else if (name2.equals("includes")) { // $NON-NLS-1$
+ String include = getElementText(n2);
+ if (d != null)
+ d.setInclude(include);
+ } else if (name2.equals("basecompoundref")) { // $NON-NLS-1$
+ // We have a base class. If public, add it to the list of nodes to look at in case we don't find the member
+ // in the current class definition.
+ NamedNodeMap m = n2.getAttributes();
+ if (m != null) {
+ Node refid = m.getNamedItem("refid"); // $NON-NLS-1$
+ Node prot2 = m.getNamedItem("prot"); // $NON-NLS-1$
+ if (prot2 != null && prot2.getNodeValue().equals("public")) { // $NON-NLS-1$
+ ClassInfo baseClass = null;
+ if (refid != null) {
+ // If we have been given the id of the base class, fetch it directly
+ baseClass = classesById.get(refid.getNodeValue());
+ } else {
+ // We probably have a template that needs resolution
+ String baseClassName = n2.getTextContent();
+// System.out.println("base class name is " + baseClassName);
+ baseClass = getClassInfo(baseClassName);
+ }
+ if (d != null && baseClass != null)
+ d.addBaseClass(baseClass);
+ }
+ }
+ } else if (name2.equals("sectiondef")) { // $NON-NLS-1$
+ // We are only interested in public member functions which are in their own section.
+ NamedNodeMap m = n2.getAttributes();
+ if (m != null) {
+ Node kind2 = m.getNamedItem("kind"); // $NON-NLS-1$
+ if (kind2 != null && kind2.getNodeValue().equals("public-func")) { // $NON-NLS-1$
+ NodeList pubfuncs = n2.getChildNodes();
+ int pubfuncLength = pubfuncs.getLength();
+ for (int j1 = 0; j1 < pubfuncLength; ++j1) {
+ Node n3 = pubfuncs.item(j1);
+ // Add all public member functions to the list of members
+ if (n3.getNodeName().equals("memberdef")) { // $NON-NLS-1$
+ NamedNodeMap m3 = n3.getAttributes();
+ if (m3 != null) {
+ Node m3Kind = m3.getNamedItem("kind"); // $NON-NLS-1$
+ if (m3Kind != null && m3Kind.getNodeValue().equals("function")) { // $NON-NLS-1$
+ String name = null;
+ String type = null;
+ String args = null;
+ String desc = null;
+ ArrayList<String> parms = new ArrayList<String>();
+ NodeList nl4 = n3.getChildNodes();
+ int memberLength = nl4.getLength();
+ for (int k = 0; k < memberLength; ++k) {
+ Node n4 = nl4.item(k);
+ String n4Name = n4.getNodeName();
+ if (n4Name.equals("type")) { // $NON-NLS-1$
+ NodeList nl5 = n4.getChildNodes();
+ type = new String(""); // $NON-NLS-1$
+ for (int x = 0; x < nl5.getLength(); ++x) {
+ Node n5 = nl5.item(x);
+ if (n5.getNodeType() == Node.TEXT_NODE)
+ type += n5.getNodeValue();
+ else if (n5.getNodeName().equals("ref")) { // $NON-NLS-1$
+ NamedNodeMap n5m = n5.getAttributes();
+ Node n5id = n5m.getNamedItem("refid");
+ if (n5id != null) {
+ String refid = n5id.getNodeValue();
+ ClassInfo refClass = classesById.get(refid);
+ if (refClass != null)
+ type += refClass.getClassName();
+ }
+ }
+ }
+ } else if (n4Name.equals("name")) { // $NON-NLS-1$
+ name = n4.getTextContent();
+ } else if (n4Name.equals("argsstring")) { // $NON-NLS-1$
+ args = getElementText(n4);
+ } else if (n4Name.equals("param")) { // $NON-NLS-1$
+ NodeList nl5 = n4.getChildNodes();
+ for (int x = 0; x < nl5.getLength(); ++x) {
+ Node n5 = nl5.item(x);
+ if (n5.getNodeName().equals("type")) { // $NON-NLS-1$
+ parms.add(getElementText(n5));
+ }
+ }
+ } else if (n4Name.equals("briefdescription")) { // $NON-NLS-1$
+ NodeList nl5 = n4.getChildNodes();
+ for (int x = 0; x < nl5.getLength(); ++x) {
+ Node n5 = nl5.item(x);
+ if (n5.getNodeName().equals("para")) { // $NON-NLS-1$
+ if (desc == null)
+ desc = new String("");
+ desc += "<p>" + getElementText(n5) + "</p>"; // $NON-NLS-1$ // $NON-NLS-2$
+ }
+ }
+ } else if (n4Name.equals("detaileddescription")) { // $NON-NLS-1$
+ NodeList nl5 = n4.getChildNodes();
+ for (int x = 0; x < nl5.getLength(); ++x) {
+ Node n5 = nl5.item(x);
+ if (n5.getNodeName().equals("para")) { // $NON-NLS-1$
+ if (desc == null)
+ desc = new String(""); // $NON-NLS-1$
+ NodeList nl6 = n5.getChildNodes();
+ Node n6 = nl6.item(0);
+ if (n6.getNodeType() == Node.TEXT_NODE)
+ desc += "<p>" + getElementText(n5) + "</p>"; // $NON-NLS-1$ // $NON-NLS-2$
+ else {
+ for (int x2 = 0; x2 < nl6.getLength(); ++x2) {
+ n6 = nl6.item(x2);
+ if (n6.getNodeName().equals("parameterlist")) { // $NON-NLS-1$
+ desc += getParameters(n6);
+ } else if (n6.getNodeName().equals("simplesect")) { // $NON-NLS-1$
+ desc += getReturn(n6);
+ }
+ }
+ }
+ }
+ }
+ } else if (n4Name.equals("location")) {
+ // Location is after all descriptions so we can now add the member
+ if (name != null) {
+ MemberInfo member = new MemberInfo(name);
+ member.setReturnType(type);
+ member.setPrototype(args);
+ member.setDescription(desc);
+ String[] argNames = new String[parms.size()];
+ member.setParamTypes(parms.toArray(argNames));
+ d.addMember(member);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ // Create a hash table of all the typedefs. Keep any template info.
+ nl = getDocument().getElementsByTagName("memberdef"); // $NON-NLS-1$
+ for (int i = 0; i < nl.getLength(); ++i) {
+ Node n = nl.item(i);
+ NamedNodeMap attrs = n.getAttributes();
+ if (attrs != null) {
+ Node kind = attrs.getNamedItem("kind"); // $NON-NLS-1$
+ Node prot = attrs.getNamedItem("prot"); // $NON-NLS-1$
+ if (kind != null && kind.getNodeValue().equals("typedef") // $NON-NLS-1$
+ && prot != null && prot.getNodeValue().equals("public")) { // $NON-NLS-1$
+ NodeList list = n.getChildNodes();
+ for (int x = 0; x < list.getLength(); ++x) {
+ Node n2 = list.item(x);
+ if (n2.getNodeName().equals("definition")) { // $NON-NLS-1$
+ String def = n2.getTextContent();
+ if (def != null && !def.equals("")) {
+ def = def.replaceAll("<\\s*", "<"); // $NON-NLS-1$ // $NON-NLS-2$
+ def = def.replaceAll("\\s*>", ">"); // $NON-NLS-1$ // $NON-NLS-2$
+ String[] types = getTypedefTypes(def);
+ TypedefInfo d = new TypedefInfo(types[1], types[0]);
+ String hashName = d.getTypedefName();
+ int index = hashName.indexOf('<');
+ if (index > 0) {
+ String className = hashName.substring(0, index);
+ hashName = hashName.replaceAll("<.*>", "<>"); // $NON-NLS-1$ // $NON-NLS-2$
+ ClassInfo e = cppInfo.classes.get(className);
+ if (e == null)
+ break;
+ ArrayList<ClassInfo> children = e.getChildren();
+ if (children != null && children.size() > 0) {
+ for (int y = 0; y < children.size(); ++y) {
+ ClassInfo child = children.get(y);
+ String childName = child.getClassName().replaceAll("\\*", "\\\\*"); // $NON-NLS-1$ // $NON-NLS-2$
+ childName = childName.replace("[]", "\\[\\]"); // $NON-NLS-1$ // $NON-NLS-2$
+ if (types[1].matches(childName.concat("::.*"))) { // $NON-NLS-1$
+ e = child;
+ break;
+ }
+ }
+ }
+ String[] templates = e.getTemplateParms();
+ d.copyTemplates(templates);
+
+ TypedefInfo f = cppInfo.typedefs.get(hashName);
+ if (f != null) {
+ String typedefName = d.getTypedefName();
+ for (int z = 0; z < templates.length; ++z) {
+ typedefName = typedefName.replaceAll(templates[z], "[a-zA-Z0-9_: ]+"); // $NON-NLS-1$
+ }
+ d.setTypedefName(typedefName);
+ f.addTypedef(d);
+ }
+ else
+ cppInfo.typedefs.put(hashName, d);
+ break;
+ } else {
+ // Otherwise we have a non-template typedef name. Just add it to the list.
+ cppInfo.typedefs.put(hashName, d);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ // Now, output the LibHoverInfo for caching later
+ FileOutputStream f = new FileOutputStream(fileName);
+ ObjectOutputStream out = new ObjectOutputStream(f);
+ out.writeObject(cppInfo);
+ out.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String getParameters(Node n6) {
+ String desc = "<br><br><h3>Parameters:</h3>";
+ NodeList nl = n6.getChildNodes();
+ for (int x = 0; x < nl.getLength(); ++x) {
+ Node n = nl.item(x);
+ if (n.getNodeName().equals("parameteritem")) {
+ NodeList nl2 = n.getChildNodes();
+ for (int y = 0; y < nl2.getLength(); ++y) {
+ Node n2 = nl2.item(y);
+ if (n2.getNodeName().equals("parameternamelist")) {
+ NodeList nl3 = n2.getChildNodes();
+ for (int z = 0; z < nl3.getLength(); ++z) {
+ Node n3 = nl3.item(z);
+ if (n3.getNodeName().equals("parametername")) {
+ desc += getElementText(n3) + " - ";
+ }
+ }
+ } else if (n2.getNodeName().equals("parameterdescription")) {
+ desc += getElementText(n2) + "<br>";
+ }
+
+ }
+ }
+ }
+ return desc;
+
+ }
+
+ private String getReturn(Node n6) {
+ String desc = "";
+ NamedNodeMap m = n6.getAttributes();
+ Node kind = m.getNamedItem("kind");
+ if (kind != null && kind.getNodeValue().equals("return")) {
+ desc += "<br><h3>Returns:</h3>" + getElementText(n6) + "<br>";
+ }
+ return desc;
+ }
+
+ public String[] getTemplateParms(Node classNode) {
+ Node n = null;
+ ArrayList<String> templateArray = new ArrayList<String>();
+ NodeList list = classNode.getChildNodes();
+ for (int i = 0; i < list.getLength(); ++i) {
+ n = list.item(i);
+ if (n.getNodeName().equals("templateparamlist")) { // $NON-NLS-1$
+ break;
+ }
+ }
+ if (n != null) {
+ NodeList templateList = n.getChildNodes();
+ for (int j = 0; j < templateList.getLength(); ++j) {
+ Node p = templateList.item(j);
+ if (p.getNodeName().equals("param")) { // $NON-NLS-1$
+ NodeList paramList = p.getChildNodes();
+ for (int k = 0; k < paramList.getLength(); ++k) {
+ Node q = paramList.item(k);
+ if (q.getNodeName().equals("declname")) { // $NON-NLS-1$
+ String templateName = q.getTextContent();
+ templateArray.add(templateName);
+ }
+ }
+ }
+ }
+ }
+ String[] templates = new String[templateArray.size()];
+ return templateArray.toArray(templates);
+ }
+
+ /**
+ * Create LibHoverInfo serialized output
+ *
+ * @param args (args[0] = location of Doxygen xml document to parse (file or URL),
+ * args[1] = name of file to put serialized LibHoverInfo
+ */
+ public static void main(String[] args) {
+ URI acDoc;
+ try {
+ acDoc = new URI(args[0]);
+ IPath p = URIUtil.toPath(acDoc);
+ InputStream docStream = null;
+ if (p == null) {
+ URL url = acDoc.toURL();
+ docStream = url.openStream();
+ } else {
+ docStream = new FileInputStream(p.toFile());
+ }
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(docStream);
+ if (doc != null) {
+ DoxygenCPPInfo d = new DoxygenCPPInfo(doc);
+ d.buildDoxygenCPPInfo(args[1]);
+ }
+ System.out.println("Built " + args[1] + " from " + args[0]);
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ParserConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/ChangeLog b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/ChangeLog
new file mode 100644
index 0000000000..5ba8f46191
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/ChangeLog
@@ -0,0 +1,37 @@
+2010-05-18 Andrew Overholt <overholt@redhat.com>
+
+ * feature.properties: Fix provider name.
+
+2010-04-26 Andrew Overholt <overholt@redhat.com>
+
+ * feature.properties: Match consistent license text (bug #306627). Update
+ copyright year.
+ * license.html: New file. HTML version of SUA (bug #306627).
+ * build.properties: Include license.html.
+ * about.html: Remove.
+ * feature.xml: Use licenseURL property instead of explicit URL.
+
+2010-04-12 Andrew Overholt <overholt@redhat.com>
+
+ * feature.properties: Match consistent license text (bug #306627).
+
+2009-08-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ Resolves #285867
+ * feature.properties: Change provider to Eclipse instead of Eclipse.org.
+
+2009-08-05 Andrew Overholt <overholt@redhat.com>
+
+ * feature.xml: Add ".qualifier" to version.
+
+2009-08-05 Andrew Overholt <overholt@redhat.com>
+
+ * feature.xml: Rename to org.eclipse.linuxtools.cdt.libhover.newlib.
+
+2009-05-08 Jeff Johnston <jjohnstn@redhat.com>
+
+ * about.html: Initial check-in.
+ * build.properties: Ditto.
+ * epl-v10.html: Ditto.
+ * feature.properties: Ditto.
+ * feature.xml: Ditto. \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/build.properties b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/build.properties
new file mode 100644
index 0000000000..39b0777e50
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/build.properties
@@ -0,0 +1,4 @@
+bin.includes = feature.xml,\
+ epl-v10.html,\
+ feature.properties,\
+ license.html
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/feature.properties b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/feature.properties
new file mode 100644
index 0000000000..176e37e504
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/feature.properties
@@ -0,0 +1,138 @@
+#################################################################################
+# Copyright (c) 2008 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Red Hat Incorporated - initial API and implementation
+#################################################################################
+featureName=Libhover for Newlib Feature (Incubation)
+description=Hover help plugins for maintaining C projects using newlib.
+provider=Eclipse Linux Tools
+copyright=Copyright 2009, 2010 Red Hat, Inc.
+licenseURL=license.html
+license=\
+Eclipse Foundation Software User Agreement\n\
+April 14, 2010\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
+OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
+USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
+AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
+NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
+AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
+AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
+OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
+OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the\n\
+Eclipse Foundation is provided to you under the terms and conditions of\n\
+the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\
+provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
+For purposes of the EPL, "Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code,\n\
+documentation and other files maintained in the Eclipse Foundation source code\n\
+repository ("Repository") in software modules ("Modules") and made available\n\
+as downloadable archives ("Downloads").\n\
+\n\
+ - Content may be structured and packaged into modules to facilitate delivering,\n\
+ extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
+ plug-in fragments ("Fragments"), and features ("Features").\n\
+ - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\
+ in a directory named "plugins".\n\
+ - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
+ Each Feature may be packaged as a sub-directory in a directory named "features".\n\
+ Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
+ numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
+ - Features may also include other Features ("Included Features"). Within a Feature, files\n\
+ named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be\n\
+contained in files named "about.html" ("Abouts"). The terms and\n\
+conditions governing Features and Included Features should be contained\n\
+in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
+Licenses may be located in any directory of a Download or Module\n\
+including, but not limited to the following locations:\n\
+\n\
+ - The top-level (root) directory\n\
+ - Plug-in and Fragment directories\n\
+ - Inside Plug-ins and Fragments packaged as JARs\n\
+ - Sub-directories of the directory named "src" of certain Plug-ins\n\
+ - Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
+Provisioning Technology (as defined below), you must agree to a license ("Feature \n\
+Update License") during the installation process. If the Feature contains\n\
+Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform\n\
+you where you can locate them. Feature Update Licenses may be found in\n\
+the "license" property of files named "feature.properties" found within a Feature.\n\
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\
+terms and conditions (or references to such terms and conditions) that\n\
+govern your use of the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\
+TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
+SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+ - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
+ - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
+ - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
+ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
+ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
+TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\
+is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
+govern that particular Content.\n\
+\n\
+\n\Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which include,\n\
+but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\
+the purpose of allowing users to install software, documentation, information and/or\n\
+other materials (collectively "Installable Software"). This capability is provided with\n\
+the intent of allowing such users to install, extend and update Eclipse-based products.\n\
+Information about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install Installable Software.\n\
+You shall be responsible for enabling the applicable license agreements relating to the\n\
+Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\
+in accordance with the Specification. By using Provisioning Technology in such a manner and\n\
+making it available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the following:\n\
+\n\
+ 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\
+ the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\
+ extending or updating the functionality of an Eclipse-based product.\n\
+ 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\
+ Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\
+ 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\
+ govern the use of the Installable Software ("Installable Software Agreement") and such\n\
+ Installable Software Agreement shall be accessed from the Target Machine in accordance\n\
+ with the Specification. Such Installable Software Agreement must inform the user of the\n\
+ terms and conditions that govern the Installable Software and must solicit acceptance by\n\
+ the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\
+ indication of agreement by the user, the provisioning Technology will complete installation\n\
+ of the Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are\n\
+currently may have restrictions on the import, possession, and use,\n\
+and/or re-export to another country, of encryption software. BEFORE\n\
+using any encryption software, please check the country's laws,\n\
+regulations and policies concerning the import, possession, or use, and\n\
+re-export of encryption software, to see if this is permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/feature.xml b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/feature.xml
new file mode 100644
index 0000000000..e55649399a
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/feature.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.eclipse.linuxtools.cdt.libhover.newlib"
+ label="%featureName"
+ version="1.0.0.qualifier"
+ provider-name="%provider">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <url>
+ <update label="Linux Tools Update Site" url="http://download.eclipse.org/technology/linuxtools/update"/>
+ </url>
+
+ <requires>
+ <import plugin="org.eclipse.linuxtools.cdt.libhover.library_docs" version="1.0.0" match="greaterOrEqual"/>
+ </requires>
+
+ <plugin
+ id="org.eclipse.linuxtools.cdt.libhover.newlib"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
+</feature>
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/license.html b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/license.html
new file mode 100644
index 0000000000..c184ca36a9
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib-feature/license.html
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Foundation Software User Agreement</title>
+</head>
+
+<body lang="EN-US">
+<h2>Eclipse Foundation Software User Agreement</h2>
+<p>April 14, 2010</p>
+
+<h3>Usage Of Content</h3>
+
+<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
+ (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
+ CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
+ OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
+ NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
+ CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
+
+<h3>Applicable Licenses</h3>
+
+<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
+ (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+ For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
+ repository (&quot;Repository&quot;) in software modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
+
+<ul>
+ <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
+ <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
+ <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
+ and/or Fragments associated with that Feature.</li>
+ <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
+</ul>
+
+<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
+Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
+including, but not limited to the following locations:</p>
+
+<ul>
+ <li>The top-level (root) directory</li>
+ <li>Plug-in and Fragment directories</li>
+ <li>Inside Plug-ins and Fragments packaged as JARs</li>
+ <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
+ <li>Feature directories</li>
+</ul>
+
+<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license (&quot;Feature Update License&quot;) during the
+installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
+inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
+that directory.</p>
+
+<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
+
+<ul>
+ <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
+ <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
+ <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
+ <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
+ <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
+</ul>
+
+<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
+contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
+
+
+<h3>Use of Provisioning Technology</h3>
+
+<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
+ Update Manager (&quot;Provisioning Technology&quot;) for the purpose of allowing users to install software, documentation, information and/or
+ other materials (collectively &quot;Installable Software&quot;). This capability is provided with the intent of allowing such users to
+ install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a
+ href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a>
+ (&quot;Specification&quot;).</p>
+
+<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
+ applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
+ in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
+ Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p>
+
+<ol>
+ <li>A series of actions may occur (&quot;Provisioning Process&quot;) in which a user may execute the Provisioning Technology
+ on a machine (&quot;Target Machine&quot;) with the intent of installing, extending or updating the functionality of an Eclipse-based
+ product.</li>
+ <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
+ accessed and copied to the Target Machine.</li>
+ <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
+ Software (&quot;Installable Software Agreement&quot;) and such Installable Software Agreement shall be accessed from the Target
+ Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
+ the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
+ indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li>
+</ol>
+
+<h3>Cryptography</h3>
+
+<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
+ another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
+ possession, or use, and re-export of encryption software, to see if this is permitted.</p>
+
+<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p>
+</body>
+</html>
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.newlib/ChangeLog b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib/ChangeLog
new file mode 100644
index 0000000000..04a4fa75be
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib/ChangeLog
@@ -0,0 +1,32 @@
+2009-08-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ Resolves #285867
+ * plugin.properties: Change Provider to Eclipse instead of Eclipse.org.
+
+2009-02-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ * META-INF/MANIFEST.MF: Bump up version to 1.0.2.
+ * plugin.xml: Change to use new libhover library interface which requires
+ the location of a serialized LibHoverInfo instance rather than an xml document.
+
+2009-01-15 Jeff Johnston <jjohnstn@redhat.com>
+
+ * META-INF/MANIFEST.MF: Add .qualifier to version and bump up to 1.0.1.
+
+2008-11-03 Andrew Overholt <overholt@redhat.com>
+
+ * build.properties: Add plugin.properties.
+
+2008-10-31 Andrew Overholt <overholt@redhat.com>
+
+ * plugin.properties: Initial checkin.
+ * META-INF/MANIFEST.MF: Use plugin.properties. Add "(Incubation)".
+
+2008-10-24 Jeff Johnston <jjohnstn@redhat.com>
+
+ * .project: New plugin for newlib libhover.
+ * META-INF/MANIFEST.MF: New file.
+ * plugin.xml: Ditto.
+ * toc.xml: Ditto.
+ * about.html: Ditto.
+ * build.properties: Ditto. \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.newlib/plugin.properties b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib/plugin.properties
new file mode 100644
index 0000000000..d960c27660
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.newlib/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2008 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Red Hat Incorporated - initial API and implementation
+#################################################################################
+bundleName=Newlib Libhover (Incubation)
+provider=Eclipse Linux Tools \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/.classpath b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/.classpath
new file mode 100644
index 0000000000..fb5011632c
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/.project b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/.project
new file mode 100644
index 0000000000..175b8a50b1
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.cdt.libhover.texinfoparsers</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/ChangeLog b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/ChangeLog
new file mode 100644
index 0000000000..ca197aa37b
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/ChangeLog
@@ -0,0 +1,55 @@
+2009-11-10 Jeff Johnston <jjohnstn@redhat.com>
+
+ Refactor to org.eclipse.linuxtools.cdt.libhover.texinfoparsers.
+
+2008-10-28 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseNewlibTexinfo.java (DeftypefunPattern3): New
+ pattern for matching va_arg functions.
+ (RtnTypeVar): Ditto.
+ (HandleFunctionDefs): Fix so multi-line prototypes are read until the line doesn't
+ end with comma. Also add function pointer and va_arg function type support.
+ * src/com/redhat/eclipse/cdt/autotools/tools/TexinfoUtils.java (transformTags): Fix
+ table handling so like tables can be nested inside each other and/or can have @itemize
+ constructs between tables.
+
+2008-10-24 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseNewlibTexinfo.java: New file.
+ * src/com/redhat/eclipse/cdt/autotools/tools/TexinfoUtils.java (transformTags):
+ Handle @strong{x}.
+
+2007-11-28 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseGlibcTexinfo.java: Fix
+ include regexp to handle the case where a choice of headers are specified
+ with a blank between them. Take the last header in the list in this case.
+ Also clear the global IncludeList whenever an @end deftypefn is seen.
+
+2007-11-26 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseTexinfo.java: Renamed...
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseGlibcTexinfo.java: ...to this.
+ Code has been modified to use new TexinfoUtils class for tag stripping. All
+ lines in synopsis are marked with <eol> at end to allow proper processing.
+ Fixed comment stripping and added @include support for bringing in sample files
+ from examples directory.
+ * src/com/redhat/eclipse/cdt/autotools/tools/TexinfoUtils.java: New file to
+ support proper transformation of texinfo tags into xml format that can be used
+ by a C Help processor. Code was based on old killTags method, but rewritten to
+ handle many more types of scenarios found in glibc docs.
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseAutoconfHTML.java: Add
+ copyright statement.
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseAutoconfTexinfo.java: Ditto.
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseAutomakeTexinfo.java: Ditto.
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseAutoconfHTML.java: Removed.
+
+2007-11-21 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseAutomakeTexinfo.java: New file to
+ parse Automake documentation and create xml files to use with Autotools plugin.
+
+2007-06-18 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/com/redhat/eclipse/cdt/autotools/tools/ParseAutoconfTexinfo.java: New file to
+ parse Autoconf documentation and create xml files to use with Autotools plugin. \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/README b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/README
new file mode 100644
index 0000000000..600b5ec95b
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/README
@@ -0,0 +1,12 @@
+This project contains texinfo parsers used to create xml files for the purpose
+of use with the Linux Tools plug-ins. The parsers here were used to create the
+ xml files for glibc and newlib libhover and for autotools hover help for the
+autoconf editor. The glibc and newlib xml files were fed to the libhover
+plugin BuildFunctionInfos java executable found in the libhover plugin:
+
+ org.eclipse.linuxtools.cdt.libhover.utils/BuildFunctionInfos.java
+
+to create the libhover binary files used in the glibc and newlib libhover
+plugins.
+
+To build, right-click on the build.xml file and run as -> Ant Build.
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/build.xml b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/build.xml
new file mode 100644
index 0000000000..9abc931009
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/build.xml
@@ -0,0 +1,15 @@
+<project name="Texinfo Parser" default="compile" basedir=".">
+ <property name="src" value="."/>
+ <property name="build" value="build"/>
+ <property name="build.compiler" value="modern"/>
+
+ <target name="init">
+ <tstamp/>
+ <mkdir dir="${build}"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="${src}" destdir="${build}" />
+ </target>
+</project>
+ \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseAutoconfTexinfo.java b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseAutoconfTexinfo.java
new file mode 100644
index 0000000000..360d494fd8
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseAutoconfTexinfo.java
@@ -0,0 +1,645 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.cdt.libhover.texinfoparsers;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+//This file contains a texinfo parser that can be
+//run to create the Autotools glibc.xml file.
+//Usage is as follows:
+//1. compile this file using javac
+//2. run this file using java, passing the
+//arguments: ${glibc_source_path}/manual glibc.xml
+
+public class ParseAutoconfTexinfo {
+
+ static final boolean DEBUG = false;
+
+ static final String ATcmd = "(@\\w*)";
+
+ // 0
+ static final String Defmac = "@defmac";
+ static final String Defmacx = "@defmacx";
+
+ // 1
+ static final String MacroName = "(\\w*)";
+ static final int MacroNameIndex = 1;
+
+ // 2 3
+ static final String Parms = "(\\((.*)\\))";
+ static final int ParmsIndex = 2;
+
+ static final String rest = ".*";
+
+ static final String WhiteSpace = "\\s*";
+
+ static final Pattern MacroPattern
+ = Pattern.compile("^" + Defmac + WhiteSpace +
+ MacroName + WhiteSpace +
+ Parms +
+ rest, Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final Pattern MacroPattern2
+ = Pattern.compile("^" + Defmac + WhiteSpace + MacroName + rest,
+ Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final Pattern MacroPatternx
+ = Pattern.compile("^" + Defmacx + WhiteSpace +
+ MacroName + WhiteSpace +
+ Parms +
+ rest, Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final Pattern MacroPatternx2
+ = Pattern.compile("^" + Defmacx + WhiteSpace + MacroName + rest,
+ Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final Pattern ParmBracketPattern = Pattern.compile("\\((.*)\\)");
+ static final Pattern IndexPattern = Pattern.compile("@\\w*index\\s+[a-zA-Z0-9_@\\{\\}]*");
+ static final Pattern IndexPattern2 = Pattern.compile("@\\w*index\\{[a-zA-Z0-9_@\\{\\}]*\\}");
+ static final Pattern ExamplePattern = Pattern.compile("@example");
+ static final Pattern EndExamplePattern = Pattern.compile("@end\\s+example");
+ static final Pattern EnumeratePattern = Pattern.compile("@enumerate");
+ static final Pattern EndEnumeratePattern = Pattern.compile("@end\\s+enumerate");
+ static final Pattern VerbatimPattern = Pattern.compile("@verbatim");
+ static final Pattern ItemPattern = Pattern.compile("@item");
+ static final Pattern NoIndentPattern = Pattern.compile("@noindent");
+ static final Pattern BRPattern = Pattern.compile("&lt;br&gt;");
+ static final Pattern EOLPattern = Pattern.compile("&lt;eol&gt;");
+ static final Pattern EndVerbatimPattern = Pattern.compile("@end\\s+verbatim");
+ static final Pattern TableSampItemPattern = Pattern.compile("(@table\\s*@samp.*)@item\\s*([a-zA-Z_0-9+\\-<>/ ]*)<eol>(.*@end\\s*table)", Pattern.DOTALL);
+ static final Pattern TableAsisItemPattern = Pattern.compile("(@table\\s*@asis.*)@item\\s*([a-zA-Z_0-9+\\-,<>/ ]*)<eol>(.*@end\\s*table)", Pattern.DOTALL);
+ static final Pattern TableSampPattern = Pattern.compile("@table\\s*@samp", Pattern.MULTILINE);
+ static final Pattern TableAsisPattern = Pattern.compile("@table\\s*@asis", Pattern.MULTILINE);
+ static final Pattern EndTablePattern = Pattern.compile("@end\\s+table");
+ static final Pattern DotsPattern = Pattern.compile("@dots\\{\\}");
+ static final Pattern ItemizeMinusPattern= Pattern.compile("@itemize\\s+@minus" + "(.*)" + "@end\\s+itemize", Pattern.MULTILINE);
+ static final Pattern ItemizeBulletPattern= Pattern.compile("@itemize\\s+@bullet" + "(.*)" + "@end\\s+itemize", Pattern.MULTILINE);
+ static final Pattern XrefPattern = Pattern.compile("@xref\\{[^\\}]*\\}", Pattern.MULTILINE);
+ static final Pattern CommandPattern = Pattern.compile("@command\\{([^\\}]*)\\}");
+ static final Pattern KbdPattern = Pattern.compile("@kbd\\{([^\\}]*)\\}");
+ static final Pattern RPattern = Pattern.compile("@r\\{([^\\}]*)\\}");
+ static final Pattern FilePattern = Pattern.compile("@file\\{([^\\}]*)\\}");
+ static final Pattern VarPattern = Pattern.compile("@var\\{([^\\}]*)\\}");
+ static final Pattern OVarPattern = Pattern.compile("@ovar\\{([^\\}]*)\\}");
+ static final Pattern DVarPattern = Pattern.compile("@dvar\\{([^\\},\\,]*),([^\\}]*)\\}");
+ static final Pattern CodePattern = Pattern.compile("@code\\{([^\\}]*)\\}");
+ static final Pattern EmphPattern = Pattern.compile("@emph\\{([^\\}]*)\\}");
+ static final Pattern SampPattern = Pattern.compile("@samp\\{([^\\}]*)\\}");
+ static final Pattern OptionPattern = Pattern.compile("@option\\{([^\\}]*)\\}");
+ static final Pattern TagPattern = Pattern.compile("@\\w*\\{([^\\}]*)\\}");
+ static final Pattern AmpersandPattern = Pattern.compile("&");
+ static final Pattern LeftAnglePattern = Pattern.compile("<");
+ static final Pattern RightAnglePattern = Pattern.compile(">");
+
+
+ private static Map macroMap;
+
+ static class MacroParms {
+ String[] parms;
+ MacroParms nextParms = null;
+
+ public MacroParms(String[] parms) {
+ this.parms = parms;
+ }
+ }
+
+ static class MacroDef {
+ String MacroName;
+ MacroParms Parameters;
+ }
+
+ static class TPElement {
+ String Content;
+ String Synopsis;
+ }
+
+ static class TPDef {
+ String TPType;
+ String TPName;
+ String TPSynopsis;
+ TPElement[] TPElements;
+ Object[] IncludeList;
+ }
+
+ private static String killTagsParms(String tt) {
+ Matcher mm;
+
+ mm = ParmBracketPattern.matcher(tt);
+ tt= mm.replaceAll("$1");
+
+ mm = OVarPattern.matcher(tt);
+ tt = mm.replaceAll("[$1]");
+
+ mm = DVarPattern.matcher(tt);
+ tt = mm.replaceAll("[$1=$2]");
+
+ mm = VarPattern.matcher(tt);
+ tt = mm.replaceAll("$1");
+
+ mm = RPattern.matcher(tt);
+ tt = mm.replaceAll("$1");
+
+ mm = DotsPattern.matcher(tt);
+ tt = mm.replaceAll("...");
+
+ return tt;
+ }
+
+
+ private static String killTags(String tt) {
+ Matcher mm;
+ String ss = "";
+
+ while (ss != tt) {
+ mm = XrefPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = IndexPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = IndexPattern2.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = NoIndentPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = VarPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<VAR>$1</VAR>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = DotsPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<small>...</small>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = CommandPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<CODE>$1</CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = CodePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<CODE>$1</CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = KbdPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<KBD>$1</KBD>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EmphPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<EM>$1</EM>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = FilePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<TT>$1</TT>");
+ }
+
+
+ ss = "";
+ while (ss != tt) {
+ mm = VerbatimPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndVerbatimPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = SampPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<samp>$1</samp>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = OptionPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<samp>$1</samp>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = ExamplePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<TABLE><tr><td>&nbsp;</td><td class=example><pre>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndExamplePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</pre></td></tr></table>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EnumeratePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<OL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndEnumeratePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</OL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableSampItemPattern.matcher(tt);
+ ss = tt;
+ if (mm.matches()) {
+ System.out.println("group 1 is " + mm.group(1));
+ System.out.println("group 2 is " + mm.group(2));
+ System.out.println("group 3 is " + mm.group(3));
+ }
+ tt = mm.replaceAll("$1<DT>'<SAMP>$2</SAMP>'\n<DD>$3");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableAsisItemPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1<DT>$2\n<DD>$3");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableSampPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<DL>\n");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableAsisPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<DL>\n");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndTablePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</DL>");
+ }
+
+ //FIXME: if there ever is a @itemize @bullet within a
+ // @itemize @minus or vice-versa, the following
+ // logic will get it wrong.
+ ss = "";
+ while (ss != tt) {
+ mm = ItemizeMinusPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<UL>$1</UL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = ItemizeBulletPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<OL>$1</OL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = ItemPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<LI>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TagPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1");
+ }
+
+ mm = AmpersandPattern.matcher(tt);
+ tt = mm.replaceAll("&amp;");
+
+ mm = LeftAnglePattern.matcher(tt);
+ tt = mm.replaceAll("&lt;");
+
+ mm = RightAnglePattern.matcher(tt);
+ tt = mm.replaceAll("&gt;");
+
+ // Clean up the eol markers we used to mark end of line for items
+ mm = EOLPattern.matcher(tt);
+ tt = mm.replaceAll("");
+
+ return tt;
+ }
+
+ private static MacroDef BuildMacroDef(Matcher m) {
+ MacroDef md = new MacroDef();
+
+ md.MacroName = m.group(MacroNameIndex);
+
+ if (null != m.group(ParmsIndex)) {
+ String tt = killTagsParms(m.group(ParmsIndex));
+ String[] parms = tt.split(",\\s");
+ md.Parameters = new MacroParms(parms);
+ }
+ return md;
+ }
+
+ private static MacroParms AddMacroDefxParms(MacroParms mp, Matcher mx) {
+ if (null != mx.group(ParmsIndex)) {
+ String tt = killTagsParms(mx.group(ParmsIndex));
+ String[] parms = tt.split(",\\s");
+ MacroParms mpnew = new MacroParms(parms);
+ mp.nextParms = mpnew;
+ return mpnew;
+ }
+ return null;
+ }
+
+ private static MacroDef HandleMacroDef(BufferedReader is, String s) throws IOException {
+ MacroDef fd = null;
+
+ Matcher m = MacroPattern.matcher(s);
+
+ if (m.matches()) {
+ fd = BuildMacroDef(m);
+ }
+ else { // assume the line got split and retry
+ is.mark(100);
+ String il = is.readLine();
+ m = MacroPattern.matcher(s + il);
+ if (m.matches()) fd = BuildMacroDef(m);
+ else {
+ is.reset();
+ m = MacroPattern2.matcher(s);
+ if (m.matches()) {
+ fd = new MacroDef();
+ fd.MacroName = m.group(MacroNameIndex);
+ fd.Parameters = new MacroParms(new String[0]);
+ }
+ }
+ }
+
+ if (fd != null) {
+ // Look for @defmacx which are alternate prototypes for the macro
+ is.mark(100);
+ String il = is.readLine();
+ if (il != null) {
+ Matcher mx = MacroPatternx.matcher(il);
+ Matcher mx2 = MacroPatternx2.matcher(il);
+ MacroParms mp = fd.Parameters;
+ while (mx.matches() || mx2.matches()) {
+ if (mx.matches())
+ mp = AddMacroDefxParms(mp, mx);
+ else {
+ MacroParms mpnew = new MacroParms(new String[0]);
+ mp.nextParms = mpnew;
+ mp = mpnew;
+ }
+ is.mark(100);
+ il = is.readLine();
+ if (il != null) {
+ mx = MacroPatternx.matcher(il);
+ mx2 = MacroPatternx2.matcher(il);
+ }
+ }
+ is.reset();
+ }
+
+ if (macroMap.get(fd.MacroName) != null)
+ return null;
+ macroMap.put(fd.MacroName, fd);
+ }
+
+ return fd;
+ }
+
+ private static void WriteString(BufferedWriter os, String s) throws IOException {
+ // System.out.println(s);
+ os.write(s+"\n", 0, 1+s.length());
+ }
+
+ private static void CreateHeader(BufferedWriter os) throws IOException {
+ WriteString(os, "<!-- This file automatically generated by ParseAutoconfTexinfo utility -->");
+ WriteString(os, "<!-- cvs -d:pserver:anonymous@sources.redhat.com:/cvs/eclipse \\ -->");
+ WriteString(os, "<!-- co autotools/ParseTexinfo -->");
+ WriteString(os, "<!DOCTYPE macros [");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT macros (macro)*>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT macro (prototype*,synopsis)>");
+ WriteString(os, " <!ATTLIST macro");
+ WriteString(os, " id ID #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT synopsis (#PCDATA)*>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT prototype (parameter+)?>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT parameter (#PCDATA)*>");
+ WriteString(os, " <!ATTLIST parameter");
+ WriteString(os, " content CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, "]>");
+ WriteString(os, "");
+ }
+
+
+
+ private static void CreateTrailer(BufferedWriter os) throws IOException {
+ WriteString(os, "</macros>");
+ }
+
+ private static void WriteSynopsis(BufferedWriter os, String Synopsis, boolean indent) throws IOException {
+ String ss = killTags(Synopsis);
+ String[] tt = ss.split("\\s");
+ String aa = "";
+ String spaces = indent ? " " : " ";
+ WriteString(os, spaces + "<synopsis>");
+ if (null != Synopsis) {
+ for (int pp = 0; pp < tt.length; pp++) {
+ if (tt[pp].equals("&lt;br&gt;")) {
+ WriteString(os, spaces + aa + "&lt;/P&gt;&lt;P&gt;\n");
+ aa = "";
+ }
+ else {
+ if ((aa.length() + tt[pp].length()) > 64) {
+ WriteString(os, spaces + aa);
+ aa = "";
+ }
+ aa = aa + " " + tt[pp];
+ }
+ }
+ }
+ if (aa.length() > 0) WriteString(os, " " + aa);
+ WriteString(os, spaces + "</synopsis>");
+ }
+
+ private static void HandleDefmacro(BufferedWriter os, BufferedReader is, String s) throws IOException {
+ String il;
+ MacroDef md;
+ List FDefs = new ArrayList();
+ String Synopsis = null;
+
+ if (null != (md = HandleMacroDef(is, s))) FDefs.add(md);
+
+ while (null != (il = is.readLine())) {
+ if (il.startsWith("@defmac")) {
+ if (null != (md = HandleMacroDef(is, il))) FDefs.add(md);
+ }
+ else if (il.startsWith("@comment") ||
+ il.startsWith("@c ")) { // comment -- ignore it
+ }
+ else if (il.startsWith("@end defmac")) {
+ for (int kk = 0; kk < FDefs.size(); kk++) {
+ md = (MacroDef)FDefs.get(kk);
+
+ WriteString(os, " <macro id=\"" + md.MacroName + "\">");
+
+ MacroParms mp = md.Parameters;
+ do {
+ WriteString(os, " <prototype>");
+ String[] parms = mp.parms;
+ for (int i = 0; i < parms.length; i++) {
+ WriteString(os, " <parameter content=\"" + parms[i] + "\"/>");
+ }
+ WriteString(os, " </prototype>");
+ mp = mp.nextParms;
+ } while (mp != null);
+
+ if (null != Synopsis) WriteSynopsis(os, Synopsis, false);
+
+ WriteString(os, " </macro>");
+ }
+ return;
+ }
+ else {
+ Synopsis = ((Synopsis == null) ? "" : Synopsis + " " ) + ((il.length() == 0) ? "<br>" :
+ il.startsWith("@item") ? il + "<eol>" : il);
+
+ }
+ }
+ FDefs.clear();
+
+ }
+
+ private static class OnlyTexi implements FilenameFilter {
+ public boolean accept(File dir, String s) {
+ return (s.endsWith(".texi")) ? true : false;
+ }
+ }
+
+ public static void BuildXMLFromTexinfo(String srcdir, String dstdir) {
+ try {
+ macroMap = new HashMap();
+ BufferedWriter os = new BufferedWriter(new FileWriter(dstdir));
+
+ CreateHeader(os);
+// CreateLicense(os);
+
+ WriteString(os, "<macros>");
+
+ try {
+ String[] dir = new java.io.File(srcdir).list(new OnlyTexi());
+ for (int i = 0; i < dir.length; i++) {
+ String qFile = srcdir.endsWith("/")
+ ? srcdir + dir[i]
+ : srcdir + "/" + dir[i];
+
+ try {
+ BufferedReader is = new BufferedReader(new FileReader(qFile));
+ String il;
+
+ while (null != (il = is.readLine())) {
+ if (il.startsWith("@defmac")) { // handle @defmac x]
+ HandleDefmacro(os, is, il);
+ }
+ }
+ is.close();
+ }
+ catch (IOException e) {
+ System.out.println("Input File IOException: " + e);
+ return;
+ }
+ }
+ }
+ catch (NullPointerException e) {
+ System.out.println("NullPointerException: " + e);
+ return;
+ }
+
+ CreateTrailer(os);
+
+ os.close();
+ }
+ catch (IOException e) {
+ System.out.println("Output File IOException: " + e);
+ return;
+ }
+ }
+
+ public static void main(String[] args) {
+ // arg[0] is input directory containing .texi documents to read
+ // arg[1] is output xml file to create
+ BuildXMLFromTexinfo(args[0], args[1]);
+ }
+
+}
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseAutomakeTexinfo.java b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseAutomakeTexinfo.java
new file mode 100644
index 0000000000..c61adc026a
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseAutomakeTexinfo.java
@@ -0,0 +1,661 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.cdt.libhover.texinfoparsers;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+//This file contains a texinfo parser that can be
+//run to create the Autotools glibc.xml file.
+//Usage is as follows:
+//1. compile this file using javac
+//2. run this file using java, passing the
+//arguments: dir_to_automake_texi_files output_xml_file_name
+
+public class ParseAutomakeTexinfo {
+
+ static final boolean DEBUG = false;
+
+ static final String ATcmd = "(@\\w*)";
+
+ // Currently in automake docs, the macro section starts with
+ // a subsection as below and a table which contains macros which
+ // are item and itemx entries.
+ static final String MacrosStart = "@subsection\\sPublic\\smacros";
+ static final String OldMacrosStart = "@section\\sAutoconf\\smacros.*";
+ static final Pattern MacroSection1 = Pattern.compile(MacrosStart);
+ static final Pattern MacroSection2 = Pattern.compile(OldMacrosStart);
+ // 0
+ static final String Defmac = "@item";
+ static final String Defmacx = "@itemx";
+
+ // 1
+ static final String MacroName = "(\\w*)";
+ static final int MacroNameIndex = 1;
+
+ // 2 3
+ static final String Parms = "(\\((.*)\\))";
+ static final int ParmsIndex = 2;
+
+ static final String rest = ".*";
+
+ static final String WhiteSpace = "\\s*";
+
+ static final Pattern MacroPattern
+ = Pattern.compile("^" + Defmac + WhiteSpace +
+ MacroName + WhiteSpace +
+ Parms +
+ rest, Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final Pattern MacroPattern2
+ = Pattern.compile("^" + Defmac + WhiteSpace + MacroName + rest,
+ Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final Pattern MacroPatternx
+ = Pattern.compile("^" + Defmacx + WhiteSpace +
+ MacroName + WhiteSpace +
+ Parms +
+ rest, Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final Pattern MacroPatternx2
+ = Pattern.compile("^" + Defmacx + WhiteSpace + MacroName + rest,
+ Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final Pattern ParmBracketPattern = Pattern.compile("\\((.*)\\)");
+ static final Pattern IndexPattern = Pattern.compile("@\\w*index.*");
+ static final Pattern IndexPattern2 = Pattern.compile("@\\w*index\\{[a-zA-Z0-9_@\\{\\}]*\\}");
+ static final Pattern ExamplePattern = Pattern.compile("@example");
+ static final Pattern EndExamplePattern = Pattern.compile("@end\\s+example");
+ static final Pattern EnumeratePattern = Pattern.compile("@enumerate");
+ static final Pattern EndEnumeratePattern = Pattern.compile("@end\\s+enumerate");
+ static final Pattern VerbatimPattern = Pattern.compile("@verbatim");
+ static final Pattern ItemPattern = Pattern.compile("@item");
+ static final Pattern NoIndentPattern = Pattern.compile("@noindent");
+ static final Pattern BRPattern = Pattern.compile("&lt;br&gt;");
+ static final Pattern EOLPattern = Pattern.compile("&lt;eol&gt;");
+ static final Pattern EndVerbatimPattern = Pattern.compile("@end\\s+verbatim");
+ static final Pattern TableSampItemPattern = Pattern.compile("(@table\\s*@samp.*)@item\\s*([a-zA-Z_0-9+\\-<>/ ]*)<eol>(.*@end\\s*table)", Pattern.DOTALL);
+ static final Pattern TableAsisItemPattern = Pattern.compile("(@table\\s*@asis.*)@item\\s*([a-zA-Z_0-9+\\-,<>/ ]*)<eol>(.*@end\\s*table)", Pattern.DOTALL);
+ static final Pattern TableSampPattern = Pattern.compile("@table\\s*@samp", Pattern.MULTILINE);
+ static final Pattern TableAsisPattern = Pattern.compile("@table\\s*@asis", Pattern.MULTILINE);
+ static final Pattern EndTablePattern = Pattern.compile("@end\\s+table");
+ static final Pattern DotsPattern = Pattern.compile("@dots\\{\\}");
+ static final Pattern ItemizeMinusPattern= Pattern.compile("@itemize\\s+@minus" + "(.*)" + "@end\\s+itemize", Pattern.MULTILINE);
+ static final Pattern ItemizeBulletPattern= Pattern.compile("@itemize\\s+@bullet" + "(.*)" + "@end\\s+itemize", Pattern.MULTILINE);
+ static final Pattern XrefPattern = Pattern.compile("@xref\\{[^\\}]*\\}", Pattern.MULTILINE);
+ static final Pattern CommandPattern = Pattern.compile("@command\\{([^\\}]*)\\}");
+ static final Pattern KbdPattern = Pattern.compile("@kbd\\{([^\\}]*)\\}");
+ static final Pattern RPattern = Pattern.compile("@r\\{([^\\}]*)\\}");
+ static final Pattern FilePattern = Pattern.compile("@file\\{([^\\}]*)\\}");
+ static final Pattern VarPattern = Pattern.compile("@var\\{([^\\}]*)\\}");
+ static final Pattern OVarPattern = Pattern.compile("@ovar\\{([^\\}]*)\\}");
+ static final Pattern DVarPattern = Pattern.compile("@dvar\\{([^\\},\\,]*),([^\\}]*)\\}");
+ static final Pattern CodePattern = Pattern.compile("@code\\{([^\\}]*)\\}");
+ static final Pattern EmphPattern = Pattern.compile("@emph\\{([^\\}]*)\\}");
+ static final Pattern SampPattern = Pattern.compile("@samp\\{([^\\}]*)\\}");
+ static final Pattern OptionPattern = Pattern.compile("@option\\{([^\\}]*)\\}");
+ static final Pattern UrefPattern = Pattern.compile("@uref\\{([^,]*),\\s+([^\\}]*)\\}");
+ static final Pattern TagPattern = Pattern.compile("@\\w*\\{([^\\}]*)\\}");
+ static final Pattern AmpersandPattern = Pattern.compile("&");
+ static final Pattern LeftAnglePattern = Pattern.compile("<");
+ static final Pattern RightAnglePattern = Pattern.compile(">");
+
+
+ private static Map macroMap;
+
+ static class MacroParms {
+ String[] parms;
+ MacroParms nextParms = null;
+
+ public MacroParms(String[] parms) {
+ this.parms = parms;
+ }
+ }
+
+ static class MacroDef {
+ String MacroName;
+ MacroParms Parameters;
+ String Synopsis;
+ }
+
+ static class TPElement {
+ String Content;
+ String Synopsis;
+ }
+
+ static class TPDef {
+ String TPType;
+ String TPName;
+ String TPSynopsis;
+ TPElement[] TPElements;
+ Object[] IncludeList;
+ }
+
+ private static String killTagsParms(String tt) {
+ Matcher mm;
+
+ mm = ParmBracketPattern.matcher(tt);
+ tt= mm.replaceAll("$1");
+
+ mm = OVarPattern.matcher(tt);
+ tt = mm.replaceAll("[$1]");
+
+ mm = DVarPattern.matcher(tt);
+ tt = mm.replaceAll("[$1=$2]");
+
+ mm = VarPattern.matcher(tt);
+ tt = mm.replaceAll("$1");
+
+ mm = RPattern.matcher(tt);
+ tt = mm.replaceAll("$1");
+
+ mm = DotsPattern.matcher(tt);
+ tt = mm.replaceAll("...");
+
+ return tt;
+ }
+
+
+ private static String killTags(String tt) {
+ Matcher mm;
+ String ss = "";
+
+ while (ss != tt) {
+ mm = XrefPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = IndexPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = IndexPattern2.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = NoIndentPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = VarPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<VAR>$1</VAR>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = DotsPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<small>...</small>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = CommandPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<CODE>$1</CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = CodePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<CODE>$1</CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = UrefPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<A HREF=\"$1>$2</A>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = KbdPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<KBD>$1</KBD>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EmphPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<EM>$1</EM>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = FilePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<TT>$1</TT>");
+ }
+
+
+ ss = "";
+ while (ss != tt) {
+ mm = VerbatimPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndVerbatimPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = SampPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<samp>$1</samp>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = OptionPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<samp>$1</samp>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = ExamplePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<TABLE><tr><td>&nbsp;</td><td class=example><pre>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndExamplePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</pre></td></tr></table>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EnumeratePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<OL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndEnumeratePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</OL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableSampItemPattern.matcher(tt);
+ ss = tt;
+ if (mm.matches()) {
+ System.out.println("group 1 is " + mm.group(1));
+ System.out.println("group 2 is " + mm.group(2));
+ System.out.println("group 3 is " + mm.group(3));
+ }
+ tt = mm.replaceAll("$1<DT>'<SAMP>$2</SAMP>'\n<DD>$3");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableAsisItemPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1<DT>$2\n<DD>$3");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableSampPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<DL>\n");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableAsisPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<DL>\n");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndTablePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</DL>");
+ }
+
+ //FIXME: if there ever is a @itemize @bullet within a
+ // @itemize @minus or vice-versa, the following
+ // logic will get it wrong.
+ ss = "";
+ while (ss != tt) {
+ mm = ItemizeMinusPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<UL>$1</UL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = ItemizeBulletPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<OL>$1</OL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = ItemPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<LI>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TagPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1");
+ }
+
+ mm = AmpersandPattern.matcher(tt);
+ tt = mm.replaceAll("&amp;");
+
+ mm = LeftAnglePattern.matcher(tt);
+ tt = mm.replaceAll("&lt;");
+
+ mm = RightAnglePattern.matcher(tt);
+ tt = mm.replaceAll("&gt;");
+
+ // Clean up the eol markers we used to mark end of line for items
+ mm = EOLPattern.matcher(tt);
+ tt = mm.replaceAll("");
+
+ return tt;
+ }
+
+ private static MacroDef BuildMacroDef(Matcher m) {
+ MacroDef md = new MacroDef();
+
+ md.MacroName = m.group(MacroNameIndex);
+
+ if (null != m.group(ParmsIndex)) {
+ String tt = killTagsParms(m.group(ParmsIndex));
+ String[] parms = tt.split(",\\s");
+ md.Parameters = new MacroParms(parms);
+ }
+ return md;
+ }
+
+ private static MacroParms AddMacroDefxParms(MacroParms mp, Matcher mx) {
+ if (null != mx.group(ParmsIndex)) {
+ String tt = killTagsParms(mx.group(ParmsIndex));
+ String[] parms = tt.split(",\\s");
+ MacroParms mpnew = new MacroParms(parms);
+ mp.nextParms = mpnew;
+ return mpnew;
+ }
+ return null;
+ }
+
+ private static MacroDef HandleMacroDef(BufferedReader is, String s) throws IOException {
+ MacroDef fd = null;
+
+ Matcher m = MacroPattern.matcher(s);
+
+ if (m.matches()) {
+ fd = BuildMacroDef(m);
+ }
+ else { // assume the line got split and retry
+ is.mark(100);
+ String il = is.readLine();
+ m = MacroPattern.matcher(s + il);
+ if (m.matches()) fd = BuildMacroDef(m);
+ else {
+ is.reset();
+ m = MacroPattern2.matcher(s);
+ if (m.matches()) {
+ fd = new MacroDef();
+ fd.MacroName = m.group(MacroNameIndex);
+ fd.Parameters = new MacroParms(new String[0]);
+ }
+ }
+ }
+
+ if (fd != null) {
+ // Look for @defmacx which are alternate prototypes for the macro
+ is.mark(100);
+ String il = is.readLine();
+ if (il != null) {
+ Matcher mx = MacroPatternx.matcher(il);
+ Matcher mx2 = MacroPatternx2.matcher(il);
+ MacroParms mp = fd.Parameters;
+ while (mx.matches() || mx2.matches()) {
+ if (mx.matches())
+ mp = AddMacroDefxParms(mp, mx);
+ else {
+ MacroParms mpnew = new MacroParms(new String[0]);
+ mp.nextParms = mpnew;
+ mp = mpnew;
+ }
+ is.mark(100);
+ il = is.readLine();
+ if (il != null) {
+ mx = MacroPatternx.matcher(il);
+ mx2 = MacroPatternx2.matcher(il);
+ }
+ }
+ is.reset();
+ }
+
+ if (macroMap.get(fd.MacroName) != null)
+ return null;
+ macroMap.put(fd.MacroName, fd);
+ }
+
+ return fd;
+ }
+
+ private static void WriteString(BufferedWriter os, String s) throws IOException {
+ // System.out.println(s);
+ os.write(s+"\n", 0, 1+s.length());
+ }
+
+ private static void CreateHeader(BufferedWriter os) throws IOException {
+ WriteString(os, "<!-- This file automatically generated by ParseAutomakeTexinfo utility -->");
+ WriteString(os, "<!-- cvs -d:pserver:anonymous@sources.redhat.com:/cvs/eclipse \\ -->");
+ WriteString(os, "<!-- co autotools/ParseTexinfo -->");
+ WriteString(os, "<!DOCTYPE macros [");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT macros (macro)*>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT macro (prototype*,synopsis)>");
+ WriteString(os, " <!ATTLIST macro");
+ WriteString(os, " id ID #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT synopsis (#PCDATA)*>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT prototype (parameter+)?>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT parameter (#PCDATA)*>");
+ WriteString(os, " <!ATTLIST parameter");
+ WriteString(os, " content CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, "]>");
+ WriteString(os, "");
+ }
+
+
+
+ private static void CreateTrailer(BufferedWriter os) throws IOException {
+ WriteString(os, "</macros>");
+ }
+
+ private static void WriteSynopsis(BufferedWriter os, String Synopsis, boolean indent) throws IOException {
+ String ss = Synopsis;
+ String[] tt = ss.split("\\s");
+ String aa = "";
+ String spaces = indent ? " " : " ";
+ WriteString(os, spaces + "<synopsis>");
+ if (null != Synopsis) {
+ for (int pp = 0; pp < tt.length; pp++) {
+ if (tt[pp].equals("&lt;br&gt;")) {
+ WriteString(os, spaces + aa + "&lt;/P&gt;&lt;P&gt;\n");
+ aa = "";
+ }
+ else {
+ if ((aa.length() + tt[pp].length()) > 64) {
+ WriteString(os, spaces + aa);
+ aa = "";
+ }
+ aa = aa + " " + tt[pp];
+ }
+ }
+ }
+ if (aa.length() > 0) WriteString(os, " " + aa);
+ WriteString(os, spaces + "</synopsis>");
+ }
+
+ private static void HandleDefmacro(BufferedWriter os, BufferedReader is, String s) throws IOException {
+ String il;
+ MacroDef md = null;
+ List FDefs = new ArrayList();
+
+ while (null != (il = is.readLine())) {
+ if (il.startsWith(Defmac)) {
+ if (null != (md = HandleMacroDef(is, il))) FDefs.add(md);
+ }
+ else if (il.startsWith("@comment") ||
+ il.startsWith("@c ")) { // comment -- ignore it
+ }
+ else if (il.startsWith("@subsection") ||
+ il.startsWith("@section")) {
+ for (int kk = 0; kk < FDefs.size(); kk++) {
+ md = (MacroDef)FDefs.get(kk);
+
+ WriteString(os, " <macro id=\"" + md.MacroName + "\">");
+
+ MacroParms mp = md.Parameters;
+ do {
+ WriteString(os, " <prototype>");
+ String[] parms = mp.parms;
+ for (int i = 0; i < parms.length; i++) {
+ WriteString(os, " <parameter content=\"" + parms[i] + "\"/>");
+ }
+ WriteString(os, " </prototype>");
+ mp = mp.nextParms;
+ } while (mp != null);
+
+ if (null != md.Synopsis) WriteSynopsis(os, md.Synopsis, false);
+
+ WriteString(os, " </macro>");
+ }
+ return;
+ }
+ else {
+ if (md != null)
+ md.Synopsis = ((md.Synopsis == null) ? "" : md.Synopsis + " " ) + ((il.length() == 0) ? "&lt;br&gt;&lt;br&gt;" :
+ il.startsWith("@item") ? killTags(il) + "<eol>" : killTags(il));
+ }
+ }
+ FDefs.clear();
+
+ }
+
+ private static class OnlyTexi implements FilenameFilter {
+ public boolean accept(File dir, String s) {
+ return (s.endsWith(".texi")) ? true : false;
+ }
+ }
+
+ public static void BuildXMLFromTexinfo(String srcdir, String dstdir) {
+ try {
+ macroMap = new HashMap();
+ BufferedWriter os = new BufferedWriter(new FileWriter(dstdir));
+
+ CreateHeader(os);
+// CreateLicense(os);
+
+ WriteString(os, "<macros>");
+
+ try {
+ String[] dir = new java.io.File(srcdir).list(new OnlyTexi());
+ for (int i = 0; i < dir.length; i++) {
+ String qFile = srcdir.endsWith("/")
+ ? srcdir + dir[i]
+ : srcdir + "/" + dir[i];
+
+ try {
+ BufferedReader is = new BufferedReader(new FileReader(qFile));
+ String il;
+
+ while (null != (il = is.readLine())) {
+ Matcher mm1 = MacroSection1.matcher(il);
+ Matcher mm2 = MacroSection2.matcher(il);
+ if (mm1.matches() || mm2.matches()) {
+ HandleDefmacro(os, is, il);
+ }
+ }
+ is.close();
+ }
+ catch (IOException e) {
+ System.out.println("Input File IOException: " + e);
+ return;
+ }
+ }
+ }
+ catch (NullPointerException e) {
+ System.out.println("NullPointerException: " + e);
+ return;
+ }
+
+ CreateTrailer(os);
+
+ os.close();
+ }
+ catch (IOException e) {
+ System.out.println("Output File IOException: " + e);
+ return;
+ }
+ }
+
+ public static void main(String[] args) {
+ // arg[0] is input directory containing .texi documents to read
+ // arg[1] is output xml file to create
+ BuildXMLFromTexinfo(args[0], args[1]);
+ }
+
+}
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseGlibcTexinfo.java b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseGlibcTexinfo.java
new file mode 100644
index 0000000000..08f657c864
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseGlibcTexinfo.java
@@ -0,0 +1,881 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.cdt.libhover.texinfoparsers;
+import java.io.*;
+import java.util.regex.*;
+import java.util.*;
+
+//This file contains a texinfo parser that can be
+//run to create the Autotools glibc.xml file.
+//Usage is as follows:
+//1. compile this file using javac
+//2. run this file using java, passing the
+//arguments: ${glibc_source_path}/manual glibc.xml
+
+public class ParseGlibcTexinfo {
+ static final boolean DEBUG = false;
+
+ // 1
+ static final String ATcmd = "(@\\w*)";
+
+
+ // 3 4
+ static final String RtnTypeM = "(\\{([^\\}]*)\\})";
+ static final int RtnTypeMIndex = 4;
+
+ // 5
+ static final String RtnTypeS = "(\\w*)";
+ static final int RtnTypeSIndex = 5;
+
+ // 2
+ static final String RtnType = "(" + RtnTypeM + "|" + RtnTypeS + ")";
+ // 6
+ static final String FunctionName = "(\\w*)";
+ static final int FunctionNameIndex = 6;
+
+ // 7 8
+ static final String Parms = "(\\((.*)\\))";
+ static final int ParmsIndex = 8;
+
+ static final String rest = ".*";
+
+ static final String WhiteSpace = "\\s*";
+
+ static final Pattern DeftypefunPattern
+ = Pattern.compile("^" + ATcmd + WhiteSpace +
+ RtnType + WhiteSpace +
+ FunctionName + WhiteSpace +
+ Parms +
+ rest, Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final String TPDataType = "\\{[^\\}]*\\}";
+
+
+ // 3 4
+ static final String TPTypeM = "(\\{([^\\}]*)\\})";
+ static final int TPTypeMIndex = 4;
+
+ // 5
+ static final String TPTypeS = "(\\w*)";
+ static final int TPTypeSIndex = 5;
+
+ // 2
+ static final String TPType = "(" + TPTypeM + "|" + TPTypeS + ")";
+
+ static final Pattern DeftpPattern
+ = Pattern.compile("^" + ATcmd + WhiteSpace + TPDataType + WhiteSpace + TPType + rest,
+ Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final Pattern IncludePattern = Pattern.compile("^@comment ((\\w*/)*\\w*\\.h\\s*)*\\s*$");
+ static final Pattern PindexPattern = Pattern.compile("^@pindex\\s*\\w*\\s*$");
+ static final Pattern ParmBracketPattern = Pattern.compile("\\((.*)\\)");
+ static final Pattern IndexPattern = Pattern.compile("@\\w*index\\s+[a-zA-Z0-9_@\\{\\}]*");
+ static final Pattern IndexPattern2 = Pattern.compile("@\\w*index\\{[a-zA-Z0-9_@\\{\\}]*\\}");
+ static final Pattern ExamplePattern = Pattern.compile("@example");
+ static final Pattern EndExamplePattern = Pattern.compile("@end\\s+example");
+ static final Pattern EnumeratePattern = Pattern.compile("@enumerate");
+ static final Pattern EndEnumeratePattern = Pattern.compile("@end\\s+enumerate");
+ static final Pattern VerbatimPattern = Pattern.compile("@verbatim");
+ static final Pattern ItemPattern = Pattern.compile("@item");
+ static final Pattern NoIndentPattern = Pattern.compile("@noindent");
+ static final Pattern BRPattern = Pattern.compile("&lt;br&gt;");
+ static final Pattern EOLPattern = Pattern.compile("&lt;eol&gt;");
+ static final Pattern EndVerbatimPattern = Pattern.compile("@end\\s+verbatim");
+ static final Pattern TableSampItemPattern = Pattern.compile("(@table\\s*@samp.*)@item\\s*([a-zA-Z_0-9+\\-<>/ ]*)<eol>(.*@end\\s*table)", Pattern.DOTALL);
+ static final Pattern TableAsisItemPattern = Pattern.compile("(@table\\s*@asis.*)@item\\s*([a-zA-Z_0-9+\\-,<>/ ]*)<eol>(.*@end\\s*table)", Pattern.DOTALL);
+ static final Pattern TableSampPattern = Pattern.compile("@table\\s*@samp", Pattern.MULTILINE);
+ static final Pattern TableAsisPattern = Pattern.compile("@table\\s*@asis", Pattern.MULTILINE);
+ static final Pattern EndTablePattern = Pattern.compile("@end\\s+table");
+ static final Pattern DotsPattern = Pattern.compile("@dots\\{\\}");
+ static final Pattern ItemizeMinusPattern= Pattern.compile("@itemize\\s+@minus" + "(.*)" + "@end\\s+itemize", Pattern.MULTILINE);
+ static final Pattern ItemizeBulletPattern= Pattern.compile("@itemize\\s+@bullet" + "(.*)" + "@end\\s+itemize", Pattern.MULTILINE);
+ static final Pattern XrefPattern = Pattern.compile("@xref\\{[^\\}]*\\}", Pattern.MULTILINE);
+ static final Pattern CommandPattern = Pattern.compile("@command\\{([^\\}]*)\\}");
+ static final Pattern KbdPattern = Pattern.compile("@kbd\\{([^\\}]*)\\}");
+ static final Pattern RPattern = Pattern.compile("@r\\{([^\\}]*)\\}");
+ static final Pattern FilePattern = Pattern.compile("@file\\{([^\\}]*)\\}");
+ static final Pattern VarPattern = Pattern.compile("@var\\{([^\\}]*)\\}");
+ static final Pattern OVarPattern = Pattern.compile("@ovar\\{([^\\}]*)\\}");
+ static final Pattern DVarPattern = Pattern.compile("@dvar\\{([^\\},\\,]*),([^\\}]*)\\}");
+ static final Pattern CodePattern = Pattern.compile("@code\\{([^\\}]*)\\}");
+ static final Pattern EmphPattern = Pattern.compile("@emph\\{([^\\}]*)\\}");
+ static final Pattern SampPattern = Pattern.compile("@samp\\{([^\\}]*)\\}");
+ static final Pattern OptionPattern = Pattern.compile("@option\\{([^\\}]*)\\}");
+ static final Pattern TagPattern = Pattern.compile("@\\w*\\{([^\\}]*)\\}");
+ static final Pattern AmpersandPattern = Pattern.compile("&");
+ static final Pattern LeftAnglePattern = Pattern.compile("<");
+ static final Pattern RightAnglePattern = Pattern.compile(">");
+
+ static List IncludeList = new ArrayList();
+
+
+ static class FunctionDef {
+ String ReturnType;
+ String FunctionName;
+ String[] Parameters;
+ Object[] IncludeList;
+ }
+
+ static class TPElement {
+ String Content;
+ String Synopsis;
+ }
+
+ static class TPDef {
+ String TPType;
+ String TPName;
+ String TPSynopsis;
+ TPElement[] TPElements;
+ Object[] IncludeList;
+ }
+
+ private static FunctionDef BuildFunctionDef(Matcher m) {
+ FunctionDef fd = new FunctionDef();
+
+ fd.ReturnType = ((null != m.group(RtnTypeSIndex))
+ ? m.group(RtnTypeSIndex)
+ : m.group(RtnTypeMIndex));
+ fd.FunctionName = m.group(FunctionNameIndex);
+
+ if (null != m.group(ParmsIndex)) {
+ String tt = TexinfoUtils.stripProtoTags(m.group(ParmsIndex));
+ String[] parms = tt.split(",\\s");
+ fd.Parameters = parms;
+ }
+
+ if (IncludeList.size() > 0) {
+ fd.IncludeList = IncludeList.toArray();
+ IncludeList.clear();
+ }
+ return fd;
+ }
+
+ private static void HandleDeftp(BufferedWriter os, BufferedReader is, String s) throws IOException {
+ TPDef td = new TPDef();
+ String il;
+ String Synopsis = null;
+ boolean ItemsAccumulating = false;
+ TPElement tpe = new TPElement();
+ List ElementList = new ArrayList();
+
+ Matcher m = DeftpPattern.matcher(s);
+ if (m.matches()) {
+ if (null != m.group(TPTypeMIndex)) {
+ String[] ss = m.group(TPTypeMIndex).split("\\s");
+ switch(ss.length) {
+ case 0:
+ td.TPType = "";
+ td.TPName = "type";
+ break;
+ case 1:
+ td.TPType = "type";
+ td.TPName = ss[0];
+ break;
+ case 2:
+ td.TPType = ss[0];
+ td.TPName = ss[1];
+ break;
+ default:
+ td.TPType = "type";
+ td.TPName = ss[ss.length - 1];
+ break;
+ }
+ }
+ else {
+ td.TPType = "dtype";
+ td.TPName = m.group(TPTypeSIndex);
+ }
+
+ while (null != (il = is.readLine())) {
+ if (il.startsWith("@end deftp")) {
+ WriteString(os, " <construct id=\"" + td.TPType + "-" + td.TPName
+ + "\" type=\"" + td.TPType + "\">");
+ WriteString(os, " <structure>");
+ if (null != td.TPSynopsis) WriteSynopsis(os, td.TPSynopsis, false);
+ if (ElementList.size() > 0) {
+ WriteString(os, " <elements>");
+ for (int ee = 0; ee < ElementList.size(); ee++) {
+ TPElement ttt = (TPElement)ElementList.get(ee);
+ WriteString(os, " <element content=\"" + ttt.Content + "\">");
+ if (null != ttt.Synopsis) WriteSynopsis(os, ttt.Synopsis, true);
+ WriteString(os, " </element>");
+ }
+ WriteString(os, " </elements>");
+ }
+ WriteString(os, " </structure>");
+ WriteString(os, " </construct>");
+ return;
+ }
+ else if (il.startsWith("@item")) {
+ if (ItemsAccumulating) {
+ tpe.Synopsis = Synopsis;
+ ElementList.add(tpe);
+ }
+ else {
+ td.TPSynopsis = Synopsis;
+ ItemsAccumulating = true;
+ }
+ Synopsis = null;
+ tpe = new TPElement();
+ tpe.Content = TexinfoUtils.transformTags(il.replaceFirst("@item ", ""));
+ }
+ else {
+ if (!il.startsWith("@table"))
+ Synopsis = ((Synopsis == null) ? "" : Synopsis + " " ) + ((il.length() == 0) ? "<br><br>" :
+ il + "<eol>");
+ }
+ }
+ }
+ }
+
+ private static FunctionDef HandleFunctionDef(BufferedReader is, String s) throws IOException {
+ FunctionDef fd;
+
+ Matcher m = DeftypefunPattern.matcher(s);
+
+ if (m.matches()) fd = BuildFunctionDef(m);
+ else { // assume the line got split and retry
+ String il = is.readLine();
+ m = DeftypefunPattern.matcher(s + il);
+ if (m.matches()) fd = BuildFunctionDef(m);
+ else fd = null;
+ }
+
+ return fd;
+ }
+
+ private static void WriteString(BufferedWriter os, String s) throws IOException {
+ // System.out.println(s);
+ os.write(s+"\n", 0, 1+s.length());
+ }
+
+ private static void CreateHeader(BufferedWriter os) throws IOException {
+ WriteString(os, "<!-- This file automatically generated by an Eclipse utility -->");
+ WriteString(os, "<!DOCTYPE descriptions [");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT descriptions (construct)*>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT construct (structure|function)*>");
+ WriteString(os, " <!ATTLIST construct");
+ WriteString(os, " id ID #REQUIRED");
+ WriteString(os, " type CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT structure (synopsis?, elements?)?>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT elements (element*)>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT element (synopsis*)>");
+ WriteString(os, " <!ATTLIST element");
+ WriteString(os, " content CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT synopsis (#PCDATA)*>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT function (prototype,headers?,synopsis)>");
+ WriteString(os, " <!ATTLIST function");
+ WriteString(os, " returntype CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT prototype (parameter+)?>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT parameter (#PCDATA)*>");
+ WriteString(os, " <!ATTLIST parameter");
+ WriteString(os, " content CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT headers (header+)?>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT header (#PCDATA)*>");
+ WriteString(os, " <!ATTLIST header");
+ WriteString(os, " filename CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, "]>");
+ WriteString(os, "");
+ }
+
+// // For now we will use an aggregate document license instead of one per
+// // document.
+// private static void CreateLicense(BufferedWriter os) throws IOException {
+// WriteString(os, "<!--");
+// WriteString(os, "A.1 GNU Free Documentation License");
+// WriteString(os,"Version 1.2, November 2002");
+// WriteString(os, "");
+// WriteString(os, "Copyright &copy; 2000,2001,2002 Free Software Foundation, Inc.");
+// WriteString(os, "59 Temple Place, Suite 330, Boston, MA 02111-1307, USA");
+// WriteString(os, "");
+// WriteString(os, "Everyone is permitted to copy and distribute verbatim copies");
+// WriteString(os, "of this license document, but changing it is not allowed.");
+// WriteString(os, "");
+// WriteString(os, "1. PREAMBLE");
+// WriteString(os, "");
+// WriteString(os, "The purpose of this License is to make a manual, textbook, or other");
+// WriteString(os, "functional and useful document free in the sense of freedom: to");
+// WriteString(os, "assure everyone the effective freedom to copy and redistribute it,");
+// WriteString(os, "with or without modifying it, either commercially or noncommercially.");
+// WriteString(os, "Secondarily, this License preserves for the author and publisher a way");
+// WriteString(os, "to get credit for their work, while not being considered responsible");
+// WriteString(os, "for modifications made by others.");
+// WriteString(os, "");
+// WriteString(os, "This License is a kind of \"copyleft\", which means that derivative");
+// WriteString(os, "works of the document must themselves be free in the same sense. It");
+// WriteString(os, "complements the GNU General Public License, which is a copyleft");
+// WriteString(os, "license designed for free software.");
+// WriteString(os, "");
+// WriteString(os, "We have designed this License in order to use it for manuals for free");
+// WriteString(os, "software, because free software needs free documentation: a free");
+// WriteString(os, "program should come with manuals providing the same freedoms that the");
+// WriteString(os, "software does. But this License is not limited to software manuals;");
+// WriteString(os, "it can be used for any textual work, regardless of subject matter or");
+// WriteString(os, "whether it is published as a printed book. We recommend this License");
+// WriteString(os, "principally for works whose purpose is instruction or reference.");
+// WriteString(os, "");
+// WriteString(os, "2. APPLICABILITY AND DEFINITIONS");
+// WriteString(os, "");
+// WriteString(os, "This License applies to any manual or other work, in any medium, that");
+// WriteString(os, "contains a notice placed by the copyright holder saying it can be");
+// WriteString(os, "distributed under the terms of this License. Such a notice grants a");
+// WriteString(os, "world-wide, royalty-free license, unlimited in duration, to use that");
+// WriteString(os, "work under the conditions stated herein. The \"Document\", below,");
+// WriteString(os, "refers to any such manual or work. Any member of the public is a");
+// WriteString(os, "licensee, and is addressed as \"you\". You accept the license if you");
+// WriteString(os, "copy, modify or distribute the work in a way requiring permission");
+// WriteString(os, "under copyright law.");
+// WriteString(os, "");
+// WriteString(os, "A \"Modified Version\" of the Document means any work containing the");
+// WriteString(os, "Document or a portion of it, either copied verbatim, or with");
+// WriteString(os, "modifications and/or translated into another language.");
+// WriteString(os, "");
+// WriteString(os, "A \"Secondary Section\" is a named appendix or a front-matter section");
+// WriteString(os, "of the Document that deals exclusively with the relationship of the");
+// WriteString(os, "publishers or authors of the Document to the Document's overall");
+// WriteString(os, "subject (or to related matters) and contains nothing that could fall");
+// WriteString(os, "directly within that overall subject. (Thus, if the Document is in");
+// WriteString(os, "part a textbook of mathematics, a Secondary Section may not explain");
+// WriteString(os, "any mathematics.) The relationship could be a matter of historical");
+// WriteString(os, "connection with the subject or with related matters, or of legal,");
+// WriteString(os, "commercial, philosophical, ethical or political position regarding");
+// WriteString(os, "them.");
+// WriteString(os, "");
+// WriteString(os, "The \"Invariant Sections\" are certain Secondary Sections whose titles");
+// WriteString(os, "are designated, as being those of Invariant Sections, in the notice");
+// WriteString(os, "that says that the Document is released under this License. If a");
+// WriteString(os, "section does not fit the above definition of Secondary then it is not");
+// WriteString(os, "allowed to be designated as Invariant. The Document may contain zero");
+// WriteString(os, "Invariant Sections. If the Document does not identify any Invariant");
+// WriteString(os, "Sections then there are none.");
+// WriteString(os, "");
+// WriteString(os, "The \"Cover Texts\" are certain short passages of text that are listed,");
+// WriteString(os, "as Front-Cover Texts or Back-Cover Texts, in the notice that says that");
+// WriteString(os, "the Document is released under this License. A Front-Cover Text may");
+// WriteString(os, "be at most 5 words, and a Back-Cover Text may be at most 25 words.");
+// WriteString(os, "");
+// WriteString(os, "A \"Transparent\" copy of the Document means a machine-readable copy,");
+// WriteString(os, "represented in a format whose specification is available to the");
+// WriteString(os, "general public, that is suitable for revising the document");
+// WriteString(os, "straightforwardly with generic text editors or (for images composed of");
+// WriteString(os, "pixels) generic paint programs or (for drawings) some widely available");
+// WriteString(os, "drawing editor, and that is suitable for input to text formatters or");
+// WriteString(os, "for automatic translation to a variety of formats suitable for input");
+// WriteString(os, "to text formatters. A copy made in an otherwise Transparent file");
+// WriteString(os, "format whose markup, or absence of markup, has been arranged to thwart");
+// WriteString(os, "or discourage subsequent modification by readers is not Transparent.");
+// WriteString(os, "An image format is not Transparent if used for any substantial amount");
+// WriteString(os, "of text. A copy that is not \"Transparent\" is called \"Opaque\".");
+// WriteString(os, "");
+// WriteString(os, "Examples of suitable formats for Transparent copies include plain");
+// WriteString(os, "ASCII without markup, Texinfo input format, LaTeX input");
+// WriteString(os, "format, SGML or XML using a publicly available");
+// WriteString(os, "DTD, and standard-conforming simple HTML,");
+// WriteString(os, "PostScript or PDF designed for human modification. Examples");
+// WriteString(os, "of transparent image formats include PNG, XCF and");
+// WriteString(os, "JPG. Opaque formats include proprietary formats that can be");
+// WriteString(os, "read and edited only by proprietary word processors, SGML or");
+// WriteString(os, "XML for which the DTD and/or processing tools are");
+// WriteString(os, "not generally available, and the machine-generated HTML,");
+// WriteString(os, "PostScript or PDF produced by some word processors for");
+// WriteString(os, "output purposes only.");
+// WriteString(os, "");
+// WriteString(os, "The \"Title Page\" means, for a printed book, the title page itself,");
+// WriteString(os, "plus such following pages as are needed to hold, legibly, the material");
+// WriteString(os, "this License requires to appear in the title page. For works in");
+// WriteString(os, "formats which do not have any title page as such, \"Title Page\" means");
+// WriteString(os, "the text near the most prominent appearance of the work's title,");
+// WriteString(os, "preceding the beginning of the body of the text.");
+// WriteString(os, "");
+// WriteString(os, "A section \"Entitled XYZ\" means a named subunit of the Document whose");
+// WriteString(os, "title either is precisely XYZ or contains XYZ in parentheses following");
+// WriteString(os, "text that translates XYZ in another language. (Here XYZ stands for a");
+// WriteString(os, "specific section name mentioned below, such as \"Acknowledgements\",");
+// WriteString(os, "\"Dedications\", \"Endorsements\", or \"History\".) To \"Preserve the Title\"");
+// WriteString(os, "of such a section when you modify the Document means that it remains a");
+// WriteString(os, "section \"Entitled XYZ\" according to this definition.");
+// WriteString(os, "");
+// WriteString(os, "The Document may include Warranty Disclaimers next to the notice which");
+// WriteString(os, "states that this License applies to the Document. These Warranty");
+// WriteString(os, "Disclaimers are considered to be included by reference in this");
+// WriteString(os, "License, but only as regards disclaiming warranties: any other");
+// WriteString(os, "implication that these Warranty Disclaimers may have is void and has");
+// WriteString(os, "no effect on the meaning of this License.");
+// WriteString(os, "");
+// WriteString(os, "3. VERBATIM COPYING");
+// WriteString(os, "");
+// WriteString(os, "You may copy and distribute the Document in any medium, either");
+// WriteString(os, "commercially or noncommercially, provided that this License, the");
+// WriteString(os, "copyright notices, and the license notice saying this License applies");
+// WriteString(os, "to the Document are reproduced in all copies, and that you add no other");
+// WriteString(os, "conditions whatsoever to those of this License. You may not use");
+// WriteString(os, "technical measures to obstruct or control the reading or further");
+// WriteString(os, "copying of the copies you make or distribute. However, you may accept");
+// WriteString(os, "compensation in exchange for copies. If you distribute a large enough");
+// WriteString(os, "number of copies you must also follow the conditions in section 3.");
+// WriteString(os, "");
+// WriteString(os, "You may also lend copies, under the same conditions stated above, and");
+// WriteString(os, "you may publicly display copies.");
+// WriteString(os, "");
+// WriteString(os, "4. COPYING IN QUANTITY");
+// WriteString(os, "");
+// WriteString(os, "If you publish printed copies (or copies in media that commonly have");
+// WriteString(os, "printed covers) of the Document, numbering more than 100, and the");
+// WriteString(os, "Document's license notice requires Cover Texts, you must enclose the");
+// WriteString(os, "copies in covers that carry, clearly and legibly, all these Cover");
+// WriteString(os, "Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on");
+// WriteString(os, "the back cover. Both covers must also clearly and legibly identify");
+// WriteString(os, "you as the publisher of these copies. The front cover must present");
+// WriteString(os, "the full title with all words of the title equally prominent and");
+// WriteString(os, "visible. You may add other material on the covers in addition.");
+// WriteString(os, "Copying with changes limited to the covers, as long as they preserve");
+// WriteString(os, "the title of the Document and satisfy these conditions, can be treated");
+// WriteString(os, "as verbatim copying in other respects.");
+// WriteString(os, "");
+// WriteString(os, "If the required texts for either cover are too voluminous to fit");
+// WriteString(os, "legibly, you should put the first ones listed (as many as fit");
+// WriteString(os, "reasonably) on the actual cover, and continue the rest onto adjacent");
+// WriteString(os, "pages.");
+// WriteString(os, "");
+// WriteString(os, "If you publish or distribute Opaque copies of the Document numbering");
+// WriteString(os, "more than 100, you must either include a machine-readable Transparent");
+// WriteString(os, "copy along with each Opaque copy, or state in or with each Opaque copy");
+// WriteString(os, "a computer-network location from which the general network-using");
+// WriteString(os, "public has access to download using public-standard network protocols");
+// WriteString(os, "a complete Transparent copy of the Document, free of added material.");
+// WriteString(os, "If you use the latter option, you must take reasonably prudent steps,");
+// WriteString(os, "when you begin distribution of Opaque copies in quantity, to ensure");
+// WriteString(os, "that this Transparent copy will remain thus accessible at the stated");
+// WriteString(os, "location until at least one year after the last time you distribute an");
+// WriteString(os, "Opaque copy (directly or through your agents or retailers) of that");
+// WriteString(os, "edition to the public.");
+// WriteString(os, "");
+// WriteString(os, "It is requested, but not required, that you contact the authors of the");
+// WriteString(os, "Document well before redistributing any large number of copies, to give");
+// WriteString(os, "them a chance to provide you with an updated version of the Document.");
+// WriteString(os, "");
+// WriteString(os, "5. MODIFICATIONS");
+// WriteString(os, "");
+// WriteString(os, "You may copy and distribute a Modified Version of the Document under");
+// WriteString(os, "the conditions of sections 2 and 3 above, provided that you release");
+// WriteString(os, "the Modified Version under precisely this License, with the Modified");
+// WriteString(os, "Version filling the role of the Document, thus licensing distribution");
+// WriteString(os, "and modification of the Modified Version to whoever possesses a copy");
+// WriteString(os, "of it. In addition, you must do these things in the Modified Version:");
+// WriteString(os, "");
+// WriteString(os, " 1. Use in the Title Page (and on the covers, if any) a title distinct");
+// WriteString(os, " from that of the Document, and from those of previous versions");
+// WriteString(os, " (which should, if there were any, be listed in the History section");
+// WriteString(os, " of the Document). You may use the same title as a previous version");
+// WriteString(os, " if the original publisher of that version gives permission.");
+// WriteString(os, "");
+// WriteString(os, " 2. List on the Title Page, as authors, one or more persons or entities");
+// WriteString(os, " responsible for authorship of the modifications in the Modified");
+// WriteString(os, " Version, together with at least five of the principal authors of the");
+// WriteString(os, " Document (all of its principal authors, if it has fewer than five),");
+// WriteString(os, " unless they release you from this requirement.");
+// WriteString(os, "");
+// WriteString(os, " 3. State on the Title page the name of the publisher of the");
+// WriteString(os, " Modified Version, as the publisher.");
+// WriteString(os, "");
+// WriteString(os, " 4. Preserve all the copyright notices of the Document.");
+// WriteString(os, "");
+// WriteString(os, " 5. Add an appropriate copyright notice for your modifications");
+// WriteString(os, " adjacent to the other copyright notices.");
+// WriteString(os, "");
+// WriteString(os, " 6. Include, immediately after the copyright notices, a license notice");
+// WriteString(os, " giving the public permission to use the Modified Version under the");
+// WriteString(os, " terms of this License, in the form shown in the Addendum below.");
+// WriteString(os, "");
+// WriteString(os, " 7. Preserve in that license notice the full lists of Invariant Sections");
+// WriteString(os, " and required Cover Texts given in the Document's license notice.");
+// WriteString(os, "");
+// WriteString(os, " 8. Include an unaltered copy of this License.");
+// WriteString(os, "");
+// WriteString(os, " 9. Preserve the section Entitled \"History\", Preserve its Title, and add");
+// WriteString(os, " to it an item stating at least the title, year, new authors, and");
+// WriteString(os, " publisher of the Modified Version as given on the Title Page. If");
+// WriteString(os, " there is no section Entitled \"History\" in the Document, create one");
+// WriteString(os, " stating the title, year, authors, and publisher of the Document as");
+// WriteString(os, " given on its Title Page, then add an item describing the Modified");
+// WriteString(os, " Version as stated in the previous sentence.");
+// WriteString(os, "");
+// WriteString(os, " 10. Preserve the network location, if any, given in the Document for");
+// WriteString(os, " public access to a Transparent copy of the Document, and likewise");
+// WriteString(os, " the network locations given in the Document for previous versions");
+// WriteString(os, " it was based on. These may be placed in the \"History\" section.");
+// WriteString(os, " You may omit a network location for a work that was published at");
+// WriteString(os, " least four years before the Document itself, or if the original");
+// WriteString(os, " publisher of the version it refers to gives permission.");
+// WriteString(os, "");
+// WriteString(os, " 11. For any section Entitled \"Acknowledgements\" or \"Dedications\", Preserve");
+// WriteString(os, " the Title of the section, and preserve in the section all the");
+// WriteString(os, " substance and tone of each of the contributor acknowledgements and/or");
+// WriteString(os, " dedications given therein.");
+// WriteString(os, "");
+// WriteString(os, " 12. Preserve all the Invariant Sections of the Document,");
+// WriteString(os, " unaltered in their text and in their titles. Section numbers");
+// WriteString(os, " or the equivalent are not considered part of the section titles.");
+// WriteString(os, "");
+// WriteString(os, " 13. Delete any section Entitled \"Endorsements\". Such a section");
+// WriteString(os, " may not be included in the Modified Version.");
+// WriteString(os, "");
+// WriteString(os, " 14. Do not retitle any existing section to be Entitled \"Endorsements\" or");
+// WriteString(os, " to conflict in title with any Invariant Section.");
+// WriteString(os, "");
+// WriteString(os, " 15. Preserve any Warranty Disclaimers.");
+// WriteString(os, "");
+// WriteString(os, "");
+// WriteString(os, "If the Modified Version includes new front-matter sections or");
+// WriteString(os, "appendices that qualify as Secondary Sections and contain no material");
+// WriteString(os, "copied from the Document, you may at your option designate some or all");
+// WriteString(os, "of these sections as invariant. To do this, add their titles to the");
+// WriteString(os, "list of Invariant Sections in the Modified Version's license notice.");
+// WriteString(os, "These titles must be distinct from any other section titles.");
+// WriteString(os, "");
+// WriteString(os, "You may add a section Entitled \"Endorsements\", provided it contains");
+// WriteString(os, "nothing but endorsements of your Modified Version by various");
+// WriteString(os, "parties - for example, statements of peer review or that the text has");
+// WriteString(os, "been approved by an organization as the authoritative definition of a");
+// WriteString(os, "standard.");
+// WriteString(os, "");
+// WriteString(os, "You may add a passage of up to five words as a Front-Cover Text, and a");
+// WriteString(os, "passage of up to 25 words as a Back-Cover Text, to the end of the list");
+// WriteString(os, "of Cover Texts in the Modified Version. Only one passage of");
+// WriteString(os, "Front-Cover Text and one of Back-Cover Text may be added by (or");
+// WriteString(os, "through arrangements made by) any one entity. If the Document already");
+// WriteString(os, "includes a cover text for the same cover, previously added by you or");
+// WriteString(os, "by arrangement made by the same entity you are acting on behalf of,");
+// WriteString(os, "you may not add another; but you may replace the old one, on explicit");
+// WriteString(os, "permission from the previous publisher that added the old one.");
+// WriteString(os, "");
+// WriteString(os, "The author(s) and publisher(s) of the Document do not by this License");
+// WriteString(os, "give permission to use their names for publicity for or to assert or");
+// WriteString(os, "imply endorsement of any Modified Version.");
+// WriteString(os, "");
+// WriteString(os, "6. COMBINING DOCUMENTS");
+// WriteString(os, "");
+// WriteString(os, "You may combine the Document with other documents released under this");
+// WriteString(os, "License, under the terms defined in section 4 above for modified");
+// WriteString(os, "versions, provided that you include in the combination all of the");
+// WriteString(os, "Invariant Sections of all of the original documents, unmodified, and");
+// WriteString(os, "list them all as Invariant Sections of your combined work in its");
+// WriteString(os, "license notice, and that you preserve all their Warranty Disclaimers.");
+// WriteString(os, "");
+// WriteString(os, "The combined work need only contain one copy of this License, and");
+// WriteString(os, "multiple identical Invariant Sections may be replaced with a single");
+// WriteString(os, "copy. If there are multiple Invariant Sections with the same name but");
+// WriteString(os, "different contents, make the title of each such section unique by");
+// WriteString(os, "adding at the end of it, in parentheses, the name of the original");
+// WriteString(os, "author or publisher of that section if known, or else a unique number.");
+// WriteString(os, "Make the same adjustment to the section titles in the list of");
+// WriteString(os, "Invariant Sections in the license notice of the combined work.");
+// WriteString(os, "");
+// WriteString(os, "In the combination, you must combine any sections Entitled \"History\"");
+// WriteString(os, "in the various original documents, forming one section Entitled");
+// WriteString(os, "\"History\"; likewise combine any sections Entitled \"Acknowledgements\",");
+// WriteString(os, "and any sections Entitled \"Dedications\". You must delete all");
+// WriteString(os, "sections Entitled \"Endorsements.\"");
+// WriteString(os, "");
+// WriteString(os, "7. COLLECTIONS OF DOCUMENTS");
+// WriteString(os, "");
+// WriteString(os, "You may make a collection consisting of the Document and other documents");
+// WriteString(os, "released under this License, and replace the individual copies of this");
+// WriteString(os, "License in the various documents with a single copy that is included in");
+// WriteString(os, "the collection, provided that you follow the rules of this License for");
+// WriteString(os, "verbatim copying of each of the documents in all other respects.");
+// WriteString(os, "");
+// WriteString(os, "You may extract a single document from such a collection, and distribute");
+// WriteString(os, "it individually under this License, provided you insert a copy of this");
+// WriteString(os, "License into the extracted document, and follow this License in all");
+// WriteString(os, "other respects regarding verbatim copying of that document.");
+// WriteString(os, "");
+// WriteString(os, "8. AGGREGATION WITH INDEPENDENT WORKS");
+// WriteString(os, "");
+// WriteString(os, "A compilation of the Document or its derivatives with other separate");
+// WriteString(os, "and independent documents or works, in or on a volume of a storage or");
+// WriteString(os, "distribution medium, is called an \"aggregate\" if the copyright");
+// WriteString(os, "resulting from the compilation is not used to limit the legal rights");
+// WriteString(os, "of the compilation's users beyond what the individual works permit.");
+// WriteString(os, "When the Document is included an aggregate, this License does not");
+// WriteString(os, "apply to the other works in the aggregate which are not themselves");
+// WriteString(os, "derivative works of the Document.");
+// WriteString(os, "");
+// WriteString(os, "If the Cover Text requirement of section 3 is applicable to these");
+// WriteString(os, "copies of the Document, then if the Document is less than one half of");
+// WriteString(os, "the entire aggregate, the Document's Cover Texts may be placed on");
+// WriteString(os, "covers that bracket the Document within the aggregate, or the");
+// WriteString(os, "electronic equivalent of covers if the Document is in electronic form.");
+// WriteString(os, "Otherwise they must appear on printed covers that bracket the whole");
+// WriteString(os, "aggregate.");
+// WriteString(os, "");
+// WriteString(os, "9. TRANSLATION");
+// WriteString(os, "");
+// WriteString(os, "Translation is considered a kind of modification, so you may");
+// WriteString(os, "distribute translations of the Document under the terms of section 4.");
+// WriteString(os, "Replacing Invariant Sections with translations requires special");
+// WriteString(os, "permission from their copyright holders, but you may include");
+// WriteString(os, "translations of some or all Invariant Sections in addition to the");
+// WriteString(os, "original versions of these Invariant Sections. You may include a");
+// WriteString(os, "translation of this License, and all the license notices in the");
+// WriteString(os, "Document, and any Warrany Disclaimers, provided that you also include");
+// WriteString(os, "the original English version of this License and the original versions");
+// WriteString(os, "of those notices and disclaimers. In case of a disagreement between");
+// WriteString(os, "the translation and the original version of this License or a notice");
+// WriteString(os, "or disclaimer, the original version will prevail.");
+// WriteString(os, "");
+// WriteString(os, "If a section in the Document is Entitled \"Acknowledgements\",");
+// WriteString(os, "\"Dedications\", or \"History\", the requirement (section 4) to Preserve");
+// WriteString(os, "its Title (section 1) will typically require changing the actual");
+// WriteString(os, "title.");
+// WriteString(os, "");
+// WriteString(os, "10. TERMINATION");
+// WriteString(os, "");
+// WriteString(os, "You may not copy, modify, sublicense, or distribute the Document except");
+// WriteString(os, "as expressly provided for under this License. Any other attempt to");
+// WriteString(os, "copy, modify, sublicense or distribute the Document is void, and will");
+// WriteString(os, "automatically terminate your rights under this License. However,");
+// WriteString(os, "parties who have received copies, or rights, from you under this");
+// WriteString(os, "License will not have their licenses terminated so long as such");
+// WriteString(os, "parties remain in full compliance.");
+// WriteString(os, "");
+// WriteString(os, "11. FUTURE REVISIONS OF THIS LICENSE");
+// WriteString(os, "");
+// WriteString(os, "The Free Software Foundation may publish new, revised versions");
+// WriteString(os, "of the GNU Free Documentation License from time to time. Such new");
+// WriteString(os, "versions will be similar in spirit to the present version, but may");
+// WriteString(os, "differ in detail to address new problems or concerns. See");
+// WriteString(os, "http://www.gnu.org/copyleft/.");
+// WriteString(os, "");
+// WriteString(os, "Each version of the License is given a distinguishing version number.");
+// WriteString(os, "If the Document specifies that a particular numbered version of this");
+// WriteString(os, "License \"or any later version\" applies to it, you have the option of");
+// WriteString(os, "following the terms and conditions either of that specified version or");
+// WriteString(os, "of any later version that has been published (not as a draft) by the");
+// WriteString(os, "Free Software Foundation. If the Document does not specify a version");
+// WriteString(os, "number of this License, you may choose any version ever published (not");
+// WriteString(os, "as a draft) by the Free Software Foundation.");
+// WriteString(os, "-->");
+// }
+
+ private static void CreateTrailer(BufferedWriter os) throws IOException {
+ WriteString(os, "</descriptions>");
+ }
+
+ private static void WriteSynopsis(BufferedWriter os, String Synopsis, boolean indent) throws IOException {
+ String ss = TexinfoUtils.transformTags(Synopsis);
+ String[] tt = ss.split("<eol>");
+ String aa = "";
+ String spaces = indent ? " " : " ";
+ WriteString(os, spaces + "<synopsis>");
+ if (null != Synopsis) {
+ for (int pp = 0; pp < tt.length; pp++) {
+ WriteString(os, spaces + tt[pp]);
+// if (tt[pp].equals("<br>")) {
+// WriteString(os, spaces + aa + "\n");
+// aa = "";
+// }
+// else {
+// if ((aa.length() + tt[pp].length()) > 64) {
+// WriteString(os, spaces + aa);
+// aa = "";
+// }
+// aa = aa + " " + tt[pp];
+// }
+ }
+ }
+ if (aa.length() > 0) WriteString(os, " " + aa);
+ WriteString(os, spaces + "</synopsis>");
+ }
+
+ private static String HandleInclude (String srcdir, String line, String Synopsis) {
+ Pattern p = Pattern.compile("@include\\s+(.*?)\\.texi");
+ Matcher mm = p.matcher(line);
+ if (mm.find()) {
+ String il;
+ try {
+ String fileName = (srcdir.endsWith("/") ? srcdir : srcdir + "/") + mm.replaceAll("examples/$1");
+ BufferedReader is = new BufferedReader(new FileReader(fileName));
+ while (null != (il = is.readLine())) {
+ // C Help does not ignore "<" or ">" inside a <pre> or <samp> tag
+ // so we have to prepare for two levels of indirection. The
+ // first is for xml to interpret and the second is for the
+ // C Help processor to interpret. So, we put &lt; and &gt; which
+ // will be transformed into &amp;lt; by the tag transformer.
+ Pattern p1 = Pattern.compile("<");
+ Pattern p2 = Pattern.compile(">");
+ Matcher mm1 = p1.matcher(il);
+ il = mm1.replaceAll("&lt;");
+ Matcher mm2 = p2.matcher(il);
+ il = mm2.replaceAll("&gt;");
+ Synopsis = ((Synopsis == null) ? "" : Synopsis + " " ) + ((il.length() == 0) ? "<br><br>" :
+ il + "<eol>");
+ }
+ } catch (IOException e) {
+ System.out.println("IOException reading example file");
+ }
+ }
+ return Synopsis;
+ }
+ private static void HandleDeftypefun(BufferedWriter os, BufferedReader is, String s, String srcdir) throws IOException {
+ String il;
+ FunctionDef fd;
+ List FDefs = new ArrayList();
+ String Synopsis = null;
+
+ if (null != (fd = HandleFunctionDef(is, s))) FDefs.add(fd);
+
+ while (null != (il = is.readLine())) {
+ Matcher mm = IncludePattern.matcher(il);
+ if (il.startsWith("@deftypefunx")) {
+ if (null != (fd = HandleFunctionDef(is, il))) FDefs.add(fd);
+ }
+ else if (mm.matches()) {
+ if (!IncludeList.contains(mm.group(1)))
+ IncludeList.add(mm.group(1));
+ }
+ else if (il.startsWith("@comment") ||
+ il.startsWith("@c ") ||
+ il.startsWith("@pindex")) { // ignore
+ }
+ else if (il.startsWith("@include") && fd != null) {
+ Synopsis = HandleInclude(srcdir, il, Synopsis);
+ }
+ else if (il.startsWith("@end deftypefun")) {
+ for (int kk = 0; kk < FDefs.size(); kk++) {
+ fd = (FunctionDef)FDefs.get(kk);
+
+ WriteString(os, " <construct id=\"function-" + fd.FunctionName + "\" type=\"function\">");
+
+ WriteString(os, " <function returntype=\"" + fd.ReturnType + "\">");
+
+ WriteString(os, " <prototype>");
+ String[] parms = fd.Parameters;
+ for (int i = 0; i < parms.length; i++) {
+ String parm = TexinfoUtils.stripProtoTags(parms[i]);
+ WriteString(os, " <parameter content=\"" + parm + "\"/>");
+ }
+ WriteString(os, " </prototype>");
+
+ if (fd.IncludeList != null) {
+ WriteString(os, " <headers>");
+ Object[] incs = fd.IncludeList;
+ for (int j = 0; j < incs.length; j++) {
+ String inc = (String)incs[j];
+ WriteString(os, " <header filename = \"" + inc + "\"/>");
+ }
+ WriteString(os, " </headers>");
+ }
+
+ if (null != Synopsis) WriteSynopsis(os, Synopsis, false);
+
+ WriteString(os, " </function>");
+ WriteString(os, " </construct>");
+ }
+ return;
+ }
+ else {
+ Synopsis = ((Synopsis == null) ? "" : Synopsis + " " ) + ((il.length() == 0) ? "<br><br>" :
+ il + "<eol>");
+ }
+ }
+ FDefs.clear();
+
+ }
+
+ private static class OnlyTexi implements FilenameFilter {
+ public boolean accept(File dir, String s) {
+ return (s.endsWith(".texi")) ? true : false;
+ }
+ }
+
+ public static void BuildXMLFromTexinfo(String srcdir, String dstdir) {
+ try {
+ BufferedWriter os = new BufferedWriter(new FileWriter(dstdir));
+
+ CreateHeader(os);
+// CreateLicense(os);
+
+ WriteString(os, "<descriptions>");
+
+ try {
+ String[] dir = new java.io.File(srcdir).list(new OnlyTexi());
+ for (int i = 0; i < dir.length; i++) {
+ String qFile = srcdir.endsWith("/")
+ ? srcdir + dir[i]
+ : srcdir + "/" + dir[i];
+
+ try {
+ BufferedReader is = new BufferedReader(new FileReader(qFile));
+ String il;
+
+ while (null != (il = is.readLine())) {
+ Matcher mm = IncludePattern.matcher(il);
+ if (il.startsWith("@deftypefun")) { // handle @deftypefun[x]
+ HandleDeftypefun(os, is, il, srcdir);
+ }
+ else if (il.startsWith("@deftp")) { // handle @deftp
+ HandleDeftp(os, is, il);
+ }
+ else if (mm.matches()) { // handle @comment <include_file>
+ if (!IncludeList.contains(mm.group(1)))
+ IncludeList.add(mm.group(1));
+ }
+ else if (il.startsWith("@end deftypefn"))
+ // Handle accumulated header file comments that are in
+ // constructs we aren't parsing.
+ IncludeList.clear();
+ }
+ is.close();
+ }
+ catch (IOException e) {
+ System.out.println("Input File IOException: " + e);
+ return;
+ }
+ }
+ }
+ catch (NullPointerException e) {
+ System.out.println("NullPointerException: " + e);
+ return;
+ }
+
+ CreateTrailer(os);
+
+ os.close();
+ }
+ catch (IOException e) {
+ System.out.println("Output File IOException: " + e);
+ return;
+ }
+ }
+
+ public static void main(String[] args) {
+ BuildXMLFromTexinfo(args[0], args[1]);
+ }
+
+}
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseNewlibTexinfo.java b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseNewlibTexinfo.java
new file mode 100644
index 0000000000..eecce6431a
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/ParseNewlibTexinfo.java
@@ -0,0 +1,564 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.cdt.libhover.texinfoparsers;
+import java.io.*;
+import java.util.regex.*;
+import java.util.*;
+
+//This file contains a texinfo parser that can be
+//run to create the Autotools glibc.xml file.
+//Usage is as follows:
+//1. compile this file using javac
+//2. run this file using java, passing the
+//arguments: ${glibc_source_path}/manual glibc.xml
+
+public class ParseNewlibTexinfo {
+ static final boolean DEBUG = false;
+
+ // 1, 2, 3
+ static final String RtnType = "(\\w+\\s+(\\w+\\s+)?(\\w+\\s+)?\\**)";
+ static final int RtnTypeSIndex = 1;
+
+ // 4
+ static final String FunctionName = "(\\w+)\\s*\\(";
+ static final int FunctionNameIndex = 4;
+
+ // 5 and 6
+ static final String Parms = "((.*)\\))";
+ static final int ParmsIndex = 6;
+
+ static final String rest = ".*";
+
+ static final String WhiteSpace = "\\s*";
+
+ static final Pattern DeftypefunPattern
+ = Pattern.compile("^" + WhiteSpace +
+ RtnType + WhiteSpace +
+ FunctionName + WhiteSpace +
+ Parms +
+ rest, Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ // 1, 2, 3
+ static final String RtnType2 = "(\\w*\\s*(\\w*\\*?\\s+)?(\\w*\\*?\\s+)?\\**\\s*)\\(\\*";
+ static final int RtnType2Index = 1;
+
+ // 4
+ static final String FunctionName2 = "(\\w+)\\s*\\(";
+ static final int FunctionName2Index = 4;
+
+ // 5 and 6
+ static final String Parms2 = "((.*)\\)\\)\\s*)";
+ static final int Parms2Index = 6;
+
+ // 7
+ static final String RtnTypeParms = "(\\(.*\\))";
+ static final int RtnTypeParmsIndex = 7;
+
+ static final Pattern DeftypefunPattern2
+ = Pattern.compile("^" + WhiteSpace +
+ RtnType2 + WhiteSpace +
+ FunctionName2 + WhiteSpace +
+ Parms2 + RtnTypeParms +
+ rest, Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ // For va_arg, the prototype is @var{type} so we create a third type of function definition
+ // and we make it so the return type ends up taking as many groups as the normal RtnType so
+ // the BuildFunctionDef routine can be used without modification.
+ // 1, 2, 3
+ static final String RtnTypeVar = "@var\\{(\\w+)(\\})(\\s)";
+
+ static final Pattern DeftypefunPattern3
+ = Pattern.compile("^" + WhiteSpace +
+ RtnTypeVar + WhiteSpace +
+ FunctionName + WhiteSpace +
+ Parms +
+ rest, Pattern.MULTILINE + Pattern.CASE_INSENSITIVE);
+
+ static final Pattern IncludePattern = Pattern.compile("^#include\\s*<((\\w*/)*\\w*\\.h)>\\s*$");
+ static final Pattern PindexPattern = Pattern.compile("^@pindex\\s*\\w*\\s*$");
+ static final Pattern FindexPattern = Pattern.compile("^@findex\\s*(\\w*)\\s*$");
+ static final Pattern SynopsisPattern = Pattern.compile("^\\s*@strong\\{Synopsis\\}\\s*");
+ static final Pattern ParmBracketPattern = Pattern.compile("\\((.*)\\)");
+ static final Pattern IndexPattern = Pattern.compile("@\\w*index\\s+[a-zA-Z0-9_@\\{\\}]*");
+ static final Pattern IndexPattern2 = Pattern.compile("@\\w*index\\{[a-zA-Z0-9_@\\{\\}]*\\}");
+ static final Pattern ExamplePattern = Pattern.compile("@example");
+ static final Pattern EndExamplePattern = Pattern.compile("@end\\s+example");
+ static final Pattern EnumeratePattern = Pattern.compile("@enumerate");
+ static final Pattern EndEnumeratePattern = Pattern.compile("@end\\s+enumerate");
+ static final Pattern VerbatimPattern = Pattern.compile("@verbatim");
+ static final Pattern ItemPattern = Pattern.compile("@item");
+ static final Pattern NoIndentPattern = Pattern.compile("@noindent");
+ static final Pattern BRPattern = Pattern.compile("&lt;br&gt;");
+ static final Pattern EOLPattern = Pattern.compile("&lt;eol&gt;");
+ static final Pattern EndVerbatimPattern = Pattern.compile("@end\\s+verbatim");
+ static final Pattern TableSampItemPattern = Pattern.compile("(@table\\s*@samp.*)@item\\s*([a-zA-Z_0-9+\\-<>/ ]*)<eol>(.*@end\\s*table)", Pattern.DOTALL);
+ static final Pattern TableAsisItemPattern = Pattern.compile("(@table\\s*@asis.*)@item\\s*([a-zA-Z_0-9+\\-,<>/ ]*)<eol>(.*@end\\s*table)", Pattern.DOTALL);
+ static final Pattern TableSampPattern = Pattern.compile("@table\\s*@samp", Pattern.MULTILINE);
+ static final Pattern TableAsisPattern = Pattern.compile("@table\\s*@asis", Pattern.MULTILINE);
+ static final Pattern EndTablePattern = Pattern.compile("@end\\s+table");
+ static final Pattern DotsPattern = Pattern.compile("@dots\\{\\}");
+ static final Pattern ItemizeMinusPattern= Pattern.compile("@itemize\\s+@minus" + "(.*)" + "@end\\s+itemize", Pattern.MULTILINE);
+ static final Pattern ItemizeBulletPattern= Pattern.compile("@itemize\\s+@bullet" + "(.*)" + "@end\\s+itemize", Pattern.MULTILINE);
+ static final Pattern XrefPattern = Pattern.compile("@xref\\{[^\\}]*\\}", Pattern.MULTILINE);
+ static final Pattern CommandPattern = Pattern.compile("@command\\{([^\\}]*)\\}");
+ static final Pattern KbdPattern = Pattern.compile("@kbd\\{([^\\}]*)\\}");
+ static final Pattern RPattern = Pattern.compile("@r\\{([^\\}]*)\\}");
+ static final Pattern FilePattern = Pattern.compile("@file\\{([^\\}]*)\\}");
+ static final Pattern VarPattern = Pattern.compile("@var\\{([^\\}]*)\\}");
+ static final Pattern OVarPattern = Pattern.compile("@ovar\\{([^\\}]*)\\}");
+ static final Pattern DVarPattern = Pattern.compile("@dvar\\{([^\\},\\,]*),([^\\}]*)\\}");
+ static final Pattern CodePattern = Pattern.compile("@code\\{([^\\}]*)\\}");
+ static final Pattern EmphPattern = Pattern.compile("@emph\\{([^\\}]*)\\}");
+ static final Pattern SampPattern = Pattern.compile("@samp\\{([^\\}]*)\\}");
+ static final Pattern OptionPattern = Pattern.compile("@option\\{([^\\}]*)\\}");
+ static final Pattern TagPattern = Pattern.compile("@\\w*\\{([^\\}]*)\\}");
+ static final Pattern AmpersandPattern = Pattern.compile("&");
+ static final Pattern LeftAnglePattern = Pattern.compile("<");
+ static final Pattern RightAnglePattern = Pattern.compile(">");
+
+ static List IncludeList = new ArrayList();
+ static Stack readers = new Stack();
+
+ static class FunctionDef {
+ String ReturnType;
+ String FunctionName;
+ String[] Parameters;
+ Object[] IncludeList;
+ }
+
+ static class TPElement {
+ String Content;
+ String Synopsis;
+ }
+
+ static class TPDef {
+ String TPType;
+ String TPName;
+ String TPSynopsis;
+ TPElement[] TPElements;
+ Object[] IncludeList;
+ }
+
+ private static FunctionDef FindFunctionDef(String name, List FDefs) {
+ for (Iterator iterator = FDefs.iterator(); iterator.hasNext();) {
+ FunctionDef k = (FunctionDef) iterator.next();
+ if (k.FunctionName.equals(name))
+ return k;
+ }
+ return null;
+ }
+
+ private static FunctionDef BuildFunctionDef(Matcher m, FunctionDef fd) {
+ fd.ReturnType = m.group(RtnTypeSIndex);
+ fd.FunctionName = m.group(FunctionNameIndex);
+
+ if (null != m.group(ParmsIndex)) {
+ String tt = TexinfoUtils.stripProtoTags(m.group(ParmsIndex));
+ String[] parms = tt.split(",\\s");
+ fd.Parameters = parms;
+ }
+
+ if (IncludeList.size() > 0) {
+ fd.IncludeList = IncludeList.toArray();
+ }
+ return fd;
+ }
+
+ private static FunctionDef BuildFunctionDef2(Matcher m, FunctionDef fd) {
+ fd.ReturnType = m.group(RtnType2Index) + "(*)" + m.group(RtnTypeParmsIndex);
+ fd.FunctionName = m.group(FunctionName2Index);
+
+ if (null != m.group(Parms2Index)) {
+ String tt = TexinfoUtils.stripProtoTags(m.group(Parms2Index));
+ String[] parms = tt.split(",\\s");
+ fd.Parameters = parms;
+ }
+
+ if (IncludeList.size() > 0) {
+ fd.IncludeList = IncludeList.toArray();
+ }
+ return fd;
+ }
+
+ private static void HandleFunctionDefs(BufferedReader is, List FDefs) throws IOException {
+ FunctionDef fd;
+ String il = null;
+ boolean preRead = false;
+
+ while (preRead || (il = is.readLine()) != null) {
+ preRead = false;
+ if (il.startsWith("@end example"))
+ return;
+
+ Matcher m = DeftypefunPattern.matcher(il);
+ Matcher m2 = DeftypefunPattern2.matcher(il);
+ Matcher m3 = DeftypefunPattern3.matcher(il);
+ Matcher mm = IncludePattern.matcher(il);
+
+ if (mm.matches()) {
+ if (!IncludeList.contains(mm.group(1)))
+ IncludeList.add(mm.group(1));
+ }
+ else if (m.matches()) {
+ fd = FindFunctionDef(m.group(FunctionNameIndex), FDefs);
+ if (fd != null)
+ BuildFunctionDef(m, fd);
+ else
+ System.out.println("Missing findex for " + m.group(FunctionNameIndex));
+ }
+ else if (m2.matches()) {
+ fd = FindFunctionDef(m2.group(FunctionName2Index), FDefs);
+ if (fd != null)
+ BuildFunctionDef2(m2, fd);
+ else
+ System.out.println("Missing findex for " + m2.group(FunctionName2Index));
+ }
+ else if (m3.matches()) {
+ fd = FindFunctionDef(m3.group(FunctionNameIndex), FDefs);
+ if (fd != null)
+ BuildFunctionDef(m3, fd);
+ else
+ System.out.println("Missing findex for " + m3.group(FunctionName2Index));
+ }
+ else if (il.trim().length() > 0) {
+ il = il.trim();
+ while (il.endsWith(",")) { // assume prototype extends more than one line
+ preRead = true;
+ String il2 = is.readLine().trim();
+ if (il2 != null && il2.startsWith("@")) { // something wrong, just look at new line fetched
+ il = il2;
+ continue;
+ }
+ il = il + il2; // concatenate
+ }
+ }
+ }
+ }
+
+ private static void WriteString(BufferedWriter os, String s) throws IOException {
+ // System.out.println(s);
+ os.write(s+"\n", 0, 1+s.length());
+ }
+
+ private static void CreateHeader(BufferedWriter os) throws IOException {
+ WriteString(os, "<!-- This file automatically generated by an Eclipse utility -->");
+ WriteString(os, "<!DOCTYPE descriptions [");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT descriptions (construct)*>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT construct (structure|function|synopsis)*>");
+ WriteString(os, " <!ATTLIST construct");
+ WriteString(os, " id ID #REQUIRED");
+ WriteString(os, " type CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT structure (synopsis?, elements?)?>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT elements (element*)>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT element (synopsis*)>");
+ WriteString(os, " <!ATTLIST element");
+ WriteString(os, " content CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT synopsis (#PCDATA)*>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT function (prototype,headers?,groupsynopsis?,synopsis)>");
+ WriteString(os, " <!ATTLIST function");
+ WriteString(os, " returntype CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT prototype (parameter+)?>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT parameter (#PCDATA)*>");
+ WriteString(os, " <!ATTLIST parameter");
+ WriteString(os, " content CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT headers (header+)?>");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT header (#PCDATA)*>");
+ WriteString(os, " <!ATTLIST header");
+ WriteString(os, " filename CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, " <!ELEMENT groupsynopsis (#PCDATA)*>");
+ WriteString(os, " <!ATTLIST groupsynopsis");
+ WriteString(os, " id CDATA #REQUIRED");
+ WriteString(os, " >");
+ WriteString(os, "");
+ WriteString(os, "]>");
+ WriteString(os, "");
+ }
+
+ private static void CreateTrailer(BufferedWriter os) throws IOException {
+ WriteString(os, "</descriptions>");
+ }
+
+ private static void WriteDescription(BufferedWriter os, String Synopsis, boolean indent) throws IOException {
+ String ss = TexinfoUtils.transformTags(Synopsis);
+ String[] tt = ss.split("<eol>");
+ String aa = "";
+ String spaces = indent ? " " : " ";
+ WriteString(os, spaces + "<synopsis>");
+ if (null != Synopsis) {
+ for (int pp = 0; pp < tt.length; pp++) {
+ WriteString(os, spaces + tt[pp]);
+// if (tt[pp].equals("<br>")) {
+// WriteString(os, spaces + aa + "\n");
+// aa = "";
+// }
+// else {
+// if ((aa.length() + tt[pp].length()) > 64) {
+// WriteString(os, spaces + aa);
+// aa = "";
+// }
+// aa = aa + " " + tt[pp];
+// }
+ }
+ }
+ if (aa.length() > 0) WriteString(os, " " + aa);
+ WriteString(os, spaces + "</synopsis>");
+ }
+
+ private static BufferedReader HandleInclude (BufferedReader is, String srcdir, String line) {
+ Pattern p = Pattern.compile("@include\\s+(.*?)");
+ Matcher mm = p.matcher(line.trim());
+ BufferedReader is2 = null;
+ if (mm.find()) {
+ String fileName = (srcdir.endsWith("/") ? srcdir : srcdir + "/") + mm.replaceAll("$1");
+ try {
+ is2 = new BufferedReader(new FileReader(fileName));
+ readers.push(is);
+ } catch (FileNotFoundException e) {
+ System.out.println("include " + fileName + " not found");
+ // do nothing and return null
+ }
+ }
+ return is2 == null ? is : is2;
+ }
+
+ private static String HandleDescription(BufferedReader is) throws IOException {
+ String Description = null;
+ String il;
+
+ while (null != (il = is.readLine())) {
+ if (il.startsWith("@page") ||
+ il.startsWith("@section") ||
+ il.startsWith("@node"))
+ break;
+ Description = ((Description == null) ? "" : Description + " " ) + ((il.length() == 0) ? "<br><br>" :
+ il + "<eol>");
+ }
+
+ return Description;
+ }
+
+ private static void HandleFunction(BufferedWriter os, BufferedReader is, String s, String builddir) throws IOException {
+ String il;
+ FunctionDef fd;
+ List FDefs = new ArrayList();
+ String Description = null;
+ boolean synopsisMarker = false;
+
+ IncludeList.clear();
+ Matcher mmf = FindexPattern.matcher(s);
+ fd = new FunctionDef();
+ if (mmf.matches())
+ fd.FunctionName = mmf.group(1);
+ else
+ return;
+ FDefs.add(fd);
+
+ while (null != (il = is.readLine())) {
+ Matcher syn = SynopsisPattern.matcher(il);
+ if (il.startsWith("@findex")) {
+ synopsisMarker = false;
+ Matcher mm2 = FindexPattern.matcher(il);
+ FunctionDef fd2 = new FunctionDef();
+ if (mm2.matches()) {
+ fd2.FunctionName = mm2.group(1);
+ FDefs.add(fd2);
+ }
+ }
+ else if (il.startsWith("@example") && synopsisMarker) {
+ HandleFunctionDefs(is, FDefs);
+ synopsisMarker = false;
+ }
+ else if (il.startsWith("@include") && fd != null) {
+ is = HandleInclude(is, builddir, il);
+ }
+ else if (syn.matches()) {
+ synopsisMarker = true;
+ }
+ else if (il.startsWith("@strong{Description}")) {
+ synopsisMarker = false;
+ Description = HandleDescription(is);
+ break; // we are done after description has been fetched
+ }
+ // otherwise ignore line
+ }
+
+ String name = ((FunctionDef)FDefs.get(0)).FunctionName;
+
+ if (FDefs.size() > 1) {
+ for (int kk = 0; kk < FDefs.size(); kk++) {
+ fd = (FunctionDef)FDefs.get(kk);
+
+ WriteString(os, " <construct id=\"function-" + fd.FunctionName + "\" type=\"function\">");
+
+ WriteString(os, " <function returntype=\"" + fd.ReturnType + "\">");
+
+ WriteString(os, " <prototype>");
+ String[] parms = fd.Parameters;
+ if (parms == null)
+ System.out.println("null parms for findex " + fd.FunctionName);
+ else {
+ for (int i = 0; i < parms.length; i++) {
+ String parm = TexinfoUtils.stripProtoTags(parms[i]);
+ WriteString(os, " <parameter content=\"" + parm + "\"/>");
+ }
+ }
+ WriteString(os, " </prototype>");
+
+ if (fd.IncludeList != null) {
+ WriteString(os, " <headers>");
+ Object[] incs = fd.IncludeList;
+ for (int j = 0; j < incs.length; j++) {
+ String inc = (String)incs[j];
+ WriteString(os, " <header filename = \"" + inc + "\"/>");
+ }
+ WriteString(os, " </headers>");
+ }
+
+ if (null != Description)
+ WriteString(os, " <groupsynopsis id=\"group-" + name + "\"/>");
+
+
+ WriteString(os, " </function>");
+ WriteString(os, " </construct>");
+ }
+
+ if (null != Description) {
+ WriteString(os, " <construct id=\"group-" + name + "\" type=\"groupsynopsis\">");
+ WriteDescription(os, Description, false);
+ WriteString(os, " </construct>");
+ }
+ }
+ else {
+ fd = (FunctionDef)FDefs.get(0);
+
+ WriteString(os, " <construct id=\"function-" + fd.FunctionName + "\" type=\"function\">");
+
+ WriteString(os, " <function returntype=\"" + fd.ReturnType + "\">");
+
+ WriteString(os, " <prototype>");
+ String[] parms = fd.Parameters;
+ if (parms == null)
+ System.out.println("null parms for findex " + fd.FunctionName);
+ else {
+ for (int i = 0; i < parms.length; i++) {
+ String parm = TexinfoUtils.stripProtoTags(parms[i]);
+ WriteString(os, " <parameter content=\"" + parm + "\"/>");
+ }
+ }
+ WriteString(os, " </prototype>");
+
+ if (fd.IncludeList != null) {
+ WriteString(os, " <headers>");
+ Object[] incs = fd.IncludeList;
+ for (int j = 0; j < incs.length; j++) {
+ String inc = (String)incs[j];
+ WriteString(os, " <header filename = \"" + inc + "\"/>");
+ }
+ WriteString(os, " </headers>");
+ }
+
+ if (null != Description) WriteDescription(os, Description, false);
+
+ WriteString(os, " </function>");
+ WriteString(os, " </construct>");
+ }
+ FDefs.clear();
+ }
+
+ public static void BuildXMLFromTexinfo2(String srcdir, String builddir, BufferedWriter os, String lib) {
+ try {
+ srcdir = srcdir.endsWith("/") ? srcdir + lib : srcdir + "/" + lib;
+ builddir = builddir.endsWith("/") ? builddir + lib : builddir + "/" + lib;
+ String qFile = srcdir + "/" + lib + ".texinfo";
+
+ try {
+ BufferedReader is = new BufferedReader(new FileReader(qFile));
+ String il;
+ boolean ignore = false;
+
+ while (is != null) {
+ while (null != (il = is.readLine())) {
+ if (!ignore && il.startsWith("@findex")) {
+ HandleFunction(os, is, il, builddir);
+ }
+ else if (!ignore && il.startsWith("@include")) {
+ is = HandleInclude(is, builddir, il);
+ }
+ else if (il.startsWith("@ignore")) {
+ ignore = true;
+ }
+ else if (il.startsWith("@end ignore"))
+ ignore = false;
+ }
+ is.close();
+ is = (BufferedReader)readers.pop();
+ }
+ }
+ catch (IOException e) {
+ System.out.println("Input File IOException: " + e);
+ return;
+ }
+ catch (EmptyStackException f) {
+ // ok, we expect to get here
+ }
+ }
+ catch (NullPointerException e) {
+ e.printStackTrace();
+ System.out.println("NullPointerException: " + e);
+ return;
+ }
+
+ }
+
+ public static void BuildXMLFromTexinfo(String srcdir, String builddir, String dstdir) {
+ try {
+ BufferedWriter os = new BufferedWriter(new FileWriter(dstdir));
+
+ CreateHeader(os);
+// CreateLicense(os);
+
+ WriteString(os, "<descriptions>");
+ BuildXMLFromTexinfo2(srcdir, builddir, os, "libc");
+ BuildXMLFromTexinfo2(srcdir, builddir, os, "libm");
+
+
+ CreateTrailer(os);
+
+ os.close();
+ }
+ catch (IOException e) {
+ System.out.println("Output File IOException: " + e);
+ return;
+ }
+ }
+
+ public static void main(String[] args) {
+ BuildXMLFromTexinfo(args[0], args[1], args[2]);
+ }
+
+}
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/TexinfoUtils.java b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/TexinfoUtils.java
new file mode 100644
index 0000000000..ceb3d91d30
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover.texinfoparsers/src/org/eclipse/linuxtools/cdt/libhover/texinfoparsers/TexinfoUtils.java
@@ -0,0 +1,733 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.cdt.libhover.texinfoparsers;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class TexinfoUtils {
+
+ static final Pattern ParmBracketPattern = Pattern.compile("\\((.*?)\\)");
+ static final Pattern IndexPattern = Pattern.compile("@\\w*index\\s+[a-zA-Z0-9_@\\{\\}]*");
+ static final Pattern IndexPattern2 = Pattern.compile("@\\w*index\\{[a-zA-Z0-9_@\\{\\}]*\\}");
+ static final Pattern ExampleItem = Pattern.compile("(@example)((.*?<br><eol>)*+.*?)(<eol>.*@end\\s+example)");
+ static final Pattern ExamplePattern = Pattern.compile("@example");
+ static final Pattern EndExamplePattern = Pattern.compile("@end\\s+example");
+ static final Pattern SmallExampleItem = Pattern.compile("(@smallexample)((.*?<br><eol>)*+.*?)(<eol>.*@end\\s+smallexample)");
+ static final Pattern SmallExamplePattern = Pattern.compile("@smallexample");
+ static final Pattern StrongPattern = Pattern.compile("@strong\\{(\\w*)\\}(@\\*)?");
+ static final Pattern EndSmallExamplePattern = Pattern.compile("@end\\s+smallexample");
+ static final Pattern EnumeratePattern = Pattern.compile("@enumerate");
+ static final Pattern EndEnumeratePattern = Pattern.compile("@end\\s+enumerate");
+ static final Pattern VerbatimPattern = Pattern.compile("@verbatim");
+ static final Pattern ItemPattern = Pattern.compile("@item");
+ static final Pattern RefillPattern = Pattern.compile("@refill");
+ static final Pattern NoIndentPattern = Pattern.compile("@noindent");
+ static final Pattern QuotationPattern = Pattern.compile("@quotation");
+ static final Pattern EndQuotation = Pattern.compile("@end\\s+quotation");
+ static final Pattern GroupPattern = Pattern.compile("@group");
+ static final Pattern TabPattern = Pattern.compile("@tab");
+ static final Pattern DeftpPattern = Pattern.compile("@deftp\\s+\\{([^\\}]*?)\\}\\s*\\{([^\\}]*?)\\}");
+ static final Pattern EndDeftpPattern = Pattern.compile("@end\\s+deftp");
+ static final Pattern CommentPattern = Pattern.compile("@c<eol>|@c\\s+.*?<eol>");
+ static final Pattern EndGroupPattern = Pattern.compile("@end\\s+group");
+ static final Pattern BracketRefPattern = Pattern.compile("\\(@.?.?ref\\{[^\\}]*\\}\\)");
+ static final Pattern BRPattern = Pattern.compile("&lt;br&gt;");
+ static final Pattern EOLPattern = Pattern.compile("&lt;eol&gt;");
+ static final Pattern EndVerbatimPattern = Pattern.compile("@end\\s+verbatim");
+ static final Pattern TableSampItemPattern = Pattern.compile("(@table\\s*@samp.*?)@item\\s+(.*?)(<eol>.*@end\\s+table)", Pattern.DOTALL);
+ static final Pattern TableAsisItemPattern = Pattern.compile("(@table\\s*@asis.*?)@item\\s+(.*?)(<eol>.*@end\\+table)", Pattern.DOTALL);
+ static final Pattern TableCodeItemPattern = Pattern.compile("(@table\\s*@code.*?)@item\\s+(.*?)(<eol>.*?)(@end\\s+table)", Pattern.DOTALL);
+ static final Pattern TableVarItemPattern = Pattern.compile("(@table\\s*@var.*?)@item\\s+(.*?)(<eol>.*@end\\s+table)", Pattern.DOTALL);
+ static final Pattern VtableCodeItemPattern = Pattern.compile("(@vtable\\s*@code.*?)@item\\s+(.*?)(<eol>.*@end\\s+vtable)", Pattern.DOTALL);
+ static final Pattern MultitableItemPattern = Pattern.compile("(@multitable.*)@item\\s+(.*?)<eol>(.*?@end\\s+multitable)" +
+ "|(@multitable.*)@item\\s*<eol>(.*?)<eol>(.*?@end\\s+multitable)", Pattern.DOTALL);
+ static final Pattern TableCodeMatchPattern = Pattern.compile("(@table\\s+@code)(.*?)(@end\\s+table)", Pattern.DOTALL);
+ static final Pattern TableSampMatchPattern = Pattern.compile("(@table\\s+@samp)(.*?)(@end\\s+table)", Pattern.DOTALL);
+ static final Pattern TableAsisMatchPattern = Pattern.compile("(@table\\s+@asis)(.*?)(@end\\s+table)", Pattern.DOTALL);
+ static final Pattern TableVarMatchPattern = Pattern.compile("(@table\\s+@var)(.*?)(@end\\s+table)", Pattern.DOTALL);
+ static final Pattern TableSampPattern = Pattern.compile("@table\\s*@samp", Pattern.MULTILINE);
+ static final Pattern TableAsisPattern = Pattern.compile("@table\\s*@asis", Pattern.MULTILINE);
+ static final Pattern TableCodePattern = Pattern.compile("@table\\s*@code", Pattern.MULTILINE);
+ static final Pattern TableVarPattern = Pattern.compile("@table\\s*@var", Pattern.MULTILINE);
+ static final Pattern VtableCodePattern = Pattern.compile("@vtable\\s*@code", Pattern.MULTILINE);
+ static final Pattern MultitablePattern = Pattern.compile("@multitable.*?<DT>", Pattern.DOTALL);
+ static final Pattern EndTablePattern = Pattern.compile("@end\\s+table");
+ static final Pattern EndVtablePattern = Pattern.compile("@end\\s+vtable");
+ static final Pattern EndMultitablePattern = Pattern.compile("@end\\s+multitable");
+ static final Pattern DotsPattern = Pattern.compile("@dots\\{\\}");
+ static final Pattern ItemizeMinusPattern= Pattern.compile("@itemize\\s+@minus" + "(.*?)" + "@end\\s+itemize", Pattern.DOTALL);
+ static final Pattern ItemizeBulletPattern= Pattern.compile("@itemize\\s+@bullet" + "(.*?)" + "@end\\s+itemize", Pattern.DOTALL);
+ static final Pattern InfoOnlyPattern = Pattern.compile("@ifinfo.*?@end\\s+ifinfo", Pattern.DOTALL);
+ static final Pattern TexOnlyPattern = Pattern.compile("@iftex.*?@end\\s+iftex", Pattern.DOTALL);
+ static final Pattern TexPattern = Pattern.compile("@tex.*?@end\\s+tex", Pattern.DOTALL);
+ static final Pattern IgnorePattern = Pattern.compile("@ignore.*?@end\\s+ignore", Pattern.DOTALL);
+ static final Pattern IfInfoPattern = Pattern.compile("@ifinfo");
+ static final Pattern InfinityPattern = Pattern.compile("@infinity");
+ static final Pattern EndIfInfoPattern = Pattern.compile("@end\\s+ifinfo");
+ static final Pattern NotTexPattern = Pattern.compile("@ifnottex");
+ static final Pattern EndNotTexPattern = Pattern.compile("@end\\s+ifnottex");
+ static final Pattern DeftypevrPattern = Pattern.compile("@deftypevr\\s+");
+ static final Pattern EndDeftypevr = Pattern.compile("@end\\s+deftypevr");
+ static final Pattern XrefPattern = Pattern.compile("@xref\\{[^\\}]*\\}", Pattern.MULTILINE);
+ static final Pattern PxrefPattern = Pattern.compile("@pxref\\{[^\\}]*\\}", Pattern.MULTILINE);
+ static final Pattern AtTPattern = Pattern.compile("@t\\{([^\\}]*)\\}");
+ static final Pattern CommandPattern = Pattern.compile("@command\\{([^\\}]*)\\}");
+ static final Pattern KbdPattern = Pattern.compile("@kbd\\{([^\\}]*)\\}");
+ static final Pattern RPattern = Pattern.compile("@r\\{([^\\}]*)\\}");
+ static final Pattern FilePattern = Pattern.compile("@file\\{([^\\}]*)\\}");
+ static final Pattern VarPattern = Pattern.compile("@var\\{([^\\}]*)\\}");
+ static final Pattern OVarPattern = Pattern.compile("@ovar\\{([^\\}]*)\\}");
+ static final Pattern DVarPattern = Pattern.compile("@dvar\\{([^\\},\\,]*),([^\\}]*)\\}");
+ static final Pattern AnyVarPattern = Pattern.compile("@[a-z]*var\\{([^\\}]*)\\}");
+ static final Pattern CodePattern = Pattern.compile("@code\\{([^\\}]*)\\}");
+ static final Pattern EmphPattern = Pattern.compile("@emph\\{([^\\}]*)\\}");
+ static final Pattern SampPattern = Pattern.compile("@samp\\{([^\\}]*)\\}");
+ static final Pattern OptionPattern = Pattern.compile("@option\\{([^\\}]*)\\}");
+ static final Pattern TagPattern = Pattern.compile("@\\w+\\{([^\\}]*)\\}");
+ static final Pattern TagCharPattern = Pattern.compile("@([\\{\\}\\:\\*\"])");
+ static final Pattern StrandedPeriod = Pattern.compile("(\\w)\\s+\\.\\s+");
+ static final Pattern LeftOverPeriod = Pattern.compile("^\\.\\s+<eol>");
+ static final Pattern AmpersandPattern = Pattern.compile("&");
+ static final Pattern LeftAnglePattern = Pattern.compile("<");
+ static final Pattern RightAnglePattern = Pattern.compile(">");
+
+ public static String stripProtoTags(String tt) {
+ Matcher mm;
+ String ss = "";
+
+ ss = "";
+ while (ss != tt) {
+ mm = AnyVarPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = DotsPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("...");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = CodePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = AtTPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TagPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TagCharPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ return tt;
+ }
+
+ public static String transformTags(String tt) {
+ Matcher mm;
+ String ss = "";
+ int endtableIndex = Integer.MAX_VALUE;
+
+ ss = "";
+ while (ss != tt) {
+ mm = BracketRefPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = XrefPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = CommentPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<eol>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = PxrefPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = DeftypevrPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = StrongPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<h3>$1</h3>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndDeftypevr.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = IndexPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = IndexPattern2.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = NoIndentPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = GroupPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndGroupPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = QuotationPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndQuotation.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = InfinityPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("infinity");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = DeftpPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<h4>$1 - $2</h4>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndDeftpPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = RefillPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = VarPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<VAR>$1</VAR>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = DotsPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<small>...</small>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = CommandPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<CODE>$1</CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = CodePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<CODE>$1</CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = KbdPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<KBD>$1</KBD>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EmphPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<EM>$1</EM>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = FilePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<TT>$1</TT>");
+ }
+
+
+ ss = "";
+ while (ss != tt) {
+ mm = VerbatimPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndVerbatimPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</CODE>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = SampPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<samp>$1</samp>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = OptionPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<samp>$1</samp>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = ExampleItem.matcher(tt);
+ ss = tt;
+ // We want to add a break at the end of each example line to preserve
+ // formatting when Eclipse processes the xml (e.g. C code lines).
+ tt = mm.replaceAll("$1$2<br>$4");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = ExamplePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<TABLE><tr><td>&nbsp;</td><td class=example><pre>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndExamplePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</pre></td></tr></table>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = SmallExampleItem.matcher(tt);
+ ss = tt;
+ // We want to add a break at the end of each example line to preserve
+ // formatting when Eclipse processes the xml (e.g. C code lines).
+ tt = mm.replaceAll("$1$2<br>$4");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = SmallExamplePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<pre>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndSmallExamplePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</pre>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EnumeratePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<OL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndEnumeratePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</OL>");
+ }
+
+// ss = "";
+// while (ss != tt) {
+// mm = InfoOnlyPattern.matcher(tt);
+// ss = tt;
+// tt = mm.replaceAll("");
+// }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TexOnlyPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TexPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = IgnorePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = NotTexPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndNotTexPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ // We will treat ifinfo the same as ifnottex which we pass through.
+ ss = "";
+ while (ss != tt) {
+ mm = IfInfoPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndIfInfoPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ endtableIndex = Integer.MAX_VALUE;
+ while (ss != tt) {
+ mm = TableSampItemPattern.matcher(tt);
+ ss = tt;
+ if (mm.find()) {
+ if (mm.start(4) > endtableIndex) {
+ // We try and find the last @[table samp] marker we can find with an @item before @[end table].
+ // The end marker has moved forward to make the match which means we have exhausted all @item markers
+ // from the last @[table samp] and @[end table] we were using prior to this iteration of the loop.
+ // If we change the table markers now, we avoid the prior table from
+ // matching any @item marker that sits between tables.
+ Matcher mm2 = TableSampMatchPattern.matcher(tt);
+ tt = mm2.replaceFirst("<DL>\n$2\n</DL>");
+ mm2 = TableSampMatchPattern.matcher(tt);
+ if (mm2.find())
+ endtableIndex = mm2.start(3);
+ }
+ else {
+ tt = mm.replaceFirst("$1<DT><SAMP>$2</SAMP>\n<DD>$3$4");
+ endtableIndex = mm.end(1) + 10 + mm.group(2).length() + 12 + mm.group(3).length();
+ }
+ }
+ }
+
+ //FIXME: This parser assumes that a table does not have an @itemize element
+ // inside it. It allows the opposite to be true (i.e. a table inside
+ // an @itemize element.
+
+ ss = "";
+ endtableIndex = Integer.MAX_VALUE;
+ while (ss != tt) {
+ mm = TableAsisItemPattern.matcher(tt);
+ ss = tt;
+ if (mm.find()) {
+ if (mm.start(4) > endtableIndex) {
+ // We try and find the last @[table asis] marker we can find with an @item before @[end table].
+ // The end marker has moved forward to make the match which means we have exhausted all @item markers
+ // from the last @[table asis] and @[end table] we were using prior to this iteration of the loop.
+ // If we change the table markers now, we avoid the prior table from
+ // matching any @item marker that sits between tables.
+ Matcher mm2 = TableAsisMatchPattern.matcher(tt);
+ tt = mm2.replaceFirst("<DL>\n$2\n</DL>");
+ mm2 = TableAsisMatchPattern.matcher(tt);
+ if (mm2.find())
+ endtableIndex = mm2.start(3);
+ }
+ else {
+ tt = mm.replaceFirst("$1<DT>$2\n<DD>$3$4");
+ endtableIndex = mm.end(1) + 10 + mm.group(2).length() + 12 + mm.group(3).length();
+ }
+ }
+ }
+
+ ss = "";
+ endtableIndex = Integer.MAX_VALUE;
+ while (ss != tt) {
+ mm = TableCodeItemPattern.matcher(tt);
+ ss = tt;
+ if (mm.find()) {
+ if (mm.start(4) > endtableIndex) {
+ // We try and find the last @[table code] marker we can find with an @item before @[end table].
+ // The end marker has moved forward to make the match which means we have exhausted all @item markers
+ // from the last @[table code] and @[end table] we were using prior to this iteration of the loop.
+ // If we change the table markers now, we avoid the prior table from
+ // matching any @item marker that sits between tables.
+ Matcher mm2 = TableCodeMatchPattern.matcher(tt);
+ tt = mm2.replaceFirst("<DL>\n$2\n</DL>");
+ mm2 = TableCodeMatchPattern.matcher(tt);
+ if (mm2.find())
+ endtableIndex = mm2.start(3);
+ }
+ else {
+ tt = mm.replaceFirst("$1<DT><CODE>$2</CODE>\n<DD>$3$4");
+ endtableIndex = mm.end(1) + 10 + mm.group(2).length() + 12 + mm.group(3).length();
+ }
+ }
+ }
+
+ ss = "";
+ endtableIndex = Integer.MAX_VALUE;
+ while (ss != tt) {
+ mm = TableVarItemPattern.matcher(tt);
+ ss = tt;
+ if (mm.find()) {
+ if (mm.start(4) > endtableIndex) {
+ // We try and find the last @[table var] marker we can find with an @item before @[end table].
+ // The end marker has moved forward to make the match which means we have exhausted all @item markers
+ // from the last @[table var] and @[end table] we were using prior to this iteration of the loop.
+ // If we change the table markers now, we avoid the prior table from
+ // matching any @item marker that sits between tables.
+ Matcher mm2 = TableVarMatchPattern.matcher(tt);
+ tt = mm2.replaceFirst("<DL>\n$2\n</DL>");
+ mm2 = TableVarMatchPattern.matcher(tt);
+ if (mm2.find())
+ endtableIndex = mm2.start(3);
+ }
+ else {
+ tt = mm.replaceFirst("$1<DT><VAR>$2</VAR>\n<DD>$3$4");
+ endtableIndex = mm.end(1) + 10 + mm.group(2).length() + 12 + mm.group(3).length();
+ }
+ }
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = VtableCodeItemPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1<DT><CODE>$2</CODE>\n<DD>$3");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = MultitableItemPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1<DT><pre>$2</pre>\n<DD><br>$3");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableSampPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<DL>\n");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableAsisPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<DL>\n");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableVarPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<DL>\n");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TableCodePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<DL>\n");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = VtableCodePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<DL>\n");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = MultitablePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<DL>\n<DT>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndTablePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</DL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndVtablePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</DL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = EndMultitablePattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("</DL>");
+ }
+
+ //FIXME: if there ever is a @itemize @bullet within a
+ // @itemize @minus or vice-versa, the following
+ // logic will get it wrong.
+ ss = "";
+ while (ss != tt) {
+ mm = ItemizeMinusPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<UL>$1</UL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = ItemizeBulletPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<OL>$1</OL>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = ItemPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("<LI>");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TagPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TagCharPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = StrandedPeriod.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("$1. ");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = LeftOverPeriod.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ ss = "";
+ while (ss != tt) {
+ mm = TabPattern.matcher(tt);
+ ss = tt;
+ tt = mm.replaceAll("");
+ }
+
+ mm = AmpersandPattern.matcher(tt);
+ tt = mm.replaceAll("&amp;");
+
+ mm = LeftAnglePattern.matcher(tt);
+ tt = mm.replaceAll("&lt;");
+
+ mm = RightAnglePattern.matcher(tt);
+ tt = mm.replaceAll("&gt;");
+
+ // Put back all the eol markers
+ mm = EOLPattern.matcher(tt);
+ tt = mm.replaceAll("<eol>");
+
+ return tt;
+ }
+}
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover/ChangeLog b/libhover/org.eclipse.linuxtools.cdt.libhover/ChangeLog
new file mode 100644
index 0000000000..5dd3997ddd
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover/ChangeLog
@@ -0,0 +1,196 @@
+2010-03-17 Jeff Johnston <jjohnstn@redhat.com>
+
+ Resolves #306283
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHover.java (getMemberSummary): Remove
+ code that looks in editor text for class name and then asks the AST. Just get the class name
+ from the member we already do the lookup for. Get the fully templated name using the new
+ getClassName method.
+ (getMatchingFunctions): Remove commented out code.
+ (getClassName): New method to get class name including template parameters.
+ (getFunctionInfo): Change to specify fully qualified name and not remove
+ namespace.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHoverLibrary.java (getClassInfo): Check
+ info is not null before accessing.
+
+2010-03-04 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHover.java (getMemberSummary): Change
+ DOMException catch statement to Exception since the IFunction interface getReturnType method
+ changes in CDT 7.0.
+
+2009-12-22 Andrew Overholt <overholt@redhat.com>
+
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHover.java (getMemberSummary):
+ Revert Helios-only change on trunk.
+
+2009-12-17 Andrew Overholt <overholt@redhat.com>
+
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHover.java (getMemberSummary):
+ Remove unnecessary catch block.
+
+2009-09-23 Jeff Johnston <jjohnstn@redhat.com>
+
+ * META-INF/MANIFEST.MF: Load plugin if any of its classes are used.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibhoverPlugin.java (LibhoverPlugin): Set
+ plugin in constructor.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHover.java (resolveArgs): Change
+ to resolve template parms to actual types where known.
+ (isParmMatch): Resolve the member prototype using template types so we are comparing
+ apples to apples.
+ (getMemberSummary): Change calls to isParmMatch and resolveArgs.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHoverLibrary.java (getHoverInfo): Add
+ code to try accessing a path locally within the plugin, then try the file system.
+
+2009-08-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ Resolves #285867
+ * plugin.properties: Change Provider to Eclipse instead of Eclipse.org.
+
+2009-07-30 Jeff Johnston <jjohnstn@redhat.com>
+
+ * META-INF/MANIFEST.MF: Bump release to 1.0.3.
+
+2009-07-30 Jeff Johnston <jjohnstn@redhat.com>
+
+ Refactor to hide internal classes in new packages.
+
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHover.java: Removed.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverLibrary.java: Removed.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverMessages.java: Removed.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverMessages.properties: Removed.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/CheckboxFieldEditor.java: Removed.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/LibHoverPreferencePage.java: Removed.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/PreferenceConstants.java: Removed.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/PreferenceInitializer.java: Removed.
+ * src/org/eclipse/linuxtools/cdt/libhover/properties/LibHoverPropertyPage.java: Removed.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHover.java: New file.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHoverLibrary.java: New file.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHoverMessages.java: New file.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/LibHoverMessages.properties: New file.
+ * plugin.xml: Changed to match new packages.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/preferences/CheckboxFieldEditor.java: New file.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/preferences/LibHoverPreferencePage.java: New file.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/preferences/PreferenceConstants.java: New file.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/preferences/PreferenceInitializer.java: New file.
+ * src/org/eclipse/linuxtools/internal/cdt/libhover/properties/LibHoverPropertyPage.java: New file.
+
+
+2009-05-29 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHover.java (getMemberSummary): Fix compiler warnings.
+ (getFunctionInfo): Ditto.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/CheckboxFieldEditor.java (doLoad): Ditto.
+ (doLoadDefault): Ditto.
+ (adjustForNumColumns): Ditto.
+ * src/org/eclipse/linuxtools/cdt/libhover/properties/LibHoverPropertyPage.java (updateCheckboxData): Ditto.
+
+2009-05-08 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHover.java (getFunctionInfo): Add logic
+ to find the qualified name of the class, even when namespaces are being used.
+
+2009-05-08 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHover.java (resolveArgs): New method.
+ (isParmMatch): Ditto.
+ (getMemberSummary): Add parameter matching support and template resolution.
+ (getFunctionInfo): Add AST logic to resolve member name for C++.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverLibrary.java (resolveTemplateTypes):
+ New method.
+ (getClassInfo): Add additional parameter of template types and fill in.
+ * src/org/eclipse/linuxtools/cdt/libhover/MemberInfo.java (getReturnType): New method.
+ (setParamTypes): Ditto.
+ (getParamTypes): Ditto.
+
+2009-02-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ * schema/org.eclipse.linuxtools.cdt.libhover.library.exsd: Change description for
+ location field which now points to a serialized LibHoverInfo instance rather than
+ xml.
+ * src/org/eclipse/linuxtools/cdt/libhover/ClassInfo.java: New file.
+ * src/org/eclipse/linuxtools/cdt/libhover/FunctionInfo.java: New file.
+ * src/org/eclipse/linuxtools/cdt/libhover/HelpBook.java: New file.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverInfo.java: New file.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverLibrary.java: New file.
+ * src/org/eclipse/linuxtools/cdt/libhover/MemberInfo.java: New file.
+ * src/org/eclipse/linuxtools/cdt/libhover/TypedefInfo.java: New file.
+ * src/org/eclipse/linuxtools/cdt/libhover/utils/BuildFunctionInfos.java: New file to
+ create serialized LibHoverInfo file from an xml file in standard function format
+ used by previous version of LibHover.
+ * META-INF/MANIFEST.MF: Add additional dependencies and bump version to 1.0.2.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHover.java (isCPPCharacter): New method.
+ (EnclosingASTNameJob): New internal class to query the AST for IASTName
+ for a symbol in the document.
+ (ASTDeclarationFinderJob): New internal class to get the declaration of a symbol from
+ the AST.
+ (getMemberSummary): New method to get the summary of a C++ method.
+ (getLibHoverDocs): Modified to no longer parse xml documentation. It now expects
+ documentation to be in LibHoverInfo format, serialized via Java. The method leaves
+ reading of the actual serialized info to LibHoverLibrary.
+ (getFunctionSummary): Rewritten to fetch info from the new LibHoverInfo class and
+ to handle C++.
+ (getMatchingFunctions): Ditto.
+ (FunctionSummary): Added a boolean to mark whether the prototype already has
+ brackets in it.
+ (FunctionSummary.FunctionPrototypeSummary.getPrototypeString): Use new boolean
+ to determine whether to add brackets or not.
+ (getFunctionInfo): Add C++ support.
+
+2009-01-15 Jeff Johnston <jjohnstn@redhat.com>
+
+ * META-INF/MANIFEST.MF: Add .qualifier to version and bump to 1.0.1.
+
+2008-10-31 Andrew Overholt <overholt@redhat.com>
+
+ * META-INF/MANIFEST.MF: Use bundleName and provider from plugin.properties. Add
+ "(Incubation)".
+ * plugin.properties: Initial import.
+
+2008-10-24 Jeff Johnston <jjohnstn@redhat.com>
+
+ * plugin.xml: Remove libhover property and preferences pages which are not needed since
+ C/C++ Documentation properties page does the job.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHover.java:
+ (getMatchingFunctions): Pass document to getFunctionSummaryFromNode.
+ (constructTypes): Add groupsynopsis.
+ (getFunctionInfo): Pass document to getFunctionSummaryFromNode.
+ (getFunctionSummaryFromNode): Add groupsynopsis support.
+
+2008-10-22 Jeff Johnston <jjohnstn@redhat.com>
+
+ * plugin.properties: New file.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/CheckboxFieldEditor.java: New file.
+ * build.properties: Add plugin.properties to list of binary files.
+ * META-INF/MANIFEST.MF: Add Bundle-Localization statement.
+ * plugin.xml: Use translatable names for preference and property pages.
+ * schema/org.eclipse.linuxtools.cdt.libhover.library.exsd: Make id and name required.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHover.java:
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverMessages.java: Fix bundle name.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverMessages.properties: New messages.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibhoverPlugin.java (getID): New method.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/LibHoverPreferencePage.java (createFieldEditors):
+ Rewrite to use new CheckboxFieldEditor.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/PreferenceConstants.java: Add P_LIBHOVER.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/PreferenceInitializer.java (initializeDefaultPreferences):
+ Set up an unused default string.
+ * src/org/eclipse/linuxtools/cdt/libhover/properties/LibHoverPropertyPage.java: Rewritten to use the
+ CheckboxFieldEditor widgets on a property page.
+
+2008-10-15 Jeff Johnston <jjohnstn@redhat.com>
+
+ * build.properties: Specify javacSource and javacTarget to be 1.5.
+
+2008-09-19 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHover.java: Initial implementation moved
+ org.eclipse.cdt.linuxtools.autotools.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverMessages.java: Ditto.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverMessages.properties: Ditto.
+ * src/org/eclipse/linuxtools/cdt/libhover/LibHoverPlugin.java: New file.
+ * META-INF/MANIFEST.MF: Ditto.
+ * schema/org.eclipse.linuxtools.cdt.libhover.library.exsd: Ditto.
+ * about.html, build.properties, plugin.xml, plugin.properties: Ditto.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/LibHoverPreferencesPage.java: Ditto.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/PreferenceConstants.java: Ditto.
+ * src/org/eclipse/linuxtools/cdt/libhover/preferences/PreferenceInitializer.java: Ditto.
+ * src/org/eclipse/linuxtools/cdt/libhover/properties/LibHoverPropertyPage.java: Ditto.
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover/META-INF/MANIFEST.MF b/libhover/org.eclipse.linuxtools.cdt.libhover/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..fc024ea3be
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.linuxtools.cdt.libhover; singleton:=true
+Bundle-Version: 1.0.3.qualifier
+Bundle-Activator: org.eclipse.linuxtools.cdt.libhover.LibhoverPlugin
+Bundle-Vendor: %provider
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.help;bundle-version="3.3.100",
+ org.eclipse.cdt.ui;bundle-version="5.0.0",
+ org.eclipse.core.filesystem;bundle-version="1.2.0",
+ org.eclipse.cdt.core;bundle-version="5.0.0",
+ org.eclipse.cdt;bundle-version="5.0.0",
+ org.eclipse.ui.editors;bundle-version="3.4.0",
+ org.eclipse.jface.text;bundle-version="3.4.1"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.linuxtools.cdt.libhover
+Bundle-ActivationPolicy: lazy
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover/about.html b/libhover/org.eclipse.linuxtools.cdt.libhover/about.html
new file mode 100644
index 0000000000..23506a4bae
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover/about.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover/build.properties b/libhover/org.eclipse.linuxtools.cdt.libhover/build.properties
new file mode 100644
index 0000000000..d786219478
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover/build.properties
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ about.html,\
+ plugin.properties
+
+javacSource=1.5
+javacTarget=1.5
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover/plugin.properties b/libhover/org.eclipse.linuxtools.cdt.libhover/plugin.properties
new file mode 100644
index 0000000000..046bdca095
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover/plugin.properties
@@ -0,0 +1,14 @@
+#################################################################################
+# Copyright (c) 2008 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Red Hat Incorporated - initial API and implementation
+#################################################################################
+LibhoverPreference.name=Library Hover
+LibhoverProperty.name=Library Hover
+bundleName=C/C++ Libhover Plug-in (Incubation)
+provider=Eclipse Linux Tools \ No newline at end of file
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover/plugin.xml b/libhover/org.eclipse.linuxtools.cdt.libhover/plugin.xml
new file mode 100644
index 0000000000..7ece4f49be
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover/plugin.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="org.eclipse.linuxtools.cdt.libhover.library" name="C/C++ Library Hover Specifier" schema="schema/org.eclipse.linuxtools.cdt.libhover.library.exsd"/>
+
+ <extension
+ point="org.eclipse.cdt.ui.CHelpProvider">
+ <provider
+ class="org.eclipse.linuxtools.internal.cdt.libhover.LibHover"
+ id="org.eclipse.linuxtools.cdt.libhover.provider"/>
+ </extension>
+</plugin>
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/cdt/libhover/LibhoverPlugin.java b/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/cdt/libhover/LibhoverPlugin.java
new file mode 100644
index 0000000000..39e2b2b0c5
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/cdt/libhover/LibhoverPlugin.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.cdt.libhover;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class LibhoverPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.cdt.libhover";
+
+ // The shared instance
+ private static LibhoverPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public LibhoverPlugin() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static LibhoverPlugin getDefault() {
+ return plugin;
+ }
+
+ /*
+ * Returns the id of the plugin
+ */
+ public static String getID() {
+ return PLUGIN_ID;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/cdt/libhover/MemberInfo.java b/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/cdt/libhover/MemberInfo.java
new file mode 100644
index 0000000000..ac92c65375
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/cdt/libhover/MemberInfo.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.cdt.libhover;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class MemberInfo implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private String name;
+ private String prototype;
+ private String desc;
+ private String returnType;
+ private String[] paramTypes = new String[0];
+ private ArrayList<MemberInfo> children = null;
+
+ /**
+ * Constructor for member.
+ *
+ * @param name
+ */
+ public MemberInfo(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get member name.
+ *
+ * @return member name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get prototype for member.
+ *
+ * @return prototype string or null
+ */
+ public String getPrototype() {
+ return prototype;
+ }
+
+ /**
+ * Set prototype string.
+ *
+ * @param prototype
+ */
+ public void setPrototype(String prototype) {
+ this.prototype = prototype;
+ }
+
+ /**
+ * Get description for member.
+ *
+ * @return description string or null
+ */
+ public String getDescription() {
+ return desc;
+ }
+
+ /**
+ * Set description string for member.
+ *
+ * @param desc
+ */
+ public void setDescription(String desc) {
+ this.desc = desc;
+ }
+
+ /**
+ * Get param types for member.
+ *
+ * @return return array of param types
+ */
+ public String[] getParamTypes() {
+ return paramTypes;
+ }
+
+ /**
+ * Set param types for member.
+ *
+ * @param array of param types
+ */
+ public void setParamTypes(String[] paramTypes) {
+ this.paramTypes = paramTypes;
+ }
+ /**
+ * Get return type for member.
+ *
+ * @return return type as string or null
+ */
+ public String getReturnType() {
+ return returnType;
+ }
+
+ /**
+ * Set return type for member.
+ *
+ * @param returnType
+ */
+ public void setReturnType(String returnType) {
+ this.returnType = returnType;
+ }
+
+ /**
+ * Add a member with the same name as a child of this member.
+ *
+ * @param info a member with same name as this member.
+ */
+ public void addChild(MemberInfo info) {
+ if (children == null)
+ children = new ArrayList<MemberInfo>();
+ children.add(info);
+ }
+
+ /**
+ * Get the children members with same name as this member.
+ *
+ * @return an ArrayList of members with same name or null.
+ */
+ public ArrayList<MemberInfo> getChildren() {
+ return children;
+ }
+}
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/internal/cdt/libhover/LibHover.java b/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/internal/cdt/libhover/LibHover.java
new file mode 100644
index 0000000000..9585485768
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/internal/cdt/libhover/LibHover.java
@@ -0,0 +1,575 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006, 2007, 2008 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+/*
+ * Initially created on Jul 8, 2004
+ */
+
+/**
+ * @author Chris Moller, Red Hat, Inc.
+ * @author Jeff Johnston, Red Hat, Inc. (rewrite to use ICHelpProvider)
+ * Modified to be org.eclipse.linuxtools.cdt.libhover package.
+ */
+
+package org.eclipse.linuxtools.internal.cdt.libhover;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.Map.Entry;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.ICHelpBook;
+import org.eclipse.cdt.ui.ICHelpProvider;
+import org.eclipse.cdt.ui.ICHelpResourceDescriptor;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.IRequiredInclude;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.cdt.ui.text.IHoverHelpInvocationContext;
+import org.eclipse.cdt.ui.text.SharedASTJob;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.RegistryFactory;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.help.IHelpResource;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.linuxtools.cdt.libhover.ClassInfo;
+import org.eclipse.linuxtools.cdt.libhover.FunctionInfo;
+import org.eclipse.linuxtools.cdt.libhover.HelpBook;
+import org.eclipse.linuxtools.cdt.libhover.LibHoverInfo;
+import org.eclipse.linuxtools.cdt.libhover.LibhoverPlugin;
+import org.eclipse.linuxtools.cdt.libhover.MemberInfo;
+
+
+public class LibHover implements ICHelpProvider {
+
+ public static String LIBHOVER_DOC_EXTENSION = LibhoverPlugin.PLUGIN_ID + ".library"; //$NON-NLS-1$
+
+ // see comment in initialize()
+ // private static String defaultSearchPath = null;
+
+ private static HashMap<ICHelpBook, LibHoverLibrary> libraries = new HashMap<ICHelpBook, LibHoverLibrary>();
+
+ static final String constructTypes[] ={
+ "dtype", // $NON-NLS-1$
+ "enum", // $NON-NLS-1$
+ "function", // $NON-NLS-1$
+ "groupsynopsis", // $NON-NLS-1$
+ "struct", // $NON-NLS-1$
+ "type", // $NON-NLS-1$
+ "union" // $NON-NLS-1$
+ };
+
+ static final int dtypeIndex = 0;
+ static final int enumIndex = 1;
+ static final int functionIndex = 2;
+ static final int groupsynopsisIndex = 3;
+ static final int structIndex = 4;
+ static final int typeIndex = 5;
+ static final int unionIndex = 6;
+
+ private static ArrayList<ICHelpBook> helpBooks = new ArrayList<ICHelpBook>();
+ public static boolean docsFetched = false;
+
+ public static synchronized void getLibHoverDocs() {
+ if (docsFetched)
+ return;
+// System.out.println("getlibhoverdocs");
+ libraries.clear();
+ helpBooks.clear();
+ IExtensionRegistry x = RegistryFactory.getRegistry();
+ IConfigurationElement[] ces = x.getConfigurationElementsFor(LIBHOVER_DOC_EXTENSION);
+ for (int i = 0; i < ces.length; ++i) {
+ IConfigurationElement ce = ces[i];
+ if (ce.getName().equals("library")) { //$NON-NLS-1$
+ // see comment in initialize()
+ // Use the FileLocator class to open the magic hover doc file
+ // in the plugin's jar.
+ // Either open the html file or file system file depending
+ // on what has been specified.
+ String location = ce.getAttribute("location"); //$NON-NLS-1$
+ String name = ce.getAttribute("name"); //$NON-NLS-1$
+ String helpdocs = ce.getAttribute("docs"); //$NON-NLS-1$
+ String type = ce.getAttribute("type"); //$NON-NLS-1$
+ HelpBook h = new HelpBook(name, type);
+ helpBooks.add(h);
+ LibHoverLibrary l = new LibHoverLibrary(name, location, helpdocs,
+ true);
+ libraries.put(h, l);
+ docsFetched = true;
+ }
+ }
+ }
+
+ public void initialize() {
+ getLibHoverDocs();
+ }
+
+ public ICHelpBook[] getCHelpBooks () {
+ ICHelpBook[] chelpbooks = new ICHelpBook[helpBooks.size()];
+ return helpBooks.toArray(chelpbooks);
+ }
+
+ private class FunctionSummary implements IFunctionSummary, Comparable<FunctionSummary> {
+
+ private String Name;
+ private String NameSpace;
+ private String ReturnType;
+ private String Prototype;
+ private String Summary;
+ private boolean prototypeHasBrackets;
+
+// private String Synopsis;
+ private class RequiredInclude implements IRequiredInclude {
+ private String include;
+
+ public RequiredInclude (String file) {
+ include = file;
+ }
+
+ public String getIncludeName() {
+ return include;
+ }
+
+ public boolean isStandard() {
+ return true;
+ }
+ }
+
+ public int compareTo (FunctionSummary x) {
+ FunctionSummary y = (FunctionSummary)x;
+ return getName().compareTo(y.getName());
+ }
+
+// private RequiredInclude Includes[];
+ private ArrayList<RequiredInclude> Includes = new ArrayList<RequiredInclude>();
+
+ private void setIncludeName (String iname) {
+ RequiredInclude nri = new RequiredInclude(iname);
+ Includes.add(nri);
+ }
+
+ public class FunctionPrototypeSummary implements IFunctionPrototypeSummary {
+ public String getName() { return Name; }
+ public String getReturnType() { return ReturnType; }
+ public String getArguments() { return Prototype; }
+ public String getPrototypeString(boolean namefirst) {
+ if (true == namefirst) {
+ if (prototypeHasBrackets())
+ return Name + " " + Prototype + " " + ReturnType; // $NON-NLS-1$ // $NON-NLS-2$
+ return Name + " (" + Prototype + ") " + ReturnType; // $NON-NLS-1$ // $NON-NLS-2$
+ }
+ else {
+ if (prototypeHasBrackets())
+ return ReturnType + " " + Name + " " + Prototype; // $NON-NLS-1$ // $NON-NLS-2$
+ return ReturnType + " " + Name + " (" + Prototype + ")"; // $NON-NLS-1$ // $NON-NLS-2$ // $NON-NLS-3$
+ }
+ }
+ }
+
+ public String getName() { return Name; }
+ public String getNamespace() { return NameSpace; }
+ public String getDescription() { return Summary; }
+ public boolean prototypeHasBrackets() { return prototypeHasBrackets; }
+ public void setPrototypeHasBrackets(boolean value) { prototypeHasBrackets = value; }
+ public IFunctionPrototypeSummary getPrototype() { return new FunctionPrototypeSummary(); }
+
+ public IRequiredInclude[] getIncludes() {
+ IRequiredInclude[] includes = new IRequiredInclude[Includes.size()];
+ for (int i = 0; i < Includes.size(); ++i) {
+ includes[i] = (IRequiredInclude)Includes.get(i);
+ }
+ return includes;
+ }
+
+ }
+
+ public boolean isCPPCharacter(int ch) {
+ return Character.isLetterOrDigit(ch) || ch == '_' || ch == ':';
+ }
+
+ private class EnclosingASTNameJob extends SharedASTJob {
+ private int tlength;
+ private int toffset;
+ private IASTName result = null;
+ public EnclosingASTNameJob (ITranslationUnit t,
+ int toffset, int tlength) {
+ super("EnclosingASTNameJob", t); // $NON-NLS-1$
+ this.toffset = toffset;
+ this.tlength = tlength;
+ }
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+ if (ast != null) {
+ result = ast.getNodeSelector(null).findEnclosingName(toffset, tlength);
+ }
+ return Status.OK_STATUS;
+ }
+ public IASTName getASTName() {
+ return result;
+ }
+ }
+
+ public class ASTDeclarationFinderJob extends SharedASTJob {
+ private IBinding binding;
+ private IASTName[] decls = null;
+ public ASTDeclarationFinderJob (ITranslationUnit t, IBinding binding) {
+ super("ASTDeclarationFinderJob", t); // $NON-NLS-1$
+ this.binding = binding;
+ }
+ public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+ if (ast != null) {
+ decls = ast.getDeclarationsInAST(binding);
+ }
+ return Status.OK_STATUS;
+ }
+ public IASTName[] getDeclarations() {
+ return decls;
+ }
+ }
+
+ public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
+ IFunctionSummary f;
+
+ f = null;
+ ITranslationUnit t = context.getTranslationUnit();
+
+ String className = null;
+ ICPPFunctionType methodType = null;
+
+ if (t.isCXXLanguage()) {
+ try {
+ if (context instanceof IHoverHelpInvocationContext) {
+ // We know the file offset of the member reference.
+ IRegion region = (IRegion)((IHoverHelpInvocationContext)context).getHoverRegion();
+
+ // Now, let's find the declaration of the method. We need to do this because we want the specific
+ // member prototype to go searching for. There could be many members called "x" which have different
+ // documentation.
+ final IASTName[] result= {null};
+ EnclosingASTNameJob job = new EnclosingASTNameJob(t, region.getOffset(), region.getLength());
+ job.schedule();
+ try {
+ job.join();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (job.getResult() == Status.OK_STATUS)
+ result[0] = job.getASTName();
+ if (result[0] != null) {
+ final IBinding binding = result[0].getBinding();
+ // Check to see we have a member function.
+ if (binding instanceof ICPPFunction) {
+ methodType = ((ICPPFunction)binding).getType();
+ // We have a member function, find the class name.
+ IBinding owner = ((ICPPFunction)binding).getOwner();
+ if (owner instanceof ICPPClassType) {
+ className = getClassName((ICPPClassType)owner);
+ }
+ }
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (DOMException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ // Loop through all the documents we have and report first match.
+ for (int i = 0; i < helpBooks.length; ++i) {
+ LibHoverLibrary l = libraries.get(helpBooks[i]);
+ if (name != null) {
+ if (className != null) {
+ if (l.isCPP())
+ f = getMemberSummary(l, className, name, methodType);
+ } else {
+ f = getFunctionSummary(l, name);
+ }
+ if (f != null)
+ return f;
+ }
+ }
+
+ return null;
+ }
+
+ // Get the class name for a type, including any instance template parameters
+ // e.g. std::basic_string<char>
+ private String getClassName(ICPPClassType c) {
+ String className = null;
+ try {
+ String[] qualified = c.getQualifiedName();
+ className = qualified[0];
+ for (int k = 1; k < qualified.length; ++k) {
+ className += "::" + qualified[k];
+ }
+
+ // Check if we have an instance of a template class.
+ if (c instanceof ICPPTemplateInstance) {
+ ICPPTemplateInstance ti = (ICPPTemplateInstance)c;
+ // Get a map which tells us the values of the template
+ // arguments (e.g. _CharT maps to char in the instance).
+ ICPPTemplateParameterMap tiMap = ti.getTemplateParameterMap();
+ ICPPTemplateDefinition td = ti.getTemplateDefinition();
+ ICPPTemplateParameter[] templateArgs = td.getTemplateParameters();
+ className += "<";
+ String separator = "";
+ for (int x = 0; x < templateArgs.length; ++x) {
+ ICPPTemplateParameter tp = templateArgs[x];
+ ICPPTemplateArgument ta = tiMap.getArgument(tp);
+ IType type = null;
+ // The template may have a type specified or a value.
+ // In the case of a value, figure out its type and use
+ // that when we do a lookup.
+ if (ta.isTypeValue())
+ type = ta.getTypeValue();
+ else
+ type = ta.getTypeOfNonTypeValue();
+ if (tp.getTemplateNestingLevel() == 0) {
+ // if the parameter is a class type, use recursion to
+ // get its class name including template parameters
+ if (type instanceof ICPPClassType)
+ className += separator + getClassName((ICPPClassType)type);
+ else
+ className += separator + type.toString();
+ separator = ",";
+ }
+ }
+ className += ">";
+ }
+ } catch(DOMException e) {
+ return null;
+ }
+ return className;
+ }
+
+ private IFunctionSummary getFunctionSummary(LibHoverLibrary l, String name) {
+ FunctionInfo x = l.getFunctionInfo(name);
+ if (x != null) {
+ FunctionSummary f = new FunctionSummary();
+ f.ReturnType = x.getReturnType();
+ f.Prototype = x.getPrototype();
+ f.Summary = x.getDescription();
+ f.Name = x.getName();
+ ArrayList<String> headers = x.getHeaders();
+ for (int i = 0; i < headers.size(); ++i)
+ f.setIncludeName(headers.get(i));
+ return f;
+ }
+ return null;
+ }
+
+ private IFunctionSummary getMemberSummary(LibHoverLibrary l, String className,
+ String memberName, ICPPFunctionType methodType) {
+
+ ArrayList<String> templateTypes = new ArrayList<String>();
+ ClassInfo info = l.getClassInfo(className, templateTypes);
+ String[] args = new String[0];
+ @SuppressWarnings("unused")
+ IType returnType = null;
+ if (info == null)
+ return null;
+ if (methodType != null) {
+ try {
+ args = resolveArgs(info, methodType.getParameterTypes(), templateTypes);
+ returnType = methodType.getReturnType();
+ } catch (Exception e) {
+ return null;
+ }
+// for (int i = 0; i < args.length; ++i)
+// System.out.println("args<" + i + "> is " + args[i].toString());
+// System.out.println("return type is " + returnType.toString());
+
+ }
+ MemberInfo member = info.getMember(memberName);
+ if (member != null) {
+ MemberInfo m = null;
+ if (!isParmMatch(member, args, templateTypes, info)) {
+ ArrayList<MemberInfo> members = member.getChildren();
+ for (int i = 0; i < members.size(); ++i) {
+ MemberInfo k = members.get(i);
+ if (isParmMatch(k, args, templateTypes, info)) {
+ m = k;
+ break;
+ }
+ }
+ } else {
+ m = member;
+ }
+
+ if (m != null) {
+ // FIXME: do some work to determine parameters and return type.
+ FunctionSummary f = new FunctionSummary();
+ f.ReturnType = m.getReturnType();
+ f.Prototype = m.getPrototype();
+ f.Summary = m.getDescription();
+// String actualClassName = className.substring(className.indexOf("::")+2); // $NON-NLS-1$
+ f.Name = className + "::" + memberName; // $NON-NLS-1$
+ String[] templateParms = info.getTemplateParms();
+ for (int i = 0; i < templateTypes.size(); ++i) {
+ f.ReturnType = f.ReturnType.replaceAll(templateParms[i], templateTypes.get(i));
+ f.Prototype = f.Prototype.replaceAll(templateParms[i], templateTypes.get(i));
+ f.Name = f.Name.replaceAll(templateParms[i], templateTypes.get(i));
+ }
+ if (f.ReturnType.indexOf('<') >= 0) {
+ f.ReturnType = f.ReturnType.replaceAll("<", "&lt;");
+ f.ReturnType = f.ReturnType.replaceAll(">", "&gt;");
+ }
+ if (f.Prototype.indexOf('<') >= 0) {
+ f.Prototype = f.Prototype.replaceAll("<", "&lt;");
+ f.Prototype = f.Prototype.replaceAll(">", "&gt;");
+ }
+ if (f.Name.indexOf('<') >= 0) {
+ f.Name = f.Name.replaceAll("<", "&lt;");
+ f.Name = f.Name.replaceAll(">", "&gt;");
+ }
+ f.setPrototypeHasBrackets(true);
+ f.setIncludeName(info.getInclude());
+ return f;
+ }
+ }
+ return null;
+ }
+
+
+ private boolean isParmMatch(MemberInfo m, String[] args, ArrayList<String> templateTypes, ClassInfo info) {
+ String[] memberParms = m.getParamTypes();
+ for (int i = 0; i < memberParms.length; ++i) {
+ String[] templateParms = info.getTemplateParms();
+ for (int j = 0; j < templateTypes.size(); ++j) {
+ memberParms[i] = memberParms[i].replaceAll(templateParms[j], templateTypes.get(j));
+ }
+ }
+ return Arrays.equals(memberParms, args);
+ }
+
+ private String[] resolveArgs(ClassInfo info, IType[] parameterTypes, ArrayList<String> templateTypes) {
+ String[] templateParms = info.getTemplateParms();
+ String[] result = new String[parameterTypes.length];
+ for (int i = 0; i < parameterTypes.length; ++i) {
+ String param = parameterTypes[i].toString();
+ param = param.replaceAll("\\{.*\\}", "");
+ param = param.trim();
+ int index = param.indexOf("#");
+ while (index >= 0) {
+ // We assume no class has more than 9 template parms.
+ int digit = param.charAt(index + 1) - '0';
+ // where possible, replace template parms with real values
+ if (digit < templateTypes.size())
+ param = param.replaceFirst(param.substring(index, index + 2), templateTypes.get(digit));
+ else
+ param = param.replaceFirst(param.substring(index, index + 2), templateParms[digit]);
+ index = param.indexOf("#");
+ }
+ result[i] = param;
+ }
+ return result;
+ }
+
+ public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String prefix) {
+ ArrayList<IFunctionSummary> fList = new ArrayList<IFunctionSummary>();
+
+ for (int di = 0; di < helpBooks.length; ++di) {
+ LibHoverLibrary l = libraries.get(helpBooks[di]);
+ LibHoverInfo cppInfo = l.getHoverInfo();
+ SortedMap<String, FunctionInfo> map = cppInfo.functions.tailMap(prefix);
+ Set<Map.Entry<String, FunctionInfo>> c = map.entrySet();
+ for (Iterator<Entry<String, FunctionInfo>> i = c.iterator(); i.hasNext();) {
+ Map.Entry<String, FunctionInfo> e = (Map.Entry<String, FunctionInfo>)i.next();
+ FunctionInfo x = e.getValue();
+ if (x.getName().startsWith(prefix)) {
+ FunctionSummary f = new FunctionSummary();
+ f.ReturnType = x.getReturnType();
+ f.Prototype = x.getPrototype();
+ f.Summary = x.getDescription();
+ f.Name = x.getName();
+ ArrayList<String> headers = x.getHeaders();
+ for (int i1 = 0; i1 < headers.size(); ++i1)
+ f.setIncludeName(headers.get(i1));
+ fList.add(f);
+ }
+ }
+ }
+ IFunctionSummary[] summaries = new IFunctionSummary[fList.size()];
+ for (int k = 0; k < summaries.length; k++) {
+ summaries[k] = (IFunctionSummary)fList.get(k);
+ }
+ return summaries;
+ }
+
+ private class HelpResource implements IHelpResource {
+ private String href;
+ private String label;
+ public HelpResource(String href, String label) {
+ this.href = href;
+ this.label = label;
+ }
+ public String getHref() {
+ return href;
+ }
+ public String getLabel() {
+ return label;
+ }
+ }
+
+ private class HelpResourceDescriptor implements ICHelpResourceDescriptor {
+ private ICHelpBook helpbook;
+
+ public HelpResourceDescriptor(ICHelpBook helpbook) {
+ this.helpbook = helpbook;
+ }
+
+ public ICHelpBook getCHelpBook() {
+ return helpbook;
+ }
+
+ public IHelpResource[] getHelpResources() {
+ LibHoverLibrary l = libraries.get(helpbook);
+ if (l != null) {
+ IHelpResource[] hr = new IHelpResource[1];
+ hr[0] = new HelpResource(l.getLocation(), l.getName());
+ return hr;
+ }
+ return null;
+ }
+ }
+
+ public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
+ for (int i = 0; i < helpBooks.length; ++i) {
+ IFunctionSummary fs = getFunctionInfo(context, new ICHelpBook[]{helpBooks[i]}, name);
+ if (fs != null) {
+ return new HelpResourceDescriptor[]{new HelpResourceDescriptor(helpBooks[i])};
+ }
+ }
+ return null;
+ }
+}
diff --git a/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/internal/cdt/libhover/LibHoverLibrary.java b/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/internal/cdt/libhover/LibHoverLibrary.java
new file mode 100644
index 0000000000..d1310580e0
--- /dev/null
+++ b/libhover/org.eclipse.linuxtools.cdt.libhover/src/org/eclipse/linuxtools/internal/cdt/libhover/LibHoverLibrary.java
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.cdt.libhover;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.linuxtools.cdt.libhover.ClassInfo;
+import org.eclipse.linuxtools.cdt.libhover.FunctionInfo;
+import org.eclipse.linuxtools.cdt.libhover.LibHoverInfo;
+import org.eclipse.linuxtools.cdt.libhover.LibhoverPlugin;
+import org.eclipse.linuxtools.cdt.libhover.TypedefInfo;
+
+public class LibHoverLibrary {
+ private String name;
+ private String location;
+ private String docs;
+ private boolean isCPP;
+ private LibHoverInfo hoverInfo = new LibHoverInfo();
+ private boolean haveReadHoverInfo = false;
+
+ public LibHoverLibrary(String name, String location, String docs,
+ boolean isCPP) {
+ this.name = name;
+ this.location = location;
+ this.docs = docs;
+ this.isCPP = isCPP;
+ }
+
+ /**
+ * Get the name of the library
+ *
+ * @return the name of the library
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get the location of the library hover info (URL or file name)
+ *
+ * @return the URL or file name string for the library hover info location
+ */
+ public String getLocation() {
+ return location;
+ }
+
+ /**
+ * Get the browser help documentation URL for this library
+ *
+ * @return the name of the help documentation URL
+ */
+ public String getDocs() {
+ return docs;
+ }
+
+ /**
+ * Is this library a C++ library?
+ *
+ * @return true if C++ library, false otherwise
+ */
+ public boolean isCPP() {
+ return isCPP;
+ }
+
+ /**
+ * Get the library hover info for this library
+ *
+ * @return the library hover info for this library
+ */
+ public LibHoverInfo getHoverInfo() {
+ // We lazily get the hover info for this library since it is possible
+ // the user will never access or ultimately need it if another library
+ // supplies the information first.
+ if (!haveReadHoverInfo) {
+ URI acDoc;
+ try {
+ acDoc = new URI(location);
+ IPath p = URIUtil.toPath(acDoc);
+ InputStream docStream = null;
+ if (p == null) {
+ URL url = acDoc.toURL();
+ docStream = url.openStream();
+ } else {
+ try {
+ // Try to open the file as local to this plug-in.
+ docStream = FileLocator.openStream(LibhoverPlugin.getDefault().getBundle(), p, false);
+ } catch (IOException e) {
+ // File is not local to plug-in, try file system.
+ docStream = new FileInputStream(p.toFile());
+ }
+ }
+ ObjectInputStream input = new ObjectInputStream(docStream);
+ hoverInfo = (LibHoverInfo)input.readObject();
+ haveReadHoverInfo = true;
+ input.close();
+ docStream.close();
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return hoverInfo;
+ }
+
+ /**
+ * Set the library hover info.
+ *
+ * @param hoverInfo the library hover info to set
+ */
+ public void setHoverinfo(LibHoverInfo hoverInfo) {
+ this.hoverInfo = hoverInfo;
+ }
+
+ /**
+ * Fetch the class info for a given class.
+ *
+ * @param className the name of the class to fetch info for
+ * @return ClassInfo or null if no class info can be found
+ */
+ public ClassInfo getClassInfo(String className, ArrayList<String> templateTypes) {
+ String typedefName = className.replaceAll("<.*>", "<>"); // $NON-NLS-1$ // $NON-NLS-2$
+ TypedefInfo typedef = getHoverInfo().typedefs.get(typedefName);
+ if (typedef != null) {
+ className = typedef.getTransformedType(className); // Reset class name to typedef transformation
+ }
+ int index = className.indexOf('<');
+ // Check if it is a template reference.
+ if (index != -1) {
+ resolveTemplateTypes(className, templateTypes, index);
+ // It is. We want to see if there are partial specific templates
+ // and we choose the first match. If nothing matches our particular
+ // case, we fall back on the initial generic template.
+ ClassInfo info = getHoverInfo().classes.get(className.substring(0, index));
+ if (info != null) {
+ ArrayList<ClassInfo> children = info.getChildren();
+ if (children != null && children.size() > 0) {
+ for (int x = 0; x < children.size(); ++x) {
+ ClassInfo child = children.get(x);
+ if (className.matches(child.getClassName())) {
+ info = child;
+ break;
+ }
+ }
+ }
+ }
+ return info;
+ }
+ // Otherwise no template, just fetch the class info directly.
+ return getHoverInfo().classes.get(className);
+ }
+
+ private void resolveTemplateTypes(String className,
+ ArrayList<String> templateTypes, int index) {
+ int startIndex = index + 1;
+ int i = startIndex;
+ int count = 1;
+ while (count > 0 && i < className.length()) {
+ char x = className.charAt(i);
+ switch (x) {
+ case ('<'):
+ ++count;
+ break;
+ case ('>'):
+ --count;
+ if (count == 0)
+ templateTypes.add(className.substring(startIndex, i).trim());
+ break;
+ case (','): {
+ if (count == 1) {
+ templateTypes.add(className.substring(startIndex, i).trim());
+ startIndex = i + 1;
+ }
+ }
+ break;
+ }
+ ++i;
+ }
+ }
+
+ /**
+ * Fetch the function info for a given function.
+ *
+ * @param name of function to find info for
+ * @return FunctionInfo or null if no function info exists
+ */
+ public FunctionInfo getFunctionInfo(String name) {
+ return getHoverInfo().functions.get(name);
+ }
+}
+

Back to the top