1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-11 10:15:39 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-10-28 12:21:20 -07:00
parent 1a87fa7fe3
commit c28c3c5aab
7 changed files with 55 additions and 92 deletions

View file

@ -495,8 +495,8 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
cproject = cpp ? cproject = cpp ?
CProjectHelper.createCCProject(getName()+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) : CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) :
CProjectHelper.createCProject(getName()+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER); CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
Bundle b = CTestPlugin.getDefault().getBundle(); Bundle b = CTestPlugin.getDefault().getBundle();
testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2); testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner; import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
/** /**
* Lambda expression, introduced in C++0x. * Lambda expression, introduced in C++11.
* *
* @since 5.3 * @since 5.3
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
@ -65,7 +65,6 @@ public interface ICPPASTLambdaExpression extends ICPPASTExpression, IASTImplicit
*/ */
IASTCompoundStatement getBody(); IASTCompoundStatement getBody();
/** /**
* Not allowed on frozen AST. * Not allowed on frozen AST.
* @see #getCaptureDefault() * @see #getCaptureDefault()

View file

@ -12,121 +12,79 @@
package org.eclipse.cdt.core.dom.parser.cpp; package org.eclipse.cdt.core.dom.parser.cpp;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider; import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.IToken.ContextSensitiveTokenType; import org.eclipse.cdt.core.parser.IToken.ContextSensitiveTokenType;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider; import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
/** /**
* Abstract C++ parser extension configuration to help model C++ dialects. * Abstract C++ parser extension configuration to help model C++ dialects.
* *
* @since 4.0 * @since 4.0
*/ */
public abstract class AbstractCPPParserExtensionConfiguration implements ICPPParserExtensionConfiguration { public abstract class AbstractCPPParserExtensionConfiguration implements ICPPParserExtensionConfiguration {
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#allowRestrictPointerOperators()
*/
@Override @Override
public boolean allowRestrictPointerOperators() { public boolean allowRestrictPointerOperators() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportAlignOfUnaryExpression()
*/
@Override @Override
public boolean supportAlignOfUnaryExpression() { public boolean supportAlignOfUnaryExpression() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportAttributeSpecifiers()
*/
@Override @Override
public boolean supportAttributeSpecifiers() { public boolean supportAttributeSpecifiers() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportComplexNumbers()
*/
@Override @Override
public boolean supportComplexNumbers() { public boolean supportComplexNumbers() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportDeclspecSpecifiers()
*/
@Override @Override
public boolean supportDeclspecSpecifiers() { public boolean supportDeclspecSpecifiers() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportExtendedTemplateSyntax()
*/
@Override @Override
public boolean supportExtendedTemplateSyntax() { public boolean supportExtendedTemplateSyntax() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportGCCOtherBuiltinSymbols()
*/
@Override @Override
public boolean supportGCCOtherBuiltinSymbols() { public boolean supportGCCOtherBuiltinSymbols() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportKnRC()
*/
@Override @Override
public boolean supportKnRC() { public boolean supportKnRC() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportLongLongs()
*/
@Override @Override
public boolean supportLongLongs() { public boolean supportLongLongs() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportMinAndMaxOperators()
*/
@Override @Override
public boolean supportMinAndMaxOperators() { public boolean supportMinAndMaxOperators() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportRestrictKeyword()
*/
@Override @Override
public boolean supportRestrictKeyword() { public boolean supportRestrictKeyword() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportStatementsInExpressions()
*/
@Override @Override
public boolean supportStatementsInExpressions() { public boolean supportStatementsInExpressions() {
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportTypeofUnaryExpressions()
*/
@Override @Override
public boolean supportTypeofUnaryExpressions() { public boolean supportTypeofUnaryExpressions() {
return false; return false;
@ -159,9 +117,6 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
return false; return false;
} }
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#getBuiltinBindingsProvider()
*/
@Override @Override
public IBuiltinBindingsProvider getBuiltinBindingsProvider() { public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
return new GCCBuiltinSymbolProvider(ParserLanguage.CPP, supportGCCOtherBuiltinSymbols()); return new GCCBuiltinSymbolProvider(ParserLanguage.CPP, supportGCCOtherBuiltinSymbols());

View file

@ -30,8 +30,9 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
/** /**
* Handles ambiguities for parameter declarations. * Handles ambiguities for parameter declarations.
* <br> * <pre>
* void function(const D*); // is D a type? * void function(const D*); // is D a type?
* </pre>
* @since 5.0.1 * @since 5.0.1
*/ */
public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration { public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration {
@ -47,7 +48,7 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements
@Override @Override
protected void beforeResolution() { protected void beforeResolution() {
// populate containing scope, so that it will not be affected by the alternative branches. // Populate containing scope, so that it will not be affected by the alternative branches.
IScope scope= CVisitor.getContainingScope(this); IScope scope= CVisitor.getContainingScope(this);
if (scope instanceof IASTInternalScope) { if (scope instanceof IASTInternalScope) {
((IASTInternalScope) scope).populateCache(); ((IASTInternalScope) scope).populateCache();
@ -94,6 +95,7 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements
return fSimpleDecl.getAttributes(); return fSimpleDecl.getAttributes();
} }
@Deprecated
@Override @Override
public void addAttribute(IASTAttribute attribute) { public void addAttribute(IASTAttribute attribute) {
fSimpleDecl.addAttribute(attribute); fSimpleDecl.addAttribute(attribute);
@ -114,18 +116,18 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements
final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent();
IASTNode nodeToReplace= this; IASTNode nodeToReplace= this;
// handle nested ambiguities first // Handle nested ambiguities first.
owner.replace(nodeToReplace, fSimpleDecl); owner.replace(nodeToReplace, fSimpleDecl);
IASTDeclSpecifier declSpec= fSimpleDecl.getDeclSpecifier(); IASTDeclSpecifier declSpec= fSimpleDecl.getDeclSpecifier();
declSpec.accept(resolver); declSpec.accept(resolver);
// find nested names // Find nested names.
final NameCollector nameCollector= new NameCollector(); final NameCollector nameCollector= new NameCollector();
declSpec.accept(nameCollector); declSpec.accept(nameCollector);
final IASTName[] names= nameCollector.getNames(); final IASTName[] names= nameCollector.getNames();
// resolve names // Resolve names.
boolean hasIssue= false; boolean hasIssue= false;
for (IASTName name : names) { for (IASTName name : names) {
try { try {
@ -140,13 +142,13 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements
} }
} }
if (hasIssue) { if (hasIssue) {
// use the alternate version // Use the alternate version.
final IASTAmbiguityParent parent = (IASTAmbiguityParent) fSimpleDecl; final IASTAmbiguityParent parent = (IASTAmbiguityParent) fSimpleDecl;
parent.replace(declSpec, fAltDeclSpec); parent.replace(declSpec, fAltDeclSpec);
parent.replace(fSimpleDecl.getDeclarators()[0], fAltDtor); parent.replace(fSimpleDecl.getDeclarators()[0], fAltDtor);
} }
// resolve further nested ambiguities // Resolve further nested ambiguities.
fSimpleDecl.accept(resolver); fSimpleDecl.accept(resolver);
return fSimpleDecl; return fSimpleDecl;
} }

View file

@ -15,11 +15,13 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Deque;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -95,7 +97,7 @@ public class ClassTypeHelper {
return new IBinding[] { new ProblemBinding(node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray()) }; return new IBinding[] { new ProblemBinding(node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray()) };
} }
} }
ObjectSet<IBinding> resultSet = new ObjectSet<IBinding>(2); ObjectSet<IBinding> resultSet = new ObjectSet<>(2);
IASTDeclaration[] members = host.getCompositeTypeSpecifier().getMembers(); IASTDeclaration[] members = host.getCompositeTypeSpecifier().getMembers();
for (IASTDeclaration decl : members) { for (IASTDeclaration decl : members) {
while (decl instanceof ICPPASTTemplateDeclaration) { while (decl instanceof ICPPASTTemplateDeclaration) {
@ -134,7 +136,7 @@ public class ClassTypeHelper {
* A class is considered a friend of itself. * A class is considered a friend of itself.
* @param binding a binding. * @param binding a binding.
* @param classType a class. * @param classType a class.
* @return <code>true</code> if <code>binding</code> is a friend of <code>classType</code>. * @return {@code true} if {@code binding} is a friend of {@code classType}.
*/ */
public static boolean isFriend(IBinding binding, ICPPClassType classType) { public static boolean isFriend(IBinding binding, ICPPClassType classType) {
IType type; IType type;
@ -282,7 +284,7 @@ public class ClassTypeHelper {
* @return An array of base classes in arbitrary order. * @return An array of base classes in arbitrary order.
*/ */
public static ICPPClassType[] getAllBases(ICPPClassType classType, IASTNode point) { public static ICPPClassType[] getAllBases(ICPPClassType classType, IASTNode point) {
HashSet<ICPPClassType> result= new HashSet<ICPPClassType>(); HashSet<ICPPClassType> result= new HashSet<>();
result.add(classType); result.add(classType);
getAllBases(classType, result, point); getAllBases(classType, result, point);
result.remove(classType); result.remove(classType);
@ -304,7 +306,7 @@ public class ClassTypeHelper {
/** /**
* Checks inheritance relationship between two classes. * Checks inheritance relationship between two classes.
* @return <code>true</code> if {@code subclass} is a subclass of {@code superclass}. * @return {@code true} if {@code subclass} is a subclass of {@code superclass}.
*/ */
public static boolean isSubclass(ICPPClassType subclass, ICPPClassType superclass, IASTNode point) { public static boolean isSubclass(ICPPClassType subclass, ICPPClassType superclass, IASTNode point) {
ICPPBase[] bases= getBases(subclass, point); ICPPBase[] bases= getBases(subclass, point);
@ -348,7 +350,7 @@ public class ClassTypeHelper {
* include methods declared in base classes. * include methods declared in base classes.
*/ */
public static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType, IASTNode point) { public static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType, IASTNode point) {
ObjectSet<ICPPMethod> set= new ObjectSet<ICPPMethod>(4); ObjectSet<ICPPMethod> set= new ObjectSet<>(4);
set.addAll(ClassTypeHelper.getDeclaredMethods(classType, point)); set.addAll(ClassTypeHelper.getDeclaredMethods(classType, point));
set.addAll(getImplicitMethods(classType, point)); set.addAll(getImplicitMethods(classType, point));
return set; return set;
@ -585,8 +587,8 @@ public class ClassTypeHelper {
if (mcl == null) if (mcl == null)
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
final ArrayList<ICPPMethod> result= new ArrayList<ICPPMethod>(); final ArrayList<ICPPMethod> result= new ArrayList<>();
final HashMap<ICPPClassType, Boolean> virtualInClass= new HashMap<ICPPClassType, Boolean>(); final HashMap<ICPPClassType, Boolean> virtualInClass= new HashMap<>();
final ICPPFunctionType methodType= method.getType(); final ICPPFunctionType methodType= method.getType();
virtualInClass.put(mcl, method.isVirtual()); virtualInClass.put(mcl, method.isVirtual());
@ -679,7 +681,7 @@ public class ClassTypeHelper {
public static ICPPMethod[] findOverriders(ICPPClassType[] subclasses, ICPPMethod method) { public static ICPPMethod[] findOverriders(ICPPClassType[] subclasses, ICPPMethod method) {
final char[] mname= method.getNameCharArray(); final char[] mname= method.getNameCharArray();
final ICPPFunctionType mft= method.getType(); final ICPPFunctionType mft= method.getType();
final ArrayList<ICPPMethod> result= new ArrayList<ICPPMethod>(); final ArrayList<ICPPMethod> result= new ArrayList<>();
for (ICPPClassType subClass : subclasses) { for (ICPPClassType subClass : subclasses) {
ICPPMethod[] methods= subClass.getDeclaredMethods(); ICPPMethod[] methods= subClass.getDeclaredMethods();
for (ICPPMethod candidate : methods) { for (ICPPMethod candidate : methods) {
@ -693,14 +695,15 @@ public class ClassTypeHelper {
} }
private static ICPPClassType[] getSubClasses(IIndex index, ICPPClassType mcl) throws CoreException { private static ICPPClassType[] getSubClasses(IIndex index, ICPPClassType mcl) throws CoreException {
List<ICPPBinding> result= new LinkedList<ICPPBinding>(); Deque<ICPPBinding> result= new ArrayDeque<>();
HashSet<String> handled= new HashSet<String>(); HashSet<String> handled= new HashSet<>();
getSubClasses(index, mcl, result, handled); getSubClasses(index, mcl, result, handled);
result.remove(0); result.remove(0);
return result.toArray(new ICPPClassType[result.size()]); return result.toArray(new ICPPClassType[result.size()]);
} }
private static void getSubClasses(IIndex index, ICPPBinding classOrTypedef, List<ICPPBinding> result, HashSet<String> handled) throws CoreException { private static void getSubClasses(IIndex index, ICPPBinding classOrTypedef,
Collection<ICPPBinding> result, HashSet<String> handled) throws CoreException {
if (!(classOrTypedef instanceof IType)) if (!(classOrTypedef instanceof IType))
return; return;
@ -778,7 +781,7 @@ public class ClassTypeHelper {
ICPPParameter[] parameters = method.getParameters(); ICPPParameter[] parameters = method.getParameters();
if (parameters.length == 0) if (parameters.length == 0)
return Collections.emptyList(); return Collections.emptyList();
List<IType> types = new ArrayList<IType>(parameters.length); List<IType> types = new ArrayList<>(parameters.length);
for (ICPPParameter parameter : parameters) { for (ICPPParameter parameter : parameters) {
if (!parameter.hasDefaultValue() && !parameter.isParameterPack()) if (!parameter.hasDefaultValue() && !parameter.isParameterPack())
types.add(parameter.getType()); types.add(parameter.getType());
@ -800,7 +803,7 @@ public class ClassTypeHelper {
if (kind == MethodKind.OTHER) if (kind == MethodKind.OTHER)
return null; return null;
List<IType> inheritedTypeids = new ArrayList<IType>(); List<IType> inheritedTypeids = new ArrayList<>();
ICPPClassType[] bases= getAllBases(owner, point); ICPPClassType[] bases= getAllBases(owner, point);
for (ICPPClassType base : bases) { for (ICPPClassType base : bases) {
if (!(base instanceof ICPPDeferredClassInstance)) { if (!(base instanceof ICPPDeferredClassInstance)) {
@ -874,11 +877,11 @@ public class ClassTypeHelper {
} }
/** /**
* Returns the visibility for a given <code>member</code> in the <code>host</code>. * Returns the visibility for a given {@code member} in the {@code host}.
* Throws an IllegalArgumentException if <code>member</code> is not a member of <code>host</code> * Throws an IllegalArgumentException if {@code member} is not a member of {@code host}
* *
* @param classType The class to get the member's visibility specifier of. * @param classType The class to get the member's visibility specifier of.
* @return the visibility of the <code>member</code>. * @return the visibility of the {@code member}.
*/ */
public static int getVisibility(ICPPInternalClassTypeMixinHost classType, IBinding member) { public static int getVisibility(ICPPInternalClassTypeMixinHost classType, IBinding member) {
if (classType.getDefinition() == null) { if (classType.getDefinition() == null) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 Tomasz Wesolowski * Copyright (c) 2010, 2014 Tomasz Wesolowski
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.INodeFactory;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
@ -128,18 +129,19 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator {
IASTDeclarator returnedDeclarator = null; IASTDeclarator returnedDeclarator = null;
try { try {
// Addition of pointer operators has to be in reverse order, so it's deferred until the end // Addition of pointer operators has to be in reverse order, so it's deferred until
// the end.
Map<IASTDeclarator, LinkedList<IASTPointerOperator>> pointerOperatorMap = new HashMap<IASTDeclarator, LinkedList<IASTPointerOperator>>(); Map<IASTDeclarator, LinkedList<IASTPointerOperator>> pointerOperatorMap = new HashMap<IASTDeclarator, LinkedList<IASTPointerOperator>>();
IASTName newName = name != null ? factory.newName(name) : factory.newName(); IASTName newName = name != null ? factory.newName(name) : factory.newName();
// If the type is an array of something, create a declaration of a pointer to something instead // If the type is an array of something, create a declaration of a pointer to something
// (to allow assignment, etc) // instead (to allow assignment, etc).
boolean replaceInitialArrayWithPointer = true; boolean replaceInitialArrayWithPointer = true;
// If the type is a function, create a declaration of a pointer to this function // If the type is a function, create a declaration of a pointer to this function
// (shorthand notation for function address) // (shorthand notation for function address).
boolean changeInitialFunctionToFuncPtr = true; boolean changeInitialFunctionToFuncPtr = true;
@ -151,7 +153,7 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator {
} else if (changeInitialFunctionToFuncPtr && type instanceof IFunctionType) { } else if (changeInitialFunctionToFuncPtr && type instanceof IFunctionType) {
returnedDeclarator = factory.newDeclarator(newName); returnedDeclarator = factory.newDeclarator(newName);
returnedDeclarator.addPointerOperator(factory.newPointer()); returnedDeclarator.addPointerOperator(factory.newPointer());
// leave type as it is, next iteration will handle the function // Leave type as it is, next iteration will handle the function.
} else if (type instanceof IArrayType) { } else if (type instanceof IArrayType) {
IArrayType arrayType = (IArrayType) type; IArrayType arrayType = (IArrayType) type;
IASTArrayDeclarator arrayDeclarator = factory.newArrayDeclarator(null); IASTArrayDeclarator arrayDeclarator = factory.newArrayDeclarator(null);
@ -161,7 +163,7 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator {
arrayDeclarator.setNestedDeclarator(returnedDeclarator); arrayDeclarator.setNestedDeclarator(returnedDeclarator);
arrayDeclarator.setName(factory.newName()); arrayDeclarator.setName(factory.newName());
} }
// consume all immediately following array expressions // Consume all immediately following array expressions.
while (type instanceof IArrayType) { while (type instanceof IArrayType) {
arrayType = (IArrayType) type; arrayType = (IArrayType) type;
IASTExpression arraySizeExpression = arrayType.getArraySizeExpression(); IASTExpression arraySizeExpression = arrayType.getArraySizeExpression();
@ -233,7 +235,7 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator {
IASTDeclarator returnedDeclarator, IASTPointerOperator ptrOp) { IASTDeclarator returnedDeclarator, IASTPointerOperator ptrOp) {
LinkedList<IASTPointerOperator> list; LinkedList<IASTPointerOperator> list;
if (!pointerOperatorMap.containsKey(returnedDeclarator)) { if (!pointerOperatorMap.containsKey(returnedDeclarator)) {
list = new LinkedList<IASTPointerOperator>(); list = new LinkedList<>();
pointerOperatorMap.put(returnedDeclarator, list); pointerOperatorMap.put(returnedDeclarator, list);
} else { } else {
list = pointerOperatorMap.get(returnedDeclarator); list = pointerOperatorMap.get(returnedDeclarator);
@ -289,13 +291,12 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator {
ICPPASTTemplateId tempId = getTemplateId(type, templateName); ICPPASTTemplateId tempId = getTemplateId(type, templateName);
ICPPASTQualifiedName newQualifiedName = ICPPASTQualifiedName newQualifiedName =
((ICPPNodeFactory) factory).newQualifiedName(); ((ICPPNodeFactory) factory).newQualifiedName(tempId);
ICPPASTNameSpecifier[] qualifier = fullQualifiedName.getQualifier(); ICPPASTNameSpecifier[] qualifier = fullQualifiedName.getQualifier();
int nbQualifiedNames = qualifier.length; int nbQualifiedNames = qualifier.length;
for (int i = 0; i < nbQualifiedNames; i++) { for (int i = 0; i < nbQualifiedNames; i++) {
newQualifiedName.addNameSpecifier(qualifier[i].copy(CopyStyle.withLocations)); newQualifiedName.addNameSpecifier(qualifier[i].copy(CopyStyle.withLocations));
} }
newQualifiedName.setLastName(tempId);
return factory.newTypedefNameSpecifier(newQualifiedName); return factory.newTypedefNameSpecifier(newQualifiedName);
} else { } else {
@ -329,9 +330,12 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator {
char[][] qualifiedNameCharArray = CPPVisitor.getQualifiedNameCharArray(binding); char[][] qualifiedNameCharArray = CPPVisitor.getQualifiedNameCharArray(binding);
IASTName name; IASTName name;
if (qualifiedNameCharArray.length > 1) { if (qualifiedNameCharArray.length > 1) {
name = ((ICPPNodeFactory) factory).newQualifiedName(); char[] cs = qualifiedNameCharArray[qualifiedNameCharArray.length - 1];
for (char[] cs : qualifiedNameCharArray) { IASTName segment = factory.newName(cs);
((ICPPASTQualifiedName) name).addName(factory.newName(cs)); name = ((ICPPNodeFactory) factory).newQualifiedName((ICPPASTName) segment);
for (int i = 0; i < qualifiedNameCharArray.length - 1; i++) {
segment = factory.newName(cs);
((ICPPASTQualifiedName) name).addName(factory.newName(qualifiedNameCharArray[i]));
} }
} else if (qualifiedNameCharArray.length == 1) { } else if (qualifiedNameCharArray.length == 1) {
name = factory.newName(qualifiedNameCharArray[0]); name = factory.newName(qualifiedNameCharArray[0]);

View file

@ -234,12 +234,12 @@ public class MacroDefinitionParser {
default: default:
throw new InvalidMacroDefinitionException(name.getCharImage(), name.getOffset(), param.getEndOffset()); throw new InvalidMacroDefinitionException(name.getCharImage(), name.getOffset(), param.getEndOffset());
} }
} } while (fHasVarArgs == 0 && next.getType() == IToken.tCOMMA);
while (fHasVarArgs==0 && next.getType() == IToken.tCOMMA);
if (next.getType() != IToken.tRPAREN) { if (next.getType() != IToken.tRPAREN) {
throw new InvalidMacroDefinitionException(name.getCharImage(), name.getOffset(), next.getEndOffset()); throw new InvalidMacroDefinitionException(name.getCharImage(), name.getOffset(), next.getEndOffset());
} }
next= lex.nextToken(); // consume the closing parenthesis next= lex.nextToken(); // Consume the closing parenthesis.
return paramList.toArray(new char[paramList.size()][]); return paramList.toArray(new char[paramList.size()][]);
} }