use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class DependencyCollector method filterImportDefinitions.
/**
* Returns the <code>importDefs</code> list, with the {@link ImportModule}s removed which refer to
* modules that are not contained in the <code>allFiles</code> set.
*/
private static void filterImportDefinitions(final Set<IResource> allFiles, final List<ImportModule> importDefs, final ProjectSourceParser projParser) {
final List<Identifier> allFileIds = new ArrayList<Identifier>(allFiles.size());
for (IResource r : allFiles) {
if (!(r instanceof IFile)) {
continue;
}
final IFile f = (IFile) r;
final Module m = projParser.containedModule(f);
allFileIds.add(m.getIdentifier());
}
final ListIterator<ImportModule> importIt = importDefs.listIterator();
while (importIt.hasNext()) {
final ImportModule im = importIt.next();
final Identifier id = im.getIdentifier();
if (!allFileIds.contains(id)) {
importIt.remove();
}
}
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class DependencyCollector method filterFriendDefinitions.
/**
* Returns the <code>friendDefs</code> list, with the {@link FriendModule}s removed which refer to
* modules that are not contained in the <code>allFiles</code> set.
*/
private static void filterFriendDefinitions(final Set<IResource> allFiles, final List<FriendModule> friendDefs, final ProjectSourceParser projParser) {
final List<Identifier> allFileIds = new ArrayList<Identifier>(allFiles.size());
for (IResource r : allFiles) {
if (!(r instanceof IFile)) {
continue;
}
final IFile f = (IFile) r;
final Module m = projParser.containedModule(f);
allFileIds.add(m.getIdentifier());
}
final ListIterator<FriendModule> importIt = friendDefs.listIterator();
while (importIt.hasNext()) {
final FriendModule fm = importIt.next();
final Identifier id = fm.getIdentifier();
if (!allFileIds.contains(id)) {
importIt.remove();
}
}
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class TemplateParser method process.
@Override
public Scope process(IVisitableNode node) {
if (node instanceof Identifier) {
name = node.toString();
// TODO : find a more sophisticated way of storing symbols (e.g. SymbolTable)
myASTVisitor.nodeNameNodeTypeHashMap.put(name, "template");
}
if (node instanceof Type) {
type = Util.getTypeName((Type) node);
template = new Template(name, type);
return Action.skip(Type.class, this);
}
if (node instanceof FormalParameterList) {
return new FormalParameterParser(this, template);
}
// is a modification
if (node instanceof Reference) {
Reference reference = (Reference) node;
String basename = reference.getId().toString();
Template base = registry.find(basename);
// TODO : templates need a base value as a fallback
// TODO : this base value should be used as a reference, to diff against
// TODO : this was a hotfix for the union types to work
String type = base.getValue().getType();
template.setValue(new Value(type, (code, indent) -> code.append("(", type, ") ").append(basename, "()")));
isModification = true;
return Action.skip(Reference.class, this);
}
if (node instanceof TTCN3Template) {
if (isModification) {
return ModificationParser.getScope(this, template, "", type, node);
}
return TemplateValueParser.getScope(this, template, type, node);
}
return this;
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Integer_Type method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (null != myScope) {
final Module module = myScope.getModuleScope();
if (null != module) {
if (module.getSkippedFromSemanticChecking()) {
return;
}
}
}
isErroneous = false;
if (null == namedNumbers) {
parseBlockInt();
}
if (isErroneous || null == namedNumbers) {
return;
}
/* check named numbers */
final Map<String, Identifier> nameMap = new HashMap<String, Identifier>();
for (int i = 0, size = namedNumbers.getSize(); i < size; i++) {
final NamedValue namedValue = namedNumbers.getNamedValueByIndex(i);
final Identifier identifier = namedValue.getName();
if (nameMap.containsKey(identifier.getName())) {
final Location tempLocation = nameMap.get(identifier.getName()).getLocation();
tempLocation.reportSingularSemanticError(MessageFormat.format(Assignments.DUPLICATEDEFINITIONFIRST, identifier.getDisplayName()));
identifier.getLocation().reportSemanticError(MessageFormat.format(Assignments.DUPLICATEDEFINITIONREPEATED, identifier.getDisplayName()));
} else {
nameMap.put(identifier.getName(), identifier);
}
}
final Map<Integer, NamedValue> valueMap = new HashMap<Integer, NamedValue>();
for (int i = 0, size = namedNumbers.getSize(); i < size; i++) {
final NamedValue namedValue = namedNumbers.getNamedValueByIndex(i);
final IValue value = namedValue.getValue();
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (last.getIsErroneous(timestamp)) {
continue;
}
switch(last.getValuetype()) {
case INTEGER_VALUE:
{
final Integer_Value integerValue = (Integer_Value) last;
if (integerValue.isNative()) {
final Integer intValue = Integer.valueOf(integerValue.intValue());
if (valueMap.containsKey(intValue)) {
value.getLocation().reportSemanticError(MessageFormat.format("Duplicate number {0} for name `{1}''", intValue, namedValue.getName().getDisplayName()));
final NamedValue temp = valueMap.get(intValue);
temp.getLocation().reportSemanticError(MessageFormat.format("Number {0} is already assigned to name `{1}''", intValue, temp.getName().getDisplayName()));
} else {
valueMap.put(intValue, namedValue);
}
} else {
value.getLocation().reportSemanticError(MessageFormat.format("Integer value `{0}'' is too big to be used as a named number", integerValue.getValueValue()));
value.setIsErroneous(true);
}
break;
}
default:
namedValue.getLocation().reportSemanticError(MessageFormat.format("INTEGER value was expected for named number `{0}''", namedValue.getName().getDisplayName()));
value.setIsErroneous(true);
break;
}
}
nameMap.clear();
if (null != constraints) {
constraints.check(timestamp);
}
if (myScope != null) {
checkEncode(timestamp);
checkVariants(timestamp);
}
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Sequence_Type method getFieldType.
// This is the same as in ASN1_Set_type
@Override
public /**
* {@inheritDoc}
*/
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return this;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDSUBREFERENCE, getTypename()));
return null;
case fieldSubReference:
if (components == null) {
return null;
}
final Identifier id = subreference.getId();
final CompField compField = components.getCompByName(id);
if (compField == null) {
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.NONEXISTENTSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
}
if (interruptIfOptional && compField.isOptional()) {
return null;
}
final Expected_Value_type internalExpectation = expectedIndex == Expected_Value_type.EXPECTED_TEMPLATE ? Expected_Value_type.EXPECTED_DYNAMIC_VALUE : expectedIndex;
return compField.getType().getFieldType(timestamp, reference, actualSubReference + 1, internalExpectation, refChain, interruptIfOptional);
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return null;
}
}
Aggregations