/** * Creates a string representation for the given RenderableBlock that is disambiguated from string * representations for blocks with the same label by appending socket information to the end of * the block's label. The created string is in the form: BlockLabel [socketLabel1, ..., * socketLabelN] * * @param block the FactoryRenderableBlock to create a string representation of * @return a String containing the given block's keyword with a list of its socket labels appended * to the end. */ public static String disambiguousStringRep(RenderableBlock block) { String rep = block.getKeyword(); String genus = block.getGenus(); Iterator<BlockConnector> sockets = block.getBlock().getSockets().iterator(); if (sockets.hasNext()) { String socketLabels = " ["; while (sockets.hasNext()) { if (socketLabels.length() > 2) { socketLabels += ", "; } socketLabels += sockets.next().getLabel(); } socketLabels += "]"; // HACK!!! TODO: rewriting typeblocking if (genus.equals("sum")) { return rep + " [number]"; } else if (genus.equals("string-append")) { return rep + " [text]"; } return rep + socketLabels; } return rep; }