mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-16 13:35:22 +02:00
Fix warnings.
This commit is contained in:
parent
6519bc4131
commit
4d2627c171
7 changed files with 93 additions and 78 deletions
|
@ -24,7 +24,7 @@ public class CharArrayObjectMap extends CharTable {
|
|||
@Override
|
||||
public Object clone() { return this; }
|
||||
@Override
|
||||
public List toList() { return Collections.EMPTY_LIST; }
|
||||
public List<char[]> toList() { return Collections.emptyList(); }
|
||||
@Override
|
||||
public Object put( char[] key, int start, int length, Object value )
|
||||
{ throw new UnsupportedOperationException(); }
|
||||
|
@ -107,7 +107,7 @@ public class CharArrayObjectMap extends CharTable {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected int partition( Comparator c, int p, int r ){
|
||||
protected int partition( Comparator<Object> c, int p, int r ){
|
||||
char[] x = keyTable[ p ];
|
||||
Object temp = null;
|
||||
int i = p;
|
||||
|
@ -138,7 +138,7 @@ public class CharArrayObjectMap extends CharTable {
|
|||
return values;
|
||||
}
|
||||
|
||||
public Object [] valueArray(Class clazz){
|
||||
public Object [] valueArray(Class<?> clazz){
|
||||
Object[] values= (Object[]) Array.newInstance(clazz, size());
|
||||
System.arraycopy( valueTable, 0, values, 0, values.length );
|
||||
return values;
|
||||
|
|
|
@ -26,11 +26,11 @@ public class CharArraySet extends CharTable {
|
|||
@Override
|
||||
public Object clone() { return this; }
|
||||
@Override
|
||||
public List toList() { return Collections.EMPTY_LIST; }
|
||||
public List<char[]> toList() { return Collections.emptyList(); }
|
||||
@Override
|
||||
public void put( char[] key ) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public void addAll( List list ) { throw new UnsupportedOperationException(); }
|
||||
public void addAll( List<char[]> list ) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public void addAll( CharArraySet set ) { throw new UnsupportedOperationException(); }
|
||||
};
|
||||
|
@ -43,13 +43,13 @@ public class CharArraySet extends CharTable {
|
|||
addIndex(key);
|
||||
}
|
||||
|
||||
public void addAll( List list ){
|
||||
public void addAll( List<char[]> list ){
|
||||
if( list == null )
|
||||
return;
|
||||
|
||||
int size = list.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
addIndex( (char[]) list.get( i ) );
|
||||
addIndex( list.get( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
private ICConfigurationDescription fCfgDes;
|
||||
private IProject fProject;
|
||||
private COwner fOwner;
|
||||
private final HashMap fDesMap = new HashMap();
|
||||
private final HashMap fStorageDataElMap = new HashMap();
|
||||
private final HashMap<String, ArrayList<ICExtensionReference>> fDesMap = new HashMap<String, ArrayList<ICExtensionReference>>();
|
||||
private final HashMap<String, Element> fStorageDataElMap = new HashMap<String, Element>();
|
||||
private boolean fApplyOnChange = true;
|
||||
private boolean fIsDirty;
|
||||
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
|
||||
ICProjectDescription des = fCfgDes.getProjectDescription();
|
||||
ICConfigurationDescription cfgs[] = des.getConfigurations();
|
||||
for(int i = 0; i < cfgs.length; i++){
|
||||
ICConfigurationDescription cfg = cfgs[i];
|
||||
for (ICConfigurationDescription cfg : cfgs) {
|
||||
if(cfg != fCfgDes){
|
||||
try {
|
||||
cfg.create(extensionPoint, id);
|
||||
|
@ -193,9 +192,9 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
private CConfigBaseDescriptorExtensionReference create(ICConfigExtensionReference ref){
|
||||
CConfigBaseDescriptorExtensionReference dr = new CConfigBaseDescriptorExtensionReference(ref);
|
||||
synchronized (fDesMap) {
|
||||
ArrayList list = (ArrayList)fDesMap.get(ref.getExtensionPoint());
|
||||
ArrayList<ICExtensionReference> list = fDesMap.get(ref.getExtensionPoint());
|
||||
if(list == null){
|
||||
list = new ArrayList(1);
|
||||
list = new ArrayList<ICExtensionReference>(1);
|
||||
fDesMap.put(ref.getExtensionPoint(), list);
|
||||
} else {
|
||||
list.ensureCapacity(list.size() + 1);
|
||||
|
@ -207,7 +206,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
|
||||
public ICExtensionReference[] get(String extensionPoint) {
|
||||
ICConfigExtensionReference[] rs = fCfgDes.get(extensionPoint);
|
||||
ArrayList refs = new ArrayList();
|
||||
ArrayList<ICConfigExtensionReference> refs = new ArrayList<ICConfigExtensionReference>();
|
||||
refs.addAll(Arrays.asList(rs));
|
||||
|
||||
ICConfigurationDescription[] cfgs =
|
||||
|
@ -223,8 +222,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
}
|
||||
}
|
||||
ICConfigExtensionReference cfgRefs[] =
|
||||
(ICConfigExtensionReference[])refs.toArray(
|
||||
new ICConfigExtensionReference[refs.size()]);
|
||||
refs.toArray(
|
||||
new ICConfigExtensionReference[refs.size()]);
|
||||
|
||||
if(cfgRefs.length == 0){
|
||||
return new ICExtensionReference[0];
|
||||
|
@ -232,7 +231,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
|
||||
ICExtensionReference[] extRefs = new ICExtensionReference[cfgRefs.length];
|
||||
synchronized (fDesMap) {
|
||||
ArrayList list = (ArrayList)fDesMap.get(extensionPoint);
|
||||
ArrayList<ICExtensionReference> list = fDesMap.get(extensionPoint);
|
||||
// if(list == null){
|
||||
// list = new ArrayList(cfgRefs.length);
|
||||
// fDesMap.put(extensionPoint, list);
|
||||
|
@ -246,14 +245,15 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
|
||||
for(int i = cfgRefs.length - 1; i >= 0; i--){
|
||||
ICConfigExtensionReference ref = cfgRefs[i];
|
||||
int k = list != null ? list.size() - 1 : -1;
|
||||
|
||||
for(; k >= 0; k--){
|
||||
CConfigBaseDescriptorExtensionReference r = (CConfigBaseDescriptorExtensionReference)list.get(k);
|
||||
if(r.fCfgExtRef == ref){
|
||||
extRefs[num--] = r;
|
||||
list.remove(k);
|
||||
break;
|
||||
int k= -1;
|
||||
if (list != null) {
|
||||
for(k= list.size()-1; k >= 0; k--){
|
||||
CConfigBaseDescriptorExtensionReference r = (CConfigBaseDescriptorExtensionReference)list.get(k);
|
||||
if(r.fCfgExtRef == ref){
|
||||
extRefs[num--] = r;
|
||||
list.remove(k);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(k < 0){
|
||||
|
@ -262,7 +262,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
}
|
||||
|
||||
if(list == null){
|
||||
list = new ArrayList(cfgRefs.length);
|
||||
list = new ArrayList<ICExtensionReference>(cfgRefs.length);
|
||||
fDesMap.put(extensionPoint, list);
|
||||
} else {
|
||||
list.clear();
|
||||
|
@ -300,7 +300,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
public Element getProjectData(String id) throws CoreException {
|
||||
// avoid deadlock by using different lock here.
|
||||
synchronized(fStorageDataElMap /*CProjectDescriptionManager.getInstance()*/){
|
||||
Element el = (Element)fStorageDataElMap.get(id);
|
||||
Element el = fStorageDataElMap.get(id);
|
||||
if(el == null || el.getParentNode() == null){
|
||||
InternalXmlStorageElement storageEl = (InternalXmlStorageElement)fCfgDes.getStorage(id, false);
|
||||
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
|
||||
ICProjectDescription des = fCfgDes.getProjectDescription();
|
||||
ICConfigurationDescription cfgs[] = des.getConfigurations();
|
||||
for(int i = 0; i < cfgs.length; i++){
|
||||
ICConfigurationDescription cfg = cfgs[i];
|
||||
for (ICConfigurationDescription cfg : cfgs) {
|
||||
if(cfg != fCfgDes){
|
||||
try {
|
||||
ICConfigExtensionReference rs[] = cfg.get(ref.getExtensionPoint());
|
||||
for(int k = 0; k < rs.length; k++){
|
||||
if(ref.getID().equals(rs[i].getID())){
|
||||
cfg.remove(rs[i]);
|
||||
for (ICConfigExtensionReference element : rs) {
|
||||
if(ref.getID().equals(element.getID())){
|
||||
cfg.remove(element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -359,8 +358,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
//write is done for all configurations to avoid "data loss" on configuration change
|
||||
ICProjectDescription des = fCfgDes.getProjectDescription();
|
||||
ICConfigurationDescription cfgs[] = des.getConfigurations();
|
||||
for(int i = 0; i < cfgs.length; i++){
|
||||
ICConfigurationDescription cfg = cfgs[i];
|
||||
for (ICConfigurationDescription cfg : cfgs) {
|
||||
if(cfg != fCfgDes){
|
||||
try {
|
||||
cfg.remove(extensionPoint);
|
||||
|
@ -383,8 +381,10 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
|||
setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
|
||||
}
|
||||
|
||||
public Map getStorageDataElMap(){
|
||||
return (HashMap)fStorageDataElMap.clone();
|
||||
public Map<String, Element> getStorageDataElMap(){
|
||||
@SuppressWarnings("unchecked")
|
||||
final HashMap<String, Element> clone = (HashMap<String, Element>)fStorageDataElMap.clone();
|
||||
return clone;
|
||||
}
|
||||
|
||||
public ICConfigurationDescription getConfigurationDescription() {
|
||||
|
|
|
@ -170,9 +170,12 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
|||
}
|
||||
}
|
||||
// Parse
|
||||
IASTTranslationUnit ast= parser.parse();
|
||||
ast.setIsHeaderUnit(!isSource[0]);
|
||||
return ast;
|
||||
if (parser != null) {
|
||||
IASTTranslationUnit ast= parser.parse();
|
||||
ast.setIsHeaderUnit(!isSource[0]);
|
||||
return ast;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset,
|
||||
|
|
|
@ -35,34 +35,30 @@ public class SavedCodeReaderFactory implements ICodeReaderFactory {
|
|||
|
||||
private SavedCodeReaderFactory()
|
||||
{
|
||||
int size=0;
|
||||
Preferences pluginPreferences = CCorePlugin.getDefault().getPluginPreferences();
|
||||
if (CCorePlugin.getDefault() == null || pluginPreferences == null)
|
||||
size = CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB;
|
||||
else
|
||||
size = pluginPreferences.getInt(CodeReaderCache.CODE_READER_BUFFER);
|
||||
|
||||
if (size > 0)
|
||||
cache = new CodeReaderCache(size);
|
||||
else if( size == 0 )
|
||||
{
|
||||
//necessary for cache to work headless
|
||||
String [] properties = pluginPreferences.propertyNames();
|
||||
boolean found = false;
|
||||
for( int j = 0; j < properties.length; ++j )
|
||||
if( properties[j].equals( CodeReaderCache.CODE_READER_BUFFER ) )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
int size= CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB;
|
||||
final CCorePlugin corePlugin = CCorePlugin.getDefault();
|
||||
if (corePlugin != null) {
|
||||
Preferences pluginPreferences = corePlugin.getPluginPreferences();
|
||||
if (pluginPreferences != null) {
|
||||
size = pluginPreferences.getInt(CodeReaderCache.CODE_READER_BUFFER);
|
||||
if (size == 0) {
|
||||
String [] properties = pluginPreferences.propertyNames();
|
||||
boolean found = false;
|
||||
for (int j = 0; j < properties.length; ++j) {
|
||||
if (properties[j].equals( CodeReaderCache.CODE_READER_BUFFER)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
size= CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB;
|
||||
}
|
||||
} 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(CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
|
||||
cache = new CodeReaderCache(size);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#getUniqueIdentifier()
|
||||
|
|
|
@ -53,13 +53,11 @@ public class DefaultEnvironmentContextInfo implements IEnvironmentContextInfo{
|
|||
*/
|
||||
public IEnvironmentContextInfo getNext(){
|
||||
DefaultEnvironmentContextInfo next = null;
|
||||
if(fContextObject == null)
|
||||
next = null;
|
||||
else if(fContextObject instanceof ICConfigurationDescription)
|
||||
if(fContextObject instanceof ICConfigurationDescription) {
|
||||
next = new DefaultEnvironmentContextInfo(null);
|
||||
|
||||
if(next != null && next.getSuppliers() == null)
|
||||
next = null;
|
||||
if (next.getSuppliers() == null)
|
||||
next = null;
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
|
|
|
@ -618,10 +618,13 @@ public final class CharOperation {
|
|||
if (nameLength == 0)
|
||||
return concatWith(array, separator);
|
||||
|
||||
int length = array == null ? 0 : array.length;
|
||||
if (array == null)
|
||||
return name;
|
||||
|
||||
final int length= array.length;
|
||||
if (length == 0)
|
||||
return name;
|
||||
|
||||
|
||||
int size = nameLength;
|
||||
int index = length;
|
||||
while (--index >= 0)
|
||||
|
@ -682,7 +685,10 @@ public final class CharOperation {
|
|||
if (nameLength == 0)
|
||||
return concatWith(array, separator);
|
||||
|
||||
int length = array == null ? 0 : array.length;
|
||||
if (array == null)
|
||||
return name;
|
||||
|
||||
final int length= array.length;
|
||||
if (length == 0)
|
||||
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
|
||||
*/
|
||||
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)
|
||||
return CharOperation.NO_CHAR;
|
||||
|
||||
|
@ -2217,7 +2226,10 @@ public final class CharOperation {
|
|||
* whitespaces equals to ' '
|
||||
*/
|
||||
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)
|
||||
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
|
||||
*/
|
||||
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)
|
||||
return NO_CHAR_CHAR;
|
||||
|
||||
|
@ -2344,7 +2359,10 @@ public final class CharOperation {
|
|||
char[] array,
|
||||
int start,
|
||||
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)
|
||||
return NO_CHAR_CHAR;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue