1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

clean up warnings

This commit is contained in:
Andrew Ferguson 2008-03-06 16:54:12 +00:00
parent 9f5355c7f6
commit 183e8317a8
17 changed files with 166 additions and 162 deletions

View file

@ -63,7 +63,7 @@ public class LanguageManager {
private static LanguageManager instance;
private Map fLanguageCache = new HashMap();
private Map fPDOMLinkageFactoryCache= new HashMap();
private Map<String, IPDOMLinkageFactory> fPDOMLinkageFactoryCache= new HashMap<String, IPDOMLinkageFactory>();
private Map fContentTypeToLanguageCache= new HashMap();
private Map fLanguageConfigurationCache = new HashMap();
private boolean fIsFullyCached;
@ -300,7 +300,7 @@ public class LanguageManager {
* @return a map.
* @since 4.0
*/
public Map getPDOMLinkageFactoryMappings() {
public Map<String, IPDOMLinkageFactory> getPDOMLinkageFactoryMappings() {
if (!fPDOMLinkageFactoryCache.isEmpty())
return Collections.unmodifiableMap(fPDOMLinkageFactoryCache);

View file

@ -24,33 +24,32 @@ import org.eclipse.core.runtime.Status;
/**
* An IExportProjectProvider suitable for subclassing. It provides convenience methods
* for obtaining options and their parameters from the command-line.
* An IExportProjectProvider implementation intended to be sub-classed by clients. It
* provides convenience methods for obtaining options and their parameters from the
* command-line.
*
* @see ExternalExportProjectProvider for usage scenarios
*/
public abstract class AbstractExportProjectProvider implements IExportProjectProvider {
public static final IProgressMonitor NPM= new NullProgressMonitor();
private Map arguments;
private Map<String, List<String>> arguments;
private String[] appArguments;
public AbstractExportProjectProvider() {}
/**
*
* @return
* @return the application arguments
*/
protected String[] getApplicationArguments() {
return (String[]) appArguments.clone();
return appArguments.clone();
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.core.index.export.IExportProjectProvider#setApplicationArguments(java.lang.String[])
*/
public void setApplicationArguments(String[] arguments) {
this.appArguments= (String[]) arguments.clone();
this.appArguments= arguments.clone();
this.arguments= Collections.unmodifiableMap(CLIUtil.parseToMap(arguments));
}
@ -61,7 +60,7 @@ public abstract class AbstractExportProjectProvider implements IExportProjectPro
* the mapping option=>[p1,p2,p3] will be present in the map
* @return a mapping from string option to parameter string list
*/
protected Map getParsedArgs() {
protected Map<String,List<String>> getParsedArgs() {
return arguments;
}
@ -74,17 +73,16 @@ public abstract class AbstractExportProjectProvider implements IExportProjectPro
* not be present, or if it does not have exactly one parameter
*/
public String getSingleString(String option) throws CoreException {
return (String) CLIUtil.getArg(arguments, option, 1).get(0);
return CLIUtil.getArg(arguments, option, 1).get(0);
}
/**
*
* @param option
* @return
* @return the list of parameters given with this option
* @throws CoreException
*/
public List getParameters(String option) {
return (List) arguments.get(option);
public List<String> getParameters(String option) {
return arguments.get(option);
}
/**
@ -105,7 +103,7 @@ public abstract class AbstractExportProjectProvider implements IExportProjectPro
* @return
* @throws CoreException
*/
public List getParameters(String option, int expected) throws CoreException {
public List<String> getParameters(String option, int expected) throws CoreException {
return CLIUtil.getArg(arguments, option, expected);
}

View file

@ -18,7 +18,6 @@ import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -82,7 +81,7 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider
}
// -include
List includeFiles= new ArrayList();
List<String> includeFiles= new ArrayList<String>();
if(isPresent(OPT_INCLUDE)) {
includeFiles.addAll(getParameters(OPT_INCLUDE));
}
@ -112,7 +111,7 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider
private ICProject createCCProject(
final String projectName,
final File location,
final List includeFiles
final List<String> includeFiles
) throws CoreException {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final ICProject newProject[] = new ICProject[1];
@ -136,11 +135,10 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider
content.createLink(new Path(location.getAbsolutePath()), IResource.NONE, null);
// Setup path entries
List entries= new ArrayList(Arrays.asList(CoreModel.getRawPathEntries(cproject)));
List<IPathEntry> entries= new ArrayList<IPathEntry>(Arrays.asList(CoreModel.getRawPathEntries(cproject)));
// pre-include files
for(Iterator j= includeFiles.iterator(); j.hasNext(); ) {
String path= (String) j.next();
for(String path : includeFiles) {
entries.add(CoreModel.newIncludeFileEntry(project.getFullPath(), new Path(path)));
}
@ -150,7 +148,7 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider
// any additional entries
entries.addAll(getAdditionalRawEntries());
cproject.setRawPathEntries((IPathEntry[]) entries.toArray(new IPathEntry[entries.size()]),
cproject.setRawPathEntries(entries.toArray(new IPathEntry[entries.size()]),
new NullProgressMonitor()
);
@ -168,8 +166,8 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider
* Get additional raw entries (above those added as part of the ExternalExportProjectProvider functionality)
* @return a list of additional entries to add to the project
*/
protected List getAdditionalRawEntries() {
List entries= new ArrayList();
protected List<IPathEntry> getAdditionalRawEntries() {
List<IPathEntry> entries= new ArrayList<IPathEntry>();
entries.add(CoreModel.newIncludeEntry(content.getProjectRelativePath(), null, content.getLocation(), true));
return entries;
}
@ -181,7 +179,6 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.core.index.export.IExportProjectProvider#getLocationConverter(org.eclipse.cdt.core.model.ICProject)
*/
public IIndexLocationConverter getLocationConverter(final ICProject cproject) {
@ -189,11 +186,10 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.core.index.export.IExportProjectProvider#getExportProperties()
*/
public Map getExportProperties() {
Map properties= new HashMap();
public Map<String,String> getExportProperties() {
Map<String,String> properties= new HashMap<String,String>();
Date now= Calendar.getInstance().getTime();
properties.put(ORG_ECLIPSE_CDT_CORE_INDEX_EXPORT_DATESTAMP,
DateFormat.getDateInstance().format(now)

View file

@ -13,8 +13,11 @@ package org.eclipse.cdt.core.index.export;
import java.util.Map;
import org.eclipse.cdt.core.index.IIndexLocationConverter;
import org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter;
import org.eclipse.cdt.core.index.URIRelativeLocationConverter;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
/**
* An IExportProjectProvider provides a configured ICProject suitable set up for
@ -62,5 +65,5 @@ public interface IExportProjectProvider {
* @return a Map of String typed key value pairs representing ISV specific properties. This
* may return null.
*/
public Map/*<String,String>*/ getExportProperties();
public Map<String,String> getExportProperties();
}

View file

@ -20,16 +20,13 @@ import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
*
*/
public class ParserFactory {
public static IParserLogService createDefaultLogService()
{
private static IParserLogService defaultLogService = new DefaultLogService();
public static IParserLogService createDefaultLogService() {
return defaultLogService;
}
public static Set getKeywordSet( KeywordSetKey key, ParserLanguage language )
{
public static Set<String> getKeywordSet(KeywordSetKey key, ParserLanguage language) {
return KeywordSets.getKeywords( key, language );
}
private static IParserLogService defaultLogService = new DefaultLogService();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others.
* Copyright (c) 2007, 2008 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
@ -47,6 +47,7 @@ public class CPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, IC
public IScope getScope() throws DOMException {
return delegate.getScope();
}
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
return delegate.getAdapter(adapter);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2008 Wind River Systems, Inc. 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
@ -16,7 +16,6 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -57,12 +56,11 @@ public class IndexFactory {
boolean addDependent= (options & ADD_DEPENDENT) != 0;
boolean skipProvided= (options & SKIP_PROVIDED) != 0;
HashMap map= new HashMap();
Collection selectedProjects= getProjects(projects, addDependencies, addDependent, map, new Integer(1));
HashMap<IProject, Integer> map= new HashMap<IProject, Integer>();
Collection<ICProject> selectedProjects= getProjects(projects, addDependencies, addDependent, map, new Integer(1));
HashMap fragments= new LinkedHashMap();
for (Iterator iter = selectedProjects.iterator(); iter.hasNext(); ) {
ICProject cproject = (ICProject) iter.next();
HashMap<String, IIndexFragment> fragments= new LinkedHashMap<String, IIndexFragment>();
for(ICProject cproject : selectedProjects) {
IIndexFragment pdom= fPDOMManager.getPDOM(cproject);
if (pdom != null) {
safeAddFragment(fragments, pdom);
@ -79,12 +77,11 @@ public class IndexFactory {
int primaryFragmentCount= fragments.size();
if (!addDependencies) {
projects= (ICProject[]) selectedProjects.toArray(new ICProject[selectedProjects.size()]);
projects= selectedProjects.toArray(new ICProject[selectedProjects.size()]);
selectedProjects.clear();
// don't clear the map, so projects are not selected again
selectedProjects= getProjects(projects, true, false, map, new Integer(2));
for (Iterator iter = selectedProjects.iterator(); iter.hasNext(); ) {
ICProject cproject = (ICProject) iter.next();
for(ICProject cproject : selectedProjects) {
IIndexFragment pdom= fPDOMManager.getPDOM(cproject);
safeAddFragment(fragments, pdom);
@ -94,12 +91,12 @@ public class IndexFactory {
}
}
Collection pdoms= fragments.values();
return new CIndex((IIndexFragment[]) pdoms.toArray(new IIndexFragment[pdoms.size()]), primaryFragmentCount);
Collection<IIndexFragment> pdoms= fragments.values();
return new CIndex(pdoms.toArray(new IIndexFragment[pdoms.size()]), primaryFragmentCount);
}
public IWritableIndex getWritableIndex(ICProject project) throws CoreException {
Map readOnlyFrag= new LinkedHashMap();
Map<String, IIndexFragment> readOnlyFrag= new LinkedHashMap<String, IIndexFragment>();
IWritableIndexFragment pdom= (IWritableIndexFragment) fPDOMManager.getPDOM(project);
if (pdom == null) {
throw new CoreException(CCorePlugin.createStatus(
@ -107,23 +104,21 @@ public class IndexFactory {
}
safeAddProvidedFragments(project, readOnlyFrag);
Collection selectedProjects= getProjects(new ICProject[] {project}, true, false, new HashMap(), new Integer(1));
Collection<ICProject> selectedProjects= getProjects(new ICProject[] {project}, true, false, new HashMap<IProject, Integer>(), new Integer(1));
selectedProjects.remove(project);
for (Iterator iter = selectedProjects.iterator(); iter.hasNext(); ) {
ICProject cproject = (ICProject) iter.next();
for(ICProject cproject : selectedProjects) {
safeAddFragment(readOnlyFrag, fPDOMManager.getPDOM(cproject));
}
Collection roPdoms= readOnlyFrag.values();
return new WritableCIndex(pdom, (IIndexFragment[]) roPdoms.toArray(new IIndexFragment[roPdoms.size()]) );
Collection<IIndexFragment> roPdoms= readOnlyFrag.values();
return new WritableCIndex(pdom, roPdoms.toArray(new IIndexFragment[roPdoms.size()]) );
}
private Collection getProjects(ICProject[] projects, boolean addDependencies, boolean addDependent, HashMap map, Integer markWith) {
List projectsToSearch= new ArrayList();
private Collection<ICProject> getProjects(ICProject[] projects, boolean addDependencies, boolean addDependent, HashMap<IProject, Integer> map, Integer markWith) {
List<IProject> projectsToSearch= new ArrayList<IProject>();
for (int i = 0; i < projects.length; i++) {
ICProject cproject = projects[i];
for(ICProject cproject : projects) {
IProject project= cproject.getProject();
checkAddProject(project, map, projectsToSearch, markWith);
projectsToSearch.add(project);
@ -131,7 +126,7 @@ public class IndexFactory {
if (addDependencies || addDependent) {
for (int i=0; i<projectsToSearch.size(); i++) {
IProject project= (IProject) projectsToSearch.get(i);
IProject project= projectsToSearch.get(i);
IProject[] nextLevel;
try {
if (addDependencies) {
@ -154,11 +149,10 @@ public class IndexFactory {
}
CoreModel cm= CoreModel.getDefault();
Collection result= new ArrayList();
for (Iterator iter= map.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry= (Map.Entry) iter.next();
Collection<ICProject> result= new ArrayList<ICProject>();
for(Map.Entry<IProject, Integer> entry : map.entrySet()) {
if (entry.getValue() == markWith) {
ICProject cproject= cm.create((IProject) entry.getKey());
ICProject cproject= cm.create(entry.getKey());
if (cproject != null) {
result.add(cproject);
}
@ -167,7 +161,7 @@ public class IndexFactory {
return result;
}
private void checkAddProject(IProject project, HashMap map, List projectsToSearch, Integer markWith) {
private void checkAddProject(IProject project, HashMap<IProject, Integer> map, List<IProject> projectsToSearch, Integer markWith) {
if (map.get(project) == null) {
if (project.isOpen()) {
map.put(project, markWith);
@ -185,7 +179,7 @@ public class IndexFactory {
* @param id2fragment the map to add the entry to
* @param fragment the fragment or null (which will result in no action)
*/
private void safeAddFragment(Map id2fragment, IIndexFragment fragment) {
private void safeAddFragment(Map<String, IIndexFragment> id2fragment, IIndexFragment fragment) {
if(fragment!=null) {
try {
fragment.acquireReadLock();
@ -210,7 +204,7 @@ public class IndexFactory {
* @param cproject
* @param fragments
*/
private void safeAddProvidedFragments(ICProject cproject, Map fragments) {
private void safeAddProvidedFragments(ICProject cproject, Map<String, IIndexFragment> fragments) {
ICProjectDescription pd= CoreModel.getDefault().getProjectDescription(cproject.getProject(), false);
if(pd!=null) {
IndexProviderManager ipm = CCoreInternals.getPDOMManager().getIndexProviderManager();
@ -218,8 +212,8 @@ public class IndexFactory {
if (cfg != null) {
try {
IIndexFragment[] pFragments= ipm.getProvidedIndexFragments(cfg);
for(int i=0; i<pFragments.length; i++) {
safeAddFragment(fragments, pFragments[i]);
for(IIndexFragment fragment : pFragments) {
safeAddFragment(fragments, fragment);
}
} catch(CoreException ce) {
CCorePlugin.log(ce);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Symbian Software Systems and others.
* Copyright (c) 2007, 2008 Symbian 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
@ -29,7 +29,7 @@ import org.eclipse.core.runtime.CoreException;
*/
public abstract class AbstractCompositeFactory implements ICompositesFactory {
protected IIndex index;
private Comparator fragmentComparator;
private Comparator<IIndexFragmentBinding> fragmentComparator;
public AbstractCompositeFactory(IIndex index) {
this.index= index;
@ -42,7 +42,6 @@ public abstract class AbstractCompositeFactory implements ICompositesFactory {
}
/*
* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.composite.ICompositesFactory#getCompositeBindings(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.internal.core.index.IIndexFragmentBinding[])
*/
public final IIndexBinding[] getCompositeBindings(IIndexFragmentBinding[] bindings) {
@ -52,7 +51,7 @@ public abstract class AbstractCompositeFactory implements ICompositesFactory {
return result;
}
/* (non-Javadoc)
/*
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getComposites(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.internal.core.index.IIndexFragmentBinding[][])
*/
public final IIndexBinding[] getCompositeBindings(IIndexFragmentBinding[][] fragmentBindings) {
@ -66,11 +65,11 @@ public abstract class AbstractCompositeFactory implements ICompositesFactory {
* @return an array of unique bindings
*/
protected IIndexFragmentBinding[] mergeBindingArrays(IIndexFragmentBinding[][] fragmentBindings) {
TreeSet ts = new TreeSet(fragmentComparator);
TreeSet<IIndexFragmentBinding> ts = new TreeSet<IIndexFragmentBinding>(fragmentComparator);
for(int i=0; i<fragmentBindings.length; i++)
for(int j=0; j<fragmentBindings[i].length; j++)
ts.add(fragmentBindings[i][j]);
return (IIndexFragmentBinding[]) ts.toArray(new IIndexFragmentBinding[ts.size()]);
return ts.toArray(new IIndexFragmentBinding[ts.size()]);
}
/**
@ -98,23 +97,18 @@ public abstract class AbstractCompositeFactory implements ICompositesFactory {
throw new CompositingNotImplementedError();
}
private static class FragmentBindingComparator implements Comparator {
private static class FragmentBindingComparator implements Comparator<IIndexFragmentBinding> {
private IIndexFragmentBindingComparator[] comparators;
FragmentBindingComparator(IIndexFragmentBindingComparator[] comparators) {
this.comparators= comparators;
}
public int compare(Object o1, Object o2) {
if(o1 instanceof IIndexFragmentBinding && o2 instanceof IIndexFragmentBinding) {
IIndexFragmentBinding f1= (IIndexFragmentBinding) o1;
IIndexFragmentBinding f2= (IIndexFragmentBinding) o2;
for(int i=0; i<comparators.length; i++) {
int cmp= comparators[i].compare(f1, f2);
if(cmp!=Integer.MIN_VALUE) {
return cmp;
}
public int compare(IIndexFragmentBinding f1, IIndexFragmentBinding f2) {
for(int i=0; i<comparators.length; i++) {
int cmp= comparators[i].compare(f1, f2);
if(cmp!=Integer.MIN_VALUE) {
return cmp;
}
}
throw new IllegalArgumentException();

View file

@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.core.runtime.CoreException;
/**
@ -73,7 +72,7 @@ public abstract class CompositeIndexBinding implements IIndexBinding {
}
public IScope getScope() throws DOMException {
return cf.getCompositeScope((IIndexScope)rbinding.getScope());
return cf.getCompositeScope(rbinding.getScope());
}
public boolean hasDefinition() throws CoreException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Symbian Software Systems and others.
* Copyright (c) 2007, 2008 Symbian 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
@ -67,8 +67,8 @@ public final class IndexProviderManager implements IElementChangedListener {
private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
private IIndexFragmentProvider[] allProviders;
private Map/*<List,Boolean>*/ provisionMap;
private Set/*<String>*/ compatibleFragmentUnavailable;
private Map<ProvisionMapKey,Boolean> provisionMap;
private Set<String> compatibleFragmentUnavailable;
private VersionRange pdomVersionRange;
public IndexProviderManager() {
@ -88,13 +88,13 @@ public final class IndexProviderManager implements IElementChangedListener {
*/
public void reset(VersionRange pdomVersionRange) {
this.allProviders= new IIndexFragmentProvider[0];
this.provisionMap= new HashMap();
this.provisionMap= new HashMap<ProvisionMapKey,Boolean>();
this.pdomVersionRange= pdomVersionRange;
this.compatibleFragmentUnavailable= new HashSet();
this.compatibleFragmentUnavailable= new HashSet<String>();
}
public void startup() {
List providers = new ArrayList();
List<IIndexProvider> providers = new ArrayList<IIndexProvider>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint indexProviders = registry.getExtensionPoint(CCorePlugin.INDEX_UNIQ_ID);
IExtension[] extensions = indexProviders.getExtensions();
@ -123,7 +123,7 @@ public final class IndexProviderManager implements IElementChangedListener {
}
CoreModel.getDefault().addElementChangedListener(this);
this.allProviders = (IIndexFragmentProvider[]) providers.toArray(new IIndexFragmentProvider[providers.size()]);
this.allProviders = providers.toArray(new IIndexFragmentProvider[providers.size()]);
}
/**
@ -135,7 +135,7 @@ public final class IndexProviderManager implements IElementChangedListener {
* @return the array of IIndexFragment objects for the current state
*/
public IIndexFragment[] getProvidedIndexFragments(ICConfigurationDescription config) throws CoreException {
Map id2fragment = new HashMap();
Map<String, IIndexFragment> id2fragment = new HashMap<String, IIndexFragment>();
IProject project= config.getProjectDescription().getProject();
for(int i=0; i<allProviders.length; i++) {
@ -158,11 +158,10 @@ public final class IndexProviderManager implements IElementChangedListener {
}
// Make log entries for any fragments which have no compatible equivalents
List preresult= new ArrayList();
for(Iterator i=id2fragment.entrySet().iterator(); i.hasNext(); ) {
Map.Entry entry= (Map.Entry) i.next();
List<IIndexFragment> preresult= new ArrayList<IIndexFragment>();
for(Map.Entry<String, IIndexFragment> entry : id2fragment.entrySet()) {
if(entry.getValue()==null) {
String key= (String) entry.getKey();
String key= entry.getKey();
if(!compatibleFragmentUnavailable.contains(key)) {
String msg= MessageFormat.format(
Messages.IndexProviderManager_NoCompatibleFragmentsAvailable,
@ -176,7 +175,7 @@ public final class IndexProviderManager implements IElementChangedListener {
preresult.add(entry.getValue());
}
}
return (IIndexFragment[]) preresult.toArray(new IIndexFragment[preresult.size()]);
return preresult.toArray(new IIndexFragment[preresult.size()]);
}
/**
@ -201,7 +200,7 @@ public final class IndexProviderManager implements IElementChangedListener {
* @param id2fragment
* @param candidate
*/
private void processCandidate(Map id2fragment, IIndexFragment candidate) throws InterruptedException, CoreException {
private void processCandidate(Map<String, IIndexFragment> id2fragment, IIndexFragment candidate) throws InterruptedException, CoreException {
String cid= null, csver= null, cformatID= null;
try {
candidate.acquireReadLock();
@ -214,7 +213,7 @@ public final class IndexProviderManager implements IElementChangedListener {
assert cid!=null && csver!=null && cformatID!=null;
Version cver= Version.parseVersion(csver); // illegal argument exception
IIndexFragment existing= (IIndexFragment) id2fragment.get(cid);
IIndexFragment existing= id2fragment.get(cid);
if(getCurrentlySupportedVersionRangeForFormat(cformatID).isIncluded(cver)) {
if(existing != null) {
@ -284,9 +283,7 @@ public final class IndexProviderManager implements IElementChangedListener {
}
private boolean providesForProject(IIndexProvider provider, IProject project) {
List key = new ArrayList();
key.add(provider);
key.add(project);
ProvisionMapKey key= new ProvisionMapKey(provider, project);
if(!provisionMap.containsKey(key)) {
try {
@ -298,7 +295,7 @@ public final class IndexProviderManager implements IElementChangedListener {
}
}
return ((Boolean) provisionMap.get(key)).booleanValue();
return provisionMap.get(key).booleanValue();
}
public void elementChanged(ElementChangedEvent event) {
@ -324,18 +321,46 @@ public final class IndexProviderManager implements IElementChangedListener {
final ICProject cproject = (ICProject)delta.getElement();
switch (delta.getKind()) {
case ICElementDelta.REMOVED:
List toRemove = new ArrayList();
for(Iterator i = provisionMap.keySet().iterator(); i.hasNext(); ) {
List key = (List) i.next();
if(key.contains(cproject.getProject())) {
List<ProvisionMapKey> toRemove = new ArrayList<ProvisionMapKey>();
for(Iterator<ProvisionMapKey> i = provisionMap.keySet().iterator(); i.hasNext(); ) {
ProvisionMapKey key = i.next();
if(key.getProject().equals(cproject.getProject())) {
toRemove.add(key);
}
}
for(Iterator i = toRemove.iterator(); i.hasNext(); ) {
provisionMap.remove(i.next());
for(ProvisionMapKey key : toRemove) {
provisionMap.remove(key);
}
break;
}
}
}
private static class ProvisionMapKey {
private final IIndexProvider provider;
private final IProject project;
ProvisionMapKey(IIndexProvider provider, IProject project) {
this.provider= provider;
this.project= project;
}
@Override
public boolean equals(Object obj) {
if(obj instanceof ProvisionMapKey) {
ProvisionMapKey other= (ProvisionMapKey) obj;
return other.project.equals(project) && other.provider.equals(provider);
}
return false;
}
@Override
public int hashCode() {
return project.hashCode() ^ provider.hashCode();
}
public IProject getProject() {
return project;
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Symbian Software Systems and others.
* Copyright (c) 2007, 2008 Symbian 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
@ -26,13 +26,13 @@ import org.eclipse.core.runtime.IPath;
* Internal singleton map maintained for non-project PDOM objects
*/
class PDOMCache {
private Map/*<File, PDOM>*/ path2pdom; // gives the PDOM for a particular path
private Map<File, PDOM> path2pdom; // gives the PDOM for a particular path
private static PDOMCache singleton;
private static Object singletonMutex = new Object();
private PDOMCache() {
this.path2pdom = new HashMap();
this.path2pdom = new HashMap<File, PDOM>();
}
/**
@ -61,11 +61,11 @@ class PDOMCache {
synchronized(path2pdom) {
if(path2pdom.containsKey(file)) {
result = (PDOM) path2pdom.get(file);
result= path2pdom.get(file);
}
if(result==null) {
try {
result = new PDOM(file, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
result= new PDOM(file, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
path2pdom.put(file, result);
} catch(CoreException ce) {
CCorePlugin.log(ce);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Symbian Software Systems and others.
* Copyright (c) 2007, 2008 Symbian 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
@ -28,24 +28,24 @@ public class ReadOnlyPDOMProviderBridge implements IIndexFragmentProvider {
protected IReadOnlyPDOMProvider opp;
public ReadOnlyPDOMProviderBridge(IReadOnlyPDOMProvider opp) {
this.opp = opp;
this.opp= opp;
}
public IIndexFragment[] getIndexFragments(ICConfigurationDescription config) throws CoreException {
IPDOMDescriptor[] descs = opp.getDescriptors(config);
IPDOMDescriptor[] descriptions = opp.getDescriptors(config);
List preresult = new ArrayList();
List<PDOM> result = new ArrayList<PDOM>();
if(descs!=null) {
for(int i=0; i<descs.length; i++) {
PDOM pdom= PDOMCache.getInstance().getPDOM(descs[i].getLocation(), descs[i].getIndexLocationConverter());
if(descriptions!=null) {
for(IPDOMDescriptor dsc : descriptions) {
PDOM pdom= PDOMCache.getInstance().getPDOM(dsc.getLocation(), dsc.getIndexLocationConverter());
if(pdom!=null) {
preresult.add(pdom);
result.add(pdom);
}
}
}
return (IIndexFragment[]) preresult.toArray(new IIndexFragment[preresult.size()]);
return result.toArray(new IIndexFragment[result.size()]);
}
public boolean providesFor(ICProject cproject) throws CoreException {

View file

@ -368,7 +368,6 @@ public class PDOMManager implements IWritableIndexManager, IListener {
}
}
@SuppressWarnings("unchecked")
private Map<String, IPDOMLinkageFactory> getLinkageFactories() {
return LanguageManager.getInstance().getPDOMLinkageFactoryMappings();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Symbian Software Systems and others.
* Copyright (c) 2007, 2008 Symbian 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
@ -80,11 +80,11 @@ public class DBProperties {
}
/**
* Returns a Set of property names (Strings) stored in this object
* @return a Set of property names (Strings) stored in this object
* Returns the Set of property names stored in this object
* @return the Set of property names stored in this object
* @throws CoreException
*/
public Set getKeySet() throws CoreException {
public Set<String> getKeySet() throws CoreException {
return DBProperty.getKeySet(db, index);
}
@ -225,8 +225,8 @@ public class DBProperties {
return result[0];
}
public static Set getKeySet(final Database db, final BTree index) throws CoreException {
final Set result= new HashSet();
public static Set<String> getKeySet(final Database db, final BTree index) throws CoreException {
final Set<String> result= new HashSet<String>();
index.accept(new IBTreeVisitor(){
public int compare(int record) throws CoreException {
return 0;

View file

@ -36,8 +36,8 @@ public class CLIUtil {
* @return
* @throws CoreException if the number of parameters is not the specified expected number
*/
public static List getArg(Map arguments, String opt, int number) throws CoreException {
List list = (List) arguments.get(opt);
public static List<String> getArg(Map<String, List<String>> arguments, String opt, int number) throws CoreException {
List<String> list = arguments.get(opt);
if(list==null || list.size()!=number) {
String msg= MessageFormat.format(Messages.CLIUtil_OptionParametersMismatch, new Object[] {opt, ""+number}); //$NON-NLS-1$
GeneratePDOMApplication.fail(msg);
@ -51,19 +51,19 @@ public class CLIUtil {
* @param args
* @return
*/
public static Map/*<String,List<String>>*/ parseToMap(String[] args) {
Map result = new HashMap();
public static Map<String,List<String>> parseToMap(String[] args) {
Map<String,List<String>> result = new HashMap<String,List<String>>();
String current = null;
for(int i=0; i<args.length; i++) {
if(args[i].startsWith("-")) { //$NON-NLS-1$
current = args[i];
result.put(current, new ArrayList());
result.put(current, new ArrayList<String>());
} else {
if(current==null) {
current= UNQUALIFIED_PARAMETERS;
result.put(current, new ArrayList());
result.put(current, new ArrayList<String>());
}
((List) result.get(current)).add(args[i]);
(result.get(current)).add(args[i]);
}
}
return result;

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.pdom.export;
import java.io.File;
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
@ -34,8 +33,8 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* An ISafeRunnable which
* <ul>
* <li>Creates a project for export
* <li>Exports the pdom
* <li>Writes new properties to the pdom
* <li>Exports the PDOM
* <li>Writes new properties to the PDOM
* <ul>
*/
public class GeneratePDOM implements ISafeRunnable {
@ -82,11 +81,10 @@ public class GeneratePDOM implements ISafeRunnable {
WritablePDOM exportedPDOM= new WritablePDOM(targetLocation, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
exportedPDOM.acquireWriteLock(0);
try {
Map exportProperties= pm.getExportProperties();
Map<String,String> exportProperties= pm.getExportProperties();
if(exportProperties!=null) {
for(Iterator i = exportProperties.entrySet().iterator(); i.hasNext(); ) {
Map.Entry entry = (Map.Entry) i.next();
exportedPDOM.setProperty((String) entry.getKey(), (String) entry.getValue());
for(Map.Entry<String,String> entry : exportProperties.entrySet()) {
exportedPDOM.setProperty(entry.getKey(), entry.getValue());
}
}
// fake PDOM-version to that which can be safely read by the CDT-version
@ -104,7 +102,6 @@ public class GeneratePDOM implements ISafeRunnable {
}
public void handleException(Throwable exception) {
// subclass for custom behaviour
CCorePlugin.log(exception);
}

View file

@ -14,6 +14,7 @@ import java.io.File;
import java.io.PrintStream;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
@ -53,7 +54,7 @@ public class GeneratePDOMApplication implements IApplication {
*/
public static final int ECODE_EXPECTED_FAILURE= 1;
private static Map/*<String,IProjectForExportManager>*/ projectInitializers;
private static Map<String,IExportProjectProvider> projectInitializers;
/**
* Starts this application
@ -76,7 +77,7 @@ public class GeneratePDOMApplication implements IApplication {
private Object startImpl(IApplicationContext context) throws CoreException {
String[] appArgs= (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
Map arguments= CLIUtil.parseToMap(appArgs);
Map<String,List<String>> arguments= CLIUtil.parseToMap(appArgs);
output(Messages.GeneratePDOMApplication_Initializing);
setupCLIProgressProvider();
@ -86,17 +87,17 @@ public class GeneratePDOMApplication implements IApplication {
output(MessageFormat.format(Messages.GeneratePDOMApplication_UsingDefaultProjectProvider, new Object[] {DEFAULT_PROJECT_PROVIDER}));
pproviderFQN= DEFAULT_PROJECT_PROVIDER;
} else {
pproviderFQN= (String) CLIUtil.getArg(arguments, OPT_PROJECTPROVIDER, 1).get(0);
pproviderFQN= CLIUtil.getArg(arguments, OPT_PROJECTPROVIDER, 1).get(0);
}
String target= (String) CLIUtil.getArg(arguments, OPT_TARGET, 1).get(0);
String target= CLIUtil.getArg(arguments, OPT_TARGET, 1).get(0);
boolean quiet= arguments.get(OPT_QUIET)!=null;
String indexerID= IPDOMManager.ID_FAST_INDEXER;
String[] indexerIDs= (String[]) arguments.get(OPT_INDEXER_ID);
List<String> indexerIDs= arguments.get(OPT_INDEXER_ID);
if(indexerIDs!=null) {
if(indexerIDs.length==1) {
indexerID= indexerIDs[0];
} else if(indexerIDs.length>1) {
if(indexerIDs.size()==1) {
indexerID= indexerIDs.get(0);
} else if(indexerIDs.size()>1) {
fail(MessageFormat.format(Messages.GeneratePDOMApplication_InvalidIndexerID, new Object[] {OPT_INDEXER_ID}));
}
}
@ -149,7 +150,7 @@ public class GeneratePDOMApplication implements IApplication {
*/
private static synchronized IExportProjectProvider getExportProjectProvider(String fqn) {
if(projectInitializers==null) {
projectInitializers = new HashMap();
projectInitializers = new HashMap<String, IExportProjectProvider>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint indexExtensions = registry.getExtensionPoint(CCorePlugin.INDEX_UNIQ_ID);
IExtension[] extensions = indexExtensions.getExtensions();
@ -170,12 +171,12 @@ public class GeneratePDOMApplication implements IApplication {
}
}
IExportProjectProvider initer = (IExportProjectProvider) projectInitializers.get(fqn);
IExportProjectProvider initer = projectInitializers.get(fqn);
return initer;
}
/**
* In this application, the usual progress reports are redirected to stdoutt
* In this application, the usual progress reports are redirected to standard out
*/
private void setupCLIProgressProvider() {
ProgressProvider pp = new ProgressProvider() {