1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Warnings elimination.

This commit is contained in:
Oleg Krasilnikov 2008-02-20 15:31:27 +00:00
parent 98fbb87384
commit 706f8fe3ef
5 changed files with 117 additions and 52 deletions

View file

@ -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;
import java.util.ArrayList;
@ -32,7 +42,7 @@ public class CFunctionSummary implements IFunctionSummary {
String args = null;
String type = null;
NodeList list = e.getChildNodes();
ArrayList incList = new ArrayList();
ArrayList<IRequiredInclude> incList = new ArrayList<IRequiredInclude>();
for(int j = 0; j < list.getLength(); j++){
Node node = list.item(j);
if(node.getNodeType() != Node.ELEMENT_NODE)
@ -58,8 +68,7 @@ public class CFunctionSummary implements IFunctionSummary {
}
}
if (incList.size() > 0)
incs = (IRequiredInclude[])incList.toArray(
new IRequiredInclude[incList.size()]);
incs = incList.toArray(new IRequiredInclude[incList.size()]);
fps = new FunctionPrototypeSummary(type + SP + name + LB + args + RB);
}

View file

@ -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;
import java.util.ArrayList;
@ -27,10 +37,10 @@ public class CHelpBook implements ICHelpBook {
private int type;
private String title;
private TreeMap entries;
private TreeMap<String, CHelpEntry> entries;
public CHelpBook(Element e) {
entries = new TreeMap();
entries = new TreeMap<String, CHelpEntry>();
if (e.hasAttribute(ATTR_TITLE))
title = e.getAttribute(ATTR_TITLE).trim();
@ -59,7 +69,7 @@ public class CHelpBook implements ICHelpBook {
if(NODE_ENTRY.equals(node.getNodeName())) {
CHelpEntry he = new CHelpEntry((Element)node);
if (he.isValid())
add(he.getKeyword(), he);
entries.put(he.getKeyword(), he);
}
}
}
@ -72,16 +82,12 @@ public class CHelpBook implements ICHelpBook {
return title;
}
private void add(String keyword, Object entry) {
entries.put(keyword, entry);
}
public IFunctionSummary getFunctionInfo(
ICHelpInvocationContext context,
String name) {
if (entries.containsKey(name)) {
CHelpEntry he = (CHelpEntry)entries.get(name);
CHelpEntry he = entries.get(name);
IFunctionSummary[] fs = he.getFunctionSummary();
if (fs != null && fs.length > 0)
return fs[0];
@ -95,11 +101,11 @@ public class CHelpBook implements ICHelpBook {
* @param prefix
* @return matching functions
*/
public List getMatchingFunctions(
public List<IFunctionSummary> getMatchingFunctions(
ICHelpInvocationContext context,
String prefix) {
Collection col = null;
Collection<CHelpEntry> col = null;
if (prefix == null || prefix.trim().length() == 0) {
// return whole data
col = entries.values();
@ -115,22 +121,26 @@ public class CHelpBook implements ICHelpBook {
} else
i--;
}
SortedMap sm = (i>-1) ?
SortedMap<String, CHelpEntry> sm = (i>-1) ?
entries.subMap(pr1, new String(bs)) :
entries.tailMap(pr1);
col = sm.values();
}
if (col.size() > 0)
return new ArrayList(col);
else
if (col.size() > 0) {
ArrayList<IFunctionSummary> out = new ArrayList<IFunctionSummary>(col.size());
for (CHelpEntry he: col)
for (IFunctionSummary fs : he.getFunctionSummary())
out.add(fs);
return out;
} else
return null;
}
public ICHelpResourceDescriptor getHelpResources(
ICHelpInvocationContext context, String name) {
if (entries.containsKey(name)) {
CHelpEntry he = (CHelpEntry)entries.get(name);
CHelpEntry he = entries.get(name);
IHelpResource[] hr = he.getHelpResource();
if (hr != null && hr.length > 0)
return new HRDescriptor(this, hr);

View file

@ -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;
import java.util.ArrayList;
@ -21,8 +31,8 @@ public class CHelpEntry {
public CHelpEntry(Element e) {
keyword = e.getAttribute(ATTR_KEYWD).trim();
ArrayList obs1 = new ArrayList();
ArrayList obs2 = new ArrayList();
ArrayList<CFunctionSummary> obs1 = new ArrayList<CFunctionSummary>();
ArrayList<CHelpTopic> obs2 = new ArrayList<CHelpTopic>();
NodeList list = e.getChildNodes();
for(int i = 0; i < list.getLength(); i++){
Node node = list.item(i);
@ -34,8 +44,8 @@ public class CHelpEntry {
obs2.add(new CHelpTopic((Element)node, keyword));
}
}
fss = (CFunctionSummary[])obs1.toArray(new CFunctionSummary[obs1.size()]);
hts = (CHelpTopic[])obs2.toArray(new CHelpTopic[obs2.size()]);
fss = obs1.toArray(new CFunctionSummary[obs1.size()]);
hts = obs2.toArray(new CHelpTopic[obs2.size()]);
if (fss.length == 0 && hts.length == 0)
isValid = false; // nothing to display

View file

@ -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;
import java.io.BufferedReader;
@ -39,10 +49,13 @@ public class CHelpProvider implements ICHelpProvider {
private static final String ATTRIB_FILE = "file"; //$NON-NLS-1$
private static final String NODE_HEAD = "documentation"; //$NON-NLS-1$
private static final String NODE_BOOK = "helpBook"; //$NON-NLS-1$
private boolean Done = false;
ICHelpBook[] hbs = null;
public ICHelpBook[] getCHelpBooks() {
waitForDone();
return hbs;
}
@ -63,18 +76,17 @@ public class CHelpProvider implements ICHelpProvider {
public ICHelpResourceDescriptor[] getHelpResources(
ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
ArrayList lst = new ArrayList();
for (int i=0; i<helpBooks.length; i++) {
if (helpBooks[i] instanceof CHelpBook) {
ArrayList<ICHelpResourceDescriptor> lst = new ArrayList<ICHelpResourceDescriptor>();
for (ICHelpBook h : helpBooks) {
if (h instanceof CHelpBook) {
ICHelpResourceDescriptor hrd =
((CHelpBook)helpBooks[i]).getHelpResources(context, name);
((CHelpBook)h).getHelpResources(context, name);
if (hrd != null)
lst.add(hrd);
}
}
if (lst.size() > 0)
return (ICHelpResourceDescriptor[])lst.toArray(
new ICHelpResourceDescriptor[lst.size()]);
return lst.toArray(new ICHelpResourceDescriptor[lst.size()]);
else
return null;
}
@ -82,50 +94,64 @@ public class CHelpProvider implements ICHelpProvider {
public IFunctionSummary[] getMatchingFunctions(
ICHelpInvocationContext context, ICHelpBook[] helpBooks,
String prefix) {
ArrayList lst = new ArrayList();
ArrayList<IFunctionSummary> lst = new ArrayList<IFunctionSummary>();
for (int i=0; i<helpBooks.length; i++) {
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
lst.addAll(fs);
}
}
if (lst.size() > 0)
return (IFunctionSummary[])lst.toArray(new IFunctionSummary[lst.size()]);
return lst.toArray(new IFunctionSummary[lst.size()]);
else
return null;
}
public void initialize() {
loadExtensions();
System.out.println();
// (new Thread() {
// public void run() {
loadExtensions();
// }
// }).run();
}
private void waitForDone() {
if (hbs != null)
return;
try {
while (! Done ) Thread.sleep(10);
} catch (InterruptedException e) {}
}
private void loadExtensions()
{
IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
.getExtensionPoint(EXTENSION_POINT_ID);
if (extensionPoint == null) return;
IExtension[] extensions = extensionPoint.getExtensions();
if (extensions == null) return;
ArrayList chbl = new ArrayList();
for (int i = 0; i < extensions.length; ++i) {
String pluginId = extensions[i].getNamespaceIdentifier();
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
for (int k = 0; k < elements.length; k++) {
if (elements[k].getName().equals(ELEMENT_NAME)) {
loadFile(elements[k], chbl, pluginId);
try {
IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
.getExtensionPoint(EXTENSION_POINT_ID);
if (extensionPoint != null) {
IExtension[] extensions = extensionPoint.getExtensions();
if (extensions != null) {
ArrayList<ICHelpBook> chbl = new ArrayList<ICHelpBook>();
for (IExtension ex: extensions) {
String pluginId = ex.getNamespaceIdentifier();
for (IConfigurationElement el : ex.getConfigurationElements()) {
if (el.getName().equals(ELEMENT_NAME)) {
loadFile(el, chbl, pluginId);
}
}
}
if (chbl.size() > 0) {
hbs = chbl.toArray(new ICHelpBook[chbl.size()]);
}
}
}
}
if (chbl.size() > 0) {
hbs = (ICHelpBook[])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);
if (fname == null || fname.trim().length() == 0) return;
URL x = FileLocator.find(Platform.getBundle(pluginId), new Path(fname), null);

View file

@ -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;
import org.eclipse.help.IHelpResource;