1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Fix warnings.

This commit is contained in:
Markus Schorn 2008-04-25 14:24:53 +00:00
parent 73c405bc38
commit 0b1b9a6092
31 changed files with 111 additions and 641 deletions

View file

@ -41,7 +41,6 @@ Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.core.templateengine.process.processes,
org.eclipse.cdt.internal.core;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.debug.core",
org.eclipse.cdt.internal.core.browser;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.browser.util;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.cdtvariables;x-internal:=true,
org.eclipse.cdt.internal.core.dom;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.dom.parser;x-friends:="org.eclipse.cdt.ui",

View file

@ -22,7 +22,7 @@ import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.browser.util.IndexModelUtil;
import org.eclipse.cdt.internal.core.browser.IndexModelUtil;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;

View file

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.browser;
public interface IQualifiedTypeName extends Comparable {
public interface IQualifiedTypeName extends Comparable<IQualifiedTypeName> {
public final static String QUALIFIER = "::"; //$NON-NLS-1$

View file

@ -17,7 +17,7 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
/**
* Type information.
*/
public interface ITypeInfo extends Comparable {
public interface ITypeInfo {
public static final int KNOWN_TYPES[] = {
ICElement.C_NAMESPACE,

View file

@ -40,8 +40,8 @@ public interface ITypeSearchScope {
public void clear();
public ICProject[] getEnclosingProjects();
public Collection pathSet();
public Collection containerSet();
public Collection projectSet();
public Collection enclosingProjectSet();
public Collection<IPath> pathSet();
public Collection<IPath> containerSet();
public Collection<ICProject> projectSet();
public Collection<ICProject> enclosingProjectSet();
}

View file

@ -36,8 +36,8 @@ import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.core.browser.IndexModelUtil;
import org.eclipse.cdt.internal.core.browser.IndexTypeReference;
import org.eclipse.cdt.internal.core.browser.util.IndexModelUtil;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
@ -59,8 +59,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
if (array == null)
return 0;
int result = 1;
for (int index = 0; index < array.length; index++) {
result = prime * result + (array[index] == null ? 0 : array[index].hashCode());
for (String element : array) {
result = prime * result + (element == null ? 0 : element.hashCode());
}
return result;
}
@ -248,8 +248,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
if (names.length == 0) {
names= index.findNames(ibs[0], IIndex.FIND_DECLARATIONS);
}
for (int i = 0; i < names.length; i++) {
reference= createReference(ibs[0], names[i]);
for (IIndexName name : names) {
reference= createReference(ibs[0], name);
if (reference != null) {
break;
}
@ -312,8 +312,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
IIndexMacro[] macros = index.findMacros(fqn[0].toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
if(macros.length>0) {
for (int i = 0; i < macros.length; i++) {
reference= createReference(macros[i]);
for (IIndexMacro macro : macros) {
reference= createReference(macro);
if (reference != null) {
break;
}
@ -368,15 +368,13 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
index.acquireReadLock();
IIndexBinding[] ibs= findBindings();
HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<IIndexFileLocation, IIndexFile>();
for (int i = 0; i < ibs.length; i++) {
IIndexBinding binding = ibs[i];
for (IIndexBinding binding : ibs) {
IIndexName[] names;
names= index.findNames(binding, IIndex.FIND_DEFINITIONS);
if (names.length == 0) {
names= index.findNames(binding, IIndex.FIND_DECLARATIONS);
}
for (int j= 0; j < names.length; j++) {
IIndexName indexName = names[j];
for (IIndexName indexName : names) {
if (checkFile(iflMap, indexName.getFile())) {
IndexTypeReference ref= createReference(binding, indexName);
if (ref != null) {
@ -406,8 +404,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
// in case a file is represented multiple times in the index then we take references from
// one of those, only.
HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<IIndexFileLocation, IIndexFile>();
for (int i = 0; i < ibs.length; i++) {
IIndexMacro macro= ibs[i];
for (IIndexMacro macro : ibs) {
if (checkParameters(macro.getParameterList())) {
if (checkFile(iflMap, macro.getFile())) {
IndexTypeReference ref= createReference(macro);
@ -515,10 +512,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
throw new PDOMNotImplementedError();
}
public int compareTo(Object arg0) {
throw new PDOMNotImplementedError();
}
/*
* @see org.eclipse.cdt.internal.core.browser.IFunctionInfo#getParameters()
*/

View file

@ -299,16 +299,6 @@ public class QualifiedTypeName implements IQualifiedTypeName {
return getFullyQualifiedName();
}
public int compareTo(Object obj) {
if (obj == this) {
return 0;
}
if (!(obj instanceof IQualifiedTypeName)) {
throw new ClassCastException();
}
return compareTo((IQualifiedTypeName)obj);
}
public int compareTo(IQualifiedTypeName typeName) {
if (typeName == this)
return 0;

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.core.browser;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.core.browser.util.ArrayUtil;
public class TypeInfo implements ITypeInfo
{
@ -260,7 +259,11 @@ public class TypeInfo implements ITypeInfo
}
public static boolean isValidType(int type) {
return ArrayUtil.contains(KNOWN_TYPES, type);
for (int i= 0; i < KNOWN_TYPES.length; ++i) {
if (KNOWN_TYPES[i] == type)
return true;
}
return false;
}
public void addDerivedReference(ITypeReference location) {

View file

@ -28,10 +28,10 @@ import org.eclipse.core.runtime.Path;
public class TypeSearchScope implements ITypeSearchScope {
private Set fPathSet = new HashSet();
private Set fContainerSet = new HashSet();
private Set fProjectSet = new HashSet();
private Set fEnclosingProjectSet = new HashSet();
private Set<IPath> fPathSet = new HashSet<IPath>();
private Set<IPath> fContainerSet = new HashSet<IPath>();
private Set<ICProject> fProjectSet = new HashSet<ICProject>();
private Set<ICProject> fEnclosingProjectSet = new HashSet<ICProject>();
private boolean fWorkspaceScope = false;
// cached arrays
@ -54,16 +54,16 @@ public class TypeSearchScope implements ITypeSearchScope {
add(project);
}
public Collection pathSet() {
public Collection<IPath> pathSet() {
return fPathSet;
}
public Collection containerSet() {
public Collection<IPath> containerSet() {
return fContainerSet;
}
public Collection projectSet() {
public Collection<ICProject> projectSet() {
return fProjectSet;
}
public Collection enclosingProjectSet() {
public Collection<ICProject> enclosingProjectSet() {
return fEnclosingProjectSet;
}
@ -73,8 +73,8 @@ public class TypeSearchScope implements ITypeSearchScope {
if (!scope.pathSet().isEmpty()) {
// check if this scope encloses the other scope's paths
for (Iterator i = scope.pathSet().iterator(); i.hasNext(); ) {
IPath path = (IPath) i.next();
for (Iterator<IPath> i = scope.pathSet().iterator(); i.hasNext(); ) {
IPath path = i.next();
if (!encloses(path))
return false;
}
@ -82,8 +82,8 @@ public class TypeSearchScope implements ITypeSearchScope {
if (!scope.containerSet().isEmpty()) {
// check if this scope encloses the other scope's containers
for (Iterator i = scope.containerSet().iterator(); i.hasNext(); ) {
IPath path = (IPath) i.next();
for (Iterator<IPath> i = scope.containerSet().iterator(); i.hasNext(); ) {
IPath path = i.next();
if (!encloses(path))
return false;
}
@ -91,8 +91,8 @@ public class TypeSearchScope implements ITypeSearchScope {
if (!scope.projectSet().isEmpty()) {
// check if this scope encloses the other scope's projects
for (Iterator i = scope.projectSet().iterator(); i.hasNext(); ) {
ICProject project = (ICProject) i.next();
for (Iterator<ICProject> i = scope.projectSet().iterator(); i.hasNext(); ) {
ICProject project = i.next();
if (!encloses(project))
return false;
}
@ -125,7 +125,7 @@ public class TypeSearchScope implements ITypeSearchScope {
if (fContainerSet.contains(path))
return true;
if (fContainerPaths == null) {
fContainerPaths = (IPath[]) fContainerSet.toArray(new IPath[fContainerSet.size()]);
fContainerPaths = fContainerSet.toArray(new IPath[fContainerSet.size()]);
// java.util.Arrays.sort(fContainerPaths);
}
for (int i = 0; i < fContainerPaths.length; ++i) {
@ -140,7 +140,7 @@ public class TypeSearchScope implements ITypeSearchScope {
// check projects that were explicity added to scope
if (fProjects == null) {
fProjects = (ICProject[]) fProjectSet.toArray(new ICProject[fProjectSet.size()]);
fProjects = fProjectSet.toArray(new ICProject[fProjectSet.size()]);
}
// check if one of the projects contains path
for (int i = 0; i < fProjects.length; ++i) {
@ -168,7 +168,7 @@ public class TypeSearchScope implements ITypeSearchScope {
if (isWorkspaceScope()) {
return getAllProjects();
}
return (ICProject[]) fEnclosingProjectSet.toArray(new ICProject[fEnclosingProjectSet.size()]);
return fEnclosingProjectSet.toArray(new ICProject[fEnclosingProjectSet.size()]);
}
private static boolean projectContainsPath(ICProject project, IPath path, boolean checkIncludePaths) {

View file

@ -134,16 +134,16 @@ public class TypeUtil {
ICElement[] types = getTypes(tu);
ArrayList<ICElement> allTypes = new ArrayList<ICElement>(types.length);
ArrayList<ICElement> typesToTraverse = new ArrayList<ICElement>(types.length);
for (int i = 0; i < types.length; i++) {
typesToTraverse.add(types[i]);
for (ICElement type : types) {
typesToTraverse.add(type);
}
while (!typesToTraverse.isEmpty()) {
ICElement type = typesToTraverse.get(0);
typesToTraverse.remove(type);
allTypes.add(type);
types = getTypes(type);
for (int i = 0; i < types.length; i++) {
typesToTraverse.add(types[i]);
for (ICElement type2 : types) {
typesToTraverse.add(type2);
}
}
return allTypes.toArray(new ICElement[allTypes.size()]);
@ -195,9 +195,9 @@ public class TypeUtil {
public static IMethodDeclaration[] getMethods(ICElement elem) {
if (elem instanceof IStructure) {
try {
List list = ((IParent)elem).getChildrenOfType(ICElement.C_METHOD_DECLARATION);
List<?> list = ((IParent)elem).getChildrenOfType(ICElement.C_METHOD_DECLARATION);
if (list != null && !list.isEmpty()) {
return (IMethodDeclaration[]) list.toArray(new IMethodDeclaration[list.size()]);
return list.toArray(new IMethodDeclaration[list.size()]);
}
} catch (CModelException e) {
}
@ -208,9 +208,9 @@ public class TypeUtil {
public static ICElement[] getFields(ICElement elem) {
if (elem instanceof IStructure) {
try {
List list = ((IParent)elem).getChildrenOfType(ICElement.C_FIELD);
List<?> list = ((IParent)elem).getChildrenOfType(ICElement.C_FIELD);
if (list != null && !list.isEmpty()) {
return (ICElement[]) list.toArray(new ICElement[list.size()]);
return list.toArray(new ICElement[list.size()]);
}
} catch (CModelException e) {
}

View file

@ -31,7 +31,6 @@ import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.index.IndexLocationFactory;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.core.browser.util.IndexModelUtil;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
@ -268,10 +267,6 @@ public class ASTTypeInfo implements ITypeInfo, IFunctionInfo {
throw new PDOMNotImplementedError();
}
public int compareTo(Object arg0) {
throw new PDOMNotImplementedError();
}
/*
* @see org.eclipse.cdt.internal.core.browser.IFunctionInfo#getParameters()
*/

View file

@ -12,7 +12,7 @@
* Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.browser.util;
package org.eclipse.cdt.internal.core.browser;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;

View file

@ -1,53 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 QNX Software Systems 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:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.browser.util;
/**
* A helper class which allows you to perform some
* simple set operations on int arrays.
*/
public class ArrayUtil {
private ArrayUtil() {
}
// returns true if set contains elem
public static boolean contains(int[] set, int elem) {
if (set == null)
return false;
for (int i= 0; i < set.length; ++i) {
if (set[i] == elem)
return true;
}
return false;
}
// returns true if set contains all of subset
public static boolean containsAll(int[] set, int[] subset) {
if (set == null || subset == null)
return false;
for (int i= 0; i < subset.length; ++i) {
if (!contains(set, subset[i]))
return false;
}
return true;
}
// return a copy of fromSet
public static int[] clone(int[] fromSet) {
if (fromSet == null)
return null;
int[] newSet= new int[fromSet.length];
for (int i= 0; i < fromSet.length; ++i) {
newSet[i]= fromSet[i];
}
return newSet;
}
}

View file

@ -1,249 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 QNX Software Systems 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:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.browser.util;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IProgressMonitorWithBlocking;
import org.eclipse.core.runtime.IStatus;
/**
* A wrapper around one or more progress monitors. Forwards
* <code>IProgressMonitor</code> and <code>IProgressMonitorWithBlocking</code>
* methods to the delegate monitors.
*/
public class DelegatedProgressMonitor implements IProgressMonitor, IProgressMonitorWithBlocking {
private static int INITIAL_DELEGATE_COUNT = 2;
private final ArrayList fDelegateList = new ArrayList(INITIAL_DELEGATE_COUNT);
String fTaskName;
String fSubTask;
int fTotalWork;
private double fWorked;
private boolean fIsBlocked;
boolean fIsCanceled;
/**
* Creates a new delegated monitor.
*/
public DelegatedProgressMonitor() {
init();
}
/**
* Creates a new delegated monitor, and adds a delegate.
*/
public DelegatedProgressMonitor(IProgressMonitor delegate) {
init();
addDelegate(delegate);
}
/**
* Resets delegated monitor to initial state.
*/
public synchronized void init() {
fTaskName= null;
fSubTask= null;
fTotalWork= IProgressMonitor.UNKNOWN;
fWorked= 0.0f;
fIsBlocked= false;
fIsCanceled= false;
}
/*
* @see IProgressMonitor#beginTask
*/
public synchronized void beginTask(String name, int totalWork) {
fTaskName = name;
fTotalWork = totalWork;
visitDelegates(new IDelegateVisitor() {
public void visit(IProgressMonitor delegate) {
delegate.beginTask(fTaskName, fTotalWork);
}
});
}
/*
* @see IProgressMonitor#done
*/
public synchronized void done() {
visitDelegates(new IDelegateVisitor() {
public void visit(IProgressMonitor delegate) {
delegate.done();
}
});
}
/*
* @see IProgressMonitor#setTaskName
*/
public synchronized void setTaskName(String name) {
fTaskName = name;
visitDelegates(new IDelegateVisitor() {
public void visit(IProgressMonitor delegate) {
delegate.setTaskName(fTaskName);
}
});
}
/*
* @see IProgressMonitor#subTask
*/
public synchronized void subTask(String name) {
fSubTask = name;
visitDelegates(new IDelegateVisitor() {
public void visit(IProgressMonitor delegate) {
delegate.subTask(fSubTask);
}
});
}
/*
* @see IProgressMonitor#worked
*/
public void worked(int work) {
internalWorked(work);
}
/*
* @see IProgressMonitor#internalWorked
*/
public synchronized void internalWorked(double internalWork) {
fWorked += internalWork;
final double fInternalWork = internalWork;
visitDelegates(new IDelegateVisitor() {
public void visit(IProgressMonitor delegate) {
delegate.internalWorked(fInternalWork);
}
});
}
/*
* @see IProgressMonitor#isCanceled
*/
public synchronized boolean isCanceled() {
visitDelegates(new IDelegateVisitor() {
public void visit(IProgressMonitor delegate) {
fIsCanceled |= delegate.isCanceled();
}
});
return fIsCanceled;
}
/*
* @see IProgressMonitor#setCanceled
*/
public synchronized void setCanceled(boolean canceled) {
fIsCanceled = canceled;
visitDelegates(new IDelegateVisitor() {
public void visit(IProgressMonitor delegate) {
delegate.setCanceled(fIsCanceled);
}
});
}
/*
* @see IProgressMonitor#setBlocked
*/
public synchronized void setBlocked(IStatus reason) {
fIsBlocked = true;
final IStatus fReason = reason;
visitDelegates(new IDelegateVisitor() {
public void visit(IProgressMonitor delegate) {
if (delegate instanceof IProgressMonitorWithBlocking)
((IProgressMonitorWithBlocking) delegate).setBlocked(fReason);
}
});
}
/*
* @see IProgressMonitor#clearBlocked
*/
public synchronized void clearBlocked() {
fIsBlocked = false;
visitDelegates(new IDelegateVisitor() {
public void visit(IProgressMonitor delegate) {
if (delegate instanceof IProgressMonitorWithBlocking)
((IProgressMonitorWithBlocking) delegate).clearBlocked();
}
});
}
/**
* Adds a delegate.
*/
public synchronized void addDelegate(IProgressMonitor delegate) {
if (fDelegateList.indexOf(delegate) == -1) {
if (fTaskName != null)
syncUp(delegate);
fDelegateList.add(delegate);
}
}
/**
* Brings delegate in sync with current progress.
*/
private void syncUp(IProgressMonitor delegate) {
delegate.beginTask(fTaskName, fTotalWork);
delegate.internalWorked(fWorked);
if (fSubTask != null && fSubTask.length() > 0)
delegate.subTask(fSubTask);
if (fIsBlocked && delegate instanceof IProgressMonitorWithBlocking)
((IProgressMonitorWithBlocking) delegate).setBlocked(null);
}
/**
* Removes a delegate.
*/
public synchronized void removeDelegate(IProgressMonitor delegate) {
int index = fDelegateList.indexOf(delegate);
if (index != -1) {
fDelegateList.remove(index);
}
}
/**
* Removes all delegates.
*/
public synchronized void removeAllDelegates() {
fDelegateList.clear();
}
/**
* Returns the delegate list.
*
* @return An array of progress monitors added using <code>addDelegate()</code>.
*/
public synchronized IProgressMonitor[] getDelegates() {
return (IProgressMonitor[]) fDelegateList.toArray();
}
/**
* Defines a delegate visitor.
*/
private static interface IDelegateVisitor {
public void visit(IProgressMonitor delegate);
}
/**
* Visits each delegate in the delegates list.
*/
private void visitDelegates(IDelegateVisitor visitor) {
// Clone the delegates since they could remove themselves when called
ArrayList delegatesList = (ArrayList) fDelegateList.clone();
for (Iterator i = delegatesList.iterator(); i.hasNext(); ) {
IProgressMonitor delegate = (IProgressMonitor) i.next();
visitor.visit(delegate);
}
}
}

View file

@ -1,84 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 QNX Software Systems 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:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.browser.util;
import java.util.ArrayList;
/**
* A helper class which allows you to perform some simple
* stack operations. Avoids the extra overhead of
* synchronization in Java.Util.Stack.
*/
public class SimpleStack {
private static int INITIAL_STACK_SIZE = 10;
private ArrayList items;
private static boolean VERBOSE = false;
public SimpleStack() {
items = new ArrayList(INITIAL_STACK_SIZE);
}
public SimpleStack(int initialSize) {
items = new ArrayList(initialSize);
}
public void clear() {
items.clear();
}
public Object push(Object item) {
items.add(item);
if (VERBOSE)
trace("push on stack: " + item); //$NON-NLS-1$
return item;
}
public Object pop() {
int top = items.size()-1;
if (top < 0)
return null;
Object item = items.get(top);
items.remove(top);
if (VERBOSE)
trace("pop from stack: " + item); //$NON-NLS-1$
return item;
}
public Object top() {
int top = items.size()-1;
if (top < 0)
return null;
return items.get(top);
}
public Object bottom() {
if (items.size() == 0)
return null;
return items.get(0);
}
public boolean isEmpty() {
return (items.size() == 0);
}
public Object[] toArray() {
return items.toArray();
}
public Object[] toArray(Object a[]) {
return items.toArray(a);
}
private static void trace(String msg) {
System.out.println("(" + Thread.currentThread() + ") " + msg); //$NON-NLS-1$ //$NON-NLS-2$
}
}

View file

@ -80,6 +80,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
}
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
return null;
}
@ -197,8 +198,8 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
return NO_CHILDREN;
}
public List getChildrenOfType(int type) throws CModelException {
return Collections.EMPTY_LIST;
public List<ICElement> getChildrenOfType(int type) throws CModelException {
return Collections.emptyList();
}
public boolean hasChildren() {

View file

@ -59,7 +59,7 @@ public class CElementHandleFactory {
public static ICElementHandle create(ITranslationUnit tu, IIndexMacro macro,
IRegion region, long timestamp) throws CoreException {
CElementHandle element= new MacroHandle(tu, macro);
if (element != null && region != null) {
if (region != null) {
element.setRangeOfID(region, timestamp);
}
return element;

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
public class EnumerationHandle extends CElementHandle implements org.eclipse.cdt.core.model.IEnumeration, ICElementHandle {
public class EnumerationHandle extends CElementHandle implements org.eclipse.cdt.core.model.IEnumeration {
public EnumerationHandle(ICElement parent, IEnumeration enumeration) {
super(parent, ICElement.C_ENUMERATION, enumeration.getName());

View file

@ -1,42 +0,0 @@
/*******************************************************************************
* Copyright (c) 2002, 2006 IBM 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:
* Rational Software - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.util;
import java.util.Enumeration;
/**
* The <code>ICacheEnumeration</code> is used to iterate over both the keys
* and values in an LRUCache. The <code>getValue()</code> method returns the
* value of the last key to be retrieved using <code>nextElement()</code>.
* The <code>nextElement()</code> method must be called before the
* <code>getValue()</code> method.
*
* <p>The iteration can be made efficient by making use of the fact that values in
* the cache (instances of <code>LRUCacheEntry</code>), know their key. For this reason,
* Hashtable lookups don't have to be made at each step of the iteration.
*
* <p>Modifications to the cache must not be performed while using the
* enumeration. Doing so will lead to an illegal state.
*
* @see LRUCache
*
* This interface is similar to the JDT ICacheEnumeration interface.
*/
public interface ICacheEnumeration extends Enumeration {
/**
* Returns the value of the previously accessed key in the enumeration.
* Must be called after a call to nextElement().
*
* @return Value of current cache entry
*/
public Object getValue();
}

View file

@ -239,33 +239,7 @@ public class LRUCache<K,T> implements Cloneable {
public boolean isEmpty() {
return fEntryTable.isEmpty();
}
/**
* Returns an enumeration that iterates over all the keys and values
* currently in the cache.
*/
public ICacheEnumeration keysAndValues() {
return new ICacheEnumeration() {
Enumeration<LRUCacheEntry<K,T>> fValues = fEntryTable.elements();
LRUCacheEntry<K,T> fEntry;
public boolean hasMoreElements() {
return fValues.hasMoreElements();
}
public K nextElement() {
fEntry = fValues.nextElement();
return fEntry._fKey;
}
public T getValue() {
if (fEntry == null) {
throw new java.util.NoSuchElementException();
}
return fEntry._fValue;
}
};
}
/**
* Ensures there is the specified amount of free space in the receiver,
* by removing old entries if necessary. Returns true if the requested space was

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.core;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@ -31,7 +32,7 @@ public class CCProjectNature extends CProjectNature {
/**
* Checks to ensure that a cnature already exists,
* if not throw a CoreException. Does NOT add a default builder
* @see IProjectNature#configure
* @see IProjectNature#configure()
*/
@Override
public void configure() throws CoreException {

View file

@ -84,7 +84,6 @@ public class CCorePreferenceConstants {
/**
* Active code formatter ID.
* @see #getDefaultOptions
*/
public static final String CODE_FORMATTER = CCorePlugin.PLUGIN_ID + ".code_formatter"; //$NON-NLS-1$

View file

@ -45,7 +45,7 @@ public class CProjectNature implements IProjectNature {
/**
* Utility method for adding a nature to a project.
*
* @param proj
* @param project
* the project to add the nature
* @param natureId
* the id of the nature to assign to the project
@ -57,8 +57,8 @@ public class CProjectNature implements IProjectNature {
public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
String[] prevNatures = description.getNatureIds();
for (int i = 0; i < prevNatures.length; i++) {
if (natureId.equals(prevNatures[i]))
for (String prevNature : prevNatures) {
if (natureId.equals(prevNature))
return;
}
String[] newNatures = new String[prevNatures.length + 1];
@ -71,7 +71,7 @@ public class CProjectNature implements IProjectNature {
/**
* Utility method for removing a project nature from a project.
*
* @param proj
* @param project
* the project to remove the nature from
* @param natureId
* the nature id to remove
@ -82,9 +82,9 @@ public class CProjectNature implements IProjectNature {
public static void removeNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
String[] prevNatures = description.getNatureIds();
List newNatures = new ArrayList(Arrays.asList(prevNatures));
List<String> newNatures = new ArrayList<String>(Arrays.asList(prevNatures));
newNatures.remove(natureId);
description.setNatureIds((String[]) newNatures.toArray(new String[newNatures.size()]));
description.setNatureIds(newNatures.toArray(new String[newNatures.size()]));
project.setDescription(description, monitor);
}

View file

@ -80,8 +80,6 @@ public class CommandLauncher {
/**
* return the constructed Command line.
*
* @return
*/
public String getCommandLine() {
return getCommandLine(getCommandArgs());
@ -193,8 +191,8 @@ public class CommandLauncher {
protected String getCommandLine(String[] commandArgs) {
StringBuffer buf = new StringBuffer();
if (fCommandArgs != null) {
for (int i = 0; i < commandArgs.length; i++) {
buf.append(commandArgs[i]);
for (String commandArg : commandArgs) {
buf.append(commandArg);
buf.append(' ');
}
buf.append(lineSeparator);

View file

@ -45,12 +45,12 @@ public class ErrorParserManager extends OutputStream {
private IProject fProject;
private IMarkerGenerator fMarkerGenerator;
// Maps a file name without directory to a IFile object or a list of a IFile objects.
private Map fFilesInProject; // Files or lists of files keyed by the file name
private Map<String, Object> fFilesInProject; // Files or lists of files keyed by the file name
private Map fErrorParsers;
private ArrayList fErrors;
private Map<String, IErrorParser[]> fErrorParsers;
private ArrayList<ProblemMarkerInfo> fErrors;
private Vector fDirectoryStack;
private Vector<IPath> fDirectoryStack;
private IPath fBaseDirectory;
private String previousLine;
@ -78,10 +78,10 @@ public class ErrorParserManager extends OutputStream {
if (parsersIDs == null) {
enableAllParsers();
} else {
fErrorParsers = new LinkedHashMap(parsersIDs.length);
for (int i = 0; i < parsersIDs.length; i++) {
IErrorParser[] parsers = CCorePlugin.getDefault().getErrorParser(parsersIDs[i]);
fErrorParsers.put(parsersIDs[i], parsers);
fErrorParsers = new LinkedHashMap<String, IErrorParser[]>(parsersIDs.length);
for (String parsersID : parsersIDs) {
IErrorParser[] parsers = CCorePlugin.getDefault().getErrorParser(parsersID);
fErrorParsers.put(parsersID, parsers);
}
}
fMarkerGenerator = markerGenerator;
@ -89,11 +89,11 @@ public class ErrorParserManager extends OutputStream {
}
private void initErrorParserManager(IPath workingDirectory) {
fFilesInProject = new HashMap();
fDirectoryStack = new Vector();
fErrors = new ArrayList();
fFilesInProject = new HashMap<String, Object>();
fDirectoryStack = new Vector<IPath>();
fErrors = new ArrayList<ProblemMarkerInfo>();
List collectedFiles = new ArrayList();
List<IResource> collectedFiles = new ArrayList<IResource>();
fBaseDirectory = (workingDirectory == null || workingDirectory.isEmpty()) ? fProject.getLocation() : workingDirectory;
collectFiles(fProject, collectedFiles);
@ -102,12 +102,14 @@ public class ErrorParserManager extends OutputStream {
String filename = file.getName();
Object existing = fFilesInProject.put(filename, file);
if (existing != null) {
Collection files;
Collection<IFile> files;
if (existing instanceof IFile) {
files = new ArrayList();
files.add(existing);
files = new ArrayList<IFile>();
files.add((IFile) existing);
} else {
files = (Collection) existing;
@SuppressWarnings("unchecked")
final Collection<IFile> casted = (Collection<IFile>) existing;
files = casted;
}
files.add(file);
fFilesInProject.put(filename, files);
@ -121,7 +123,7 @@ public class ErrorParserManager extends OutputStream {
public IPath getWorkingDirectory() {
if (fDirectoryStack.size() != 0) {
return (IPath) fDirectoryStack.lastElement();
return fDirectoryStack.lastElement();
}
// Fall back to the Project Location
return fBaseDirectory;
@ -143,7 +145,7 @@ public class ErrorParserManager extends OutputStream {
public IPath popDirectory() {
int i = fDirectoryStack.size();
if (i != 0) {
IPath dir = (IPath) fDirectoryStack.lastElement();
IPath dir = fDirectoryStack.lastElement();
fDirectoryStack.removeElementAt(i - 1);
return dir;
}
@ -155,11 +157,11 @@ public class ErrorParserManager extends OutputStream {
}
private void enableAllParsers() {
fErrorParsers = new LinkedHashMap();
fErrorParsers = new LinkedHashMap<String, IErrorParser[]>();
String[] parserIDs = CCorePlugin.getDefault().getAllErrorParsersIDs();
for (int i = 0; i < parserIDs.length; i++) {
IErrorParser[] parsers = CCorePlugin.getDefault().getErrorParser(parserIDs[i]);
fErrorParsers.put(parserIDs[i], parsers);
for (String parserID : parserIDs) {
IErrorParser[] parsers = CCorePlugin.getDefault().getErrorParser(parserID);
fErrorParsers.put(parserID, parsers);
}
if (fErrorParsers.size() == 0) {
initErrorParsersMap();
@ -169,13 +171,13 @@ public class ErrorParserManager extends OutputStream {
private void initErrorParsersMap() {
String[] parserIDs = CCorePlugin.getDefault().getAllErrorParsersIDs();
for (int i = 0; i < parserIDs.length; i++) {
IErrorParser[] parsers = CCorePlugin.getDefault().getErrorParser(parserIDs[i]);
fErrorParsers.put(parserIDs[i], parsers);
for (String parserID : parserIDs) {
IErrorParser[] parsers = CCorePlugin.getDefault().getErrorParser(parserID);
fErrorParsers.put(parserID, parsers);
}
}
protected void collectFiles(IProject parent, final List result) {
protected void collectFiles(IProject parent, final List<IResource> result) {
try {
parent.accept(new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) {
@ -204,15 +206,14 @@ public class ErrorParserManager extends OutputStream {
return;
String[] parserIDs = new String[fErrorParsers.size()];
Iterator items = fErrorParsers.keySet().iterator();
Iterator<String> items = fErrorParsers.keySet().iterator();
for (int i = 0; items.hasNext(); i++) {
parserIDs[i] = (String) items.next();
parserIDs[i] = items.next();
}
for (int i = 0; i <parserIDs.length; ++i) {
IErrorParser[] parsers = (IErrorParser[])fErrorParsers.get(parserIDs[i]);
for (int j = 0; j < parsers.length; j++) {
IErrorParser curr = parsers[j];
IErrorParser[] parsers = fErrorParsers.get(parserIDs[i]);
for (IErrorParser curr : parsers) {
if (curr.processLine(line, this)) {
return;
}
@ -252,10 +253,10 @@ public class ErrorParserManager extends OutputStream {
if (obj == null || obj instanceof IFile) {
return (IFile) obj;
}
Collection files = (Collection) obj;
Collection<?> files = (Collection<?>) obj;
IFile matchingFile = null;
for (Iterator it = files.iterator(); it.hasNext();) {
IFile file = (IFile) it.next();
for (Object name : files) {
IFile file = (IFile) name;
IPath location = file.getLocation();
boolean match = false;
if (path.isAbsolute()) {
@ -282,9 +283,9 @@ public class ErrorParserManager extends OutputStream {
// It may be a link resource so we must check it also.
if (file == null) {
IFile[] files = root.findFilesForLocation(path);
for (int i = 0; i < files.length; i++) {
if (files[i].getProject().equals(fProject)) {
file = files[i];
for (IFile file2 : files) {
if (file2.getProject().equals(fProject)) {
file = file2;
break;
}
}
@ -479,9 +480,9 @@ public class ErrorParserManager extends OutputStream {
public boolean reportProblems() {
boolean reset = false;
if (nOpens == 0) {
Iterator iter = fErrors.iterator();
Iterator<ProblemMarkerInfo> iter = fErrors.iterator();
while (iter.hasNext()) {
ProblemMarkerInfo problemMarkerInfo = (ProblemMarkerInfo) iter.next();
ProblemMarkerInfo problemMarkerInfo = iter.next();
if (problemMarkerInfo.severity == IMarkerGenerator.SEVERITY_ERROR_BUILD) {
reset = true;
}

View file

@ -14,14 +14,14 @@ package org.eclipse.cdt.core;
import java.math.BigInteger;
/**
* Represents C/C++ address in CDT. All implementors of this inteface should be
* Represents C/C++ address in CDT. All implementors of this interface should be
* immutable, i.e. all methods should not modify objects, they should return
* new object.
*
* Please see Addr32 and Addr64 classes to see how this interface should
* be extended
*/
public interface IAddress extends Comparable {
public interface IAddress extends Comparable<Object> {
/**
* Adds offset to address and returns new address object
* which is the result
@ -56,7 +56,6 @@ public interface IAddress extends Comparable {
/**
* Returns the value of the address.
* @return
*/
BigInteger getValue();
@ -99,7 +98,6 @@ public interface IAddress extends Comparable {
* with all leading zeros. The length of returned string should be
* the same for all addresses of given class. I.e. 10 for 32-bit
* addresses and 18 for 64-bit addresses
* @return
*/
String toHexAddressString();
@ -109,7 +107,6 @@ public interface IAddress extends Comparable {
* with all leading zeros. The length of returned string should be
* the same for all addresses of given class. I.e. 34 for 32-bit
* addresses and 66 for 64-bit addresses
* @return
*/
String toBinaryAddressString();

View file

@ -22,13 +22,11 @@ public interface IAddressFactory
{
/**
* Returns zero address, i.e. minimal possible address
* @return
*/
IAddress getZero();
/**
* Returns maximal address.
* @return
*/
IAddress getMax();
@ -50,7 +48,6 @@ public interface IAddressFactory
* Please see Addr32Factory.createAddress() for reference implementation.
*
* @param addr
* @return
*/
IAddress createAddress(String addr);
@ -70,7 +67,6 @@ public interface IAddressFactory
*
* @param addr
* @param radix
* @return
*/
IAddress createAddress(String addr, int radix);
@ -78,7 +74,6 @@ public interface IAddressFactory
* Create address from a BigInteger
*
* @param addr
* @return
*/
IAddress createAddress(BigInteger addr);
}

View file

@ -69,7 +69,6 @@ public interface IBinaryParser extends IAdaptable {
/**
* Return the binary parser
* @return
*/
IBinaryParser getBinaryParser();
}
@ -150,12 +149,11 @@ public interface IBinaryParser extends IAdaptable {
interface IBinaryShared extends IBinaryExecutable {
/**
* The Share Object name.
* @return
*/
String getSoName();
}
interface ISymbol extends Comparable {
interface ISymbol extends Comparable<Object> {
/**
* Symbol is type function.
@ -169,56 +167,47 @@ public interface IBinaryParser extends IAdaptable {
/**
* Name of the Symbol
* @return
*/
String getName();
/**
* Address of the symbol
* @return
*/
IAddress getAddress();
/**
* Size of the symbol.
* @return
*/
long getSize();
/**
* Start linenumber of the symbol in the source
* @return
*/
int getStartLine();
/**
* End line number of the symbol in the source
* @return
*/
int getEndLine();
/**
* Source filename of the symbol.
* @return
*/
IPath getFilename();
/**
* Type of the symbol
* @return
*/
int getType();
/**
* Line number corresponding to the address offset.
* @param offset
* @return
*/
int getLineNumber(long offset);
/**
* Return the binary object this symbol is from.
* @return
*/
IBinaryObject getBinaryObject();
}
@ -228,7 +217,6 @@ public interface IBinaryParser extends IAdaptable {
* @param hints - array byte that can be use to recognise the file.
* Can be null or empty array when no hints are passed.
* @param path
* @return
* @throws IOException
*/
IBinaryFile getBinary(byte[] hints, IPath path) throws IOException;
@ -237,14 +225,12 @@ public interface IBinaryParser extends IAdaptable {
* Creates an IBinaryFile.
*
* @param path
* @return
* @throws IOException
*/
IBinaryFile getBinary(IPath path) throws IOException;
/**
* Returns the name of the Format.
* @return
*/
String getFormat();
@ -252,13 +238,11 @@ public interface IBinaryParser extends IAdaptable {
* True if the resource is a binary.
* @param hints
* @param path
* @return
*/
boolean isBinary(byte[] hints, IPath path);
/**
* Get a hint of the needed buffer size to recognise the file.
* @return
* Get a hint of the needed buffer size to recognize the file.
*/
int getHintBufferSize();
}

View file

@ -17,40 +17,14 @@ import org.eclipse.core.runtime.IProgressMonitor;
public interface ICDescriptorManager {
/**
* @param project
* @param id
* @throws CoreException
*/
public void configure(IProject project, String id) throws CoreException;
/**
* @param project
* @param id
* @throws CoreException
*/
public void convert(IProject project, String id) throws CoreException;
/**
* @param project
* @return
* @throws CoreException
*/
public ICDescriptor getDescriptor(IProject project) throws CoreException;
/**
* @param project
* @param forceCreation
* @return
* @throws CoreException
*/
public ICDescriptor getDescriptor(IProject project, boolean create) throws CoreException;
/**
* @param project
* @param op
* @param monitor
* @throws CoreException
*/
public void runDescriptorOperation(IProject project, ICDescriptorOperation op, IProgressMonitor monitor) throws CoreException;
public void runDescriptorOperation(IProject project,
@ -59,13 +33,7 @@ public interface ICDescriptorManager {
IProgressMonitor monitor)
throws CoreException;
/**
* @param listener
*/
public void addDescriptorListener(ICDescriptorListener listener);
/**
* @param listener
*/
public void removeDescriptorListener(ICDescriptorListener listener);
}

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.IBinaryParser.ISymbol;
import org.eclipse.core.runtime.IPath;
public class Symbol implements ISymbol, Comparable {
public class Symbol implements ISymbol {
protected final BinaryObjectAdapter binary;
private final String name;

View file

@ -50,7 +50,7 @@ import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
import org.eclipse.cdt.internal.core.browser.util.IndexModelUtil;
import org.eclipse.cdt.internal.core.browser.IndexModelUtil;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;