1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

Bug 471621 - Have CPPASTAlignmentSpecifier implement IASTAmbiguityParent

This is necessary because the expression inside the alignment specifier
may be an ambiguous expression.

Change-Id: Ibb38410fea21251d866ddc58de6dc29b73623732
Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
Nathan Ridge 2015-07-03 18:55:06 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent f413507257
commit ebd396e2fb

View file

@ -13,10 +13,13 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier; import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public class CPPASTAlignmentSpecifier extends ASTNode implements IASTAlignmentSpecifier { public class CPPASTAlignmentSpecifier extends ASTNode implements IASTAlignmentSpecifier,
IASTAmbiguityParent {
// Precisely one of these is null. // Precisely one of these is null.
private IASTExpression fExpression; private IASTExpression fExpression;
private IASTTypeId fTypeId; private IASTTypeId fTypeId;
@ -66,4 +69,17 @@ public class CPPASTAlignmentSpecifier extends ASTNode implements IASTAlignmentSp
} }
return fTypeId.accept(visitor); return fTypeId.accept(visitor);
} }
@Override
public void replace(IASTNode child, IASTNode other) {
if (child instanceof IASTExpression && other instanceof IASTExpression && fExpression == child) {
fExpression = (IASTExpression) other;
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
} else if (child instanceof IASTTypeId && other instanceof IASTTypeId && fTypeId == child) {
fTypeId = (IASTTypeId) other;
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
}
}
} }