Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2015-01-16 18:07:02 +0000
committerSergey Prigogin2015-01-16 18:18:48 +0000
commit568e8a995bd6406ec6879d9ed5727809613370d0 (patch)
tree61d50d03ab67e2428e1a58b86cb166ee574d79e8
parent773eb90b41c7cf2a69ce3b7133a6ff4b61b3750d (diff)
downloadorg.eclipse.cdt-568e8a995bd6406ec6879d9ed5727809613370d0.tar.gz
org.eclipse.cdt-568e8a995bd6406ec6879d9ed5727809613370d0.tar.xz
org.eclipse.cdt-568e8a995bd6406ec6879d9ed5727809613370d0.zip
Bug 457503 - Argument-dependent lookup fails for index types in global
namespace
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java19
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java18
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDirective.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalNamespaceScope.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java38
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMGlobalScope.java80
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCGlobalScope.java23
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java39
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPGlobalScope.java39
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDirective.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java6
19 files changed, 311 insertions, 71 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java
index 1268db2edf8..ce9670c5a50 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.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
@@ -1308,6 +1308,23 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
assertEquals("base", name.resolveBinding().getOwner().getName());
}
+ // class A {};
+
+ // void waldo(A p) {}
+ //
+ // namespace ns {
+ //
+ // void waldo() {}
+ //
+ // void test(A a) {
+ // waldo(a);
+ // }
+ //
+ // }
+ public void test_457503() throws Exception {
+ checkBindings();
+ }
+
// class A {
// class B;
// };
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
index fb80abe3724..fbd58de8e21 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2014 Symbian Software Systems and others.
+ * Copyright (c) 2007, 2015 Symbian 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
@@ -22,6 +22,7 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
@@ -236,7 +237,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
// namespace n { class C{}; }
// m::C c;
public void testUsingNamingDirective_177917_1b() {
- IBinding b0= getBindingFromASTName("C c", 1);
+ IBinding b0= getBindingFromFirstIdentifier("C c");
}
// int ff(int x) { return x; }
@@ -438,7 +439,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
assertVariable(b1, "c", ICPPClassType.class, "C");
ICPPClassType b1type = (ICPPClassType) ((ICPPVariable) b1).getType();
assertClassTypeBinding(b1type, "C", ICPPClassType.k_class, 0, 0, 0, 4, 0, 0, 0, 2, 0);
- assertTrue(b1type.getScope() == null);
+ assertEquals(EScopeKind.eGlobal, b1type.getScope().getKind());
assertTrue(b1type.getCompositeScope() instanceof ICPPClassScope);
assertClassTypeBinding(((ICPPClassScope) b1type.getCompositeScope()).getClassType(), "C", ICPPClassType.k_class, 0, 0, 0, 4, 0, 0, 0, 2, 0);
}
@@ -468,7 +469,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
assertVariable(b7, "e", IEnumeration.class, "E");
IEnumeration b5type = (IEnumeration) ((ICPPVariable) b7).getType();
assertEnumeration(b5type, "E", new String[] {"ER1","ER2","ER3"});
- assertTrue(b5type.getScope() == null);
+ assertEquals(EScopeKind.eGlobal, b5type.getScope().getKind());
}
{
IBinding b8 = getBindingFromASTName("var1 = 1;", 4);
@@ -505,7 +506,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
IBinding b25 = getBindingFromASTName("S {}; /*base*/", 1);
}
-
//// header content
//class TopC {}; struct TopS {}; union TopU {}; enum TopE {TopER1,TopER2};
//short topBasic; void *topPtr; TopC *topCPtr; TopU topFunc(){return *new TopU();}
@@ -566,19 +566,19 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
IBinding b0 = getBindingFromASTName("S _s0;", 1);
assertTrue(b0.getScope() instanceof ICPPNamespaceScope);
assertTrue(b0.getScope().getParent() instanceof ICPPNamespaceScope);
- assertTrue(b0.getScope().getParent().getParent() == null);
+ assertEquals(EScopeKind.eGlobal, b0.getScope().getParent().getParent().getKind());
assertQNEquals("n1::n2::S", b0);
IBinding b1 = getBindingFromASTName("S _s1;", 1);
assertTrue(b1.getScope() instanceof ICPPNamespaceScope);
assertTrue(b1.getScope().getParent() instanceof ICPPNamespaceScope);
- assertTrue(b1.getScope().getParent().getParent() == null);
+ assertEquals(EScopeKind.eGlobal, b1.getScope().getParent().getParent().getKind());
assertQNEquals("n1::n2::S", b1);
IBinding b2 = getBindingFromASTName("S _s2;", 1);
assertTrue(b2.getScope() instanceof ICPPClassScope);
assertTrue(b2.getScope().getParent() instanceof ICPPClassScope);
- assertTrue(b2.getScope().getParent().getParent() == null);
+ assertEquals(EScopeKind.eGlobal, b2.getScope().getParent().getParent().getKind());
assertQNEquals("c1::c2::S", b2);
IBinding b3 = getBindingFromASTName("S _s3;", 1);
@@ -601,7 +601,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
assertTrue(b10.getScope().getParent() instanceof ICPPClassScope);
assertTrue(b10.getScope().getParent().getParent() instanceof ICPPClassScope);
assertTrue(b10.getScope().getParent().getParent().getParent() instanceof ICPPNamespaceScope);
- assertTrue(b10.getScope().getParent().getParent().getParent().getParent() == null);
+ assertEquals(EScopeKind.eGlobal, b10.getScope().getParent().getParent().getParent().getParent().getKind());
assertQNEquals("n3::c3::s3::u3::S", b10);
IBinding b11 = getBindingFromASTName("S _s11;", 1);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
index aea80db1c0c..bcd6055182b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2014 Symbian Software Systems and others.
+ * Copyright (c) 2007, 2015 Symbian 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
@@ -19,6 +19,7 @@ import java.util.List;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
+import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
@@ -1185,7 +1186,8 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
IBinding foo3= getBindingFromASTName("foo(e)", 3);
IBinding foo4= getBindingFromASTName("foo(cx)", 3);
- assertEquals(foo1, foo2); assertEquals(foo2, foo3);
+ assertEquals(foo1, foo2);
+ assertEquals(foo2, foo3);
assertEquals(foo3, foo4);
}
@@ -1209,8 +1211,8 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPClassType sc1= assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
assertTrue(sc0.isSameType(sc1));
- assertNull(sc0.getScope());
- assertNull(b0.getScope());
+ assertEquals(EScopeKind.eGlobal, sc0.getScope().getKind());
+ assertEquals(EScopeKind.eGlobal, b0.getScope().getKind());
}
// template<typename T>
@@ -1256,7 +1258,8 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertFalse(b0 instanceof ICPPSpecialization);
- IIndexScope s0= (IIndexScope) b0.getScope(), s4= (IIndexScope) b4.getScope();
+ IIndexScope s0= (IIndexScope) b0.getScope();
+ IIndexScope s4= (IIndexScope) b4.getScope();
IScope s1= b1.getScope();
assertTrue(((IType)s0.getScopeBinding()).isSameType((IType)((IIndexScope)b2.getCompositeScope()).getScopeBinding()));
@@ -1315,7 +1318,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPClassScope s1= assertInstance(b1.getScope(), ICPPClassScope.class);
assertInstance(s1.getClassType(), ICPPTemplateDefinition.class);
- assertNull(s1.getClassType().getScope());
+ assertEquals(EScopeKind.eGlobal, s1.getClassType().getScope().getKind());
}
// typedef signed int SI;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java
index 2f14cdc2cd8..11860d8dbb3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 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,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
import org.eclipse.cdt.core.dom.ast.INodeFactory;
+import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFile;
@@ -421,7 +422,16 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
/**
* Can be called to create a type for a type-id.
*/
- abstract protected IType createType(IASTTypeId typeid);
+ protected abstract IType createType(IASTTypeId typeid);
+
+ /**
+ * Maps an index scope to the AST.
+ *
+ * @param scope a scope, possibly from index
+ * @return the corresponding scope in the AST, or the original scope if it doesn't have
+ * a counterpart in the AST.
+ */
+ public abstract IScope mapToASTScope(IScope scope);
protected <T extends ASTTranslationUnit> T copy(T copy, CopyStyle style) {
copy.setIndex(fIndex);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
index 2e2dbc77d88..08da101fa82 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2011 IBM Corporation and others.
+ * Copyright (c) 2002, 2015 IBM Corporation 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
@@ -9,6 +9,7 @@
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Yuan Zhang / Beth Tibbitts (IBM Research)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@@ -21,11 +22,13 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
+import org.eclipse.cdt.internal.core.index.IIndexScope;
/**
* C-specific implementation of a translation unit.
@@ -101,6 +104,20 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
accept(new CASTAmbiguityResolver());
}
+ @Override
+ public IScope mapToASTScope(IScope scope) {
+ if (scope instanceof IIndexScope) {
+ if (scope.getKind() == EScopeKind.eGlobal)
+ return getScope();
+ if (scope instanceof ICCompositeTypeScope) {
+ ICompositeType type = ((ICCompositeTypeScope) scope).getCompositeType();
+ type = mapToASTType(type);
+ return type.getCompositeScope();
+ }
+ }
+ return scope;
+ }
+
/**
* Maps structs from the index into this AST.
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
index 1aadc892ce2..05b442da82b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
@@ -161,13 +161,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
fScopeMapper.registerAdditionalDirectives(offset, fileContent.getUsingDirectives());
}
- /**
- * Maps an index scope to the AST.
- *
- * @param scope a scope, possibly from index
- * @return the corresponding scope in the AST, or the original scope if it doesn't have
- * a counterpart in the AST.
- */
+ @Override
public IScope mapToASTScope(IScope scope) {
if (scope instanceof IIndexScope) {
return fScopeMapper.mapToASTScope((IIndexScope) scope);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java
index 80b840251c8..eacf065fade 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -175,12 +176,19 @@ public class CPPScopeMapper {
public ICPPInternalNamespaceScope[] getInlineNamespaces() {
// Obtain the inline namespaces from the index and map them to the ast
ICPPNamespaceScope[] pre = fScope.getInlineNamespaces();
+ if (pre.length == 0)
+ return ICPPInternalNamespaceScope.EMPTY_NAMESPACE_SCOPE_ARRAY;
ICPPInternalNamespaceScope[] result= new ICPPInternalNamespaceScope[pre.length];
for (int i = 0; i < result.length; i++) {
result[i]= (ICPPInternalNamespaceScope) mapToASTScope((IIndexScope) pre[i]);
}
return result;
}
+
+ @Override
+ public String toString() {
+ return fScope.toString();
+ }
}
/**
@@ -213,6 +221,11 @@ public class CPPScopeMapper {
public int getPointOfDeclaration() {
return fOffset;
}
+
+ @Override
+ public String toString() {
+ return fDirective.toString();
+ }
}
/**
@@ -302,7 +315,7 @@ public class CPPScopeMapper {
private String getReverseQualifiedName(IScope scope) throws DOMException {
final CPPNamespaceScope tuscope = fTu.getScope();
- if (scope == tuscope || scope == null) {
+ if (scope == tuscope || scope == null || scope.getKind() == EScopeKind.eGlobal) {
return ""; //$NON-NLS-1$
}
StringBuilder buf= new StringBuilder();
@@ -311,7 +324,7 @@ public class CPPScopeMapper {
buf.append(scopeName.getSimpleID());
}
scope= scope.getParent();
- while (scope != null && scope != tuscope) {
+ while (scope.getKind() != EScopeKind.eGlobal && scope != tuscope) {
buf.append(':');
scopeName= scope.getScopeName();
if (scopeName != null) {
@@ -326,7 +339,7 @@ public class CPPScopeMapper {
* Maps namespace scopes from the index back into the AST.
*/
public IScope mapToASTScope(IIndexScope scope) {
- if (scope == null) {
+ if (scope.getKind() == EScopeKind.eGlobal) {
return fTu.getScope();
}
if (scope instanceof ICPPNamespaceScope) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDirective.java
index eb289f6602c..99ba210be03 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDirective.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDirective.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -64,6 +65,6 @@ public class CPPUsingDirective implements ICPPUsingDirective {
@Override
public String toString() {
- return fNamespaceName.toString();
+ return "using namespace " + fNamespaceName.toString(); //$NON-NLS-1$
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalNamespaceScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalNamespaceScope.java
index 1d2208a312a..29ca46f4e45 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalNamespaceScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalNamespaceScope.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2010, 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -16,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
* For namespace scopes from the AST or mapped index namespace scopes.
*/
public interface ICPPInternalNamespaceScope extends ICPPNamespaceScope {
+ public ICPPInternalNamespaceScope[] EMPTY_NAMESPACE_SCOPE_ARRAY = {};
/**
* Returns the enclosing namespace set (7.3.1-9)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
index 3941171208a..af32edb887f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2014 IBM Corporation and others.
+ * Copyright (c) 2004, 2015 IBM Corporation 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
@@ -68,6 +68,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArraySet;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
+import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
@@ -541,8 +542,8 @@ public class SemanticUtil {
public static IScope mapToAST(IScope scope, IASTNode point) {
if (point != null) {
IASTTranslationUnit ast = point.getTranslationUnit();
- if (ast instanceof CPPASTTranslationUnit) {
- return ((CPPASTTranslationUnit) ast).mapToASTScope(scope);
+ if (ast instanceof ASTTranslationUnit) {
+ return ((ASTTranslationUnit) ast).mapToASTScope(scope);
}
}
return scope;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java
index b013f291fe3..a2520259234 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Symbian Software Systems and others.
+ * Copyright (c) 2007, 2015 Symbian 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
@@ -7,9 +7,11 @@
*
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.c;
+import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
@@ -50,6 +52,9 @@ public class CCompositesFactory extends AbstractCompositeFactory {
public IIndexScope getCompositeScope(IIndexScope rscope) {
if (rscope == null)
return null;
+ if (rscope.getKind() == EScopeKind.eGlobal)
+ return rscope;
+
if (rscope instanceof ICCompositeTypeScope) {
ICCompositeTypeScope cscope = (ICCompositeTypeScope) rscope;
IIndexFragmentBinding rbinding = (IIndexFragmentBinding) cscope.getCompositeType();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
index 09e8ed830f4..daa8743cc61 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2014 Symbian Software Systems and others.
+ * Copyright (c) 2007, 2015 Symbian 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
@@ -13,6 +13,7 @@
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
@@ -118,7 +119,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
try {
if (rscope == null) {
return null;
- }
+ }
+ if (rscope.getKind() == EScopeKind.eGlobal) {
+ return rscope;
+ }
if (rscope instanceof ICPPClassScope) {
if (rscope instanceof ICPPClassSpecializationScope) {
return new CompositeCPPClassSpecializationScope(this, (IIndexFragmentBinding) rscope.getScopeBinding());
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java
index c4c8ca72c6d..110cc584d7a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 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
@@ -9,6 +9,7 @@
* Doug Schaefer (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
@@ -17,19 +18,15 @@ import java.lang.reflect.Modifier;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
-import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IScope.ScopeLookupData;
import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
import org.eclipse.cdt.core.dom.ast.tag.ITagReader;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBindingComparator;
@@ -38,6 +35,7 @@ import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.IString;
import org.eclipse.cdt.internal.core.pdom.db.PDOMExternalReferencesList;
+import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCGlobalScope;
import org.eclipse.cdt.internal.core.pdom.tag.PDOMTaggable;
import org.eclipse.core.runtime.CoreException;
@@ -55,6 +53,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 20;
+
private byte hasDeclaration= -1;
protected PDOMBinding(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException {
@@ -255,39 +254,24 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
if (parent instanceof IIndexScope) {
return (IIndexScope) parent;
}
- } catch (CoreException ce) {
- CCorePlugin.log(ce);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
}
- return null;
+ return PDOMCGlobalScope.INSTANCE;
}
@Override
- public final IIndexScope getScope() {
+ public IIndexScope getScope() {
// The parent node in the binding hierarchy is the scope.
try {
IBinding parent= getParentBinding();
- while (parent != null) {
- if (parent instanceof ICPPClassType) {
- return (IIndexScope) ((ICPPClassType) parent).getCompositeScope();
- } else if (parent instanceof ICPPUnknownBinding) {
- return (IIndexScope) ((ICPPUnknownBinding) parent).asScope();
- } else if (parent instanceof ICPPEnumeration) {
- final ICPPEnumeration enumeration = (ICPPEnumeration) parent;
- if (enumeration.isScoped()) {
- return (IIndexScope) enumeration.asScope();
- }
- parent= ((PDOMNamedNode) parent).getParentBinding();
- } else if (parent instanceof IIndexScope) {
- return (IIndexScope) parent;
- } else {
- return null;
- }
+ if (parent instanceof IIndexScope) {
+ return (IIndexScope) parent;
}
- } catch (DOMException e) {
} catch (CoreException e) {
CCorePlugin.log(e);
}
- return null;
+ return PDOMCGlobalScope.INSTANCE;
}
@Override
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMGlobalScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMGlobalScope.java
new file mode 100644
index 00000000000..0e881952ed4
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMGlobalScope.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Google, 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.pdom.dom;
+
+import org.eclipse.cdt.core.dom.ast.EScopeKind;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexFileSet;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.internal.core.index.IIndexScope;
+
+/**
+ * Base class for C and C++ global index scopes.
+ */
+public abstract class PDOMGlobalScope implements IIndexScope {
+ @Override
+ public EScopeKind getKind() {
+ return EScopeKind.eGlobal;
+ }
+
+ @Override
+ public IBinding[] find(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public IBinding getBinding(IASTName name, boolean resolve) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup,
+ IIndexFileSet acceptLocalBindings) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public IBinding[] getBindings(ScopeLookupData lookup) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public IIndexBinding getScopeBinding() {
+ return null;
+ }
+
+ @Override
+ public IIndexScope getParent() {
+ return null;
+ }
+
+ @Override
+ public IIndexName getScopeName() {
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return "<global scope>"; //$NON-NLS-1$
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCGlobalScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCGlobalScope.java
new file mode 100644
index 00000000000..3095041365f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCGlobalScope.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Google, 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.pdom.dom.c;
+
+import org.eclipse.cdt.core.dom.ast.c.ICScope;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMGlobalScope;
+
+/**
+ * Represents the global C index scope.
+ */
+public class PDOMCGlobalScope extends PDOMGlobalScope implements ICScope {
+ public static final PDOMCGlobalScope INSTANCE = new PDOMCGlobalScope();
+
+ private PDOMCGlobalScope() {}
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java
index 8aa08252ac9..d5bfbf8f3b2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Symbian Corporation and others.
+ * Copyright (c) 2006, 2015 Symbian Corporation 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
@@ -8,14 +8,22 @@
* Contributors:
* Symbian - Initial API and implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@@ -49,4 +57,33 @@ public abstract class PDOMCPPBinding extends PDOMBinding implements ICPPBinding
// Local stuff is not stored in the index.
return true;
}
+
+ @Override
+ public final IIndexScope getScope() {
+ // The parent node in the binding hierarchy is the scope.
+ try {
+ IBinding parent= getParentBinding();
+ while (parent != null) {
+ if (parent instanceof ICPPClassType) {
+ return (IIndexScope) ((ICPPClassType) parent).getCompositeScope();
+ } else if (parent instanceof ICPPUnknownBinding) {
+ return (IIndexScope) ((ICPPUnknownBinding) parent).asScope();
+ } else if (parent instanceof ICPPEnumeration) {
+ final ICPPEnumeration enumeration = (ICPPEnumeration) parent;
+ if (enumeration.isScoped()) {
+ return (IIndexScope) enumeration.asScope();
+ }
+ parent= ((PDOMNamedNode) parent).getParentBinding();
+ } else if (parent instanceof IIndexScope) {
+ return (IIndexScope) parent;
+ } else {
+ break;
+ }
+ }
+ } catch (DOMException e) {
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ return PDOMCPPGlobalScope.INSTANCE;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPGlobalScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPGlobalScope.java
new file mode 100644
index 00000000000..a22a763e774
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPGlobalScope.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Google, 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.pdom.dom.cpp;
+
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMGlobalScope;
+
+/**
+ * Represents the global C++ index scope.
+ */
+public class PDOMCPPGlobalScope extends PDOMGlobalScope implements ICPPNamespaceScope {
+ public static final PDOMCPPGlobalScope INSTANCE = new PDOMCPPGlobalScope();
+
+ private PDOMCPPGlobalScope() {}
+
+ @Override
+ public void addUsingDirective(ICPPUsingDirective usingDirective) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ICPPUsingDirective[] getUsingDirectives() {
+ return ICPPUsingDirective.EMPTY_ARRAY;
+ }
+
+ @Override
+ public ICPPNamespaceScope[] getInlineNamespaces() {
+ return ICPPNamespaceScope.EMPTY_NAMESPACE_SCOPE_ARRAY;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDirective.java
index 5889399939d..832be34bf28 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDirective.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDirective.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -86,7 +87,7 @@ public class PDOMCPPUsingDirective implements ICPPUsingDirective, IPDOMNode {
} catch (CoreException e) {
CCorePlugin.log(e);
}
- return null;
+ return PDOMCPPGlobalScope.INSTANCE;
}
@Override
@@ -116,4 +117,9 @@ public class PDOMCPPUsingDirective implements ICPPUsingDirective, IPDOMNode {
public void delete(PDOMLinkage linkage) throws CoreException {
fLinkage.getDB().free(fRecord);
}
+
+ @Override
+ public String toString() {
+ return "using namespace " + getNominatedScope(); //$NON-NLS-1$
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java
index 75f76282bcf..c304a918c14 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2005, 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
@@ -36,6 +36,7 @@ import org.eclipse.ui.services.IDisposable;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -360,6 +361,9 @@ public class ASTManager implements IDisposable {
return hasSameLocation(node1, node2, fileStatic);
}
+ if (s1.getKind() == EScopeKind.eGlobal && s2.getKind() == EScopeKind.eGlobal)
+ return TRUE;
+
String name1= getName(s1);
String name2= getName(s2);

Back to the top