Returns an excerpt of the {@link javax.annotation.Generated} annotation, if available,
with value set to the full name of the {@code generator} class as recommended.
484038
public static Excerpt generated(Class<?> generator) {
    return code -> {
      code.feature(JavaxPackage.JAVAX).generated().ifPresent(generated -> {
        code.addLine("@%s(\"%s\")", generated, generator.getName());
      });
    };
  }
947706
protected GeneratorConfig createDefaultGeneratorConfig() {
		final GeneratorConfig config = new GeneratorConfig();
		if (this.defaultVersion == null) {
			this.defaultVersion = JavaVersion.fromQualifier(System.getProperty("java.specification.version")); //$NON-NLS-1$
			if (this.defaultVersion != null) {
				config.setJavaSourceVersion(this.defaultVersion);
			}
		} else {
			config.setJavaSourceVersion(this.defaultVersion);
		}
		return config;
	}
134916
protected void createGenModelAnnotations()
	{
		String source = "http://www.eclipse.org/emf/2002/GenModel";	
		addAnnotation
		  (jvmIdentifiableElementEClass.getEOperations().get(0), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>The identifier of a JvmIdentifiableElement is a canonical representation of the element.</p>\n<p>A type will return its fully qualified name as its identifier with a \'$\' delimiter for inner classes. \nThe identifier of an executables contains the identifiers of their respective parameter types. They do\nnot contain any information about type parameters.</p>\n<p>Examples for identifiers are:</p>\n<ul>\n<li>java.lang.String for a class</li>\n<li>java.util.Map$Entry for an inner class</li>\n<li>java.lang.String.String() for a constructor (note the repeated simple name)</li>\n<li>java.lang.String.charAt(int) for a method</li>\n<li>java.lang.String.offset for a field</li>\n<li>java.lang.Object[][] for an array type</li>\n</ul>"
		   });	
		addAnnotation
		  (jvmIdentifiableElementEClass.getEOperations().get(1), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>The simple name of a JvmIdentifiableElement is short representation of the element.</p>\n<p>The simple name does not contain any information about type parameters.</p>\n<p>Examples for simple names are:</p>\n<ul>\n<li>String for class java.lang.String</li>\n<li>Entry for class java.util.Map$Entry</li>\n<li>charAt for method java.lang.String.charAt(int)</li>\n<li>String for constructor java.lang.String.String(java.lang.String)</li>\n</ul>"
		   });	
		addAnnotation
		  (jvmIdentifiableElementEClass.getEOperations().get(2), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>The qualified name of a JvmIdentifiableElement is a textual representation of the element.</p>\n<p>The default delimiter character is the \'$\'.</p>\n@see #getQualifiedName(char)"
		   });	
		addAnnotation
		  (jvmIdentifiableElementEClass.getEOperations().get(3), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>The qualified name of a JvmIdentifiableElement is a textual representation of the element.</p>\n<p>The name does not contain any information about type parameters. Inner classes are delimited by means of \nthe given \'innerClassDelimiter\'</p>\n<p>Examples for qualified names with a \'$\' delimiter are:</p>\n<ul>\n<li>java.lang.String for class java.lang.String</li>\n<li>java.util.Map$Entry for class java.util.Map$Entry</li>\n<li>java.lang.String.charAt for method java.lang.String.charAt(int)</li>\n<li>java.lang.String.offset for field java.lang.String.offset</li>\n<li>java.lang.String for a constructor that is identified by java.lang.String.String(java.lang.String)</li>\n</ul>"
		   });	
		addAnnotation
		  (jvmDeclaredTypeEClass.getEOperations().get(2), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>Returns all the fields and operations with the given simple name.</p>\n<p>Inherited features will be returend, but overridden features are not contained in the result.</p>"
		   });	
		addAnnotation
		  (jvmDeclaredTypeEClass.getEOperations().get(3), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>Returns all the fields and operations of this type.</p>\n<p>Inherited features are included, but overridden features will not be returned.</p>"
		   });	
		addAnnotation
		  (jvmDeclaredTypeEClass.getEOperations().get(7), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>Returns all the nested types with the given simple name.</p>\n<p>Inherited types will be returned, too.</p>"
		   });	
		addAnnotation
		  (jvmDeclaredTypeEClass.getEOperations().get(10), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>Returns all the nested types of this type.</p>\n<p>Inherited types will also be returned.</p>"
		   });	
		addAnnotation
		  (jvmTypeConstraintEClass.getEOperations().get(0), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>The identifier of a JvmTypeConstraint is a canonical representation of the constraint information.</p>\n<p>Examples for constraint identifiers are:</p>\n<ul>\n<li>extends java.util.List<java.lang.Map$Entry<java.lang.Object,java.lang.Object>></li>\n<li>super java.lang.Object</li>\n</ul>"
		   });	
		addAnnotation
		  (jvmTypeReferenceEClass.getEOperations().get(1), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>The identifier of a JvmTypeReference is a canonical representation of the referenced type \nincluding its type arguments.</p>\n<p>The types fully qualified name is used (\'$\' is the delimiter for inner types).</p>\n<p>Examples for reference identifiers are:</p>\n<ul>\n<li>java.lang.String for a reference to an object type</li>\n<li>java.util.Map$Entry<java.lang.Object,java.lang.Integer> for a parameterized type</li>\n<li>java.util.List<? extends java.lang.String>[] for a generic array type</li>\n</ul>"
		   });	
		addAnnotation
		  (jvmFeatureEClass.getEOperations().get(0), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>Returns <code>true</code> if the feature is a static field or static operation.</p>\n\n@since 2.4"
		   });	
		addAnnotation
		  (getJvmOperation_DefaultValue(), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>Returns the default value for the annotation member represented by this JvmOperation instance.</p>\n<p>Returns null if no default is associated with the member, or if the operation does not represent a declared member of an annotation type.</p>"
		   });	
		addAnnotation
		  (jvmAnnotationReferenceEClass.getEOperations().get(0), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>Returns all annotation values. That is, default values are not included if not explicitely given.</p>"
		   });	
		addAnnotation
		  (getJvmAnnotationReference_ExplicitValues(), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>Returns the explicit annotation values. That is, default values are not expected to be contained in that list.</p>\n<p>Important note: Some implementations don\'t have enough information about default values on annotations.\nThey may choose to consider all available values as explicit values.</p>"
		   });	
		addAnnotation
		  (jvmAnnotationValueEClass, 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>Represents the value of an annotation member.</p>\n<p>That is, either the default value of an operation as a member of an annotation type, or the \nconcrete value in an annotation reference is returned.</p>"
		   });	
		addAnnotation
		  (getJvmUnknownTypeReference_QualifiedName(), 
		   source, 
		   new String[] 
		   {
			 "documentation", "<p>Returns the known qualified name of the otherwise unresolveable type. May be <code>null</code>.</p>\n\n@since 2.4"
		   });
	}
