From 653e8971b42a17e2400a63e1e1ff97727254f377 Mon Sep 17 00:00:00 2001 From: AlexisDrogoul Date: Sat, 29 Jan 2022 23:06:55 +0700 Subject: [PATCH] Adding headers and auto-javadoc to msi.gama.processor --- .../gama/precompiler/ConstantProcessor.java | 13 + .../gama/precompiler/DisplayProcessor.java | 13 + .../gama/precompiler/ExperimentProcessor.java | 13 + .../msi/gama/precompiler/GamaProcessor.java | 8 +- .../src/msi/gama/precompiler/IProcessor.java | 48 +++ .../gama/precompiler/ListenerProcessor.java | 13 + .../msi/gama/precompiler/SkillProcessor.java | 13 + .../gama/precompiler/SpeciesProcessor.java | 13 + .../msi/gama/precompiler/SymbolProcessor.java | 15 + .../msi/gama/precompiler/TypeProcessor.java | 13 + .../msi/gama/precompiler/doc/Category.java | 26 +- .../gama/precompiler/doc/DocProcessor.java | 277 +++++++++++++++++- .../msi/gama/precompiler/doc/DocUsage.java | 30 ++ .../gama/precompiler/doc/Documentation.java | 46 +++ .../precompiler/doc/ElementTypeUtils.java | 43 ++- .../msi/gama/precompiler/doc/IElement.java | 23 +- .../src/msi/gama/precompiler/doc/Operand.java | 37 ++- .../msi/gama/precompiler/doc/Operands.java | 47 ++- .../msi/gama/precompiler/doc/Operator.java | 76 ++++- .../precompiler/tests/ExamplesToTests.java | 60 +++- .../gama/precompiler/tests/TestProcessor.java | 48 +++ 21 files changed, 808 insertions(+), 67 deletions(-) diff --git a/msi.gama.processor/src/msi/gama/precompiler/ConstantProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/ConstantProcessor.java index 09baca8141..e806751d5c 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/ConstantProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/ConstantProcessor.java @@ -1,9 +1,22 @@ +/******************************************************************************************************* + * + * ConstantProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler; import javax.lang.model.element.Element; import msi.gama.precompiler.GamlAnnotations.constant; +/** + * The Class ConstantProcessor. + */ public class ConstantProcessor extends ElementProcessor { @Override diff --git a/msi.gama.processor/src/msi/gama/precompiler/DisplayProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/DisplayProcessor.java index e91ea2f8b2..8829931be5 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/DisplayProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/DisplayProcessor.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * DisplayProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler; import javax.lang.model.element.Element; @@ -5,6 +15,9 @@ import msi.gama.precompiler.GamlAnnotations.display; +/** + * The Class DisplayProcessor. + */ public class DisplayProcessor extends ElementProcessor { @Override diff --git a/msi.gama.processor/src/msi/gama/precompiler/ExperimentProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/ExperimentProcessor.java index a3f3b68c00..93c5000305 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/ExperimentProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/ExperimentProcessor.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * ExperimentProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler; import javax.lang.model.element.Element; @@ -5,6 +15,9 @@ import msi.gama.precompiler.GamlAnnotations.experiment; +/** + * The Class ExperimentProcessor. + */ public class ExperimentProcessor extends ElementProcessor { @Override diff --git a/msi.gama.processor/src/msi/gama/precompiler/GamaProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/GamaProcessor.java index 8ec7dfab84..71bff9f8b0 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/GamaProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/GamaProcessor.java @@ -1,12 +1,12 @@ /******************************************************************************************************* * - * GamaProcessor.java, in msi.gama.processor, is part of the source code of the GAMA modeling and simulation platform - * (v.1.8.2). + * GamaProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). * - * (c) 2007-2021 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * * Visit https://github.com/gama-platform/gama for license information and contacts. - * + * ********************************************************************************************************/ package msi.gama.precompiler; diff --git a/msi.gama.processor/src/msi/gama/precompiler/IProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/IProcessor.java index e58ed57456..1b93498cef 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/IProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/IProcessor.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * IProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler; import java.lang.annotation.Annotation; @@ -13,8 +23,18 @@ */ public interface IProcessor { + /** + * Process. + * + * @param context the context + */ default void process(final ProcessorContext context) {} + /** + * Gets the initialization method name. + * + * @return the initialization method name + */ /* * Returns the name of the initialization method in which the elements will be written * @@ -24,6 +44,11 @@ default String getInitializationMethodName() { return null; } + /** + * Gets the exceptions. + * + * @return the exceptions + */ /* * The exceptions that should decorate the initialization method */ @@ -31,6 +56,11 @@ default String getExceptions() { return ""; } + /** + * Output to java. + * + * @return true, if successful + */ /* * Returns whether or not this processor produces Java code */ @@ -38,14 +68,32 @@ default boolean outputToJava() { return true; } + /** + * Checks for elements. + * + * @return true, if successful + */ /* * Returns whether or not this processor has elements to process * */ boolean hasElements(); + /** + * Serialize. + * + * @param context the context + * @param elements the elements + * @param sb the sb + */ void serialize(ProcessorContext context, Collection elements, StringBuilder sb); + /** + * Write java body. + * + * @param sb the sb + * @param context the context + */ void writeJavaBody(StringBuilder sb, ProcessorContext context); } diff --git a/msi.gama.processor/src/msi/gama/precompiler/ListenerProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/ListenerProcessor.java index 38209c1dd8..3e833bdaa4 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/ListenerProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/ListenerProcessor.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * ListenerProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler; import java.util.List; @@ -8,6 +18,9 @@ import msi.gama.precompiler.GamlAnnotations.listener; +/** + * The Class ListenerProcessor. + */ public class ListenerProcessor extends ElementProcessor { @Override diff --git a/msi.gama.processor/src/msi/gama/precompiler/SkillProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/SkillProcessor.java index e8f8d728df..b1fff06e82 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/SkillProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/SkillProcessor.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * SkillProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler; import javax.lang.model.element.Element; @@ -5,6 +15,9 @@ import msi.gama.precompiler.GamlAnnotations.skill; +/** + * The Class SkillProcessor. + */ public class SkillProcessor extends ElementProcessor { @Override diff --git a/msi.gama.processor/src/msi/gama/precompiler/SpeciesProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/SpeciesProcessor.java index 085e96554e..fb6a004457 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/SpeciesProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/SpeciesProcessor.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * SpeciesProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler; import javax.lang.model.element.Element; @@ -5,6 +15,9 @@ import msi.gama.precompiler.GamlAnnotations.species; +/** + * The Class SpeciesProcessor. + */ public class SpeciesProcessor extends ElementProcessor { @Override diff --git a/msi.gama.processor/src/msi/gama/precompiler/SymbolProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/SymbolProcessor.java index 54a4fa1f7c..9f65c9694c 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/SymbolProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/SymbolProcessor.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * SymbolProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler; import java.util.HashSet; @@ -11,7 +21,12 @@ import msi.gama.precompiler.GamlAnnotations.inside; import msi.gama.precompiler.GamlAnnotations.symbol; +/** + * The Class SymbolProcessor. + */ public class SymbolProcessor extends ElementProcessor { + + /** The temp. */ Set temp = new HashSet<>(); @Override diff --git a/msi.gama.processor/src/msi/gama/precompiler/TypeProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/TypeProcessor.java index a95061a353..34398f3166 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/TypeProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/TypeProcessor.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * TypeProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler; import java.util.Arrays; @@ -15,6 +25,9 @@ import msi.gama.precompiler.GamlAnnotations.type; import msi.gama.precompiler.doc.utils.TypeConverter; +/** + * The Class TypeProcessor. + */ public class TypeProcessor extends ElementProcessor { @Override diff --git a/msi.gama.processor/src/msi/gama/precompiler/doc/Category.java b/msi.gama.processor/src/msi/gama/precompiler/doc/Category.java index d09cff4f59..411aff576f 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/doc/Category.java +++ b/msi.gama.processor/src/msi/gama/precompiler/doc/Category.java @@ -1,15 +1,13 @@ -/********************************************************************************************* +/******************************************************************************************************* * - * 'Category.java, in plugin msi.gama.processor, is part of the source code of the - * GAMA modeling and simulation platform. - * (v. 1.8.1) + * Category.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). * - * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * - * Visit https://github.com/gama-platform/gama for license information and developers contact. + * Visit https://github.com/gama-platform/gama for license information and contacts. * - * - **********************************************************************************************/ + ********************************************************************************************************/ package msi.gama.precompiler.doc; import msi.gama.precompiler.doc.utils.XMLElements; @@ -17,11 +15,23 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +/** + * The Class Category. + */ public class Category implements IElement { + /** The doc. */ Document doc; + + /** The id category. */ String idCategory; + /** + * Instantiates a new category. + * + * @param _doc the doc + * @param id the id + */ public Category(Document _doc, String id){ doc = _doc; idCategory = id; diff --git a/msi.gama.processor/src/msi/gama/precompiler/doc/DocProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/doc/DocProcessor.java index 75669232e7..aa05e23a65 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/doc/DocProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/doc/DocProcessor.java @@ -1,14 +1,13 @@ -/********************************************************************************************* +/******************************************************************************************************* * - * 'GamlDocProcessor.java, in plugin msi.gama.processor, is part of the source code of the GAMA modeling and simulation - * platform. (v. 1.8.1) + * DocProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). * - * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * - * Visit https://github.com/gama-platform/gama for license information and developers contact. + * Visit https://github.com/gama-platform/gama for license information and contacts. * - * - **********************************************************************************************/ + ********************************************************************************************************/ package msi.gama.precompiler.doc; import java.io.PrintWriter; @@ -65,22 +64,41 @@ import msi.gama.precompiler.doc.utils.TypeConverter; import msi.gama.precompiler.doc.utils.XMLElements; +/** + * The Class DocProcessor. + */ public class DocProcessor extends ElementProcessor { + /** The Constant CAST_METHOD. */ public static final String CAST_METHOD = "cast"; + /** The mes. */ Messager mes; + + /** The tc. */ TypeConverter tc; + + /** The document. */ public Document document; // boolean firstParsing; + /** The nbr operators. */ // Statistic values int nbrOperators; + + /** The nbr operators doc. */ int nbrOperatorsDoc; + + /** The nbr skills. */ int nbrSkills; + + /** The nbr symbols. */ int nbrSymbols; + /** + * Instantiates a new doc processor. + */ public DocProcessor() { // firstParsing = true; nbrOperators = 0; @@ -104,10 +122,21 @@ protected Class getAnnotationClass() { return doc.class; } + /** + * Gets the root name. + * + * @return the root name + */ protected String getRootName() { return "doc"; } + /** + * Gets the root node. + * + * @param doc the doc + * @return the root node + */ protected org.w3c.dom.Element getRootNode(final Document doc) { org.w3c.dom.Element root = null; if (doc.hasChildNodes()) { @@ -238,6 +267,12 @@ public void process(final ProcessorContext context) { } } + /** + * Process doc XML constants. + * + * @param set the set + * @return the org.w 3 c.dom. element + */ private org.w3c.dom.Element processDocXMLConstants(final Set set) { final org.w3c.dom.Element eltConstants = document.createElement(XMLElements.CONSTANTS); for (final Element e : set) { @@ -289,6 +324,12 @@ private org.w3c.dom.Element processDocXMLConstants(final Set return eltConstants; } + /** + * Process doc XML operators from types. + * + * @param set the set + * @return the array list + */ private ArrayList processDocXMLOperatorsFromTypes(final Set set) { // Parcours de tous les types @@ -337,6 +378,12 @@ private ArrayList processDocXMLOperatorsFromTypes(final Set return eltOpFromTypes; } + /** + * Process doc XML types. + * + * @param setFiles the set files + * @return the org.w 3 c.dom. element + */ private org.w3c.dom.Element processDocXMLTypes(final Set setFiles) { final org.w3c.dom.Element files = document.createElement(XMLElements.FILES); @@ -384,6 +431,12 @@ private org.w3c.dom.Element processDocXMLTypes(final Set setF return files; } + /** + * Process doc XML operators from files. + * + * @param set the set + * @return the array list + */ private ArrayList processDocXMLOperatorsFromFiles(final Set set) { final ArrayList eltOpFromTypes = new ArrayList<>(); @@ -471,6 +524,13 @@ private ArrayList processDocXMLOperatorsFromFiles(final Set return eltOpFromTypes; } + /** + * Process doc XML categories. + * + * @param set the set + * @param typeElement the type element + * @return the org.w 3 c.dom. element + */ private org.w3c.dom.Element processDocXMLCategories(final Set set, final String typeElement) { final org.w3c.dom.Element categories = document.createElement(typeElement); @@ -522,6 +582,13 @@ private org.w3c.dom.Element processDocXMLCategories(final Set return categories; } + /** + * Process doc XML concepts. + * + * @param conceptArray the concept array + * @param typeElement the type element + * @return the org.w 3 c.dom. element + */ private org.w3c.dom.Element processDocXMLConcepts(final Field[] conceptArray, final String typeElement) { final org.w3c.dom.Element concepts = document.createElement(typeElement); for (final Field field : conceptArray) { @@ -541,6 +608,12 @@ private org.w3c.dom.Element processDocXMLConcepts(final Field[] conceptArray, fi return concepts; } + /** + * Process doc XML operators. + * + * @param set the set + * @return the org.w 3 c.dom. element + */ private org.w3c.dom.Element processDocXMLOperators(final Set set) { final org.w3c.dom.Element operators = document.createElement(XMLElements.OPERATORS); @@ -705,6 +778,13 @@ private org.w3c.dom.Element processDocXMLOperators(final Set setArchis, final RoundEnvironment env) { final org.w3c.dom.Element archis = document.createElement(XMLElements.ARCHITECTURES); @@ -764,6 +844,13 @@ private org.w3c.dom.Element processDocXMLArchitectures(final Set setSkills, final RoundEnvironment env) { @@ -859,6 +946,12 @@ private org.w3c.dom.Element processDocXMLSkills(final Set set return skills; } + /** + * Process doc XML species. + * + * @param setSpecies the set species + * @return the org.w 3 c.dom. element + */ private org.w3c.dom.Element processDocXMLSpecies(final Set setSpecies) { final org.w3c.dom.Element species = document.createElement(XMLElements.SPECIESS); @@ -931,6 +1024,12 @@ private org.w3c.dom.Element processDocXMLSpecies(final Set setStatement) { final org.w3c.dom.Element statementsInsideSymbolElt = document.createElement(XMLElements.INSIDE_STAT_SYMBOLS); final ArrayList insideStatementSymbol = new ArrayList<>(); @@ -961,6 +1060,12 @@ private org.w3c.dom.Element processDocXMLStatementsInsideSymbol(final Set setStatement) { final org.w3c.dom.Element statementsInsideKindElt = document.createElement(XMLElements.INSIDE_STAT_KINDS); final ArrayList insideStatementKind = new ArrayList<>(); @@ -992,6 +1097,12 @@ private org.w3c.dom.Element processDocXMLStatementsInsideKind(final Set setStatements) { final org.w3c.dom.Element statementsKindsElt = document.createElement(XMLElements.STATEMENT_KINDS); final ArrayList statementKinds = new ArrayList<>(); @@ -1018,6 +1129,13 @@ private Node processDocXMLStatementsKinds(final Set setStatem return statementsKindsElt; } + /** + * Process doc XML types. + * + * @param setTypes the set types + * @param env the env + * @return the org.w 3 c.dom. element + */ private org.w3c.dom.Element processDocXMLTypes(final Set setTypes, final RoundEnvironment env) { final org.w3c.dom.Element types = document.createElement(XMLElements.TYPES); @@ -1054,6 +1172,12 @@ private org.w3c.dom.Element processDocXMLTypes(final Set setT return types; } + /** + * Process doc XML statements. + * + * @param setStatement the set statement + * @return the org.w 3 c.dom. element + */ private org.w3c.dom.Element processDocXMLStatements(final Set setStatement) { final org.w3c.dom.Element statementsElt = document.createElement(XMLElements.STATEMENTS); @@ -1112,14 +1236,40 @@ private org.w3c.dom.Element processDocXMLStatements(final Set return statementsElt; } + /** The Constant PREFIX_CONSTANT. */ public static final String PREFIX_CONSTANT = "#"; + /** + * Gets the doc elt. + * + * @param docAnnot the doc annot + * @param doc the doc + * @param mes the mes + * @param eltName the elt name + * @param tc the tc + * @param e the e + * @param parentElement the parent element + * @return the doc elt + */ public org.w3c.dom.Element getDocElt(final doc docAnnot, final Document doc, final Messager mes, final String eltName, final TypeConverter tc, final ExecutableElement e, final org.w3c.dom.Element parentElement) { return getDocElt(docAnnot, doc, null, mes, eltName, tc, e, parentElement); } + /** + * Gets the doc elt. + * + * @param docAnnot the doc annot + * @param doc the doc + * @param docElement the doc element + * @param mes the mes + * @param eltName the elt name + * @param tc the tc + * @param e the e + * @param parentElement the parent element + * @return the doc elt + */ public org.w3c.dom.Element getDocElt(final doc docAnnot, final Document doc, final org.w3c.dom.Element docElement, final Messager mes, final String eltName, final TypeConverter tc, final ExecutableElement e, final org.w3c.dom.Element parentElement) { // e.getSimpleName() @@ -1290,6 +1440,18 @@ else if (usage.examples().length == 0) { return docElt; } + /** + * Gets the doc elt. + * + * @param docAnnotTab the doc annot tab + * @param doc the doc + * @param mes the mes + * @param eltName the elt name + * @param tc the tc + * @param e the e + * @param parentElement the parent element + * @return the doc elt + */ public org.w3c.dom.Element getDocElt(final doc[] docAnnotTab, final Document doc, final Messager mes, final String eltName, final TypeConverter tc, final ExecutableElement e, final org.w3c.dom.Element parentElement) { // e.getSimpleName() @@ -1298,6 +1460,16 @@ public org.w3c.dom.Element getDocElt(final doc[] docAnnotTab, final Document doc return getDocElt(docAnnotTab[0], doc, null, mes, eltName, tc, e, parentElement); } + /** + * Gets the examples elt. + * + * @param examples the examples + * @param doc the doc + * @param e the e + * @param tc the tc + * @param parentElement the parent element + * @return the examples elt + */ public org.w3c.dom.Element getExamplesElt(final example[] examples, final Document doc, final ExecutableElement e, final TypeConverter tc, final org.w3c.dom.Element parentElement) { final org.w3c.dom.Element examplesElt = doc.createElement(XMLElements.EXAMPLES); @@ -1307,6 +1479,16 @@ public org.w3c.dom.Element getExamplesElt(final example[] examples, final Docume return examplesElt; } + /** + * Gets the example elt. + * + * @param example the example + * @param doc the doc + * @param e the e + * @param tc the tc + * @param parentElement the parent element + * @return the example elt + */ public org.w3c.dom.Element getExampleElt(final example example, final Document doc, final ExecutableElement e, final TypeConverter tc, final org.w3c.dom.Element parentElement) { final org.w3c.dom.Element exampleElt = doc.createElement(XMLElements.EXAMPLE); @@ -1343,6 +1525,16 @@ public org.w3c.dom.Element getExampleElt(final example example, final Document d return exampleElt; } + /** + * Gets the constant elt. + * + * @param constant the constant + * @param doc the doc + * @param e the e + * @param mes the mes + * @param tc the tc + * @return the constant elt + */ public org.w3c.dom.Element getConstantElt(final constant constant, final Document doc, final Element e, final Messager mes, final TypeConverter tc) { final org.w3c.dom.Element constantElt = doc.createElement(XMLElements.CONSTANT); @@ -1373,6 +1565,16 @@ public org.w3c.dom.Element getConstantElt(final constant constant, final Documen return constantElt; } + /** + * Gets the vars elt. + * + * @param varsAnnot the vars annot + * @param doc the doc + * @param mes the mes + * @param skillName the skill name + * @param tc the tc + * @return the vars elt + */ public org.w3c.dom.Element getVarsElt(final vars varsAnnot, final Document doc, final Messager mes, final String skillName, final TypeConverter tc) { if (varsAnnot != null) { @@ -1401,6 +1603,16 @@ public org.w3c.dom.Element getVarsElt(final vars varsAnnot, final Document doc, return null; } + /** + * Gets the action elt. + * + * @param actionAnnot the action annot + * @param doc the doc + * @param mes the mes + * @param e the e + * @param tc the tc + * @return the action elt + */ public org.w3c.dom.Element getActionElt(final action actionAnnot, final Document doc, final Messager mes, final Element e, final TypeConverter tc) { if (!(e instanceof ExecutableElement) || actionAnnot == null) { return null; } @@ -1442,6 +1654,16 @@ public org.w3c.dom.Element getActionElt(final action actionAnnot, final Document return actionElt; } + /** + * Gets the facets elt. + * + * @param facetsAnnot the facets annot + * @param doc the doc + * @param mes the mes + * @param statName the stat name + * @param tc the tc + * @return the facets elt + */ public org.w3c.dom.Element getFacetsElt(final facets facetsAnnot, final Document doc, final Messager mes, final String statName, final TypeConverter tc) { if (facetsAnnot == null) { return null; } @@ -1477,6 +1699,14 @@ public org.w3c.dom.Element getFacetsElt(final facets facetsAnnot, final Document return facetsElt; } + /** + * Gets the inside elt. + * + * @param insideAnnot the inside annot + * @param doc the doc + * @param tc the tc + * @return the inside elt + */ public org.w3c.dom.Element getInsideElt(final inside insideAnnot, final Document doc, final TypeConverter tc) { if (insideAnnot == null) { return null; } @@ -1501,6 +1731,13 @@ public org.w3c.dom.Element getInsideElt(final inside insideAnnot, final Document return insideElt; } + /** + * Gets the operator element. + * + * @param operators the operators + * @param eltName the elt name + * @return the operator element + */ public org.w3c.dom.Element getOperatorElement(final org.w3c.dom.Element operators, final String eltName) { final NodeList nL = operators.getElementsByTagName(XMLElements.OPERATOR); int i = 0; @@ -1513,6 +1750,15 @@ public org.w3c.dom.Element getOperatorElement(final org.w3c.dom.Element operator return null; } + /** + * Gets the categories. + * + * @param e the e + * @param doc the doc + * @param categoriesElt the categories elt + * @param tc the tc + * @return the categories + */ public org.w3c.dom.Element getCategories(final Element e, final Document doc, final org.w3c.dom.Element categoriesElt, final TypeConverter tc) { final ArrayList categories = new ArrayList<>(); @@ -1561,12 +1807,29 @@ public org.w3c.dom.Element getCategories(final Element e, final Document doc, return categoriesElt; } + /** + * Gets the categories. + * + * @param e the e + * @param doc the doc + * @param tc the tc + * @return the categories + */ public org.w3c.dom.Element getCategories(final Element e, final Document doc, final TypeConverter tc) { final org.w3c.dom.Element categoriesElt = doc.createElement(XMLElements.OPERATORS_CATEGORIES); return getCategories(e, doc, categoriesElt, tc); } + /** + * Gets the concepts. + * + * @param e the e + * @param doc the doc + * @param conceptElt the concept elt + * @param tc the tc + * @return the concepts + */ public org.w3c.dom.Element getConcepts(final Element e, final Document doc, final org.w3c.dom.Element conceptElt, final TypeConverter tc) { final ArrayList concepts = new ArrayList<>(); diff --git a/msi.gama.processor/src/msi/gama/precompiler/doc/DocUsage.java b/msi.gama.processor/src/msi/gama/precompiler/doc/DocUsage.java index fc645bb1fb..25fa5a4b60 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/doc/DocUsage.java +++ b/msi.gama.processor/src/msi/gama/precompiler/doc/DocUsage.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * DocUsage.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler.doc; import org.w3c.dom.Document; @@ -6,16 +16,36 @@ import msi.gama.precompiler.doc.utils.XMLElements; +/** + * The Class DocUsage. + */ public class DocUsage implements IElement { + /** The doc. */ Document doc; + + /** The description usage. */ String descriptionUsage; + + /** The ex elt. */ org.w3c.dom.Element exElt; + /** + * Instantiates a new doc usage. + * + * @param _doc the doc + */ public DocUsage(final Document _doc) { this(_doc,"",null); } + /** + * Instantiates a new doc usage. + * + * @param _doc the doc + * @param desc the desc + * @param _exElt the ex elt + */ public DocUsage(final Document _doc, final String desc, org.w3c.dom.Element _exElt) { doc = _doc; descriptionUsage = desc; diff --git a/msi.gama.processor/src/msi/gama/precompiler/doc/Documentation.java b/msi.gama.processor/src/msi/gama/precompiler/doc/Documentation.java index 977792ac0c..241254bf3e 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/doc/Documentation.java +++ b/msi.gama.processor/src/msi/gama/precompiler/doc/Documentation.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * Documentation.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler.doc; import java.util.ArrayList; @@ -8,18 +18,38 @@ import msi.gama.precompiler.doc.utils.XMLElements; +/** + * The Class Documentation. + */ public class Documentation implements IElement { + /** The doc. */ Document doc; + /** The result. */ String result; + + /** The usages. */ List usages; + + /** The see also. */ List seeAlso; + /** + * Instantiates a new documentation. + * + * @param _doc the doc + */ public Documentation(final Document _doc) { this(_doc,""); } + /** + * Instantiates a new documentation. + * + * @param _doc the doc + * @param res the res + */ public Documentation(final Document _doc, final String res) { doc = _doc; result = res; @@ -28,14 +58,30 @@ public Documentation(final Document _doc, final String res) { seeAlso = new ArrayList<>(); } + /** + * Sets the result. + * + * @param r the new result + */ public void setResult(String r) { result = r; } + /** + * Adds the see. + * + * @param see the see + */ public void addSee(String see) { seeAlso.add(see); } + /** + * Adds the usage. + * + * @param desc the desc + * @param exElt the ex elt + */ public void addUsage(String desc, org.w3c.dom.Element exElt) { usages.add(new DocUsage(doc, desc, exElt)); } diff --git a/msi.gama.processor/src/msi/gama/precompiler/doc/ElementTypeUtils.java b/msi.gama.processor/src/msi/gama/precompiler/doc/ElementTypeUtils.java index f57748ca62..4a51cfea61 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/doc/ElementTypeUtils.java +++ b/msi.gama.processor/src/msi/gama/precompiler/doc/ElementTypeUtils.java @@ -1,15 +1,13 @@ -/********************************************************************************************* +/******************************************************************************************************* * - * 'ElementTypeUtils.java, in plugin msi.gama.processor, is part of the source code of the - * GAMA modeling and simulation platform. - * (v. 1.8.1) + * ElementTypeUtils.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). * - * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * - * Visit https://github.com/gama-platform/gama for license information and developers contact. + * Visit https://github.com/gama-platform/gama for license information and contacts. * - * - **********************************************************************************************/ + ********************************************************************************************************/ package msi.gama.precompiler.doc; import java.util.ArrayList; @@ -24,14 +22,36 @@ import msi.gama.precompiler.GamlAnnotations.vars; +/** + * The Class ElementTypeUtils. + */ public class ElementTypeUtils { + + /** The Constant ARCHITECTURE. */ public static final String ARCHITECTURE = "IArchitecture"; + + /** The Constant SKILL. */ public static final String SKILL = "ISkill"; + /** + * Checks if is architecture element. + * + * @param typeElt the type elt + * @param mes the mes + * @return true, if is architecture element + */ public static boolean isArchitectureElement(TypeElement typeElt, Messager mes) { return isImplementingInterface(typeElt, ARCHITECTURE, mes); } + /** + * Checks if is implementing interface. + * + * @param typeElt the type elt + * @param interfaceName the interface name + * @param mes the mes + * @return true, if is implementing interface + */ // Inspired by http://types.cs.washington.edu/checker-framework/current/api/ElementUtils public static boolean isImplementingInterface(TypeElement typeElt, String interfaceName, Messager mes) { @@ -67,6 +87,13 @@ public static boolean isImplementingInterface(TypeElement typeElt, String interf return isImplementing; } + /** + * Gets the first implementing interfaces with vars. + * + * @param typeElt the type elt + * @param mes the mes + * @return the first implementing interfaces with vars + */ // Inspired by the previous method and thus by http://types.cs.washington.edu/checker-framework/current/api/ElementUtils public static TypeElement getFirstImplementingInterfacesWithVars(TypeElement typeElt, Messager mes) { diff --git a/msi.gama.processor/src/msi/gama/precompiler/doc/IElement.java b/msi.gama.processor/src/msi/gama/precompiler/doc/IElement.java index db22b72302..acd8aeb2df 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/doc/IElement.java +++ b/msi.gama.processor/src/msi/gama/precompiler/doc/IElement.java @@ -1,17 +1,24 @@ -/********************************************************************************************* +/******************************************************************************************************* * - * 'IElement.java, in plugin msi.gama.processor, is part of the source code of the - * GAMA modeling and simulation platform. - * (v. 1.8.1) + * IElement.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). * - * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * - * Visit https://github.com/gama-platform/gama for license information and developers contact. + * Visit https://github.com/gama-platform/gama for license information and contacts. * - * - **********************************************************************************************/ + ********************************************************************************************************/ package msi.gama.precompiler.doc; +/** + * The Interface IElement. + */ public interface IElement { + + /** + * Gets the element DOM. + * + * @return the element DOM + */ public org.w3c.dom.Element getElementDOM(); } diff --git a/msi.gama.processor/src/msi/gama/precompiler/doc/Operand.java b/msi.gama.processor/src/msi/gama/precompiler/doc/Operand.java index c17d27cf33..c88150a86d 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/doc/Operand.java +++ b/msi.gama.processor/src/msi/gama/precompiler/doc/Operand.java @@ -1,15 +1,13 @@ -/********************************************************************************************* +/******************************************************************************************************* * - * 'Operand.java, in plugin msi.gama.processor, is part of the source code of the - * GAMA modeling and simulation platform. - * (v. 1.8.1) + * Operand.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). * - * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * - * Visit https://github.com/gama-platform/gama for license information and developers contact. + * Visit https://github.com/gama-platform/gama for license information and contacts. * - * - **********************************************************************************************/ + ********************************************************************************************************/ package msi.gama.precompiler.doc; import msi.gama.precompiler.doc.utils.XMLElements; @@ -17,17 +15,40 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +/** + * The Class Operand. + */ public class Operand implements IElement { + /** The doc. */ Document doc; + + /** The name. */ String name; + + /** The position. */ int position; + + /** The type. */ String type; + /** + * Instantiates a new operand. + * + * @param _doc the doc + */ public Operand(Document _doc){ doc = _doc; } + /** + * Instantiates a new operand. + * + * @param _doc the doc + * @param _name the name + * @param _position the position + * @param _type the type + */ public Operand(Document _doc, String _name, int _position, String _type){ doc = _doc; name = _name; diff --git a/msi.gama.processor/src/msi/gama/precompiler/doc/Operands.java b/msi.gama.processor/src/msi/gama/precompiler/doc/Operands.java index e513e16f81..394324854f 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/doc/Operands.java +++ b/msi.gama.processor/src/msi/gama/precompiler/doc/Operands.java @@ -1,15 +1,13 @@ -/********************************************************************************************* +/******************************************************************************************************* * - * 'Operands.java, in plugin msi.gama.processor, is part of the source code of the - * GAMA modeling and simulation platform. - * (v. 1.8.1) + * Operands.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). * - * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * - * Visit https://github.com/gama-platform/gama for license information and developers contact. + * Visit https://github.com/gama-platform/gama for license information and contacts. * - * - **********************************************************************************************/ + ********************************************************************************************************/ package msi.gama.precompiler.doc; import java.util.ArrayList; @@ -19,20 +17,48 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +/** + * The Class Operands. + */ public class Operands implements IElement { + /** The doc. */ Document doc; + + /** The classe. */ String classe; + + /** The content type. */ String content_type; + + /** The return type. */ String return_type; + + /** The type. */ String type; + + /** The list operand. */ ArrayList listOperand; + /** + * Instantiates a new operands. + * + * @param _doc the doc + */ public Operands(Document _doc){ doc = _doc; listOperand = new ArrayList(); } + /** + * Instantiates a new operands. + * + * @param _doc the doc + * @param _classe the classe + * @param _content_type the content type + * @param _return_type the return type + * @param _type the type + */ public Operands(Document _doc, String _classe, String _content_type, String _return_type, String _type){ this(_doc); classe = _classe; @@ -41,6 +67,11 @@ public Operands(Document _doc, String _classe, String _content_type, String _ret type = _type; } + /** + * Adds the operand. + * + * @param op the op + */ public void addOperand(Operand op){ listOperand.add(op); } diff --git a/msi.gama.processor/src/msi/gama/precompiler/doc/Operator.java b/msi.gama.processor/src/msi/gama/precompiler/doc/Operator.java index 069a7ea473..7ef5045629 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/doc/Operator.java +++ b/msi.gama.processor/src/msi/gama/precompiler/doc/Operator.java @@ -1,14 +1,13 @@ -/********************************************************************************************* +/******************************************************************************************************* * - * 'Operator.java, in plugin msi.gama.processor, is part of the source code of the GAMA modeling and simulation - * platform. (v. 1.8.1) + * Operator.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). * - * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * - * Visit https://github.com/gama-platform/gama for license information and developers contact. + * Visit https://github.com/gama-platform/gama for license information and contacts. * - * - **********************************************************************************************/ + ********************************************************************************************************/ package msi.gama.precompiler.doc; import java.util.ArrayList; @@ -20,19 +19,39 @@ import msi.gama.precompiler.Constants; import msi.gama.precompiler.doc.utils.XMLElements; +/** + * The Class Operator. + */ public class Operator implements IElement { + /** The doc. */ Document doc; + /** The category. */ String category; + + /** The concepts. */ String[] concepts; + + /** The name. */ String name; + + /** The combi IO. */ // Operands operands; List combiIO; + +/** The documentation. */ // String documentation; Documentation documentation; + + /** The has example. */ boolean has_example = false; + /** + * Instantiates a new operator. + * + * @param _doc the doc + */ public Operator(final Document _doc) { doc = _doc; combiIO = new ArrayList<>(); @@ -40,6 +59,14 @@ public Operator(final Document _doc) { // operands = new Operands(_doc); } + /** + * Instantiates a new operator. + * + * @param _doc the doc + * @param _category the category + * @param _concepts the concepts + * @param _name the name + */ public Operator(final Document _doc, final String _category, final String[] _concepts, final String _name) { this(_doc); category = _category; @@ -47,6 +74,15 @@ public Operator(final Document _doc, final String _category, final String[] _con concepts = _concepts; } + /** + * Instantiates a new operator. + * + * @param _doc the doc + * @param _category the category + * @param _concepts the concepts + * @param _name the name + * @param _documentation the documentation + */ public Operator(final Document _doc, final String _category, final String[] _concepts, final String _name, final String _documentation) { this(_doc); @@ -56,19 +92,40 @@ public Operator(final Document _doc, final String _category, final String[] _con concepts = _concepts; } + /** + * Sets the documentation. + * + * @param d the new documentation + */ public void setDocumentation(final String d) { documentation.setResult(d); } + /** + * Adds the operands. + * + * @param ops the ops + */ public void addOperands(Operands ops) { combiIO.add(ops); } + /** + * Adds the see also. + * + * @param see the see + */ public void addSeeAlso(String see) { documentation.addSee(see); } + /** + * Adds the usage. + * + * @param descUsage the desc usage + * @param exElt the ex elt + */ public void addUsage(String descUsage, org.w3c.dom.Element exElt) { if(exElt != null) { has_example = true; @@ -76,6 +133,11 @@ public void addUsage(String descUsage, org.w3c.dom.Element exElt) { documentation.addUsage(descUsage, exElt); } + /** + * Adds the usage. + * + * @param descUsage the desc usage + */ public void addUsage(String descUsage) { this.addUsage(descUsage, null); } diff --git a/msi.gama.processor/src/msi/gama/precompiler/tests/ExamplesToTests.java b/msi.gama.processor/src/msi/gama/precompiler/tests/ExamplesToTests.java index 3e0a3b1983..f047ad7e4b 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/tests/ExamplesToTests.java +++ b/msi.gama.processor/src/msi/gama/precompiler/tests/ExamplesToTests.java @@ -1,15 +1,13 @@ -/********************************************************************************************* +/******************************************************************************************************* * + * ExamplesToTests.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). * - * 'XmlToTestGAML.java', in plugin 'msi.gama.documentation', is part of the source code of the GAMA modeling and - * simulation platform. (v. 1.8.1) + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * - * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners - * - * Visit https://github.com/gama-platform/gama for license information and developers contact. - * - * - **********************************************************************************************/ + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler.tests; import java.io.IOException; @@ -41,13 +39,25 @@ import msi.gama.precompiler.ProcessorContext; import msi.gama.precompiler.doc.utils.XMLElements; +/** + * The Class ExamplesToTests. + */ public class ExamplesToTests implements XMLElements { + /** The Constant ATT_NAME_FILE. */ public static final String ATT_NAME_FILE = "fileName"; + + /** The Constant factoryT. */ static final TransformerFactory factoryT = TransformerFactory.newInstance(); + + /** The Constant OPERATORS_XSL. */ static final URL OPERATORS_XSL = GamaProcessor.class.getClassLoader() .getResource("msi/gama/precompiler/resources/testGaml-Operators-xml2test.xsl"); + + /** The Constant OPERATORS_TRANSFORMER. */ static final Transformer OPERATORS_TRANSFORMER; + + /** The Constant NAME_OPERATOR. */ static final HashMap NAME_OPERATOR = new HashMap() { { put("*", "Multiply"); @@ -87,12 +97,24 @@ public class ExamplesToTests implements XMLElements { OPERATORS_TRANSFORMER = transformer; } + /** + * Creates the tests. + * + * @param context the context + * @param doc the doc + */ public static void createTests(final ProcessorContext context, final Document doc) { if (doc == null || !doc.hasChildNodes()) { return; } final Document document = cleanDocumentTest(doc); createOperatorsTests(context, document, OPERATORS_TRANSFORMER); } + /** + * List. + * + * @param nl the nl + * @return the list + */ private static List list(final NodeList nl) { if (nl.getLength() == 0) { return Collections.EMPTY_LIST; } final List result = new ArrayList<>(); @@ -102,8 +124,16 @@ private static List list(final NodeList nl) { return result; } + /** The Constant documents. */ final static Map documents = new HashMap<>(); + /** + * Creates the operators tests. + * + * @param context the context + * @param document the document + * @param xsl the xsl + */ private static void createOperatorsTests(final ProcessorContext context, final Document document, final Transformer xsl) { final List categories = @@ -150,6 +180,12 @@ private static void createOperatorsTests(final ProcessorContext context, final D } + /** + * Transform documents. + * + * @param context the context + * @param transformer the transformer + */ public static void transformDocuments(final ProcessorContext context, final Transformer transformer) { documents.forEach((targetFile, doc) -> { @@ -175,6 +211,12 @@ public static void transformDocuments(final ProcessorContext context, final Tran // Cleaning means: // - Category: remove space and minus characters in the category name to be able to use it in the model // - Operators: replace special characters like +, -, *, / + /** + * Clean document test. + * + * @param doc the doc + * @return the document + */ // - Operators and statements: addition of an index to have different variables public static Document cleanDocumentTest(final Document doc) { diff --git a/msi.gama.processor/src/msi/gama/precompiler/tests/TestProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/tests/TestProcessor.java index 39256647f1..fcc351cced 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/tests/TestProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/tests/TestProcessor.java @@ -1,3 +1,13 @@ +/******************************************************************************************************* + * + * TestProcessor.java, in msi.gama.processor, is part of the source code of the + * GAMA modeling and simulation platform (v.1.8.2). + * + * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) + * + * Visit https://github.com/gama-platform/gama for license information and contacts. + * + ********************************************************************************************************/ package msi.gama.precompiler.tests; import java.io.IOException; @@ -25,6 +35,9 @@ import msi.gama.precompiler.GamlAnnotations.type; import msi.gama.precompiler.ProcessorContext; +/** + * The Class TestProcessor. + */ public class TestProcessor extends ElementProcessor { @Override @@ -56,6 +69,12 @@ public boolean outputToJava() { return false; } + /** + * Creates the from. + * + * @param test the test + * @return the tests + */ private tests createFrom(final test test) { return new tests() { @@ -88,6 +107,13 @@ public void createElement(final StringBuilder sb, final ProcessorContext context sb.append(ln).append(tab).append("}").append(ln); } + /** + * Write tests. + * + * @param context the context + * @param sb the sb + * @throws IOException Signals that an I/O exception has occurred. + */ public void writeTests(final ProcessorContext context, final Writer sb) throws IOException { sb.append("experiment ").append(toJavaString("Tests for " + context.currentPlugin)).append(" type: test {"); for (final StringBuilder tests : serializedElements.values()) { @@ -98,6 +124,13 @@ public void writeTests(final ProcessorContext context, final Writer sb) throws I namesAlreadyUsed.clear(); } + /** + * Determine text. + * + * @param context the context + * @param test the test + * @return the string + */ private String determineText(final ProcessorContext context, final test test) { String text = test.value().trim(); final int lastSemiColon = text.lastIndexOf(';'); @@ -110,6 +143,14 @@ private String determineText(final ProcessorContext context, final test test) { return text + "assert " + lastAssert + ";"; } + /** + * Determine name. + * + * @param context the context + * @param e the e + * @param tests the tests + * @return the string + */ private String determineName(final ProcessorContext context, final Element e, final tests tests) { String testName = null; // Looking for named tests and concatenating their individual names @@ -174,8 +215,15 @@ protected Class getAnnotationClass() { return tests.class; } + /** The names already used. */ final Map namesAlreadyUsed = new HashMap<>(); + /** + * Gets the test name. + * + * @param name the name + * @return the test name + */ private String getTestName(final String name) { String result = name; if (namesAlreadyUsed.containsKey(name)) {