diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java index e886d525fdb..0eb9bb5906a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java @@ -797,7 +797,7 @@ public class ASTTypeUtil { CCorePlugin.log(e); } } else { - IASTNode node = ASTInternal.getDeclaredInSourceFileOnly(binding); + IASTNode node = ASTInternal.getDefinitionOfBinding(binding); if (node != null) { IPath filePath = new Path(node.getTranslationUnit().getFilePath()); URI uri = UNCPathConverter.getInstance().toURI(filePath); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java index 3ad61ea68f2..42460ee736a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2015 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 @@ -37,10 +37,38 @@ import org.eclipse.core.runtime.CoreException; * Access to methods on scopes and bindings internal to the parser. */ public class ASTInternal { + /** + * Returns the definition for an AST binding. Calling this method for an index binding + * is considered an error. + * + * @param binding the binding to get the definition for + * @return the definition node for the binding or {@code null} + */ + public static IASTNode getDefinitionOfBinding(IBinding binding) { + if (binding instanceof ICPPInternalBinding) { + return ((ICPPInternalBinding) binding).getDefinition(); + } + if (binding instanceof ICInternalBinding) { + return ((ICInternalBinding) binding).getDefinition(); + } + assert false; + return null; + } + + /** + * Returns the declarations for an AST binding. Calling this method for an index binding + * is considered an error. + * + * @param binding the binding to get the declarations for + * @return the declaration nodes for the binding, possibly none + */ public static IASTNode[] getDeclarationsOfBinding(IBinding binding) { if (binding instanceof ICPPInternalBinding) { return ((ICPPInternalBinding) binding).getDeclarations(); } + if (binding instanceof ICInternalBinding) { + return ((ICInternalBinding) binding).getDeclarations(); + } assert false; return IASTNode.EMPTY_NODE_ARRAY; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index e801cd7143d..c67f5b9bde0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2014 QNX Software Systems and others. + * Copyright (c) 2005, 2015 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 @@ -1224,7 +1224,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { if (file == null && !(binding instanceof IIndexBinding)) { IBinding owner= binding.getOwner(); if (owner instanceof ICPPNamespace && owner.getNameCharArray().length == 0) { - IASTNode node= ASTInternal.getDeclaredInSourceFileOnly(getPDOM(), binding, false, glob); + IASTNode node= ASTInternal.getDefinitionOfBinding(binding); if (node != null) { file= wpdom.getFileForASTNode(getLinkageID(), node); }