Element (TextWithImports text) { Element element = new Element("TextWithImports"); element.setAttribute("text", text.toExternalForm()); element.setAttribute("type", text.getKind() == CodeFragmentKind.EXPRESSION ? "expression" : "code fragment"); return element; }