1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-01 12:43:26 +02:00

Fix warnings.

This commit is contained in:
Markus Schorn 2008-05-09 14:49:29 +00:00
parent 6519bc4131
commit 4d2627c171
7 changed files with 93 additions and 78 deletions

View file

@ -24,7 +24,7 @@ public class CharArrayObjectMap extends CharTable {
@Override @Override
public Object clone() { return this; } public Object clone() { return this; }
@Override @Override
public List toList() { return Collections.EMPTY_LIST; } public List<char[]> toList() { return Collections.emptyList(); }
@Override @Override
public Object put( char[] key, int start, int length, Object value ) public Object put( char[] key, int start, int length, Object value )
{ throw new UnsupportedOperationException(); } { throw new UnsupportedOperationException(); }
@ -107,7 +107,7 @@ public class CharArrayObjectMap extends CharTable {
} }
@Override @Override
protected int partition( Comparator c, int p, int r ){ protected int partition( Comparator<Object> c, int p, int r ){
char[] x = keyTable[ p ]; char[] x = keyTable[ p ];
Object temp = null; Object temp = null;
int i = p; int i = p;
@ -138,7 +138,7 @@ public class CharArrayObjectMap extends CharTable {
return values; return values;
} }
public Object [] valueArray(Class clazz){ public Object [] valueArray(Class<?> clazz){
Object[] values= (Object[]) Array.newInstance(clazz, size()); Object[] values= (Object[]) Array.newInstance(clazz, size());
System.arraycopy( valueTable, 0, values, 0, values.length ); System.arraycopy( valueTable, 0, values, 0, values.length );
return values; return values;

View file

@ -26,11 +26,11 @@ public class CharArraySet extends CharTable {
@Override @Override
public Object clone() { return this; } public Object clone() { return this; }
@Override @Override
public List toList() { return Collections.EMPTY_LIST; } public List<char[]> toList() { return Collections.emptyList(); }
@Override @Override
public void put( char[] key ) { throw new UnsupportedOperationException(); } public void put( char[] key ) { throw new UnsupportedOperationException(); }
@Override @Override
public void addAll( List list ) { throw new UnsupportedOperationException(); } public void addAll( List<char[]> list ) { throw new UnsupportedOperationException(); }
@Override @Override
public void addAll( CharArraySet set ) { throw new UnsupportedOperationException(); } public void addAll( CharArraySet set ) { throw new UnsupportedOperationException(); }
}; };
@ -43,13 +43,13 @@ public class CharArraySet extends CharTable {
addIndex(key); addIndex(key);
} }
public void addAll( List list ){ public void addAll( List<char[]> list ){
if( list == null ) if( list == null )
return; return;
int size = list.size(); int size = list.size();
for( int i = 0; i < size; i++ ){ for( int i = 0; i < size; i++ ){
addIndex( (char[]) list.get( i ) ); addIndex( list.get( i ) );
} }
} }

View file

@ -49,8 +49,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
private ICConfigurationDescription fCfgDes; private ICConfigurationDescription fCfgDes;
private IProject fProject; private IProject fProject;
private COwner fOwner; private COwner fOwner;
private final HashMap fDesMap = new HashMap(); private final HashMap<String, ArrayList<ICExtensionReference>> fDesMap = new HashMap<String, ArrayList<ICExtensionReference>>();
private final HashMap fStorageDataElMap = new HashMap(); private final HashMap<String, Element> fStorageDataElMap = new HashMap<String, Element>();
private boolean fApplyOnChange = true; private boolean fApplyOnChange = true;
private boolean fIsDirty; private boolean fIsDirty;
private CDescriptorEvent fOpEvent; private CDescriptorEvent fOpEvent;
@ -152,8 +152,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
//write is done for all configurations to avoid "data loss" on configuration change //write is done for all configurations to avoid "data loss" on configuration change
ICProjectDescription des = fCfgDes.getProjectDescription(); ICProjectDescription des = fCfgDes.getProjectDescription();
ICConfigurationDescription cfgs[] = des.getConfigurations(); ICConfigurationDescription cfgs[] = des.getConfigurations();
for(int i = 0; i < cfgs.length; i++){ for (ICConfigurationDescription cfg : cfgs) {
ICConfigurationDescription cfg = cfgs[i];
if(cfg != fCfgDes){ if(cfg != fCfgDes){
try { try {
cfg.create(extensionPoint, id); cfg.create(extensionPoint, id);
@ -193,9 +192,9 @@ public class CConfigBasedDescriptor implements ICDescriptor {
private CConfigBaseDescriptorExtensionReference create(ICConfigExtensionReference ref){ private CConfigBaseDescriptorExtensionReference create(ICConfigExtensionReference ref){
CConfigBaseDescriptorExtensionReference dr = new CConfigBaseDescriptorExtensionReference(ref); CConfigBaseDescriptorExtensionReference dr = new CConfigBaseDescriptorExtensionReference(ref);
synchronized (fDesMap) { synchronized (fDesMap) {
ArrayList list = (ArrayList)fDesMap.get(ref.getExtensionPoint()); ArrayList<ICExtensionReference> list = fDesMap.get(ref.getExtensionPoint());
if(list == null){ if(list == null){
list = new ArrayList(1); list = new ArrayList<ICExtensionReference>(1);
fDesMap.put(ref.getExtensionPoint(), list); fDesMap.put(ref.getExtensionPoint(), list);
} else { } else {
list.ensureCapacity(list.size() + 1); list.ensureCapacity(list.size() + 1);
@ -207,7 +206,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
public ICExtensionReference[] get(String extensionPoint) { public ICExtensionReference[] get(String extensionPoint) {
ICConfigExtensionReference[] rs = fCfgDes.get(extensionPoint); ICConfigExtensionReference[] rs = fCfgDes.get(extensionPoint);
ArrayList refs = new ArrayList(); ArrayList<ICConfigExtensionReference> refs = new ArrayList<ICConfigExtensionReference>();
refs.addAll(Arrays.asList(rs)); refs.addAll(Arrays.asList(rs));
ICConfigurationDescription[] cfgs = ICConfigurationDescription[] cfgs =
@ -223,8 +222,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
} }
} }
ICConfigExtensionReference cfgRefs[] = ICConfigExtensionReference cfgRefs[] =
(ICConfigExtensionReference[])refs.toArray( refs.toArray(
new ICConfigExtensionReference[refs.size()]); new ICConfigExtensionReference[refs.size()]);
if(cfgRefs.length == 0){ if(cfgRefs.length == 0){
return new ICExtensionReference[0]; return new ICExtensionReference[0];
@ -232,7 +231,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
ICExtensionReference[] extRefs = new ICExtensionReference[cfgRefs.length]; ICExtensionReference[] extRefs = new ICExtensionReference[cfgRefs.length];
synchronized (fDesMap) { synchronized (fDesMap) {
ArrayList list = (ArrayList)fDesMap.get(extensionPoint); ArrayList<ICExtensionReference> list = fDesMap.get(extensionPoint);
// if(list == null){ // if(list == null){
// list = new ArrayList(cfgRefs.length); // list = new ArrayList(cfgRefs.length);
// fDesMap.put(extensionPoint, list); // fDesMap.put(extensionPoint, list);
@ -246,14 +245,15 @@ public class CConfigBasedDescriptor implements ICDescriptor {
for(int i = cfgRefs.length - 1; i >= 0; i--){ for(int i = cfgRefs.length - 1; i >= 0; i--){
ICConfigExtensionReference ref = cfgRefs[i]; ICConfigExtensionReference ref = cfgRefs[i];
int k = list != null ? list.size() - 1 : -1; int k= -1;
if (list != null) {
for(; k >= 0; k--){ for(k= list.size()-1; k >= 0; k--){
CConfigBaseDescriptorExtensionReference r = (CConfigBaseDescriptorExtensionReference)list.get(k); CConfigBaseDescriptorExtensionReference r = (CConfigBaseDescriptorExtensionReference)list.get(k);
if(r.fCfgExtRef == ref){ if(r.fCfgExtRef == ref){
extRefs[num--] = r; extRefs[num--] = r;
list.remove(k); list.remove(k);
break; break;
}
} }
} }
if(k < 0){ if(k < 0){
@ -262,7 +262,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
} }
if(list == null){ if(list == null){
list = new ArrayList(cfgRefs.length); list = new ArrayList<ICExtensionReference>(cfgRefs.length);
fDesMap.put(extensionPoint, list); fDesMap.put(extensionPoint, list);
} else { } else {
list.clear(); list.clear();
@ -300,7 +300,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
public Element getProjectData(String id) throws CoreException { public Element getProjectData(String id) throws CoreException {
// avoid deadlock by using different lock here. // avoid deadlock by using different lock here.
synchronized(fStorageDataElMap /*CProjectDescriptionManager.getInstance()*/){ synchronized(fStorageDataElMap /*CProjectDescriptionManager.getInstance()*/){
Element el = (Element)fStorageDataElMap.get(id); Element el = fStorageDataElMap.get(id);
if(el == null || el.getParentNode() == null){ if(el == null || el.getParentNode() == null){
InternalXmlStorageElement storageEl = (InternalXmlStorageElement)fCfgDes.getStorage(id, false); InternalXmlStorageElement storageEl = (InternalXmlStorageElement)fCfgDes.getStorage(id, false);
if(storageEl == null){ if(storageEl == null){
@ -332,14 +332,13 @@ public class CConfigBasedDescriptor implements ICDescriptor {
//write is done for all configurations to avoid "data loss" on configuration change //write is done for all configurations to avoid "data loss" on configuration change
ICProjectDescription des = fCfgDes.getProjectDescription(); ICProjectDescription des = fCfgDes.getProjectDescription();
ICConfigurationDescription cfgs[] = des.getConfigurations(); ICConfigurationDescription cfgs[] = des.getConfigurations();
for(int i = 0; i < cfgs.length; i++){ for (ICConfigurationDescription cfg : cfgs) {
ICConfigurationDescription cfg = cfgs[i];
if(cfg != fCfgDes){ if(cfg != fCfgDes){
try { try {
ICConfigExtensionReference rs[] = cfg.get(ref.getExtensionPoint()); ICConfigExtensionReference rs[] = cfg.get(ref.getExtensionPoint());
for(int k = 0; k < rs.length; k++){ for (ICConfigExtensionReference element : rs) {
if(ref.getID().equals(rs[i].getID())){ if(ref.getID().equals(element.getID())){
cfg.remove(rs[i]); cfg.remove(element);
break; break;
} }
} }
@ -359,8 +358,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
//write is done for all configurations to avoid "data loss" on configuration change //write is done for all configurations to avoid "data loss" on configuration change
ICProjectDescription des = fCfgDes.getProjectDescription(); ICProjectDescription des = fCfgDes.getProjectDescription();
ICConfigurationDescription cfgs[] = des.getConfigurations(); ICConfigurationDescription cfgs[] = des.getConfigurations();
for(int i = 0; i < cfgs.length; i++){ for (ICConfigurationDescription cfg : cfgs) {
ICConfigurationDescription cfg = cfgs[i];
if(cfg != fCfgDes){ if(cfg != fCfgDes){
try { try {
cfg.remove(extensionPoint); cfg.remove(extensionPoint);
@ -383,8 +381,10 @@ public class CConfigBasedDescriptor implements ICDescriptor {
setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0)); setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
} }
public Map getStorageDataElMap(){ public Map<String, Element> getStorageDataElMap(){
return (HashMap)fStorageDataElMap.clone(); @SuppressWarnings("unchecked")
final HashMap<String, Element> clone = (HashMap<String, Element>)fStorageDataElMap.clone();
return clone;
} }
public ICConfigurationDescription getConfigurationDescription() { public ICConfigurationDescription getConfigurationDescription() {

View file

@ -170,9 +170,12 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
} }
} }
// Parse // Parse
IASTTranslationUnit ast= parser.parse(); if (parser != null) {
ast.setIsHeaderUnit(!isSource[0]); IASTTranslationUnit ast= parser.parse();
return ast; ast.setIsHeaderUnit(!isSource[0]);
return ast;
}
return null;
} }
public IASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset, public IASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset,

View file

@ -35,34 +35,30 @@ public class SavedCodeReaderFactory implements ICodeReaderFactory {
private SavedCodeReaderFactory() private SavedCodeReaderFactory()
{ {
int size=0; int size= CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB;
Preferences pluginPreferences = CCorePlugin.getDefault().getPluginPreferences(); final CCorePlugin corePlugin = CCorePlugin.getDefault();
if (CCorePlugin.getDefault() == null || pluginPreferences == null) if (corePlugin != null) {
size = CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB; Preferences pluginPreferences = corePlugin.getPluginPreferences();
else if (pluginPreferences != null) {
size = pluginPreferences.getInt(CodeReaderCache.CODE_READER_BUFFER); size = pluginPreferences.getInt(CodeReaderCache.CODE_READER_BUFFER);
if (size == 0) {
if (size > 0) String [] properties = pluginPreferences.propertyNames();
cache = new CodeReaderCache(size); boolean found = false;
else if( size == 0 ) for (int j = 0; j < properties.length; ++j) {
{ if (properties[j].equals( CodeReaderCache.CODE_READER_BUFFER)) {
//necessary for cache to work headless found = true;
String [] properties = pluginPreferences.propertyNames(); break;
boolean found = false; }
for( int j = 0; j < properties.length; ++j ) }
if( properties[j].equals( CodeReaderCache.CODE_READER_BUFFER ) ) if (!found) {
{ size= CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB;
found = true; }
break; } else if (size < 0) {
size= CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB;
} }
}
if( !found && size == 0 )
cache = new CodeReaderCache(CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
else
cache = new CodeReaderCache(0);
} }
else cache = new CodeReaderCache(size);
cache = new CodeReaderCache(CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#getUniqueIdentifier() * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#getUniqueIdentifier()

View file

@ -53,13 +53,11 @@ public class DefaultEnvironmentContextInfo implements IEnvironmentContextInfo{
*/ */
public IEnvironmentContextInfo getNext(){ public IEnvironmentContextInfo getNext(){
DefaultEnvironmentContextInfo next = null; DefaultEnvironmentContextInfo next = null;
if(fContextObject == null) if(fContextObject instanceof ICConfigurationDescription) {
next = null;
else if(fContextObject instanceof ICConfigurationDescription)
next = new DefaultEnvironmentContextInfo(null); next = new DefaultEnvironmentContextInfo(null);
if (next.getSuppliers() == null)
if(next != null && next.getSuppliers() == null) next = null;
next = null; }
return next; return next;
} }

View file

@ -618,10 +618,13 @@ public final class CharOperation {
if (nameLength == 0) if (nameLength == 0)
return concatWith(array, separator); return concatWith(array, separator);
int length = array == null ? 0 : array.length; if (array == null)
return name;
final int length= array.length;
if (length == 0) if (length == 0)
return name; return name;
int size = nameLength; int size = nameLength;
int index = length; int index = length;
while (--index >= 0) while (--index >= 0)
@ -682,7 +685,10 @@ public final class CharOperation {
if (nameLength == 0) if (nameLength == 0)
return concatWith(array, separator); return concatWith(array, separator);
int length = array == null ? 0 : array.length; if (array == null)
return name;
final int length= array.length;
if (length == 0) if (length == 0)
return name; return name;
@ -728,7 +734,10 @@ public final class CharOperation {
* @return the concatenation of the given array parts using the given separator between each part * @return the concatenation of the given array parts using the given separator between each part
*/ */
public static final char[] concatWith(char[][] array, char separator) { public static final char[] concatWith(char[][] array, char separator) {
int length = array == null ? 0 : array.length; if (array == null)
return CharOperation.NO_CHAR;
int length= array.length;
if (length == 0) if (length == 0)
return CharOperation.NO_CHAR; return CharOperation.NO_CHAR;
@ -2217,7 +2226,10 @@ public final class CharOperation {
* whitespaces equals to ' ' * whitespaces equals to ' '
*/ */
public static final char[][] splitAndTrimOn(char divider, char[] array) { public static final char[][] splitAndTrimOn(char divider, char[] array) {
int length = array == null ? 0 : array.length; if (array == null)
return NO_CHAR_CHAR;
final int length= array.length;
if (length == 0) if (length == 0)
return NO_CHAR_CHAR; return NO_CHAR_CHAR;
@ -2289,7 +2301,10 @@ public final class CharOperation {
* @return a new array which is the split of the given array using the given divider * @return a new array which is the split of the given array using the given divider
*/ */
public static final char[][] splitOn(char divider, char[] array) { public static final char[][] splitOn(char divider, char[] array) {
int length = array == null ? 0 : array.length; if (array == null)
return NO_CHAR_CHAR;
final int length= array.length;
if (length == 0) if (length == 0)
return NO_CHAR_CHAR; return NO_CHAR_CHAR;
@ -2344,7 +2359,10 @@ public final class CharOperation {
char[] array, char[] array,
int start, int start,
int end) { int end) {
int length = array == null ? 0 : array.length; if (array == null)
return NO_CHAR_CHAR;
final int length= array.length;
if (length == 0 || start > end) if (length == 0 || start > end)
return NO_CHAR_CHAR; return NO_CHAR_CHAR;