mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Use CPPVisitor.getQualifiedName instead of IIndexBinding.getQualifiedName.
This commit is contained in:
parent
9efcf6f96c
commit
e5b9283973
5 changed files with 19 additions and 13 deletions
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
|||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -271,7 +272,7 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
for (IIndexName indexName : names) {
|
||||
if (indexName.isReference() && indexName.toString().equals("vm")) {
|
||||
assertEquals(couldbepolymorphic[j], indexName.couldBePolymorphicMethodCall());
|
||||
assertEquals(container[j], fIndex.findBinding(indexName).getQualifiedName()[0]);
|
||||
assertEquals(container[j], CPPVisitor.getQualifiedName(fIndex.findBinding(indexName))[0]);
|
||||
j++;
|
||||
}
|
||||
else {
|
||||
|
@ -279,8 +280,7 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
assertEquals(couldbepolymorphic.length, j);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.cdt.core.index.IIndex;
|
|||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||
import org.eclipse.cdt.core.index.IIndexName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScopeMapper.InlineNamespaceDirective;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -97,23 +98,23 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace
|
|||
@Override
|
||||
public IName getScopeName() {
|
||||
IASTNode node = getPhysicalNode();
|
||||
if( node instanceof ICPPASTNamespaceDefinition ){
|
||||
if (node instanceof ICPPASTNamespaceDefinition) {
|
||||
return ((ICPPASTNamespaceDefinition)node).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IScope findNamespaceScope(IIndexScope scope) {
|
||||
final String[] qname= scope.getScopeBinding().getQualifiedName();
|
||||
final String[] qname= CPPVisitor.getQualifiedName(scope.getScopeBinding());
|
||||
final IScope[] result= {null};
|
||||
final ASTVisitor visitor= new ASTVisitor () {
|
||||
final ASTVisitor visitor= new ASTVisitor() {
|
||||
private int depth= 0;
|
||||
{
|
||||
shouldVisitNamespaces= shouldVisitDeclarations= true;
|
||||
}
|
||||
@Override
|
||||
public int visit( IASTDeclaration declaration ){
|
||||
if( declaration instanceof ICPPASTLinkageSpecification )
|
||||
if (declaration instanceof ICPPASTLinkageSpecification)
|
||||
return PROCESS_CONTINUE;
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* Binding comparator suitable for C/C++ across index implementations. This will not be used
|
||||
* unless we ever have non-PDOM implementations of IIndexFragment, and in that case we may find
|
||||
|
@ -17,7 +19,7 @@ package org.eclipse.cdt.internal.core.index;
|
|||
*/
|
||||
public class DefaultFragmentBindingComparator implements IIndexFragmentBindingComparator {
|
||||
public int compare(IIndexFragmentBinding a, IIndexFragmentBinding b) {
|
||||
int cmp= compareQualifiedNames(a.getQualifiedName(), b.getQualifiedName());
|
||||
int cmp= compareQualifiedNames(CPPVisitor.getQualifiedName(a), CPPVisitor.getQualifiedName(b));
|
||||
if (cmp == 0) {
|
||||
int ac= a.getBindingConstant(), bc= b.getBindingConstant();
|
||||
cmp= ac < bc ? -1 : (ac > bc ? 1 : 0);
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.index.IndexFilter;
|
|||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
|
||||
|
@ -246,7 +247,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
|
||||
@Override
|
||||
protected String toStringBase() {
|
||||
String[] names = getQualifiedName();
|
||||
String[] names = CPPVisitor.getQualifiedName(this);
|
||||
if (names.length == 0) {
|
||||
return "<unnamed namespace>"; //$NON-NLS-1$
|
||||
}
|
||||
|
@ -255,7 +256,8 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
|
||||
public ICPPNamespaceScope[] getInlineNamespaces() {
|
||||
if (fInlineNamespaces == null) {
|
||||
List<PDOMCPPNamespace> nslist = collectInlineNamespaces(getDB(), getLinkage(), record+FIRST_NAMESPACE_CHILD_OFFSET);
|
||||
List<PDOMCPPNamespace> nslist = collectInlineNamespaces(getDB(), getLinkage(),
|
||||
record + FIRST_NAMESPACE_CHILD_OFFSET);
|
||||
if (nslist == null) {
|
||||
fInlineNamespaces= new PDOMCPPNamespace[0];
|
||||
} else {
|
||||
|
@ -265,8 +267,8 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
return fInlineNamespaces;
|
||||
}
|
||||
|
||||
public static List<PDOMCPPNamespace> collectInlineNamespaces(Database db,
|
||||
PDOMLinkage linkage, long listRecord) {
|
||||
public static List<PDOMCPPNamespace> collectInlineNamespaces(Database db, PDOMLinkage linkage,
|
||||
long listRecord) {
|
||||
List<PDOMCPPNamespace> nslist= null;
|
||||
try {
|
||||
long rec= db.getRecPtr(listRecord);
|
||||
|
|
|
@ -86,6 +86,7 @@ import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
|||
import org.eclipse.cdt.ui.text.SharedASTJob;
|
||||
import org.eclipse.cdt.utils.PathUtil;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||
import org.eclipse.cdt.internal.corext.codemanipulation.AddIncludesOperation;
|
||||
|
@ -647,7 +648,7 @@ public class AddIncludeOnSelectionAction extends TextEditorAction {
|
|||
* @throws CoreException
|
||||
*/
|
||||
private static String getBindingQualifiedName(IIndexBinding binding) throws CoreException {
|
||||
String[] qname= binding.getQualifiedName();
|
||||
String[] qname= CPPVisitor.getQualifiedName(binding);
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean needSep= false;
|
||||
for (String element : qname) {
|
||||
|
|
Loading…
Add table
Reference in a new issue