use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Set_Seq_Choice_BaseType method getFieldTypesAsArray.
@Override
public /**
* {@inheritDoc}
*/
boolean getFieldTypesAsArray(final Reference reference, final int actualSubReference, final List<IType> typeArray) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return true;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
if (compFieldMap == null) {
return false;
}
final Identifier id = subreference.getId();
final CompField compField = compFieldMap.getCompWithName(id);
if (compField == null) {
return false;
}
final IType fieldType = compField.getType();
if (fieldType == null) {
return false;
}
typeArray.add(this);
return fieldType.getFieldTypesAsArray(reference, actualSubReference + 1, typeArray);
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class CompFieldMap method checkUniqueness.
/**
* Checks the uniqueness of the definitions, and also builds a hashmap of
* them to speed up further searches.
*
* @param timestamp the timestamp of the actual semantic check cycle, or -1
* in silent check mode.
*/
protected void checkUniqueness(final CompilationTimeStamp timestamp) {
if (lastUniquenessCheck != null && !lastUniquenessCheck.isLess(timestamp)) {
return;
}
if (doubleComponents != null) {
doubleComponents.clear();
}
componentFieldMap = new HashMap<String, CompField>(fields.size());
if (fields.size() == 0) {
// too early check
return;
}
lastUniquenessCheck = timestamp;
for (int i = 0, size = fields.size(); i < size; i++) {
final CompField field = fields.get(i);
final Identifier fieldIdentifier = field.getIdentifier();
if (fieldIdentifier == null) {
continue;
}
final String fieldName = fieldIdentifier.getName();
if (componentFieldMap.containsKey(fieldName)) {
if (doubleComponents == null) {
doubleComponents = new ArrayList<CompField>();
}
doubleComponents.add(field);
} else {
componentFieldMap.put(fieldName, field);
}
}
// FIXME: Perhaps this class should be copied under asn1 to handle this ASN1 problem
if (doubleComponents != null) {
final INamedNode p = getNameParent();
if (p instanceof Open_Type) {
return;
}
for (int i = 0, size = doubleComponents.size(); i < size; i++) {
final CompField field = doubleComponents.get(i);
// remove duplication from fields - not used anymore
// fields.remove(field);
// report duplication:
final Identifier fieldIdentifier = field.getIdentifier();
final String fieldName = fieldIdentifier.getName();
componentFieldMap.get(fieldName).getIdentifier().getLocation().reportSingularSemanticError(MessageFormat.format(DUPLICATEFIELDNAMEFIRST, fieldIdentifier.getDisplayName()));
fieldIdentifier.getLocation().reportSemanticError(MessageFormat.format(DUPLICATEFIELDNAMEREPEATED, fieldIdentifier.getDisplayName()));
}
}
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class ComponentTypeBody method addDeclaration.
public void addDeclaration(final DeclarationCollector declarationCollector, final int i) {
final Identifier identifier = declarationCollector.getReference().getId();
Definition definition = definitions.getDefinition(identifier.getName());
if (definition != null) {
definition.addDeclaration(declarationCollector, i);
}
definition = extendsGainedDefinitions.get(identifier.getName());
if (definition != null) {
definition.addDeclaration(declarationCollector, i);
}
definition = attributeGainedDefinitions.get(identifier.getName());
if (definition != null) {
definition.addDeclaration(declarationCollector, i);
}
if (i == 0) {
super.addDeclaration(declarationCollector);
}
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class EnumItem method getDeclaration.
@Override
public /**
* {@inheritDoc}
*/
Declaration getDeclaration() {
if (getMyScope() == null) {
return null;
}
final Module module = getMyScope().getModuleScope();
final Assignment assignment = module.getEnclosingAssignment(getLocation().getOffset());
final IType type = assignment.getType(CompilationTimeStamp.getBaseTimestamp());
if (type instanceof ITypeWithComponents) {
final Identifier id = ((ITypeWithComponents) type).getComponentIdentifierByName(getId());
return Declaration.createInstance(assignment, id);
}
return null;
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Set_Type method checkThisValueSet.
/**
* Checks the Set_Value kind value against this type.
* <p>
* Please note, that this function can only be called once we know for sure
* that the value is of set type.
*
* @param timestamp the timestamp of the actual semantic check cycle.
* @param value the value to be checked
* @param expectedValue the kind of value we expect to find.
* @param incompleteAllowed wheather incomplete value is allowed or not.
* @param impliciOmit true if the implicit omit optional attribute was set
* for the value, false otherwise
*/
private boolean checkThisValueSet(final CompilationTimeStamp timestamp, final Set_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean impliciOmit, final boolean strElem) {
value.removeGeneratedValues();
boolean selfReference = false;
final Map<String, NamedValue> componentMap = new HashMap<String, NamedValue>();
final Map<String, CompField> realComponents = compFieldMap.getComponentFieldMap(timestamp);
final boolean isAsn = value.isAsn();
final int nofValueComponents = value.getNofComponents();
for (int i = 0; i < nofValueComponents; i++) {
final NamedValue namedValue = value.getSequenceValueByIndex(i);
final Identifier valueId = namedValue.getName();
if (!realComponents.containsKey(valueId.getName())) {
namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? NONEXISTENTFIELDASN1 : NONEXISTENTFIELDTTCN3, namedValue.getName().getDisplayName(), getTypename()));
} else {
if (componentMap.containsKey(valueId.getName())) {
namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? DUPLICATEFIELDAGAINASN1 : DUPLICATEFIELDAGAINTTCN3, valueId.getDisplayName()));
componentMap.get(valueId.getName()).getLocation().reportSingularSemanticError(MessageFormat.format(isAsn ? DUPLICATEFIELDFIRSTASN1 : DUPLICATEFIELDFIRSTTTCN3, valueId.getDisplayName()));
} else {
componentMap.put(valueId.getName(), namedValue);
}
final CompField componentField = realComponents.get(valueId.getName());
final Type type = componentField.getType();
final IValue componentValue = namedValue.getValue();
if (componentValue != null) {
componentValue.setMyGovernor(type);
if (Value_type.NOTUSED_VALUE.equals(componentValue.getValuetype())) {
if (!incompleteAllowed) {
componentValue.getLocation().reportSemanticError(INCOMPLETEPRESENTERROR);
}
} else {
final IValue tempValue = type.checkThisValueRef(timestamp, componentValue);
selfReference |= type.checkThisValue(timestamp, tempValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, componentField.isOptional(), true, impliciOmit, strElem));
}
}
}
}
if (!incompleteAllowed || strictConstantCheckingSeverity) {
final int nofTypeComponents = realComponents.size();
CompField field;
for (int i = 0; i < nofTypeComponents; i++) {
field = compFieldMap.fields.get(i);
final Identifier id = field.getIdentifier();
if (!componentMap.containsKey(id.getName())) {
if (field.isOptional() && impliciOmit) {
value.addNamedValue(new NamedValue(new Identifier(Identifier_type.ID_TTCN, id.getDisplayName()), new Omit_Value(), false));
} else {
value.getLocation().reportSemanticError(MessageFormat.format(isAsn ? MISSINGFIELDASN1 : MISSINGFIELDTTCN3, id.getDisplayName()));
}
}
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
Aggregations