1276792
protected SibRaStringGenerator getStringGenerator() {

        final SibRaStringGenerator generator = super.getStringGenerator();
        // The sync here is probably unnecessary (in that a dirty value would probably
        // be accepable), but I'd like to allow findbugs to spot other inconsistent usages
        synchronized(this) {

          generator.addField("remoteConnection", _remoteConnection);

        }
        generator.addField("remoteDestination", _remoteDestination);
        generator.addField("timer", _timer);
        return generator;

    }
1344608
public static Class<? extends IDAOGeneratorManager<? extends Annotation>> getGenerationLogicClass(Annotation annotation) {
		
		// Si l'annotation est nulle
		if(annotation == null) {
			
			// On retourne null
			return null;
		}
		
		// Recherche dans la MAP
		Class<? extends IDAOGeneratorManager<? extends Annotation>> mappedLogicClass = mGeneratorMapping.get(annotation.annotationType().getName());
		
		// Si la Classe est non nulle
		if(mappedLogicClass != null) return mappedLogicClass;
		
		// Obtention de l'annotation DAO
		DAOGeneratorManager logicAnnotation = annotation.annotationType().getAnnotation(DAOGeneratorManager.class);
		
		// On retourne cette annotation
		return logicAnnotation.managerClass();
	}
854375
public static String generatedNameOf(Class<?> clazz, Annotation annotation)
    {
        return builder(clazz, annotation).build();
    }
