use of org.eclipse.titan.designer.AST.INamedNode in project titan.EclipsePlug-ins by eclipse.
the class NamedValue method getDeclaration.
@Override
public /**
* {@inheritDoc}
*/
Declaration getDeclaration() {
INamedNode inamedNode = getNameParent();
while (!(inamedNode instanceof IValue)) {
if (inamedNode == null) {
// FIXME: this is just a temp solution! find the reason!
return null;
}
inamedNode = inamedNode.getNameParent();
}
final IValue iValue = (IValue) inamedNode;
IType type = iValue.getMyGovernor();
if (type == null) {
return null;
}
type = type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
if (type instanceof ITypeWithComponents) {
final Identifier id = ((ITypeWithComponents) type).getComponentIdentifierByName(getName());
return Declaration.createInstance(type.getDefiningAssignment(), id);
}
return null;
}
use of org.eclipse.titan.designer.AST.INamedNode 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.INamedNode in project titan.EclipsePlug-ins by eclipse.
the class Shorthand method check.
protected void check(final Statement s, final Problems problems) {
if (s == null) {
return;
}
// shorthand statements are ignored inside alt statements
INamedNode curr = s;
while (curr != null) {
if (curr instanceof Alt_Statement || curr instanceof Call_Statement) {
return;
}
curr = curr.getNameParent();
}
final StatementBlock sb = s.getMyStatementBlock();
if (sb == null) {
return;
}
final Definition d = sb.getMyDefinition();
if (d == null) {
return;
}
// shorthand statements are marked in functions, test cases and altsteps that have a 'runs on' clause
if (d instanceof Def_Function && ((Def_Function) d).getRunsOnType(timestamp) != null) {
problems.report(s.getLocation(), ERROR_MESSAGE_PREFIX + typename + ERROR_MESSAGE_SUFFIX);
return;
}
if (d instanceof Def_Altstep || d instanceof Def_Testcase) {
problems.report(s.getLocation(), ERROR_MESSAGE_PREFIX + typename + ERROR_MESSAGE_SUFFIX);
}
}
use of org.eclipse.titan.designer.AST.INamedNode in project titan.EclipsePlug-ins by eclipse.
the class CompField method getDeclaration.
@Override
public /**
* {@inheritDoc}
*/
Declaration getDeclaration() {
INamedNode inamedNode = getNameParent();
while (!(inamedNode instanceof Definition)) {
if (inamedNode == null) {
// FIXME: this is just a temp solution! find the reason!
return null;
}
inamedNode = inamedNode.getNameParent();
}
final Definition namedTemplList = (Definition) inamedNode;
IType tempType = namedTemplList.getType(CompilationTimeStamp.getBaseTimestamp());
if (tempType == null) {
return null;
}
tempType = tempType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
if (tempType instanceof ITypeWithComponents) {
final Identifier resultId = ((ITypeWithComponents) tempType).getComponentIdentifierByName(getIdentifier());
return Declaration.createInstance(tempType.getDefiningAssignment(), resultId);
}
return null;
}
use of org.eclipse.titan.designer.AST.INamedNode in project titan.EclipsePlug-ins by eclipse.
the class NamedTemplate method getDeclaration.
@Override
public /**
* {@inheritDoc}
*/
Declaration getDeclaration() {
INamedNode inamedNode = getNameParent();
while (!(inamedNode instanceof Named_Template_List)) {
if (inamedNode == null) {
// FIXME: this is just a temp solution! find the reason!
return null;
}
inamedNode = inamedNode.getNameParent();
}
final Named_Template_List namedTemplList = (Named_Template_List) inamedNode;
IType type = namedTemplList.getMyGovernor();
if (type == null) {
return null;
}
type = type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
if (type instanceof ITypeWithComponents) {
final Identifier id = ((ITypeWithComponents) type).getComponentIdentifierByName(getName());
return Declaration.createInstance(type.getDefiningAssignment(), id);
}
return null;
}
Aggregations