/** add style into unit-wide list */ private void registerStyle(Context context, MetaDataNode metaDataNode, String name, MetaData md) { try { unit.styles.addStyle(name, md, unit.getSource()); } catch (StyleConflictException e) { context.localizedWarning2(metaDataNode.pos(), e); if (Trace.error) e.printStackTrace(); } }
public Value evaluate(Context context, MetaDataNode node) { if ("Style".equals(node.getId())) { if (NodeMagic.isClassDefinition(node)) { processStyle(context, node); } else { context.localizedError2(node.pos(), new StyleMustAnnotateAClass()); } } return null; }
private void processStyle(Context context, MetaDataNode metaDataNode) { MetaData metaData = new MetaData(metaDataNode); String styleName = metaData.getValue("name"); String typeName = metaData.getValue("type"); if (styleName == null) { // preilly: we should report this earlier in the process. context.localizedError2(metaDataNode.pos(), new StyleHasMissingName()); } if (typeName != null) { unit.expressions.add(NameFormatter.toMultiName(typeName)); } registerStyle(context, metaDataNode, styleName, metaData); }