742902
private Content getInheritedTagletOutput(boolean isParameters, Element holder,
            TagletWriter writer, List<? extends Element> formalParameters,
            Set<String> alreadyDocumented) {
        Utils utils = writer.configuration().utils;
        Content result = writer.getOutputInstance();
        if ((!alreadyDocumented.contains(null)) && utils.isExecutableElement(holder)) {
            for (int i = 0; i < formalParameters.size(); i++) {
                if (alreadyDocumented.contains(String.valueOf(i))) {
                    continue;
                }
                // This parameter does not have any @param documentation.
                // Try to inherit it.
                Input input = new DocFinder.Input(writer.configuration().utils, holder, this,
                        Integer.toString(i), !isParameters);
                DocFinder.Output inheritedDoc = DocFinder.search(writer.configuration(), input);
                if (inheritedDoc.inlineTags != null && !inheritedDoc.inlineTags.isEmpty()) {
                    Element e = formalParameters.get(i);
                    String lname = isParameters
                            ? utils.getSimpleName(e)
                            : utils.getTypeName(e.asType(), false);
                    CommentHelper ch = utils.getCommentHelper(holder);
                    ch.setOverrideElement(inheritedDoc.holder);
                    Content content = processParamTag(holder, isParameters, writer,
                            inheritedDoc.holderTag,
                            lname,
                            alreadyDocumented.isEmpty());
                    result.addContent(content);
                }
                alreadyDocumented.add(String.valueOf(i));
            }
        }
        return result;
    }
1225738
public IGeneratorSet getGenerators() {
    if( generatorSet_ == null && generatorSetRef_ != null)
      {
      try( GeneratorSetResource resource = GeneratorSetResource.at( urlFor( generatorSetRef_)))
        {
        generatorSet_ = resource.getGeneratorSet();
        }
      catch( Exception e)
        {
        throw new GeneratorSetException( String.format( "Can't read resource at %s", generatorSetRef_), e);
        }
      }
    return generatorSet_;
    }
637022
private GeneratorMain loadXMLSpecification() {
    try {
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
      URL url = ClassLoader.getSystemResource(GENERATOR_SCHEMA_FILE);
      if(url != null) {
        try {
          Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(url);
          dbf.setSchema(schema);
          dbf.setIgnoringElementContentWhitespace(true);
        }
        catch(Exception e) {
          LOG.warning("Could not set up XML Schema validation for specification file.", e);
        }
      }
      else {
        LOG.warning("Could not set up XML Schema validation for specification file.");
      }
      Document doc = dbf.newDocumentBuilder().parse(specfile);
      Node root = doc.getDocumentElement();
      if(TAG_DATASET.equals(root.getNodeName())) {
        GeneratorMain gen = new GeneratorMain();
        processElementDataset(gen, root);
        return gen;
      }
      else {
        throw new AbortException("Experiment specification has incorrect document element: " + root.getNodeName());
      }
    }
    catch(FileNotFoundException e) {
      throw new AbortException("Can't open specification file.", e);
    }
    catch(SAXException e) {
      throw new AbortException("Error parsing specification file.", e);
    }
    catch(IOException e) {
      throw new AbortException("IO Exception loading specification file.", e);
    }
    catch(ParserConfigurationException e) {
      throw new AbortException("Parser Configuration Error", e);
    }
  }
