use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Set_Type method isPresentAnyvalueEmbeddedField.
@Override
public /**
* {@inheritDoc}
*/
boolean isPresentAnyvalueEmbeddedField(final ExpressionStruct expression, final List<ISubReference> subreferences, final int beginIndex) {
if (subreferences == null || getIsErroneous(CompilationTimeStamp.getBaseTimestamp())) {
return true;
}
if (beginIndex >= subreferences.size()) {
return true;
}
final ISubReference subReference = subreferences.get(beginIndex);
if (!(subReference instanceof FieldSubReference)) {
ErrorReporter.INTERNAL_ERROR("Code generator reached erroneous type reference `" + getFullName() + "''");
expression.expression.append("FATAL_ERROR encountered");
return true;
}
final Identifier fieldId = ((FieldSubReference) subReference).getId();
final CompField compField = getComponentByName(fieldId.getName());
if (compField.isOptional()) {
return false;
}
return compField.getType().isPresentAnyvalueEmbeddedField(expression, subreferences, beginIndex + 1);
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class Anytype_Value method getReferencedSubValue.
@Override
public /**
* {@inheritDoc}
*/
IValue getReferencedSubValue(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final IReferenceChain refChain) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return this;
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return null;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDVALUESUBREFERENCE, type.getTypename()));
return null;
case fieldSubReference:
final Identifier fieldId = ((FieldSubReference) subreference).getId();
switch(type.getTypetype()) {
case TYPE_ANY:
if (!((Anytype_Type) type).hasComponentWithName(fieldId.getDisplayName())) {
subreference.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTFIELD, fieldId.getDisplayName(), type.getTypename()));
return null;
}
break;
default:
return null;
}
if (name.getDisplayName().equals(fieldId.getDisplayName())) {
return value.getReferencedSubValue(timestamp, reference, actualSubReference + 1, refChain);
}
subreference.getLocation().reportSemanticError(MessageFormat.format(INACTIVEFIELD, fieldId.getDisplayName(), type.getTypename(), name.getDisplayName()));
return null;
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(ParameterisedSubReference.INVALIDVALUESUBREFERENCE);
return null;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return null;
}
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class SelectCoverage method process.
@Override
protected void process(final IVisitableNode node, final Problems problems) {
if (!(node instanceof SelectCase_Statement)) {
return;
}
final SelectCase_Statement s = (SelectCase_Statement) node;
final Value v = s.getExpression();
if (v == null || v.getIsErroneous(timestamp)) {
return;
}
// if there is an else branch, no smell will be reported
final SelectCases scs = s.getSelectCases();
if (scs == null || scs.getSelectCaseArray() == null) {
return;
}
for (final SelectCase sc : scs.getSelectCaseArray()) {
if (sc.hasElse()) {
return;
}
}
IType itype = v.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
if (itype instanceof Referenced_Type) {
itype = itype.getTypeRefdLast(timestamp);
}
if (itype == null || !(itype instanceof TTCN3_Enumerated_Type)) {
return;
}
final TTCN3_Enumerated_Type enumType = (TTCN3_Enumerated_Type) itype;
// count number of items in enum, get all items from enum
final EnumItemVisitor enumVisitor = new EnumItemVisitor();
enumType.accept(enumVisitor);
// count number of TemplateInstances in select, get used enum items
final CaseVisitor caseVisitor = new CaseVisitor();
scs.accept(caseVisitor);
if (caseVisitor.isContainsUnfoldable()) {
return;
}
final int casesSize = caseVisitor.getCount();
final int enumSize = enumVisitor.getCount();
if (enumSize > casesSize) {
final List<Identifier> allEnumItems = enumVisitor.getItemsFound();
final List<Identifier> usedEnumItems = caseVisitor.getItemsUsed();
final String enumName = itype.getTypename();
final String itemsNotCovered = getItemsNotCovered(allEnumItems, usedEnumItems);
problems.report(v.getLocation(), MessageFormat.format(ERR_MSG, enumName, enumSize, casesSize, itemsNotCovered));
}
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class Visibility method process.
@Override
protected void process(final IVisitableNode node, final Problems problems) {
if (node instanceof FormalParameter) {
return;
} else if (node instanceof Definition) {
final Definition s = (Definition) node;
final Identifier identifier = s.getIdentifier();
check(identifier, s.getDescription(), problems);
} else if (node instanceof Group) {
final Group s = (Group) node;
final Identifier identifier = s.getIdentifier();
check(identifier, "group", problems);
} else {
return;
}
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class TypenameInDef method check.
private void check(final Identifier identifier, final IType type, final String description, final Problems problems) {
if (type == null) {
return;
}
final String displayName = identifier.getDisplayName();
Identifier typeId = null;
if (type instanceof Referenced_Type) {
final Referenced_Type referencedType = (Referenced_Type) type;
typeId = referencedType.getReference().getId();
}
String typeName;
if (typeId == null) {
typeName = type.getTypename();
} else {
typeName = typeId.getDisplayName();
}
if (displayName.contains(typeName)) {
final String msg = MessageFormat.format(REPORT, description, displayName, typeName);
problems.report(identifier.getLocation(), msg);
}
}
Aggregations