/** * Creates a <code>toString()</code> method accumulating the values of all fields. * * @return a result representing a Java toString() method, <code>null</code> if sourceElement or declaredType are <code>null</code>. */ /* @Nullable */ public JvmOperation toToStringMethod(/* @Nullable */ final EObject sourceElement, /* @Nullable */ final JvmDeclaredType declaredType) { if(sourceElement == null || declaredType == null) return null; JvmOperation result = toMethod(sourceElement, "toString", newTypeRef(sourceElement, String.class), null); if (result == null) return null; JvmType overrideType = references.findDeclaredType(Override.class, sourceElement); if (overrideType != null) result.getAnnotations().add(toAnnotation(sourceElement, Override.class)); setBody(result, new Procedure1<ITreeAppendable>() { @Override public void apply(/* @Nullable */ ITreeAppendable p) { if (p == null) return; p.append("String result = new "); p.append(ToStringBuilder.class); p.append("(this).addAllFields().toString();"); p.newLine().append("return result;"); } }); return result; }
@Test public void testExplicitFieldListing() { ToStringHelperTest.MyEntity _myEntity = new ToStringHelperTest.MyEntity(); final ToStringBuilder helper = new ToStringBuilder(_myEntity).add("boolProp", Boolean.valueOf(false)).addField("intProp"); StringConcatenation _builder = new StringConcatenation(); _builder.append("MyEntity ["); _builder.newLine(); _builder.append(" "); _builder.append("boolProp = false"); _builder.newLine(); _builder.append(" "); _builder.append("intProp = 42"); _builder.newLine(); _builder.append("]"); Assert.assertEquals( ToStringHelperTest.toUnix(_builder.toString()), helper.toString()); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("label", this.label); b.add("kind", this.kind); b.add("detail", this.detail); b.add("documentation", this.documentation); b.add("sortText", this.sortText); b.add("filterText", this.filterText); b.add("insertText", this.insertText); b.add("insertTextFormat", this.insertTextFormat); b.add("textEdit", this.textEdit); b.add("additionalTextEdits", this.additionalTextEdits); b.add("command", this.command); b.add("data", this.data); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.skipNulls(); b.add("prefix", this.prefix); b.add("proposal", this.proposal); b.add("label", this.label); b.add("description", this.description); b.add("documentation", this.documentation); b.add("escapePosition", this.escapePosition); b.add("textReplacements", this.textReplacements); b.add("editPositions", this.editPositions); b.add("kind", this.kind); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("registrations", this.registrations); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("filters", this.filters); b.add("exceptionOptions", this.exceptionOptions); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("typeReference", this.typeReference); b.add("variance", this.variance); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("frameId", this.frameId); b.add("text", this.text); b.add("column", this.column); b.add("line", this.line); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("title", this.title); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("triggerCharacters", this.triggerCharacters); b.add("resolveProvider", this.resolveProvider); b.add("documentSelector", getDocumentSelector()); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("type", this.type); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("rawValue", this.rawValue); b.add("compileTimeConstant", this.compileTimeConstant); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("dynamicRegistration", getDynamicRegistration()); return b.toString(); }
@Override @Pure public String toString() { String result = new ToStringBuilder(this) .addAllFields() .toString(); return result; }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("textDocument", this.textDocument); b.add("reason", this.reason); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("triggerCharacters", this.triggerCharacters); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("id", this.id); b.add("verified", this.verified); b.add("message", this.message); b.add("source", this.source); b.add("line", this.line); b.add("column", this.column); b.add("endLine", this.endLine); b.add("endColumn", this.endColumn); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("offset", this.offset); b.add("leafs", this.leafs); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("reason", this.reason); b.add("module", this.module); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("algorithm", this.algorithm); b.add("checksum", this.checksum); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("offset", this.offset); b.add("length", this.length); b.add("increaseIndentationChange", this.increaseIndentationChange); b.add("decreaseIndentationChange", this.decreaseIndentationChange); b.add("trace", this.trace); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("container", this.container); b.add("node", this.node); b.add("newLines", this.newLines); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("signatures", this.signatures); b.add("activeSignature", this.activeSignature); b.add("activeParameter", this.activeParameter); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("type", this.type); b.add("message", this.message); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("range", this.range); b.add("rangeLength", this.rangeLength); b.add("text", this.text); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("workspace", this.workspace); b.add("textDocument", this.textDocument); b.add("experimental", this.experimental); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("ePackage", this.ePackage); b.add("ePackageImportURI", this.ePackageImportURI); b.add("genmodelURI", this.genmodelURI); b.add("ePackageJavaFQN", this.ePackageJavaFQN); b.add("bundleID", this.bundleID); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("name", this.name); b.add("dependencies", this.dependencies); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("imageIDs", this.imageIDs); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("breakpoints", this.breakpoints); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("edit", this.edit); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("label", this.label); b.add("text", this.text); b.add("type", this.type); b.add("start", this.start); b.add("length", this.length); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("line", this.line); b.add("character", this.character); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("event", this.event); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("documentSelector", this.documentSelector); return b.toString(); }
@Override @Pure public String toString() { ToStringBuilder b = new ToStringBuilder(this); b.add("completionItem", this.completionItem); b.add("dynamicRegistration", getDynamicRegistration()); return b.toString(); }