mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 406462 - Allow designated initializers for C++
Change-Id: Iafadba03e6a54b679b4c10ea693a5f8a84ddf839
This commit is contained in:
parent
49a9b0c3f6
commit
f0bd13a754
26 changed files with 4574 additions and 3632 deletions
|
@ -24,7 +24,11 @@ import static org.eclipse.cdt.core.parser.ParserLanguage.CPP;
|
|||
import static org.eclipse.cdt.core.parser.tests.VisibilityAsserts.assertVisibility;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
|
@ -90,11 +94,14 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignatedInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
|
@ -133,6 +140,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.SemanticQueries;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTArrayRangeDesignator;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
@ -151,11 +159,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class AST2CPPTests extends AST2TestBase {
|
||||
|
||||
|
@ -11625,4 +11629,40 @@ public class AST2CPPTests extends AST2TestBase {
|
|||
// this test will need to be updated.
|
||||
helper.assertVariableValue("generic_lambdas_supported", 0);
|
||||
}
|
||||
|
||||
|
||||
// struct S {
|
||||
// int x;
|
||||
// int y;
|
||||
// int z[10];
|
||||
// };
|
||||
// S a = { .x = 10, .y = 11 };
|
||||
// S b = { .z[4 ... 6] = 3 };
|
||||
// int c[6] = { [4] = 29, [2] = 15 };
|
||||
// int d[6] = { [2 ... 4] = 29 };
|
||||
public void testDesignatedInitializers() throws Exception {
|
||||
BindingAssertionHelper bh = getAssertionHelper();
|
||||
ICPPASTDesignatedInitializer d1 = bh.assertNode(".x = 10");
|
||||
assertEquals(1, d1.getDesignators().length);
|
||||
assertTrue(d1.getDesignators()[0] instanceof ICPPASTFieldDesignator);
|
||||
ICPPASTDesignatedInitializer d2 = bh.assertNode(".y = 11");
|
||||
assertEquals(1, d2.getDesignators().length);
|
||||
assertTrue(d2.getDesignators()[0] instanceof ICPPASTFieldDesignator);
|
||||
ICPPASTDesignatedInitializer d3 = bh.assertNode(".z[4 ... 6] = 3");
|
||||
assertEquals(2, d3.getDesignators().length);
|
||||
assertTrue(d3.getDesignators()[0] instanceof ICPPASTFieldDesignator);
|
||||
assertTrue(d3.getDesignators()[1] instanceof IGPPASTArrayRangeDesignator);
|
||||
ICPPASTDesignatedInitializer d4 = bh.assertNode("[4] = 29");
|
||||
assertEquals(1, d4.getDesignators().length);
|
||||
assertTrue(d4.getDesignators()[0] instanceof ICPPASTArrayDesignator);
|
||||
ICPPASTDesignatedInitializer d5 = bh.assertNode("[2] = 15");
|
||||
assertEquals(1, d5.getDesignators().length);
|
||||
assertTrue(d5.getDesignators()[0] instanceof ICPPASTArrayDesignator);
|
||||
ICPPASTDesignatedInitializer d6 = bh.assertNode("[2 ... 4] = 29");
|
||||
assertEquals(1, d6.getDesignators().length);
|
||||
assertTrue(d6.getDesignators()[0] instanceof IGPPASTArrayRangeDesignator);
|
||||
ICPPField x = bh.assertNonProblemOnFirstIdentifier(".x");
|
||||
ICPPField y = bh.assertNonProblemOnFirstIdentifier(".y");
|
||||
ICPPField a = bh.assertNonProblemOnFirstIdentifier(".z[4 ... 6]");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,14 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* For testing resolution of bindings in C++ code with GNU extensions.
|
||||
*/
|
||||
|
@ -71,17 +72,28 @@ public abstract class IndexGPPBindingResolutionTest extends IndexBindingResoluti
|
|||
public SingleProject() { setStrategy(new GPPSinglePDOMTestStrategy()); }
|
||||
public static TestSuite suite() { return suite(SingleProject.class); }
|
||||
}
|
||||
|
||||
|
||||
public static class ProjectWithDepProj extends IndexGPPBindingResolutionTest {
|
||||
public ProjectWithDepProj() { setStrategy(new GPPReferencedProject()); }
|
||||
public static TestSuite suite() { return suite(ProjectWithDepProj.class); }
|
||||
}
|
||||
|
||||
|
||||
public static void addTests(TestSuite suite) {
|
||||
suite.addTest(SingleProject.suite());
|
||||
suite.addTest(ProjectWithDepProj.suite());
|
||||
}
|
||||
|
||||
|
||||
// struct B {
|
||||
// float f;
|
||||
// };
|
||||
|
||||
// struct B b = {
|
||||
// .f = 3.1
|
||||
// };
|
||||
public void testDesignatedInitializer() throws Exception {
|
||||
IField f= getBindingFromASTName("f", 0);
|
||||
}
|
||||
|
||||
// template <typename T>
|
||||
// struct underlying_type {
|
||||
// typedef __underlying_type(T) type;
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignatedInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
|
||||
|
@ -378,7 +379,7 @@ public class ASTStringUtil {
|
|||
}
|
||||
trimRight(buffer);
|
||||
buffer.append(Keywords.cpRBRACE);
|
||||
} else if (initializer instanceof ICASTDesignatedInitializer) {
|
||||
} else if (initializer instanceof ICASTDesignatedInitializer || initializer instanceof ICPPASTDesignatedInitializer) {
|
||||
//TODO handle ICASTDesignatedInitializer?
|
||||
// final ICASTDesignatedInitializer designatedInitializer= (ICASTDesignatedInitializer) initializer;
|
||||
// final ICASTDesignator[] designator= designatedInitializer.getDesignators();
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTClassVirtSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVirtSpecifier;
|
||||
|
@ -345,14 +346,21 @@ public abstract class ASTVisitor {
|
|||
public int visit(ICASTDesignator designator) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.12
|
||||
*/
|
||||
public int visit(ICPPASTDesignator designator) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.7
|
||||
*/
|
||||
public int visit(ICPPASTVirtSpecifier virtSpecifier) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.7
|
||||
*/
|
||||
|
@ -475,7 +483,14 @@ public abstract class ASTVisitor {
|
|||
public int leave(ICASTDesignator designator) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.12
|
||||
*/
|
||||
public int leave(ICPPASTDesignator designator) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.7
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
|
||||
/**
|
||||
* Array designator, e.g. [4] in int a[6] = { [4] = 29, [2] = 15 };
|
||||
* @since 5.12
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPASTArrayDesignator extends ICPPASTDesignator {
|
||||
/**
|
||||
* The relationship between the array designator and the subscript expression.
|
||||
*/
|
||||
public static final ASTNodeProperty SUBSCRIPT_EXPRESSION = new ASTNodeProperty(
|
||||
"ICPPASTArrayDesignator.SUBSCRIPT_EXPRESSION - expression inside square brackets"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns the subscript expression.
|
||||
*/
|
||||
public ICPPASTExpression getSubscriptExpression();
|
||||
|
||||
/**
|
||||
* Sets the subscript expression.
|
||||
*
|
||||
* @param expression the expression for the subscript
|
||||
*/
|
||||
public void setSubscriptExpression(ICPPASTExpression expression);
|
||||
|
||||
@Override
|
||||
public ICPPASTArrayDesignator copy();
|
||||
|
||||
@Override
|
||||
public ICPPASTArrayDesignator copy(CopyStyle style);
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||
|
||||
/**
|
||||
* This interface represents a designated initializer,
|
||||
* e.g. in struct A y = { .z = 4, .t[1] = 3 };
|
||||
* @since 5.12
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPASTDesignatedInitializer extends IASTInitializer, ICPPASTInitializerClause {
|
||||
/** The part of the initializer before the equal sign. */
|
||||
public static final ASTNodeProperty DESIGNATOR = new ASTNodeProperty(
|
||||
"ICPPASTDesignatedInitializer.DESIGNATOR - [ICPPASTDesignator]"); //$NON-NLS-1$
|
||||
|
||||
/** The part of the initializer after the equal sign. */
|
||||
public static final ASTNodeProperty OPERAND = new ASTNodeProperty(
|
||||
"ICPPASTDesignatedInitializer.OPERAND - [ICPPASTInitializerClause]"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Adds a designator to this initializer.
|
||||
*/
|
||||
public void addDesignator(ICPPASTDesignator designator);
|
||||
|
||||
/**
|
||||
* Returns all of the designators.
|
||||
*/
|
||||
public ICPPASTDesignator[] getDesignators();
|
||||
|
||||
/**
|
||||
* Returns the operand of the initializer.
|
||||
*/
|
||||
public ICPPASTInitializerClause getOperand();
|
||||
|
||||
/**
|
||||
* Sets the initializer clause. Not allowed on a frozen AST.
|
||||
*/
|
||||
void setOperand(ICPPASTInitializerClause operand);
|
||||
|
||||
@Override
|
||||
public ICPPASTDesignatedInitializer copy();
|
||||
|
||||
@Override
|
||||
public ICPPASTDesignatedInitializer copy(CopyStyle style);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
||||
/**
|
||||
* Base interface for all C-style designators.
|
||||
* @since 5.12
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPASTDesignator extends IASTNode {
|
||||
public static final ICPPASTDesignator[] EMPTY_ARRAY = {};
|
||||
|
||||
@Override
|
||||
public ICPPASTDesignator copy();
|
||||
|
||||
@Override
|
||||
public ICPPASTDesignator copy(CopyStyle style);
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
|
||||
/**
|
||||
* Specific designator that represents a field reference.
|
||||
* @since 5.12
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPASTFieldDesignator extends ICPPASTDesignator {
|
||||
/** The name of the field being initialized. */
|
||||
public static final ASTNodeProperty FIELD_NAME = new ASTNodeProperty(
|
||||
"ICPPASTFieldDesignator.FIELD_NAME - field name"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns the field name.
|
||||
*/
|
||||
public IASTName getName();
|
||||
|
||||
/**
|
||||
* Sets the field name.
|
||||
*/
|
||||
public void setName(IASTName name);
|
||||
|
||||
@Override
|
||||
public ICPPASTFieldDesignator copy();
|
||||
|
||||
@Override
|
||||
public ICPPASTFieldDesignator copy(CopyStyle style);
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
* Mike Kucera (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Thomas Corbat (IFS)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
@ -30,26 +31,42 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
|||
import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation.Operator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTArrayRangeDesignator;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
|
||||
/**
|
||||
* Factory for AST nodes for the C++ programming language.
|
||||
*
|
||||
*
|
||||
* @since 5.1
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPNodeFactory extends INodeFactory {
|
||||
/**
|
||||
* @since 5.5
|
||||
*/
|
||||
public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId aliasedType);
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
@Override
|
||||
public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.12
|
||||
*/
|
||||
public ICPPASTArrayDesignator newArrayDesignator(ICPPASTExpression exp);
|
||||
|
||||
/**
|
||||
* @since 5.12
|
||||
*/
|
||||
public IGPPASTArrayRangeDesignator newArrayRangeDesignatorGPP(ICPPASTExpression floor, ICPPASTExpression ceiling);
|
||||
|
||||
@Override
|
||||
public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
|
@ -67,15 +84,15 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
|
||||
@Deprecated
|
||||
public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.8
|
||||
*/
|
||||
public ICPPASTBaseSpecifier newBaseSpecifier(ICPPASTNameSpecifier nameSpecifier, int visibility, boolean isVirtual);
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
|
@ -90,20 +107,20 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
* @since 5.3
|
||||
*/
|
||||
public ICPPASTCapture newCapture();
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand);
|
||||
|
||||
|
||||
public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body);
|
||||
|
||||
/**
|
||||
* @since 5.7
|
||||
*/
|
||||
public ICPPASTClassVirtSpecifier newClassVirtSpecifier(ICPPASTClassVirtSpecifier.SpecifierKind kind);
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newConstructorChainInitializer(IASTName, IASTInitializer)}
|
||||
*/
|
||||
|
@ -120,7 +137,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
@Deprecated
|
||||
public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
|
@ -133,14 +150,19 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
@Override
|
||||
public ICPPASTDeclarator newDeclarator(IASTName name);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.6
|
||||
*/
|
||||
public ICPPASTDecltypeSpecifier newDecltypeSpecifier(ICPPASTExpression decltypeExpression);
|
||||
|
||||
|
||||
public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
|
||||
|
||||
/**
|
||||
* @since 5.12
|
||||
*/
|
||||
public ICPPASTDesignatedInitializer newDesignatedInitializer(ICPPASTInitializerClause initializer);
|
||||
|
||||
@Override
|
||||
public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
|
||||
|
||||
|
@ -148,7 +170,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTEnumerationSpecifier newEnumerationSpecifier(boolean isScoped, IASTName name, ICPPASTDeclSpecifier baseType);
|
||||
|
||||
|
||||
public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration);
|
||||
|
||||
/**
|
||||
|
@ -159,50 +181,55 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
|
||||
@Override
|
||||
public ICPPASTExpressionList newExpressionList();
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
@Override
|
||||
public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.12
|
||||
*/
|
||||
public ICPPASTFieldDesignator newFieldDesignator(IASTName name);
|
||||
|
||||
@Override
|
||||
public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner);
|
||||
|
||||
|
||||
public ICPPASTForStatement newForStatement();
|
||||
|
||||
public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition,
|
||||
IASTExpression iterationExpression, IASTStatement body);
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
|
||||
IASTExpression iterationExpression, IASTStatement body);
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newFunctionCallExpression(IASTExpression, IASTInitializerClause[])}.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
@Override
|
||||
public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTInitializerClause[] arguments);
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name);
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
|
||||
IASTFunctionDeclarator declarator, IASTStatement bodyStatement);
|
||||
|
||||
|
||||
public ICPPASTFunctionWithTryBlock newFunctionTryBlock(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
|
||||
IASTStatement bodyStatement);
|
||||
|
||||
|
||||
public ICPPASTIfStatement newIfStatement();
|
||||
|
||||
|
||||
public ICPPASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause);
|
||||
|
||||
@Override
|
||||
|
@ -213,7 +240,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
@Override
|
||||
public ICPPASTInitializerList newInitializerList();
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
|
@ -223,9 +250,9 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
|
||||
@Override
|
||||
public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep);
|
||||
|
||||
|
||||
public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName);
|
||||
|
||||
|
||||
public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name);
|
||||
|
||||
/**
|
||||
|
@ -233,7 +260,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
@Deprecated
|
||||
public ICPPASTNewExpression newNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
|
@ -246,7 +273,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern);
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
|
||||
|
||||
|
@ -257,13 +284,13 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer newPointerGPP();
|
||||
|
||||
public ICPPASTPointerToMember newPointerToMember(IASTName name);
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newPointerToMember(IASTName)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember newPointerToMemberGPP(IASTName name);
|
||||
|
||||
|
||||
public IASTProblemTypeId newProblemTypeId(IASTProblem problem);
|
||||
|
||||
/**
|
||||
|
@ -291,7 +318,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
@Override
|
||||
public ICPPASTName newName();
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.9
|
||||
*/
|
||||
|
@ -313,13 +340,13 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
* @deprecated Replaced by {@link #newReferenceOperator(boolean)}.
|
||||
*/
|
||||
@Deprecated public ICPPASTReferenceOperator newReferenceOperator();
|
||||
|
||||
|
||||
/**
|
||||
* Creates an lvalue or rvalue reference operator.
|
||||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTReferenceOperator newReferenceOperator(boolean isRValueReference);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
|
@ -333,12 +360,12 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
@Deprecated
|
||||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier declSpec, IASTInitializer initializer);
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier, IASTInitializer)}
|
||||
*/
|
||||
|
@ -346,7 +373,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression);
|
||||
|
||||
public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId);
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new static assertion declaration with the given condition and message.
|
||||
* @since 5.2
|
||||
|
@ -359,11 +386,11 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
|
||||
@Override
|
||||
public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controlloer, IASTStatement body);
|
||||
|
||||
|
||||
public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration);
|
||||
|
||||
|
||||
public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression defaultValue);
|
||||
|
||||
|
||||
public ICPPASTTemplateId newTemplateId(IASTName templateName);
|
||||
|
||||
public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration);
|
||||
|
@ -383,9 +410,9 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
@Override
|
||||
public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner);
|
||||
|
||||
|
||||
public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body);
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name);
|
||||
|
||||
|
@ -394,7 +421,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
@Override
|
||||
public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator);
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId);
|
||||
|
||||
|
@ -408,7 +435,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
* @since 5.6
|
||||
*/
|
||||
public ICPPASTTypeTransformationSpecifier newTypeTransformationSpecifier(Operator kind, ICPPASTTypeId typeId);
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand);
|
||||
|
||||
|
@ -420,18 +447,13 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
* @since 5.7
|
||||
*/
|
||||
public ICPPASTVirtSpecifier newVirtSpecifier(ICPPASTVirtSpecifier.SpecifierKind kind);
|
||||
|
||||
|
||||
public ICPPASTVisibilityLabel newVisibilityLabel(int visibility);
|
||||
|
||||
|
||||
public ICPPASTWhileStatement newWhileStatement();
|
||||
|
||||
public ICPPASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body);
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
|
||||
|
||||
/**
|
||||
* @since 5.5
|
||||
*/
|
||||
public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId aliasedType);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
||||
|
||||
/**
|
||||
* GCC-specific designator that allows for shorthand array range to be specified
|
||||
* in a designated initializer, e.g. in int a[6] = { [2 ... 4] = 29 }; or
|
||||
* struct ABC { int def[10]; } abc = { .def[4 ... 6] = 3 };
|
||||
* @since 5.12
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IGPPASTArrayRangeDesignator extends ICPPASTDesignator {
|
||||
/** The start of the index range. */
|
||||
public static final ASTNodeProperty SUBSCRIPT_FLOOR_EXPRESSION = new ASTNodeProperty(
|
||||
"IGPPASTArrayRangeDesignator.SUBSCRIPT_FLOOR_EXPRESSION - start of index range"); //$NON-NLS-1$
|
||||
|
||||
/** The end of the index range. */
|
||||
public static final ASTNodeProperty SUBSCRIPT_CEILING_EXPRESSION = new ASTNodeProperty(
|
||||
"IGPPASTArrayRangeDesignator.SUBSCRIPT_CEILING_EXPRESSION - end of index range"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns the start expression of the index range.
|
||||
*/
|
||||
public ICPPASTExpression getRangeFloor();
|
||||
|
||||
/**
|
||||
* Sets the start expression of the index range.
|
||||
*
|
||||
* @param expression the expression for the start of the range
|
||||
*/
|
||||
public void setRangeFloor(ICPPASTExpression expression);
|
||||
|
||||
/**
|
||||
* Returns the end expression of the index range.
|
||||
*/
|
||||
public ICPPASTExpression getRangeCeiling();
|
||||
|
||||
/**
|
||||
* Sets the end expression of the index range.
|
||||
*
|
||||
* @param expression the expression for the end of the range
|
||||
*/
|
||||
public void setRangeCeiling(ICPPASTExpression expression);
|
||||
|
||||
@Override
|
||||
public IGPPASTArrayRangeDesignator copy();
|
||||
|
||||
@Override
|
||||
public IGPPASTArrayRangeDesignator copy(CopyStyle style);
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Richard Eames
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||
|
||||
|
@ -61,6 +62,14 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.12
|
||||
*/
|
||||
@Override
|
||||
public boolean supportGCCStyleDesignators() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportKnRC() {
|
||||
return false;
|
||||
|
@ -92,7 +101,6 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 5.1
|
||||
*/
|
||||
@Override
|
||||
|
@ -101,7 +109,6 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 5.1
|
||||
*/
|
||||
@Override
|
||||
|
@ -110,31 +117,26 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 5.1
|
||||
*/
|
||||
@Override
|
||||
public boolean supportFunctionStyleAssembler() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 5.11
|
||||
*/
|
||||
@Override
|
||||
public boolean supportUserDefinedLiterals() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#getBuiltinBindingsProvider()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
|
||||
return new GCCBuiltinSymbolProvider(ParserLanguage.CPP, supportGCCOtherBuiltinSymbols());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.9
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2015 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||
|
||||
|
@ -17,8 +18,8 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.IToken.ContextSensitiveTokenType;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||
|
||||
/**
|
||||
|
@ -33,113 +34,79 @@ public class GPPParserExtensionConfiguration extends AbstractCPPParserExtensionC
|
|||
return sInstance;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#allowRestrictPointerOperators()
|
||||
*/
|
||||
@Override
|
||||
public boolean allowRestrictPointerOperators() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportTypeofUnaryExpressions()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportTypeofUnaryExpressions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportAlignOfUnaryExpression()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportAlignOfUnaryExpression() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportExtendedTemplateSyntax()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportExtendedTemplateSyntax() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportMinAndMaxOperators()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportMinAndMaxOperators() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportStatementsInExpressions()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportStatementsInExpressions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportComplexNumbers()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportComplexNumbers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportRestrictKeyword()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportRestrictKeyword() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportLongLongs()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportLongLongs() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportKnRC()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportKnRC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportAttributeSpecifiers()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean supportAttributeSpecifiers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportDeclspecSpecifiers()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportDeclspecSpecifiers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#getBuiltinBindingsProvider()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportGCCStyleDesignators() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
|
||||
return new GCCBuiltinSymbolProvider(ParserLanguage.CPP, true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, ContextSensitiveTokenType> getAdditionalContextSensitiveKeywords() {
|
||||
Map<String, ContextSensitiveTokenType> result =
|
||||
Map<String, ContextSensitiveTokenType> result =
|
||||
new HashMap<>(super.getAdditionalContextSensitiveKeywords());
|
||||
result.put(GCCKeywords.__FINAL, ContextSensitiveTokenType.FINAL);
|
||||
return result;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* Ed Swartz (Nokia)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||
|
||||
|
@ -21,11 +22,11 @@ import org.eclipse.cdt.core.parser.IToken.ContextSensitiveTokenType;
|
|||
|
||||
/**
|
||||
* C++ parser extension configuration interface.
|
||||
*
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* Clients can subclass {@link AbstractCPPParserExtensionConfiguration} instead.
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
*
|
||||
*
|
||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html"
|
||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Extensions.html"
|
||||
* @since 4.0
|
||||
|
@ -33,7 +34,7 @@ import org.eclipse.cdt.core.parser.IToken.ContextSensitiveTokenType;
|
|||
public interface ICPPParserExtensionConfiguration {
|
||||
/**
|
||||
* Support for GNU extension "Restricting Pointer Aliasing".
|
||||
*
|
||||
*
|
||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html"
|
||||
* @return {@code true} if support for the extension should be enabled
|
||||
*/
|
||||
|
@ -41,7 +42,7 @@ public interface ICPPParserExtensionConfiguration {
|
|||
|
||||
/**
|
||||
* Support for GNU extension "Extended Syntax for Template Instantiation".
|
||||
*
|
||||
*
|
||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/Template-Instantiation.html"
|
||||
* @return {@code true} if support for the extension should be enabled
|
||||
*/
|
||||
|
@ -49,7 +50,7 @@ public interface ICPPParserExtensionConfiguration {
|
|||
|
||||
/**
|
||||
* Support for GNU extension "Data types for complex numbers".
|
||||
*
|
||||
*
|
||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/Complex.html#Complex"
|
||||
* @return {@code true} if support for the extension should be enabled
|
||||
*/
|
||||
|
@ -57,7 +58,7 @@ public interface ICPPParserExtensionConfiguration {
|
|||
|
||||
/**
|
||||
* Support for GNU long long types.
|
||||
*
|
||||
*
|
||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/Long-Long.html"
|
||||
* @return {@code true} if support for the extension should be enabled
|
||||
*/
|
||||
|
@ -65,7 +66,7 @@ public interface ICPPParserExtensionConfiguration {
|
|||
|
||||
/**
|
||||
* Support for GNU extension "Statements and Declarations in Expressions".
|
||||
*
|
||||
*
|
||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html"
|
||||
* @return {@code true} if support for the extension should be enabled
|
||||
*/
|
||||
|
@ -73,7 +74,7 @@ public interface ICPPParserExtensionConfiguration {
|
|||
|
||||
/**
|
||||
* Support for GNU extension "Referring to a Type with typeof".
|
||||
*
|
||||
*
|
||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/Typeof.html"
|
||||
* @return {@code true} if support for the extension should be enabled
|
||||
*/
|
||||
|
@ -81,7 +82,7 @@ public interface ICPPParserExtensionConfiguration {
|
|||
|
||||
/**
|
||||
* Support for GNU extension "Inquiring on Alignment of Types or Variables".
|
||||
*
|
||||
*
|
||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/Alignment.html"
|
||||
* @return {@code true} if support for the extension should be enabled
|
||||
*/
|
||||
|
@ -89,7 +90,7 @@ public interface ICPPParserExtensionConfiguration {
|
|||
|
||||
/**
|
||||
* Support for Kernighan and Richie (K&R) C.
|
||||
*
|
||||
*
|
||||
* @return {@code true} if support for K&R C should be enabled
|
||||
*/
|
||||
public boolean supportKnRC();
|
||||
|
@ -97,21 +98,21 @@ public interface ICPPParserExtensionConfiguration {
|
|||
/**
|
||||
* See http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html for more
|
||||
* information on GCC's Attribute Specifiers.
|
||||
*
|
||||
*
|
||||
* @return {@code true} if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers();
|
||||
|
||||
/**
|
||||
* Win32 compiler extensions also supported by GCC on Win32
|
||||
*
|
||||
*
|
||||
* @return {@code true} if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers();
|
||||
|
||||
/**
|
||||
* Provide additional built-in bindings.
|
||||
*
|
||||
*
|
||||
* @return an instance of {@link IBuiltinBindingsProvider} or {@code null}
|
||||
*/
|
||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider();
|
||||
|
@ -123,21 +124,21 @@ public interface ICPPParserExtensionConfiguration {
|
|||
* @since 5.1
|
||||
*/
|
||||
public boolean supportParameterInfoBlock();
|
||||
|
||||
|
||||
/**
|
||||
* Support additional parameters for the sizeof operator:
|
||||
* 'sizeof' '(' typeid ',' expression-list ')'
|
||||
* @since 5.1
|
||||
*/
|
||||
public boolean supportExtendedSizeofOperator();
|
||||
|
||||
|
||||
/**
|
||||
* Support function style assembler definitions:
|
||||
* 'asm' ['volatile'] [return-type] name '(' parameter-list ')' '{' assembler-code '}'
|
||||
* @since 5.1
|
||||
*/
|
||||
public boolean supportFunctionStyleAssembler();
|
||||
|
||||
|
||||
/**
|
||||
* Support user-defined literal expressions:
|
||||
* (char_expr | string_expr | int_expr | float_expr) ud-suffix
|
||||
|
@ -150,21 +151,30 @@ public interface ICPPParserExtensionConfiguration {
|
|||
* @since 5.9
|
||||
*/
|
||||
public Map<String, ContextSensitiveTokenType> getAdditionalContextSensitiveKeywords();
|
||||
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Designated Initializers".
|
||||
*
|
||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html"
|
||||
* @return {@code true} if support for the extension should be enabled
|
||||
* @since 5.12
|
||||
*/
|
||||
public boolean supportGCCStyleDesignators();
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getBuiltinBindingsProvider()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean supportGCCOtherBuiltinSymbols();
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated use {@link IScannerExtensionConfiguration#supportMinAndMaxOperators()}, instead.
|
||||
* @deprecated use {@link IScannerExtensionConfiguration#supportMinAndMaxOperators()}, instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean supportMinAndMaxOperators();
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated configure extra keywords, via {@link IScannerExtensionConfiguration#getAdditionalKeywords()}
|
||||
* @deprecated configure extra keywords, via {@link IScannerExtensionConfiguration#getAdditionalKeywords()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean supportRestrictKeyword();
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class CVariableReadWriteFlags extends VariableReadWriteFlags {
|
|||
public static int getReadWriteFlags(IASTName variable) {
|
||||
return INSTANCE.rwAnyNode(variable, 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int rwAnyNode(IASTNode node, int indirection) {
|
||||
final IASTNode parent= node.getParent();
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
* Implementation of array designator.
|
||||
*/
|
||||
public class CPPASTArrayDesignator extends ASTNode implements ICPPASTArrayDesignator, IASTAmbiguityParent {
|
||||
private ICPPASTExpression expression;
|
||||
|
||||
public CPPASTArrayDesignator() {
|
||||
}
|
||||
|
||||
public CPPASTArrayDesignator(ICPPASTExpression exp) {
|
||||
setSubscriptExpression(exp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTArrayDesignator copy() {
|
||||
return copy(CopyStyle.withoutLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTArrayDesignator copy(CopyStyle style) {
|
||||
CPPASTArrayDesignator copy = new CPPASTArrayDesignator(
|
||||
expression == null ? null : (ICPPASTExpression) expression.copy(style));
|
||||
return copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTExpression getSubscriptExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubscriptExpression(ICPPASTExpression value) {
|
||||
assertNotFrozen();
|
||||
expression = value;
|
||||
if (value != null) {
|
||||
value.setParent(this);
|
||||
value.setPropertyInParent(SUBSCRIPT_EXPRESSION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitDesignators) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (expression != null && !expression.accept(action))
|
||||
return false;
|
||||
|
||||
if (action.shouldVisitDesignators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(IASTNode child, IASTNode other) {
|
||||
if (child == expression) {
|
||||
other.setPropertyInParent(child.getPropertyInParent());
|
||||
other.setParent(child.getParent());
|
||||
expression = (ICPPASTExpression) other;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTArrayRangeDesignator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
* Implementation of array range designator.
|
||||
*/
|
||||
public class CPPASTArrayRangeDesignator extends ASTNode
|
||||
implements IGPPASTArrayRangeDesignator, IASTAmbiguityParent {
|
||||
private ICPPASTExpression floor;
|
||||
private ICPPASTExpression ceiling;
|
||||
|
||||
public CPPASTArrayRangeDesignator() {
|
||||
}
|
||||
|
||||
public CPPASTArrayRangeDesignator(ICPPASTExpression floor, ICPPASTExpression ceiling) {
|
||||
setRangeFloor(floor);
|
||||
setRangeCeiling(ceiling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTArrayRangeDesignator copy() {
|
||||
return copy(CopyStyle.withoutLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTArrayRangeDesignator copy(CopyStyle style) {
|
||||
CPPASTArrayRangeDesignator copy = new CPPASTArrayRangeDesignator();
|
||||
copy.setRangeFloor(floor == null ? null : (ICPPASTExpression) floor.copy(style));
|
||||
copy.setRangeCeiling(ceiling == null ? null : (ICPPASTExpression) ceiling.copy(style));
|
||||
return copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTExpression getRangeFloor() {
|
||||
return this.floor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRangeFloor(ICPPASTExpression expression) {
|
||||
assertNotFrozen();
|
||||
floor = expression;
|
||||
if (expression != null) {
|
||||
expression.setParent(this);
|
||||
expression.setPropertyInParent(SUBSCRIPT_FLOOR_EXPRESSION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTExpression getRangeCeiling() {
|
||||
return ceiling;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRangeCeiling(ICPPASTExpression expression) {
|
||||
assertNotFrozen();
|
||||
ceiling = expression;
|
||||
if (expression != null) {
|
||||
expression.setParent(this);
|
||||
expression.setPropertyInParent(SUBSCRIPT_CEILING_EXPRESSION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitDesignators) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (floor != null && !floor.accept(action))
|
||||
return false;
|
||||
if (ceiling != null && !ceiling.accept(action))
|
||||
return false;
|
||||
|
||||
if (action.shouldVisitDesignators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(IASTNode child, IASTNode other) {
|
||||
if (child == floor) {
|
||||
other.setPropertyInParent(child.getPropertyInParent());
|
||||
other.setParent(child.getParent());
|
||||
floor = (ICPPASTExpression) other;
|
||||
}
|
||||
if (child == ceiling) {
|
||||
other.setPropertyInParent(child.getPropertyInParent());
|
||||
other.setParent(child.getParent());
|
||||
ceiling = (ICPPASTExpression) other;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -148,7 +148,7 @@ public class CPPASTBaseSpecifier extends ASTNode implements ICPPASTBaseSpecifier
|
|||
@Override
|
||||
public IBinding[] findBindings(IASTName n, boolean isPrefix, String[] namespaces) {
|
||||
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix, namespaces);
|
||||
List<IBinding> filtered = new ArrayList<IBinding>();
|
||||
List<IBinding> filtered = new ArrayList<>();
|
||||
|
||||
ICPPClassType classType = null;
|
||||
if (getParent() instanceof CPPASTCompositeTypeSpecifier) {
|
||||
|
@ -184,6 +184,11 @@ public class CPPASTBaseSpecifier extends ASTNode implements ICPPASTBaseSpecifier
|
|||
return filtered.toArray(new IBinding[filtered.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
|
||||
return findBindings(n, isPrefix, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPackExpansion() {
|
||||
return fIsPackExpansion;
|
||||
|
@ -194,9 +199,4 @@ public class CPPASTBaseSpecifier extends ASTNode implements ICPPASTBaseSpecifier
|
|||
assertNotFrozen();
|
||||
fIsPackExpansion= val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
|
||||
return findBindings(n, isPrefix, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignatedInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
* Implementation for designated initializers.
|
||||
*/
|
||||
public class CPPASTDesignatedInitializer extends ASTNode
|
||||
implements ICPPASTDesignatedInitializer, IASTAmbiguityParent {
|
||||
private ICPPASTInitializerClause rhs;
|
||||
private ICPPASTDesignator[] designators = ICPPASTDesignator.EMPTY_ARRAY;
|
||||
private int designatorsPos;
|
||||
|
||||
public CPPASTDesignatedInitializer() {
|
||||
}
|
||||
|
||||
public CPPASTDesignatedInitializer(ICPPASTInitializerClause init) {
|
||||
setOperand(init);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTDesignatedInitializer copy() {
|
||||
return copy(CopyStyle.withoutLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTDesignatedInitializer copy(CopyStyle style) {
|
||||
CPPASTDesignatedInitializer copy =
|
||||
new CPPASTDesignatedInitializer(rhs == null ? null : (ICPPASTInitializerClause) rhs.copy(style));
|
||||
for (ICPPASTDesignator designator : getDesignators()) {
|
||||
copy.addDesignator(designator == null ? null : designator.copy(style));
|
||||
}
|
||||
return copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDesignator(ICPPASTDesignator designator) {
|
||||
assertNotFrozen();
|
||||
if (designator != null) {
|
||||
designator.setParent(this);
|
||||
designator.setPropertyInParent(DESIGNATOR);
|
||||
designators = ArrayUtil.appendAt(designators, designatorsPos++, designator);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTDesignator[] getDesignators() {
|
||||
designators = ArrayUtil.trim(designators, designatorsPos);
|
||||
return designators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTInitializerClause getOperand() {
|
||||
return rhs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOperand(ICPPASTInitializerClause operand) {
|
||||
assertNotFrozen();
|
||||
this.rhs = operand;
|
||||
if (rhs != null) {
|
||||
rhs.setParent(this);
|
||||
rhs.setPropertyInParent(OPERAND);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation getEvaluation() {
|
||||
return rhs.getEvaluation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitInitializers) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
ICPPASTDesignator[] ds = getDesignators();
|
||||
for (int i = 0; i < ds.length; i++) {
|
||||
if (!ds[i].accept(action))
|
||||
return false;
|
||||
}
|
||||
if (rhs != null && !rhs.accept(action)) return false;
|
||||
|
||||
if (action.shouldVisitInitializers) {
|
||||
switch (action.leave(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(IASTNode child, IASTNode other) {
|
||||
if (child == rhs) {
|
||||
other.setPropertyInParent(child.getPropertyInParent());
|
||||
other.setParent(child.getParent());
|
||||
rhs = (ICPPASTInitializerClause) other;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICPPASTCompletionContext;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDesignator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
|
||||
/**
|
||||
* Implementation of field designator.
|
||||
*/
|
||||
public class CPPASTFieldDesignator extends ASTNode
|
||||
implements ICPPASTFieldDesignator, ICPPASTCompletionContext {
|
||||
private IASTName name;
|
||||
|
||||
public CPPASTFieldDesignator() {
|
||||
}
|
||||
|
||||
public CPPASTFieldDesignator(IASTName name) {
|
||||
setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTFieldDesignator copy() {
|
||||
return copy(CopyStyle.withoutLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTFieldDesignator copy(CopyStyle style) {
|
||||
CPPASTFieldDesignator copy = new CPPASTFieldDesignator(name == null ? null : name.copy(style));
|
||||
return copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(IASTName name) {
|
||||
assertNotFrozen();
|
||||
this.name = name;
|
||||
if (name != null) {
|
||||
name.setParent(this);
|
||||
name.setPropertyInParent(FIELD_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept( ASTVisitor action) {
|
||||
if (action.shouldVisitDesignators) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (name != null && !name.accept(action))
|
||||
return false;
|
||||
if (action.shouldVisitDesignators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
|
||||
return findBindings(n, isPrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] findBindings(IASTName n, boolean isPrefix, String[] namespaces) {
|
||||
return CPPSemantics.findBindingsForContentAssist(n, isPrefix, namespaces);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
* Markus Schorn (Wind River Systems)
|
||||
* Thomas Corbat (IFS)
|
||||
* Anders Dahlberg (Ericsson) - bug 84144
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -55,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArraySubscriptExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttribute;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||
|
@ -71,12 +73,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignatedInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
||||
|
@ -84,6 +88,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||
|
@ -126,6 +131,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTArrayRangeDesignator;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTToken;
|
||||
|
@ -139,11 +145,16 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
|||
*/
|
||||
public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
||||
private static final CPPNodeFactory DEFAULT_INSTANCE = new CPPNodeFactory();
|
||||
|
||||
|
||||
public static CPPNodeFactory getDefault() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId mappingTypeId) {
|
||||
return new CPPASTAliasDeclaration(aliasName, mappingTypeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTAlignmentSpecifier newAlignmentSpecifier(IASTExpression expression) {
|
||||
return new CPPASTAlignmentSpecifier(expression);
|
||||
|
@ -158,7 +169,17 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name) {
|
||||
return new CPPASTArrayDeclarator(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTArrayDesignator newArrayDesignator(ICPPASTExpression exp) {
|
||||
return new CPPASTArrayDesignator(exp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGPPASTArrayRangeDesignator newArrayRangeDesignatorGPP(ICPPASTExpression floor, ICPPASTExpression ceiling) {
|
||||
return new CPPASTArrayRangeDesignator(floor, ceiling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTArrayModifier newArrayModifier(IASTExpression expr) {
|
||||
return new CPPASTArrayModifier(expr);
|
||||
|
@ -168,13 +189,13 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript) {
|
||||
return new CPPASTArraySubscriptExpression(arrayExpr, subscript);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr,
|
||||
IASTInitializerClause subscript) {
|
||||
return new CPPASTArraySubscriptExpression(arrayExpr, subscript);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IASTASMDeclaration newASMDeclaration(String assembly) {
|
||||
return new CPPASTASMDeclaration(assembly);
|
||||
|
@ -200,7 +221,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual) {
|
||||
return new CPPASTBaseSpecifier((ICPPASTName) name, visibility, isVirtual);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTBaseSpecifier newBaseSpecifier(ICPPASTNameSpecifier nameSpecifier, int visibility, boolean isVirtual) {
|
||||
return new CPPASTBaseSpecifier(nameSpecifier, visibility, isVirtual);
|
||||
|
@ -220,7 +241,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IASTExpression newBinaryTypeIdExpression(IASTBinaryTypeIdExpression.Operator op, IASTTypeId type1, IASTTypeId type2) {
|
||||
return new CPPASTBinaryTypeIdExpression(op, type1, type2);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IASTBreakStatement newBreakStatement() {
|
||||
return new CPPASTBreakStatement();
|
||||
|
@ -252,7 +273,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
assert kind == ICPPASTClassVirtSpecifier.SpecifierKind.Final;
|
||||
return new CPPASTClassVirtSpecifier();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name) {
|
||||
return new CPPASTCompositeTypeSpecifier(key, name);
|
||||
|
@ -298,7 +319,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IASTContinueStatement newContinueStatement() {
|
||||
return new CPPASTContinueStatement();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTConversionName newConversionName(IASTTypeId typeId) {
|
||||
return new CPPASTConversionName(typeId);
|
||||
|
@ -308,7 +329,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration) {
|
||||
return new CPPASTDeclarationStatement(declaration);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTDeclarator newDeclarator(IASTName name) {
|
||||
return new CPPASTDeclarator(name);
|
||||
|
@ -329,6 +350,11 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
return new CPPASTDeleteExpression(operand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTDesignatedInitializer newDesignatedInitializer(ICPPASTInitializerClause initializer) {
|
||||
return new CPPASTDesignatedInitializer(initializer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) {
|
||||
return new CPPASTDoStatement(body, condition);
|
||||
|
@ -370,12 +396,12 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration) {
|
||||
return new GPPASTExplicitTemplateInstantiation(declaration);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTExpressionList newExpressionList() {
|
||||
return new CPPASTExpressionList();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IASTExpressionStatement newExpressionStatement(IASTExpression expression) {
|
||||
return new CPPASTExpressionStatement(expression);
|
||||
|
@ -385,7 +411,12 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize) {
|
||||
return new CPPASTFieldDeclarator(name, bitFieldSize);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTFieldDesignator newFieldDesignator(IASTName name) {
|
||||
return new CPPASTFieldDesignator(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner) {
|
||||
return new CPPASTFieldReference(name, owner);
|
||||
|
@ -397,13 +428,13 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition,
|
||||
public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition,
|
||||
IASTExpression iterationExpression, IASTStatement body) {
|
||||
return new CPPASTForStatement(init, condition, iterationExpression, body);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
|
||||
public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
|
||||
IASTExpression iterationExpr, IASTStatement body) {
|
||||
return new CPPASTForStatement(init, condition, iterationExpr, body);
|
||||
}
|
||||
|
@ -447,7 +478,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement) {
|
||||
return new CPPASTCompoundStatementExpression(compoundStatement);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IASTGotoStatement newGotoStatement(IASTName name) {
|
||||
return new CPPASTGotoStatement(name);
|
||||
|
@ -488,7 +519,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTInitializerList newInitializerList() {
|
||||
return new CPPASTInitializerList();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement) {
|
||||
return new CPPASTLabelStatement(name, nestedStatement);
|
||||
|
@ -498,7 +529,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTLambdaExpression newLambdaExpression() {
|
||||
return new CPPASTLambdaExpression();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTLinkageSpecification newLinkageSpecification(String literal) {
|
||||
return new CPPASTLinkageSpecification(literal);
|
||||
|
@ -572,7 +603,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
||||
return new CPPASTParameterDeclaration(declSpec, declarator);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IASTPointer newPointer() {
|
||||
return new CPPASTPointer();
|
||||
|
@ -654,7 +685,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTReferenceOperator newReferenceOperator(boolean isRValueReference) {
|
||||
return new CPPASTReferenceOperator(isRValueReference);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IASTReturnStatement newReturnStatement(IASTExpression retValue) {
|
||||
return new CPPASTReturnStatement(retValue);
|
||||
|
@ -669,7 +700,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
|
||||
return new CPPASTSimpleDeclaration(declSpecifier);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier() {
|
||||
return new CPPASTSimpleDeclSpecifier();
|
||||
|
@ -716,7 +747,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body) {
|
||||
return new CPPASTSwitchStatement(controller, body);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body) {
|
||||
return new CPPASTSwitchStatement(controller, body);
|
||||
|
@ -760,7 +791,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
@Override
|
||||
public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner) {
|
||||
CPPASTTranslationUnit tu = new CPPASTTranslationUnit();
|
||||
|
||||
|
||||
if (scanner != null) {
|
||||
tu.setLocationResolver(scanner.getLocationResolver());
|
||||
if (scanner instanceof CPreprocessor) {
|
||||
|
@ -785,7 +816,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
|
||||
return new CPPASTTypeId(declSpecifier, declarator);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
|
||||
return new CPPASTTypeIdExpression(operator, typeId);
|
||||
|
@ -806,7 +837,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTTypeTransformationSpecifier newTypeTransformationSpecifier(ICPPUnaryTypeTransformation.Operator operator, ICPPASTTypeId operand) {
|
||||
return new CPPASTTypeTransformationSpecifier(operator, operand);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) {
|
||||
return new CPPASTUnaryExpression(operator, operand);
|
||||
|
@ -831,7 +862,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTVirtSpecifier newVirtSpecifier(SpecifierKind kind) {
|
||||
return new CPPASTVirtSpecifier(kind);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPASTWhileStatement newWhileStatement() {
|
||||
return new CPPASTWhileStatement();
|
||||
|
@ -846,9 +877,4 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
|
||||
return new CPPASTWhileStatement(condition, body);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId mappingTypeId) {
|
||||
return new CPPASTAliasDeclaration(aliasName, mappingTypeId);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2015 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,7 +8,8 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Patrick Hofer - [Bug 328528]
|
||||
*******************************************************************************/
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
|
@ -26,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
|
@ -47,16 +49,19 @@ public final class CPPVariableReadWriteFlags extends VariableReadWriteFlags {
|
|||
public static int getReadWriteFlags(IASTName variable) {
|
||||
return INSTANCE.rwAnyNode(variable, 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int rwAnyNode(IASTNode node, int indirection) {
|
||||
final IASTNode parent = node.getParent();
|
||||
if (parent instanceof ICPPASTConstructorInitializer) {
|
||||
return rwInCtorInitializer(node, indirection, (ICPPASTConstructorInitializer) parent);
|
||||
}
|
||||
if (parent instanceof ICPPASTFieldDesignator) {
|
||||
return WRITE; // Field is initialized via a designated initializer.
|
||||
}
|
||||
return super.rwAnyNode(node, indirection);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int rwInDeclarator(IASTDeclarator parent, int indirection) {
|
||||
IType type = CPPVisitor.createType(parent);
|
||||
|
@ -99,7 +104,7 @@ public final class CPPVariableReadWriteFlags extends VariableReadWriteFlags {
|
|||
}
|
||||
return READ | WRITE; // fallback
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int rwInUnaryExpression(IASTNode node, IASTUnaryExpression expr, int indirection) {
|
||||
switch (expr.getOperator()) {
|
||||
|
|
|
@ -110,6 +110,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
|
||||
|
@ -322,6 +323,8 @@ public class CPPVisitor extends ASTQueries {
|
|||
return createBinding((IASTLabelStatement) parent);
|
||||
} else if (parent instanceof ICPPASTTemplateParameter) {
|
||||
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
||||
} else if (parent instanceof ICPPASTFieldDesignator) {
|
||||
binding = resolveBinding(parent);
|
||||
}
|
||||
|
||||
if (name.getLookupKey().length > 0)
|
||||
|
@ -1310,6 +1313,17 @@ public class CPPVisitor extends ASTQueries {
|
|||
} else {
|
||||
return new CPPScope.CPPScopeProblem(name, ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
} else if (parent instanceof ICPPASTFieldDesignator) {
|
||||
ICPPASTDeclarator declarator = findAncestorWithType(parent, ICPPASTDeclarator.class);
|
||||
if (declarator != null) {
|
||||
IType type = createType(declarator);
|
||||
type= getNestedType(type, TDEF | CVTYPE);
|
||||
if (type instanceof ICPPClassType) {
|
||||
type= SemanticUtil.mapToAST(type, name);
|
||||
return ((ICPPClassType) type).getCompositeScope();
|
||||
}
|
||||
}
|
||||
return new CPPScope.CPPScopeProblem(name, ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
} else if (parent instanceof IASTGotoStatement || parent instanceof IASTLabelStatement) {
|
||||
while (!(parent instanceof IASTFunctionDefinition)) {
|
||||
parent = parent.getParent();
|
||||
|
@ -1398,6 +1412,9 @@ public class CPPVisitor extends ASTQueries {
|
|||
} else if (node instanceof ICPPASTFieldReference) {
|
||||
name = ((ICPPASTFieldReference) node).getFieldName();
|
||||
break;
|
||||
} else if (node instanceof ICPPASTFieldDesignator) {
|
||||
name = ((ICPPASTFieldDesignator) node).getName();
|
||||
break;
|
||||
} else if (node instanceof IASTFunctionCallExpression) {
|
||||
node = ((IASTFunctionCallExpression) node).getFunctionNameExpression();
|
||||
} else if (node instanceof IASTUnaryExpression) {
|
||||
|
|
|
@ -53,6 +53,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
|
||||
|
@ -245,6 +246,7 @@ public class LookupData extends ScopeLookupData {
|
|||
if (nameProp == IASTIdExpression.ID_NAME ||
|
||||
nameProp == IASTFieldReference.FIELD_NAME ||
|
||||
nameProp == ICASTFieldDesignator.FIELD_NAME ||
|
||||
nameProp == ICPPASTFieldDesignator.FIELD_NAME ||
|
||||
nameProp == ICPPASTUsingDirective.QUALIFIED_NAME ||
|
||||
nameProp == ICPPASTUsingDeclaration.NAME ||
|
||||
nameProp == IASTFunctionCallExpression.FUNCTION_NAME ||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Rapperswil, University of applied sciences 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:
|
||||
* 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:
|
||||
* Institute for Software - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
@ -20,15 +20,20 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
|
|||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignatedInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTArrayRangeDesignator;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||
|
||||
/**
|
||||
* Generates source code of initializer nodes. The actual string operations are delegated
|
||||
* to the <code>Scribe</code> class.
|
||||
*
|
||||
*
|
||||
* @see Scribe
|
||||
* @see IASTInitializer
|
||||
* @author Emanuel Graf IFS
|
||||
|
@ -38,7 +43,7 @@ public class InitializerWriter extends NodeWriter{
|
|||
public InitializerWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
|
||||
super(scribe, visitor, commentMap);
|
||||
}
|
||||
|
||||
|
||||
protected void writeInitializer(IASTInitializer initializer) {
|
||||
if (initializer instanceof IASTEqualsInitializer) {
|
||||
writeEqualsInitializer((IASTEqualsInitializer) initializer);
|
||||
|
@ -48,13 +53,15 @@ public class InitializerWriter extends NodeWriter{
|
|||
writeConstructorInitializer((ICPPASTConstructorInitializer) initializer);
|
||||
} else if (initializer instanceof ICASTDesignatedInitializer) {
|
||||
writeDesignatedInitializer((ICASTDesignatedInitializer) initializer);
|
||||
} else if (initializer instanceof ICPPASTDesignatedInitializer) {
|
||||
writeDesignatedInitializer((ICPPASTDesignatedInitializer) initializer);
|
||||
} else if (initializer instanceof ICPPASTConstructorChainInitializer) {
|
||||
writeConstructorChainInitializer((ICPPASTConstructorChainInitializer) initializer);
|
||||
}
|
||||
|
||||
writeTrailingComments(initializer, false);
|
||||
}
|
||||
|
||||
|
||||
private void writeEqualsInitializer(IASTEqualsInitializer initializer) {
|
||||
scribe.print(EQUALS);
|
||||
IASTInitializerClause init = initializer.getInitializerClause();
|
||||
|
@ -78,7 +85,7 @@ public class InitializerWriter extends NodeWriter{
|
|||
private void writeConstructorInitializer(ICPPASTConstructorInitializer ctorInit) {
|
||||
scribe.print('(');
|
||||
writeNodeList(ctorInit.getArguments());
|
||||
scribe.print(')');
|
||||
scribe.print(')');
|
||||
}
|
||||
|
||||
private void writeDesignatedInitializer(ICASTDesignatedInitializer desigInit) {
|
||||
|
@ -90,20 +97,52 @@ public class InitializerWriter extends NodeWriter{
|
|||
desigInit.getOperand().accept(visitor);
|
||||
}
|
||||
|
||||
private void writeDesignatedInitializer(ICPPASTDesignatedInitializer desigInit) {
|
||||
ICPPASTDesignator[] designators = desigInit.getDesignators();
|
||||
for (ICPPASTDesignator designator : designators) {
|
||||
writeDesignator(designator);
|
||||
}
|
||||
scribe.print(EQUALS);
|
||||
desigInit.getOperand().accept(visitor);
|
||||
}
|
||||
|
||||
private void writeDesignator(ICASTDesignator designator) {
|
||||
if (designator instanceof ICASTFieldDesignator) {
|
||||
ICASTFieldDesignator fieldDes = (ICASTFieldDesignator) designator;
|
||||
scribe.print('.');
|
||||
ICASTFieldDesignator fieldDes = (ICASTFieldDesignator) designator;
|
||||
fieldDes.getName().accept(visitor);
|
||||
} else if (designator instanceof ICASTArrayDesignator) {
|
||||
ICASTArrayDesignator arrDes = (ICASTArrayDesignator) designator;
|
||||
scribe.print('[');
|
||||
ICASTArrayDesignator arrDes = (ICASTArrayDesignator) designator;
|
||||
arrDes.getSubscriptExpression().accept(visitor);
|
||||
scribe.print(']');
|
||||
} else if (designator instanceof IGCCASTArrayRangeDesignator) {
|
||||
//IGCCASTArrayRangeDesignator new_name = (IGCCASTArrayRangeDesignator) designator;
|
||||
//TODO IGCCASTArrayRangeDesignator Bespiel zu parsen bringen
|
||||
throw new UnsupportedOperationException("Writing of GCC ArrayRangeDesignator is not yet implemented"); //$NON-NLS-1$
|
||||
scribe.print('[');
|
||||
IGCCASTArrayRangeDesignator arrDes = (IGCCASTArrayRangeDesignator) designator;
|
||||
arrDes.getRangeFloor().accept(visitor);
|
||||
scribe.print(" ... "); //$NON-NLS-1$
|
||||
arrDes.getRangeCeiling().accept(visitor);
|
||||
scribe.print(']');
|
||||
}
|
||||
}
|
||||
|
||||
private void writeDesignator(ICPPASTDesignator designator) {
|
||||
if (designator instanceof ICPPASTFieldDesignator) {
|
||||
scribe.print('.');
|
||||
ICPPASTFieldDesignator fieldDes = (ICPPASTFieldDesignator) designator;
|
||||
fieldDes.getName().accept(visitor);
|
||||
} else if (designator instanceof ICPPASTArrayDesignator) {
|
||||
scribe.print('[');
|
||||
ICPPASTArrayDesignator arrDes = (ICPPASTArrayDesignator) designator;
|
||||
arrDes.getSubscriptExpression().accept(visitor);
|
||||
scribe.print(']');
|
||||
} else if (designator instanceof IGPPASTArrayRangeDesignator) {
|
||||
scribe.print('[');
|
||||
IGPPASTArrayRangeDesignator arrDes = (IGPPASTArrayRangeDesignator) designator;
|
||||
arrDes.getRangeFloor().accept(visitor);
|
||||
scribe.print(" ... "); //$NON-NLS-1$
|
||||
arrDes.getRangeCeiling().accept(visitor);
|
||||
scribe.print(']');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignatedInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||
|
@ -749,6 +751,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
visit((IASTInitializerList) node);
|
||||
} else if (node instanceof ICASTDesignatedInitializer) {
|
||||
visit((ICASTDesignatedInitializer) node);
|
||||
} else if (node instanceof ICPPASTDesignatedInitializer) {
|
||||
visit((ICPPASTDesignatedInitializer) node);
|
||||
} else {
|
||||
formatRaw(node);
|
||||
}
|
||||
|
@ -2497,6 +2501,47 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
return PROCESS_SKIP;
|
||||
}
|
||||
|
||||
private int visit(ICPPASTDesignatedInitializer node) {
|
||||
scribe.printComment();
|
||||
ICPPASTDesignator[] designators = node.getDesignators();
|
||||
for (ICPPASTDesignator designator : designators) {
|
||||
designator.accept(this);
|
||||
if (scribe.printComment()) {
|
||||
scribe.space();
|
||||
}
|
||||
}
|
||||
|
||||
if (peekNextToken() == Token.tASSIGN) {
|
||||
scribe.printNextToken(Token.tASSIGN, preferences.insert_space_before_assignment_operator);
|
||||
if (preferences.insert_space_after_assignment_operator) {
|
||||
scribe.space();
|
||||
}
|
||||
}
|
||||
|
||||
Alignment expressionAlignment= scribe.createAlignment(
|
||||
Alignment.DESIGNATED_INITIALIZER,
|
||||
preferences.alignment_for_assignment,
|
||||
1,
|
||||
getCurrentPosition());
|
||||
|
||||
scribe.enterAlignment(expressionAlignment);
|
||||
boolean ok = false;
|
||||
do {
|
||||
try {
|
||||
scribe.alignFragment(expressionAlignment, 0);
|
||||
|
||||
IASTInitializerClause initializer = node.getOperand();
|
||||
initializer.accept(this);
|
||||
|
||||
ok = true;
|
||||
} catch (AlignmentException e) {
|
||||
scribe.redoAlignment(e);
|
||||
}
|
||||
} while (!ok);
|
||||
scribe.exitAlignment(expressionAlignment, true);
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
|
||||
private int visit(IASTInitializerList node) {
|
||||
scribe.printComment();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue