use of org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Choice_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
if (getIsErroneous(timestamp)) {
return false;
}
boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
switch(last.getValuetype()) {
case SEQUENCE_VALUE:
if (value.isAsn()) {
value.getLocation().reportSemanticError(MessageFormat.format(CHOICEEXPECTED, getFullName()));
value.setIsErroneous(true);
} else {
last = last.setValuetype(timestamp, Value_type.CHOICE_VALUE);
if (!last.getIsErroneous(timestamp)) {
selfReference = checkThisValueChoice(timestamp, (Choice_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed);
}
}
break;
case CHOICE_VALUE:
selfReference = checkThisValueChoice(timestamp, (Choice_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed);
break;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
break;
default:
if (value.isAsn()) {
value.getLocation().reportSemanticError(MessageFormat.format(CHOICEEXPECTED, getFullName()));
value.setIsErroneous(true);
} else {
value.getLocation().reportSemanticError(MessageFormat.format(UNIONEXPECTED, getFullName()));
value.setIsErroneous(true);
}
value.setIsErroneous(true);
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value in project titan.EclipsePlug-ins by eclipse.
the class ChangeCreator method calculateEditLocations.
private WorkspaceJob calculateEditLocations(final NavigableSet<ILocateableNode> nodes, final IFile file, final MultiTextEdit rootEdit) throws CoreException {
final WorkspaceJob job = new WorkspaceJob("InsertFieldRefactoring: calculate edit locations") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
for (ILocateableNode node : nodes) {
int vmLen = settings.getType().length() + settings.getId().getTtcnName().length();
if (node instanceof Def_Type) {
Def_Type df = (Def_Type) node;
Type type = df.getType(CompilationTimeStamp.getBaseTimestamp());
if (type instanceof TTCN3_Sequence_Type || type instanceof TTCN3_Set_Type) {
vmLen = insertField((TTCN3_Set_Seq_Choice_BaseType) type, node, rootEdit, vmLen);
}
} else if (node instanceof Sequence_Value) {
Sequence_Value sv = (Sequence_Value) node;
vmLen += 6;
final Location nodeLocation = node.getLocation();
if (settings.getPosition() < sv.getNofComponents()) {
final Location valueLocation = sv.getSeqValueByIndex(settings.getPosition()).getLocation();
Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), valueLocation.getOffset(), valueLocation.getEndOffset() + vmLen);
rootEdit.addChild(new InsertEdit(l.getOffset(), settings.getId().getTtcnName() + " := " + settings.getValue() + ", "));
} else {
int max = sv.getNofComponents();
final Location valueLocation = sv.getSeqValueByIndex(max - 1).getLocation();
Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), valueLocation.getEndOffset(), valueLocation.getEndOffset() + vmLen);
rootEdit.addChild(new InsertEdit(l.getOffset(), ", " + settings.getId().getTtcnName() + " := " + settings.getValue()));
}
} else if (node instanceof TTCN3Template) {
TTCN3Template template = (TTCN3Template) node;
vmLen += 6;
if (template instanceof Named_Template_List) {
Named_Template_List ntl = (Named_Template_List) template;
final Location nodeLocation = node.getLocation();
if (settings.getPosition() < ntl.getNofTemplates()) {
final Location templateLocation = ntl.getTemplateByIndex(settings.getPosition()).getLocation();
Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), templateLocation.getOffset(), templateLocation.getEndOffset() + vmLen);
rootEdit.addChild(new InsertEdit(l.getOffset(), settings.getId().getTtcnName() + " := " + settings.getValue() + ", "));
} else {
int max = ntl.getNofTemplates();
final Location templateLocation = ntl.getTemplateByIndex(max - 1).getLocation();
Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), templateLocation.getEndOffset(), templateLocation.getEndOffset() + vmLen);
rootEdit.addChild(new InsertEdit(l.getOffset(), ", " + settings.getId().getTtcnName() + " := " + settings.getValue()));
}
} else if (template instanceof Template_List) {
Template_List tl = (Template_List) template;
final Location nodeLocation = node.getLocation();
if (settings.getPosition() < tl.getNofTemplates()) {
final Location templateLocation = tl.getTemplateByIndex(settings.getPosition()).getLocation();
Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), templateLocation.getOffset(), templateLocation.getEndOffset() + vmLen);
rootEdit.addChild(new InsertEdit(l.getOffset(), settings.getValue() + ","));
} else {
int max = tl.getNofTemplates();
final Location templateLocation = tl.getTemplateByIndex(max - 1).getLocation();
Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), templateLocation.getEndOffset(), templateLocation.getEndOffset() + vmLen);
rootEdit.addChild(new InsertEdit(l.getOffset(), "," + settings.getValue()));
}
}
}
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return job;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Set_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
if (getIsErroneous(timestamp)) {
return false;
}
boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
switch(last.getValuetype()) {
case SEQUENCE_VALUE:
last = last.setValuetype(timestamp, Value_type.SET_VALUE);
if (last.isAsn()) {
selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
} else {
selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
}
break;
case SEQUENCEOF_VALUE:
if (((SequenceOf_Value) last).isIndexed()) {
value.getLocation().reportSemanticError(MessageFormat.format("Indexed assignment notation cannot be used for set type `{0}''", getFullName()));
value.setIsErroneous(true);
} else {
final SequenceOf_Value tempValue = (SequenceOf_Value) last;
if (tempValue.getNofComponents() == 0) {
if (compFieldMap != null && compFieldMap.getComponentFieldMap(timestamp).isEmpty()) {
last = last.setValuetype(timestamp, Value_type.SET_VALUE);
} else {
value.getLocation().reportSemanticError(MessageFormat.format(NONEMPTYEXPECTED, getFullName()));
value.setIsErroneous(true);
}
} else {
value.getLocation().reportSemanticError(MessageFormat.format(last.isAsn() ? VALUELISTNOTATIONERRORASN1 : VALUELISTNOTATIONERRORTTCN3, getFullName()));
value.setIsErroneous(true);
}
}
break;
case SET_VALUE:
if (last.isAsn()) {
selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
} else {
selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
}
break;
case UNDEFINED_BLOCK:
last = last.setValuetype(timestamp, Value_type.SET_VALUE);
selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
break;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
break;
default:
value.getLocation().reportSemanticError(MessageFormat.format(last.isAsn() ? SETVALUEXPECTEDASN1 : SETVALUEXPECTEDTTCN3, getFullName()));
value.setIsErroneous(true);
}
if (valueCheckingOptions.sub_check) {
// there is no parent type to check
if (subType != null) {
subType.checkThisValue(timestamp, last);
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value in project titan.EclipsePlug-ins by eclipse.
the class Named_Template_List method getValue.
@Override
public /**
* {@inheritDoc}
*/
IValue getValue() {
if (asValue != null) {
return asValue;
}
final NamedValues values = new NamedValues();
for (int i = 0, size = getNofTemplates(); i < size; i++) {
final NamedTemplate namedTemplate = namedTemplates.getTemplateByIndex(i);
final NamedValue namedValue = new NamedValue(namedTemplate.getName(), namedTemplate.getTemplate().getValue());
namedValue.setLocation(namedTemplate.getLocation());
values.addNamedValue(namedValue);
}
asValue = new Sequence_Value(values);
asValue.setLocation(getLocation());
asValue.setMyScope(getMyScope());
asValue.setFullNameParent(getNameParent());
asValue.setMyGovernor(getMyGovernor());
return asValue;
}
Aggregations