mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Warnings elimination.
This commit is contained in:
parent
98fbb87384
commit
706f8fe3ef
5 changed files with 117 additions and 52 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007, 2008 Intel Corporation and others.
|
||||||
|
* 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:
|
||||||
|
* Intel Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.help;
|
package org.eclipse.cdt.internal.ui.help;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -32,7 +42,7 @@ public class CFunctionSummary implements IFunctionSummary {
|
||||||
String args = null;
|
String args = null;
|
||||||
String type = null;
|
String type = null;
|
||||||
NodeList list = e.getChildNodes();
|
NodeList list = e.getChildNodes();
|
||||||
ArrayList incList = new ArrayList();
|
ArrayList<IRequiredInclude> incList = new ArrayList<IRequiredInclude>();
|
||||||
for(int j = 0; j < list.getLength(); j++){
|
for(int j = 0; j < list.getLength(); j++){
|
||||||
Node node = list.item(j);
|
Node node = list.item(j);
|
||||||
if(node.getNodeType() != Node.ELEMENT_NODE)
|
if(node.getNodeType() != Node.ELEMENT_NODE)
|
||||||
|
@ -58,8 +68,7 @@ public class CFunctionSummary implements IFunctionSummary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (incList.size() > 0)
|
if (incList.size() > 0)
|
||||||
incs = (IRequiredInclude[])incList.toArray(
|
incs = incList.toArray(new IRequiredInclude[incList.size()]);
|
||||||
new IRequiredInclude[incList.size()]);
|
|
||||||
fps = new FunctionPrototypeSummary(type + SP + name + LB + args + RB);
|
fps = new FunctionPrototypeSummary(type + SP + name + LB + args + RB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007, 2008 Intel Corporation and others.
|
||||||
|
* 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:
|
||||||
|
* Intel Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.help;
|
package org.eclipse.cdt.internal.ui.help;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -27,10 +37,10 @@ public class CHelpBook implements ICHelpBook {
|
||||||
|
|
||||||
private int type;
|
private int type;
|
||||||
private String title;
|
private String title;
|
||||||
private TreeMap entries;
|
private TreeMap<String, CHelpEntry> entries;
|
||||||
|
|
||||||
public CHelpBook(Element e) {
|
public CHelpBook(Element e) {
|
||||||
entries = new TreeMap();
|
entries = new TreeMap<String, CHelpEntry>();
|
||||||
|
|
||||||
if (e.hasAttribute(ATTR_TITLE))
|
if (e.hasAttribute(ATTR_TITLE))
|
||||||
title = e.getAttribute(ATTR_TITLE).trim();
|
title = e.getAttribute(ATTR_TITLE).trim();
|
||||||
|
@ -59,7 +69,7 @@ public class CHelpBook implements ICHelpBook {
|
||||||
if(NODE_ENTRY.equals(node.getNodeName())) {
|
if(NODE_ENTRY.equals(node.getNodeName())) {
|
||||||
CHelpEntry he = new CHelpEntry((Element)node);
|
CHelpEntry he = new CHelpEntry((Element)node);
|
||||||
if (he.isValid())
|
if (he.isValid())
|
||||||
add(he.getKeyword(), he);
|
entries.put(he.getKeyword(), he);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,16 +82,12 @@ public class CHelpBook implements ICHelpBook {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(String keyword, Object entry) {
|
|
||||||
entries.put(keyword, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IFunctionSummary getFunctionInfo(
|
public IFunctionSummary getFunctionInfo(
|
||||||
ICHelpInvocationContext context,
|
ICHelpInvocationContext context,
|
||||||
String name) {
|
String name) {
|
||||||
|
|
||||||
if (entries.containsKey(name)) {
|
if (entries.containsKey(name)) {
|
||||||
CHelpEntry he = (CHelpEntry)entries.get(name);
|
CHelpEntry he = entries.get(name);
|
||||||
IFunctionSummary[] fs = he.getFunctionSummary();
|
IFunctionSummary[] fs = he.getFunctionSummary();
|
||||||
if (fs != null && fs.length > 0)
|
if (fs != null && fs.length > 0)
|
||||||
return fs[0];
|
return fs[0];
|
||||||
|
@ -95,11 +101,11 @@ public class CHelpBook implements ICHelpBook {
|
||||||
* @param prefix
|
* @param prefix
|
||||||
* @return matching functions
|
* @return matching functions
|
||||||
*/
|
*/
|
||||||
public List getMatchingFunctions(
|
public List<IFunctionSummary> getMatchingFunctions(
|
||||||
ICHelpInvocationContext context,
|
ICHelpInvocationContext context,
|
||||||
String prefix) {
|
String prefix) {
|
||||||
|
|
||||||
Collection col = null;
|
Collection<CHelpEntry> col = null;
|
||||||
if (prefix == null || prefix.trim().length() == 0) {
|
if (prefix == null || prefix.trim().length() == 0) {
|
||||||
// return whole data
|
// return whole data
|
||||||
col = entries.values();
|
col = entries.values();
|
||||||
|
@ -115,22 +121,26 @@ public class CHelpBook implements ICHelpBook {
|
||||||
} else
|
} else
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
SortedMap sm = (i>-1) ?
|
SortedMap<String, CHelpEntry> sm = (i>-1) ?
|
||||||
entries.subMap(pr1, new String(bs)) :
|
entries.subMap(pr1, new String(bs)) :
|
||||||
entries.tailMap(pr1);
|
entries.tailMap(pr1);
|
||||||
col = sm.values();
|
col = sm.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col.size() > 0)
|
if (col.size() > 0) {
|
||||||
return new ArrayList(col);
|
ArrayList<IFunctionSummary> out = new ArrayList<IFunctionSummary>(col.size());
|
||||||
else
|
for (CHelpEntry he: col)
|
||||||
|
for (IFunctionSummary fs : he.getFunctionSummary())
|
||||||
|
out.add(fs);
|
||||||
|
return out;
|
||||||
|
} else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICHelpResourceDescriptor getHelpResources(
|
public ICHelpResourceDescriptor getHelpResources(
|
||||||
ICHelpInvocationContext context, String name) {
|
ICHelpInvocationContext context, String name) {
|
||||||
if (entries.containsKey(name)) {
|
if (entries.containsKey(name)) {
|
||||||
CHelpEntry he = (CHelpEntry)entries.get(name);
|
CHelpEntry he = entries.get(name);
|
||||||
IHelpResource[] hr = he.getHelpResource();
|
IHelpResource[] hr = he.getHelpResource();
|
||||||
if (hr != null && hr.length > 0)
|
if (hr != null && hr.length > 0)
|
||||||
return new HRDescriptor(this, hr);
|
return new HRDescriptor(this, hr);
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007, 2008 Intel Corporation and others.
|
||||||
|
* 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:
|
||||||
|
* Intel Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.help;
|
package org.eclipse.cdt.internal.ui.help;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -21,8 +31,8 @@ public class CHelpEntry {
|
||||||
|
|
||||||
public CHelpEntry(Element e) {
|
public CHelpEntry(Element e) {
|
||||||
keyword = e.getAttribute(ATTR_KEYWD).trim();
|
keyword = e.getAttribute(ATTR_KEYWD).trim();
|
||||||
ArrayList obs1 = new ArrayList();
|
ArrayList<CFunctionSummary> obs1 = new ArrayList<CFunctionSummary>();
|
||||||
ArrayList obs2 = new ArrayList();
|
ArrayList<CHelpTopic> obs2 = new ArrayList<CHelpTopic>();
|
||||||
NodeList list = e.getChildNodes();
|
NodeList list = e.getChildNodes();
|
||||||
for(int i = 0; i < list.getLength(); i++){
|
for(int i = 0; i < list.getLength(); i++){
|
||||||
Node node = list.item(i);
|
Node node = list.item(i);
|
||||||
|
@ -34,8 +44,8 @@ public class CHelpEntry {
|
||||||
obs2.add(new CHelpTopic((Element)node, keyword));
|
obs2.add(new CHelpTopic((Element)node, keyword));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fss = (CFunctionSummary[])obs1.toArray(new CFunctionSummary[obs1.size()]);
|
fss = obs1.toArray(new CFunctionSummary[obs1.size()]);
|
||||||
hts = (CHelpTopic[])obs2.toArray(new CHelpTopic[obs2.size()]);
|
hts = obs2.toArray(new CHelpTopic[obs2.size()]);
|
||||||
|
|
||||||
if (fss.length == 0 && hts.length == 0)
|
if (fss.length == 0 && hts.length == 0)
|
||||||
isValid = false; // nothing to display
|
isValid = false; // nothing to display
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007, 2008 Intel Corporation and others.
|
||||||
|
* 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:
|
||||||
|
* Intel Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.help;
|
package org.eclipse.cdt.internal.ui.help;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
@ -40,9 +50,12 @@ public class CHelpProvider implements ICHelpProvider {
|
||||||
private static final String NODE_HEAD = "documentation"; //$NON-NLS-1$
|
private static final String NODE_HEAD = "documentation"; //$NON-NLS-1$
|
||||||
private static final String NODE_BOOK = "helpBook"; //$NON-NLS-1$
|
private static final String NODE_BOOK = "helpBook"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private boolean Done = false;
|
||||||
|
|
||||||
ICHelpBook[] hbs = null;
|
ICHelpBook[] hbs = null;
|
||||||
|
|
||||||
public ICHelpBook[] getCHelpBooks() {
|
public ICHelpBook[] getCHelpBooks() {
|
||||||
|
waitForDone();
|
||||||
return hbs;
|
return hbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,18 +76,17 @@ public class CHelpProvider implements ICHelpProvider {
|
||||||
public ICHelpResourceDescriptor[] getHelpResources(
|
public ICHelpResourceDescriptor[] getHelpResources(
|
||||||
ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
|
ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
|
||||||
|
|
||||||
ArrayList lst = new ArrayList();
|
ArrayList<ICHelpResourceDescriptor> lst = new ArrayList<ICHelpResourceDescriptor>();
|
||||||
for (int i=0; i<helpBooks.length; i++) {
|
for (ICHelpBook h : helpBooks) {
|
||||||
if (helpBooks[i] instanceof CHelpBook) {
|
if (h instanceof CHelpBook) {
|
||||||
ICHelpResourceDescriptor hrd =
|
ICHelpResourceDescriptor hrd =
|
||||||
((CHelpBook)helpBooks[i]).getHelpResources(context, name);
|
((CHelpBook)h).getHelpResources(context, name);
|
||||||
if (hrd != null)
|
if (hrd != null)
|
||||||
lst.add(hrd);
|
lst.add(hrd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lst.size() > 0)
|
if (lst.size() > 0)
|
||||||
return (ICHelpResourceDescriptor[])lst.toArray(
|
return lst.toArray(new ICHelpResourceDescriptor[lst.size()]);
|
||||||
new ICHelpResourceDescriptor[lst.size()]);
|
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -82,50 +94,64 @@ public class CHelpProvider implements ICHelpProvider {
|
||||||
public IFunctionSummary[] getMatchingFunctions(
|
public IFunctionSummary[] getMatchingFunctions(
|
||||||
ICHelpInvocationContext context, ICHelpBook[] helpBooks,
|
ICHelpInvocationContext context, ICHelpBook[] helpBooks,
|
||||||
String prefix) {
|
String prefix) {
|
||||||
ArrayList lst = new ArrayList();
|
ArrayList<IFunctionSummary> lst = new ArrayList<IFunctionSummary>();
|
||||||
for (int i=0; i<helpBooks.length; i++) {
|
for (int i=0; i<helpBooks.length; i++) {
|
||||||
if (helpBooks[i] instanceof CHelpBook) {
|
if (helpBooks[i] instanceof CHelpBook) {
|
||||||
List fs = ((CHelpBook)helpBooks[i]).getMatchingFunctions(context, prefix);
|
List<IFunctionSummary> fs = ((CHelpBook)helpBooks[i]).getMatchingFunctions(context, prefix);
|
||||||
if (fs != null) // if null, try with another book
|
if (fs != null) // if null, try with another book
|
||||||
lst.addAll(fs);
|
lst.addAll(fs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lst.size() > 0)
|
if (lst.size() > 0)
|
||||||
return (IFunctionSummary[])lst.toArray(new IFunctionSummary[lst.size()]);
|
return lst.toArray(new IFunctionSummary[lst.size()]);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
// (new Thread() {
|
||||||
|
// public void run() {
|
||||||
loadExtensions();
|
loadExtensions();
|
||||||
System.out.println();
|
// }
|
||||||
|
// }).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void waitForDone() {
|
||||||
|
if (hbs != null)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
while (! Done ) Thread.sleep(10);
|
||||||
|
} catch (InterruptedException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadExtensions()
|
private void loadExtensions()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
|
IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
|
||||||
.getExtensionPoint(EXTENSION_POINT_ID);
|
.getExtensionPoint(EXTENSION_POINT_ID);
|
||||||
if (extensionPoint == null) return;
|
if (extensionPoint != null) {
|
||||||
IExtension[] extensions = extensionPoint.getExtensions();
|
IExtension[] extensions = extensionPoint.getExtensions();
|
||||||
if (extensions == null) return;
|
if (extensions != null) {
|
||||||
|
ArrayList<ICHelpBook> chbl = new ArrayList<ICHelpBook>();
|
||||||
ArrayList chbl = new ArrayList();
|
for (IExtension ex: extensions) {
|
||||||
|
String pluginId = ex.getNamespaceIdentifier();
|
||||||
for (int i = 0; i < extensions.length; ++i) {
|
for (IConfigurationElement el : ex.getConfigurationElements()) {
|
||||||
String pluginId = extensions[i].getNamespaceIdentifier();
|
if (el.getName().equals(ELEMENT_NAME)) {
|
||||||
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
|
loadFile(el, chbl, pluginId);
|
||||||
for (int k = 0; k < elements.length; k++) {
|
|
||||||
if (elements[k].getName().equals(ELEMENT_NAME)) {
|
|
||||||
loadFile(elements[k], chbl, pluginId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (chbl.size() > 0) {
|
if (chbl.size() > 0) {
|
||||||
hbs = (ICHelpBook[])chbl.toArray(new ICHelpBook[chbl.size()]);
|
hbs = chbl.toArray(new ICHelpBook[chbl.size()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
Done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadFile(IConfigurationElement el, ArrayList chbl, String pluginId) {
|
private void loadFile(IConfigurationElement el, ArrayList<ICHelpBook> chbl, String pluginId) {
|
||||||
String fname = el.getAttribute(ATTRIB_FILE);
|
String fname = el.getAttribute(ATTRIB_FILE);
|
||||||
if (fname == null || fname.trim().length() == 0) return;
|
if (fname == null || fname.trim().length() == 0) return;
|
||||||
URL x = FileLocator.find(Platform.getBundle(pluginId), new Path(fname), null);
|
URL x = FileLocator.find(Platform.getBundle(pluginId), new Path(fname), null);
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007, 2008 Intel Corporation and others.
|
||||||
|
* 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:
|
||||||
|
* Intel Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.help;
|
package org.eclipse.cdt.internal.ui.help;
|
||||||
|
|
||||||
import org.eclipse.help.IHelpResource;
|
import org.eclipse.help.IHelpResource;
|
||||||
|
|
Loading…
Add table
Reference in a new issue