Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2014-11-04 23:00:31 +0000
committerSergey Prigogin2014-11-04 23:00:31 +0000
commit2c8b0701cc8bd6903bfca4ee4b60d0ea55cc20a9 (patch)
tree61ba73dc4001dca766655b91ed4b1172f71d8016
parent8997a49ef1a91af088dd2fff0ba58ea83b549fff (diff)
downloadorg.eclipse.cdt-2c8b0701cc8bd6903bfca4ee4b60d0ea55cc20a9.tar.gz
org.eclipse.cdt-2c8b0701cc8bd6903bfca4ee4b60d0ea55cc20a9.tar.xz
org.eclipse.cdt-2c8b0701cc8bd6903bfca4ee4b60d0ea55cc20a9.zip
Bug 450009 - NPE in CPPSemantics.getContainingNamespaceScope called from
IndexUI.findSpecializations
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java8
8 files changed, 28 insertions, 20 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index 5b10815e7f0..19d90ff64d9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -817,7 +817,7 @@ public class CPPSemantics {
if (binding == null)
return null;
IScope scope = binding.getScope();
- if (scope instanceof IIndexScope) {
+ if (scope instanceof IIndexScope && tu != null) {
scope= tu.mapToASTScope((IIndexScope) scope);
}
while (scope != null && !(scope instanceof ICPPNamespaceScope)) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java
index ef3b20b7278..843e5b49145 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java
@@ -20,6 +20,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
@@ -109,7 +110,8 @@ public class CHQueries {
private static void findCalledBy1(IIndex index, IBinding callee, boolean includeOrdinaryCalls,
ICProject project, CalledByResult result) throws CoreException {
findCalledBy2(index, callee, includeOrdinaryCalls, project, result);
- List<? extends IBinding> specializations = IndexUI.findSpecializations(index, callee);
+ IASTNode point= null; // Instantiation of dependent expressions may not work.
+ List<? extends IBinding> specializations = IndexUI.findSpecializations(index, callee, point);
for (IBinding spec : specializations) {
findCalledBy2(index, spec, includeOrdinaryCalls, project, result);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java
index c3881339bc7..28959744ad9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * Copyright (c) 2006, 2014 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
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.model.ICElement;
@@ -52,7 +53,8 @@ public class IndexViewSearchQuery extends CSearchQuery {
public IStatus runWithIndex(IIndex index, IProgressMonitor monitor) throws OperationCanceledException {
try {
if (CCoreInternals.getPDOMManager().getPDOM(fProject).getLastWriteAccess() == fLastWrite) {
- createMatches(index, fBinding);
+ IASTNode point= null; // Instantiation of dependent expressions may not work.
+ createMatches(index, fBinding, point);
}
return Status.OK_STATUS;
} catch (CoreException e) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java
index 8130288e2bd..1eeb6917d67 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchElementQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * Copyright (c) 2006, 2014 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
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ICElement;
@@ -46,7 +47,8 @@ public class CSearchElementQuery extends CSearchQuery {
IBinding binding= IndexUI.elementToBinding(index, (ICElement) element);
if (binding != null) {
label= labelForBinding(index, binding, label);
- createMatches(index, binding);
+ IASTNode point= null; // Instantiation of dependent expressions may not work.
+ createMatches(index, binding, point);
}
}
return Status.OK_STATUS;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java
index 6294a000a3c..6ae17d19ab7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPatternQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 QNX Software Systems and others.
+ * Copyright (c) 2006, 2014 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
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
@@ -184,7 +185,8 @@ public class CSearchPatternQuery extends CSearchQuery {
matchedBindings.add(indexBinding);
}
}
- createMatches(index, matchedBindings.toArray(new IIndexBinding[matchedBindings.size()]));
+ IASTNode point= null; // Instantiation of dependent expressions may not work.
+ createMatches(index, matchedBindings.toArray(new IIndexBinding[matchedBindings.size()]), point);
} catch (CoreException e) {
return e.getStatus();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
index 2c3dfde4de2..a29539c667e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
@@ -340,11 +340,11 @@ public abstract class CSearchQuery implements ISearchQuery {
}
}
- protected void createMatches(IIndex index, IBinding binding) throws CoreException {
- createMatches(index, new IBinding[] { binding });
+ protected void createMatches(IIndex index, IBinding binding, IASTNode point) throws CoreException {
+ createMatches(index, new IBinding[] { binding }, point);
}
- protected void createMatches(IIndex index, IBinding[] bindings) throws CoreException {
+ protected void createMatches(IIndex index, IBinding[] bindings, IASTNode point) throws CoreException {
if (bindings == null)
return;
List<IIndexName> names= new ArrayList<>();
@@ -360,7 +360,7 @@ public abstract class CSearchQuery implements ISearchQuery {
if ((flags & FIND_REFERENCES) != 0) {
for (IBinding binding : bindings) {
if (binding != null) {
- List<? extends IBinding> specializations = IndexUI.findSpecializations(index, binding);
+ List<? extends IBinding> specializations = IndexUI.findSpecializations(index, binding, point);
for (IBinding spec : specializations) {
if (spec != null && handled.add(spec)) {
createMatches1(index, spec, names);
@@ -369,7 +369,6 @@ public abstract class CSearchQuery implements ISearchQuery {
if (binding instanceof ICPPMethod) {
ICPPMethod m= (ICPPMethod) binding;
- IASTNode point = null; // Instantiation of dependent expressions may not work.
ICPPMethod[] msInBases = ClassTypeHelper.findOverridden(m, point);
if (msInBases.length > 0) {
if (polymorphicNames == null) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java
index 442c44aef67..0ac7b25fec8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchTextSelectionQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * Copyright (c) 2006, 2014 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
@@ -43,7 +43,8 @@ public class CSearchTextSelectionQuery extends CSearchQuery {
private ITextSelection selection;
private String label;
- public CSearchTextSelectionQuery(ICElement[] scope, ITranslationUnit tu, ITextSelection selection, int flags) {
+ public CSearchTextSelectionQuery(ICElement[] scope, ITranslationUnit tu, ITextSelection selection,
+ int flags) {
super(scope, flags | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
this.tu = tu;
this.selection = selection;
@@ -76,7 +77,7 @@ public class CSearchTextSelectionQuery extends CSearchQuery {
binding= CPPTemplates.findDeclarationForSpecialization(binding);
if (binding != null) {
label= labelForBinding(index, binding, label);
- createMatches(index, binding);
+ createMatches(index, binding, searchName);
return Status.OK_STATUS;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
index daa17b3465f..22793647942 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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
@@ -497,7 +497,8 @@ public class IndexUI {
/**
* Searches for all specializations that depend on the definition of the given binding.
*/
- public static List<? extends IBinding> findSpecializations(IIndex index, IBinding binding) throws CoreException {
+ public static List<? extends IBinding> findSpecializations(IIndex index, IBinding binding, IASTNode point)
+ throws CoreException {
List<IBinding> result= null;
// Check for instances of the given binding.
@@ -515,8 +516,7 @@ public class IndexUI {
// Check for specializations of the owner.
IBinding owner = binding.getOwner();
if (owner != null) {
- IASTNode point= null; // Instantiation of dependent expressions may not work.
- List<? extends IBinding> specializations = findSpecializations(index, owner);
+ List<? extends IBinding> specializations = findSpecializations(index, owner, point);
for (IBinding specOwner : specializations) {
if (specOwner instanceof ICPPClassSpecialization) {
// Add the specialized member.

Back to the top