diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/AllTypesCache.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/AllTypesCache.java index d66340a51bd..d63bc6072f6 100644 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/AllTypesCache.java +++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/AllTypesCache.java @@ -51,7 +51,12 @@ public class AllTypesCache { try { index.acquireReadLock(); - + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return new ITypeInfo[0]; + } + + try { long start = System.currentTimeMillis(); IIndexBinding[] all = @@ -80,12 +85,9 @@ public class AllTypesCache { } return result; - } catch(InterruptedException ie) { - ie.printStackTrace(); } finally { index.releaseReadLock(); } - return new ITypeInfo[0]; } /** diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java index 832b54fc73e..fffee8044f0 100644 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java +++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java @@ -250,7 +250,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { } try { index.acquireReadLock(); - + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + return null; + } + try { IIndexBinding[] ibs = findBindings(); if(ibs.length>0) { IIndexName[] names; @@ -267,8 +271,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { } } catch(CoreException ce) { CCorePlugin.log(ce); - } catch (InterruptedException ie) { - CCorePlugin.log(ie); } finally { index.releaseReadLock(); } @@ -319,7 +321,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { private ITypeReference createMacroReference() { try { index.acquireReadLock(); - + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + return null; + } + try { IIndexMacro[] macros = index.findMacros(fqn[0].toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor()); if(macros.length>0) { for (IIndexMacro macro : macros) { @@ -331,9 +337,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { } } catch(CoreException ce) { CCorePlugin.log(ce); - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - } finally { + } finally { index.releaseReadLock(); } return reference; @@ -374,6 +378,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { List references= new ArrayList(); try { index.acquireReadLock(); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + return new ITypeReference[0]; + } + try { IIndexBinding[] ibs= findBindings(); HashMap iflMap= new HashMap(); for (IIndexBinding binding : ibs) { @@ -392,9 +401,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { } } } catch(CoreException ce) { - CCorePlugin.log(ce); - } catch (InterruptedException ie) { - CCorePlugin.log(ie); + CCorePlugin.log(ce); } finally { index.releaseReadLock(); } @@ -406,7 +413,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { List references= new ArrayList(); try { index.acquireReadLock(); - + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return new ITypeReference[0]; + } + try { char[] cfn= fqn[0].toCharArray(); IIndexMacro[] ibs = index.findMacros(cfn, IndexFilter.ALL_DECLARED, new NullProgressMonitor()); // in case a file is represented multiple times in the index then we take references from @@ -424,8 +435,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { } } catch(CoreException ce) { CCorePlugin.log(ce); - } catch (InterruptedException ie) { - CCorePlugin.log(ie); } finally { index.releaseReadLock(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java index 734dbb1f37b..8733a42db24 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Systems and others. + * Copyright (c) 2007, 2009 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 @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.provider; -import com.ibm.icu.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -20,6 +19,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import com.ibm.icu.text.MessageFormat; + import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.provider.IIndexProvider; import org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider; @@ -202,8 +203,8 @@ public final class IndexProviderManager implements IElementChangedListener { */ private void processCandidate(Map id2fragment, IIndexFragment candidate) throws InterruptedException, CoreException { String cid= null, csver= null, cformatID= null; + candidate.acquireReadLock(); try { - candidate.acquireReadLock(); cid= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID); csver= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION); cformatID= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID); @@ -218,8 +219,8 @@ public final class IndexProviderManager implements IElementChangedListener { if(getCurrentlySupportedVersionRangeForFormat(cformatID).isIncluded(cver)) { if(existing != null) { String esver= null, eformatID= null; + existing.acquireReadLock(); try { - existing.acquireReadLock(); esver= existing.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION); eformatID= existing.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID); } finally { diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java index 8ab1d821991..ec4013846be 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java @@ -302,8 +302,8 @@ public class ElementSelectionDialog extends TypeSelectionDialog { }; try { IIndex index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects()); + index.acquireReadLock(); try { - index.acquireReadLock(); IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor); for(int i=0; i