diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/IType.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/IType.java index fb248bf87d32665d72b85524f9293ff07bb8e6c1..7eac4a9ee9d5be3048076fd7ca0ee33bfd7a348e 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/IType.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/IType.java @@ -576,6 +576,8 @@ public interface IType extends IGovernor, IIdentifierContainer, IVisitableNode, */ boolean getFieldTypesAsArray(final Reference reference, final int actualSubReference, List typeArray); + boolean hasRawAttributes(final CompilationTimeStamp timestamp); + /** * Checks if there is a variant attribute among the ones reaching to * this type. diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/Type.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/Type.java index 95539f4361530f3b62b237e0b901d1c142cedecf..d76e3e495b406baa91c8c636a49e6a2fd267a49b 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/Type.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/Type.java @@ -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 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 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 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;