mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 450009 - NPE in CPPSemantics.getContainingNamespaceScope called from
IndexUI.findSpecializations
This commit is contained in:
parent
8997a49ef1
commit
2c8b0701cc
8 changed files with 28 additions and 20 deletions
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue