mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Correcting IASTName.toCharArray(), bug 258054.
This commit is contained in:
parent
ed9ade92a2
commit
416bf3a0e0
82 changed files with 588 additions and 567 deletions
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
|||
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.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.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
@ -127,6 +128,9 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
|||
NULL_LOG, config );
|
||||
}
|
||||
|
||||
if (expectedProblemBindings > 0)
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
|
||||
IASTTranslationUnit tu = parser2.parse();
|
||||
|
||||
// resolve all bindings
|
||||
|
|
|
@ -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.util.ObjectMap;
|
||||
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.ICPPInternalUnknownScope;
|
||||
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*, int*, 2> a5; //ambiguous, matches #3 & #5.
|
||||
public void test_14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
@ -1765,6 +1768,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testBug98666() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse("A::template B<T> b;", ParserLanguage.CPP); //$NON-NLS-1$
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
@ -1772,7 +1776,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
ICPPASTQualifiedName qn = (ICPPASTQualifiedName) col.getName(0);
|
||||
IASTName[] ns = qn.getNames();
|
||||
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{
|
||||
|
@ -2293,6 +2297,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
//
|
||||
// void f(B<int>::tb r) {}
|
||||
public void testTemplateTypedef_214447() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
|
@ -2326,6 +2331,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
//
|
||||
// void f(Vec<int>::reference r) {}
|
||||
public void testRebindPattern_214447_1() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
|
@ -2365,6 +2371,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
//
|
||||
// void f(Vec<int>::reference r) {}
|
||||
public void testRebindPattern_214447_2() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
|
@ -2403,6 +2410,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
//
|
||||
// void f(map<int>::value_type r) {}
|
||||
public void testRebindPattern_236197() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
@ -2434,6 +2442,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
//
|
||||
// void main(Iter<int*>::iter_reference r);
|
||||
public void testSpecializationSelection_229218() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
@ -2462,6 +2471,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
//
|
||||
// B<int>::b::a x;
|
||||
public void testDefaultTemplateParameter() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
|
@ -2746,6 +2756,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// C c1;
|
||||
// C<> c2; // ok - default args
|
||||
public void testMissingTemplateArgumentLists() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation=true;
|
||||
BindingAssertionHelper ba=new BindingAssertionHelper(getAboveComment(), true);
|
||||
ba.assertProblem("B b1", 1);
|
||||
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
|
||||
public void testTypeArgumentToNonTypeParameter() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation=true;
|
||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||
ba.assertProblem("A<int>", 6);
|
||||
}
|
||||
|
|
|
@ -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.model.ICElement;
|
||||
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.core.resources.IFile;
|
||||
|
||||
|
@ -630,6 +631,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
|
|||
}
|
||||
|
||||
public void testBug72814() throws Exception{
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "namespace N{ \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( ((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);
|
||||
// TODO raised bug 92632 for below
|
||||
// assertEquals(decls.length, 1);
|
||||
|
@ -1740,7 +1743,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
|
|||
assertNotNull( node );
|
||||
assertTrue( node instanceof IASTName );
|
||||
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);
|
||||
assertEquals(decls.length, 1);
|
||||
assertEquals( decls[0].toString(), "AAA" ); //$NON-NLS-1$
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
|||
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.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.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
@ -60,7 +61,14 @@ public class QuickParser2Tests extends TestCase {
|
|||
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
|
||||
* simplest form.
|
||||
*/
|
||||
|
@ -549,6 +557,8 @@ public class QuickParser2Tests extends TestCase {
|
|||
|
||||
public void testBug36704() throws Exception {
|
||||
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("struct Length< Typelist<T, U> >\n");
|
||||
code.write("{\n");
|
||||
|
|
|
@ -21,6 +21,8 @@ import java.util.regex.Pattern;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
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.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
@ -142,7 +144,7 @@ public class CommentHandlingTest extends RewriteBaseTest {
|
|||
for (IASTNode actNode : keyTree) {
|
||||
ArrayList<IASTComment> comments = map.get(actNode);
|
||||
|
||||
output.append(actNode.getRawSignature() + " = "); //$NON-NLS-1$
|
||||
output.append(getSignature(actNode) + " = "); //$NON-NLS-1$
|
||||
boolean first = true;
|
||||
for (IASTComment actComment : comments) {
|
||||
if (!first) {
|
||||
|
@ -156,6 +158,17 @@ public class CommentHandlingTest extends RewriteBaseTest {
|
|||
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() {
|
||||
return LEADING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + TRAILING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + FREESTANDING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP;
|
||||
}
|
||||
|
|
|
@ -153,6 +153,7 @@ template<template <class T> class K> class vector /*TEST 2*/
|
|||
//!Commented TemplateSpecialization 1
|
||||
//%CPP
|
||||
//TEST 1
|
||||
template<typename T> class MyQueue;
|
||||
template<> class MyQueue<double> //TEST 2
|
||||
{
|
||||
//TEST 3
|
||||
|
@ -167,6 +168,7 @@ public:
|
|||
//!Commented TemplateSpecialization 2
|
||||
//%CPP
|
||||
/*TEST 1*/
|
||||
template<typename T> class MyQueue;
|
||||
template<> class MyQueue<double> /*TEST 2*/
|
||||
{
|
||||
/*TEST 3*/
|
||||
|
|
|
@ -54,6 +54,7 @@ template<template <class T> class K> class vector
|
|||
|
||||
//!TemplateSpecialization
|
||||
//%CPP
|
||||
template<typename T> class MyQueue;
|
||||
template<> class MyQueue<double>
|
||||
{
|
||||
std::vector<double> data;
|
||||
|
|
|
@ -57,6 +57,7 @@ public class BaseTestCase extends TestCase {
|
|||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
CPPASTNameBase.sAllowRecursionBindings= false;
|
||||
CPPASTNameBase.sAllowNameComputation= false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -671,7 +671,7 @@ public class ASTStringUtil {
|
|||
}
|
||||
buffer.append(Keywords.cpGT);
|
||||
} else if (name != null) {
|
||||
buffer.append(name.toCharArray());
|
||||
buffer.append(name.getSimpleID());
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public class CElementHandleFactory {
|
|||
return null;
|
||||
}
|
||||
else if (scope instanceof ICPPNamespaceScope) {
|
||||
element= new NamespaceHandle(parentElement, new String(scopeName.toCharArray()));
|
||||
element= new NamespaceHandle(parentElement, new String(scopeName.getSimpleID()));
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
|
|
@ -16,21 +16,23 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
|
||||
/**
|
||||
* 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
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IName {
|
||||
/**
|
||||
* Return a char array representation of the name.
|
||||
*
|
||||
* @return ~ toString().toCharArray()
|
||||
* Returns the name without qualification and without template arguments.
|
||||
* @since 5.1
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,7 @@ public final class ASTNameCollector extends ASTVisitor {
|
|||
@Override
|
||||
public int visit(IASTName name) {
|
||||
if (name != null && !(name instanceof ICPPASTQualifiedName) && !(name instanceof ICPPASTTemplateId)) {
|
||||
if (CharArrayUtils.equals(fName, name.toCharArray())) {
|
||||
if (CharArrayUtils.equals(fName, name.getSimpleID())) {
|
||||
fFound.add(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,24 +13,18 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
|
||||
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.ICBasicType;
|
||||
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.cpp.ICPPBasicType;
|
||||
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.ICPPFunctionScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
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.ICPPTemplateInstance;
|
||||
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.IGPPPointerType;
|
||||
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 {
|
||||
LinkedList<String> result= new LinkedList<String>();
|
||||
result.addFirst(getNameForAnonymous(binding));
|
||||
ICPPScope scope = (ICPPScope) binding.getScope();
|
||||
while (scope != null) {
|
||||
if (scope instanceof ICPPBlockScope || scope instanceof ICPPFunctionScope) {
|
||||
break;
|
||||
}
|
||||
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));
|
||||
|
||||
IBinding owner= binding.getOwner();
|
||||
while(owner instanceof ICPPNamespace || owner instanceof ICPPClassType) {
|
||||
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));
|
||||
}
|
||||
} else {
|
||||
result.addFirst(new String(name));
|
||||
}
|
||||
} else {
|
||||
result.addFirst(new String(name));
|
||||
}
|
||||
scope = (ICPPScope) scope.getParent();
|
||||
owner= owner.getOwner();
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
}
|
||||
|
@ -692,13 +677,6 @@ public class ASTTypeUtil {
|
|||
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) {
|
||||
IASTNode node= null;
|
||||
if (binding instanceof ICInternalBinding) {
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Doug Schaefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public interface IASTDeclSpecifier extends IASTNode {
|
||||
|
@ -117,14 +117,6 @@ public interface IASTDeclSpecifier extends IASTNode {
|
|||
* boolean
|
||||
*/
|
||||
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
|
||||
|
|
|
@ -19,9 +19,6 @@ import org.eclipse.cdt.core.dom.IName;
|
|||
* This class represents a name in the program that represents a semantic object
|
||||
* 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.
|
||||
*/
|
||||
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];
|
||||
|
||||
/**
|
||||
* 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
|
||||
* has not yet been semantically resolved (@see resolveBinding)
|
||||
|
@ -38,12 +46,6 @@ public interface IASTName extends IASTNode, IName {
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
@ -100,4 +102,10 @@ public interface IASTName extends IASTNode, IName {
|
|||
* @since 5.1
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
|
||||
public ICPPASTTemplateId newTemplateId(IASTName templateName);
|
||||
|
||||
public ICPPASTConversionName newConversionName(char[] name, IASTTypeId typeId);
|
||||
public ICPPASTConversionName newConversionName(IASTTypeId typeId);
|
||||
|
||||
public ICPPASTQualifiedName newQualifiedName();
|
||||
|
||||
|
|
|
@ -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.parser.IToken;
|
||||
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.ILocationResolver;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.Lexer;
|
||||
|
@ -143,16 +144,20 @@ public abstract class ASTNode implements IASTNode {
|
|||
return null;
|
||||
}
|
||||
|
||||
public String getRawSignature() {
|
||||
protected char[] getRawSignatureChars() {
|
||||
final IASTFileLocation floc= getFileLocation();
|
||||
final IASTTranslationUnit ast = getTranslationUnit();
|
||||
if (floc != null && ast != null) {
|
||||
ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class);
|
||||
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() {
|
||||
|
|
|
@ -1615,11 +1615,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
}
|
||||
}
|
||||
|
||||
if (dtor.getName().toCharArray().length == 0 && dtor.getNestedDeclarator() == null) {
|
||||
throw new Error();
|
||||
// backup(lastTokenOfExpression); consume();
|
||||
// return expressionStatement;
|
||||
}
|
||||
assert dtor.getNestedDeclarator() != null || dtor.getName().getSimpleID().length > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,9 +122,7 @@ public class FindNodeForOffsetAction extends CPPASTVisitor implements ICASTVisit
|
|||
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
if (name.toString() != null)
|
||||
return processNode(name);
|
||||
return PROCESS_CONTINUE;
|
||||
return processNode(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
* Implementation for C composite specifiers.
|
||||
*/
|
||||
public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
|
||||
ICASTCompositeTypeSpecifier {
|
||||
|
@ -102,12 +102,6 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
|
|||
return scope;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRawSignature() {
|
||||
return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitDeclSpecifiers ){
|
||||
|
|
|
@ -90,11 +90,6 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier
|
|||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRawSignature() {
|
||||
return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitDeclSpecifiers ){
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
* Implementation for names in C translation units.
|
||||
*/
|
||||
public class CASTName extends ASTNode implements IASTName, IASTCompletionContext {
|
||||
|
||||
|
@ -98,6 +98,10 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
|
|||
return name;
|
||||
}
|
||||
|
||||
public char[] getSimpleID() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitNames) {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
|||
}
|
||||
|
||||
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)) {
|
||||
return specialClass;
|
||||
|
@ -83,7 +83,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
|||
|
||||
public IBinding[] getBindings(IASTName name, boolean forceResolve, boolean prefixLookup,
|
||||
IIndexFileSet fileSet) throws DOMException {
|
||||
char[] c = name.toCharArray();
|
||||
char[] c = name.getSimpleID();
|
||||
IBinding[] result = null;
|
||||
|
||||
if ((!prefixLookup && CharArrayUtils.equals(c, specialClass.getNameCharArray())) ||
|
||||
|
|
|
@ -50,11 +50,6 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
|
|||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRawSignature() {
|
||||
return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public ICPPASTBaseSpecifier[] getBaseSpecifiers() {
|
||||
if( baseSpecs == null ) return ICPPASTBaseSpecifier.EMPTY_BASESPECIFIER_ARRAY;
|
||||
baseSpecs = (ICPPASTBaseSpecifier[]) ArrayUtil.removeNullsAfter( ICPPASTBaseSpecifier.class, baseSpecs, baseSpecsPos );
|
||||
|
|
|
@ -6,40 +6,35 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Emanuel Graf IFS - Bugfix for #198259
|
||||
* Devin Steffler (IBM) - Initial API and implementation
|
||||
* Emanuel Graf IFS - Fix for #198259
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
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.parser.Keywords;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* The implemented ICPPASTConversionName.
|
||||
*
|
||||
* @author dsteffle
|
||||
* Implementation of conversion function ids
|
||||
*/
|
||||
public class CPPASTConversionName extends CPPASTName implements ICPPASTConversionName {
|
||||
|
||||
public class CPPASTConversionName extends CPPASTNameBase implements ICPPASTConversionName {
|
||||
private IASTTypeId typeId = null;
|
||||
private char[] fName;
|
||||
|
||||
public CPPASTConversionName() {
|
||||
}
|
||||
|
||||
public CPPASTConversionName(char[] name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public CPPASTConversionName(char[] name, IASTTypeId typeId) {
|
||||
super(name);
|
||||
public CPPASTConversionName(IASTTypeId typeId) {
|
||||
setTypeId(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTConversionName copy() {
|
||||
char[] name = toCharArray();
|
||||
CPPASTConversionName copy = new CPPASTConversionName(name == null ? null : name.clone());
|
||||
CPPASTConversionName copy = new CPPASTConversionName();
|
||||
copy.setTypeId(typeId == null ? null : typeId.copy());
|
||||
copy.setOffsetAndLength(this);
|
||||
return copy;
|
||||
|
@ -86,4 +81,29 @@ public class CPPASTConversionName extends CPPASTName implements ICPPASTConversio
|
|||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
* C++ specific declarator.
|
||||
*/
|
||||
public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
|
||||
private IASTInitializer initializer;
|
||||
|
@ -205,7 +205,7 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
|
|||
return r_reference;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -83,11 +83,6 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
|
|||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRawSignature() {
|
||||
return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitDeclSpecifiers) {
|
||||
|
|
|
@ -14,13 +14,11 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
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.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompletionContext;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
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.IBinding;
|
||||
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.parser.util.ArrayUtil;
|
||||
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.CPPVisitor;
|
||||
|
||||
|
@ -58,7 +54,8 @@ public class CPPASTName extends CPPASTNameBase implements IASTCompletionContext
|
|||
return CPPVisitor.createBinding(this);
|
||||
}
|
||||
|
||||
public IASTCompletionContext getCompletionContext() {
|
||||
@Override
|
||||
public IASTCompletionContext getCompletionContext() {
|
||||
IASTNode node = getParent();
|
||||
while (node != null) {
|
||||
if (node instanceof IASTCompletionContext) {
|
||||
|
@ -135,18 +132,15 @@ public class CPPASTName extends CPPASTNameBase implements IASTCompletionContext
|
|||
return (IBinding[])ArrayUtil.removeNulls(IBinding.class, bindings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (name.length == 0)
|
||||
return ""; //$NON-NLS-1$
|
||||
return new String(name);
|
||||
}
|
||||
|
||||
public char[] toCharArray() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(char[] name) {
|
||||
public char[] getSimpleID() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(char[] name) {
|
||||
assertNotFrozen();
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -177,65 +171,4 @@ public class CPPASTName extends CPPASTNameBase implements IASTCompletionContext
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,21 @@
|
|||
*******************************************************************************/
|
||||
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.IASTNameOwner;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
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.IASTInternalNameOwner;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
|
||||
|
@ -23,11 +33,13 @@ import org.eclipse.core.runtime.Assert;
|
|||
* names plus template-ids
|
||||
*/
|
||||
public abstract class CPPASTNameBase extends ASTNode implements IASTName {
|
||||
protected static final Pattern WHITESPACE_SEQ = Pattern.compile("\\s+"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* For test-purposes, only.
|
||||
*/
|
||||
public static boolean sAllowRecursionBindings = true;
|
||||
public static boolean sAllowNameComputation = true;
|
||||
private static final byte MAX_RESOLUTION_DEPTH= 6;
|
||||
|
||||
protected final static class RecursionResolvingBinding extends ProblemBinding {
|
||||
|
@ -61,6 +73,18 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
|
|||
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 byte fResolutionDepth = 0;
|
||||
private boolean fIsFinal= false;
|
||||
|
@ -162,4 +186,72 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
|
|||
public IASTName getLastName() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import java.util.ArrayList;
|
||||
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.DOMException;
|
||||
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.ICPPConstructor;
|
||||
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.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.core.runtime.Assert;
|
||||
|
@ -51,8 +50,7 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
private IASTName[] names = null;
|
||||
private int namesPos= -1;
|
||||
private boolean isFullyQualified;
|
||||
private String signature;
|
||||
|
||||
private char[] signature;
|
||||
public CPPASTQualifiedName() {
|
||||
}
|
||||
|
||||
|
@ -61,7 +59,6 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
for(IASTName name : getNames())
|
||||
copy.addName(name == null ? null : name.copy());
|
||||
copy.setFullyQualified(isFullyQualified);
|
||||
copy.setSignature(signature);
|
||||
copy.setOffsetAndLength(this);
|
||||
return copy;
|
||||
}
|
||||
|
@ -95,22 +92,6 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
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) {
|
||||
assertNotFrozen();
|
||||
|
@ -137,33 +118,26 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
|
||||
return names[namesPos];
|
||||
}
|
||||
|
||||
public char[] getSimpleID() {
|
||||
return names[namesPos].getSimpleID();
|
||||
}
|
||||
|
||||
public char[] toCharArray() {
|
||||
if (namesPos < 0)
|
||||
return new char[0];
|
||||
|
||||
// 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++) {
|
||||
if (i != 0) {
|
||||
nameArray[pos++] = ':';
|
||||
nameArray[pos++] = ':';
|
||||
if (signature == null) {
|
||||
StringBuilder buf= new StringBuilder();
|
||||
for (int i = 0; i <= namesPos; i++) {
|
||||
if (i > 0 || isFullyQualified) {
|
||||
buf.append(Keywords.cpCOLONCOLON);
|
||||
}
|
||||
buf.append(names[i].toCharArray());
|
||||
}
|
||||
final char[] n = names[i].toCharArray();
|
||||
System.arraycopy(n, 0, nameArray, pos, n.length);
|
||||
pos += n.length;
|
||||
|
||||
final int len= buf.length();
|
||||
signature= new char[len];
|
||||
buf.getChars(0, len, signature, 0);
|
||||
}
|
||||
return nameArray;
|
||||
return signature;
|
||||
}
|
||||
|
||||
public boolean isFullyQualified() {
|
||||
|
@ -175,10 +149,11 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
this.isFullyQualified = isFullyQualified;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated there is no need to set the signature, it will be computed lazily.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSignature(String signature) {
|
||||
assertNotFrozen();
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -194,11 +169,12 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
}
|
||||
}
|
||||
for (int i = 0; i <= namesPos; i++) {
|
||||
final IASTName name = names[i];
|
||||
if (i == namesPos) {
|
||||
// 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;
|
||||
} else if (!names[i].accept(action))
|
||||
} else if (!name.accept(action))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -216,6 +192,7 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRoleOfName(boolean allowResolution) {
|
||||
IASTNode parent = getParent();
|
||||
if (parent instanceof IASTInternalNameOwner) {
|
||||
|
@ -227,26 +204,6 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
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) {
|
||||
for (int i=0; i < namesPos; ++i) {
|
||||
if (names[i] == n)
|
||||
|
@ -278,16 +235,6 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
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) {
|
||||
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix);
|
||||
|
||||
|
@ -299,7 +246,7 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
List<IBinding> filtered = filterClassScopeBindings(classType, bindings, isDeclaration);
|
||||
|
||||
if (isDeclaration && nameMatches(classType.getNameCharArray(),
|
||||
n.toCharArray(), isPrefix)) {
|
||||
n.getSimpleID(), isPrefix)) {
|
||||
try {
|
||||
ICPPConstructor[] constructors = classType.getConstructors();
|
||||
for (int i = 0; i < constructors.length; i++) {
|
||||
|
@ -359,13 +306,6 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
return CharArrayUtils.equals(potential, name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#getLinkage()
|
||||
*/
|
||||
public ILinkage getLinkage() {
|
||||
return Linkage.CPP_LINKAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IBinding createIntermediateBinding() {
|
||||
Assert.isLegal(false);
|
||||
|
|
|
@ -12,23 +12,24 @@
|
|||
*******************************************************************************/
|
||||
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.IASTCompletionContext;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
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.IASTTypeId;
|
||||
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.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
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.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.CPPVisitor;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
public char[] getSimpleID() {
|
||||
return templateName.getSimpleID();
|
||||
}
|
||||
|
||||
public IASTName getTemplateName() {
|
||||
return templateName;
|
||||
}
|
||||
|
@ -98,17 +103,43 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
|
|||
return CPPTemplates.createBinding(this);
|
||||
}
|
||||
|
||||
public IASTCompletionContext getCompletionContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public char[] toCharArray() {
|
||||
return templateName.toCharArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return templateName.toString();
|
||||
assert sAllowNameComputation;
|
||||
|
||||
StringBuilder buf= new StringBuilder();
|
||||
buf.append(getTemplateName().toCharArray());
|
||||
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
|
||||
|
@ -136,10 +167,12 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeclaration() {
|
||||
return false; //for now this seems to be true
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReference() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
|
||||
/**
|
||||
* 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 {
|
||||
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.
|
||||
ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
|
||||
IASTName name = compTypeSpec.getName();
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
name = ((ICPPASTQualifiedName) name).getLastName();
|
||||
}
|
||||
|
||||
IASTName name = compTypeSpec.getName().getLastName();
|
||||
IBinding binding = name.resolveBinding();
|
||||
if (!(binding instanceof ICPPClassType))
|
||||
return;
|
||||
|
@ -100,7 +98,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
char[] className = name.toCharArray();
|
||||
char[] className = name.getSimpleID();
|
||||
|
||||
IParameter[] voidPs = new IParameter[] { new CPPParameter(CPPSemantics.VOID_TYPE) };
|
||||
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 IASTName[] names= qname.getNames();
|
||||
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;
|
||||
|
||||
b= b.getOwner();
|
||||
|
@ -215,14 +213,14 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
*/
|
||||
@Override
|
||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
|
||||
char[] c = name.toCharArray();
|
||||
char[] c = name.getSimpleID();
|
||||
|
||||
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
IASTName compName = compType.getName().getLastName();
|
||||
if (compName instanceof ICPPASTTemplateId) {
|
||||
compName= ((ICPPASTTemplateId) compName).getTemplateName();
|
||||
}
|
||||
if (CharArrayUtils.equals(c, compName.toCharArray())) {
|
||||
if (CharArrayUtils.equals(c, compName.getSimpleID())) {
|
||||
if (isConstructorReference(name)) {
|
||||
return CPPSemantics.resolveAmbiguities(name, getConstructors(bindings, resolve, name));
|
||||
}
|
||||
|
@ -234,7 +232,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
|
||||
@Override
|
||||
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();
|
||||
IASTName compName = compType.getName().getLastName();
|
||||
|
@ -242,8 +240,8 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
compName= ((ICPPASTTemplateId) compName).getTemplateName();
|
||||
}
|
||||
IBinding[] result = null;
|
||||
if ((!prefixLookup && CharArrayUtils.equals(c, compName.toCharArray()))
|
||||
|| (prefixLookup && CharArrayUtils.equals(compName.toCharArray(), 0, c.length, c, true))) {
|
||||
if ((!prefixLookup && CharArrayUtils.equals(c, compName.getSimpleID()))
|
||||
|| (prefixLookup && CharArrayUtils.equals(compName.getSimpleID(), 0, c.length, c, true))) {
|
||||
if (isConstructorReference(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 {
|
||||
char[] n = name.toCharArray();
|
||||
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
IASTName compName = compType.getName();
|
||||
if (compName instanceof ICPPASTQualifiedName) {
|
||||
compName = ((ICPPASTQualifiedName) compName).getLastName();
|
||||
}
|
||||
IASTName compName = compType.getName().getLastName();
|
||||
if (compName instanceof ICPPASTTemplateId) {
|
||||
compName= ((ICPPASTTemplateId) compName).getTemplateName();
|
||||
}
|
||||
|
||||
if (CharArrayUtils.equals(compName.toCharArray(), n)) {
|
||||
return new IBinding[] { getClassType() };
|
||||
if (CharArrayUtils.equals(compName.getSimpleID(), n)) {
|
||||
return new IBinding[] {compName.resolveBinding()};
|
||||
}
|
||||
|
||||
return super.find(name);
|
||||
|
@ -358,11 +356,12 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
*/
|
||||
public ICPPClassType getClassType() {
|
||||
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
IBinding binding = compSpec.getName().resolveBinding();
|
||||
final IASTName name = compSpec.getName();
|
||||
IBinding binding = name.resolveBinding();
|
||||
if (binding instanceof ICPPClassType)
|
||||
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)
|
||||
|
@ -449,7 +448,7 @@ class ImplicitsAnalysis {
|
|||
private static ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor(ICPPASTCompositeTypeSpecifier compSpec, boolean constructor) {
|
||||
List<ICPPASTFunctionDeclarator> result= new ArrayList<ICPPASTFunctionDeclarator>();
|
||||
IASTDeclaration[] members = compSpec.getMembers();
|
||||
char[] name = compSpec.getName().toCharArray();
|
||||
char[] name = compSpec.getName().getSimpleID();
|
||||
IASTDeclarator dcltor = null;
|
||||
IASTDeclSpecifier spec = null;
|
||||
for (IASTDeclaration member : members) {
|
||||
|
@ -471,7 +470,7 @@ class ImplicitsAnalysis {
|
|||
}
|
||||
|
||||
boolean nameEquals= false;
|
||||
char[] dtorname= CPPVisitor.findInnermostDeclarator(dcltor).getName().toCharArray();
|
||||
char[] dtorname= CPPASTNameBase.getLookupKey(CPPVisitor.findInnermostDeclarator(dcltor).getName());
|
||||
if (constructor) {
|
||||
nameEquals= CharArrayUtils.equals(dtorname, name);
|
||||
} else {
|
||||
|
@ -504,7 +503,7 @@ class ImplicitsAnalysis {
|
|||
if (dcltor instanceof ICPPASTFunctionDeclarator == false)
|
||||
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()))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -257,12 +257,12 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
|
|||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return ( definition != null ) ? definition.toString() : declarations[0].toString();
|
||||
public final String getName() {
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
return ( definition != null ) ? definition.toCharArray() : declarations[0].toCharArray();
|
||||
return ( definition != null ) ? definition.getSimpleID() : declarations[0].getSimpleID();
|
||||
}
|
||||
|
||||
public IScope getScope() {
|
||||
|
|
|
@ -49,11 +49,11 @@ public class CPPEnumeration extends PlatformObject implements IEnumeration, ICPP
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
return enumName.toString();
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
return enumName.toCharArray();
|
||||
return enumName.getSimpleID();
|
||||
}
|
||||
|
||||
public IScope getScope() {
|
||||
|
|
|
@ -63,14 +63,14 @@ public class CPPEnumerator extends PlatformObject implements IEnumerator, ICPPIn
|
|||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return enumName.toString();
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return enumName.toCharArray();
|
||||
return enumName.getSimpleID();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -89,7 +89,7 @@ public class CPPField extends CPPVariable implements ICPPField {
|
|||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)member).getDeclarators();
|
||||
for (IASTDeclarator dtor : dtors) {
|
||||
IASTName name = dtor.getName();
|
||||
if( CharArrayUtils.equals( name.toCharArray(), myName ) &&
|
||||
if( CharArrayUtils.equals( name.getSimpleID(), myName ) &&
|
||||
name.resolveBinding() == this )
|
||||
{
|
||||
return member;
|
||||
|
|
|
@ -257,7 +257,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
return getASTName().toCharArray();
|
||||
return getASTName().getSimpleID();
|
||||
}
|
||||
|
||||
protected IASTName getASTName() {
|
||||
|
|
|
@ -70,7 +70,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[])
|
||||
*/
|
||||
public IBinding getBinding(IASTName name) {
|
||||
return (IBinding) labels.get(name.toCharArray());
|
||||
return (IBinding) labels.get(name.getSimpleID());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -112,7 +112,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
while( dtor != null ){
|
||||
IASTName name = CPPVisitor.findInnermostDeclarator(dtor).getName();
|
||||
if( CPPVisitor.findTypeRelevantDeclarator(dtor) instanceof ICPPASTFunctionDeclarator &&
|
||||
CharArrayUtils.equals( name.toCharArray(), getNameCharArray() ) )
|
||||
CharArrayUtils.equals( name.getSimpleID(), getNameCharArray() ) )
|
||||
{
|
||||
IType t0= CPPVisitor.createType( dtor );
|
||||
boolean ok= false;
|
||||
|
|
|
@ -51,11 +51,11 @@ public class CPPLabel extends PlatformObject implements ILabel, ICPPInternalBind
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
return statement.toString();
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
return statement.toCharArray();
|
||||
return statement.getSimpleID();
|
||||
}
|
||||
|
||||
public IScope getScope() {
|
||||
|
|
|
@ -109,7 +109,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
|
|||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)member).getDeclarators();
|
||||
for (IASTDeclarator dtor : dtors) {
|
||||
IASTName name = CPPVisitor.findInnermostDeclarator(dtor).getName();
|
||||
if( CharArrayUtils.equals( name.toCharArray(), myName ) &&
|
||||
if( CharArrayUtils.equals( name.getSimpleID(), myName ) &&
|
||||
name.resolveBinding() == this )
|
||||
{
|
||||
return member;
|
||||
|
@ -118,7 +118,7 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
|
|||
} else if( member instanceof IASTFunctionDefinition ){
|
||||
final IASTFunctionDeclarator declarator = ((IASTFunctionDefinition) member).getDeclarator();
|
||||
IASTName name = CPPVisitor.findInnermostDeclarator(declarator).getName();
|
||||
if( CharArrayUtils.equals( name.toCharArray(), myName ) &&
|
||||
if( CharArrayUtils.equals( name.getSimpleID(), myName ) &&
|
||||
name.resolveBinding() == this )
|
||||
{
|
||||
return member;
|
||||
|
|
|
@ -73,7 +73,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements
|
|||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
||||
for (IASTDeclarator dtor : dtors) {
|
||||
IASTName name = CPPVisitor.findInnermostDeclarator(dtor).getName();
|
||||
if( CharArrayUtils.equals( name.toCharArray(), myName ) &&
|
||||
if( CharArrayUtils.equals( name.getSimpleID(), myName ) &&
|
||||
name.resolveBinding() == this )
|
||||
{
|
||||
return member;
|
||||
|
@ -81,7 +81,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements
|
|||
}
|
||||
} else if( decl instanceof IASTFunctionDefinition ){
|
||||
IASTName name = CPPVisitor.findInnermostDeclarator(((IASTFunctionDefinition) decl).getDeclarator()).getName();
|
||||
if( CharArrayUtils.equals( name.toCharArray(), myName ) &&
|
||||
if( CharArrayUtils.equals( name.getSimpleID(), myName ) &&
|
||||
name.resolveBinding() == this )
|
||||
{
|
||||
return member;
|
||||
|
|
|
@ -109,7 +109,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
|
|||
public int visit(ICPPASTNamespaceDefinition namespace) {
|
||||
ICPPASTNamespaceDefinition orig = namespaceDef, candidate = namespace;
|
||||
while(candidate != null) {
|
||||
if (!CharArrayUtils.equals(orig.getName().toCharArray(), candidate.getName().toCharArray()))
|
||||
if (!CharArrayUtils.equals(orig.getName().getSimpleID(), candidate.getName().getSimpleID()))
|
||||
return PROCESS_CONTINUE;
|
||||
if (orig.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()
|
||||
*/
|
||||
public String getName() {
|
||||
return tu != null ? null : namespaceDefinitions[0].toString();
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return tu != null ? EMPTY_CHAR_ARRAY : namespaceDefinitions[0].toCharArray();
|
||||
return tu != null ? EMPTY_CHAR_ARRAY : namespaceDefinitions[0].getSimpleID();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -50,11 +50,11 @@ public class CPPNamespaceAlias extends PlatformObject implements ICPPNamespaceAl
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
return alias.toString();
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
return alias.toCharArray();
|
||||
return alias.getSimpleID();
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() {
|
||||
|
|
|
@ -103,7 +103,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
|
|||
}
|
||||
@Override
|
||||
public int leave(ICPPASTNamespaceDefinition namespace) {
|
||||
if (namespace.getName().toCharArray().length > 0) {
|
||||
if (namespace.getName().getSimpleID().length > 0) {
|
||||
--depth;
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
|
|
|
@ -206,8 +206,8 @@ public class CPPNodeFactory implements ICPPNodeFactory {
|
|||
return new CPPASTTemplateId(templateName);
|
||||
}
|
||||
|
||||
public ICPPASTConversionName newConversionName(char[] name, IASTTypeId typeId) {
|
||||
return new CPPASTConversionName(name, typeId);
|
||||
public ICPPASTConversionName newConversionName(IASTTypeId typeId) {
|
||||
return new CPPASTConversionName(typeId);
|
||||
}
|
||||
|
||||
public ICPPASTQualifiedName newQualifiedName() {
|
||||
|
|
|
@ -144,10 +144,7 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
|||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
IASTName name = getPrimaryDeclaration();
|
||||
if (name != null)
|
||||
return name.toString();
|
||||
return CPPSemantics.EMPTY_NAME;
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -156,7 +153,7 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
|||
public char[] getNameCharArray() {
|
||||
IASTName name = getPrimaryDeclaration();
|
||||
if (name != null)
|
||||
return name.toCharArray();
|
||||
return name.getSimpleID();
|
||||
return CPPSemantics.EMPTY_NAME_ARRAY;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,22 +76,17 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
public void addName(IASTName name) throws DOMException {
|
||||
if (bindings == null)
|
||||
bindings = new CharArrayObjectMap(1);
|
||||
char[] c;
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
if (!(physicalNode instanceof ICPPASTCompositeTypeSpecifier) &&
|
||||
!(physicalNode instanceof ICPPASTNamespaceDefinition)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//name belongs to a different scope, don't add it here except it names this scope
|
||||
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
|
||||
final IASTName[] ns= qname.getNames();
|
||||
if (!canDenoteScopeMember(qname))
|
||||
// name belongs to a different scope, don't add it here except it names this scope
|
||||
if (!canDenoteScopeMember((ICPPASTQualifiedName) name))
|
||||
return;
|
||||
c= ns[ns.length - 1].toCharArray();
|
||||
} else {
|
||||
c= name.toCharArray();
|
||||
}
|
||||
}
|
||||
final char[] c= name.getSimpleID();
|
||||
Object o = bindings.get(c);
|
||||
if (o != null) {
|
||||
if (o instanceof ObjectSet) {
|
||||
|
@ -114,9 +109,11 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
for (int i= na.length - 2; i >= 0; i++) {
|
||||
if (scope == null)
|
||||
return false;
|
||||
IASTName n= na[i];
|
||||
final IName scopeName = scope.getScopeName();
|
||||
if (scopeName == null || !CharArrayUtils.equals(scopeName.toCharArray(), n.toCharArray()))
|
||||
IName scopeName = scope.getScopeName();
|
||||
if (scopeName == null)
|
||||
return false;
|
||||
|
||||
if (!CharArrayUtils.equals(scopeName.getSimpleID(), na[i].getSimpleID()))
|
||||
return false;
|
||||
scope= scope.getParent();
|
||||
}
|
||||
|
@ -135,10 +132,11 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
final IASTTranslationUnit tu = name.getTranslationUnit();
|
||||
IIndex index = tu == null ? null : tu.getIndex();
|
||||
if (index != null) {
|
||||
final char[] nchars = name.getSimpleID();
|
||||
// Try looking this up in the PDOM
|
||||
if (physicalNode instanceof IASTTranslationUnit) {
|
||||
try {
|
||||
IBinding[] bindings= index.findBindings(name.toCharArray(),
|
||||
IBinding[] bindings= index.findBindings(nchars,
|
||||
IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, NPM);
|
||||
if (fileSet != null) {
|
||||
bindings= fileSet.filterFileLocalBindings(bindings);
|
||||
|
@ -158,7 +156,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
if (nsbinding instanceof ICPPNamespace) {
|
||||
ICPPNamespace nsbindingAdapted = (ICPPNamespace) index.adaptBinding(nsbinding);
|
||||
if (nsbindingAdapted!=null) {
|
||||
IBinding[] bindings = nsbindingAdapted.getNamespaceScope().find(name.toString());
|
||||
IBinding[] bindings = nsbindingAdapted.getNamespaceScope().find(new String(nchars));
|
||||
if (fileSet != null) {
|
||||
bindings= fileSet.filterFileLocalBindings(bindings);
|
||||
}
|
||||
|
@ -176,7 +174,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
}
|
||||
|
||||
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
|
||||
if (c.length == 0)
|
||||
return null;
|
||||
|
@ -236,9 +234,10 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
if (physicalNode instanceof IASTTranslationUnit) {
|
||||
try {
|
||||
IndexFilter filter = IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE;
|
||||
final char[] nchars = name.getSimpleID();
|
||||
IBinding[] bindings = prefixLookup ?
|
||||
index.findBindingsForPrefix(name.toCharArray(), true, filter, null) :
|
||||
index.findBindings(name.toCharArray(), filter, null);
|
||||
index.findBindingsForPrefix(nchars, true, filter, null) :
|
||||
index.findBindings(nchars, filter, null);
|
||||
if (fileSet != null) {
|
||||
bindings= fileSet.filterFileLocalBindings(bindings);
|
||||
}
|
||||
|
@ -270,7 +269,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
|
||||
public IBinding[] getBindingsInAST(IASTName name, boolean forceResolve, boolean prefixLookup)
|
||||
throws DOMException {
|
||||
char[] c = name.toCharArray();
|
||||
char[] c = name.getSimpleID();
|
||||
IBinding[] result = null;
|
||||
|
||||
Object[] obj = null;
|
||||
|
@ -294,11 +293,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
for (int j = 0; j < os.size(); j++) {
|
||||
Object o = os.keyAt(j);
|
||||
if (o instanceof IASTName) {
|
||||
IASTName n = (IASTName) o;
|
||||
if (n instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||
n = ns[ns.length - 1];
|
||||
}
|
||||
IASTName n = ((IASTName) o).getLastName();
|
||||
IBinding binding = forceResolve ? n.resolveBinding() : n.getBinding();
|
||||
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
|
||||
} else {
|
||||
|
@ -310,11 +305,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
if (forceResolve && element != name && element != name.getParent()) {
|
||||
binding = ((IASTName) element).resolveBinding();
|
||||
} else {
|
||||
IASTName n = (IASTName) element;
|
||||
if (n instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||
n = ns[ns.length - 1];
|
||||
}
|
||||
IASTName n = ((IASTName) element).getLastName();
|
||||
binding = n.getBinding();
|
||||
}
|
||||
if (binding instanceof ICPPUsingDeclaration) {
|
||||
|
|
|
@ -183,14 +183,14 @@ public class CPPScopeMapper {
|
|||
StringBuilder buf= new StringBuilder();
|
||||
IName scopeName = scope.getScopeName();
|
||||
if (scopeName != null) {
|
||||
buf.append(scopeName.toCharArray());
|
||||
buf.append(scopeName.getSimpleID());
|
||||
}
|
||||
scope= scope.getParent();
|
||||
while (scope != null && scope != tuscope) {
|
||||
buf.append(':');
|
||||
scopeName= scope.getScopeName();
|
||||
if (scopeName != null) {
|
||||
buf.append(scope.getScopeName().toCharArray());
|
||||
buf.append(scope.getScopeName().getSimpleID());
|
||||
}
|
||||
scope= scope.getParent();
|
||||
}
|
||||
|
|
|
@ -134,14 +134,14 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
|||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return getTemplateName().toString();
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return getTemplateName().toCharArray();
|
||||
return getTemplateName().getSimpleID();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -92,14 +92,14 @@ public abstract class CPPTemplateParameter extends PlatformObject
|
|||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return declarations[0].toString();
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return declarations[0].toCharArray();
|
||||
return declarations[0].getSimpleID();
|
||||
}
|
||||
|
||||
public int getParameterID() {
|
||||
|
|
|
@ -99,23 +99,14 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
|||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return getSimpleName().toString();
|
||||
}
|
||||
|
||||
private IASTName getSimpleName() {
|
||||
IASTName name= declarations[0];
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] na= ((ICPPASTQualifiedName) name).getNames();
|
||||
name= na[na.length-1];
|
||||
}
|
||||
return name;
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return getSimpleName().toCharArray();
|
||||
return declarations[0].getSimpleID();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -75,7 +75,7 @@ public class CPPUnknownBinding extends PlatformObject
|
|||
}
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
return name.toCharArray();
|
||||
return name.getSimpleID();
|
||||
}
|
||||
|
||||
public IScope getScope() throws DOMException {
|
||||
|
|
|
@ -147,7 +147,7 @@ public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
|
|||
if (map == null)
|
||||
map = new CharArrayObjectMap(2);
|
||||
|
||||
char[] c = name.toCharArray();
|
||||
char[] c = name.getSimpleID();
|
||||
IBinding[] o= (IBinding[]) map.get(c);
|
||||
if (o == null) {
|
||||
o= new IBinding[3];
|
||||
|
|
|
@ -64,11 +64,11 @@ public class CPPUsingDeclaration extends PlatformObject implements ICPPUsingDecl
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
return name.toString();
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
return name.toCharArray();
|
||||
return name.getSimpleID();
|
||||
}
|
||||
|
||||
public IScope getScope() {
|
||||
|
|
|
@ -216,16 +216,7 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
|||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
if (declarations != null) {
|
||||
return declarations[0].toString();
|
||||
}
|
||||
IASTName name = definition;
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
|
||||
name = ns[ns.length - 1];
|
||||
}
|
||||
|
||||
return name.toString();
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -233,15 +224,9 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
|||
*/
|
||||
public char[] getNameCharArray() {
|
||||
if (declarations != null) {
|
||||
return declarations[0].toCharArray();
|
||||
return declarations[0].getSimpleID();
|
||||
}
|
||||
IASTName name = definition;
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
|
||||
name = ns[ns.length - 1];
|
||||
}
|
||||
|
||||
return name.toCharArray();
|
||||
return definition.getSimpleID();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -220,8 +220,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
private IASTName qualifiedName() throws BacktrackException, EndOfFileException {
|
||||
// mstodo
|
||||
IToken first= LA(1);
|
||||
ICPPASTQualifiedName qname= null;
|
||||
IASTName name= null;
|
||||
final int offset= LA(1).getOffset();
|
||||
|
@ -293,8 +291,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return name;
|
||||
|
||||
setRange(qname, offset, endOffset);
|
||||
// mstodo
|
||||
((CPPASTQualifiedName) qname).setSignature(new String(computeOperatorImage(first, LA(1))));
|
||||
return qname;
|
||||
}
|
||||
|
||||
|
@ -579,41 +575,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (typeId == null)
|
||||
throwBacktrack(t);
|
||||
|
||||
char[] image= computeOperatorImage(firstToken, LA(1));
|
||||
IASTName name = nodeFactory.newConversionName(image, typeId);
|
||||
IASTName name = nodeFactory.newConversionName(typeId);
|
||||
setRange(name, firstToken.getOffset(), calculateEndOffset(typeId));
|
||||
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
|
||||
protected IASTExpression expression() throws EndOfFileException, BacktrackException {
|
||||
final boolean wasOnTop= onTopInTemplateArgs;
|
||||
|
@ -2316,7 +2282,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
}
|
||||
|
||||
identifier= qualifiedName();
|
||||
if (identifier.getLastName().toCharArray().length == 0 && LT(1) != IToken.tEOC)
|
||||
if (identifier.getSimpleID().length == 0 && LT(1) != IToken.tEOC)
|
||||
throwBacktrack(LA(1));
|
||||
|
||||
endOffset= calculateEndOffset(identifier);
|
||||
|
@ -2427,23 +2393,22 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
|
||||
final IASTName names[]= qname.getNames();
|
||||
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
|
||||
|
||||
name= qname.getLastName();
|
||||
name= lastName;
|
||||
}
|
||||
if (name instanceof ICPPASTTemplateId)
|
||||
name= ((ICPPASTTemplateId) name).getTemplateName();
|
||||
|
||||
if (name instanceof ICPPASTConversionName)
|
||||
return true; // conversion
|
||||
if (name instanceof ICPPASTTemplateId) {
|
||||
if (((ICPPASTTemplateId) name).getTemplateName() instanceof ICPPASTConversionName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
final char[] nchars= name.toCharArray();
|
||||
return true;
|
||||
|
||||
final char[] nchars= name.getSimpleID();
|
||||
if (nchars.length > 0 && nchars[0] == '~')
|
||||
return true; // destructor
|
||||
|
||||
if (declOption == DeclarationOptions.CPP_MEMBER && CharArrayUtils.equals(nchars, currentClassName))
|
||||
return true;
|
||||
}
|
||||
|
@ -2977,7 +2942,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (coloncolon != 0) {
|
||||
try {
|
||||
name= qualifiedName();
|
||||
if (name.getLastName().toCharArray().length != 0) {
|
||||
if (CPPASTNameBase.getLookupKey(name).length != 0) {
|
||||
backup(mark);
|
||||
return;
|
||||
}
|
||||
|
@ -3321,11 +3286,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
int endOffset= consume().getEndOffset();
|
||||
final char[] outerName= currentClassName;
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
currentClassName= ((ICPPASTQualifiedName)name).getLastName().toCharArray();
|
||||
} else {
|
||||
currentClassName= name.toCharArray();
|
||||
}
|
||||
currentClassName= name.getSimpleID();
|
||||
|
||||
try {
|
||||
int declOffset= -1;
|
||||
loop: while (true) {
|
||||
|
@ -3396,7 +3358,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
((ASTNode) astClassSpecifier).setOffsetAndLength(offset, endOffset - offset);
|
||||
return astClassSpecifier;
|
||||
}
|
||||
|
||||
|
||||
protected int token2Visibility(int type) {
|
||||
switch (type) {
|
||||
|
|
|
@ -591,7 +591,7 @@ public class CPPSemantics {
|
|||
so= map.get(key);
|
||||
} else if (objs != null) {
|
||||
so= objs[i];
|
||||
key= (so instanceof IBinding) ? ((IBinding) so).getNameCharArray() : ((IASTName) so).toCharArray();
|
||||
key= (so instanceof IBinding) ? ((IBinding) so).getNameCharArray() : ((IASTName) so).getSimpleID();
|
||||
} else {
|
||||
return resultMap;
|
||||
}
|
||||
|
@ -1189,7 +1189,7 @@ public class CPPSemantics {
|
|||
nsscope.addUsingDirective(new CPPUsingDirective(usingDirective));
|
||||
}
|
||||
} else if (item instanceof ICPPASTNamespaceDefinition &&
|
||||
((ICPPASTNamespaceDefinition)item).getName().toCharArray().length == 0) {
|
||||
((ICPPASTNamespaceDefinition)item).getName().getSimpleID().length == 0) {
|
||||
if (scope instanceof ICPPNamespaceScope) {
|
||||
final ICPPNamespaceScope nsscope = (ICPPNamespaceScope)scope;
|
||||
final ICPPASTNamespaceDefinition nsdef= (ICPPASTNamespaceDefinition) item;
|
||||
|
@ -1414,7 +1414,7 @@ public class CPPSemantics {
|
|||
|
||||
//anonymous union? //GCC supports anonymous structs too
|
||||
if (declarators.length == 0 && /*compSpec.getKey() == IASTCompositeTypeSpecifier.k_union &&*/
|
||||
specName.toCharArray().length == 0)
|
||||
specName.getSimpleID().length == 0)
|
||||
{
|
||||
Object o = null;
|
||||
IASTDeclaration[] decls = compSpec.getMembers();
|
||||
|
@ -1531,7 +1531,7 @@ public class CPPSemantics {
|
|||
|
||||
potential= qname.getLastName();
|
||||
}
|
||||
char[] c = potential.toCharArray();
|
||||
char[] c = potential.getSimpleID();
|
||||
char[] n = data.name();
|
||||
return (data.prefixLookup && CharArrayUtils.equals(c, 0, n.length, n, true))
|
||||
|| (!data.prefixLookup && CharArrayUtils.equals(c, n));
|
||||
|
|
|
@ -1083,7 +1083,7 @@ public class CPPTemplates {
|
|||
for (ICPPASTTemplateParameter par : pars) {
|
||||
IASTName name= CPPTemplates.getTemplateParameterName(par);
|
||||
if (name != null)
|
||||
set.put(name.toCharArray());
|
||||
set.put(name.getSimpleID());
|
||||
}
|
||||
final IASTNode next= tdecl.getDeclaration();
|
||||
if (next instanceof ICPPASTTemplateDeclaration) {
|
||||
|
@ -1110,7 +1110,7 @@ public class CPPTemplates {
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
if (names.containsKey(name.toCharArray())) {
|
||||
if (names.containsKey(name.getSimpleID())) {
|
||||
IASTNode parent= name.getParent();
|
||||
if (parent instanceof ICPPASTQualifiedName) {
|
||||
if (((ICPPASTQualifiedName) parent).getNames()[0] != name) {
|
||||
|
@ -1289,7 +1289,7 @@ public class CPPTemplates {
|
|||
return true;
|
||||
}
|
||||
|
||||
return CharArrayUtils.equals(definition.getNameCharArray(), name.toCharArray());
|
||||
return CharArrayUtils.equals(definition.getNameCharArray(), name.getSimpleID());
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
||||
}
|
||||
|
||||
if (name.toCharArray().length > 0)
|
||||
if (name.getSimpleID().length > 0)
|
||||
return binding;
|
||||
return null;
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
if (name instanceof ICPPASTTemplateId) {
|
||||
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);
|
||||
if (!(binding instanceof ICPPInternalBinding) || !(binding instanceof ICPPClassType)) {
|
||||
if (template) {
|
||||
|
@ -732,11 +732,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
return false;
|
||||
|
||||
IASTName name = findInnermostDeclarator(declarator).getName();
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] names = ((ICPPASTQualifiedName)name).getNames();
|
||||
name = names[names.length - 1];
|
||||
}
|
||||
if (!CharArrayUtils.equals(name.toCharArray(), parentName.toCharArray()))
|
||||
if (!CharArrayUtils.equals(CPPASTNameBase.getLookupKey(name), CPPASTNameBase.getLookupKey(parentName)))
|
||||
return false;
|
||||
|
||||
IASTDeclSpecifier declSpec = null;
|
||||
|
|
|
@ -115,7 +115,7 @@ class LookupData {
|
|||
|
||||
public final char[] name() {
|
||||
if (astName != null)
|
||||
return astName.toCharArray();
|
||||
return astName.getSimpleID();
|
||||
return CPPSemantics.EMPTY_NAME_ARRAY;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,10 @@ class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName {
|
|||
public char[] toCharArray() {
|
||||
return fName;
|
||||
}
|
||||
public char[] getSimpleID() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new String(fName);
|
||||
|
|
|
@ -406,7 +406,7 @@ class ASTFunctionStyleMacroDefinition extends ASTMacroDefinition implements IAST
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuilder result= new StringBuilder();
|
||||
result.append(getName().toCharArray());
|
||||
result.append(getName().getSimpleID());
|
||||
result.append('(');
|
||||
boolean needComma= false;
|
||||
for (IASTFunctionStyleMacroParameter param : getParameters()) {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class SingleMacroExpansionExplorer extends MacroExpansionExplorer {
|
|||
private void addMacroDefinition(CharArrayMap<PreprocessorMacro> map, IASTName name) {
|
||||
IBinding binding= name.getBinding();
|
||||
if (binding instanceof PreprocessorMacro) {
|
||||
map.put(name.toCharArray(), (PreprocessorMacro) binding);
|
||||
map.put(name.getSimpleID(), (PreprocessorMacro) binding);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -380,7 +380,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
} else if (name.getPropertyInParent() == IASTPreprocessorStatement.MACRO_NAME) {
|
||||
PDOMLinkage linkage= adaptLinkage(name.getLinkage());
|
||||
if (linkage != null) {
|
||||
return linkage.findMacroContainer(name.toCharArray());
|
||||
return linkage.findMacroContainer(name.getSimpleID());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -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.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class PDOMASTAdapter {
|
||||
|
@ -162,6 +163,10 @@ public class PDOMASTAdapter {
|
|||
return fDelegate.toCharArray();
|
||||
}
|
||||
|
||||
public char[] getSimpleID() {
|
||||
return fDelegate.getSimpleID();
|
||||
}
|
||||
|
||||
public IASTImageLocation getImageLocation() {
|
||||
return null;
|
||||
}
|
||||
|
@ -494,7 +499,7 @@ public class PDOMASTAdapter {
|
|||
* it is returned unchanged.
|
||||
*/
|
||||
public static IASTName getAdapterIfAnonymous(IASTName name) {
|
||||
if (name.toCharArray().length == 0) {
|
||||
if (CPPASTNameBase.getLookupKey(name).length == 0) {
|
||||
if (name.getFileLocation() == null) {
|
||||
IASTNode parent= name.getParent();
|
||||
if (parent != null) {
|
||||
|
|
|
@ -241,11 +241,11 @@ public class PDOMFile implements IIndexFragmentFile {
|
|||
PDOMMacro pdomMacro= null;
|
||||
if (stmt instanceof IASTPreprocessorMacroDefinition) {
|
||||
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);
|
||||
} else if (stmt instanceof IASTPreprocessorUndefStatement) {
|
||||
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);
|
||||
}
|
||||
if (pdomMacro != null) {
|
||||
|
@ -326,7 +326,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
|
|||
|
||||
setFlag(encodeFlags(include, targetFile == null));
|
||||
setIncludedBy(containerFile);
|
||||
setIncludes(targetFile, name.toCharArray());
|
||||
setIncludes(targetFile, name.getSimpleID());
|
||||
}
|
||||
|
||||
private byte encodeFlags(IASTPreprocessorIncludeStatement include, boolean unresolved) {
|
||||
|
|
|
@ -68,9 +68,19 @@ class PDOMMacroDefinitionName implements IIndexFragmentName {
|
|||
public boolean isReference() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public char[] toCharArray() {
|
||||
return fMacro.getNameCharArray();
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return new String(getSimpleID());
|
||||
}
|
||||
|
||||
public char[] getSimpleID() {
|
||||
return fMacro.getNameCharArray();
|
||||
}
|
||||
public IIndexFragmentBinding getBinding() {
|
||||
return fMacro;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,15 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
|
|||
setNameField(FILE_NEXT_OFFSET, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getSimpleID()}.
|
||||
*/
|
||||
@Deprecated
|
||||
public char[] toCharArray() {
|
||||
return getSimpleID();
|
||||
}
|
||||
|
||||
public char[] getSimpleID() {
|
||||
try {
|
||||
return getContainer().getNameCharArray();
|
||||
} catch (CoreException e) {
|
||||
|
@ -133,7 +141,7 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new String(toCharArray());
|
||||
return new String(getSimpleID());
|
||||
}
|
||||
|
||||
public boolean isBaseSpecifier() throws CoreException {
|
||||
|
|
|
@ -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.index.IIndexFile;
|
||||
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.IIndexFragmentName;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -180,8 +181,16 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
|
|||
public void setNextInFile(PDOMName name) throws CoreException {
|
||||
setNameField(FILE_NEXT_OFFSET, name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getSimpleID()}, instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public char[] toCharArray() {
|
||||
return getSimpleID();
|
||||
}
|
||||
|
||||
public char[] getSimpleID() {
|
||||
try {
|
||||
Database db = pdom.getDB();
|
||||
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;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
return CharArrayUtils.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
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;
|
||||
}
|
||||
return new String(getSimpleID());
|
||||
}
|
||||
|
||||
private int getFlags(int mask) throws CoreException {
|
||||
|
|
|
@ -161,7 +161,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
|||
if (name == null)
|
||||
return null;
|
||||
|
||||
char[] namechars = name.toCharArray();
|
||||
char[] namechars = name.getSimpleID();
|
||||
if (namechars == null)
|
||||
return null;
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope {
|
|||
|
||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
|
||||
try {
|
||||
final char[] nameChars = name.toCharArray();
|
||||
final char[] nameChars = name.getSimpleID();
|
||||
if (CharArrayUtils.equals(fBinding.getNameCharArray(), nameChars)) {
|
||||
if (CPPClassScope.isConstructorReference(name)){
|
||||
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 {
|
||||
IBinding[] result = null;
|
||||
try {
|
||||
final char[] nameChars = name.toCharArray();
|
||||
final char[] nameChars = name.getSimpleID();
|
||||
if (!prefixLookup) {
|
||||
return getBindingsViaCache(fBinding, nameChars, IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE);
|
||||
}
|
||||
|
|
|
@ -204,11 +204,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
if (name == null || name instanceof ICPPASTQualifiedName)
|
||||
return null;
|
||||
|
||||
// Check for null name
|
||||
char[] namechars = name.toCharArray();
|
||||
if (namechars == null)
|
||||
return null;
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
|
||||
PDOMBinding pdomBinding = addBinding(binding, name);
|
||||
|
|
|
@ -129,7 +129,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
@Override
|
||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
|
||||
try {
|
||||
IBinding[] bindings= getBindingsViaCache(name.toCharArray());
|
||||
IBinding[] bindings= getBindingsViaCache(name.getSimpleID());
|
||||
if (fileSet != null) {
|
||||
bindings= fileSet.filterFileLocalBindings(bindings);
|
||||
}
|
||||
|
@ -146,9 +146,9 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
IBinding[] result = null;
|
||||
try {
|
||||
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);
|
||||
getIndex().accept(visitor);
|
||||
IBinding[] bindings = visitor.getBindings();
|
||||
|
|
|
@ -470,7 +470,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
}
|
||||
}
|
||||
IASTName name= node.getName();
|
||||
if (name != null && name.toCharArray().length != 0) {
|
||||
if (name != null && name.getSimpleID().length != 0) {
|
||||
if (isFirstDeclarator(node)) {
|
||||
// preserve non-space between pointer operator and name
|
||||
if (pointerOperators.length == 0 || scribe.printComment()) {
|
||||
|
|
|
@ -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.IASTBinaryExpression;
|
||||
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.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
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.gnu.c.IGCCASTArrayRangeDesignator;
|
||||
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.internal.core.dom.parser.ASTNode;
|
||||
|
@ -130,10 +133,10 @@ public class DOMASTNodeLeaf implements IAdaptable {
|
|||
StringBuffer buffer = new StringBuffer();
|
||||
List<Class<?>> search= new LinkedList<Class<?>>();
|
||||
boolean done= false;
|
||||
boolean needComma= false;
|
||||
|
||||
for (search.add(node.getClass()); !search.isEmpty(); ) {
|
||||
Class<?> clazz= search.remove(0);
|
||||
boolean needComma= false;
|
||||
if (clazz.isInterface()) {
|
||||
if (clazz.getPackage().toString().indexOf(INTERNAL) < 0) {
|
||||
String interfaceName= clazz.getName();
|
||||
|
@ -197,7 +200,7 @@ public class DOMASTNodeLeaf implements IAdaptable {
|
|||
} else if( node instanceof IASTDeclSpecifier )
|
||||
{
|
||||
buffer.append( START_OF_LIST );
|
||||
buffer.append( ((IASTDeclSpecifier)node).getRawSignature() );
|
||||
buffer.append( getSignature((IASTDeclSpecifier)node) );
|
||||
return buffer.toString();
|
||||
} else if ( node instanceof IASTPreprocessorIncludeStatement ) {
|
||||
String path = ((IASTPreprocessorIncludeStatement)node).getPath();
|
||||
|
@ -288,6 +291,35 @@ public class DOMASTNodeLeaf implements IAdaptable {
|
|||
|
||||
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) {
|
||||
String name = BLANK_STRING;
|
||||
|
|
|
@ -68,7 +68,7 @@ class TrailName extends CPPASTName {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return realName.toString();
|
||||
public char[] toCharArray() {
|
||||
return realName.toCharArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class SelectionParseAction extends Action {
|
|||
|
||||
IASTFileLocation fileloc = name.getFileLocation();
|
||||
if (fileloc == null) {
|
||||
reportSymbolLookupFailure(new String(name.toCharArray()));
|
||||
reportSymbolLookupFailure(name.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
|||
int nodeLength= fileLocation.getNodeLength();
|
||||
|
||||
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);
|
||||
LocationKind locationKind= LocationKind.LOCATION;
|
||||
if (name instanceof IASTName && !name.isReference()) {
|
||||
|
|
|
@ -188,7 +188,7 @@ public class IndexUI {
|
|||
IIndexName[] names= file.findNames(region.getOffset(), region.getLength());
|
||||
for (int j = 0; j < names.length; 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.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.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.IASTElaboratedTypeSpecifier;
|
||||
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.IASTFunctionDeclarator;
|
||||
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.ICPPASTNamespaceDefinition;
|
||||
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.ICPPASTPointerToMember;
|
||||
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.ICPPASTUsingDirective;
|
||||
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.lrparser.IParser;
|
||||
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
|
||||
|
@ -490,11 +533,12 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
public void consumeConversionName() {
|
||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
||||
|
||||
String rep = createStringRepresentation(parser.getRuleTokens());
|
||||
char[] chars = rep.toCharArray();
|
||||
// Representation is computed by the conversion name itself, see bug 258054
|
||||
// String rep = createStringRepresentation(parser.getRuleTokens());
|
||||
// char[] chars = rep.toCharArray();
|
||||
|
||||
IASTTypeId typeId = (IASTTypeId) astStack.pop();
|
||||
ICPPASTConversionName name = nodeFactory.newConversionName(chars, typeId);
|
||||
ICPPASTConversionName name = nodeFactory.newConversionName(typeId);
|
||||
setOffsetAndLength(name);
|
||||
astStack.push(name);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue