Commit b0985db9 authored by Farkas Ingrid's avatar Farkas Ingrid

added hasRawAttributes function

Signed-off-by: Farkas Ingrid's avatarFarkas Ingrid <farkas94ingi@gmail.com>
parent 996d919c
......@@ -576,6 +576,8 @@ public interface IType extends IGovernor, IIdentifierContainer, IVisitableNode,
*/
boolean getFieldTypesAsArray(final Reference reference, final int actualSubReference, List<IType> typeArray);
boolean hasRawAttributes(final CompilationTimeStamp timestamp);
/**
* Checks if there is a variant attribute among the ones reaching to
* this type.
......
......@@ -529,6 +529,43 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
return 1;
}
@Override
/** {@inheritDoc} */
public final boolean hasRawAttributes(final CompilationTimeStamp timestamp) {
if(rawAttribute != null) {
return true;
}
if (withAttributesPath == null) {
return false;
}
if (withAttributesPath.getHadGlobalVariants()) {
return true;
}
final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp);
for (int i = 0; i < realAttributes.size(); i++)
if (SingleWithAttribute.Attribute_Type.Variant_Attribute.equals(realAttributes.get(i).getAttributeType())) {
return true;
}
final MultipleWithAttributes localAttributes = withAttributesPath.getAttributes();
if (localAttributes == null) {
return false;
}
for(int i = 0; i < localAttributes.getNofElements(); i++) {
final SingleWithAttribute tempSingle = localAttributes.getAttribute(i);
if(Attribute_Type.Variant_Attribute.equals(tempSingle.getAttributeType()) && (tempSingle.getQualifiers() == null || tempSingle.getQualifiers().getNofQualifiers() == 0)) {
withAttributesPath.setHadGlobalVariants(true);
return true;
}
}
return false;
}
@Override
/** {@inheritDoc} */
public final boolean hasVariantAttributes(final CompilationTimeStamp timestamp) {
......@@ -536,6 +573,10 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
return false;
}
if (withAttributesPath.getHadGlobalVariants()) {
return true;
}
final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp);
for (int i = 0; i < realAttributes.size(); i++) {
if (SingleWithAttribute.Attribute_Type.Variant_Attribute.equals(realAttributes.get(i).getAttributeType())) {
......@@ -551,6 +592,7 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
for (int i = 0; i < localAttributes.getNofElements(); i++) {
final SingleWithAttribute tempSingle = localAttributes.getAttribute(i);
if (Attribute_Type.Variant_Attribute.equals(tempSingle.getAttributeType())) {
withAttributesPath.setHadGlobalVariants(true);
return true;
}
}
......@@ -561,7 +603,7 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
@Override
/** {@inheritDoc} */
public void initAttributes(final CompilationTimeStamp timestamp) {
// codingTable.clear();
// codingTable.clear();
hasDone = false;
checkDoneAttribute(timestamp);
......@@ -842,9 +884,9 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
final IType type = getTypeWithCodingTable(timestamp, false);
if (type == null) {
//FIXME as only RAW is supported for now, we can not report this error
// if (!global) {
// singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("No encoding rules defined for type `{0}''", getTypename()));
// }
// if (!global) {
// singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("No encoding rules defined for type `{0}''", getTypename()));
// }
} else {
final List<String> codingStrings = singleWithAttribute.getAttributeSpecification().getEncodings();
// gather the built-in codecs referred to by the variant's encoding strings
......@@ -1148,7 +1190,7 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
last.checkThisValue(timestamp, temporalValue, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_CONSTANT, true, false, true,
false,// can not have implicit omit as this is a type.
false));
jsonAttribute.default_value = temporalValue;
}
}
......@@ -2632,10 +2674,10 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
switch(encodingType) {
case RAW:
case JSON:
// case BER:
// case XER:
// case TEXT:
// case OER:
// case BER:
// case XER:
// case TEXT:
// case OER:
break;
default:
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment