1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 10:25:32 +02:00

Correcting IASTName.toCharArray(), bug 258054.

This commit is contained in:
Markus Schorn 2008-12-19 12:19:16 +00:00
parent ed9ade92a2
commit 416bf3a0e0
82 changed files with 588 additions and 567 deletions

View file

@ -33,6 +33,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
@ -127,6 +128,9 @@ public class AST2SpecBaseTest extends AST2BaseTest {
NULL_LOG, config ); NULL_LOG, config );
} }
if (expectedProblemBindings > 0)
CPPASTNameBase.sAllowNameComputation= true;
IASTTranslationUnit tu = parser2.parse(); IASTTranslationUnit tu = parser2.parse();
// resolve all bindings // resolve all bindings

View file

@ -74,6 +74,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
@ -463,6 +464,8 @@ public class AST2TemplateTests extends AST2BaseTest {
// A <int, char*, 1> a4; //uses #5, T is int, T2 is char, I is1 // A <int, char*, 1> a4; //uses #5, T is int, T2 is char, I is1
// A <int*, int*, 2> a5; //ambiguous, matches #3 & #5. // A <int*, int*, 2> a5; //ambiguous, matches #3 & #5.
public void test_14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{ public void test_14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{
CPPASTNameBase.sAllowNameComputation= true;
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();
tu.accept(col); tu.accept(col);
@ -1765,6 +1768,7 @@ public class AST2TemplateTests extends AST2BaseTest {
} }
public void testBug98666() throws Exception { public void testBug98666() throws Exception {
CPPASTNameBase.sAllowNameComputation= true;
IASTTranslationUnit tu = parse("A::template B<T> b;", ParserLanguage.CPP); //$NON-NLS-1$ IASTTranslationUnit tu = parse("A::template B<T> b;", ParserLanguage.CPP); //$NON-NLS-1$
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();
tu.accept(col); tu.accept(col);
@ -1772,7 +1776,7 @@ public class AST2TemplateTests extends AST2BaseTest {
ICPPASTQualifiedName qn = (ICPPASTQualifiedName) col.getName(0); ICPPASTQualifiedName qn = (ICPPASTQualifiedName) col.getName(0);
IASTName[] ns = qn.getNames(); IASTName[] ns = qn.getNames();
assertTrue(ns[1] instanceof ICPPASTTemplateId); assertTrue(ns[1] instanceof ICPPASTTemplateId);
assertEquals(((ICPPASTTemplateId)ns[1]).toString(), "B"); //$NON-NLS-1$ assertEquals(ns[1].toString(), "B<T>"); //$NON-NLS-1$
} }
// template <class T> struct A{ // template <class T> struct A{
@ -2293,6 +2297,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// //
// void f(B<int>::tb r) {} // void f(B<int>::tb r) {}
public void testTemplateTypedef_214447() throws Exception { public void testTemplateTypedef_214447() throws Exception {
CPPASTNameBase.sAllowNameComputation= true;
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();
@ -2326,6 +2331,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// //
// void f(Vec<int>::reference r) {} // void f(Vec<int>::reference r) {}
public void testRebindPattern_214447_1() throws Exception { public void testRebindPattern_214447_1() throws Exception {
CPPASTNameBase.sAllowNameComputation= true;
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();
@ -2365,6 +2371,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// //
// void f(Vec<int>::reference r) {} // void f(Vec<int>::reference r) {}
public void testRebindPattern_214447_2() throws Exception { public void testRebindPattern_214447_2() throws Exception {
CPPASTNameBase.sAllowNameComputation= true;
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();
@ -2403,6 +2410,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// //
// void f(map<int>::value_type r) {} // void f(map<int>::value_type r) {}
public void testRebindPattern_236197() throws Exception { public void testRebindPattern_236197() throws Exception {
CPPASTNameBase.sAllowNameComputation= true;
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();
tu.accept(col); tu.accept(col);
@ -2434,6 +2442,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// //
// void main(Iter<int*>::iter_reference r); // void main(Iter<int*>::iter_reference r);
public void testSpecializationSelection_229218() throws Exception { public void testSpecializationSelection_229218() throws Exception {
CPPASTNameBase.sAllowNameComputation= true;
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();
tu.accept(col); tu.accept(col);
@ -2462,6 +2471,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// //
// B<int>::b::a x; // B<int>::b::a x;
public void testDefaultTemplateParameter() throws Exception { public void testDefaultTemplateParameter() throws Exception {
CPPASTNameBase.sAllowNameComputation= true;
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();
@ -2746,6 +2756,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// C c1; // C c1;
// C<> c2; // ok - default args // C<> c2; // ok - default args
public void testMissingTemplateArgumentLists() throws Exception { public void testMissingTemplateArgumentLists() throws Exception {
CPPASTNameBase.sAllowNameComputation=true;
BindingAssertionHelper ba=new BindingAssertionHelper(getAboveComment(), true); BindingAssertionHelper ba=new BindingAssertionHelper(getAboveComment(), true);
ba.assertProblem("B b1", 1); ba.assertProblem("B b1", 1);
ba.assertNonProblem("B<> b2", 1, ICPPTemplateDefinition.class, ICPPClassType.class); ba.assertNonProblem("B<> b2", 1, ICPPTemplateDefinition.class, ICPPClassType.class);
@ -2918,6 +2929,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// //
// A<int> aint; // should be an error // A<int> aint; // should be an error
public void testTypeArgumentToNonTypeParameter() throws Exception { public void testTypeArgumentToNonTypeParameter() throws Exception {
CPPASTNameBase.sAllowNameComputation=true;
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertProblem("A<int>", 6); ba.assertProblem("A<int>", 6);
} }

View file

@ -37,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.model.CProject; import org.eclipse.cdt.internal.core.model.CProject;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
@ -630,6 +631,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
} }
public void testBug72814() throws Exception{ public void testBug72814() throws Exception{
CPPASTNameBase.sAllowNameComputation= true;
Writer writer = new StringWriter(); Writer writer = new StringWriter();
writer.write( "namespace N{ \n"); //$NON-NLS-1$ writer.write( "namespace N{ \n"); //$NON-NLS-1$
writer.write( " template < class T > class AAA { T _t; };\n"); //$NON-NLS-1$ writer.write( " template < class T > class AAA { T _t; };\n"); //$NON-NLS-1$
@ -653,7 +656,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertTrue( node instanceof IASTName ); assertTrue( node instanceof IASTName );
assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPClassType ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPClassType );
assertEquals( ((IASTName)node).toString(), "AAA" ); //$NON-NLS-1$ assertEquals( ((IASTName)node).toString(), "AAA<int>" ); //$NON-NLS-1$
decls = getDeclarationOffTU((IASTName)node); decls = getDeclarationOffTU((IASTName)node);
// TODO raised bug 92632 for below // TODO raised bug 92632 for below
// assertEquals(decls.length, 1); // assertEquals(decls.length, 1);
@ -1740,7 +1743,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertNotNull( node ); assertNotNull( node );
assertTrue( node instanceof IASTName ); assertTrue( node instanceof IASTName );
assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPTemplateInstance ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPTemplateInstance );
assertEquals( ((IASTName)node).toString(), "AAA" ); //$NON-NLS-1$ assertEquals( ((IASTName)node).toString(), "AAA<int>" ); //$NON-NLS-1$
IName[] decls = getDeclarationOffTU((IASTName)node); IName[] decls = getDeclarationOffTU((IASTName)node);
assertEquals(decls.length, 1); assertEquals(decls.length, 1);
assertEquals( decls[0].toString(), "AAA" ); //$NON-NLS-1$ assertEquals( decls[0].toString(), "AAA" ); //$NON-NLS-1$

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
@ -60,6 +61,13 @@ public class QuickParser2Tests extends TestCase {
super(name); super(name);
} }
@Override
protected void setUp() throws Exception {
CPPASTNameBase.sAllowRecursionBindings= false;
CPPASTNameBase.sAllowNameComputation= false;
}
/** /**
* Test code: int x = 5; Purpose: to test the simple decaration in it's * Test code: int x = 5; Purpose: to test the simple decaration in it's
* simplest form. * simplest form.
@ -549,6 +557,8 @@ public class QuickParser2Tests extends TestCase {
public void testBug36704() throws Exception { public void testBug36704() throws Exception {
Writer code = new StringWriter(); Writer code = new StringWriter();
code.write("template<typename T, typename U> class Typelist;");
code.write("template<typename T> struct Length {};");
code.write("template <class T, class U>\n"); code.write("template <class T, class U>\n");
code.write("struct Length< Typelist<T, U> >\n"); code.write("struct Length< Typelist<T, U> >\n");
code.write("{\n"); code.write("{\n");

View file

@ -21,6 +21,8 @@ import java.util.regex.Pattern;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTComment; import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
@ -142,7 +144,7 @@ public class CommentHandlingTest extends RewriteBaseTest {
for (IASTNode actNode : keyTree) { for (IASTNode actNode : keyTree) {
ArrayList<IASTComment> comments = map.get(actNode); ArrayList<IASTComment> comments = map.get(actNode);
output.append(actNode.getRawSignature() + " = "); //$NON-NLS-1$ output.append(getSignature(actNode) + " = "); //$NON-NLS-1$
boolean first = true; boolean first = true;
for (IASTComment actComment : comments) { for (IASTComment actComment : comments) {
if (!first) { if (!first) {
@ -156,6 +158,17 @@ public class CommentHandlingTest extends RewriteBaseTest {
return output.toString().trim(); return output.toString().trim();
} }
private String getSignature(IASTNode actNode) {
if (actNode instanceof IASTCompositeTypeSpecifier) {
IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) actNode;
return comp.getName().toString();
} else if (actNode instanceof IASTEnumerationSpecifier) {
IASTEnumerationSpecifier comp = (IASTEnumerationSpecifier) actNode;
return comp.getName().toString();
}
return actNode.getRawSignature();
}
private static String getSeparatingRegexp() { private static String getSeparatingRegexp() {
return LEADING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + TRAILING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + FREESTANDING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP; return LEADING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + TRAILING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + FREESTANDING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP;
} }

View file

@ -153,6 +153,7 @@ template<template <class T> class K> class vector /*TEST 2*/
//!Commented TemplateSpecialization 1 //!Commented TemplateSpecialization 1
//%CPP //%CPP
//TEST 1 //TEST 1
template<typename T> class MyQueue;
template<> class MyQueue<double> //TEST 2 template<> class MyQueue<double> //TEST 2
{ {
//TEST 3 //TEST 3
@ -167,6 +168,7 @@ public:
//!Commented TemplateSpecialization 2 //!Commented TemplateSpecialization 2
//%CPP //%CPP
/*TEST 1*/ /*TEST 1*/
template<typename T> class MyQueue;
template<> class MyQueue<double> /*TEST 2*/ template<> class MyQueue<double> /*TEST 2*/
{ {
/*TEST 3*/ /*TEST 3*/

View file

@ -54,6 +54,7 @@ template<template <class T> class K> class vector
//!TemplateSpecialization //!TemplateSpecialization
//%CPP //%CPP
template<typename T> class MyQueue;
template<> class MyQueue<double> template<> class MyQueue<double>
{ {
std::vector<double> data; std::vector<double> data;

View file

@ -57,6 +57,7 @@ public class BaseTestCase extends TestCase {
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
CPPASTNameBase.sAllowRecursionBindings= false; CPPASTNameBase.sAllowRecursionBindings= false;
CPPASTNameBase.sAllowNameComputation= false;
} }
@Override @Override

View file

@ -671,7 +671,7 @@ public class ASTStringUtil {
} }
buffer.append(Keywords.cpGT); buffer.append(Keywords.cpGT);
} else if (name != null) { } else if (name != null) {
buffer.append(name.toCharArray()); buffer.append(name.getSimpleID());
} }
return buffer; return buffer;
} }

View file

@ -154,7 +154,7 @@ public class CElementHandleFactory {
return null; return null;
} }
else if (scope instanceof ICPPNamespaceScope) { else if (scope instanceof ICPPNamespaceScope) {
element= new NamespaceHandle(parentElement, new String(scopeName.toCharArray())); element= new NamespaceHandle(parentElement, new String(scopeName.getSimpleID()));
} }
return element; return element;
} }

View file

@ -16,21 +16,23 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
/** /**
* Common interface for names in the index and the AST. * Common interface for names in the index and the AST.
* <p> This interface is not intended to be implemented by clients. </p>
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will
* work or that it will remain the same. Please do not use this API without
* consulting with the CDT team.
* </p>
* @since 4.0 * @since 4.0
* @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IName { public interface IName {
/** /**
* Return a char array representation of the name. * Returns the name without qualification and without template arguments.
* * @since 5.1
* @return ~ toString().toCharArray()
*/ */
public char[] getSimpleID();
/**
* @deprecated Using this method is problematic, because for names from the
* index never contain qualification or template arguments, which is different
* for names from the AST.
* Use {@link #getSimpleID()}, instead.
*/
@Deprecated
public char[] toCharArray(); public char[] toCharArray();
/** /**

View file

@ -45,7 +45,7 @@ public final class ASTNameCollector extends ASTVisitor {
@Override @Override
public int visit(IASTName name) { public int visit(IASTName name) {
if (name != null && !(name instanceof ICPPASTQualifiedName) && !(name instanceof ICPPASTTemplateId)) { if (name != null && !(name instanceof ICPPASTQualifiedName) && !(name instanceof ICPPASTTemplateId)) {
if (CharArrayUtils.equals(fName, name.toCharArray())) { if (CharArrayUtils.equals(fName, name.getSimpleID())) {
fFound.add(name); fFound.add(name);
} }
} }

View file

@ -13,24 +13,18 @@ package org.eclipse.cdt.core.dom.ast;
import java.util.LinkedList; import java.util.LinkedList;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.c.ICArrayType; import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
import org.eclipse.cdt.core.dom.ast.c.ICBasicType; import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
import org.eclipse.cdt.core.dom.ast.c.ICPointerType; import org.eclipse.cdt.core.dom.ast.c.ICPointerType;
import org.eclipse.cdt.core.dom.ast.c.ICQualifierType; import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPQualifierType; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPQualifierType;
@ -653,30 +647,21 @@ public class ASTTypeUtil {
private static String[] getQualifiedNameForAnonymous(ICPPBinding binding) throws DOMException { private static String[] getQualifiedNameForAnonymous(ICPPBinding binding) throws DOMException {
LinkedList<String> result= new LinkedList<String>(); LinkedList<String> result= new LinkedList<String>();
result.addFirst(getNameForAnonymous(binding)); result.addFirst(getNameForAnonymous(binding));
ICPPScope scope = (ICPPScope) binding.getScope();
while (scope != null) { IBinding owner= binding.getOwner();
if (scope instanceof ICPPBlockScope || scope instanceof ICPPFunctionScope) { while(owner instanceof ICPPNamespace || owner instanceof ICPPClassType) {
break; char[] name= owner.getNameCharArray();
if (name == null || name.length == 0) {
if (!(binding instanceof ICPPNamespace)) {
char[] altname= createNameForAnonymous(binding);
if (altname != null) {
result.addFirst(new String(altname));
} }
if (!(scope instanceof ICPPTemplateScope)) {
IName n = scope.getScopeName();
if (n == null) {
break;
}
char[] name= n.toCharArray();
if (name.length == 0) {
if (!(scope instanceof ICPPNamespaceScope)) {
name= createNameForAnonymous(scope);
if (name == null) {
break;
}
result.addFirst(new String(name));
} }
} else { } else {
result.addFirst(new String(name)); result.addFirst(new String(name));
} }
} owner= owner.getOwner();
scope = (ICPPScope) scope.getParent();
} }
return result.toArray(new String[result.size()]); return result.toArray(new String[result.size()]);
} }
@ -692,13 +677,6 @@ public class ASTTypeUtil {
return new String(name); return new String(name);
} }
private static char[] createNameForAnonymous(ICPPScope scope) {
if (scope instanceof ICPPClassScope) {
return createNameForAnonymous(((ICPPClassScope) scope).getClassType());
}
return null;
}
public static char[] createNameForAnonymous(IBinding binding) { public static char[] createNameForAnonymous(IBinding binding) {
IASTNode node= null; IASTNode node= null;
if (binding instanceof ICInternalBinding) { if (binding instanceof ICInternalBinding) {

View file

@ -1,19 +1,19 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others. * Copyright (c) 2004, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
/** /**
* This is the base interface that represents a declaration specifier sequence. * This is the base interface that represents a declaration specifier sequence.
* *
* @author Doug Schaefer
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTDeclSpecifier extends IASTNode { public interface IASTDeclSpecifier extends IASTNode {
@ -118,14 +118,6 @@ public interface IASTDeclSpecifier extends IASTNode {
*/ */
public void setInline(boolean value); public void setInline(boolean value);
/**
* Get the string that represents the decl specifier seq. as represented in
* the file pre-processing.
*
* @return String
*/
public String getRawSignature();
/** /**
* @since 5.1 * @since 5.1
*/ */

View file

@ -19,9 +19,6 @@ import org.eclipse.cdt.core.dom.IName;
* This class represents a name in the program that represents a semantic object * This class represents a name in the program that represents a semantic object
* in the program. * in the program.
* *
* The toString method produces a string representation of the name as
* appropriate for the language.
*
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTName extends IASTNode, IName { public interface IASTName extends IASTNode, IName {
@ -31,6 +28,17 @@ public interface IASTName extends IASTNode, IName {
*/ */
public static final IASTName[] EMPTY_NAME_ARRAY = new IASTName[0]; public static final IASTName[] EMPTY_NAME_ARRAY = new IASTName[0];
/**
* Returns the name including qualification and template arguments.
*/
public char[] toCharArray();
/**
* Same as {@link #toCharArray()}.
* @since 5.1
*/
public String toString();
/** /**
* Get the semantic object attached to this name. May be null if this name * Get the semantic object attached to this name. May be null if this name
* has not yet been semantically resolved (@see resolveBinding) * has not yet been semantically resolved (@see resolveBinding)
@ -38,12 +46,6 @@ public interface IASTName extends IASTNode, IName {
*/ */
public IBinding getBinding(); public IBinding getBinding();
/**
* Set the semantic object for this name to be the given binding
* @param binding
*/
public void setBinding( IBinding binding );
/** /**
* Resolve the semantic object this name is referring to. * Resolve the semantic object this name is referring to.
* *
@ -100,4 +102,10 @@ public interface IASTName extends IASTNode, IName {
* @since 5.1 * @since 5.1
*/ */
public IASTName copy(); public IASTName copy();
/**
* Set the semantic object for this name to be the given binding
* @noreference This method is not intended to be referenced by clients.
*/
public void setBinding( IBinding binding );
} }

View file

@ -66,7 +66,7 @@ public interface ICPPNodeFactory extends INodeFactory {
public ICPPASTTemplateId newTemplateId(IASTName templateName); public ICPPASTTemplateId newTemplateId(IASTName templateName);
public ICPPASTConversionName newConversionName(char[] name, IASTTypeId typeId); public ICPPASTConversionName newConversionName(IASTTypeId typeId);
public ICPPASTQualifiedName newQualifiedName(); public ICPPASTQualifiedName newQualifiedName();

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.OffsetLimitReachedException; import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.parser.scanner.ILexerLog; import org.eclipse.cdt.internal.core.parser.scanner.ILexerLog;
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver; import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
import org.eclipse.cdt.internal.core.parser.scanner.Lexer; import org.eclipse.cdt.internal.core.parser.scanner.Lexer;
@ -143,16 +144,20 @@ public abstract class ASTNode implements IASTNode {
return null; return null;
} }
public String getRawSignature() { protected char[] getRawSignatureChars() {
final IASTFileLocation floc= getFileLocation(); final IASTFileLocation floc= getFileLocation();
final IASTTranslationUnit ast = getTranslationUnit(); final IASTTranslationUnit ast = getTranslationUnit();
if (floc != null && ast != null) { if (floc != null && ast != null) {
ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class); ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class);
if (lr != null) { if (lr != null) {
return new String(lr.getUnpreprocessedSignature(getFileLocation())); return lr.getUnpreprocessedSignature(getFileLocation());
} }
} }
return ""; //$NON-NLS-1$ return CharArrayUtils.EMPTY;
}
public String getRawSignature() {
return new String(getRawSignatureChars());
} }
public String getContainingFilename() { public String getContainingFilename() {

View file

@ -1615,11 +1615,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
} }
} }
if (dtor.getName().toCharArray().length == 0 && dtor.getNestedDeclarator() == null) { assert dtor.getNestedDeclarator() != null || dtor.getName().getSimpleID().length > 0;
throw new Error();
// backup(lastTokenOfExpression); consume();
// return expressionStatement;
}
} }
} }
} }

View file

@ -122,9 +122,7 @@ public class FindNodeForOffsetAction extends CPPASTVisitor implements ICASTVisit
@Override @Override
public int visit(IASTName name) { public int visit(IASTName name) {
if (name.toString() != null)
return processNode(name); return processNode(name);
return PROCESS_CONTINUE;
} }
@Override @Override

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * John Camelon (IBM Rational Software) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Yuan Zhang / Beth Tibbitts (IBM Research) * Yuan Zhang / Beth Tibbitts (IBM Research)
*******************************************************************************/ *******************************************************************************/
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
/** /**
* @author jcamelon * Implementation for C composite specifiers.
*/ */
public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
ICASTCompositeTypeSpecifier { ICASTCompositeTypeSpecifier {
@ -102,12 +102,6 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
return scope; return scope;
} }
@Override
public String getRawSignature() {
return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$
}
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept( ASTVisitor action ){
if( action.shouldVisitDeclSpecifiers ){ if( action.shouldVisitDeclSpecifiers ){

View file

@ -90,11 +90,6 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier
return name; return name;
} }
@Override
public String getRawSignature() {
return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$
}
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept( ASTVisitor action ){
if( action.shouldVisitDeclSpecifiers ){ if( action.shouldVisitDeclSpecifiers ){

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * John Camelon (IBM Rational Software) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Yuan Zhang / Beth Tibbitts (IBM Research) * Yuan Zhang / Beth Tibbitts (IBM Research)
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
@ -30,7 +30,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner; import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
/** /**
* @author jcamelon * Implementation for names in C translation units.
*/ */
public class CASTName extends ASTNode implements IASTName, IASTCompletionContext { public class CASTName extends ASTNode implements IASTName, IASTCompletionContext {
@ -98,6 +98,10 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return name; return name;
} }
public char[] getSimpleID() {
return name;
}
@Override @Override
public boolean accept(ASTVisitor action) { public boolean accept(ASTVisitor action) {
if (action.shouldVisitNames) { if (action.shouldVisitNames) {

View file

@ -60,7 +60,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
} }
public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) throws DOMException { public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) throws DOMException {
char[] c = name.toCharArray(); char[] c = name.getSimpleID();
if (CharArrayUtils.equals(c, specialClass.getNameCharArray()) && !CPPClassScope.isConstructorReference(name)) { if (CharArrayUtils.equals(c, specialClass.getNameCharArray()) && !CPPClassScope.isConstructorReference(name)) {
return specialClass; return specialClass;
@ -83,7 +83,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
public IBinding[] getBindings(IASTName name, boolean forceResolve, boolean prefixLookup, public IBinding[] getBindings(IASTName name, boolean forceResolve, boolean prefixLookup,
IIndexFileSet fileSet) throws DOMException { IIndexFileSet fileSet) throws DOMException {
char[] c = name.toCharArray(); char[] c = name.getSimpleID();
IBinding[] result = null; IBinding[] result = null;
if ((!prefixLookup && CharArrayUtils.equals(c, specialClass.getNameCharArray())) || if ((!prefixLookup && CharArrayUtils.equals(c, specialClass.getNameCharArray())) ||

View file

@ -50,11 +50,6 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
return copy; return copy;
} }
@Override
public String getRawSignature() {
return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$
}
public ICPPASTBaseSpecifier[] getBaseSpecifiers() { public ICPPASTBaseSpecifier[] getBaseSpecifiers() {
if( baseSpecs == null ) return ICPPASTBaseSpecifier.EMPTY_BASESPECIFIER_ARRAY; if( baseSpecs == null ) return ICPPASTBaseSpecifier.EMPTY_BASESPECIFIER_ARRAY;
baseSpecs = (ICPPASTBaseSpecifier[]) ArrayUtil.removeNullsAfter( ICPPASTBaseSpecifier.class, baseSpecs, baseSpecsPos ); baseSpecs = (ICPPASTBaseSpecifier[]) ArrayUtil.removeNullsAfter( ICPPASTBaseSpecifier.class, baseSpecs, baseSpecsPos );

View file

@ -6,40 +6,35 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * Devin Steffler (IBM) - Initial API and implementation
* Emanuel Graf IFS - Bugfix for #198259 * Emanuel Graf IFS - Fix for #198259
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/** /**
* The implemented ICPPASTConversionName. * Implementation of conversion function ids
*
* @author dsteffle
*/ */
public class CPPASTConversionName extends CPPASTName implements ICPPASTConversionName { public class CPPASTConversionName extends CPPASTNameBase implements ICPPASTConversionName {
private IASTTypeId typeId = null; private IASTTypeId typeId = null;
private char[] fName;
public CPPASTConversionName() { public CPPASTConversionName() {
} }
public CPPASTConversionName(char[] name) { public CPPASTConversionName(IASTTypeId typeId) {
super(name);
}
public CPPASTConversionName(char[] name, IASTTypeId typeId) {
super(name);
setTypeId(typeId); setTypeId(typeId);
} }
@Override
public CPPASTConversionName copy() { public CPPASTConversionName copy() {
char[] name = toCharArray(); CPPASTConversionName copy = new CPPASTConversionName();
CPPASTConversionName copy = new CPPASTConversionName(name == null ? null : name.clone());
copy.setTypeId(typeId == null ? null : typeId.copy()); copy.setTypeId(typeId == null ? null : typeId.copy());
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
return copy; return copy;
@ -86,4 +81,29 @@ public class CPPASTConversionName extends CPPASTName implements ICPPASTConversio
} }
return true; return true;
} }
@Override
protected IBinding createIntermediateBinding() {
return CPPVisitor.createBinding(this);
}
public char[] toCharArray() {
if (fName == null) {
StringBuilder buf= new StringBuilder();
buf.append(Keywords.cOPERATOR);
buf.append(' ');
if (typeId != null) {
buf.append(typeId.getRawSignature());
WHITESPACE_SEQ.matcher(buf).replaceAll(" "); //$NON-NLS-1$
}
final int len= buf.length();
fName= new char[len];
buf.getChars(0, len, fName, 0);
}
return fName;
}
public char[] getSimpleID() {
return toCharArray();
}
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/** /**
* @author jcamelon * C++ specific declarator.
*/ */
public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
private IASTInitializer initializer; private IASTInitializer initializer;
@ -205,7 +205,7 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
return r_reference; return r_reference;
} }
if (getParent instanceof IASTParameterDeclaration) if (getParent instanceof IASTParameterDeclaration)
return (n.toCharArray().length > 0) ? r_definition : r_declaration; return (n.getSimpleID().length > 0) ? r_definition : r_declaration;
return r_unclear; return r_unclear;
} }

View file

@ -83,11 +83,6 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
return name; return name;
} }
@Override
public String getRawSignature() {
return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$
}
@Override @Override
public boolean accept(ASTVisitor action) { public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) { if (action.shouldVisitDeclSpecifiers) {

View file

@ -14,13 +14,11 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompletionContext; import org.eclipse.cdt.core.dom.ast.IASTCompletionContext;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
@ -29,8 +27,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; 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.dom.parser.cpp.semantics.CPPVisitor;
@ -58,6 +54,7 @@ public class CPPASTName extends CPPASTNameBase implements IASTCompletionContext
return CPPVisitor.createBinding(this); return CPPVisitor.createBinding(this);
} }
@Override
public IASTCompletionContext getCompletionContext() { public IASTCompletionContext getCompletionContext() {
IASTNode node = getParent(); IASTNode node = getParent();
while (node != null) { while (node != null) {
@ -135,14 +132,11 @@ public class CPPASTName extends CPPASTNameBase implements IASTCompletionContext
return (IBinding[])ArrayUtil.removeNulls(IBinding.class, bindings); return (IBinding[])ArrayUtil.removeNulls(IBinding.class, bindings);
} }
@Override public char[] toCharArray() {
public String toString() { return name;
if (name.length == 0)
return ""; //$NON-NLS-1$
return new String(name);
} }
public char[] toCharArray() { public char[] getSimpleID() {
return name; return name;
} }
@ -177,65 +171,4 @@ public class CPPASTName extends CPPASTNameBase implements IASTCompletionContext
} }
return true; return true;
} }
public int getRoleOfName(boolean allowResolution) {
IASTNode parent = getParent();
if (parent instanceof IASTInternalNameOwner) {
return ((IASTInternalNameOwner) parent).getRoleForName(this, allowResolution);
}
if (parent instanceof IASTNameOwner) {
return ((IASTNameOwner) parent).getRoleForName(this);
}
return IASTNameOwner.r_unclear;
}
public boolean isDeclaration() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
switch (role) {
case IASTNameOwner.r_reference:
case IASTNameOwner.r_unclear:
return false;
default:
return true;
}
}
return false;
}
public boolean isReference() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
switch (role) {
case IASTNameOwner.r_reference:
return true;
default:
return false;
}
}
return false;
}
public boolean isDefinition() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
switch (role) {
case IASTNameOwner.r_definition:
return true;
default:
return false;
}
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#getLinkage()
*/
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
} }

