Search in sources :

Example 1 with ListOrMapLiteralItem

use of net.vtst.ow.eclipse.soy.soy.ListOrMapLiteralItem in project ow by vtst.

the class SoyJavaValidator method checkListOrMapLiteral.

// **************************************************************************
// Patches for the parser
/**
   * Check that all elements of a list-or-map are either list elements or map elements.
   */
@Check
@ConfigurableCheck(configurable = false)
public void checkListOrMapLiteral(ListOrMapLiteral listOrMap) {
    EList<ListOrMapLiteralItem> items = listOrMap.getItem();
    boolean isMap = false;
    int index = 0;
    for (ListOrMapLiteralItem item : items) {
        if (index == 0) {
            isMap = (item.getSecond() != null);
        } else {
            if ((item.getSecond() != null) != isMap) {
                error(messages.getString(isMap ? "map_becoming_list" : "list_becoming_map"), listOrMap, SoyPackage.Literals.LIST_OR_MAP_LITERAL__ITEM, index);
            }
        }
        ++index;
    }
}
Also used : ListOrMapLiteralItem(net.vtst.ow.eclipse.soy.soy.ListOrMapLiteralItem) ConfigurableCheck(net.vtst.eclipse.easyxtext.validation.config.ConfigurableCheck) Check(org.eclipse.xtext.validation.Check) ConfigurableCheck(net.vtst.eclipse.easyxtext.validation.config.ConfigurableCheck)

Aggregations

ConfigurableCheck (net.vtst.eclipse.easyxtext.validation.config.ConfigurableCheck)1 ListOrMapLiteralItem (net.vtst.ow.eclipse.soy.soy.ListOrMapLiteralItem)1 Check (org.eclipse.xtext.validation.Check)1