Commit cb3ee2b5 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ improved handling of external functions

+ improved handling of test case scopes
parent caf4543a
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -72,7 +72,13 @@ ExtFunctionDef:
	return=ReturnType?;

ExtConstDef:
	EXTKEYWORD CONSTKEYWORD type=Type id=IdentifierList;
	EXTKEYWORD CONSTKEYWORD type=Type id=IdentifierObjectList;

IdentifierObjectList:
    ids+=NamedObject (COMMA ids+=NamedObject)*;

NamedObject:
    name=IDENTIFIER;

ImportDef:
	IMPORTKEYWORD FROMKEYWORD name=IDENTIFIER spec=LanguageSpec? RECURSIVEKEYWORD? (all=AllWithExcepts | LBRACKET
@@ -881,7 +887,7 @@ TempVarList:
	variables+=SingleTempVarInstance (COMMA variables+=SingleTempVarInstance)*;

TimerVarInstance:
	SingleVarInstance | FormalTimerPar;
	SingleVarInstance | FormalTimerPar | ComponentDef;

SingleVarInstance:
	name=IDENTIFIER array=ArrayDef? (ac=ASSIGNMENTCHAR expr=Expression)?;
@@ -1115,7 +1121,7 @@ ExtendedFieldReference:
// SingleVarInstance contained in TimerVarInstance (according to EBNF rules)
RefValue:
	ModuleParameter | FieldReference | FormalTemplatePar | SingleTempVarInstance |
	FunctionRef | TimerVarInstance | FormalPortPar | PortElement;
	FunctionRef | TimerVarInstance | FormalPortPar | PortElement | NamedObject;

	// IDENTIFIER omitted
PredefinedValue:
+26 −0
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ import org.eclipse.emf.ecore.EObject
import org.eclipse.xtext.scoping.IScope

import static org.eclipse.xtext.scoping.Scopes.*
import de.ugoe.cs.swe.tTCN3.ExtConstDef
import de.ugoe.cs.swe.tTCN3.IdentifierObjectList

class TTCN3ScopeHelper {

@@ -148,6 +150,14 @@ class TTCN3ScopeHelper {
			}
		}

        defs = moduleDef.definitions.filter[it.def instanceof ExtConstDef]
        for (ModuleDefinition v : defs) {
            val constDefList = (v.def as ExtConstDef).id as IdentifierObjectList
            for (EObject d : constDefList.ids) {
                list.add(d)
            }
        }

		defs = moduleDef.definitions.filter[it.def instanceof TypeDef]
		for (ModuleDefinition v : defs) {
			val body = (v.def as TypeDef).body
@@ -362,6 +372,22 @@ class TTCN3ScopeHelper {
		list
	}

    def static Iterable<RefValueElement> testcaseLocalParameter(TestcaseDef testcase) {
        val list = newArrayList
        if (testcase.parList == null)
            return list;

        for (p : testcase.parList.params) {
            if (p.value != null) {
                list.add(p.value)
            } else if (p.template != null) {
                list.add(p.template)
            }
        }
        list
    }


	def static Iterable<RefValueElement> altstepLocalParameter(AltstepDef altstep) {
		val list = newArrayList
		if (altstep.params == null)
+16 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ import static org.eclipse.xtext.scoping.Scopes.*

import static extension de.ugoe.cs.swe.common.TTCN3ScopeHelper.*
import static extension org.eclipse.xtext.EcoreUtil2.*
import de.ugoe.cs.swe.tTCN3.ExtConstDef
import de.ugoe.cs.swe.tTCN3.NamedObject

class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	private final static Logger LOG = Logger.getLogger(TTCN3LocalScopeProvider);
@@ -308,6 +310,15 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
				}
				list.addAll(parent.eAllOfType(SingleVarInstance))
				list.addAll(parent.functionLocalParameter)
            } else if (parent instanceof TestcaseDef) {
                if (parent.spec.runsOn != null) {
                    componentScopeValueRefs(parent.spec.runsOn.component, list, true, false, false)
                }
                if (parent.spec.systemSpec != null) {
                    componentScopeValueRefs(parent.spec.systemSpec.component, list, true, false, false)
                }
                list.addAll(parent.eAllOfType(SingleVarInstance))
                list.addAll(parent.testcaseLocalParameter)
			} else if (parent instanceof ComponentDef) {
				for (ComponentDefList l : parent.defs) {
					if (l.element.timer != null) {
@@ -710,6 +721,11 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
			if (variable.type.ref != null) {
				variable.type.ref.scopeReferencedFields
			}
        } else if (value instanceof NamedObject) {
            val variable = value.findDesiredParent(ExtConstDef)
            if (variable.type.ref != null) {
                variable.type.ref.scopeReferencedFields
            }
		}
	}

+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public class NamingConventionsValidator extends AbstractDeclarativeValidator {
	 	val regExp = activeProfile.namingConventionsConfig.extConstantRegExp;
	 	val INode node = NodeModelUtils.getNode(const)
	 	for (n : const.id.ids) {
	 		n.toString.checkIdentifierForNamingConventionCompliance(node, regExp, "External Constant")
	 		n.name.checkIdentifierForNamingConventionCompliance(node, regExp, "External Constant")
	 	}	 	
	 }