mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Support search for references off #undef statement (fixes a NPE).
This commit is contained in:
parent
a27ec4031f
commit
066875bdab
4 changed files with 28 additions and 15 deletions
|
@ -34,6 +34,7 @@ import org.eclipse.cdt.core.dom.IPDOMNode;
|
|||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
|
@ -364,6 +365,11 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
if (linkage != null) {
|
||||
return findBindingInLinkage(linkage, binding);
|
||||
}
|
||||
} else if (name.getPropertyInParent() == IASTPreprocessorStatement.MACRO_NAME) {
|
||||
PDOMLinkage linkage= adaptLinkage(name.getLinkage());
|
||||
if (linkage != null) {
|
||||
return linkage.findMacroContainer(name.toCharArray());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
|
@ -159,6 +158,11 @@ public class PDOMASTAdapter {
|
|||
public boolean isPartOfTranslationUnitFile() {
|
||||
return fLocation.getFileName().equals(fDelegate.getTranslationUnit().getFilePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fDelegate.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static class AnonymousEnumeration implements IEnumeration {
|
||||
|
@ -319,7 +323,7 @@ public class PDOMASTAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
private static class AnonymousCPPEnumeration extends AnonymousCPPBinding implements IEnumeration, ICPPBinding {
|
||||
private static class AnonymousCPPEnumeration extends AnonymousCPPBinding implements IEnumeration {
|
||||
public AnonymousCPPEnumeration(char[] name, IEnumeration delegate) {
|
||||
super(name, (ICPPBinding) delegate);
|
||||
}
|
||||
|
|
|
@ -307,7 +307,8 @@ public class PDOMFile implements IIndexFragmentFile {
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
if (binding instanceof IMacroBinding
|
||||
|| (binding == null && name.getPropertyInParent() == IASTPreprocessorStatement.MACRO_NAME)) {
|
||||
return createPDOMMacroReferenceName(linkage, name);
|
||||
}
|
||||
PDOMBinding pdomBinding = linkage.addBinding(name);
|
||||
|
|
|
@ -60,19 +60,21 @@ public class PDOMSearchTextSelectionQuery extends PDOMSearchQuery {
|
|||
searchText= searchName.toString();
|
||||
IBinding binding= searchName.resolveBinding();
|
||||
if (binding instanceof IProblemBinding == false) {
|
||||
IScope scope= null;
|
||||
try {
|
||||
scope = binding.getScope();
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
if (scope instanceof ICPPBlockScope || scope instanceof ICFunctionScope) {
|
||||
createLocalMatches(ast, binding);
|
||||
}
|
||||
else {
|
||||
binding = index.findBinding(searchName);
|
||||
if (binding != null) {
|
||||
createMatches(index, binding);
|
||||
if (binding != null) {
|
||||
IScope scope= null;
|
||||
try {
|
||||
scope = binding.getScope();
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
if (scope instanceof ICPPBlockScope || scope instanceof ICFunctionScope) {
|
||||
createLocalMatches(ast, binding);
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}
|
||||
binding = index.findBinding(searchName);
|
||||
if (binding != null) {
|
||||
createMatches(index, binding);
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue