use of org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class ASTComparison method typeSensitiveNodeEquals.
private static <T extends IASTNode> boolean typeSensitiveNodeEquals(T expected, T actual, EnumSet<ComparisonArg> args) {
if (!expected.getClass().equals(actual.getClass())) {
return false;
}
if (expected instanceof IASTDeclaration) {
/* Terminal checks */
if (expected instanceof ICPPASTFunctionDefinition) {
ICPPASTFunctionDefinition et = as(expected);
ICPPASTFunctionDefinition at = as(actual);
return et.isDefaulted() == at.isDefaulted() && et.isDeleted() == at.isDeleted();
} else if (expected instanceof ICPPASTTemplateDeclaration) {
ICPPASTTemplateDeclaration et = as(expected);
ICPPASTTemplateDeclaration at = as(actual);
return et.isExported() == at.isExported();
} else if (expected instanceof ICPPASTNamespaceDefinition) {
ICPPASTNamespaceDefinition et = as(expected);
ICPPASTNamespaceDefinition at = as(actual);
return et.isInline() == at.isInline();
} else if (expected instanceof ICPPASTVisibilityLabel) {
ICPPASTVisibilityLabel et = as(expected);
ICPPASTVisibilityLabel at = as(actual);
return et.getVisibility() == at.getVisibility();
} else if (expected instanceof ICPPASTLinkageSpecification) {
ICPPASTLinkageSpecification et = as(expected);
ICPPASTLinkageSpecification at = as(actual);
return et.getLiteral().equals(at.getLiteral());
} else if (expected instanceof ICPPASTUsingDeclaration) {
ICPPASTUsingDeclaration et = as(expected);
ICPPASTUsingDeclaration at = as(actual);
return et.isTypename() == at.isTypename();
} else if (expected instanceof IASTSimpleDeclaration || expected instanceof ICPPASTAliasDeclaration || expected instanceof ICPPASTUsingDirective) {
/* All tokens are stored in the child-nodes */
return defaultHandler(expected, actual, args);
}
/* Continue comparing raw-signature */
} else if (expected instanceof ICPPASTTemplateParameter) {
/* Template Parameter */
ICPPASTTemplateParameter e = as(expected);
ICPPASTTemplateParameter a = as(actual);
if (e.isParameterPack() != a.isParameterPack())
return false;
if (expected instanceof ICPPASTSimpleTypeTemplateParameter) {
ICPPASTSimpleTypeTemplateParameter et = as(expected);
ICPPASTSimpleTypeTemplateParameter at = as(actual);
return et.getParameterType() == at.getParameterType();
} else if (expected instanceof ICPPASTParameterDeclaration || expected instanceof ICPPASTTemplatedTypeTemplateParameter) {
/* All tokens are stored in the child-nodes */
return defaultHandler(expected, actual, args);
}
} else if (expected instanceof ICPPASTDeclarator) {
/* Terminal checks */
if (expected instanceof ICPPASTFunctionDeclarator) {
ICPPASTFunctionDeclarator e = as(expected);
ICPPASTFunctionDeclarator a = as(actual);
return e.isConst() == a.isConst() && e.isFinal() == a.isFinal() && e.isPureVirtual() == a.isPureVirtual() && e.isVolatile() == a.isVolatile();
} else {
/* All tokens are stored in the child-nodes */
return defaultHandler(expected, actual, args);
}
/* Continue comparing raw-signature */
} else if (expected instanceof ICPPASTDeclSpecifier) {
/* DeclSpecifier */
ICPPASTDeclSpecifier e = as(expected);
ICPPASTDeclSpecifier a = as(actual);
if (e.isConst() != a.isConst() || e.isVirtual() != a.isVirtual() || e.isVolatile() != a.isVolatile() || e.isConstexpr() != a.isConstexpr() || e.isExplicit() != a.isExplicit() || e.isFriend() != a.isFriend() || e.isRestrict() != a.isRestrict() || e.isThreadLocal() != a.isThreadLocal() || e.getStorageClass() != a.getStorageClass())
return false;
/* Terminal checks */
if (expected instanceof ICPPASTNamedTypeSpecifier) {
ICPPASTNamedTypeSpecifier et = as(expected);
ICPPASTNamedTypeSpecifier at = as(actual);
return et.isTypename() == at.isTypename();
} else if (expected instanceof ICPPASTCompositeTypeSpecifier) {
ICPPASTCompositeTypeSpecifier et = as(expected);
ICPPASTCompositeTypeSpecifier at = as(actual);
return et.isFinal() == at.isFinal() && et.isVirtual() == at.isVirtual() && et.getKey() == at.getKey();
} else if (expected instanceof ICPPASTElaboratedTypeSpecifier) {
ICPPASTElaboratedTypeSpecifier et = as(expected);
ICPPASTElaboratedTypeSpecifier at = as(actual);
return et.getKind() == at.getKind();
} else if (expected instanceof ICPPASTEnumerationSpecifier) {
ICPPASTEnumerationSpecifier et = as(expected);
ICPPASTEnumerationSpecifier at = as(actual);
return et.isOpaque() == at.isOpaque() && et.isScoped() == at.isScoped();
} else {
return defaultHandler(expected, actual, args);
}
/* Continue comparing raw-signature */
} else if (expected instanceof IASTExpression) {
if (expected instanceof ICPPASTUnaryExpression) {
ICPPASTUnaryExpression et = as(expected);
ICPPASTUnaryExpression at = as(actual);
return et.getOperator() == at.getOperator();
} else if (expected instanceof ICPPASTBinaryExpression) {
ICPPASTBinaryExpression et = as(expected);
ICPPASTBinaryExpression at = as(actual);
return et.getOperator() == at.getOperator();
} else if (expected instanceof ICPPASTLiteralExpression) {
ICPPASTLiteralExpression et = as(expected);
ICPPASTLiteralExpression at = as(actual);
return et.getKind() == at.getKind() && equalsRaw(et, at, args);
} else if (expected instanceof ICPPASTCastExpression) {
ICPPASTCastExpression et = as(expected);
ICPPASTCastExpression at = as(actual);
return et.getOperator() == at.getOperator();
} else if (expected instanceof ICPPASTNewExpression) {
ICPPASTNewExpression et = as(expected);
ICPPASTNewExpression at = as(actual);
return et.isArrayAllocation() == at.isArrayAllocation() && et.isGlobal() == at.isGlobal() && et.isNewTypeId() == at.isNewTypeId();
} else if (expected instanceof ICPPASTDeleteExpression) {
ICPPASTDeleteExpression et = as(expected);
ICPPASTDeleteExpression at = as(actual);
return et.isVectored() == at.isVectored() && et.isGlobal() == at.isGlobal();
} else if (expected instanceof ICPPASTFieldReference) {
ICPPASTFieldReference et = as(expected);
ICPPASTFieldReference at = as(actual);
return et.isPointerDereference() == at.isPointerDereference() && et.isTemplate() == at.isTemplate();
} else if (expected instanceof ICPPASTLambdaExpression) {
ICPPASTLambdaExpression et = as(expected);
ICPPASTLambdaExpression at = as(actual);
return et.getCaptureDefault() == at.getCaptureDefault();
} else if (expected instanceof ICPPASTFunctionCallExpression || expected instanceof ICPPASTSimpleTypeConstructorExpression || expected instanceof ICPPASTLambdaExpression || expected instanceof ICPPASTPackExpansionExpression || expected instanceof IASTIdExpression || expected instanceof ICPPASTArraySubscriptExpression || expected instanceof ICPPASTExpressionList || expected instanceof IASTConditionalExpression) {
/* All tokens are stored in the child-nodes */
return defaultHandler(expected, actual, args);
}
/* Continue comparing raw-signature */
} else if (expected instanceof ICPPASTReferenceOperator) {
/* ReferenceOperator */
ICPPASTReferenceOperator et = as(expected);
ICPPASTReferenceOperator at = as(actual);
return et.isRValueReference() == at.isRValueReference();
} else if (expected instanceof IASTPointer) {
/* Pointers */
IASTPointer et = as(expected);
IASTPointer at = as(actual);
return et.isConst() == at.isConst() && et.isRestrict() == at.isRestrict() && et.isVolatile() == at.isVolatile();
} else if (expected instanceof IASTStatement) {
return defaultHandler(expected, actual, args);
} else if (expected instanceof ICPPASTPackExpandable) {
/* ICPPASTPackExpandable */
ICPPASTPackExpandable e = as(expected);
ICPPASTPackExpandable a = as(actual);
if (e.isPackExpansion() != a.isPackExpansion())
return false;
if (expected instanceof ICPPASTInitializerList) {
ICPPASTInitializerList et = as(expected);
ICPPASTInitializerList at = as(actual);
return et.getSize() == at.getSize();
} else if (expected instanceof ICPPASTBaseSpecifier) {
ICPPASTBaseSpecifier et = as(expected);
ICPPASTBaseSpecifier at = as(actual);
return et.isVirtual() == at.isVirtual() && et.getVisibility() == at.getVisibility();
} else if (expected instanceof ICPPASTCapture) {
ICPPASTCapture et = as(expected);
ICPPASTCapture at = as(actual);
return et.capturesThisPointer() == at.capturesThisPointer() && et.isByReference() == at.isByReference();
} else if (expected instanceof ICPPASTTypeId) {
return true;
} else {
return defaultHandler(expected, actual, args);
}
} else if (expected instanceof ICPPASTName) {
/* Names */
ICPPASTName e = as(expected);
ICPPASTName a = as(actual);
if (e.isQualified() != a.isQualified())
return false;
if (expected instanceof ICPPASTTemplateId) {
ICPPASTTemplateId et = as(expected);
ICPPASTTemplateId at = as(actual);
return et.isDeclaration() == at.isDeclaration();
} else if (expected instanceof ICPPASTQualifiedName) {
ICPPASTQualifiedName et = as(expected);
ICPPASTQualifiedName at = as(actual);
return et.isFullyQualified() == at.isFullyQualified();
} else if (expected instanceof ICPPASTTemplateId) {
/* Relevant information is contained in the children */
return defaultHandler(expected, actual, args);
}
} else {
/* OTHER */
if (expected instanceof IASTTranslationUnit || expected instanceof IASTArrayModifier || expected instanceof IASTInitializer) {
/* Relevant information is contained in the children */
return defaultHandler(expected, actual, args);
}
/* Continue comparing raw-signature */
}
/* Default case */
return equalsNormalizedRaw(expected, actual);
}
Aggregations