View file

@ -10,11 +10,21 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import java.util.regex.Pattern;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTCompletionContext;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
@ -23,11 +33,13 @@ import org.eclipse.core.runtime.Assert;
* names plus template-ids * names plus template-ids
*/ */
public abstract class CPPASTNameBase extends ASTNode implements IASTName { public abstract class CPPASTNameBase extends ASTNode implements IASTName {
protected static final Pattern WHITESPACE_SEQ = Pattern.compile("\\s+"); //$NON-NLS-1$
/** /**
* For test-purposes, only. * For test-purposes, only.
*/ */
public static boolean sAllowRecursionBindings = true; public static boolean sAllowRecursionBindings = true;
public static boolean sAllowNameComputation = true;
private static final byte MAX_RESOLUTION_DEPTH= 6; private static final byte MAX_RESOLUTION_DEPTH= 6;
protected final static class RecursionResolvingBinding extends ProblemBinding { protected final static class RecursionResolvingBinding extends ProblemBinding {
@ -61,6 +73,18 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return name.getBinding(); return name.getBinding();
} }
/**
* Helper method, returns "operator" for conversion names, and {@code IASTName#getSimpleName()}, otherwise.
*/
public static char[] getLookupKey(IASTName name) {
name= name.getLastName();
if (name instanceof ICPPASTTemplateId)
name= ((ICPPASTTemplateId) name).getTemplateName();
if (name instanceof ICPPASTConversionName)
return Keywords.cOPERATOR;
return name.toCharArray();
}
private IBinding fBinding = null; private IBinding fBinding = null;
private byte fResolutionDepth = 0; private byte fResolutionDepth = 0;
private boolean fIsFinal= false; private boolean fIsFinal= false;
@ -162,4 +186,72 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
public IASTName getLastName() { public IASTName getLastName() {
return this; return this;
} }
@Override
public final String toString() {
return new String(toCharArray());
}
public IASTCompletionContext getCompletionContext() {
IASTNode node = getParent();
while (node != null) {
if (node instanceof IASTCompletionContext) {
return (IASTCompletionContext) node;
}
node = node.getParent();
}
return null;
}
public int getRoleOfName(boolean allowResolution) {
IASTNode parent = getParent();
if (parent instanceof IASTInternalNameOwner) {
return ((IASTInternalNameOwner) parent).getRoleForName(this, allowResolution);
}
if (parent instanceof IASTNameOwner) {
return ((IASTNameOwner) parent).getRoleForName(this);
}
return IASTNameOwner.r_unclear;
}
public boolean isDeclaration() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
switch (role) {
case IASTNameOwner.r_reference:
case IASTNameOwner.r_unclear:
return false;
default:
return true;
}
}
return false;
}
public boolean isReference() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
return role == IASTNameOwner.r_reference;
}
return false;
}
public boolean isDefinition() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
return role == IASTNameOwner.r_definition;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#getLinkage()
*/
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
} }

