mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +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.eclipse.cdt.core.parser.tests.VisibilityAsserts.assertVisibility;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
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.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
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.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
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.ICPPASTCastExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
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.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
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.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.ICPPASTFunctionCallExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
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.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.ICPPUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
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.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.IProblem;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
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.index.IndexCPPSignatureUtil;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import junit.framework.TestSuite;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class AST2CPPTests extends AST2TestBase {
|
public class AST2CPPTests extends AST2TestBase {
|
||||||
|
|
||||||
|
@ -11625,4 +11629,40 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
// this test will need to be updated.
|
// this test will need to be updated.
|
||||||
helper.assertVariableValue("generic_lambdas_supported", 0);
|
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;
|
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.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||||
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
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.
|
* For testing resolution of bindings in C++ code with GNU extensions.
|
||||||
*/
|
*/
|
||||||
|
@ -82,6 +83,17 @@ public abstract class IndexGPPBindingResolutionTest extends IndexBindingResoluti
|
||||||
suite.addTest(ProjectWithDepProj.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>
|
// template <typename T>
|
||||||
// struct underlying_type {
|
// struct underlying_type {
|
||||||
// typedef __underlying_type(T) 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.ICPPASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier;
|
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.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.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
|
||||||
|
@ -378,7 +379,7 @@ public class ASTStringUtil {
|
||||||
}
|
}
|
||||||
trimRight(buffer);
|
trimRight(buffer);
|
||||||
buffer.append(Keywords.cpRBRACE);
|
buffer.append(Keywords.cpRBRACE);
|
||||||
} else if (initializer instanceof ICASTDesignatedInitializer) {
|
} else if (initializer instanceof ICASTDesignatedInitializer || initializer instanceof ICPPASTDesignatedInitializer) {
|
||||||
//TODO handle ICASTDesignatedInitializer?
|
//TODO handle ICASTDesignatedInitializer?
|
||||||
// final ICASTDesignatedInitializer designatedInitializer= (ICASTDesignatedInitializer) initializer;
|
// final ICASTDesignatedInitializer designatedInitializer= (ICASTDesignatedInitializer) initializer;
|
||||||
// final ICASTDesignator[] designator= designatedInitializer.getDesignators();
|
// 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.ICPPASTClassVirtSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier;
|
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.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVirtSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVirtSpecifier;
|
||||||
|
@ -346,6 +347,13 @@ public abstract class ASTVisitor {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.12
|
||||||
|
*/
|
||||||
|
public int visit(ICPPASTDesignator designator) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.7
|
* @since 5.7
|
||||||
*/
|
*/
|
||||||
|
@ -476,6 +484,13 @@ public abstract class ASTVisitor {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.12
|
||||||
|
*/
|
||||||
|
public int leave(ICPPASTDesignator designator) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.7
|
* @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
|
* Mike Kucera (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Thomas Corbat (IFS)
|
* Thomas Corbat (IFS)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
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.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation.Operator;
|
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.dom.parser.cpp.ICPPASTAttributeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
|
|
||||||
|
@ -41,12 +43,27 @@ import org.eclipse.cdt.core.parser.IScanner;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPNodeFactory extends INodeFactory {
|
public interface ICPPNodeFactory extends INodeFactory {
|
||||||
|
/**
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId aliasedType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name);
|
public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.12
|
||||||
|
*/
|
||||||
|
public ICPPASTArrayDesignator newArrayDesignator(ICPPASTExpression exp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.12
|
||||||
|
*/
|
||||||
|
public IGPPASTArrayRangeDesignator newArrayRangeDesignatorGPP(ICPPASTExpression floor, ICPPASTExpression ceiling);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript);
|
public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript);
|
||||||
|
|
||||||
|
@ -141,6 +158,11 @@ public interface ICPPNodeFactory extends INodeFactory {
|
||||||
|
|
||||||
public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
|
public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.12
|
||||||
|
*/
|
||||||
|
public ICPPASTDesignatedInitializer newDesignatedInitializer(ICPPASTInitializerClause initializer);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
|
public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
|
||||||
|
|
||||||
|
@ -166,6 +188,11 @@ public interface ICPPNodeFactory extends INodeFactory {
|
||||||
@Override
|
@Override
|
||||||
public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
|
public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.12
|
||||||
|
*/
|
||||||
|
public ICPPASTFieldDesignator newFieldDesignator(IASTName name);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner);
|
public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner);
|
||||||
|
|
||||||
|
@ -429,9 +456,4 @@ public interface ICPPNodeFactory extends INodeFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
|
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
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Richard Eames
|
* Richard Eames
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -61,6 +62,14 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.12
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean supportGCCStyleDesignators() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportKnRC() {
|
public boolean supportKnRC() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -92,7 +101,6 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,7 +109,6 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,7 +117,6 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,7 +125,6 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
* @since 5.11
|
* @since 5.11
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,9 +132,6 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#getBuiltinBindingsProvider()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
|
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
|
||||||
return new GCCBuiltinSymbolProvider(ParserLanguage.CPP, supportGCCOtherBuiltinSymbols());
|
return new GCCBuiltinSymbolProvider(ParserLanguage.CPP, supportGCCOtherBuiltinSymbols());
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
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.dom.parser.IBuiltinBindingsProvider;
|
||||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
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.IToken.ContextSensitiveTokenType;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,105 +34,71 @@ public class GPPParserExtensionConfiguration extends AbstractCPPParserExtensionC
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#allowRestrictPointerOperators()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean allowRestrictPointerOperators() {
|
public boolean allowRestrictPointerOperators() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportTypeofUnaryExpressions()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportTypeofUnaryExpressions() {
|
public boolean supportTypeofUnaryExpressions() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportAlignOfUnaryExpression()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportAlignOfUnaryExpression() {
|
public boolean supportAlignOfUnaryExpression() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportExtendedTemplateSyntax()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportExtendedTemplateSyntax() {
|
public boolean supportExtendedTemplateSyntax() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportMinAndMaxOperators()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportMinAndMaxOperators() {
|
public boolean supportMinAndMaxOperators() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportStatementsInExpressions()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportStatementsInExpressions() {
|
public boolean supportStatementsInExpressions() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportComplexNumbers()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportComplexNumbers() {
|
public boolean supportComplexNumbers() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportRestrictKeyword()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportRestrictKeyword() {
|
public boolean supportRestrictKeyword() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportLongLongs()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportLongLongs() {
|
public boolean supportLongLongs() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportKnRC()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportKnRC() {
|
public boolean supportKnRC() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportAttributeSpecifiers()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportAttributeSpecifiers() {
|
public boolean supportAttributeSpecifiers() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportDeclspecSpecifiers()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportDeclspecSpecifiers() {
|
public boolean supportDeclspecSpecifiers() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#getBuiltinBindingsProvider()
|
public boolean supportGCCStyleDesignators() {
|
||||||
*/
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
|
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
|
||||||
return new GCCBuiltinSymbolProvider(ParserLanguage.CPP, true);
|
return new GCCBuiltinSymbolProvider(ParserLanguage.CPP, true);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -151,6 +152,15 @@ public interface ICPPParserExtensionConfiguration {
|
||||||
*/
|
*/
|
||||||
public Map<String, ContextSensitiveTokenType> getAdditionalContextSensitiveKeywords();
|
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 use {@link #getBuiltinBindingsProvider()} instead.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
@Override
|
||||||
public IBinding[] findBindings(IASTName n, boolean isPrefix, String[] namespaces) {
|
public IBinding[] findBindings(IASTName n, boolean isPrefix, String[] namespaces) {
|
||||||
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix, namespaces);
|
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix, namespaces);
|
||||||
List<IBinding> filtered = new ArrayList<IBinding>();
|
List<IBinding> filtered = new ArrayList<>();
|
||||||
|
|
||||||
ICPPClassType classType = null;
|
ICPPClassType classType = null;
|
||||||
if (getParent() instanceof CPPASTCompositeTypeSpecifier) {
|
if (getParent() instanceof CPPASTCompositeTypeSpecifier) {
|
||||||
|
@ -184,6 +184,11 @@ public class CPPASTBaseSpecifier extends ASTNode implements ICPPASTBaseSpecifier
|
||||||
return filtered.toArray(new IBinding[filtered.size()]);
|
return filtered.toArray(new IBinding[filtered.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
|
||||||
|
return findBindings(n, isPrefix, null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPackExpansion() {
|
public boolean isPackExpansion() {
|
||||||
return fIsPackExpansion;
|
return fIsPackExpansion;
|
||||||
|
@ -194,9 +199,4 @@ public class CPPASTBaseSpecifier extends ASTNode implements ICPPASTBaseSpecifier
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
fIsPackExpansion= val;
|
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)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Thomas Corbat (IFS)
|
* Thomas Corbat (IFS)
|
||||||
* Anders Dahlberg (Ericsson) - bug 84144
|
* Anders Dahlberg (Ericsson) - bug 84144
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
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.IASTTypeIdInitializerExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
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.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.ICPPASTArraySubscriptExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttribute;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
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.ICPPASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier;
|
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.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.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier;
|
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.ICPPASTExplicitTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
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.ICPPASTExpressionList;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator;
|
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.ICPPASTFieldReference;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
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.ICPPASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
|
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.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.ICPPASTInitializerList;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
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.cpp.ICPPUnaryTypeTransformation;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier;
|
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.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.dom.parser.cpp.ICPPASTAttributeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTToken;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTToken;
|
||||||
|
@ -144,6 +150,11 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
||||||
return DEFAULT_INSTANCE;
|
return DEFAULT_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId mappingTypeId) {
|
||||||
|
return new CPPASTAliasDeclaration(aliasName, mappingTypeId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTAlignmentSpecifier newAlignmentSpecifier(IASTExpression expression) {
|
public IASTAlignmentSpecifier newAlignmentSpecifier(IASTExpression expression) {
|
||||||
return new CPPASTAlignmentSpecifier(expression);
|
return new CPPASTAlignmentSpecifier(expression);
|
||||||
|
@ -159,6 +170,16 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
||||||
return new CPPASTArrayDeclarator(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
|
@Override
|
||||||
public IASTArrayModifier newArrayModifier(IASTExpression expr) {
|
public IASTArrayModifier newArrayModifier(IASTExpression expr) {
|
||||||
return new CPPASTArrayModifier(expr);
|
return new CPPASTArrayModifier(expr);
|
||||||
|
@ -329,6 +350,11 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
||||||
return new CPPASTDeleteExpression(operand);
|
return new CPPASTDeleteExpression(operand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPASTDesignatedInitializer newDesignatedInitializer(ICPPASTInitializerClause initializer) {
|
||||||
|
return new CPPASTDesignatedInitializer(initializer);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) {
|
public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) {
|
||||||
return new CPPASTDoStatement(body, condition);
|
return new CPPASTDoStatement(body, condition);
|
||||||
|
@ -386,6 +412,11 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
||||||
return new CPPASTFieldDeclarator(name, bitFieldSize);
|
return new CPPASTFieldDeclarator(name, bitFieldSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPASTFieldDesignator newFieldDesignator(IASTName name) {
|
||||||
|
return new CPPASTFieldDesignator(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner) {
|
public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner) {
|
||||||
return new CPPASTFieldReference(name, owner);
|
return new CPPASTFieldReference(name, owner);
|
||||||
|
@ -846,9 +877,4 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
||||||
public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
|
public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
|
||||||
return new CPPASTWhileStatement(condition, body);
|
return new CPPASTWhileStatement(condition, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId mappingTypeId) {
|
|
||||||
return new CPPASTAliasDeclaration(aliasName, mappingTypeId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
|
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.ICPPASTAttribute;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||||
|
@ -89,11 +90,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.ICPPASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier;
|
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.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.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier;
|
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.ICPPASTExplicitTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator;
|
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.ICPPASTFieldReference;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
|
@ -101,6 +105,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
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.ICPPASTFunctionWithTryBlock;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
|
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.ICPPASTInitializerList;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression.CaptureDefault;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression.CaptureDefault;
|
||||||
|
@ -140,6 +145,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVirtSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTArrayRangeDesignator;
|
||||||
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
|
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
|
||||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
|
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||||
|
@ -187,6 +193,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
private final boolean supportExtendedTemplateSyntax;
|
private final boolean supportExtendedTemplateSyntax;
|
||||||
private final boolean supportAutoTypeSpecifier;
|
private final boolean supportAutoTypeSpecifier;
|
||||||
private final boolean supportUserDefinedLiterals;
|
private final boolean supportUserDefinedLiterals;
|
||||||
|
private final boolean supportGCCStyleDesignators;
|
||||||
|
|
||||||
private final IIndex index;
|
private final IIndex index;
|
||||||
protected ICPPASTTranslationUnit translationUnit;
|
protected ICPPASTTranslationUnit translationUnit;
|
||||||
|
@ -219,6 +226,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
supportParameterInfoBlock= config.supportParameterInfoBlock();
|
supportParameterInfoBlock= config.supportParameterInfoBlock();
|
||||||
supportExtendedSizeofOperator= config.supportExtendedSizeofOperator();
|
supportExtendedSizeofOperator= config.supportExtendedSizeofOperator();
|
||||||
supportFunctionStyleAsm= config.supportFunctionStyleAssembler();
|
supportFunctionStyleAsm= config.supportFunctionStyleAssembler();
|
||||||
|
supportGCCStyleDesignators = config.supportGCCStyleDesignators();
|
||||||
functionCallCanBeLValue= true;
|
functionCallCanBeLValue= true;
|
||||||
supportAutoTypeSpecifier= true;
|
supportAutoTypeSpecifier= true;
|
||||||
supportUserDefinedLiterals= config.supportUserDefinedLiterals();
|
supportUserDefinedLiterals= config.supportUserDefinedLiterals();
|
||||||
|
@ -481,7 +489,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
private ICPPASTDecltypeSpecifier decltypeSpecifier() throws EndOfFileException, BacktrackException {
|
private ICPPASTDecltypeSpecifier decltypeSpecifier() throws EndOfFileException, BacktrackException {
|
||||||
int start = consume(IToken.t_decltype).getOffset();
|
int start = consume(IToken.t_decltype).getOffset();
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
ICPPASTExpression decltypeExpression = (ICPPASTExpression) expression();
|
ICPPASTExpression decltypeExpression = expression();
|
||||||
int end = consume(IToken.tRPAREN).getEndOffset();
|
int end = consume(IToken.tRPAREN).getEndOffset();
|
||||||
ICPPASTDecltypeSpecifier decltypeSpec = getNodeFactory().newDecltypeSpecifier(decltypeExpression);
|
ICPPASTDecltypeSpecifier decltypeSpec = getNodeFactory().newDecltypeSpecifier(decltypeExpression);
|
||||||
setRange(decltypeSpec, start, end);
|
setRange(decltypeSpec, start, end);
|
||||||
|
@ -894,16 +902,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
private enum BinaryExprCtx {eInTemplateID, eNotInTemplateID}
|
private enum BinaryExprCtx {eInTemplateID, eNotInTemplateID}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IASTExpression expression() throws BacktrackException, EndOfFileException {
|
protected ICPPASTExpression expression() throws BacktrackException, EndOfFileException {
|
||||||
return expression(ExprKind.eExpression, BinaryExprCtx.eNotInTemplateID, null, null);
|
return expression(ExprKind.eExpression, BinaryExprCtx.eNotInTemplateID, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IASTExpression constantExpression() throws BacktrackException, EndOfFileException {
|
protected ICPPASTExpression constantExpression() throws BacktrackException, EndOfFileException {
|
||||||
return expression(ExprKind.eConstant, BinaryExprCtx.eNotInTemplateID, null, null);
|
return expression(ExprKind.eConstant, BinaryExprCtx.eNotInTemplateID, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTExpression expression(final ExprKind kind, final BinaryExprCtx ctx, IASTInitializerClause expr, ITemplateIdStrategy strat) throws EndOfFileException, BacktrackException {
|
private ICPPASTExpression expression(final ExprKind kind, final BinaryExprCtx ctx, IASTInitializerClause expr, ITemplateIdStrategy strat) throws EndOfFileException, BacktrackException {
|
||||||
final boolean allowComma= kind == ExprKind.eExpression;
|
final boolean allowComma= kind == ExprKind.eExpression;
|
||||||
boolean allowAssignment= kind != ExprKind.eConstant;
|
boolean allowAssignment= kind != ExprKind.eConstant;
|
||||||
|
|
||||||
|
@ -1157,7 +1165,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildExpression(lastOperator, expr);
|
return (ICPPASTExpression) buildExpression(lastOperator, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object castExpressionForBinaryExpression(ITemplateIdStrategy s)
|
public Object castExpressionForBinaryExpression(ITemplateIdStrategy s)
|
||||||
|
@ -1215,7 +1223,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTExpression throwExpression() throws EndOfFileException, BacktrackException {
|
private ICPPASTExpression throwExpression() throws EndOfFileException, BacktrackException {
|
||||||
IToken throwToken = consume();
|
IToken throwToken = consume();
|
||||||
IASTExpression throwExpression = null;
|
IASTExpression throwExpression = null;
|
||||||
try {
|
try {
|
||||||
|
@ -1226,7 +1234,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
int o = throwExpression != null ?
|
int o = throwExpression != null ?
|
||||||
calculateEndOffset(throwExpression) : throwToken.getEndOffset();
|
calculateEndOffset(throwExpression) : throwToken.getEndOffset();
|
||||||
return buildUnaryExpression(ICPPASTUnaryExpression.op_throw,
|
return (ICPPASTExpression) buildUnaryExpression(ICPPASTUnaryExpression.op_throw,
|
||||||
throwExpression, throwToken.getOffset(), o); // fix for 95225
|
throwExpression, throwToken.getOffset(), o); // fix for 95225
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1276,7 +1284,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
consume();
|
consume();
|
||||||
|
|
||||||
// consider placement first (P) ...
|
// consider placement first (P) ...
|
||||||
List<IASTInitializerClause> plcmt= null;
|
List<ICPPASTInitializerClause> plcmt= null;
|
||||||
IASTTypeId typeid= null;
|
IASTTypeId typeid= null;
|
||||||
boolean isNewTypeId= true;
|
boolean isNewTypeId= true;
|
||||||
IASTInitializer init= null;
|
IASTInitializer init= null;
|
||||||
|
@ -1381,9 +1389,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return newExpression(isGlobal, null, typeid, true, init, offset, endOffset);
|
return newExpression(isGlobal, null, typeid, true, init, offset, endOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTExpression newExpression(boolean isGlobal, List<IASTInitializerClause> plcmt, IASTTypeId typeid,
|
private IASTExpression newExpression(boolean isGlobal, List<? extends IASTInitializerClause> plcmt, IASTTypeId typeid,
|
||||||
boolean isNewTypeId, IASTInitializer init, int offset, int endOffset) {
|
boolean isNewTypeId, IASTInitializer init, int offset, int endOffset) {
|
||||||
|
|
||||||
IASTInitializerClause[] plcmtArray= null;
|
IASTInitializerClause[] plcmtArray= null;
|
||||||
if (plcmt != null && !plcmt.isEmpty()) {
|
if (plcmt != null && !plcmt.isEmpty()) {
|
||||||
plcmtArray= plcmt.toArray(new IASTInitializerClause[plcmt.size()]);
|
plcmtArray= plcmt.toArray(new IASTInitializerClause[plcmt.size()]);
|
||||||
|
@ -1710,7 +1717,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) == IToken.tRPAREN) {
|
if (LT(1) == IToken.tRPAREN) {
|
||||||
initArray= IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
initArray= IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||||
} else {
|
} else {
|
||||||
final List<IASTInitializerClause> exprList = expressionList();
|
final List<ICPPASTInitializerClause> exprList = expressionList();
|
||||||
initArray = exprList.toArray(new IASTInitializerClause[exprList.size()]);
|
initArray = exprList.toArray(new IASTInitializerClause[exprList.size()]);
|
||||||
}
|
}
|
||||||
endOffset = consumeOrEOC(IToken.tRPAREN).getEndOffset();
|
endOffset = consumeOrEOC(IToken.tRPAREN).getEndOffset();
|
||||||
|
@ -3852,14 +3859,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (optionalExpressionList && LT(1) == IToken.tRPAREN) {
|
if (optionalExpressionList && LT(1) == IToken.tRPAREN) {
|
||||||
initArray= IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
initArray= IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||||
} else {
|
} else {
|
||||||
final List<IASTInitializerClause> exprList = expressionList();
|
final List<ICPPASTInitializerClause> exprList = expressionList();
|
||||||
initArray = exprList.toArray(new IASTInitializerClause[exprList.size()]);
|
initArray = exprList.toArray(new IASTInitializerClause[exprList.size()]);
|
||||||
}
|
}
|
||||||
int endOffset = consumeOrEOC(IToken.tRPAREN).getEndOffset();
|
int endOffset = consumeOrEOC(IToken.tRPAREN).getEndOffset();
|
||||||
return setRange(getNodeFactory().newConstructorInitializer(initArray), offset, endOffset);
|
return setRange(getNodeFactory().newConstructorInitializer(initArray), offset, endOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IASTInitializerClause> expressionList() throws EndOfFileException, BacktrackException {
|
private List<ICPPASTInitializerClause> expressionList() throws EndOfFileException, BacktrackException {
|
||||||
return initializerList(false);
|
return initializerList(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3868,7 +3875,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* assignment-expression
|
* assignment-expression
|
||||||
* braced-init-list
|
* braced-init-list
|
||||||
*/
|
*/
|
||||||
private IASTInitializerClause initClause(boolean allowSkipping) throws EndOfFileException,
|
private ICPPASTInitializerClause initClause(boolean allowSkipping) throws EndOfFileException,
|
||||||
BacktrackException {
|
BacktrackException {
|
||||||
// braced-init-list
|
// braced-init-list
|
||||||
if (LT(1) == IToken.tLBRACE) {
|
if (LT(1) == IToken.tLBRACE) {
|
||||||
|
@ -3895,7 +3902,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// { initializer-list ,opt }
|
// { initializer-list ,opt }
|
||||||
List<IASTInitializerClause> initList= initializerList(allowSkipping);
|
List<ICPPASTInitializerClause> initList= initializerList(allowSkipping);
|
||||||
if (LT(1) == IToken.tCOMMA)
|
if (LT(1) == IToken.tCOMMA)
|
||||||
consume();
|
consume();
|
||||||
|
|
||||||
|
@ -3912,13 +3919,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* initializer-clause ...opt
|
* initializer-clause ...opt
|
||||||
* initializer-list , initializer-clause ...opt
|
* initializer-list , initializer-clause ...opt
|
||||||
*/
|
*/
|
||||||
private List<IASTInitializerClause> initializerList(boolean allowSkipping) throws EndOfFileException,
|
private List<ICPPASTInitializerClause> initializerList(boolean allowSkipping) throws EndOfFileException,
|
||||||
BacktrackException {
|
BacktrackException {
|
||||||
List<IASTInitializerClause> result= new ArrayList<>();
|
List<ICPPASTInitializerClause> result= new ArrayList<>();
|
||||||
// List of initializer clauses
|
// List of initializer clauses
|
||||||
loop: while (true) {
|
loop: while (true) {
|
||||||
// Clause may be null, add to initializer anyways, such that the size can be computed.
|
List<ICPPASTDesignator> designators= designatorList();
|
||||||
IASTInitializerClause clause = initClause(allowSkipping);
|
if (designators == null) {
|
||||||
|
// Clause may be null, add to initializer anyways, so that the size can be computed.
|
||||||
|
ICPPASTInitializerClause clause = initClause(allowSkipping);
|
||||||
if (allowSkipping && result.size() >= maximumTrivialExpressionsInAggregateInitializers
|
if (allowSkipping && result.size() >= maximumTrivialExpressionsInAggregateInitializers
|
||||||
&& !ASTQueries.canContainName(clause)) {
|
&& !ASTQueries.canContainName(clause)) {
|
||||||
translationUnit.setHasNodesOmitted(true);
|
translationUnit.setHasNodesOmitted(true);
|
||||||
|
@ -3932,11 +3941,30 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
adjustEndOffset(clause, endOffset);
|
adjustEndOffset(clause, endOffset);
|
||||||
} else if (clause instanceof IASTExpression) {
|
} else if (clause instanceof IASTExpression) {
|
||||||
// Wrap pack expanded assignment expressions
|
// Wrap pack expanded assignment expressions
|
||||||
IASTExpression packExpansion= getNodeFactory().newPackExpansionExpression((IASTExpression) clause);
|
ICPPASTExpression packExpansion= getNodeFactory().newPackExpansionExpression((IASTExpression) clause);
|
||||||
clause= setRange(packExpansion, clause, endOffset);
|
clause= setRange(packExpansion, clause, endOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.add(clause);
|
result.add(clause);
|
||||||
|
} else {
|
||||||
|
ICPPASTDesignatedInitializer desigInitializer = getNodeFactory().newDesignatedInitializer(null);
|
||||||
|
setRange(desigInitializer, designators.get(0));
|
||||||
|
for (ICPPASTDesignator d : designators) {
|
||||||
|
desigInitializer.addDesignator(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LT(1) != IToken.tEOC) {
|
||||||
|
// GNU extension: the assign operator is optional.
|
||||||
|
if (LT(1) == IToken.tASSIGN)
|
||||||
|
consume(IToken.tASSIGN);
|
||||||
|
|
||||||
|
ICPPASTInitializerClause clause= initClause(false);
|
||||||
|
desigInitializer.setOperand(clause);
|
||||||
|
adjustLength(desigInitializer, clause);
|
||||||
|
}
|
||||||
|
result.add(desigInitializer);
|
||||||
|
}
|
||||||
|
|
||||||
if (LT(1) != IToken.tCOMMA)
|
if (LT(1) != IToken.tCOMMA)
|
||||||
break;
|
break;
|
||||||
switch (LT(2)) {
|
switch (LT(2)) {
|
||||||
|
@ -3950,6 +3978,68 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ICPPASTDesignator> designatorList() throws EndOfFileException, BacktrackException {
|
||||||
|
IToken mark= mark();
|
||||||
|
try {
|
||||||
|
final int lt1= LT(1);
|
||||||
|
if (lt1 == IToken.tDOT || lt1 == IToken.tLBRACKET) {
|
||||||
|
List<ICPPASTDesignator> designatorList= null;
|
||||||
|
while (true) {
|
||||||
|
switch (LT(1)) {
|
||||||
|
case IToken.tDOT:
|
||||||
|
int offset = consume().getOffset();
|
||||||
|
IASTName n = identifier();
|
||||||
|
ICPPASTFieldDesignator fieldDesignator = getNodeFactory().newFieldDesignator(n);
|
||||||
|
setRange(fieldDesignator, offset, calculateEndOffset(n));
|
||||||
|
if (designatorList == null)
|
||||||
|
designatorList = new ArrayList<>(DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
|
designatorList.add(fieldDesignator);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IToken.tLBRACKET:
|
||||||
|
offset = consume().getOffset();
|
||||||
|
ICPPASTExpression constantExpression = expression();
|
||||||
|
if (supportGCCStyleDesignators && LT(1) == IToken.tELLIPSIS) {
|
||||||
|
consume(IToken.tELLIPSIS);
|
||||||
|
ICPPASTExpression constantExpression2 = expression();
|
||||||
|
int lastOffset = consume(IToken.tRBRACKET).getEndOffset();
|
||||||
|
IGPPASTArrayRangeDesignator designator = getNodeFactory().newArrayRangeDesignatorGPP(constantExpression, constantExpression2);
|
||||||
|
setRange(designator, offset, lastOffset);
|
||||||
|
if (designatorList == null)
|
||||||
|
designatorList = new ArrayList<>(DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
|
designatorList.add(designator);
|
||||||
|
} else {
|
||||||
|
int lastOffset = consume(IToken.tRBRACKET).getEndOffset();
|
||||||
|
ICPPASTArrayDesignator designator = getNodeFactory().newArrayDesignator(constantExpression);
|
||||||
|
setRange(designator, offset, lastOffset);
|
||||||
|
if (designatorList == null)
|
||||||
|
designatorList = new ArrayList<>(DEFAULT_DESIGNATOR_LIST_SIZE);
|
||||||
|
designatorList.add(designator);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return designatorList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If reached identifier and it's not a designator then return empty designator list (bug 84176).
|
||||||
|
if (supportGCCStyleDesignators && lt1 == IToken.tIDENTIFIER && LT(2) == IToken.tCOLON) {
|
||||||
|
int offset= LA(1).getOffset();
|
||||||
|
IASTName n = identifier();
|
||||||
|
int lastOffset = consume(IToken.tCOLON).getEndOffset();
|
||||||
|
ICPPASTFieldDesignator designator = getNodeFactory().newFieldDesignator(n);
|
||||||
|
setRange(designator, offset, lastOffset);
|
||||||
|
return Collections.singletonList(designator);
|
||||||
|
}
|
||||||
|
} catch (BacktrackException bt) {
|
||||||
|
backup(mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ICPPASTTypeId typeId(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
protected ICPPASTTypeId typeId(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
||||||
if (!canBeTypeSpecifier()) {
|
if (!canBeTypeSpecifier()) {
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Patrick Hofer - [Bug 328528]
|
* Patrick Hofer - [Bug 328528]
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
|
@ -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.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
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.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.ICPPASTNewExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
@ -54,6 +56,9 @@ public final class CPPVariableReadWriteFlags extends VariableReadWriteFlags {
|
||||||
if (parent instanceof ICPPASTConstructorInitializer) {
|
if (parent instanceof ICPPASTConstructorInitializer) {
|
||||||
return rwInCtorInitializer(node, indirection, (ICPPASTConstructorInitializer) parent);
|
return rwInCtorInitializer(node, indirection, (ICPPASTConstructorInitializer) parent);
|
||||||
}
|
}
|
||||||
|
if (parent instanceof ICPPASTFieldDesignator) {
|
||||||
|
return WRITE; // Field is initialized via a designated initializer.
|
||||||
|
}
|
||||||
return super.rwAnyNode(node, indirection);
|
return super.rwAnyNode(node, indirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier;
|
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.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.ICPPASTFieldReference;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
|
||||||
|
@ -322,6 +323,8 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return createBinding((IASTLabelStatement) parent);
|
return createBinding((IASTLabelStatement) parent);
|
||||||
} else if (parent instanceof ICPPASTTemplateParameter) {
|
} else if (parent instanceof ICPPASTTemplateParameter) {
|
||||||
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
||||||
|
} else if (parent instanceof ICPPASTFieldDesignator) {
|
||||||
|
binding = resolveBinding(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.getLookupKey().length > 0)
|
if (name.getLookupKey().length > 0)
|
||||||
|
@ -1310,6 +1313,17 @@ public class CPPVisitor extends ASTQueries {
|
||||||
} else {
|
} else {
|
||||||
return new CPPScope.CPPScopeProblem(name, ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
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) {
|
} else if (parent instanceof IASTGotoStatement || parent instanceof IASTLabelStatement) {
|
||||||
while (!(parent instanceof IASTFunctionDefinition)) {
|
while (!(parent instanceof IASTFunctionDefinition)) {
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
|
@ -1398,6 +1412,9 @@ public class CPPVisitor extends ASTQueries {
|
||||||
} else if (node instanceof ICPPASTFieldReference) {
|
} else if (node instanceof ICPPASTFieldReference) {
|
||||||
name = ((ICPPASTFieldReference) node).getFieldName();
|
name = ((ICPPASTFieldReference) node).getFieldName();
|
||||||
break;
|
break;
|
||||||
|
} else if (node instanceof ICPPASTFieldDesignator) {
|
||||||
|
name = ((ICPPASTFieldDesignator) node).getName();
|
||||||
|
break;
|
||||||
} else if (node instanceof IASTFunctionCallExpression) {
|
} else if (node instanceof IASTFunctionCallExpression) {
|
||||||
node = ((IASTFunctionCallExpression) node).getFunctionNameExpression();
|
node = ((IASTFunctionCallExpression) node).getFunctionNameExpression();
|
||||||
} else if (node instanceof IASTUnaryExpression) {
|
} 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.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
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.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.ICPPASTFieldReference;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
|
||||||
|
@ -245,6 +246,7 @@ public class LookupData extends ScopeLookupData {
|
||||||
if (nameProp == IASTIdExpression.ID_NAME ||
|
if (nameProp == IASTIdExpression.ID_NAME ||
|
||||||
nameProp == IASTFieldReference.FIELD_NAME ||
|
nameProp == IASTFieldReference.FIELD_NAME ||
|
||||||
nameProp == ICASTFieldDesignator.FIELD_NAME ||
|
nameProp == ICASTFieldDesignator.FIELD_NAME ||
|
||||||
|
nameProp == ICPPASTFieldDesignator.FIELD_NAME ||
|
||||||
nameProp == ICPPASTUsingDirective.QUALIFIED_NAME ||
|
nameProp == ICPPASTUsingDirective.QUALIFIED_NAME ||
|
||||||
nameProp == ICPPASTUsingDeclaration.NAME ||
|
nameProp == ICPPASTUsingDeclaration.NAME ||
|
||||||
nameProp == IASTFunctionCallExpression.FUNCTION_NAME ||
|
nameProp == IASTFunctionCallExpression.FUNCTION_NAME ||
|
||||||
|
|
|
@ -20,9 +20,14 @@ 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.ICASTDesignatedInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
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.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.ICPPASTConstructorChainInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
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.c.IGCCASTArrayRangeDesignator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTArrayRangeDesignator;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,6 +53,8 @@ public class InitializerWriter extends NodeWriter{
|
||||||
writeConstructorInitializer((ICPPASTConstructorInitializer) initializer);
|
writeConstructorInitializer((ICPPASTConstructorInitializer) initializer);
|
||||||
} else if (initializer instanceof ICASTDesignatedInitializer) {
|
} else if (initializer instanceof ICASTDesignatedInitializer) {
|
||||||
writeDesignatedInitializer((ICASTDesignatedInitializer) initializer);
|
writeDesignatedInitializer((ICASTDesignatedInitializer) initializer);
|
||||||
|
} else if (initializer instanceof ICPPASTDesignatedInitializer) {
|
||||||
|
writeDesignatedInitializer((ICPPASTDesignatedInitializer) initializer);
|
||||||
} else if (initializer instanceof ICPPASTConstructorChainInitializer) {
|
} else if (initializer instanceof ICPPASTConstructorChainInitializer) {
|
||||||
writeConstructorChainInitializer((ICPPASTConstructorChainInitializer) initializer);
|
writeConstructorChainInitializer((ICPPASTConstructorChainInitializer) initializer);
|
||||||
}
|
}
|
||||||
|
@ -90,20 +97,52 @@ public class InitializerWriter extends NodeWriter{
|
||||||
desigInit.getOperand().accept(visitor);
|
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) {
|
private void writeDesignator(ICASTDesignator designator) {
|
||||||
if (designator instanceof ICASTFieldDesignator) {
|
if (designator instanceof ICASTFieldDesignator) {
|
||||||
ICASTFieldDesignator fieldDes = (ICASTFieldDesignator) designator;
|
|
||||||
scribe.print('.');
|
scribe.print('.');
|
||||||
|
ICASTFieldDesignator fieldDes = (ICASTFieldDesignator) designator;
|
||||||
fieldDes.getName().accept(visitor);
|
fieldDes.getName().accept(visitor);
|
||||||
} else if (designator instanceof ICASTArrayDesignator) {
|
} else if (designator instanceof ICASTArrayDesignator) {
|
||||||
ICASTArrayDesignator arrDes = (ICASTArrayDesignator) designator;
|
|
||||||
scribe.print('[');
|
scribe.print('[');
|
||||||
|
ICASTArrayDesignator arrDes = (ICASTArrayDesignator) designator;
|
||||||
arrDes.getSubscriptExpression().accept(visitor);
|
arrDes.getSubscriptExpression().accept(visitor);
|
||||||
scribe.print(']');
|
scribe.print(']');
|
||||||
} else if (designator instanceof IGCCASTArrayRangeDesignator) {
|
} else if (designator instanceof IGCCASTArrayRangeDesignator) {
|
||||||
//IGCCASTArrayRangeDesignator new_name = (IGCCASTArrayRangeDesignator) designator;
|
scribe.print('[');
|
||||||
//TODO IGCCASTArrayRangeDesignator Bespiel zu parsen bringen
|
IGCCASTArrayRangeDesignator arrDes = (IGCCASTArrayRangeDesignator) designator;
|
||||||
throw new UnsupportedOperationException("Writing of GCC ArrayRangeDesignator is not yet implemented"); //$NON-NLS-1$
|
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.ICPPASTConstructorInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier;
|
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.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.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||||
|
@ -749,6 +751,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
visit((IASTInitializerList) node);
|
visit((IASTInitializerList) node);
|
||||||
} else if (node instanceof ICASTDesignatedInitializer) {
|
} else if (node instanceof ICASTDesignatedInitializer) {
|
||||||
visit((ICASTDesignatedInitializer) node);
|
visit((ICASTDesignatedInitializer) node);
|
||||||
|
} else if (node instanceof ICPPASTDesignatedInitializer) {
|
||||||
|
visit((ICPPASTDesignatedInitializer) node);
|
||||||
} else {
|
} else {
|
||||||
formatRaw(node);
|
formatRaw(node);
|
||||||
}
|
}
|
||||||
|
@ -2497,6 +2501,47 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
return PROCESS_SKIP;
|
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) {
|
private int visit(IASTInitializerList node) {
|
||||||
scribe.printComment();
|
scribe.printComment();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue