/** * Asserts that each top-level variable has associative (or not) {@link DartBinaryExpression} * value. */ private void assert_isAssociative(boolean expected) throws DartModelException { DartUnit unit = DartCompilerUtilities.resolveUnit(testUnit); for (DartNode topLevelNode : unit.getTopLevelNodes()) { if (topLevelNode instanceof DartFieldDefinition) { DartFieldDefinition fieldDefinition = (DartFieldDefinition) topLevelNode; List<DartField> fields = fieldDefinition.getFields(); if (fields.size() == 1) { DartBinaryExpression expression = (DartBinaryExpression) fields.get(0).getValue(); assertEquals(expected, ExtractUtils.isAssociative(expression)); } } } }
/** @return the {@link DartExpression} of top-level variable "x" in the given source. */ private DartExpression getMarkerVariableExpression(String... lines) throws Exception { setTestUnitContent(lines); DartUnit unit = DartCompilerUtilities.resolveUnit(testUnit); for (DartNode topLevelNode : unit.getTopLevelNodes()) { if (topLevelNode instanceof DartFieldDefinition) { DartFieldDefinition fieldDefinition = (DartFieldDefinition) topLevelNode; List<DartField> fields = fieldDefinition.getFields(); if (fields.size() == 1 && fields.get(0).getName().getName().equals("x")) { return fields.get(0).getValue(); } } } fail("Field 'x' not found"); return null; }