Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2007-02-01 20:04:38 +0000
committerDoug Schaefer2007-02-01 20:04:38 +0000
commite74ea0d9609bc61e916844fe9a958dad518b4e45 (patch)
tree52a3648a599b13da77a00ea89270a0a745e9aeb6
parentcf063cd423ca965be187462242da50a80ced2d3f (diff)
downloadorg.eclipse.cdt-e74ea0d9609bc61e916844fe9a958dad518b4e45.tar.gz
org.eclipse.cdt-e74ea0d9609bc61e916844fe9a958dad518b4e45.tar.xz
org.eclipse.cdt-e74ea0d9609bc61e916844fe9a958dad518b4e45.zip
Bug 169777 - The new class wizard did not aquire the read lock on the PDOM. it now does.
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java78
1 files changed, 43 insertions, 35 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
index 5325bd6454..9646afcbb6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
@@ -378,47 +378,53 @@ public class NewClassWizardUtil {
IPDOMManager pdomManager = CCorePlugin.getPDOMManager();
try {
- PDOM pdom = (PDOM)pdomManager.getPDOM(project);
- IBinding[] bindings = pdom.findBindings(Pattern.compile(typeName.getName()), new NullProgressMonitor());
boolean sameTypeNameExists = false;
boolean sameNameDifferentTypeExists = false;
-
- for (int i = 0; i < bindings.length; ++i)
- {
- PDOMBinding binding = (PDOMBinding)bindings[i];
- PDOMBinding pdomBinding = pdom.getLinkage(GPPLanguage.getDefault()).adaptBinding(binding);
-
- //get the fully qualified name of this binding
- String bindingFullName = getBindingQualifiedName(pdomBinding);
+ PDOM pdom = (PDOM)pdomManager.getPDOM(project);
+ pdom.acquireReadLock();
+ try {
+ IBinding[] bindings = pdom.findBindings(Pattern.compile(typeName.getName()), new NullProgressMonitor());
- int currentNodeType = pdomBinding.getNodeType();
- // full binding
- if (currentNodeType == pdomNodeType)
- {
- if (bindingFullName.equals(fullyQualifiedTypeName))
- {
- return SEARCH_MATCH_FOUND_EXACT;
- } else {
- // same type , same name , but different name space
- // see if there is an exact match;
- sameTypeNameExists = true;
+ for (int i = 0; i < bindings.length; ++i)
+ {
+ PDOMBinding binding = (PDOMBinding)bindings[i];
+ PDOMBinding pdomBinding = pdom.getLinkage(GPPLanguage.getDefault()).adaptBinding(binding);
+
+ //get the fully qualified name of this binding
+ String bindingFullName = getBindingQualifiedName(pdomBinding);
+
+ int currentNodeType = pdomBinding.getNodeType();
+ // full binding
+ if (currentNodeType == pdomNodeType)
+ {
+ if (bindingFullName.equals(fullyQualifiedTypeName))
+ {
+ return SEARCH_MATCH_FOUND_EXACT;
+ } else {
+ // same type , same name , but different name space
+ // see if there is an exact match;
+ sameTypeNameExists = true;
+ }
+ }
+ else if(currentNodeType == PDOMCPPLinkage.CPPCLASSTYPE ||
+ currentNodeType == PDOMCPPLinkage.CPPENUMERATION ||
+ currentNodeType == PDOMCPPLinkage.CPPNAMESPACE ||
+ currentNodeType == PDOMCPPLinkage.CPPTYPEDEF ||
+ currentNodeType == PDOMCPPLinkage.CPPBASICTYPE)
+ {
+ if (bindingFullName.equals(fullyQualifiedTypeName))
+ {
+ return SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE;
+ } else {
+ // different type , same name , but different name space
+ sameNameDifferentTypeExists = true;
+ }
}
}
- else if(currentNodeType == PDOMCPPLinkage.CPPCLASSTYPE ||
- currentNodeType == PDOMCPPLinkage.CPPENUMERATION ||
- currentNodeType == PDOMCPPLinkage.CPPNAMESPACE ||
- currentNodeType == PDOMCPPLinkage.CPPTYPEDEF ||
- currentNodeType == PDOMCPPLinkage.CPPBASICTYPE)
- {
- if (bindingFullName.equals(fullyQualifiedTypeName))
- {
- return SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE;
- } else {
- // different type , same name , but different name space
- sameNameDifferentTypeExists = true;
- }
- }
+ } finally {
+ pdom.releaseReadLock();
}
+
if(sameTypeNameExists){
return SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE;
}
@@ -426,6 +432,8 @@ public class NewClassWizardUtil {
if(sameNameDifferentTypeExists){
return SEARCH_MATCH_FOUND_ANOTHER_TYPE;
}
+ } catch (InterruptedException e) {
+ return SEARCH_MATCH_ERROR;
} catch (CoreException e) {
return SEARCH_MATCH_ERROR;
}

Back to the top