View file

@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompletionContext; import org.eclipse.cdt.core.dom.ast.IASTCompletionContext;
@ -34,9 +33,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner; import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
@ -51,8 +50,7 @@ public class CPPASTQualifiedName extends CPPASTNameBase
private IASTName[] names = null; private IASTName[] names = null;
private int namesPos= -1; private int namesPos= -1;
private boolean isFullyQualified; private boolean isFullyQualified;
private String signature; private char[] signature;
public CPPASTQualifiedName() { public CPPASTQualifiedName() {
} }
@ -61,7 +59,6 @@ public class CPPASTQualifiedName extends CPPASTNameBase
for(IASTName name : getNames()) for(IASTName name : getNames())
copy.addName(name == null ? null : name.copy()); copy.addName(name == null ? null : name.copy());
copy.setFullyQualified(isFullyQualified); copy.setFullyQualified(isFullyQualified);
copy.setSignature(signature);
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
return copy; return copy;
} }
@ -95,22 +92,6 @@ public class CPPASTQualifiedName extends CPPASTNameBase
getLastName().setBinding(binding); getLastName().setBinding(binding);
} }
public IASTCompletionContext getCompletionContext() {
IASTNode node = getParent();
while (node != null) {
if (node instanceof IASTCompletionContext) {
return (IASTCompletionContext) node;
}
node = node.getParent();
}
return null;
}
@Override
public String toString() {
return (signature == null) ? "" : signature; //$NON-NLS-1$
}
public void addName(IASTName name) { public void addName(IASTName name) {
assertNotFrozen(); assertNotFrozen();
@ -138,32 +119,25 @@ public class CPPASTQualifiedName extends CPPASTNameBase
return names[namesPos]; return names[namesPos];
} }
public char[] getSimpleID() {
return names[namesPos].getSimpleID();
}
public char[] toCharArray() { public char[] toCharArray() {
if (namesPos < 0) if (signature == null) {
return new char[0]; StringBuilder buf= new StringBuilder();
// count first
int len = -2;
for (int i = 0; i <= namesPos; ++i) {
char[] n = names[i].toCharArray();
if (n == null)
return null;
len+= 2;
len+= n.length;
}
char[] nameArray = new char[len];
int pos = 0;
for (int i = 0; i <= namesPos; i++) { for (int i = 0; i <= namesPos; i++) {
if (i != 0) { if (i > 0 || isFullyQualified) {
nameArray[pos++] = ':'; buf.append(Keywords.cpCOLONCOLON);
nameArray[pos++] = ':';
} }
final char[] n = names[i].toCharArray(); buf.append(names[i].toCharArray());
System.arraycopy(n, 0, nameArray, pos, n.length);
pos += n.length;
} }
return nameArray;
final int len= buf.length();
signature= new char[len];
buf.getChars(0, len, signature, 0);
}
return signature;
} }
public boolean isFullyQualified() { public boolean isFullyQualified() {
@ -175,10 +149,11 @@ public class CPPASTQualifiedName extends CPPASTNameBase
this.isFullyQualified = isFullyQualified; this.isFullyQualified = isFullyQualified;
} }
/**
* @deprecated there is no need to set the signature, it will be computed lazily.
*/
@Deprecated
public void setSignature(String signature) { public void setSignature(String signature) {
assertNotFrozen();
this.signature = signature;
} }
@Override @Override
@ -194,11 +169,12 @@ public class CPPASTQualifiedName extends CPPASTNameBase
} }
} }
for (int i = 0; i <= namesPos; i++) { for (int i = 0; i <= namesPos; i++) {
final IASTName name = names[i];
if (i == namesPos) { if (i == namesPos) {
// pointer-to-member qualified names have a dummy name as the last part of the name, don't visit it // pointer-to-member qualified names have a dummy name as the last part of the name, don't visit it
if (names[i].toCharArray().length > 0 && !names[i].accept(action)) if (getLookupKey(name).length > 0 && !name.accept(action))
return false; return false;
} else if (!names[i].accept(action)) } else if (!name.accept(action))
return false; return false;
} }
@ -216,6 +192,7 @@ public class CPPASTQualifiedName extends CPPASTNameBase
return true; return true;
} }
@Override
public int getRoleOfName(boolean allowResolution) { public int getRoleOfName(boolean allowResolution) {
IASTNode parent = getParent(); IASTNode parent = getParent();
if (parent instanceof IASTInternalNameOwner) { if (parent instanceof IASTInternalNameOwner) {
@ -227,26 +204,6 @@ public class CPPASTQualifiedName extends CPPASTNameBase
return IASTNameOwner.r_unclear; return IASTNameOwner.r_unclear;
} }
public boolean isDeclaration() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
if (role == IASTNameOwner.r_reference) return false;
return true;
}
return false;
}
public boolean isReference() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
if (role == IASTNameOwner.r_reference) return true;
return false;
}
return false;
}
public int getRoleForName(IASTName n) { public int getRoleForName(IASTName n) {
for (int i=0; i < namesPos; ++i) { for (int i=0; i < namesPos; ++i) {
if (names[i] == n) if (names[i] == n)
@ -278,16 +235,6 @@ public class CPPASTQualifiedName extends CPPASTNameBase
return false; return false;
} }
public boolean isDefinition() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
if (role == IASTNameOwner.r_definition) return true;
return false;
}
return false;
}
public IBinding[] findBindings(IASTName n, boolean isPrefix) { public IBinding[] findBindings(IASTName n, boolean isPrefix) {
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix); IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix);
@ -299,7 +246,7 @@ public class CPPASTQualifiedName extends CPPASTNameBase
List<IBinding> filtered = filterClassScopeBindings(classType, bindings, isDeclaration); List<IBinding> filtered = filterClassScopeBindings(classType, bindings, isDeclaration);
if (isDeclaration && nameMatches(classType.getNameCharArray(), if (isDeclaration && nameMatches(classType.getNameCharArray(),
n.toCharArray(), isPrefix)) { n.getSimpleID(), isPrefix)) {
try { try {
ICPPConstructor[] constructors = classType.getConstructors(); ICPPConstructor[] constructors = classType.getConstructors();
for (int i = 0; i < constructors.length; i++) { for (int i = 0; i < constructors.length; i++) {
@ -359,13 +306,6 @@ public class CPPASTQualifiedName extends CPPASTNameBase
return CharArrayUtils.equals(potential, name); return CharArrayUtils.equals(potential, name);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#getLinkage()
*/
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
@Override @Override
protected IBinding createIntermediateBinding() { protected IBinding createIntermediateBinding() {
Assert.isLegal(false); Assert.isLegal(false);

View file

@ -12,23 +12,24 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompletionContext;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner; import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/** /**
* Template ids consist of an unqualified name (or operator or conversion name) * Template ids consist of an unqualified name (or operator or conversion name)
@ -53,6 +54,10 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
return copy; return copy;
} }
public char[] getSimpleID() {
return templateName.getSimpleID();
}
public IASTName getTemplateName() { public IASTName getTemplateName() {
return templateName; return templateName;
} }
@ -98,17 +103,43 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
return CPPTemplates.createBinding(this); return CPPTemplates.createBinding(this);
} }
public IASTCompletionContext getCompletionContext() {
return null;
}
public char[] toCharArray() { public char[] toCharArray() {
return templateName.toCharArray(); assert sAllowNameComputation;
}
@Override StringBuilder buf= new StringBuilder();
public String toString() { buf.append(getTemplateName().toCharArray());
return templateName.toString(); buf.append('<');
boolean needComma= false;
boolean cleanupWhitespace= false;
final IASTNode[] args= getTemplateArguments();
for (IASTNode arg : args) {
if (needComma)
buf.append(", "); //$NON-NLS-1$
needComma= true;
if (arg instanceof IASTExpression) {
IValue value= Value.create((IASTExpression) arg, Value.MAX_RECURSION_DEPTH);
if (value != Value.UNKNOWN && !Value.isDependentValue(value)) {
buf.append(value.getSignature());
} else {
buf.append(arg.getRawSignature());
cleanupWhitespace= true;
}
} else {
IType type= CPPVisitor.createType(arg);
if (type == null || type instanceof IProblemBinding) {
buf.append(arg.getRawSignature());
} else {
buf.append(ASTTypeUtil.getType(type, false));
}
}
if (cleanupWhitespace)
WHITESPACE_SEQ.matcher(buf).replaceAll(" "); //$NON-NLS-1$
}
buf.append('>');
final int len= buf.length();
final char[] result= new char[len];
buf.getChars(0, len, result, 0);
return result;
} }
@Override @Override
@ -136,10 +167,12 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
return true; return true;
} }
@Override
public boolean isDeclaration() { public boolean isDeclaration() {
return false; //for now this seems to be true return false; //for now this seems to be true
} }
@Override
public boolean isReference() { public boolean isReference() {
return true; //for now this seems to be true return true; //for now this seems to be true
} }
@ -160,28 +193,4 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
} }
} }
} }
public int getRoleOfName(boolean allowResolution) {
IASTNode parent = getParent();
if (parent instanceof IASTInternalNameOwner) {
return ((IASTInternalNameOwner) parent).getRoleForName(this, allowResolution);
}
if (parent instanceof IASTNameOwner) {
return ((IASTNameOwner) parent).getRoleForName(this);
}
return IASTNameOwner.r_unclear;
}
public boolean isDefinition() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
return role == IASTNameOwner.r_definition;
}
return false;
}
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
} }

View file

@ -61,6 +61,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/** /**
* Base implementation for c++ scopes. * Base implementation for c++ scopes.
*
* mstodo store user defined conversions under the same key, see {@link CPPASTNameBase#getLookupKey(IASTName)}
*/ */
public class CPPClassScope extends CPPScope implements ICPPClassScope { public class CPPClassScope extends CPPScope implements ICPPClassScope {
private static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$ private static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$
@ -84,11 +86,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
//will resolve to these bindings. //will resolve to these bindings.
ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName name = compTypeSpec.getName(); IASTName name = compTypeSpec.getName().getLastName();
if (name instanceof ICPPASTQualifiedName) {
name = ((ICPPASTQualifiedName) name).getLastName();
}
IBinding binding = name.resolveBinding(); IBinding binding = name.resolveBinding();
if (!(binding instanceof ICPPClassType)) if (!(binding instanceof ICPPClassType))
return; return;
@ -100,7 +98,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
} catch (DOMException e) { } catch (DOMException e) {
} }
} }
char[] className = name.toCharArray(); char[] className = name.getSimpleID();
IParameter[] voidPs = new IParameter[] { new CPPParameter(CPPSemantics.VOID_TYPE) }; IParameter[] voidPs = new IParameter[] { new CPPParameter(CPPSemantics.VOID_TYPE) };
IType pType = new CPPReferenceType(new CPPQualifierType(clsType, true, false)); IType pType = new CPPReferenceType(new CPPQualifierType(clsType, true, false));
@ -173,7 +171,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name; final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
final IASTName[] names= qname.getNames(); final IASTName[] names= qname.getNames();
for (int i = names.length-2; i>=0; i--) { for (int i = names.length-2; i>=0; i--) {
if (b == null || !CharArrayUtils.equals(names[i].toCharArray(), b.getNameCharArray())) if (b == null || !CharArrayUtils.equals(names[i].getSimpleID(), b.getNameCharArray()))
return; return;
b= b.getOwner(); b= b.getOwner();
@ -215,14 +213,14 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
*/ */
@Override @Override
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException { public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
char[] c = name.toCharArray(); char[] c = name.getSimpleID();
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName().getLastName(); IASTName compName = compType.getName().getLastName();
if (compName instanceof ICPPASTTemplateId) { if (compName instanceof ICPPASTTemplateId) {
compName= ((ICPPASTTemplateId) compName).getTemplateName(); compName= ((ICPPASTTemplateId) compName).getTemplateName();
} }
if (CharArrayUtils.equals(c, compName.toCharArray())) { if (CharArrayUtils.equals(c, compName.getSimpleID())) {
if (isConstructorReference(name)) { if (isConstructorReference(name)) {
return CPPSemantics.resolveAmbiguities(name, getConstructors(bindings, resolve, name)); return CPPSemantics.resolveAmbiguities(name, getConstructors(bindings, resolve, name));
} }
@ -234,7 +232,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
@Override @Override
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException { public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException {
char[] c = name.toCharArray(); char[] c = name.getSimpleID();
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName().getLastName(); IASTName compName = compType.getName().getLastName();
@ -242,8 +240,8 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
compName= ((ICPPASTTemplateId) compName).getTemplateName(); compName= ((ICPPASTTemplateId) compName).getTemplateName();
} }
IBinding[] result = null; IBinding[] result = null;
if ((!prefixLookup && CharArrayUtils.equals(c, compName.toCharArray())) if ((!prefixLookup && CharArrayUtils.equals(c, compName.getSimpleID()))
|| (prefixLookup && CharArrayUtils.equals(compName.toCharArray(), 0, c.length, c, true))) { || (prefixLookup && CharArrayUtils.equals(compName.getSimpleID(), 0, c.length, c, true))) {
if (isConstructorReference(name)) { if (isConstructorReference(name)) {
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, getConstructors(bindings, resolve, name)); result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, getConstructors(bindings, resolve, name));
} }
@ -321,13 +319,13 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
public IBinding[] find(String name) throws DOMException { public IBinding[] find(String name) throws DOMException {
char[] n = name.toCharArray(); char[] n = name.toCharArray();
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName(); IASTName compName = compType.getName().getLastName();
if (compName instanceof ICPPASTQualifiedName) { if (compName instanceof ICPPASTTemplateId) {
compName = ((ICPPASTQualifiedName) compName).getLastName(); compName= ((ICPPASTTemplateId) compName).getTemplateName();
} }
if (CharArrayUtils.equals(compName.toCharArray(), n)) { if (CharArrayUtils.equals(compName.getSimpleID(), n)) {
return new IBinding[] { getClassType() }; return new IBinding[] {compName.resolveBinding()};
} }
return super.find(name); return super.find(name);
@ -358,11 +356,12 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
*/ */
public ICPPClassType getClassType() { public ICPPClassType getClassType() {
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IBinding binding = compSpec.getName().resolveBinding(); final IASTName name = compSpec.getName();
IBinding binding = name.resolveBinding();
if (binding instanceof ICPPClassType) if (binding instanceof ICPPClassType)
return (ICPPClassType) binding; return (ICPPClassType) binding;
return new CPPClassType.CPPClassTypeProblem(compSpec.getName(), IProblemBinding.SEMANTIC_BAD_SCOPE, compSpec.getName().toCharArray()); return new CPPClassType.CPPClassTypeProblem(name, IProblemBinding.SEMANTIC_BAD_SCOPE, name.toCharArray());
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -449,7 +448,7 @@ class ImplicitsAnalysis {
private static ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor(ICPPASTCompositeTypeSpecifier compSpec, boolean constructor) { private static ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor(ICPPASTCompositeTypeSpecifier compSpec, boolean constructor) {
List<ICPPASTFunctionDeclarator> result= new ArrayList<ICPPASTFunctionDeclarator>(); List<ICPPASTFunctionDeclarator> result= new ArrayList<ICPPASTFunctionDeclarator>();
IASTDeclaration[] members = compSpec.getMembers(); IASTDeclaration[] members = compSpec.getMembers();
char[] name = compSpec.getName().toCharArray(); char[] name = compSpec.getName().getSimpleID();
IASTDeclarator dcltor = null; IASTDeclarator dcltor = null;
IASTDeclSpecifier spec = null; IASTDeclSpecifier spec = null;
for (IASTDeclaration member : members) { for (IASTDeclaration member : members) {
@ -471,7 +470,7 @@ class ImplicitsAnalysis {
} }
boolean nameEquals= false; boolean nameEquals= false;
char[] dtorname= CPPVisitor.findInnermostDeclarator(dcltor).getName().toCharArray(); char[] dtorname= CPPASTNameBase.getLookupKey(CPPVisitor.findInnermostDeclarator(dcltor).getName());
if (constructor) { if (constructor) {
nameEquals= CharArrayUtils.equals(dtorname, name); nameEquals= CharArrayUtils.equals(dtorname, name);
} else { } else {
@ -504,7 +503,7 @@ class ImplicitsAnalysis {
if (dcltor instanceof ICPPASTFunctionDeclarator == false) if (dcltor instanceof ICPPASTFunctionDeclarator == false)
continue; continue;
final char[] nchars= CPPVisitor.findInnermostDeclarator(dcltor).getName().toCharArray(); final char[] nchars= CPPASTNameBase.getLookupKey(CPPVisitor.findInnermostDeclarator(dcltor).getName());
if (!CharArrayUtils.equals(nchars, OverloadableOperator.ASSIGN.toCharArray())) if (!CharArrayUtils.equals(nchars, OverloadableOperator.ASSIGN.toCharArray()))
continue; continue;

View file

@ -257,12 +257,12 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
return null; return null;
} }
public String getName() { public final String getName() {
return ( definition != null ) ? definition.toString() : declarations[0].toString(); return new String(getNameCharArray());
} }
public char[] getNameCharArray() { public char[] getNameCharArray() {
return ( definition != null ) ? definition.toCharArray() : declarations[0].toCharArray(); return ( definition != null ) ? definition.getSimpleID() : declarations[0].getSimpleID();
} }
public IScope getScope() { public IScope getScope() {

View file

@ -49,11 +49,11 @@ public class CPPEnumeration extends PlatformObject implements IEnumeration, ICPP
} }
public String getName() { public String getName() {
return enumName.toString(); return new String(getNameCharArray());
} }
public char[] getNameCharArray() { public char[] getNameCharArray() {
return enumName.toCharArray(); return enumName.getSimpleID();
} }
public IScope getScope() { public IScope getScope() {

View file

@ -63,14 +63,14 @@ public class CPPEnumerator extends PlatformObject implements IEnumerator, ICPPIn
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName() * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/ */
public String getName() { public String getName() {
return enumName.toString(); return new String(getNameCharArray());
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray() * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
*/ */
public char[] getNameCharArray() { public char[] getNameCharArray() {
return enumName.toCharArray(); return enumName.getSimpleID();
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -89,7 +89,7 @@ public class CPPField extends CPPVariable implements ICPPField {
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)member).getDeclarators(); IASTDeclarator [] dtors = ((IASTSimpleDeclaration)member).getDeclarators();
for (IASTDeclarator dtor : dtors) { for (IASTDeclarator dtor : dtors) {
IASTName name = dtor.getName(); IASTName name = dtor.getName();
if( CharArrayUtils.equals( name.toCharArray(), myName ) && if( CharArrayUtils.equals( name.getSimpleID(), myName ) &&
name.resolveBinding() == this ) name.resolveBinding() == this )
{ {
return member; return member;

View file

@ -257,7 +257,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
public char[] getNameCharArray() { public char[] getNameCharArray() {
return getASTName().toCharArray(); return getASTName().getSimpleID();
} }
protected IASTName getASTName() { protected IASTName getASTName() {

View file

@ -70,7 +70,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[]) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[])
*/ */
public IBinding getBinding(IASTName name) { public IBinding getBinding(IASTName name) {
return (IBinding) labels.get(name.toCharArray()); return (IBinding) labels.get(name.getSimpleID());
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -112,7 +112,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
while( dtor != null ){ while( dtor != null ){
IASTName name = CPPVisitor.findInnermostDeclarator(dtor).getName(); IASTName name = CPPVisitor.findInnermostDeclarator(dtor).getName();
if( CPPVisitor.findTypeRelevantDeclarator(dtor) instanceof ICPPASTFunctionDeclarator && if( CPPVisitor.findTypeRelevantDeclarator(dtor) instanceof ICPPASTFunctionDeclarator &&
CharArrayUtils.equals( name.toCharArray(), getNameCharArray() ) ) CharArrayUtils.equals( name.getSimpleID(), getNameCharArray() ) )
{ {
IType t0= CPPVisitor.createType( dtor ); IType t0= CPPVisitor.createType( dtor );
boolean ok= false; boolean ok= false;

View file

@ -51,11 +51,11 @@ public class CPPLabel extends PlatformObject implements ILabel, ICPPInternalBind
} }
public String getName() { public String getName() {
return statement.toString(); return new String(getNameCharArray());
} }
public char[] getNameCharArray() { public char[] getNameCharArray() {
return statement.toCharArray(); return statement.getSimpleID();
} }
public IScope getScope() { public IScope getScope() {

View file

@ -109,7 +109,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)member).getDeclarators(); IASTDeclarator [] dtors = ((IASTSimpleDeclaration)member).getDeclarators();
for (IASTDeclarator dtor : dtors) { for (IASTDeclarator dtor : dtors) {
IASTName name = CPPVisitor.findInnermostDeclarator(dtor).getName(); IASTName name = CPPVisitor.findInnermostDeclarator(dtor).getName();
if( CharArrayUtils.equals( name.toCharArray(), myName ) && if( CharArrayUtils.equals( name.getSimpleID(), myName ) &&
name.resolveBinding() == this ) name.resolveBinding() == this )
{ {
return member; return member;
@ -118,7 +118,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
} else if( member instanceof IASTFunctionDefinition ){ } else if( member instanceof IASTFunctionDefinition ){
final IASTFunctionDeclarator declarator = ((IASTFunctionDefinition) member).getDeclarator(); final IASTFunctionDeclarator declarator = ((IASTFunctionDefinition) member).getDeclarator();
IASTName name = CPPVisitor.findInnermostDeclarator(declarator).getName(); IASTName name = CPPVisitor.findInnermostDeclarator(declarator).getName();
if( CharArrayUtils.equals( name.toCharArray(), myName ) && if( CharArrayUtils.equals( name.getSimpleID(), myName ) &&
name.resolveBinding() == this ) name.resolveBinding() == this )
{ {
return member; return member;

View file

@ -73,7 +73,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators(); IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
for (IASTDeclarator dtor : dtors) { for (IASTDeclarator dtor : dtors) {
IASTName name = CPPVisitor.findInnermostDeclarator(dtor).getName(); IASTName name = CPPVisitor.findInnermostDeclarator(dtor).getName();
if( CharArrayUtils.equals( name.toCharArray(), myName ) && if( CharArrayUtils.equals( name.getSimpleID(), myName ) &&
name.resolveBinding() == this ) name.resolveBinding() == this )
{ {
return member; return member;
@ -81,7 +81,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements
} }
} else if( decl instanceof IASTFunctionDefinition ){ } else if( decl instanceof IASTFunctionDefinition ){
IASTName name = CPPVisitor.findInnermostDeclarator(((IASTFunctionDefinition) decl).getDeclarator()).getName(); IASTName name = CPPVisitor.findInnermostDeclarator(((IASTFunctionDefinition) decl).getDeclarator()).getName();
if( CharArrayUtils.equals( name.toCharArray(), myName ) && if( CharArrayUtils.equals( name.getSimpleID(), myName ) &&
name.resolveBinding() == this ) name.resolveBinding() == this )
{ {
return member; return member;

View file

@ -109,7 +109,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
public int visit(ICPPASTNamespaceDefinition namespace) { public int visit(ICPPASTNamespaceDefinition namespace) {
ICPPASTNamespaceDefinition orig = namespaceDef, candidate = namespace; ICPPASTNamespaceDefinition orig = namespaceDef, candidate = namespace;
while(candidate != null) { while(candidate != null) {
if (!CharArrayUtils.equals(orig.getName().toCharArray(), candidate.getName().toCharArray())) if (!CharArrayUtils.equals(orig.getName().getSimpleID(), candidate.getName().getSimpleID()))
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
if (orig.getParent() instanceof ICPPASTNamespaceDefinition) { if (orig.getParent() instanceof ICPPASTNamespaceDefinition) {
if (!(candidate.getParent() instanceof ICPPASTNamespaceDefinition)) if (!(candidate.getParent() instanceof ICPPASTNamespaceDefinition))
@ -238,14 +238,14 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName() * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/ */
public String getName() { public String getName() {
return tu != null ? null : namespaceDefinitions[0].toString(); return new String(getNameCharArray());
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray() * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
*/ */
public char[] getNameCharArray() { public char[] getNameCharArray() {
return tu != null ? EMPTY_CHAR_ARRAY : namespaceDefinitions[0].toCharArray(); return tu != null ? EMPTY_CHAR_ARRAY : namespaceDefinitions[0].getSimpleID();
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -50,11 +50,11 @@ public class CPPNamespaceAlias extends PlatformObject implements ICPPNamespaceAl
} }
public String getName() { public String getName() {
return alias.toString(); return new String(getNameCharArray());
} }
public char[] getNameCharArray() { public char[] getNameCharArray() {
return alias.toCharArray(); return alias.getSimpleID();
} }
public String[] getQualifiedName() { public String[] getQualifiedName() {

View file

@ -103,7 +103,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
} }
@Override @Override
public int leave(ICPPASTNamespaceDefinition namespace) { public int leave(ICPPASTNamespaceDefinition namespace) {
if (namespace.getName().toCharArray().length > 0) { if (namespace.getName().getSimpleID().length > 0) {
--depth; --depth;
} }
return PROCESS_CONTINUE; return PROCESS_CONTINUE;

View file

@ -206,8 +206,8 @@ public class CPPNodeFactory implements ICPPNodeFactory {
return new CPPASTTemplateId(templateName); return new CPPASTTemplateId(templateName);
} }
public ICPPASTConversionName newConversionName(char[] name, IASTTypeId typeId) { public ICPPASTConversionName newConversionName(IASTTypeId typeId) {
return new CPPASTConversionName(name, typeId); return new CPPASTConversionName(typeId);
} }
public ICPPASTQualifiedName newQualifiedName() { public ICPPASTQualifiedName newQualifiedName() {

View file

@ -144,10 +144,7 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName() * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/ */
public String getName() { public String getName() {
IASTName name = getPrimaryDeclaration(); return new String(getNameCharArray());
if (name != null)
return name.toString();
return CPPSemantics.EMPTY_NAME;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -156,7 +153,7 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
public char[] getNameCharArray() { public char[] getNameCharArray() {
IASTName name = getPrimaryDeclaration(); IASTName name = getPrimaryDeclaration();
if (name != null) if (name != null)
return name.toCharArray(); return name.getSimpleID();
return CPPSemantics.EMPTY_NAME_ARRAY; return CPPSemantics.EMPTY_NAME_ARRAY;
} }

View file

@ -76,22 +76,17 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
public void addName(IASTName name) throws DOMException { public void addName(IASTName name) throws DOMException {
if (bindings == null) if (bindings == null)
bindings = new CharArrayObjectMap(1); bindings = new CharArrayObjectMap(1);
char[] c;
if (name instanceof ICPPASTQualifiedName) { if (name instanceof ICPPASTQualifiedName) {
if (!(physicalNode instanceof ICPPASTCompositeTypeSpecifier) && if (!(physicalNode instanceof ICPPASTCompositeTypeSpecifier) &&
!(physicalNode instanceof ICPPASTNamespaceDefinition)) { !(physicalNode instanceof ICPPASTNamespaceDefinition)) {
return; return;
} }
//name belongs to a different scope, don't add it here except it names this scope // name belongs to a different scope, don't add it here except it names this scope
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name; if (!canDenoteScopeMember((ICPPASTQualifiedName) name))
final IASTName[] ns= qname.getNames();
if (!canDenoteScopeMember(qname))
return; return;
c= ns[ns.length - 1].toCharArray();
} else {
c= name.toCharArray();
} }
final char[] c= name.getSimpleID();
Object o = bindings.get(c); Object o = bindings.get(c);
if (o != null) { if (o != null) {
if (o instanceof ObjectSet) { if (o instanceof ObjectSet) {
@ -114,9 +109,11 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
for (int i= na.length - 2; i >= 0; i++) { for (int i= na.length - 2; i >= 0; i++) {
if (scope == null) if (scope == null)
return false; return false;
IASTName n= na[i]; IName scopeName = scope.getScopeName();
final IName scopeName = scope.getScopeName(); if (scopeName == null)
if (scopeName == null || !CharArrayUtils.equals(scopeName.toCharArray(), n.toCharArray())) return false;
if (!CharArrayUtils.equals(scopeName.getSimpleID(), na[i].getSimpleID()))
return false; return false;
scope= scope.getParent(); scope= scope.getParent();
} }
@ -135,10 +132,11 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
final IASTTranslationUnit tu = name.getTranslationUnit(); final IASTTranslationUnit tu = name.getTranslationUnit();
IIndex index = tu == null ? null : tu.getIndex(); IIndex index = tu == null ? null : tu.getIndex();
if (index != null) { if (index != null) {
final char[] nchars = name.getSimpleID();
// Try looking this up in the PDOM // Try looking this up in the PDOM
if (physicalNode instanceof IASTTranslationUnit) { if (physicalNode instanceof IASTTranslationUnit) {
try { try {
IBinding[] bindings= index.findBindings(name.toCharArray(), IBinding[] bindings= index.findBindings(nchars,
IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, NPM); IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, NPM);
if (fileSet != null) { if (fileSet != null) {
bindings= fileSet.filterFileLocalBindings(bindings); bindings= fileSet.filterFileLocalBindings(bindings);
@ -158,7 +156,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
if (nsbinding instanceof ICPPNamespace) { if (nsbinding instanceof ICPPNamespace) {
ICPPNamespace nsbindingAdapted = (ICPPNamespace) index.adaptBinding(nsbinding); ICPPNamespace nsbindingAdapted = (ICPPNamespace) index.adaptBinding(nsbinding);
if (nsbindingAdapted!=null) { if (nsbindingAdapted!=null) {
IBinding[] bindings = nsbindingAdapted.getNamespaceScope().find(name.toString()); IBinding[] bindings = nsbindingAdapted.getNamespaceScope().find(new String(nchars));
if (fileSet != null) { if (fileSet != null) {
bindings= fileSet.filterFileLocalBindings(bindings); bindings= fileSet.filterFileLocalBindings(bindings);
} }
@ -176,7 +174,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
} }
public IBinding getBindingInAST(IASTName name, boolean forceResolve) throws DOMException { public IBinding getBindingInAST(IASTName name, boolean forceResolve) throws DOMException {
char[] c = name.toCharArray(); char[] c = name.getSimpleID();
//can't look up bindings that don't have a name //can't look up bindings that don't have a name
if (c.length == 0) if (c.length == 0)
return null; return null;
@ -236,9 +234,10 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
if (physicalNode instanceof IASTTranslationUnit) { if (physicalNode instanceof IASTTranslationUnit) {
try { try {
IndexFilter filter = IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE; IndexFilter filter = IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE;
final char[] nchars = name.getSimpleID();
IBinding[] bindings = prefixLookup ? IBinding[] bindings = prefixLookup ?
index.findBindingsForPrefix(name.toCharArray(), true, filter, null) : index.findBindingsForPrefix(nchars, true, filter, null) :
index.findBindings(name.toCharArray(), filter, null); index.findBindings(nchars, filter, null);
if (fileSet != null) { if (fileSet != null) {
bindings= fileSet.filterFileLocalBindings(bindings); bindings= fileSet.filterFileLocalBindings(bindings);
} }
@ -270,7 +269,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
public IBinding[] getBindingsInAST(IASTName name, boolean forceResolve, boolean prefixLookup) public IBinding[] getBindingsInAST(IASTName name, boolean forceResolve, boolean prefixLookup)
throws DOMException { throws DOMException {
char[] c = name.toCharArray(); char[] c = name.getSimpleID();
IBinding[] result = null; IBinding[] result = null;
Object[] obj = null; Object[] obj = null;
@ -294,11 +293,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
for (int j = 0; j < os.size(); j++) { for (int j = 0; j < os.size(); j++) {
Object o = os.keyAt(j); Object o = os.keyAt(j);
if (o instanceof IASTName) { if (o instanceof IASTName) {
IASTName n = (IASTName) o; IASTName n = ((IASTName) o).getLastName();
if (n instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
n = ns[ns.length - 1];
}
IBinding binding = forceResolve ? n.resolveBinding() : n.getBinding(); IBinding binding = forceResolve ? n.resolveBinding() : n.getBinding();
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
} else { } else {
@ -310,11 +305,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
if (forceResolve && element != name && element != name.getParent()) { if (forceResolve && element != name && element != name.getParent()) {
binding = ((IASTName) element).resolveBinding(); binding = ((IASTName) element).resolveBinding();
} else { } else {
IASTName n = (IASTName) element; IASTName n = ((IASTName) element).getLastName();
if (n instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
n = ns[ns.length - 1];
}
binding = n.getBinding(); binding = n.getBinding();
} }
if (binding instanceof ICPPUsingDeclaration) { if (binding instanceof ICPPUsingDeclaration) {

View file

@ -183,14 +183,14 @@ public class CPPScopeMapper {
StringBuilder buf= new StringBuilder(); StringBuilder buf= new StringBuilder();
IName scopeName = scope.getScopeName(); IName scopeName = scope.getScopeName();
if (scopeName != null) { if (scopeName != null) {
buf.append(scopeName.toCharArray()); buf.append(scopeName.getSimpleID());
} }
scope= scope.getParent(); scope= scope.getParent();
while (scope != null && scope != tuscope) { while (scope != null && scope != tuscope) {
buf.append(':'); buf.append(':');
scopeName= scope.getScopeName(); scopeName= scope.getScopeName();
if (scopeName != null) { if (scopeName != null) {
buf.append(scope.getScopeName().toCharArray()); buf.append(scope.getScopeName().getSimpleID());
} }
scope= scope.getParent(); scope= scope.getParent();
} }

View file

@ -134,14 +134,14 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName() * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/ */
public String getName() { public String getName() {
return getTemplateName().toString(); return new String(getNameCharArray());
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray() * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
*/ */
public char[] getNameCharArray() { public char[] getNameCharArray() {
return getTemplateName().toCharArray(); return getTemplateName().getSimpleID();
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -92,14 +92,14 @@ public abstract class CPPTemplateParameter extends PlatformObject
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName() * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/ */
public String getName() { public String getName() {
return declarations[0].toString(); return new String(getNameCharArray());
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray() * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
*/ */
public char[] getNameCharArray() { public char[] getNameCharArray() {
return declarations[0].toCharArray(); return declarations[0].getSimpleID();
} }
public int getParameterID() { public int getParameterID() {

View file

@ -99,23 +99,14 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName() * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/ */
public String getName() { public String getName() {
return getSimpleName().toString(); return new String(getNameCharArray());
}
private IASTName getSimpleName() {
IASTName name= declarations[0];
if (name instanceof ICPPASTQualifiedName) {
IASTName[] na= ((ICPPASTQualifiedName) name).getNames();
name= na[na.length-1];
}
return name;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray() * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
*/ */
public char[] getNameCharArray() { public char[] getNameCharArray() {
return getSimpleName().toCharArray(); return declarations[0].getSimpleID();
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -75,7 +75,7 @@ public class CPPUnknownBinding extends PlatformObject
} }
public char[] getNameCharArray() { public char[] getNameCharArray() {
return name.toCharArray(); return name.getSimpleID();
} }
public IScope getScope() throws DOMException { public IScope getScope() throws DOMException {

View file

@ -147,7 +147,7 @@ public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
if (map == null) if (map == null)
map = new CharArrayObjectMap(2); map = new CharArrayObjectMap(2);
char[] c = name.toCharArray(); char[] c = name.getSimpleID();
IBinding[] o= (IBinding[]) map.get(c); IBinding[] o= (IBinding[]) map.get(c);
if (o == null) { if (o == null) {
o= new IBinding[3]; o= new IBinding[3];

View file

@ -64,11 +64,11 @@ public class CPPUsingDeclaration extends PlatformObject implements ICPPUsingDecl
} }
public String getName() { public String getName() {
return name.toString(); return new String(getNameCharArray());
} }
public char[] getNameCharArray() { public char[] getNameCharArray() {
return name.toCharArray(); return name.getSimpleID();
} }
public IScope getScope() { public IScope getScope() {

View file

@ -216,16 +216,7 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName() * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/ */
public String getName() { public String getName() {
if (declarations != null) { return new String(getNameCharArray());
return declarations[0].toString();
}
IASTName name = definition;
if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
name = ns[ns.length - 1];
}
return name.toString();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -233,15 +224,9 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
*/ */
public char[] getNameCharArray() { public char[] getNameCharArray() {
if (declarations != null) { if (declarations != null) {
return declarations[0].toCharArray(); return declarations[0].getSimpleID();
} }
IASTName name = definition; return definition.getSimpleID();
if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
name = ns[ns.length - 1];
}
return name.toCharArray();
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -220,8 +220,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* @throws BacktrackException request a backtrack * @throws BacktrackException request a backtrack
*/ */
private IASTName qualifiedName() throws BacktrackException, EndOfFileException { private IASTName qualifiedName() throws BacktrackException, EndOfFileException {
// mstodo
IToken first= LA(1);
ICPPASTQualifiedName qname= null; ICPPASTQualifiedName qname= null;
IASTName name= null; IASTName name= null;
final int offset= LA(1).getOffset(); final int offset= LA(1).getOffset();
@ -293,8 +291,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return name; return name;
setRange(qname, offset, endOffset); setRange(qname, offset, endOffset);
// mstodo
((CPPASTQualifiedName) qname).setSignature(new String(computeOperatorImage(first, LA(1))));
return qname; return qname;
} }
@ -579,41 +575,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (typeId == null) if (typeId == null)
throwBacktrack(t); throwBacktrack(t);
char[] image= computeOperatorImage(firstToken, LA(1)); IASTName name = nodeFactory.newConversionName(typeId);
IASTName name = nodeFactory.newConversionName(image, typeId);
setRange(name, firstToken.getOffset(), calculateEndOffset(typeId)); setRange(name, firstToken.getOffset(), calculateEndOffset(typeId));
return name; return name;
} }
private char[] computeOperatorImage(IToken from, final IToken to) throws EndOfFileException {
if(from == to)
return CharArrayUtils.EMPTY;
StringBuilder buf= new StringBuilder();
int prevKind= -1;
while (from != to && from != null) {
final int nextKind= from.getType();
if (prevKind != -1 &&
prevKind != IToken.tCOLONCOLON &&
prevKind != IToken.tIDENTIFIER &&
prevKind != IToken.tLT &&
prevKind != IToken.tBITCOMPLEMENT &&
prevKind != IToken.tLBRACKET &&
nextKind != IToken.tGT &&
nextKind != IToken.tRBRACKET &&
nextKind != IToken.tCOLONCOLON) {
buf.append(' ');
}
buf.append(from.getCharImage());
prevKind= nextKind;
from= from.getNext();
}
final int len= buf.length();
final char[] result= new char[len];
buf.getChars(0, len, result, 0);
return result;
}
@Override @Override
protected IASTExpression expression() throws EndOfFileException, BacktrackException { protected IASTExpression expression() throws EndOfFileException, BacktrackException {
final boolean wasOnTop= onTopInTemplateArgs; final boolean wasOnTop= onTopInTemplateArgs;
@ -2316,7 +2282,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
} }
identifier= qualifiedName(); identifier= qualifiedName();
if (identifier.getLastName().toCharArray().length == 0 && LT(1) != IToken.tEOC) if (identifier.getSimpleID().length == 0 && LT(1) != IToken.tEOC)
throwBacktrack(LA(1)); throwBacktrack(LA(1));
endOffset= calculateEndOffset(identifier); endOffset= calculateEndOffset(identifier);
@ -2427,23 +2393,22 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name; final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
final IASTName names[]= qname.getNames(); final IASTName names[]= qname.getNames();
final int len = names.length; final int len = names.length;
if (len > 1 && CharArrayUtils.equals(names[len-2].toCharArray(), names[len-1].toCharArray())) final IASTName lastName = names[len-1];
if (len > 1 && CharArrayUtils.equals(CPPASTNameBase.getLookupKey(names[len-2]), CPPASTNameBase.getLookupKey(lastName)))
return true; // constructor return true; // constructor
name= qname.getLastName(); name= lastName;
}
if (name instanceof ICPPASTConversionName)
return true; // conversion
if (name instanceof ICPPASTTemplateId) {
if (((ICPPASTTemplateId) name).getTemplateName() instanceof ICPPASTConversionName) {
return true;
} }
if (name instanceof ICPPASTTemplateId)
name= ((ICPPASTTemplateId) name).getTemplateName();
} if (name instanceof ICPPASTConversionName)
final char[] nchars= name.toCharArray(); return true;
final char[] nchars= name.getSimpleID();
if (nchars.length > 0 && nchars[0] == '~') if (nchars.length > 0 && nchars[0] == '~')
return true; // destructor return true; // destructor
if (declOption == DeclarationOptions.CPP_MEMBER && CharArrayUtils.equals(nchars, currentClassName)) if (declOption == DeclarationOptions.CPP_MEMBER && CharArrayUtils.equals(nchars, currentClassName))
return true; return true;
} }
@ -2977,7 +2942,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (coloncolon != 0) { if (coloncolon != 0) {
try { try {
name= qualifiedName(); name= qualifiedName();
if (name.getLastName().toCharArray().length != 0) { if (CPPASTNameBase.getLookupKey(name).length != 0) {
backup(mark); backup(mark);
return; return;
} }
@ -3321,11 +3286,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
int endOffset= consume().getEndOffset(); int endOffset= consume().getEndOffset();
final char[] outerName= currentClassName; final char[] outerName= currentClassName;
if (name instanceof ICPPASTQualifiedName) { currentClassName= name.getSimpleID();
currentClassName= ((ICPPASTQualifiedName)name).getLastName().toCharArray();
} else {
currentClassName= name.toCharArray();
}
try { try {
int declOffset= -1; int declOffset= -1;
loop: while (true) { loop: while (true) {
@ -3397,7 +3359,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return astClassSpecifier; return astClassSpecifier;
} }
protected int token2Visibility(int type) { protected int token2Visibility(int type) {
switch (type) { switch (type) {
case IToken.t_public: case IToken.t_public:

View file

@ -591,7 +591,7 @@ public class CPPSemantics {
so= map.get(key); so= map.get(key);
} else if (objs != null) { } else if (objs != null) {
so= objs[i]; so= objs[i];
key= (so instanceof IBinding) ? ((IBinding) so).getNameCharArray() : ((IASTName) so).toCharArray(); key= (so instanceof IBinding) ? ((IBinding) so).getNameCharArray() : ((IASTName) so).getSimpleID();
} else { } else {
return resultMap; return resultMap;
} }
@ -1189,7 +1189,7 @@ public class CPPSemantics {
nsscope.addUsingDirective(new CPPUsingDirective(usingDirective)); nsscope.addUsingDirective(new CPPUsingDirective(usingDirective));
} }
} else if (item instanceof ICPPASTNamespaceDefinition && } else if (item instanceof ICPPASTNamespaceDefinition &&
((ICPPASTNamespaceDefinition)item).getName().toCharArray().length == 0) { ((ICPPASTNamespaceDefinition)item).getName().getSimpleID().length == 0) {
if (scope instanceof ICPPNamespaceScope) { if (scope instanceof ICPPNamespaceScope) {
final ICPPNamespaceScope nsscope = (ICPPNamespaceScope)scope; final ICPPNamespaceScope nsscope = (ICPPNamespaceScope)scope;
final ICPPASTNamespaceDefinition nsdef= (ICPPASTNamespaceDefinition) item; final ICPPASTNamespaceDefinition nsdef= (ICPPASTNamespaceDefinition) item;
@ -1414,7 +1414,7 @@ public class CPPSemantics {
//anonymous union? //GCC supports anonymous structs too //anonymous union? //GCC supports anonymous structs too
if (declarators.length == 0 && /*compSpec.getKey() == IASTCompositeTypeSpecifier.k_union &&*/ if (declarators.length == 0 && /*compSpec.getKey() == IASTCompositeTypeSpecifier.k_union &&*/
specName.toCharArray().length == 0) specName.getSimpleID().length == 0)
{ {
Object o = null; Object o = null;
IASTDeclaration[] decls = compSpec.getMembers(); IASTDeclaration[] decls = compSpec.getMembers();
@ -1531,7 +1531,7 @@ public class CPPSemantics {
potential= qname.getLastName(); potential= qname.getLastName();
} }
char[] c = potential.toCharArray(); char[] c = potential.getSimpleID();
char[] n = data.name(); char[] n = data.name();
return (data.prefixLookup && CharArrayUtils.equals(c, 0, n.length, n, true)) return (data.prefixLookup && CharArrayUtils.equals(c, 0, n.length, n, true))
|| (!data.prefixLookup && CharArrayUtils.equals(c, n)); || (!data.prefixLookup && CharArrayUtils.equals(c, n));

View file

@ -1083,7 +1083,7 @@ public class CPPTemplates {
for (ICPPASTTemplateParameter par : pars) { for (ICPPASTTemplateParameter par : pars) {
IASTName name= CPPTemplates.getTemplateParameterName(par); IASTName name= CPPTemplates.getTemplateParameterName(par);
if (name != null) if (name != null)
set.put(name.toCharArray()); set.put(name.getSimpleID());
} }
final IASTNode next= tdecl.getDeclaration(); final IASTNode next= tdecl.getDeclaration();
if (next instanceof ICPPASTTemplateDeclaration) { if (next instanceof ICPPASTTemplateDeclaration) {
@ -1110,7 +1110,7 @@ public class CPPTemplates {
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
if (names.containsKey(name.toCharArray())) { if (names.containsKey(name.getSimpleID())) {
IASTNode parent= name.getParent(); IASTNode parent= name.getParent();
if (parent instanceof ICPPASTQualifiedName) { if (parent instanceof ICPPASTQualifiedName) {
if (((ICPPASTQualifiedName) parent).getNames()[0] != name) { if (((ICPPASTQualifiedName) parent).getNames()[0] != name) {
@ -1289,7 +1289,7 @@ public class CPPTemplates {
return true; return true;
} }
return CharArrayUtils.equals(definition.getNameCharArray(), name.toCharArray()); return CharArrayUtils.equals(definition.getNameCharArray(), name.getSimpleID());
} }
} catch (DOMException e) { } catch (DOMException e) {
} }

View file

@ -267,7 +267,7 @@ public class CPPVisitor extends ASTQueries {
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent); return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
} }
if (name.toCharArray().length > 0) if (name.getSimpleID().length > 0)
return binding; return binding;
return null; return null;
} }
@ -444,7 +444,7 @@ public class CPPVisitor extends ASTQueries {
if (name instanceof ICPPASTTemplateId) { if (name instanceof ICPPASTTemplateId) {
return CPPTemplates.createBinding((ICPPASTTemplateId) name); return CPPTemplates.createBinding((ICPPASTTemplateId) name);
} }
if (name.toCharArray().length > 0 && scope != null) //can't lookup anonymous things if (name.getSimpleID().length > 0 && scope != null) //can't lookup anonymous things
binding = scope.getBinding(name, false); binding = scope.getBinding(name, false);
if (!(binding instanceof ICPPInternalBinding) || !(binding instanceof ICPPClassType)) { if (!(binding instanceof ICPPInternalBinding) || !(binding instanceof ICPPClassType)) {
if (template) { if (template) {
@ -732,11 +732,7 @@ public class CPPVisitor extends ASTQueries {
return false; return false;
IASTName name = findInnermostDeclarator(declarator).getName(); IASTName name = findInnermostDeclarator(declarator).getName();
if (name instanceof ICPPASTQualifiedName) { if (!CharArrayUtils.equals(CPPASTNameBase.getLookupKey(name), CPPASTNameBase.getLookupKey(parentName)))
IASTName[] names = ((ICPPASTQualifiedName)name).getNames();
name = names[names.length - 1];
}
if (!CharArrayUtils.equals(name.toCharArray(), parentName.toCharArray()))
return false; return false;
IASTDeclSpecifier declSpec = null; IASTDeclSpecifier declSpec = null;

View file

@ -115,7 +115,7 @@ class LookupData {
public final char[] name() { public final char[] name() {
if (astName != null) if (astName != null)
return astName.toCharArray(); return astName.getSimpleID();
return CPPSemantics.EMPTY_NAME_ARRAY; return CPPSemantics.EMPTY_NAME_ARRAY;
} }

View file

@ -62,6 +62,10 @@ class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName {
public char[] toCharArray() { public char[] toCharArray() {
return fName; return fName;
} }
public char[] getSimpleID() {
return fName;
}
@Override @Override
public String toString() { public String toString() {
return new String(fName); return new String(fName);

View file

@ -406,7 +406,7 @@ class ASTFunctionStyleMacroDefinition extends ASTMacroDefinition implements IAST
@Override @Override
public String toString() { public String toString() {
StringBuilder result= new StringBuilder(); StringBuilder result= new StringBuilder();
result.append(getName().toCharArray()); result.append(getName().getSimpleID());
result.append('('); result.append('(');
boolean needComma= false; boolean needComma= false;
for (IASTFunctionStyleMacroParameter param : getParameters()) { for (IASTFunctionStyleMacroParameter param : getParameters()) {

View file

@ -60,7 +60,7 @@ public class SingleMacroExpansionExplorer extends MacroExpansionExplorer {
private void addMacroDefinition(CharArrayMap<PreprocessorMacro> map, IASTName name) { private void addMacroDefinition(CharArrayMap<PreprocessorMacro> map, IASTName name) {
IBinding binding= name.getBinding(); IBinding binding= name.getBinding();
if (binding instanceof PreprocessorMacro) { if (binding instanceof PreprocessorMacro) {
map.put(name.toCharArray(), (PreprocessorMacro) binding); map.put(name.getSimpleID(), (PreprocessorMacro) binding);
} }
} }

View file

@ -380,7 +380,7 @@ public class PDOM extends PlatformObject implements IPDOM {
} else if (name.getPropertyInParent() == IASTPreprocessorStatement.MACRO_NAME) { } else if (name.getPropertyInParent() == IASTPreprocessorStatement.MACRO_NAME) {
PDOMLinkage linkage= adaptLinkage(name.getLinkage()); PDOMLinkage linkage= adaptLinkage(name.getLinkage());
if (linkage != null) { if (linkage != null) {
return linkage.findMacroContainer(name.toCharArray()); return linkage.findMacroContainer(name.getSimpleID());
} }
} }
return null; return null;

View file

@ -38,6 +38,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
public class PDOMASTAdapter { public class PDOMASTAdapter {
@ -162,6 +163,10 @@ public class PDOMASTAdapter {
return fDelegate.toCharArray(); return fDelegate.toCharArray();
} }
public char[] getSimpleID() {
return fDelegate.getSimpleID();
}
public IASTImageLocation getImageLocation() { public IASTImageLocation getImageLocation() {
return null; return null;
} }
@ -494,7 +499,7 @@ public class PDOMASTAdapter {
* it is returned unchanged. * it is returned unchanged.
*/ */
public static IASTName getAdapterIfAnonymous(IASTName name) { public static IASTName getAdapterIfAnonymous(IASTName name) {
if (name.toCharArray().length == 0) { if (CPPASTNameBase.getLookupKey(name).length == 0) {
if (name.getFileLocation() == null) { if (name.getFileLocation() == null) {
IASTNode parent= name.getParent(); IASTNode parent= name.getParent();
if (parent != null) { if (parent != null) {

View file

@ -241,11 +241,11 @@ public class PDOMFile implements IIndexFragmentFile {
PDOMMacro pdomMacro= null; PDOMMacro pdomMacro= null;
if (stmt instanceof IASTPreprocessorMacroDefinition) { if (stmt instanceof IASTPreprocessorMacroDefinition) {
IASTPreprocessorMacroDefinition macro= (IASTPreprocessorMacroDefinition) stmt; IASTPreprocessorMacroDefinition macro= (IASTPreprocessorMacroDefinition) stmt;
PDOMMacroContainer container= linkage.getMacroContainer(macro.getName().toCharArray()); PDOMMacroContainer container= linkage.getMacroContainer(macro.getName().getSimpleID());
pdomMacro = new PDOMMacro(pdom, container, macro, this); pdomMacro = new PDOMMacro(pdom, container, macro, this);
} else if (stmt instanceof IASTPreprocessorUndefStatement) { } else if (stmt instanceof IASTPreprocessorUndefStatement) {
IASTPreprocessorUndefStatement undef= (IASTPreprocessorUndefStatement) stmt; IASTPreprocessorUndefStatement undef= (IASTPreprocessorUndefStatement) stmt;
PDOMMacroContainer container= linkage.getMacroContainer(undef.getMacroName().toCharArray()); PDOMMacroContainer container= linkage.getMacroContainer(undef.getMacroName().getSimpleID());
pdomMacro = new PDOMMacro(pdom, container, undef, this); pdomMacro = new PDOMMacro(pdom, container, undef, this);
} }
if (pdomMacro != null) { if (pdomMacro != null) {
@ -326,7 +326,7 @@ public class PDOMFile implements IIndexFragmentFile {
} }
private IIndexFragmentName createPDOMMacroReferenceName(PDOMLinkage linkage, IASTName name) throws CoreException { private IIndexFragmentName createPDOMMacroReferenceName(PDOMLinkage linkage, IASTName name) throws CoreException {
PDOMMacroContainer cont= linkage.getMacroContainer(name.toCharArray()); PDOMMacroContainer cont= linkage.getMacroContainer(name.getSimpleID());
return new PDOMMacroReferenceName(pdom, name, this, cont); return new PDOMMacroReferenceName(pdom, name, this, cont);
} }

View file

@ -69,7 +69,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
setFlag(encodeFlags(include, targetFile == null)); setFlag(encodeFlags(include, targetFile == null));
setIncludedBy(containerFile); setIncludedBy(containerFile);
setIncludes(targetFile, name.toCharArray()); setIncludes(targetFile, name.getSimpleID());
} }
private byte encodeFlags(IASTPreprocessorIncludeStatement include, boolean unresolved) { private byte encodeFlags(IASTPreprocessorIncludeStatement include, boolean unresolved) {

View file

@ -68,9 +68,19 @@ class PDOMMacroDefinitionName implements IIndexFragmentName {
public boolean isReference() { public boolean isReference() {
return false; return false;
} }
@Deprecated
public char[] toCharArray() { public char[] toCharArray() {
return fMacro.getNameCharArray(); return fMacro.getNameCharArray();
} }
@Override
public String toString() {
return new String(getSimpleID());
}
public char[] getSimpleID() {
return fMacro.getNameCharArray();
}
public IIndexFragmentBinding getBinding() { public IIndexFragmentBinding getBinding() {
return fMacro; return fMacro;
} }

View file

@ -122,7 +122,15 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
setNameField(FILE_NEXT_OFFSET, name); setNameField(FILE_NEXT_OFFSET, name);
} }
/**
* @deprecated use {@link #getSimpleID()}.
*/
@Deprecated
public char[] toCharArray() { public char[] toCharArray() {
return getSimpleID();
}
public char[] getSimpleID() {
try { try {
return getContainer().getNameCharArray(); return getContainer().getNameCharArray();
} catch (CoreException e) { } catch (CoreException e) {
@ -133,7 +141,7 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
@Override @Override
public String toString() { public String toString() {
return new String(toCharArray()); return new String(getSimpleID());
} }
public boolean isBaseSpecifier() throws CoreException { public boolean isBaseSpecifier() throws CoreException {

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexFragmentName; import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -181,7 +182,15 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
setNameField(FILE_NEXT_OFFSET, name); setNameField(FILE_NEXT_OFFSET, name);
} }
/**
* @deprecated use {@link #getSimpleID()}, instead.
*/
@Deprecated
public char[] toCharArray() { public char[] toCharArray() {
return getSimpleID();
}
public char[] getSimpleID() {
try { try {
Database db = pdom.getDB(); Database db = pdom.getDB();
int bindingRec = db.getInt(record + BINDING_REC_OFFSET); int bindingRec = db.getInt(record + BINDING_REC_OFFSET);
@ -189,21 +198,13 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
return binding != null ? binding.getNameCharArray() : null; return binding != null ? binding.getNameCharArray() : null;
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
return null; return CharArrayUtils.EMPTY;
} }
} }
@Override @Override
public String toString() { public String toString() {
try { return new String(getSimpleID());
Database db = pdom.getDB();
int bindingRec = db.getInt(record + BINDING_REC_OFFSET);
PDOMBinding binding = pdom.getBinding(bindingRec);
return binding != null ? binding.getName() : null;
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
}
} }
private int getFlags(int mask) throws CoreException { private int getFlags(int mask) throws CoreException {

View file

@ -161,7 +161,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
if (name == null) if (name == null)
return null; return null;
char[] namechars = name.toCharArray(); char[] namechars = name.getSimpleID();
if (namechars == null) if (namechars == null)
return null; return null;

View file

@ -75,7 +75,7 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope {
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException { public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
try { try {
final char[] nameChars = name.toCharArray(); final char[] nameChars = name.getSimpleID();
if (CharArrayUtils.equals(fBinding.getNameCharArray(), nameChars)) { if (CharArrayUtils.equals(fBinding.getNameCharArray(), nameChars)) {
if (CPPClassScope.isConstructorReference(name)){ if (CPPClassScope.isConstructorReference(name)){
return CPPSemantics.resolveAmbiguities(name, fBinding.getConstructors()); return CPPSemantics.resolveAmbiguities(name, fBinding.getConstructors());
@ -99,7 +99,7 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope {
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException { public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException {
IBinding[] result = null; IBinding[] result = null;
try { try {
final char[] nameChars = name.toCharArray(); final char[] nameChars = name.getSimpleID();
if (!prefixLookup) { if (!prefixLookup) {
return getBindingsViaCache(fBinding, nameChars, IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE); return getBindingsViaCache(fBinding, nameChars, IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE);
} }

View file

@ -204,11 +204,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (name == null || name instanceof ICPPASTQualifiedName) if (name == null || name instanceof ICPPASTQualifiedName)
return null; return null;
// Check for null name
char[] namechars = name.toCharArray();
if (namechars == null)
return null;
IBinding binding = name.resolveBinding(); IBinding binding = name.resolveBinding();
PDOMBinding pdomBinding = addBinding(binding, name); PDOMBinding pdomBinding = addBinding(binding, name);

View file

@ -129,7 +129,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
@Override @Override
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException { public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
try { try {
IBinding[] bindings= getBindingsViaCache(name.toCharArray()); IBinding[] bindings= getBindingsViaCache(name.getSimpleID());
if (fileSet != null) { if (fileSet != null) {
bindings= fileSet.filterFileLocalBindings(bindings); bindings= fileSet.filterFileLocalBindings(bindings);
} }
@ -146,9 +146,9 @@ class PDOMCPPNamespace extends PDOMCPPBinding
IBinding[] result = null; IBinding[] result = null;
try { try {
if (!prefixLookup) { if (!prefixLookup) {
return getBindingsViaCache(name.toCharArray()); return getBindingsViaCache(name.getSimpleID());
} }
BindingCollector visitor= new BindingCollector(getLinkageImpl(), name.toCharArray(), BindingCollector visitor= new BindingCollector(getLinkageImpl(), name.getSimpleID(),
IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, prefixLookup, !prefixLookup); IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, prefixLookup, !prefixLookup);
getIndex().accept(visitor); getIndex().accept(visitor);
IBinding[] bindings = visitor.getBindings(); IBinding[] bindings = visitor.getBindings();

View file

@ -470,7 +470,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
} }
} }
IASTName name= node.getName(); IASTName name= node.getName();
if (name != null && name.toCharArray().length != 0) { if (name != null && name.getSimpleID().length != 0) {
if (isFirstDeclarator(node)) { if (isFirstDeclarator(node)) {
// preserve non-space between pointer operator and name // preserve non-space between pointer operator and name
if (pointerOperators.length == 0 || scribe.printComment()) { if (pointerOperators.length == 0 || scribe.printComment()) {

View file

@ -30,8 +30,10 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTCastExpression; import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
@ -56,6 +58,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer; import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator; import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
@ -130,10 +133,10 @@ public class DOMASTNodeLeaf implements IAdaptable {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
List<Class<?>> search= new LinkedList<Class<?>>(); List<Class<?>> search= new LinkedList<Class<?>>();
boolean done= false; boolean done= false;
boolean needComma= false;
for (search.add(node.getClass()); !search.isEmpty(); ) { for (search.add(node.getClass()); !search.isEmpty(); ) {
Class<?> clazz= search.remove(0); Class<?> clazz= search.remove(0);
boolean needComma= false;
if (clazz.isInterface()) { if (clazz.isInterface()) {
if (clazz.getPackage().toString().indexOf(INTERNAL) < 0) { if (clazz.getPackage().toString().indexOf(INTERNAL) < 0) {
String interfaceName= clazz.getName(); String interfaceName= clazz.getName();
@ -197,7 +200,7 @@ public class DOMASTNodeLeaf implements IAdaptable {
} else if( node instanceof IASTDeclSpecifier ) } else if( node instanceof IASTDeclSpecifier )
{ {
buffer.append( START_OF_LIST ); buffer.append( START_OF_LIST );
buffer.append( ((IASTDeclSpecifier)node).getRawSignature() ); buffer.append( getSignature((IASTDeclSpecifier)node) );
return buffer.toString(); return buffer.toString();
} else if ( node instanceof IASTPreprocessorIncludeStatement ) { } else if ( node instanceof IASTPreprocessorIncludeStatement ) {
String path = ((IASTPreprocessorIncludeStatement)node).getPath(); String path = ((IASTPreprocessorIncludeStatement)node).getPath();
@ -288,6 +291,35 @@ public class DOMASTNodeLeaf implements IAdaptable {
return buffer.toString(); return buffer.toString();
} }
private String getSignature(IASTDeclSpecifier declSpec) {
if (declSpec instanceof IASTCompositeTypeSpecifier) {
StringBuilder buf= new StringBuilder();
IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) declSpec;
switch(comp.getKey()) {
case IASTCompositeTypeSpecifier.k_struct:
buf.append(Keywords.cSTRUCT);
break;
case IASTCompositeTypeSpecifier.k_union:
buf.append(Keywords.cUNION);
break;
default:
buf.append(Keywords.cCLASS);
break;
}
buf.append(' ');
buf.append(comp.getName().toString());
return buf.toString();
} else if (declSpec instanceof IASTEnumerationSpecifier) {
StringBuilder buf= new StringBuilder();
IASTEnumerationSpecifier comp = (IASTEnumerationSpecifier) declSpec;
buf.append(Keywords.cENUM);
buf.append(' ');
buf.append(comp.getName().toString());
return buf.toString();
}
String intermed= declSpec.getRawSignature();
return intermed.replaceAll("\\s+", " ");
}
private String getDeclaratorName(IASTDeclarator decltor) { private String getDeclaratorName(IASTDeclarator decltor) {
String name = BLANK_STRING; String name = BLANK_STRING;

View file

@ -68,7 +68,7 @@ class TrailName extends CPPASTName {
} }
@Override @Override
public String toString() { public char[] toCharArray() {
return realName.toString(); return realName.toCharArray();
} }
} }

View file

@ -96,7 +96,7 @@ public class SelectionParseAction extends Action {
IASTFileLocation fileloc = name.getFileLocation(); IASTFileLocation fileloc = name.getFileLocation();
if (fileloc == null) { if (fileloc == null) {
reportSymbolLookupFailure(new String(name.toCharArray())); reportSymbolLookupFailure(name.toString());
return; return;
} }

View file

@ -271,7 +271,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
int nodeLength= fileLocation.getNodeLength(); int nodeLength= fileLocation.getNodeLength();
String fileName= fileLocation.getFileName(); String fileName= fileLocation.getFileName();
if (DEBUG) System.out.println("[CSourceHover] Computing source for " + new String(name.toCharArray()) + " in " + fileName); //$NON-NLS-1$//$NON-NLS-2$ if (DEBUG) System.out.println("[CSourceHover] Computing source for " + name + " in " + fileName); //$NON-NLS-1$//$NON-NLS-2$
IPath location= Path.fromOSString(fileName); IPath location= Path.fromOSString(fileName);
LocationKind locationKind= LocationKind.LOCATION; LocationKind locationKind= LocationKind.LOCATION;
if (name instanceof IASTName && !name.isReference()) { if (name instanceof IASTName && !name.isReference()) {

View file

@ -188,7 +188,7 @@ public class IndexUI {
IIndexName[] names= file.findNames(region.getOffset(), region.getLength()); IIndexName[] names= file.findNames(region.getOffset(), region.getLength());
for (int j = 0; j < names.length; j++) { for (int j = 0; j < names.length; j++) {
IIndexName name = names[j]; IIndexName name = names[j];
if (!name.isReference() && elementName.endsWith(new String(name.toCharArray()))) { if (!name.isReference() && elementName.endsWith(new String(name.getSimpleID()))) {
return name; return name;
} }
} }

View file

@ -12,7 +12,51 @@ package org.eclipse.cdt.core.dom.lrparser.action.cpp;
import static org.eclipse.cdt.core.parser.util.CollectionUtils.findFirstAndRemove; import static org.eclipse.cdt.core.parser.util.CollectionUtils.findFirstAndRemove;
import static org.eclipse.cdt.core.parser.util.CollectionUtils.reverseIterable; import static org.eclipse.cdt.core.parser.util.CollectionUtils.reverseIterable;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.*; import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_ColonColon;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_Completion;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_EndOfCompletion;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_GT;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_LT;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_LeftBracket;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_LeftParen;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_RightBracket;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_RightParen;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_Tilde;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_auto;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_bool;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_char;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_class;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_const;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_delete;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_double;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_enum;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_explicit;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_extern;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_float;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_for;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_friend;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_identifier;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_inline;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_int;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_long;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_mutable;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_new;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_private;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_protected;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_public;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_register;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_short;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_signed;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_static;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_struct;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_typedef;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_typename;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_union;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_unsigned;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_virtual;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_void;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_volatile;
import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_wchar_t;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
@ -28,7 +72,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTForStatement; import org.eclipse.cdt.core.dom.ast.IASTForStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
@ -68,7 +111,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
@ -87,6 +129,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.lrparser.IParser; import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider; import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
@ -490,11 +533,12 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
public void consumeConversionName() { public void consumeConversionName() {
if(TRACE_ACTIONS) DebugUtil.printMethodTrace(); if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
String rep = createStringRepresentation(parser.getRuleTokens()); // Representation is computed by the conversion name itself, see bug 258054
char[] chars = rep.toCharArray(); // String rep = createStringRepresentation(parser.getRuleTokens());
// char[] chars = rep.toCharArray();
IASTTypeId typeId = (IASTTypeId) astStack.pop(); IASTTypeId typeId = (IASTTypeId) astStack.pop();
ICPPASTConversionName name = nodeFactory.newConversionName(chars, typeId); ICPPASTConversionName name = nodeFactory.newConversionName(typeId);
setOffsetAndLength(name); setOffsetAndLength(name);
astStack.push(name); astStack.push(name);