String actionName = sourceModule.getSource().substring(tma.getNameStart(), tma.getNameEnd());
String[] keywords = RutaKeywordsManager.getKeywords(IRutaKeywords.ACTION);
List<String> asList = Arrays.asList(keywords);
if (!StringUtils.isEmpty(actionName) && !"-".equals(actionName)
&& !asList.contains(actionName) && !implicitString.equals(tma.getName())) {
IProblem problem = problemFactory.createUnknownActionProblem(tma);
pr.reportProblem(problem);
}
IRutaExtension extension = actionExtensions.get(actionName);
if (extension != null) {
extension.checkSyntax(tma, problemFactory, pr);
}
if (tma.getName().equals("GETFEATURE") || tma.getName().equals("SETFEATURE")) {
List<?> childs = tma.getChilds();
RutaStringExpression stringExpr = (RutaStringExpression) childs.get(0);
String feat = stringExpr.toString();
feat = getFeatureName(stringExpr, feat);
boolean featureFound = findFeature(matchedType, feat, -1);
if (!featureFound) {
IProblem problem = problemFactory.createUnknownFeatureProblem(stringExpr, matchedType);
pr.reportProblem(problem);
}
}
if (tma.getKind() == RutaActionConstants.A_ASSIGN) {
List<?> childs = tma.getChilds();
try {
RutaVariableReference ref = (RutaVariableReference) childs.get(0);
RutaExpression expr = (RutaExpression) childs.get(1);
int type = expr.getKind();
if (ref.getType() == RutaTypeConstants.RUTA_TYPE_G) {
ref.setType(type);
}
} catch (IndexOutOfBoundsException e) {
// exception should have been recognized and reported in
// parser
return false;
} catch (ClassCastException e) {
// exception should have been recognized and reported in
// parser
return false;
}
}
if (s instanceof RutaStructureAction) {
RutaStructureAction sa = (RutaStructureAction) s;
Expression struct = sa.getStructure();
String structure = null;
if (struct != null) {
structure = sourceModule.getSource().substring(struct.sourceStart(), struct.sourceEnd());
structure = expand(structure);
}
Map<Expression, Expression> assignments = sa.getAssignments();
// hotfix... correct name in ast
String action = sourceModule.getSource().substring(sa.getNameStart(), sa.getNameEnd());
if (assignments != null && !action.equals("TRIE")) {
for (Expression each : assignments.keySet()) {
// TODO refactor to visitor?
String feat = each.toString();
// List<?> childs = each.getChilds();
feat = getFeatureName(each, feat);
boolean featureFound = findFeature(structure, feat, -1);
if (!featureFound) {
IProblem problem = problemFactory.createUnknownFeatureProblem(each, structure);
pr.reportProblem(problem);
}
}
}
}
}
if (s instanceof RutaCondition) {
RutaCondition cond = (RutaCondition) s;
String conditionName = sourceModule.getSource().substring(cond.getNameStart(),
cond.getNameEnd());
String[] keywords = RutaKeywordsManager.getKeywords(IRutaKeywords.CONDITION);
List<String> asList = Arrays.asList(keywords);
if (!StringUtils.isEmpty(conditionName) && !"-".equals(conditionName)
&& !asList.contains(conditionName) && !implicitString.equals(cond.getName())) {
IProblem problem = problemFactory.createUnknownConditionProblem(cond);
pr.reportProblem(problem);
}
IRutaExtension extension = conditionExtensions.get(conditionName);
if (extension != null) {
// boolean checkSyntax =
extension.checkSyntax(cond, problemFactory, pr);
}
if (conditionName.equals("FEATURE")) {
if (matchedType != null) {
List<?> args = cond.getChilds();
RutaStringExpression se = (RutaStringExpression) args.get(0);
String feat = se.toString();
feat = getFeatureName(se, feat);
boolean featureFound = findFeature(matchedType, feat, -1);
if (!featureFound) {
String featureMatch = isFeatureMatch(matchedType);
if (featureMatch != null) {
featureFound = findFeature(featureMatch, feat, -1);
}
}
if (!featureFound) {
IProblem problem = problemFactory.createUnknownFeatureProblem(se, matchedType);
pr.reportProblem(problem);
}
}
}
}