|
Lines 89-95
Link Here
|
| 89 |
import org.eclipse.ocl.cst.RealLiteralExpCS; |
89 |
import org.eclipse.ocl.cst.RealLiteralExpCS; |
| 90 |
import org.eclipse.ocl.cst.SimpleNameCS; |
90 |
import org.eclipse.ocl.cst.SimpleNameCS; |
| 91 |
import org.eclipse.ocl.cst.SimpleTypeEnum; |
91 |
import org.eclipse.ocl.cst.SimpleTypeEnum; |
| 92 |
import org.eclipse.ocl.cst.StateExpCS; |
|
|
| 93 |
import org.eclipse.ocl.cst.StringLiteralExpCS; |
92 |
import org.eclipse.ocl.cst.StringLiteralExpCS; |
| 94 |
import org.eclipse.ocl.cst.TupleLiteralExpCS; |
93 |
import org.eclipse.ocl.cst.TupleLiteralExpCS; |
| 95 |
import org.eclipse.ocl.cst.TupleTypeCS; |
94 |
import org.eclipse.ocl.cst.TupleTypeCS; |
|
Lines 290-303
Link Here
|
| 290 |
case OCLParsersym.TK_collectNested : |
289 |
case OCLParsersym.TK_collectNested : |
| 291 |
case OCLParsersym.TK_sortedBy : |
290 |
case OCLParsersym.TK_sortedBy : |
| 292 |
case OCLParsersym.TK_closure : |
291 |
case OCLParsersym.TK_closure : |
| 293 |
case OCLParsersym.TK_oclIsKindOf : |
|
|
| 294 |
case OCLParsersym.TK_oclIsTypeOf : |
| 295 |
case OCLParsersym.TK_oclAsType : |
| 296 |
case OCLParsersym.TK_oclIsNew : |
| 297 |
case OCLParsersym.TK_oclIsUndefined : |
| 298 |
case OCLParsersym.TK_oclIsInvalid : |
| 299 |
case OCLParsersym.TK_oclIsInState : |
| 300 |
case OCLParsersym.TK_allInstances : |
| 301 |
case OCLParsersym.TK_String : |
292 |
case OCLParsersym.TK_String : |
| 302 |
case OCLParsersym.TK_Integer : |
293 |
case OCLParsersym.TK_Integer : |
| 303 |
case OCLParsersym.TK_UnlimitedNatural : |
294 |
case OCLParsersym.TK_UnlimitedNatural : |
|
Lines 705-711
Link Here
|
| 705 |
initASTMapping(packageEnv, createDummyPackage(env, |
696 |
initASTMapping(packageEnv, createDummyPackage(env, |
| 706 |
packageDeclarationCS), packageDeclarationCS); |
697 |
packageDeclarationCS), packageDeclarationCS); |
| 707 |
} else { |
698 |
} else { |
| 708 |
pathname = createSequenceOfNames(pathNameCS.getSimpleNames()); |
699 |
pathname = createSequenceOfNames(pathNameCS, null); |
| 709 |
try { |
700 |
try { |
| 710 |
packageEnv = createPackageContext(getOCLEnvironment(), pathname); |
701 |
packageEnv = createPackageContext(getOCLEnvironment(), pathname); |
| 711 |
if (packageEnv != null) { |
702 |
if (packageEnv != null) { |
|
Lines 826-833
Link Here
|
| 826 |
|
817 |
|
| 827 |
O operation = null; |
818 |
O operation = null; |
| 828 |
C classifier = null; |
819 |
C classifier = null; |
| 829 |
EList<String> className = createSequenceOfNames(operationCS.getPathNameCS() |
820 |
EList<String> className = createSequenceOfNames(operationCS.getPathNameCS(), null); |
| 830 |
.getSimpleNames()); |
|
|
| 831 |
String operationName = operationCS.getSimpleNameCS().getValue(); |
821 |
String operationName = operationCS.getSimpleNameCS().getValue(); |
| 832 |
EList<String> qualifiedOperationName = new BasicEList<String>(); |
822 |
EList<String> qualifiedOperationName = new BasicEList<String>(); |
| 833 |
qualifiedOperationName.addAll(className); |
823 |
qualifiedOperationName.addAll(className); |
|
Lines 1132-1139
Link Here
|
| 1132 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env, |
1122 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env, |
| 1133 |
List<CT> constraints) { |
1123 |
List<CT> constraints) { |
| 1134 |
|
1124 |
|
| 1135 |
EList<String> pathName = createSequenceOfNames(propertyContextCS.getPathNameCS() |
1125 |
EList<String> pathName = createSequenceOfNames(propertyContextCS.getPathNameCS(), null); |
| 1136 |
.getSimpleNames()); |
|
|
| 1137 |
C owner = lookupClassifier(propertyContextCS.getPathNameCS(), env, |
1126 |
C owner = lookupClassifier(propertyContextCS.getPathNameCS(), env, |
| 1138 |
pathName); |
1127 |
pathName); |
| 1139 |
|
1128 |
|
|
Lines 1348-1354
Link Here
|
| 1348 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> result = null; |
1337 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> result = null; |
| 1349 |
|
1338 |
|
| 1350 |
PathNameCS pathNameCS = classifierContextDeclCS.getPathNameCS(); |
1339 |
PathNameCS pathNameCS = classifierContextDeclCS.getPathNameCS(); |
| 1351 |
EList<String> pathName = createSequenceOfNames(pathNameCS.getSimpleNames()); |
1340 |
EList<String> pathName = createSequenceOfNames(pathNameCS, null); |
| 1352 |
C type = lookupClassifier(pathNameCS, env, pathName); |
1341 |
C type = lookupClassifier(pathNameCS, env, pathName); |
| 1353 |
|
1342 |
|
| 1354 |
if (type == null) { |
1343 |
if (type == null) { |
|
Lines 1757-1763
Link Here
|
| 1757 |
astNode = primitiveTypeCS(((PrimitiveTypeCS) typeCS).getType(), env); |
1746 |
astNode = primitiveTypeCS(((PrimitiveTypeCS) typeCS).getType(), env); |
| 1758 |
typeCS.setAst(astNode); |
1747 |
typeCS.setAst(astNode); |
| 1759 |
} else if (typeCS instanceof PathNameCS) { |
1748 |
} else if (typeCS instanceof PathNameCS) { |
| 1760 |
EList<String> pathName = createSequenceOfNames(((PathNameCS) typeCS).getSimpleNames()); |
1749 |
EList<String> pathName = createSequenceOfNames((PathNameCS) typeCS, null); |
| 1761 |
astNode = lookupClassifier(typeCS, env, pathName); |
1750 |
astNode = lookupClassifier(typeCS, env, pathName); |
| 1762 |
if (astNode == null) { |
1751 |
if (astNode == null) { |
| 1763 |
String message = OCLMessages.bind( |
1752 |
String message = OCLMessages.bind( |
|
Lines 1789-1797
Link Here
|
| 1789 |
* @param env |
1778 |
* @param env |
| 1790 |
* the OCL environment |
1779 |
* the OCL environment |
| 1791 |
* @return a <code>StateExp</code> representing the state |
1780 |
* @return a <code>StateExp</code> representing the state |
|
|
1781 |
* @since 3.0 |
| 1792 |
*/ |
1782 |
*/ |
| 1793 |
protected StateExp<C, S> stateExpCS(OCLExpression<C> source, |
1783 |
protected StateExp<C, S> stateExpCS(OCLExpression<C> source, |
| 1794 |
StateExpCS stateExpCS, |
1784 |
CSTNode stateExpCS, EList<String> statePath, |
| 1795 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env) { |
1785 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env) { |
| 1796 |
|
1786 |
|
| 1797 |
C sourceType = null; |
1787 |
C sourceType = null; |
|
Lines 1801-1808
Link Here
|
| 1801 |
|
1791 |
|
| 1802 |
S state = null; |
1792 |
S state = null; |
| 1803 |
|
1793 |
|
| 1804 |
EList<String> statePath = createSequenceOfNames(stateExpCS.getSimpleNames()); |
|
|
| 1805 |
|
| 1806 |
if (!statePath.isEmpty()) { |
1794 |
if (!statePath.isEmpty()) { |
| 1807 |
// to support content-assist, we can parse an expression that |
1795 |
// to support content-assist, we can parse an expression that |
| 1808 |
// has no state, to provide suggestions for the first part |
1796 |
// has no state, to provide suggestions for the first part |
|
Lines 3283-3290
Link Here
|
| 3283 |
|
3271 |
|
| 3284 |
OCLExpression<C> astNode = null; |
3272 |
OCLExpression<C> astNode = null; |
| 3285 |
|
3273 |
|
| 3286 |
List<SimpleNameCS> simpleNames = enumLiteralExpCS.getPathNameCS().getSimpleNames(); |
3274 |
EList<String> sequenceOfNames = createSequenceOfNames(enumLiteralExpCS.getPathNameCS(), null); |
| 3287 |
EList<String> sequenceOfNames = createSequenceOfNames(simpleNames); |
|
|
| 3288 |
String lastToken = enumLiteralExpCS.getSimpleNameCS().getValue(); |
3275 |
String lastToken = enumLiteralExpCS.getSimpleNameCS().getValue(); |
| 3289 |
|
3276 |
|
| 3290 |
EL literal = null; |
3277 |
EL literal = null; |
|
Lines 4009-4115
Link Here
|
| 4009 |
OperationCallExpCS operationCallExpCS, |
3996 |
OperationCallExpCS operationCallExpCS, |
| 4010 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env) { |
3997 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env) { |
| 4011 |
|
3998 |
|
| 4012 |
OperationCallExp<C, O> astNode = null; |
|
|
| 4013 |
|
| 4014 |
List<OCLExpression<C>> args = new java.util.ArrayList<OCLExpression<C>>(); |
| 4015 |
// boolean isMarkedPre = false; |
| 4016 |
|
| 4017 |
String name = operationCallExpCS.getSimpleNameCS().getValue(); |
| 4018 |
int operator = operationCallExpCS.getAccessor().getValue(); |
3999 |
int operator = operationCallExpCS.getAccessor().getValue(); |
| 4019 |
|
|
|
| 4020 |
/* |
| 4021 |
* The type of the operation is specified by a path expression or self, |
| 4022 |
* or by an explicit source expression. The source expression may be a |
| 4023 |
* collection type (-> operation) or a regular navigation expression (. |
| 4024 |
* operation) |
| 4025 |
*/ |
| 4026 |
OCLExpression<C> source = null; |
| 4027 |
if (operator == DotOrArrowEnum.ARROW) { |
4000 |
if (operator == DotOrArrowEnum.ARROW) { |
| 4028 |
source = getCollectionSourceExpression(operationCallExpCS |
4001 |
return arrowOperationCallExpCS(operationCallExpCS, env); |
| 4029 |
.getSource(), env); |
4002 |
} |
| 4030 |
} else { |
4003 |
OCLExpressionCS sourceCS = operationCallExpCS.getSource(); |
| 4031 |
OCLExpressionCS sourceCS = operationCallExpCS.getSource(); |
4004 |
if ((sourceCS == null) && (operationCallExpCS.getPathNameCS() != null)) { |
| 4032 |
|
4005 |
return staticOperationCallExpCS(operationCallExpCS, env); |
| 4033 |
if (sourceCS instanceof PathNameCS) { |
|
|
| 4034 |
// static operation call |
| 4035 |
PathNameCS pathName = (PathNameCS) sourceCS; |
| 4036 |
|
| 4037 |
EList<String> pathNames = createSequenceOfNames(pathName |
| 4038 |
.getSimpleNames()); |
| 4039 |
C sourceType = lookupClassifier(sourceCS, env, pathNames); |
| 4040 |
if (sourceType == null) { |
| 4041 |
String message = OCLMessages.bind( |
| 4042 |
OCLMessages.UnrecognizedType_ERROR_, pathNames); |
| 4043 |
ERROR(sourceCS, "operatonCallExpCS", message);//$NON-NLS-1$ |
| 4044 |
} else { |
| 4045 |
source = typeCS(sourceCS, env, sourceType); |
| 4046 |
} |
| 4047 |
} else { |
| 4048 |
source = oclExpressionCS(operationCallExpCS.getSource(), env); |
| 4049 |
} |
| 4050 |
} |
4006 |
} |
| 4051 |
|
|
|
| 4052 |
String operationName = operationCallExpCS.getSimpleNameCS().getValue(); |
4007 |
String operationName = operationCallExpCS.getSimpleNameCS().getValue(); |
| 4053 |
|
|
|
| 4054 |
if (PredefinedType.OCL_IS_IN_STATE_NAME.equals(operationName)) { |
4008 |
if (PredefinedType.OCL_IS_IN_STATE_NAME.equals(operationName)) { |
| 4055 |
if (operationCallExpCS.getArguments().size() != 1) { |
4009 |
return oclIsInStateOperationCallExpCS(operationCallExpCS, env); |
| 4056 |
String message = OCLMessages.bind( |
|
|
| 4057 |
OCLMessages.IsInStateSignature_ERROR_, |
| 4058 |
computeInputString(operationCallExpCS)); |
| 4059 |
ERROR(operationCallExpCS, "operationCallExpCS", message);//$NON-NLS-1$ |
| 4060 |
} |
| 4061 |
|
| 4062 |
if (!operationCallExpCS.getArguments().isEmpty()) { |
| 4063 |
OCLExpressionCS arg = operationCallExpCS.getArguments().get(0); |
| 4064 |
|
| 4065 |
if (arg instanceof StateExpCS) { |
| 4066 |
args.add(stateExpCS(source, (StateExpCS) arg, env)); |
| 4067 |
} else { |
| 4068 |
String message = OCLMessages.bind( |
| 4069 |
OCLMessages.IsInStateSignature_ERROR_, |
| 4070 |
computeInputString(operationCallExpCS)); |
| 4071 |
ERROR(arg, "operationCallExpCS", message);//$NON-NLS-1$ |
| 4072 |
} |
| 4073 |
} |
| 4074 |
} else { |
| 4075 |
for (OCLExpressionCS arg : operationCallExpCS.getArguments()) { |
| 4076 |
OCLExpression<C> argExpr = oclExpressionCS(arg, env); |
| 4077 |
if (argExpr == null) { |
| 4078 |
argExpr = createDummyInvalidLiteralExp(env, arg); |
| 4079 |
initASTMapping(env, argExpr, arg); |
| 4080 |
} |
| 4081 |
args.add(argExpr); |
| 4082 |
} |
| 4083 |
} |
4010 |
} |
| 4084 |
|
4011 |
OCLExpression<C> source = oclExpressionCS(operationCallExpCS.getSource(), env); |
| 4085 |
if (source == null) { // create an implicit source |
4012 |
List<OCLExpression<C>> args = argumentsCS(operationCallExpCS, env); |
| 4086 |
Variable<C, PM> implicitSource = lookupImplicitSourceForOperation( |
4013 |
if (source == null) { // create an implicit source |
| 4087 |
operationCallExpCS, env, args, operationName); |
4014 |
source = createImplicitSource(operationCallExpCS, env, args); |
| 4088 |
VariableExp<C, PM> vexp = createVariableExp(env, |
|
|
| 4089 |
operationCallExpCS, implicitSource); |
| 4090 |
|
| 4091 |
if (implicitSource == null) { |
| 4092 |
String errMessage = name + "(";//$NON-NLS-1$ |
| 4093 |
for (int i = 0; i < args.size(); i++) { |
| 4094 |
if (i > 0) { |
| 4095 |
errMessage += ", ";//$NON-NLS-1$ |
| 4096 |
} |
| 4097 |
errMessage += uml.getName(args.get(i).getType()); |
| 4098 |
} |
| 4099 |
errMessage += ")";//$NON-NLS-1$ |
| 4100 |
String message = OCLMessages.bind( |
| 4101 |
OCLMessages.IllegalSignature_ERROR_, errMessage); |
| 4102 |
ERROR(operationCallExpCS, "operationCallExpCS", message); //$NON-NLS-1$ |
| 4103 |
} |
| 4104 |
|
| 4105 |
if (implicitSource != null) { |
| 4106 |
vexp.setType(implicitSource.getType()); |
| 4107 |
vexp.setReferredVariable(implicitSource); |
| 4108 |
} else { |
| 4109 |
vexp.setType(getOclVoid()); |
| 4110 |
} |
| 4111 |
|
| 4112 |
source = vexp; |
| 4113 |
} |
4015 |
} |
| 4114 |
|
4016 |
|
| 4115 |
/* |
4017 |
/* |
|
Lines 4130-4136
Link Here
|
| 4130 |
// if the sourceType is a TypeType then this must be a static operation |
4032 |
// if the sourceType is a TypeType then this must be a static operation |
| 4131 |
boolean isStatic = operationSourceType instanceof TypeType<?, ?>; |
4033 |
boolean isStatic = operationSourceType instanceof TypeType<?, ?>; |
| 4132 |
|
4034 |
|
| 4133 |
astNode = genOperationCallExp(env, operationCallExpCS, |
4035 |
OperationCallExp<C, O> astNode = genOperationCallExp(env, operationCallExpCS, |
| 4134 |
"operationCallExpCS", operationName,//$NON-NLS-1$ |
4036 |
"operationCallExpCS", operationName,//$NON-NLS-1$ |
| 4135 |
source, operationSourceType, args); |
4037 |
source, operationSourceType, args); |
| 4136 |
if (isStatic) { |
4038 |
if (isStatic) { |
|
Lines 4170-4175
Link Here
|
| 4170 |
} |
4072 |
} |
| 4171 |
|
4073 |
|
| 4172 |
/** |
4074 |
/** |
|
|
4075 |
* @since 3.0 |
| 4076 |
*/ |
| 4077 |
protected OCLExpression<C> createImplicitSource(OperationCallExpCS operationCallExpCS, |
| 4078 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env, |
| 4079 |
List<OCLExpression<C>> args) { |
| 4080 |
|
| 4081 |
String operationName = operationCallExpCS.getSimpleNameCS().getValue(); |
| 4082 |
Variable<C, PM> implicitSource = lookupImplicitSourceForOperation( |
| 4083 |
operationCallExpCS, env, args, operationName); |
| 4084 |
VariableExp<C, PM> vexp = createVariableExp(env, operationCallExpCS, implicitSource); |
| 4085 |
|
| 4086 |
if (implicitSource == null) { |
| 4087 |
String errMessage = operationName + "(";//$NON-NLS-1$ |
| 4088 |
for (int i = 0; i < args.size(); i++) { |
| 4089 |
if (i > 0) { |
| 4090 |
errMessage += ", ";//$NON-NLS-1$ |
| 4091 |
} |
| 4092 |
errMessage += uml.getName(args.get(i).getType()); |
| 4093 |
} |
| 4094 |
errMessage += ")";//$NON-NLS-1$ |
| 4095 |
String message = OCLMessages.bind( |
| 4096 |
OCLMessages.IllegalSignature_ERROR_, errMessage); |
| 4097 |
ERROR(operationCallExpCS, "operationCallExpCS", message); //$NON-NLS-1$ |
| 4098 |
} |
| 4099 |
|
| 4100 |
if (implicitSource != null) { |
| 4101 |
vexp.setType(implicitSource.getType()); |
| 4102 |
vexp.setReferredVariable(implicitSource); |
| 4103 |
} else { |
| 4104 |
vexp.setType(getOclVoid()); |
| 4105 |
} |
| 4106 |
return vexp; |
| 4107 |
} |
| 4108 |
|
| 4109 |
/** |
| 4110 |
* OperationCallExpCS for an -> |
| 4111 |
* |
| 4112 |
* @param operationCallExpCS |
| 4113 |
* the <code>OperationCallExpCS</code> <code>CSTNode</code> |
| 4114 |
* @param env |
| 4115 |
* the OCL environment |
| 4116 |
* @return the parsed <code>OCLExpression</code> |
| 4117 |
* @since 3.0 |
| 4118 |
*/ |
| 4119 |
protected OCLExpression<C> arrowOperationCallExpCS( |
| 4120 |
OperationCallExpCS operationCallExpCS, |
| 4121 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env) { |
| 4122 |
|
| 4123 |
OCLExpression<C> source = getCollectionSourceExpression(operationCallExpCS.getSource(), env); |
| 4124 |
List<OCLExpression<C>> args = argumentsCS(operationCallExpCS, env); |
| 4125 |
|
| 4126 |
String operationName = operationCallExpCS.getSimpleNameCS().getValue(); |
| 4127 |
C operationSourceType = source.getType(); |
| 4128 |
OperationCallExp<C, O> astNode = genOperationCallExp(env, operationCallExpCS, |
| 4129 |
"operationCallExpCS", operationName,//$NON-NLS-1$ |
| 4130 |
source, operationSourceType, args); |
| 4131 |
|
| 4132 |
initPropertyPositions(astNode, operationCallExpCS.getSimpleNameCS()); |
| 4133 |
|
| 4134 |
if (isErrorNode(source)) { |
| 4135 |
// don't attempt to parse navigation from an unparseable source |
| 4136 |
markAsErrorNode(astNode); |
| 4137 |
} |
| 4138 |
|
| 4139 |
return astNode; |
| 4140 |
} |
| 4141 |
/** |
| 4142 |
* OperationCallExpCS for oclIsInState |
| 4143 |
* |
| 4144 |
* @param operationCallExpCS |
| 4145 |
* the <code>OperationCallExpCS</code> <code>CSTNode</code> |
| 4146 |
* @param env |
| 4147 |
* the OCL environment |
| 4148 |
* @return the parsed <code>OCLExpression</code> |
| 4149 |
* @since 3.0 |
| 4150 |
*/ |
| 4151 |
protected OCLExpression<C> oclIsInStateOperationCallExpCS( |
| 4152 |
OperationCallExpCS operationCallExpCS, |
| 4153 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env) { |
| 4154 |
if (operationCallExpCS.getArguments().size() != 1) { |
| 4155 |
String message = OCLMessages.bind( |
| 4156 |
OCLMessages.IsInStateSignature_ERROR_, |
| 4157 |
computeInputString(operationCallExpCS)); |
| 4158 |
ERROR(operationCallExpCS, "operationCallExpCS", message);//$NON-NLS-1$ |
| 4159 |
} |
| 4160 |
|
| 4161 |
OCLExpression<C> source = oclExpressionCS(operationCallExpCS.getSource(), env); |
| 4162 |
List<OCLExpression<C>> args = new java.util.ArrayList<OCLExpression<C>>(); |
| 4163 |
if (!operationCallExpCS.getArguments().isEmpty()) { |
| 4164 |
OCLExpressionCS arg = operationCallExpCS.getArguments().get(0); |
| 4165 |
if (arg instanceof VariableExpCS) { |
| 4166 |
VariableExpCS stateName = (VariableExpCS) arg; |
| 4167 |
EList<String> statePath = createSequenceOfNames(null, stateName.getSimpleNameCS()); |
| 4168 |
args.add(stateExpCS(source, stateName, statePath, env)); |
| 4169 |
} else if (arg instanceof EnumLiteralExpCS) { |
| 4170 |
EnumLiteralExpCS stateName = (EnumLiteralExpCS) arg; |
| 4171 |
EList<String> statePath = createSequenceOfNames(stateName.getPathNameCS(), stateName.getSimpleNameCS()); |
| 4172 |
args.add(stateExpCS(source, stateName, statePath, env)); |
| 4173 |
} else { |
| 4174 |
String message = OCLMessages.bind( |
| 4175 |
OCLMessages.IsInStateSignature_ERROR_, |
| 4176 |
computeInputString(operationCallExpCS)); |
| 4177 |
ERROR(arg, "operationCallExpCS", message);//$NON-NLS-1$ |
| 4178 |
} |
| 4179 |
} |
| 4180 |
if (source == null) { // create an implicit source |
| 4181 |
source = createImplicitSource(operationCallExpCS, env, args); |
| 4182 |
} |
| 4183 |
C operationSourceType = source.getType(); |
| 4184 |
String operationName = operationCallExpCS.getSimpleNameCS().getValue(); |
| 4185 |
OperationCallExp<C, O> astNode = genOperationCallExp(env, operationCallExpCS, |
| 4186 |
"operationCallExpCS", operationName,//$NON-NLS-1$ |
| 4187 |
source, operationSourceType, args); |
| 4188 |
astNode.setMarkedPre(isAtPre(operationCallExpCS)); |
| 4189 |
initPropertyPositions(astNode, operationCallExpCS.getSimpleNameCS()); |
| 4190 |
if (isErrorNode(source)) { |
| 4191 |
// don't attempt to parse navigation from an unparseable source |
| 4192 |
markAsErrorNode(astNode); |
| 4193 |
} |
| 4194 |
return astNode; |
| 4195 |
} |
| 4196 |
|
| 4197 |
/** |
| 4198 |
* @since 3.0 |
| 4199 |
*/ |
| 4200 |
protected OCLExpression<C> staticOperationCallExpCS( |
| 4201 |
OperationCallExpCS operationCallExpCS, |
| 4202 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env) { |
| 4203 |
|
| 4204 |
OCLExpression<C> source = null; |
| 4205 |
// OCLExpressionCS sourceCS = operationCallExpCS.getSource(); |
| 4206 |
PathNameCS pathNameCS = operationCallExpCS.getPathNameCS(); |
| 4207 |
|
| 4208 |
EList<String> pathNames = createSequenceOfNames(pathNameCS, null); |
| 4209 |
C sourceType = lookupClassifier(pathNameCS, env, pathNames); |
| 4210 |
if (sourceType == null) { |
| 4211 |
String message = OCLMessages.bind( |
| 4212 |
OCLMessages.UnrecognizedType_ERROR_, pathNames); |
| 4213 |
ERROR(operationCallExpCS, "operatonCallExpCS", message);//$NON-NLS-1$ |
| 4214 |
} else { |
| 4215 |
source = typeCS(pathNameCS, env, sourceType); |
| 4216 |
} |
| 4217 |
|
| 4218 |
String operationName = operationCallExpCS.getSimpleNameCS().getValue(); |
| 4219 |
|
| 4220 |
List<OCLExpression<C>> args = argumentsCS(operationCallExpCS, env); |
| 4221 |
|
| 4222 |
/* |
| 4223 |
* If the source type is a collection and operator is ".", then there is |
| 4224 |
* an implicit COLLECT operator. |
| 4225 |
*/ |
| 4226 |
C operationSourceType = source.getType(); |
| 4227 |
|
| 4228 |
// if the sourceType is a TypeType then this must be a static operation |
| 4229 |
boolean isStatic = operationSourceType instanceof TypeType<?, ?>; |
| 4230 |
|
| 4231 |
OperationCallExp<C, O> astNode = genOperationCallExp(env, operationCallExpCS, |
| 4232 |
"operationCallExpCS", operationName,//$NON-NLS-1$ |
| 4233 |
source, operationSourceType, args); |
| 4234 |
if (isStatic) { |
| 4235 |
@SuppressWarnings("unchecked") |
| 4236 |
TypeType<C, O> typeType = (TypeType<C, O>) operationSourceType; |
| 4237 |
O operation = astNode.getReferredOperation(); |
| 4238 |
|
| 4239 |
// operation must either be defined by the TypeType (e.g., |
| 4240 |
// allInstances()) |
| 4241 |
// or be a static operation of the referred classifier |
| 4242 |
if (!(typeType.oclOperations().contains(operation) || uml |
| 4243 |
.isStatic(operation))) { |
| 4244 |
|
| 4245 |
String message = OCLMessages.bind( |
| 4246 |
OCLMessages.NonStaticOperation_ERROR_, operationName); |
| 4247 |
ERROR(astNode, "operationCallExpCS", message);//$NON-NLS-1$ |
| 4248 |
} |
| 4249 |
} |
| 4250 |
|
| 4251 |
// astNode.setMarkedPre(isAtPre(operationCallExpCS)); |
| 4252 |
|
| 4253 |
initPropertyPositions(astNode, operationCallExpCS.getSimpleNameCS()); |
| 4254 |
|
| 4255 |
OCLExpression<C> result = astNode; |
| 4256 |
|
| 4257 |
if (isErrorNode(source)) { |
| 4258 |
// don't attempt to parse navigation from an unparseable source |
| 4259 |
markAsErrorNode(result); |
| 4260 |
} |
| 4261 |
|
| 4262 |
return result; |
| 4263 |
} |
| 4264 |
|
| 4265 |
/** |
| 4266 |
* @since 3.0 |
| 4267 |
*/ |
| 4268 |
protected List<OCLExpression<C>> argumentsCS(OperationCallExpCS operationCallExpCS, |
| 4269 |
Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env) { |
| 4270 |
List<OCLExpression<C>> args = new java.util.ArrayList<OCLExpression<C>>(); |
| 4271 |
for (OCLExpressionCS arg : operationCallExpCS.getArguments()) { |
| 4272 |
OCLExpression<C> argExpr = oclExpressionCS(arg, env); |
| 4273 |
if (argExpr == null) { |
| 4274 |
argExpr = createDummyInvalidLiteralExp(env, arg); |
| 4275 |
initASTMapping(env, argExpr, arg); |
| 4276 |
} |
| 4277 |
args.add(argExpr); |
| 4278 |
} |
| 4279 |
return args; |
| 4280 |
} |
| 4281 |
|
| 4282 |
/** |
| 4173 |
* MessageExpCS |
4283 |
* MessageExpCS |
| 4174 |
* |
4284 |
* |
| 4175 |
* @param messageExpCS |
4285 |
* @param messageExpCS |
|
Lines 4821-4830
Link Here
|
| 4821 |
/** |
4931 |
/** |
| 4822 |
* @since 3.0 |
4932 |
* @since 3.0 |
| 4823 |
*/ |
4933 |
*/ |
| 4824 |
public static EList<String> createSequenceOfNames(List<SimpleNameCS> simpleNames) { |
4934 |
public static EList<String> createSequenceOfNames(PathNameCS pathNameCS, SimpleNameCS simpleNameCS) { |
| 4825 |
EList<String> sequenceOfNames = new BasicEList<String>(); |
4935 |
EList<String> sequenceOfNames = new BasicEList<String>(); |
| 4826 |
for (SimpleNameCS simpleName : simpleNames) |
4936 |
if (pathNameCS != null) { |
| 4827 |
sequenceOfNames.add(simpleName.getValue()); |
4937 |
for (SimpleNameCS simpleName : pathNameCS.getSimpleNames()) |
|
|
4938 |
sequenceOfNames.add(simpleName.getValue()); |
| 4939 |
} |
| 4940 |
if (simpleNameCS != null) { |
| 4941 |
sequenceOfNames.add(simpleNameCS.getValue()); |
| 4942 |
} |
| 4828 |
return sequenceOfNames; |
4943 |
return sequenceOfNames; |
| 4829 |
} |
4944 |
} |
| 4830 |
|
4945 |
|