Example #1
0
  /** 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();
    }
  }
Example #2
0
  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;
  }
Example #3
0
  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);
  }