777973
protected void generateElementSourceAppender() {
		final List<TopElementDescription> topElements = generateTopElements(false, true);
		for (final TopElementDescription element : topElements) {
			final TypeReference appender = element.getElementDescription().getAppenderType();
			final StringConcatenationClient content = new StringConcatenationClient() {
				@Override
				protected void appendTo(TargetStringConcatenation it) {
					it.append("/** Source adapter of a " + getLanguageName() //$NON-NLS-1$
							+ " " + element.getElementDescription().getElementType().getSimpleName() //$NON-NLS-1$
							+ "."); //$NON-NLS-1$
					it.newLine();
					it.append(" */"); //$NON-NLS-1$
					it.newLine();
					it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
					it.newLine();
					it.append("public class "); //$NON-NLS-1$
					it.append(appender.getSimpleName());
					it.append(" extends "); //$NON-NLS-1$
					it.append(getCodeElementExtractor().getAbstractAppenderImpl());
					it.append(" implements "); //$NON-NLS-1$
					it.append(element.getElementDescription().getBuilderInterfaceType());
					it.append(" {"); //$NON-NLS-1$
					it.newLineIfNotEmpty();
					it.newLine();
					it.append(generateAppenderMembers(appender.getSimpleName(),
							element.getElementDescription().getBuilderInterfaceType(),
							getGeneratedTypeAccessor(element.getElementDescription().getElementType())));
					it.append(element.getContent());
					for (final StringConcatenationClient cons : generateMembers(element.getConstructors(), element,
							false, true, true)) {
						it.append(cons);
					}
					for (final StringConcatenationClient mbr : generateMembers(element.getNamedMembers(), element,
							false, true, true)) {
						it.append(mbr);
					}
					for (final StringConcatenationClient mbr : generateMembers(element.getUnnamedMembers(), element,
							false, true, false)) {
						it.append(mbr);
					}
					it.append("}"); //$NON-NLS-1$
					it.newLineIfNotEmpty();
					it.newLine();
				}
			};
			final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(appender, content);
			javaFile.writeTo(getSrcGen());
		}
	}
485578
public String generate (String fsection, String msection)
        throws IOException
    {
        StringWriter writer = new StringWriter();
        BufferedWriter bout = new BufferedWriter(writer);
        addOrRemoveGeneratedImport(StringUtil.deNull(fsection).contains("@Generated(") ||
            StringUtil.deNull(msection).contains("@Generated("));

        // write the preamble
        for (int ii = 0; ii < _nstart; ii++) {
            writeln(bout, _lines.get(ii));
        }

        // write the field section
        if (!StringUtil.isBlank(fsection)) {
            String prev = safeGetLine(_nstart-1);
            if (!StringUtil.isBlank(prev) && !prev.equals("{")) {
                bout.newLine();
            }
            writeln(bout, "    " + FIELDS_START);
            bout.write(fsection);
            writeln(bout, "    " + FIELDS_END);
            if (!StringUtil.isBlank(safeGetLine(_nend))) {
                bout.newLine();
            }
        }

        // write the mid-amble
        for (int ii = _nend; ii < _mstart; ii++) {
            writeln(bout, _lines.get(ii));
        }

        // write the method section
        if (!StringUtil.isBlank(msection)) {
            if (!StringUtil.isBlank(safeGetLine(_mstart-1))) {
                bout.newLine();
            }
            writeln(bout, "    " + METHODS_START);
            bout.write(msection);
            writeln(bout, "    " + METHODS_END);
            String next = safeGetLine(_mend);
            if (!StringUtil.isBlank(next) && !next.equals("}")) {
                bout.newLine();
            }
        }

        // write the postamble
        for (int ii = _mend, nn = _lines.size(); ii < nn; ii++) {
            writeln(bout, _lines.get(ii));
        }
        bout.close();
        return writer.toString();
    }
