docs: @SuppressWarnings("checkstyle:all")
  	protected StringConcatenationClient generateFieldsAndMethods(boolean forInterface, boolean forAppender) {
  		TypeReference scriptInterface = getCodeElementExtractor().getLanguageScriptInterface();
  		return new StringConcatenationClient() {
  			@Override
  			protected void appendTo(TargetStringConcatenation it) {
  				// Fields
  				if (!forInterface && !forAppender) {
  					it.append("\tprivate "); //$NON-NLS-1$
  					it.append(scriptInterface);
  					it.append(" script;"); //$NON-NLS-1$
  					it.newLineIfNotEmpty();
  					it.newLine();
  					it.append("\tprivate boolean isFinalized;"); //$NON-NLS-1$
  					it.newLineIfNotEmpty();
  					it.newLine();
  				} else if (forAppender) {
  					it.append("\tprivate "); //$NON-NLS-1$
  					it.append(getScriptBuilderInterface());
  					it.append(" builder;"); //$NON-NLS-1$
  					it.newLineIfNotEmpty();
  					it.newLine();
  				}
  				if (forInterface || forAppender) {
  					it.append("\t/** Find the reference to the type with the given name."); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t * @param typeName the fully qualified name of the type"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t * @return the type reference."); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t */"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t"); //$NON-NLS-1$
  					if (!forInterface) {
  						it.append("public "); //$NON-NLS-1$
  					}
  					it.append(JvmParameterizedTypeReference.class);
  					it.append(" newTypeRef(String typeName)"); //$NON-NLS-1$
  					if (forInterface) {
  						it.append(";"); //$NON-NLS-1$
  					} else {
  						it.append(" {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\treturn this.builder.newTypeRef(typeName);"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t}"); //$NON-NLS-1$
  					}
  					it.newLineIfNotEmpty();
  					it.newLine();
  					it.append("\t/** Find the reference to the type with the given name."); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t * @param context the context for the type reference use"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t * @param typeName the fully qualified name of the type"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t * @return the type reference."); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t */"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t"); //$NON-NLS-1$
  					if (!forInterface) {
  						it.append("public "); //$NON-NLS-1$
  					}
  					it.append(JvmParameterizedTypeReference.class);
  					it.append(" newTypeRef("); //$NON-NLS-1$
  					it.append(Notifier.class);
  					it.append(" context, String typeName)"); //$NON-NLS-1$
  					if (forInterface) {
  						it.append(";"); //$NON-NLS-1$
  					} else {
  						it.append(" {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\treturn this.builder.newTypeRef(context, typeName);"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t}"); //$NON-NLS-1$
  					}
  					it.newLineIfNotEmpty();
  					it.newLine();
  				}
  				if (forInterface) {
  					it.append("\t/** Replies the context for type resolution."); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t * @return the context or <code>null</code> if the Ecore object is the context."); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t */"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t"); //$NON-NLS-1$
  					it.append(IJvmTypeProvider.class);
  					it.append(" getTypeResolutionContext();"); //$NON-NLS-1$
  					it.newLineIfNotEmpty();
  					it.newLine();
  				} else if (forAppender) {
  					it.append("\tpublic "); //$NON-NLS-1$
  					it.append(IJvmTypeProvider.class);
  					it.append(" getTypeResolutionContext() {"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t\treturn this.builder.getTypeResolutionContext();"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t}"); //$NON-NLS-1$
  					it.newLineIfNotEmpty();
  					it.newLine();
  				}
  				if (forAppender) {
  					it.append("\tpublic "); //$NON-NLS-1$
  					it.append(getScriptAppender().getSimpleName());
  					it.append("("); //$NON-NLS-1$
  					it.append(getScriptBuilderInterface());
  					it.append(" builder) {"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t\tthis.builder = builder;"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t}"); //$NON-NLS-1$
  					it.newLineIfNotEmpty();
  					it.newLine();
  					it.append("\tpublic void build("); //$NON-NLS-1$
  					it.append(ISourceAppender.class);
  					it.append(" appender) throws "); //$NON-NLS-1$
  					it.append(IOException.class);
  					it.append(" {"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t\tif (!isFinalized()) {"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t\t\tfinalizeScript();"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t\t}"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t\tbuild(this.builder.getScript(), appender);"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t}"); //$NON-NLS-1$
  					it.newLineIfNotEmpty();
  					it.newLine();
  				}
  				it.append("\t/** Create the internal " + getLanguageName() + " script."); //$NON-NLS-1$ //$NON-NLS-2$
  				it.newLine();
  				it.append("\t */"); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t"); //$NON-NLS-1$
  				if (!forInterface) {
  					it.append("public "); //$NON-NLS-1$
  				}
  				it.append("void eInit("); //$NON-NLS-1$
  				it.append(Resource.class);
  				it.append(" resource, String packageName, "); //$NON-NLS-1$
  				it.append(IJvmTypeProvider.class);
  				it.append(" context)"); //$NON-NLS-1$
  				if (forInterface) {
  					it.append(";"); //$NON-NLS-1$
  				} else {
  					it.append(" {"); //$NON-NLS-1$
  					it.newLine();
  					if (forAppender) {
  						it.append("\t\tthis.builder.eInit(resource, packageName, context);"); //$NON-NLS-1$
  					} else {
  						it.append("\t\tsetTypeResolutionContext(context);"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\tif (this.script == null) {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\tthis.script = "); //$NON-NLS-1$
  						it.append(getXFactoryFor(scriptInterface));
  						it.append(".eINSTANCE.create"); //$NON-NLS-1$
  						it.append(Strings.toFirstUpper(scriptInterface.getSimpleName()));
  						it.append("();"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t"); //$NON-NLS-1$
  						it.append(EList.class);
  						it.append("<"); //$NON-NLS-1$
  						it.append(EObject.class);
  						it.append("> content = resource.getContents();"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\tif (!content.isEmpty()) {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t\tcontent.clear();"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t}"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\tcontent.add(this.script);"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\tif (!"); //$NON-NLS-1$
  						it.append(Strings.class);
  						it.append(".isEmpty(packageName)) {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t\tscript.setPackage(packageName);"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t}"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t}"); //$NON-NLS-1$
  					}
  					it.newLine();
  					it.append("\t}"); //$NON-NLS-1$
  				}
  				it.newLineIfNotEmpty();
  				it.newLine();
  				it.append("\t/** Replies the " + getLanguageName() + " script."); //$NON-NLS-1$ //$NON-NLS-2$
  				it.newLine();
  				it.append("\t */"); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t@"); //$NON-NLS-1$
  				it.append(Pure.class);
  				it.newLine();
  				it.append("\t"); //$NON-NLS-1$
  				if (!forInterface) {
  					it.append("public "); //$NON-NLS-1$
  				}
  				it.append(scriptInterface);
  				it.append(" getScript()"); //$NON-NLS-1$
  				if (forInterface) {
  					it.append(";"); //$NON-NLS-1$
  				} else {
  					it.append(" {"); //$NON-NLS-1$
  					it.newLine();
  					if (forAppender) {
  						it.append("\t\treturn this.builder.getScript();"); //$NON-NLS-1$
  					} else {
  						it.append("\t\treturn this.script;"); //$NON-NLS-1$
  					}
  					it.newLine();
  					it.append("\t}"); //$NON-NLS-1$
  				}
  				it.newLineIfNotEmpty();
  				it.newLine();
  				it.append("\t/** Replies the resource to which the script is attached."); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t */"); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t@"); //$NON-NLS-1$
  				it.append(Pure.class);
  				it.newLine();
  				it.append("\t"); //$NON-NLS-1$
  				if (!forInterface) {
  					it.append("public "); //$NON-NLS-1$
  				}
  				it.append(Resource.class);
  				it.append(" eResource()"); //$NON-NLS-1$
  				if (forInterface) {
  					it.append(";"); //$NON-NLS-1$
  				} else {
  					it.append(" {"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t\treturn getScript().eResource();"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t}"); //$NON-NLS-1$
  				}
  				it.newLineIfNotEmpty();
  				it.newLine();
  				it.append("\t/** Finalize the script."); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t *"); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t * <p>The finalization includes: <ul>"); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t * <li>The import section is created.</li>"); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t * </ul>"); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t */"); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t"); //$NON-NLS-1$
  				if (!forInterface) {
  					it.append("public "); //$NON-NLS-1$
  				}
  				it.append("void finalizeScript()"); //$NON-NLS-1$
  				if (forInterface) {
  					it.append(";"); //$NON-NLS-1$
  				} else {
  					it.append(" {"); //$NON-NLS-1$
  					it.newLine();
  					if (forAppender) {
  						it.append("\t\tthis.builder.finalizeScript();"); //$NON-NLS-1$
  					} else {
  						it.append("\t\tif (this.isFinalized) {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\tthrow new "); //$NON-NLS-1$
  						it.append(IllegalStateException.class);
  						it.append("(\"already finalized\");"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t}"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\tthis.isFinalized = true;"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t"); //$NON-NLS-1$
  						it.append(ImportManager.class);
  						it.append(" concreteImports = new "); //$NON-NLS-1$
  						it.append(ImportManager.class);
  						it.append("(true);"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t"); //$NON-NLS-1$
  						it.append(XImportSection.class);
  						it.append(" importSection = getScript().getImportSection();"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\tif (importSection != null) {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\tfor ("); //$NON-NLS-1$
  						it.append(XImportDeclaration.class);
  						it.append(" decl : importSection.getImportDeclarations()) {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t\tconcreteImports.addImportFor(decl.getImportedType());"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t}"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t}"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\tfor (String importName : getImportManager().getImports()) {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t"); //$NON-NLS-1$
  						it.append(JvmType.class);
  						it.append(" type = findType(getScript(), importName).getType();"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\tif (concreteImports.addImportFor(type) && type instanceof "); //$NON-NLS-1$
  						it.append(JvmDeclaredType.class);
  						it.append(") {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t\t"); //$NON-NLS-1$
  						it.append(XImportDeclaration.class);
  						it.append(" declaration = "); //$NON-NLS-1$
  						it.append(XtypeFactory.class);
  						it.append(".eINSTANCE.createXImportDeclaration();"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t\tdeclaration.setImportedType(("); //$NON-NLS-1$
  						it.append(JvmDeclaredType.class);
  						it.append(") type);"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t\tif (importSection == null) {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t\t\timportSection = "); //$NON-NLS-1$
  						it.append(XtypeFactory.class);
  						it.append(".eINSTANCE.createXImportSection();"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t\t\tgetScript().setImportSection(importSection);"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t\t}"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t\timportSection.getImportDeclarations().add(declaration);"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t}"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t}"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t"); //$NON-NLS-1$
  						it.append(Resource.class);
  						it.append(" resource = getScript().eResource();"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\tif (resource instanceof "); //$NON-NLS-1$
  						it.append(DerivedStateAwareResource.class);
  						it.append(") {"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t\t(("); //$NON-NLS-1$
  						it.append(DerivedStateAwareResource.class);
  						it.append(") resource).discardDerivedState();"); //$NON-NLS-1$
  						it.newLine();
  						it.append("\t\t}"); //$NON-NLS-1$
  					}
  					it.newLine();
  					it.append("\t}"); //$NON-NLS-1$
  				}
  				it.newLineIfNotEmpty();
  				it.newLine();
  				it.append("\t/** Replies if the script was finalized."); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t */"); //$NON-NLS-1$
  				it.newLine();
  				it.append("\t"); //$NON-NLS-1$
  				if (!forInterface) {
  					it.append("public "); //$NON-NLS-1$
  				}
  				it.append("boolean isFinalized()"); //$NON-NLS-1$
  				if (forInterface) {
  					it.append(";"); //$NON-NLS-1$
  				} else {
  					it.append(" {"); //$NON-NLS-1$
  					it.newLine();
  					if (forAppender) {
  						it.append("\t\treturn this.builder.isFinalized();"); //$NON-NLS-1$
  					} else {
  						it.append("\t\treturn this.isFinalized;"); //$NON-NLS-1$
  					}
  					it.newLine();
  					it.append("\t}"); //$NON-NLS-1$
  				}
  				it.newLineIfNotEmpty();
  				it.newLine();
  				if (!forInterface) {
  					it.append("\t@"); //$NON-NLS-1$
  					it.append(Override.class);
  					it.newLine();
  					it.append("\t@"); //$NON-NLS-1$
  					it.append(Pure.class);
  					it.newLine();
  					it.append("\tpublic "); //$NON-NLS-1$
  					it.append(String.class);
  					it.append(" toString() {"); //$NON-NLS-1$
  					it.newLine();
  					it.append("\t\treturn "); //$NON-NLS-1$
  					if (forAppender) {
  						it.append("this.builder.toString();"); //$NON-NLS-1$
  					} else {
  						it.append(EmfFormatter.class);
  						it.append(".objToStr(this.script);"); //$NON-NLS-1$
  					}
  					it.newLine();
  					it.append("\t}"); //$NON-NLS-1$
  					it.newLineIfNotEmpty();
  					it.newLine();
  				}
  			}
  		};
  	}