@Override
public boolean visit(Expression s) throws Exception {
if (s instanceof RutaRuleElement) {
RutaRuleElement re = (RutaRuleElement) s;
Expression head = re.getHead();
if (head != null) {
String type = currentFile.getSource().substring(head.sourceStart(), head.sourceEnd());
matchedType = type;
}
}
if (s instanceof RutaVariableReference) {
RutaVariableReference ref = (RutaVariableReference) s;
// filter AnnotationTypeReferences
if ((ref.getType() & RutaTypeConstants.RUTA_TYPE_AT) != 0) {
return false;
}
if (!isVariableDeclared(ref)) {
return false;
}
checkTypeOfReference(ref);
return false;
}
// check assign types
if (s instanceof RutaAction) {
RutaAction tma = (RutaAction) s;
String actionName = currentFile.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)) {
IProblem problem = problemFactory.createUnknownActionProblem(tma);
rep.reportProblem(problem);
}
IRutaExtension extension = actionExtensions.get(actionName);
if (extension != null) {
// boolean checkSyntax =
extension.checkSyntax(tma, problemFactory, rep);
}
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);
if (!featureFound) {
IProblem problem = problemFactory.createUnknownFeatureProblem(stringExpr, matchedType);
rep.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 = currentFile.getSource().substring(struct.sourceStart(), struct.sourceEnd());
}
Map<Expression, Expression> assignments = sa.getAssignments();
// hotfix... correct name in ast
String action = currentFile.getSource().substring(sa.getNameStart(), sa.getNameEnd());
if (assignments != null && !action.equals("TRIE")) {