use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Function_Instance_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment == null) {
return;
}
if (myStatementBlock != null) {
myStatementBlock.checkRunsOnScope(timestamp, assignment, reference, "call");
}
switch(assignment.getAssignmentType()) {
case A_FUNCTION_RVAL:
case A_EXT_FUNCTION_RVAL:
location.reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNUSEDFUNCTIONRETURNVALUES, GeneralConstants.WARNING, null), MessageFormat.format(UNUSEDRETURN1, assignment.getFullName()));
break;
case A_FUNCTION_RTEMP:
case A_EXT_FUNCTION_RTEMP:
location.reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNUSEDFUNCTIONRETURNVALUES, GeneralConstants.WARNING, null), MessageFormat.format(UNUSEDRETURN2, assignment.getFullName()));
break;
default:
break;
}
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class ImportModule method addProposal.
/**
* Adds the imported module or definitions contained in it, to the list
* completion proposals.
*
* @param propCollector
* the proposal collector.
* @param targetModuleId
* the identifier of the module where the definition will
* be inserted. It is used to check if it is visible
* there or not.
*/
@Override
public /**
* {@inheritDoc}
*/
void addProposal(final ProposalCollector propCollector, final Identifier targetModuleId) {
final List<ISubReference> subrefs = propCollector.getReference().getSubreferences();
if (propCollector.getReference().getModuleIdentifier() == null && subrefs.size() == 1) {
propCollector.addProposal(identifier, ImageCache.getImage(getOutlineIcon()), KIND);
}
final Module savedReferredModule = referredModule;
if (savedReferredModule != null) {
final Assignments assignments = savedReferredModule.getAssignments();
for (int i = 0, size = assignments.getNofAssignments(); i < size; i++) {
final Assignment temporalAssignment = assignments.getAssignmentByIndex(i);
if (savedReferredModule.isVisible(CompilationTimeStamp.getBaseTimestamp(), targetModuleId, temporalAssignment)) {
temporalAssignment.addProposal(propCollector, 0);
}
}
}
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class TableConstraint method getOpenTypeAlternativeName.
// Original titan.core version: t_type->get_otaltname(is_strange);
private Identifier getOpenTypeAlternativeName(final CompilationTimeStamp timestamp, final Type type, final AtomicBoolean isStrange) {
StringBuffer sb = new StringBuffer();
// TODO: if (is_tagged() || is_constrained() || hasRawAttrs()) {
if (!type.getIsErroneous(timestamp) && type.isConstrained()) {
sb.append(type.getGenNameOwn());
isStrange.set(true);
} else if (!type.getIsErroneous(timestamp) && type instanceof Referenced_Type) {
Reference t_ref = ((Referenced_Type) type).getReference();
if (t_ref != null) {
final Identifier id = t_ref.getId();
final String dn = id.getDisplayName();
int i = dn.indexOf('.');
if (i >= 0 && i < dn.length()) {
// id is not regular because t_ref is a parameterized reference
sb.append(id.getName());
isStrange.set(true);
} else {
Assignment as = t_ref.getRefdAssignment(timestamp, true);
if (as == null) {
return null;
}
Scope assScope = as.getMyScope();
if (assScope.getParentScope() == assScope.getModuleScope()) {
sb.append(id.getName());
isStrange.set(false);
} else {
// t_ref is a dummy reference in a parameterized assignment
// (i.e. it points to a parameter assignment of an instantiation)
// perform the same examination recursively on the referenced type
// (which is the actual parameter)
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
IType referencedType = ((Referenced_Type) type).getTypeRefd(timestamp, chain);
chain.release();
return getOpenTypeAlternativeName(timestamp, (Type) referencedType, isStrange);
}
}
} else {
// the type comes from an information object [class]
// examine the referenced type recursively
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
IType referencedType = ((Referenced_Type) type).getTypeRefd(timestamp, chain);
chain.release();
return getOpenTypeAlternativeName(timestamp, (Type) referencedType, isStrange);
}
} else {
Identifier tmpId1 = new Identifier(Identifier_type.ID_NAME, type.getFullName());
String s = tmpId1.getDisplayName();
// module name will be cut off:
if (s.startsWith("@") && s.indexOf('.') > 0) {
s = s.substring(s.indexOf('.') + 1);
}
Identifier tmpId2 = new Identifier(Identifier_type.ID_ASN, s);
sb.append(tmpId2.getTtcnName());
}
// conversion to lower case initial:
sb.replace(0, 1, sb.substring(0, 1).toLowerCase());
// trick:
Identifier tmpId = new Identifier(Identifier_type.ID_NAME, sb.toString());
return new Identifier(Identifier_type.ID_ASN, tmpId.getAsnName());
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class ReferencedObject method getRefd.
public ASN1Object getRefd(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
if (referenceChain.add(this)) {
if (objectReferenced != null && lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return objectReferenced;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true, referenceChain);
if (null != assignment) {
final ISetting setting = reference.getRefdSetting(timestamp);
if (null != setting && !Setting_type.S_ERROR.equals(setting.getSettingtype())) {
if (Setting_type.S_O.equals(setting.getSettingtype())) {
objectReferenced = (ASN1Object) setting;
return objectReferenced;
}
location.reportSemanticError(OBJECTEXPECTED);
}
}
}
objectReferenced = new Object_Definition(null);
objectReferenced.setMyGovernor(myGovernor);
return objectReferenced;
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Export_Debug_AST_Action method exportDebugAST.
private void exportDebugAST(final ZipOutputStream out, final Module module) throws Exception {
out.putNextEntry(new ZipEntry("DebugAST_for_" + module.getIdentifier().getName() + ".txt"));
out.write("*************************".getBytes());
out.write(lineend);
out.write(("Printing DEBUG information for module `" + module.getName() + "':").getBytes());
out.write(lineend);
out.write("*************************".getBytes());
out.write(lineend);
module.accept(new ASTVisitor() {
private int padding = 0;
@Override
public int visit(IVisitableNode node) {
if (node instanceof Assignment) {
Assignment assignment = (Assignment) node;
printInfoln(out, padding, assignment.getAssignmentName(), assignment.getFullName(), assignment.getLastTimeChecked(), assignment.getLocation());
} else if (node instanceof Identifier) {
printInfoln(out, padding, "identifier", ((Identifier) node).getDisplayName(), null, ((Identifier) node).getLocation());
} else if (node instanceof Statement) {
Statement statement = (Statement) node;
printInfoln(out, padding, "statement", statement.getFullName(), statement.getLastTimeChecked(), statement.getLocation());
} else if (node instanceof Reference) {
Reference ref = (Reference) node;
printInfoln(out, padding, "reference", ref.getFullName(), ref.getLastTimeChecked(), ref.getLocation());
Assignment old = ref.getAssOld();
if (old != null) {
printInfoln(out, padding + 1, "This reference was last pointing to " + old.getFullName() + " analyzed at " + old.getLastTimeChecked());
}
} else if (node instanceof ComponentTypeBody) {
ComponentTypeBody body = (ComponentTypeBody) node;
Map<String, Definition> map = body.getDefinitionMap();
printInfoln(out, padding + 1, " contains definitions:");
if (map != null) {
for (Map.Entry<String, Definition> entry : map.entrySet()) {
printInfoln(out, padding + 2, entry.getKey() + " was last checked at " + entry.getValue().getLastTimeChecked());
}
}
}
if (node instanceof StatementBlock || node instanceof Definition) {
padding++;
}
return super.visit(node);
}
@Override
public int leave(IVisitableNode node) {
if (node instanceof StatementBlock || node instanceof Definition) {
padding--;
}
return super.leave(node);
}
});
out.write("*************************".getBytes());
out.write(lineend);
out.write(("Printing DEBUG information for module `" + module.getName() + "' finished").getBytes());
out.write(lineend);
out.write("*************************".getBytes());
out.write(lineend);
out.closeEntry();
}
Aggregations