From e717e34177da170f9f4f6c3c5b756621ee51226a Mon Sep 17 00:00:00 2001 From: HUYNH Nghi Date: Mon, 28 Dec 2020 00:27:02 +0700 Subject: [PATCH] mvn chain fixed with the port of processor 2.0 --- .../compilation/kernel/GamaBundleLoader.java | 18 ++-- .../models/multi-criteria.experiment | 90 +++++++++---------- .../Spatial Tests/models/Operators.experiment | 90 +++++++++---------- msi.gama.parent/pom.xml | 16 +--- .../msi/gama/precompiler/GamaProcessor.java | 38 ++++---- .../gama/precompiler/ProcessorContext.java | 41 ++++++--- .../gama/precompiler/doc/DocProcessor.java | 4 +- .../msi/gama/common/interfaces/IKeyword.java | 4 +- .../msi/gama/common/interfaces/INamed.java | 4 +- .../msi/gama/precompiler/GamlAnnotations.java | 4 +- ummisco.gama.feature.dependencies/feature.xml | 8 -- 11 files changed, 163 insertions(+), 154 deletions(-) diff --git a/msi.gama.core/src/msi/gaml/compilation/kernel/GamaBundleLoader.java b/msi.gama.core/src/msi/gaml/compilation/kernel/GamaBundleLoader.java index d49b64506a..696f830756 100644 --- a/msi.gama.core/src/msi/gaml/compilation/kernel/GamaBundleLoader.java +++ b/msi.gama.core/src/msi/gaml/compilation/kernel/GamaBundleLoader.java @@ -71,6 +71,8 @@ public static void ERROR(final Exception e) { public static String CORE_TESTS = "tests"; public static String CURRENT_PLUGIN_NAME = CORE_PLUGIN.getSymbolicName(); public static String ADDITIONS = "gaml.additions.GamlAdditions"; + public static final String ADDITIONS_PACKAGE_BASE = "gaml.additions"; + public static final String ADDITIONS_CLASS_NAME = "GamlAdditions"; public static String GRAMMAR_EXTENSION_DEPRECATED = "gaml.grammar.addition"; public static String GRAMMAR_EXTENSION = "gaml.extension"; public static String CREATE_EXTENSION = "gama.create"; @@ -135,7 +137,7 @@ public static void preBuildContributions() throws Exception { } catch (final Exception e2) { ERR(ERROR_MESSAGE); ERR("Error in loading plugin " + CORE_PLUGIN.getSymbolicName() + ": " + e2.getMessage()); - System.exit(0); +// System.exit(0); return; } // We then build the other extensions to the language @@ -146,7 +148,7 @@ public static void preBuildContributions() throws Exception { } catch (final Exception e1) { ERR(ERROR_MESSAGE); ERR("Error in loading plugin " + CORE_PLUGIN.getSymbolicName() + ": " + e1.getMessage()); - System.exit(0); +// System.exit(0); return; } } @@ -164,7 +166,7 @@ public static void preBuildContributions() throws Exception { } catch (final Exception e1) { ERR(ERROR_MESSAGE); ERR("Error in loading CreateStatement delegate : " + e1.getMessage()); - System.exit(0); +// System.exit(0); return; } @@ -180,7 +182,7 @@ public static void preBuildContributions() throws Exception { ERR(ERROR_MESSAGE); ERR("Error in loading EventLayerStatement delegate : " + e1.getMessage()); - System.exit(0); +// System.exit(0); return; } @@ -219,10 +221,16 @@ public static void preBuildContributions() throws Exception { @SuppressWarnings ("unchecked") public static void preBuild(final Bundle bundle) throws Exception { TIMER_WITH_EXCEPTIONS(PAD("> GAMA: " + bundle.getSymbolicName(), 45) + " loaded in ", () -> { + String shortcut = bundle.getSymbolicName(); + shortcut = shortcut.substring(shortcut.lastIndexOf('.') + 1); GamaClassLoader.getInstance().addBundle(bundle); Class gamlAdditions = null; try { - gamlAdditions = (Class) bundle.loadClass(ADDITIONS); +// gamlAdditions = (Class) bundle.loadClass(ADDITIONS); + + gamlAdditions = (Class) bundle + .loadClass(ADDITIONS_PACKAGE_BASE + "." + shortcut + "." + ADDITIONS_CLASS_NAME); + } catch (final ClassNotFoundException e1) { ERR(">> Impossible to load additions from " + bundle.toString() + " because of " + e1); throw e1; diff --git a/msi.gama.core/tests/Multi-criteria Tests/models/multi-criteria.experiment b/msi.gama.core/tests/Multi-criteria Tests/models/multi-criteria.experiment index a05dc6c234..6120f7226f 100644 --- a/msi.gama.core/tests/Multi-criteria Tests/models/multi-criteria.experiment +++ b/msi.gama.core/tests/Multi-criteria Tests/models/multi-criteria.experiment @@ -1,47 +1,47 @@ -/** -* Name: multicriteria -* Author: Patrick Taillandier -* Description: Tests multi-criteria decision making operators -* Tags: multi_criteria, test +/** +* Name: multicriteria +* Author: Patrick Taillandier +* Description: Tests multi-criteria decision making operators +* Tags: multi_criteria, test */ -model multicriteriaTest - -experiment TopologyTests type: test { - list> candidates <- [[1.0,1.0,1.0],[2.0,0.0,1.0],[0.0,0.0,0.0],[1.0,2.0,0.0],[0.0,0.5,3.0]]; - - test "weighted_means_DM"{ - list criteria_WM <- [["name"::"C1", "weight" :: 1.0],["name"::"C2", "weight" :: 2.0],["name"::"C3", "weight" ::3.0]]; - int choice <- weighted_means_DM(candidates,criteria_WM); - assert choice = 4; - } - - test "electre_DM"{ - list criteria_WM <- [["name"::"C1", "weight" :: 1.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true],["name"::"C2", "weight" :: 2.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true],["name"::"C3", "weight" ::3.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true]]; - int choice <- electre_DM(candidates,criteria_WM, 0.7); - assert choice = 4; - } - - test "promethee_DM"{ - list criteria_Promethee <- [["name"::"C1", "weight" :: 1.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true],["name"::"C2", "weight" :: 2.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true],["name"::"C3", "weight" ::1.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true]]; - int choice <- promethee_DM(candidates,criteria_Promethee); - assert choice = 3; - } - - test "evidence_theory_DM"{ - list criteria_ET <- [["name"::"C1", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::1.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true],["name"::"C2", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::2.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true],["name"::"C3", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::3.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true]]; - int choice <- evidence_theory_DM(candidates,criteria_ET, true); - assert choice = 4; - - choice <- evidence_theory_DM(candidates,criteria_ET, false); - assert choice = 0; - } - - test "fuzzy_choquet_DM"{ - map,float> criteria_FC <- ([["C1"]::1.0, ["C2"]::2.0, ["C3"]:: 3.0,["C1","C2"]::1.0]); - int choice <- fuzzy_choquet_DM(candidates,["C1", "C2", "C3"],criteria_FC); - assert choice = 4; - } -} - - +model multicriteriaTest + +experiment TopologyTests type: test { + list> candidates <- [[1.0,1.0,1.0],[2.0,0.0,1.0],[0.0,0.0,0.0],[1.0,2.0,0.0],[0.0,0.5,3.0]]; + + test "weighted_means_DM"{ + list criteria_WM <- [["name"::"C1", "weight" :: 1.0],["name"::"C2", "weight" :: 2.0],["name"::"C3", "weight" ::3.0]]; + int choice <- weighted_means_DM(candidates,criteria_WM); + assert choice = 4; + } + + test "electre_DM"{ + list criteria_WM <- [["name"::"C1", "weight" :: 1.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true],["name"::"C2", "weight" :: 2.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true],["name"::"C3", "weight" ::3.0, "p"::2.0, "q"::0.0, "v"::2.0, "maximize" :: true]]; + int choice <- electre_DM(candidates,criteria_WM, 0.7); + assert choice = 4; + } + + test "promethee_DM"{ + list criteria_Promethee <- [["name"::"C1", "weight" :: 1.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true],["name"::"C2", "weight" :: 2.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true],["name"::"C3", "weight" ::1.0, "p"::2.0, "q"::0.0, "s"::3.0, "maximize" :: true]]; + int choice <- promethee_DM(candidates,criteria_Promethee); + assert choice = 3; + } + + test "evidence_theory_DM"{ + list criteria_ET <- [["name"::"C1", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::1.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true],["name"::"C2", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::2.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true],["name"::"C3", "s1"::0.0, "s2"::3.0, "v1p"::0.0, "v2p"::3.0, "v1c"::0.0, "v2c"::0.0,"maximize" :: true]]; + int choice <- evidence_theory_DM(candidates,criteria_ET, true); + assert choice = 4; + + choice <- evidence_theory_DM(candidates,criteria_ET, false); + assert choice = 0; + } + + test "fuzzy_choquet_DM"{ + map,float> criteria_FC <- ([["C1"]::1.0, ["C2"]::2.0, ["C3"]:: 3.0,["C1","C2"]::1.0]); + int choice <- fuzzy_choquet_DM(candidates,["C1", "C2", "C3"],criteria_FC); + assert choice = 4; + } +} + + diff --git a/msi.gama.core/tests/Spatial Tests/models/Operators.experiment b/msi.gama.core/tests/Spatial Tests/models/Operators.experiment index 5eacc060dd..3d10d83c75 100644 --- a/msi.gama.core/tests/Spatial Tests/models/Operators.experiment +++ b/msi.gama.core/tests/Spatial Tests/models/Operators.experiment @@ -1,47 +1,47 @@ -/** -* Name: Spatial Operators -* Author: Patrick Taillandier -* Description: Tests various spatial operators -* Tags: spatial, operators, test -*/ +/** +* Name: Spatial Operators +* Author: Patrick Taillandier +* Description: Tests various spatial operators +* Tags: spatial, operators, test +*/ -experiment OperatorsTest type: test { - test "add_point" { - assert (geometry(nil) add_point {20,20}) = nil; - assert ({10,10} add_point point(nil)) = {10,10}; - assert ({10,10} add_point {20,20}) = line([{10,10},{20,20}]); - assert (line([{10,10},{20,20}]) add_point {30,30}) = line([{10,10},{20,20},{30,30}]); - assert (line([{10,10},{20,20},{30,30}]) add_point {0,0}) = line([{0,0},{10,10},{20,20},{30,30}]); - assert (line([{10,10},{20,20},{30,30}]) add_point {25,22}) = line([{10,10},{20,20},{25,22},{30,30}]); - assert ((square(10) at_location {50,50}) add_point {50,35}) = polygon([{45,55}, {55,55}, {55,45}, {50,35},{45,45}]); - assert ((square(10) at_location {50,50}) add_point {50,50}) = polygon([{45,55}, {50,50}, {55,55},{55,45},{45,45}]); - } - test "inter" { - assert geometry(nil) inter {10,10} = nil; - assert {10,10} inter geometry(nil) = nil; - assert {10,10} inter {20,10} = nil; - assert {10,10} inter {10,10} = {10,10}; - assert line([{10,10},{20,20}]) inter {10,10} = {10,10}; - assert line([{10,10},{20,20}]) inter {20,10} = nil; - assert line([{10,10},{20,20}]) inter line([{5,5},{15,15}]) = line([{10,10},{15,15}]); - assert line([{10,5},{10,20}]) inter line([{5,15},{30,15}]) distance_to {10,15} < 0.1; - } - test "minus" { - assert geometry(nil) - {10,10} = nil; - assert geometry({10,10}) - geometry(nil) = {10,10}; - assert (square(10) - {10,10}).area = 100.0; - assert length((line([{0,10},{20,10}]) - line([{10,0},{10,25}])).geometries) = 2 ; - assert ((square(10) at_location {0,0}) - (square(10) at_location {5,0})) = polygon ([{-5,5},{0,5},{0,-5},{-5,-5}]); - } - test "union" { - assert geometry(nil) union {10,10} = {10,10} ; - assert {10,10} union geometry(nil) = {10,10} ; - assert union([line([{0,10},{20,10}]) , line([{20,10},{30,10}])]).perimeter = 30.0 ; - } - test "masked_by" { - } - test "split_at" { - assert (line([{0,0},{100,0}]) split_at {50,0}) = [line([{0,0},{50,0}]), line([{50,0},{100,0}])]; - } -} +experiment OperatorsTest type: test { + test "add_point" { + assert (geometry(nil) add_point {20,20}) = nil; + assert ({10,10} add_point point(nil)) = {10,10}; + assert ({10,10} add_point {20,20}) = line([{10,10},{20,20}]); + assert (line([{10,10},{20,20}]) add_point {30,30}) = line([{10,10},{20,20},{30,30}]); + assert (line([{10,10},{20,20},{30,30}]) add_point {0,0}) = line([{0,0},{10,10},{20,20},{30,30}]); + assert (line([{10,10},{20,20},{30,30}]) add_point {25,22}) = line([{10,10},{20,20},{25,22},{30,30}]); + assert ((square(10) at_location {50,50}) add_point {50,35}) = polygon([{45,55}, {55,55}, {55,45}, {50,35},{45,45}]); + assert ((square(10) at_location {50,50}) add_point {50,50}) = polygon([{45,55}, {50,50}, {55,55},{55,45},{45,45}]); + } + test "inter" { + assert geometry(nil) inter {10,10} = nil; + assert {10,10} inter geometry(nil) = nil; + assert {10,10} inter {20,10} = nil; + assert {10,10} inter {10,10} = {10,10}; + assert line([{10,10},{20,20}]) inter {10,10} = {10,10}; + assert line([{10,10},{20,20}]) inter {20,10} = nil; + assert line([{10,10},{20,20}]) inter line([{5,5},{15,15}]) = line([{10,10},{15,15}]); + assert line([{10,5},{10,20}]) inter line([{5,15},{30,15}]) distance_to {10,15} < 0.1; + } + test "minus" { + assert geometry(nil) - {10,10} = nil; + assert geometry({10,10}) - geometry(nil) = {10,10}; + assert (square(10) - {10,10}).area = 100.0; + assert length((line([{0,10},{20,10}]) - line([{10,0},{10,25}])).geometries) = 2 ; + assert ((square(10) at_location {0,0}) - (square(10) at_location {5,0})) = polygon ([{-5,5},{0,5},{0,-5},{-5,-5}]); + } + test "union" { + assert geometry(nil) union {10,10} = {10,10} ; + assert {10,10} union geometry(nil) = {10,10} ; + assert union([line([{0,10},{20,10}]) , line([{20,10},{30,10}])]).perimeter = 30.0 ; + } + test "masked_by" { + } + test "split_at" { + assert (line([{0,0},{100,0}]) split_at {50,0}) = [line([{0,0},{50,0}]), line([{50,0},{100,0}])]; + } +} \ No newline at end of file diff --git a/msi.gama.parent/pom.xml b/msi.gama.parent/pom.xml index db0de4b91f..ee3628e0b5 100644 --- a/msi.gama.parent/pom.xml +++ b/msi.gama.parent/pom.xml @@ -297,7 +297,7 @@ 2.11.0-v20150123-0347 3.11.0.v20150405-1723 54.1.1 - 1.2 + 1.3.2 1 1.3.04 3.2 @@ -371,7 +371,7 @@ org.eclipse.tycho tycho-compiler-plugin - 2.1.0 + ${tycho.version} false 11 @@ -587,14 +587,7 @@ - - - - - - org.apache.maven.plugins - maven-dependency-plugin - + org.apache.maven.plugins maven-compiler-plugin @@ -623,7 +616,6 @@ - - + diff --git a/msi.gama.processor/src/msi/gama/precompiler/GamaProcessor.java b/msi.gama.processor/src/msi/gama/precompiler/GamaProcessor.java index 79ebf1e8cb..08f61d357b 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/GamaProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/GamaProcessor.java @@ -1,9 +1,7 @@ /********************************************************************************************* * * 'GamaProcessor.java, in plugin msi.gama.processor, is part of the source code of the GAMA modeling and simulation - * platform. (v. 1.8.1) - * - * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners + * platform. (c) 2007-2016 UMI 209 UMMISCO IRD/UPMC & Partners * * Visit https://github.com/gama-platform/gama for license information and developers contact. * @@ -13,7 +11,6 @@ import java.io.IOException; import java.io.Writer; -import java.util.Arrays; import java.util.Set; import javax.annotation.processing.AbstractProcessor; @@ -27,17 +24,24 @@ import javax.tools.Diagnostic.Kind; import javax.tools.FileObject; -import msi.gama.precompiler.GamlAnnotations.doc; import msi.gama.precompiler.GamlAnnotations.tests; -import msi.gama.precompiler.doc.DocProcessor; -import msi.gama.precompiler.tests.ExamplesToTests; import msi.gama.precompiler.tests.TestProcessor; + @SuppressWarnings ({ "unchecked", "rawtypes" }) @SupportedAnnotationTypes ({ "*" }) -@SupportedSourceVersion (SourceVersion.RELEASE_8) +@SupportedSourceVersion (SourceVersion.RELEASE_11) public class GamaProcessor extends AbstractProcessor implements Constants { +// public final static String[] IMPORTS = new String[] { "java.util", "java.lang", "gama.util.map", "gama.util.list", +// "gama.util.file", "gama.util.matrix", "gama.util.path", "gama.util.graph", "gama.util.random", +// "gama.util.tree", "gama.util", "gama.metamodel.agent", "gama.metamodel.population", "gama.metamodel.shape", +// "gaml.types", "gaml.skills", "gama.common.interfaces.batch", "gama.common.interfaces.experiment", +// "gama.common.interfaces.gui", "gama.common.interfaces.outputs", "gama.common.interfaces", +// "gama.runtime.scope", "gaml.operators.noisegeneration", "gaml.operators", "gama.kernel.batch", +// "gama.kernel.experiment", "gama.kernel.root", "gama.kernel.model", "gama.kernel.simulation", "gaml.species", +// "gaml.expressions" }; + public final static String[] IMPORTS = new String[] { "msi.gaml.extensions.multi_criteria", "msi.gama.outputs.layers.charts", "msi.gama.outputs.layers", "msi.gama.outputs", "msi.gama.kernel.batch", "msi.gama.kernel.root", "msi.gaml.architecture.weighted_tasks", "msi.gaml.architecture.user", @@ -62,7 +66,6 @@ public class GamaProcessor extends AbstractProcessor implements Constants { final StringBuilder sb = new StringBuilder(); writeImmutableHeader(sb); JAVA_HEADER = sb.toString(); - Arrays.sort(IMPORTS, (a, b) -> b.compareTo(a)); } @Override @@ -113,11 +116,8 @@ public void generateTests() { } } // We pass the current document of the documentation processor to avoir re-reading it - final DocProcessor dp = (DocProcessor) processors.get(doc.class); - // context.emit(Kind.NOTE, - // " GAML Tests: lone tests serialization took " + (System.currentTimeMillis() - begin) + "ms", - // (Element) null); - ExamplesToTests.createTests(context, dp.document); + // final DocProcessor dp = (DocProcessor) processors.get(doc.class); + // ExamplesToTests.createTests(context, dp.document); } public void generateJavaSource(final FileObject file) { @@ -134,7 +134,6 @@ public void generateJavaSource(final FileObject file) { } protected static void writeImmutableHeader(final StringBuilder sb) { - sb.append("package ").append(PACKAGE_NAME).append(';'); for (final String element : IMPORTS) { sb.append(ln).append("import ").append(element).append(".*;"); } @@ -144,8 +143,9 @@ protected static void writeImmutableHeader(final StringBuilder sb) { sb.append(ln).append("import static msi.gaml.operators.Cast.*;"); sb.append(ln).append("import static msi.gaml.operators.Spatial.*;"); sb.append(ln).append("import static msi.gama.common.interfaces.IKeyword.*;"); - sb.append(ln).append(" @SuppressWarnings({ \"rawtypes\", \"unchecked\", \"unused\" })"); - sb.append(ln).append(ln).append("public class GamlAdditions extends AbstractGamlAdditions").append(" {"); + sb.append(ln).append("@SuppressWarnings({ \"rawtypes\", \"unchecked\", \"unused\" })"); + sb.append(ln).append(ln).append("public class GamlAdditions extends msi.gaml.compilation.AbstractGamlAdditions") + .append(" {"); sb.append(ln).append(tab); sb.append("public void initialize() throws SecurityException, NoSuchMethodException {"); } @@ -164,7 +164,9 @@ protected void writeMutableHeader(final StringBuilder sb) { } public StringBuilder writeJavaBody() { - final StringBuilder sb = new StringBuilder(JAVA_HEADER); + final StringBuilder sb = new StringBuilder(); + sb.append("package ").append(PACKAGE_NAME).append(".").append(context.shortcut).append(';'); + sb.append(ln).append(JAVA_HEADER); writeMutableHeader(sb); processors.values().forEach(p -> { if (p.outputToJava() && p.hasElements()) { diff --git a/msi.gama.processor/src/msi/gama/precompiler/ProcessorContext.java b/msi.gama.processor/src/msi/gama/precompiler/ProcessorContext.java index c865ec247b..8b654db08a 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/ProcessorContext.java +++ b/msi.gama.processor/src/msi/gama/precompiler/ProcessorContext.java @@ -2,7 +2,7 @@ import static java.util.Collections.sort; -// import static msi.gama.precompiler.GamlProperties.GAML; +// import static gama.processor.annotations.GamlProperties.GAML; import java.io.IOException; import java.io.InputStream; @@ -41,13 +41,15 @@ public class ProcessorContext implements ProcessingEnvironment, RoundEnvironment, Constants { private final static boolean PRODUCES_DOC = true; public static final Charset CHARSET = Charset.forName("UTF-8"); - public static final String ADDITIONS = "gaml.additions.GamlAdditions"; + public static final String ADDITIONS_PACKAGE_BASE = "gaml.additions"; + public static final String ADDITIONS_CLASS_NAME = "GamlAdditions"; private final static boolean PRODUCES_WARNING = true; public static final StandardLocation OUT = StandardLocation.SOURCE_OUTPUT; private final ProcessingEnvironment delegate; private RoundEnvironment round; private TypeMirror iSkill, iAgent; public volatile String currentPlugin; + public volatile String shortcut; public List roots; public static final DocumentBuilder xmlBuilder; @@ -59,7 +61,7 @@ public class ProcessorContext implements ProcessingEnvironment, RoundEnvironment xmlBuilder = temp; } - ProcessorContext(final ProcessingEnvironment pe) { + public ProcessorContext(final ProcessingEnvironment pe) { delegate = pe; } @@ -68,7 +70,8 @@ public DocumentBuilder getBuilder() { } public String nameOf(final TypeElement e) { - if (e.getNestingKind() == NestingKind.TOP_LEVEL) { return e.getQualifiedName().toString(); } + if (e.getNestingKind() == NestingKind.TOP_LEVEL) + return e.getQualifiedName().toString(); return nameOf((TypeElement) e.getEnclosingElement()) + "." + e.getSimpleName().toString(); } @@ -98,9 +101,8 @@ private String getRootClassOf(final Element e) { final Element enclosing = e.getEnclosingElement(); final ElementKind enclosingKind = enclosing.getKind(); if ((kind == ElementKind.CLASS || kind == ElementKind.INTERFACE) - && !(enclosingKind == ElementKind.CLASS || enclosingKind == ElementKind.INTERFACE)) { + && !(enclosingKind == ElementKind.CLASS || enclosingKind == ElementKind.INTERFACE)) return e.toString(); - } return getRootClassOf(enclosing); } @@ -170,7 +172,8 @@ public void emitError(final String s, final Element e) { } public void emit(final Kind kind, final String s, final Element e) { - if (!PRODUCES_WARNING) { return; } + if (!PRODUCES_WARNING) + return; if (e == null) { getMessager().printMessage(kind, s); } else { @@ -246,13 +249,25 @@ public Writer createWriter(final String s) { return null; } - FileObject createSource() { + void initCurrentPlugin() { try { - final FileObject obj = getFiler().createSourceFile(ADDITIONS, (Element[]) null); - // To accomodate for different classpaths in Maven and Eclipse - final String plugin2 = obj.toUri().toASCIIString().replace("/target/gaml/additions/GamlAdditions.java", "") - .replace("/gaml/gaml/additions/GamlAdditions.java", ""); + final FileObject temp = getFiler().createSourceFile("gaml.additions.package-info", (Element[]) null); + emit(Kind.NOTE, "GAML Processor: creating " + temp.toUri(), (Element) null); + final String plugin2 = temp.toUri().toASCIIString().replace("/target/gaml/additions/package-info.java", "") + .replace("/gaml/gaml/additions/package-info.java", ""); currentPlugin = plugin2.substring(plugin2.lastIndexOf('/') + 1); + shortcut = currentPlugin.substring(currentPlugin.lastIndexOf('.') + 1); + } catch (IOException e) { + emitWarning("Exception raised while reading the current plugin name " + e.getMessage(), e); + } + } + + public FileObject createSource() { + initCurrentPlugin(); + try { + + final FileObject obj = getFiler().createSourceFile( + ADDITIONS_PACKAGE_BASE + "." + shortcut + "." + ADDITIONS_CLASS_NAME, (Element[]) null); return obj; } catch (final Exception e) { emitWarning("Exception raised while creating the source file: " + e.getMessage(), e); @@ -318,7 +333,7 @@ public void createTestsFolder() { } } - Writer createSourceWriter(final FileObject file) { + public Writer createSourceWriter(final FileObject file) { try { final OutputStream output = file.openOutputStream(); final Writer writer = new OutputStreamWriter(output, CHARSET); 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 7896d49ccb..75669232e7 100644 --- a/msi.gama.processor/src/msi/gama/precompiler/doc/DocProcessor.java +++ b/msi.gama.processor/src/msi/gama/precompiler/doc/DocProcessor.java @@ -1,8 +1,8 @@ /********************************************************************************************* * * 'GamlDocProcessor.java, in plugin msi.gama.processor, is part of the source code of the GAMA modeling and simulation - * platform. (v. 1.8.1) - * + * platform. (v. 1.8.1) + * * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners * * Visit https://github.com/gama-platform/gama for license information and developers contact. diff --git a/ummisco.gama.annotations/src/msi/gama/common/interfaces/IKeyword.java b/ummisco.gama.annotations/src/msi/gama/common/interfaces/IKeyword.java index 81991178a9..79098cc54d 100644 --- a/ummisco.gama.annotations/src/msi/gama/common/interfaces/IKeyword.java +++ b/ummisco.gama.annotations/src/msi/gama/common/interfaces/IKeyword.java @@ -1,8 +1,8 @@ /********************************************************************************************* * * 'IKeyword.java, in plugin ummisco.gama.annotations, is part of the source code of the GAMA modeling and simulation - * platform. (v. 1.8.1) - * + * platform. (v. 1.8.1) + * * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners * * Visit https://github.com/gama-platform/gama for license information and developers contact. diff --git a/ummisco.gama.annotations/src/msi/gama/common/interfaces/INamed.java b/ummisco.gama.annotations/src/msi/gama/common/interfaces/INamed.java index 4338de3a67..6492843374 100644 --- a/ummisco.gama.annotations/src/msi/gama/common/interfaces/INamed.java +++ b/ummisco.gama.annotations/src/msi/gama/common/interfaces/INamed.java @@ -1,8 +1,8 @@ /********************************************************************************************* * * 'INamed.java, in plugin ummisco.gama.annotations, is part of the source code of the GAMA modeling and simulation - * platform. (v. 1.8.1) - * + * platform. (v. 1.8.1) + * * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners * * Visit https://github.com/gama-platform/gama for license information and developers contact. diff --git a/ummisco.gama.annotations/src/msi/gama/precompiler/GamlAnnotations.java b/ummisco.gama.annotations/src/msi/gama/precompiler/GamlAnnotations.java index 5088c635b9..29eff5731a 100644 --- a/ummisco.gama.annotations/src/msi/gama/precompiler/GamlAnnotations.java +++ b/ummisco.gama.annotations/src/msi/gama/precompiler/GamlAnnotations.java @@ -1,8 +1,8 @@ /********************************************************************************************* * * 'GamlAnnotations.java, in plugin ummisco.gama.annotations, is part of the source code of the GAMA modeling and - * simulation platform. (v. 1.8.1) - * + * simulation platform. (v. 1.8.1) + * * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners * * Visit https://github.com/gama-platform/gama for license information and developers contact. diff --git a/ummisco.gama.feature.dependencies/feature.xml b/ummisco.gama.feature.dependencies/feature.xml index 00027366b0..03358396d1 100644 --- a/ummisco.gama.feature.dependencies/feature.xml +++ b/ummisco.gama.feature.dependencies/feature.xml @@ -1399,12 +1399,4 @@ install-size="0" version="0.0.0"/> - -