401882
private static PropertySourceGenerator getSourceGenerator(final ErrorBuffer errorBuffer, final String className, final PropertyDefinition propertyDefinition) throws FrameworkException {

		final String propertyName                                  = propertyDefinition.getPropertyName();
		final Type propertyType                                    = propertyDefinition.getPropertyType();
		final Class<? extends PropertySourceGenerator> parserClass = parserMap.get(propertyType);

		try {

			return parserClass.getConstructor(ErrorBuffer.class, String.class, PropertyDefinition.class).newInstance(errorBuffer, className, propertyDefinition);

		} catch (Throwable t) {
			logger.warn("", t);
		}

		errorBuffer.add(new InvalidPropertySchemaToken(SchemaProperty.class.getSimpleName(), propertyName, propertyName, "invalid_property_definition", "Unknow value type " + source + ", options are " + Arrays.asList(Type.values()) + "."));
		throw new FrameworkException(422, "Invalid property definition for property " + propertyDefinition.getPropertyName(), errorBuffer);
	}
1310964
public Annotation getAnnotation(final Class<? extends Annotation> clazz) {
        final List<Annotation> found = foundAnnotations.get(clazz);
        return found == null || found.isEmpty() ? null : found.get(found.size() - 1);
    }
834703
protected void generateIElementBuilder() {
		final List<TopElementDescription> topElements = generateTopElements(true, false);
		for (final TopElementDescription element : topElements) {
			final StringConcatenationClient content = new StringConcatenationClient() {
				@Override
				protected void appendTo(TargetStringConcatenation it) {
					it.append("/** Builder of a " + getLanguageName() //$NON-NLS-1$
							+ " " + element.getElementDescription().getElementType().getSimpleName() //$NON-NLS-1$
							+ "."); //$NON-NLS-1$
					it.newLine();
					it.append(" */"); //$NON-NLS-1$
					it.newLine();
					it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
					it.newLine();
					it.append("public interface "); //$NON-NLS-1$
					it.append(element.getElementDescription().getBuilderInterfaceType().getSimpleName());
					it.append(" {"); //$NON-NLS-1$
					it.newLineIfNotEmpty();
					it.newLine();
					it.append(element.getContent());
					for (final StringConcatenationClient cons : generateMembers(element.getConstructors(),
							element, true, false, true)) {
						it.append(cons);
					}
					for (final StringConcatenationClient mbr : generateMembers(element.getNamedMembers(),
							element, true, false, true)) {
						it.append(mbr);
					}
					for (final StringConcatenationClient mbr : generateMembers(element.getUnnamedMembers(),
							element, true, false, false)) {
						it.append(mbr);
					}
					it.append("}"); //$NON-NLS-1$
					it.newLineIfNotEmpty();
					it.newLine();
				}
			};
			final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(
					element.getElementDescription().getBuilderInterfaceType(), content);
			javaFile.writeTo(getSrcGen());
		}
	}
302884
public Iterator
generators() {
	if (generators != null)
		return Collections.unmodifiableList(generators).iterator();
	else
		return Collections.EMPTY_LIST.iterator();
}
740882
public SourceSnippet getCreationStatements(NameGenerator nameGenerator,
      List<InjectorMethod> methodsOutput) throws NoSourceNameException {
    String moduleSourceName = ReflectUtil.getSourceName(moduleType);
    String createModule = "new " + moduleSourceName + "()";
    String type = ReflectUtil.getSourceName(targetKey.getTypeLiteral());

    return new SourceSnippetBuilder()
        .append(type).append(" result = ")
        .append(methodCallUtil.createMethodCallWithInjection(providerMethod, createModule,
            nameGenerator, methodsOutput))
        .build();
  }
405785
private Map<String, CompiledClass> extractClassFileMap() {
    if (context instanceof StandardGeneratorContext) {
      StandardGeneratorContext standardContext = (StandardGeneratorContext) context;
      return standardContext.getCompilationState().getClassFileMap();
    } else {
      logger.log(TreeLogger.Type.WARN,
          String.format("Could not load generated classes from GWT context, "
              + "encountered unexpected generator type %s.", context.getClass()));
      return null;
    }
  }