use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class Def_Altstep method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
isUsed = false;
runsOnType = null;
lastTimeChecked = timestamp;
T3Doc.check(this.getCommentLocation(), KIND);
if (runsOnRef != null) {
runsOnType = runsOnRef.chkComponentypeReference(timestamp);
if (runsOnType != null) {
final Scope formalParlistPreviosScope = formalParList.getParentScope();
if (formalParlistPreviosScope instanceof RunsOnScope && ((RunsOnScope) formalParlistPreviosScope).getParentScope() == myScope) {
((RunsOnScope) formalParlistPreviosScope).setComponentType(runsOnType);
} else {
final Scope tempScope = new RunsOnScope(runsOnType, myScope);
formalParList.setMyScope(tempScope);
}
}
}
if (formalParList.hasNotusedDefaultValue()) {
formalParList.getLocation().reportSemanticError(DASHALLOWEDONLYFORTEMPLATES);
}
boolean canSkip = false;
if (myScope != null) {
final Module module = myScope.getModuleScope();
if (module != null) {
if (module.getSkippedFromSemanticChecking()) {
canSkip = true;
}
}
}
if (!canSkip) {
formalParList.reset();
}
formalParList.check(timestamp, getAssignmentType());
if (canSkip) {
return;
}
NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_ALTSTEP, identifier, this);
NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
if (block != null) {
block.check(timestamp);
block.setCodeSection(CodeSectionType.CS_INLINE);
}
if (altGuards != null) {
altGuards.setIsAltstep();
altGuards.setMyAltguards(altGuards);
altGuards.setMyLaicStmt(altGuards, null);
altGuards.check(timestamp);
altGuards.setCodeSection(CodeSectionType.CS_INLINE);
}
if (withAttributesPath != null) {
withAttributesPath.checkGlobalAttributes(timestamp, false);
withAttributesPath.checkAttributes(timestamp);
}
if (block != null) {
block.postCheck();
}
if (altGuards != null) {
altGuards.postCheck();
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class Done_Statement method generateCodeExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpression(final JavaGenData aData, final ExpressionStruct expression) {
aData.addCommonLibraryImport("TTCN_Runtime");
aData.addBuiltinTypeImport("TitanComponent");
if (componentreference != null) {
if (doneMatch != null) {
// value returning done
// figure out what type the done() function belongs to
IType t = doneMatch.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
if (t == null) {
ErrorReporter.INTERNAL_ERROR("Encountered a done with unknown governor `" + getFullName() + "''");
return;
}
while (t instanceof Referenced_Type && !t.hasDoneAttribute()) {
final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
t = ((IReferencingType) t).getTypeRefd(CompilationTimeStamp.getBaseTimestamp(), refChain);
refChain.release();
}
if (!t.hasDoneAttribute()) {
ErrorReporter.INTERNAL_ERROR("Encountered a done return type without done attribute `" + getFullName() + "''");
return;
}
// determine whether the done() function is in the same module
final Module t_module = t.getMyScope().getModuleScope();
if (t_module != myStatementBlock.getModuleScope()) {
expression.expression.append(MessageFormat.format("{0}.", t_module.getIdentifier().getName()));
}
expression.expression.append("done(");
componentreference.generateCodeExpression(aData, expression, true);
expression.expression.append(", ");
// FIXME handle decoded match
doneMatch.generateCode(aData, expression, Restriction_type.TR_NONE);
// expression.expression.append(", ");
// FIXME handle value redirection
} else {
// simple done
componentreference.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".done(");
}
// FIXME handle index redirection
expression.expression.append(')');
} else if (isAny) {
// any component.done
expression.expression.append("TTCN_Runtime.component_done(TitanComponent.ANY_COMPREF)");
} else {
// all component.done
expression.expression.append("TTCN_Runtime.component_done(TitanComponent.ALL_COMPREF)");
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class CTs_EE_CTs method check.
public void check(final CompilationTimeStamp timestamp) {
if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (null != myScope && null != lastTimeChecked) {
final Module module = myScope.getModuleScope();
if (null != module) {
if (module.getSkippedFromSemanticChecking()) {
lastTimeChecked = timestamp;
return;
}
}
}
if (null == myType) {
return;
} else if (null == components) {
components = new ArrayList<CompField>();
componentsMap = new HashMap<String, CompField>();
}
lastTimeChecked = timestamp;
components.clear();
componentsMap.clear();
String typeName;
String componentName;
switch(myType.getTypetype()) {
case TYPE_ASN1_SEQUENCE:
typeName = "SEQUENCE";
componentName = "Component";
break;
case TYPE_ASN1_SET:
typeName = "SET";
componentName = "Component";
break;
case TYPE_ASN1_CHOICE:
typeName = "CHOICE";
componentName = "Alternative";
break;
default:
// some INTERNAL ERROR
typeName = "<unknown>";
componentName = "component";
break;
}
for (int i = 0; i < componentTypeList1.getNofComps(); i++) {
checkComponentField(componentTypeList1.getCompByIndex(i), typeName, componentName);
}
if (null != extensionAndException) {
for (int i = 0; i < extensionAndException.getNofComps(); i++) {
checkComponentField(extensionAndException.getCompByIndex(i), typeName, componentName);
}
final ExceptionSpecification es = extensionAndException.getExceptionSpecification();
if (es != null) {
es.getType().check(timestamp);
}
}
for (int i = 0; i < componentTypeList2.getNofComps(); i++) {
checkComponentField(componentTypeList2.getCompByIndex(i), typeName, componentName);
}
components.trimToSize();
IType type;
for (final CompField componentField : components) {
type = componentField.getType();
type.setGenName(myType.getGenNameOwn(), componentField.getIdentifier().getName());
type.setParentType(myType);
componentField.check(timestamp);
}
}
use of org.eclipse.titan.designer.AST.Module 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.Module in project titan.EclipsePlug-ins by eclipse.
the class Imports method checkImports.
/**
* Checks the import hierarchies of this importation (and the ones in
* the imported module recursively).
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param referenceChain
* a chain of references used to find circularly imported
* modules.
* @param moduleStack
* the stack of modules visited so far, from the starting
* point.
*/
public void checkImports(final CompilationTimeStamp timestamp, final ModuleImportationChain referenceChain, final List<Module> moduleStack) {
if (null != lastImportCheckTimeStamp && !lastImportCheckTimeStamp.isLess(timestamp)) {
return;
}
lastImportCheckTimeStamp = timestamp;
if (null == project) {
return;
}
importedModules_map.clear();
singularImportedSymbols_map.clear();
pluralImportedSymbols.clear();
final ProjectSourceParser parser = GlobalParser.getProjectSourceParser(project);
if (null == parser) {
return;
}
for (ImportModule importModule : importedModules_v) {
final Identifier identifier = importModule.getIdentifier();
if (null == identifier || null == identifier.getLocation()) {
continue;
}
final Module referredModule = parser.getModuleByName(identifier.getName());
if (null == referredModule) {
identifier.getLocation().reportSemanticError(MessageFormat.format(ImportModule.MISSINGMODULE, identifier.getDisplayName()));
continue;
} else if (!(referredModule instanceof ASN1Module)) {
identifier.getLocation().reportSemanticError(TTCN3IMPORT);
continue;
} else if (referredModule == module) {
identifier.getLocation().reportSemanticError(SELFIMPORT);
continue;
}
String name = identifier.getName();
if (importedModules_map.containsKey(name)) {
final Location importedLocation = importedModules_map.get(name).getIdentifier().getLocation();
importedLocation.reportSingularSemanticError(MessageFormat.format(DUPLICATEIMPORTFIRST, identifier.getDisplayName()));
identifier.getLocation().reportSemanticError(MessageFormat.format(DUPLICATEIMPORTREPEATED, identifier.getDisplayName()));
} else {
importedModules_map.put(name, importModule);
}
final Symbols symbols = importModule.getSymbols();
if (null == symbols) {
continue;
}
for (int i = 0; i < symbols.size(); i++) {
name = symbols.getNthElement(i).getName();
if (singularImportedSymbols_map.containsKey(name)) {
if (!referredModule.equals(singularImportedSymbols_map.get(name))) {
singularImportedSymbols_map.remove(name);
pluralImportedSymbols.add(name);
}
} else if (!pluralImportedSymbols.contains(name)) {
singularImportedSymbols_map.put(name, referredModule);
}
}
importModule.setUnhandledChange(false);
LoadBalancingUtilities.astNodeChecked();
}
for (ImportModule importModule : importedModules_v) {
// check the imports recursively
referenceChain.markState();
importModule.checkImports(timestamp, referenceChain, moduleStack);
referenceChain.previousState();
}
}
Aggregations