Permalink
Browse files

Fixes #2014 by emitting a warning at compilation time in Java.

Signed-off-by: AlexisDrogoul <alexis.drogoul@gmail.com>
  • Loading branch information...
1 parent aab1cf0 commit 09cbca4f12d77bb68d5f9480476389e6a1862ecc @AlexisDrogoul AlexisDrogoul committed Nov 9, 2016
@@ -991,6 +991,8 @@ public void processOperators(final RoundEnvironment env) {
}
}
+ private static Set<String> RESERVED_FACETS = new HashSet(Arrays.asList("name", "keyword", "returns"));
+
// Format: prefix 0.method 1.declClass 2.retClass 3.name 4.nbArgs 5.[arg]*
void processActions(final RoundEnvironment env) {
for (final Element e : sortElements(env, action.class)) {
@@ -1036,12 +1038,19 @@ void processActions(final RoundEnvironment env) {
if (args.length > 0) {
for (int i = 0; i < args.length; i++) {
final arg arg = args[i];
- sb.append(arg.name()).append(SEP);
+ final String argName = arg.name();
+ if (RESERVED_FACETS.contains(argName)) {
+ emitWarning(
+ "Argument " + argName
+ + " will prevent this primitive to be called using facets (e.g. 'do action arg1: val1 arg2: val2;'). Consider renaming it to a non-reserved facet keyword",
+ e);
+ }
+ sb.append(argName).append(SEP);
sb.append(arg.type()).append(SEP);
sb.append(arg.optional()).append(SEP);
final doc[] docs = arg.doc();
if (docs.length == 0) {
- emitWarning("GAML: argument '" + arg.name() + "' is not documented", e);
+ emitWarning("GAML: argument '" + argName + "' is not documented", e);
}
sb.append(docToString(arg.doc())).append(SEP);
strings.add(args[i].name());
@@ -1,8 +1,7 @@
/*********************************************************************************************
*
- * 'ITypeProvider.java, in plugin ummisco.gama.annotations, is part of the source code of the
- * GAMA modeling and simulation platform.
- * (c) 2007-2016 UMI 209 UMMISCO IRD/UPMC & Partners
+ * 'ITypeProvider.java, in plugin ummisco.gama.annotations, is part of the source code of the GAMA modeling and
+ * simulation platform. (c) 2007-2016 UMI 209 UMMISCO IRD/UPMC & Partners
*
* Visit https://github.com/gama-platform/gama for license information and developers contact.
*
@@ -19,32 +18,28 @@
public interface ITypeProvider {
/*
- * The content type is provided by the content type of the first child of
- * the expression
+ * The content type is provided by the content type of the first child of the expression
*/
static final int FIRST_CONTENT_TYPE = -20;
static final int OWNER_CONTENT_TYPE = FIRST_CONTENT_TYPE;
static final int FIRST_KEY_TYPE = -23;
static final int OWNER_KEY_TYPE = FIRST_KEY_TYPE;
/*
- * The content type is provided by the content type of the second child of
- * the expression
+ * The content type is provided by the content type of the second child of the expression
*/
static final int SECOND_CONTENT_TYPE = -19;
static final int SECOND_KEY_TYPE = -24;
+ static final int SECOND_DENOTED_TYPE = -32;
/*
- * The content type is provided by the type of the first child of the
- * expression
+ * The content type is provided by the type of the first child of the expression
*/
static final int FIRST_TYPE = -18;
/**
- * For variables, represents the type of the owner (i.e. the species)
- * holding this attribute
+ * For variables, represents the type of the owner (i.e. the species) holding this attribute
*/
static final int OWNER_TYPE = FIRST_TYPE;
/*
- * The content type is provided by the type of the second child of the
- * expression
+ * The content type is provided by the type of the second child of the expression
*/
static final int SECOND_TYPE = -17;
static final int SECOND_CONTENT_TYPE_OR_TYPE = -25;
@@ -56,8 +51,7 @@
static final int MODEL_TYPE = -27;
/**
- * The generic type experiment (which does not exist as a type -- at least
- * not yet)
+ * The generic type experiment (which does not exist as a type -- at least not yet)
*/
static final int EXPERIMENT_TYPE = -31;
/**
@@ -73,32 +67,28 @@
*/
static final int WRAPPED = -30;
/*
- * The content type is provided by the type of the expression itself (i.e.
- * species)
+ * The content type is provided by the type of the expression itself (i.e. species)
*/
static final int TYPE = -14;
/*
* The content type cannot be computed
*/
static final int NONE = -13;
/*
- * The type or content type are provided by both or all operands (which must
- * match).
+ * The type or content type are provided by both or all operands (which must match).
*/
static final int BOTH = -21;
static final int ALL = BOTH;
/*
- * The content type is provided by the content type of the first element of
- * the child (if the child is a container) -- EXPERIMENTAL RIGHT NOW (and
- * probably limited to the matrix and as_matrix operators) e.g. : matrix
- * ([[4, 5, 6],[1, 2, 4]]) should get int as a content type.
+ * The content type is provided by the content type of the first element of the child (if the child is a container)
+ * -- EXPERIMENTAL RIGHT NOW (and probably limited to the matrix and as_matrix operators) e.g. : matrix ([[4, 5,
+ * 6],[1, 2, 4]]) should get int as a content type.
*/
static final int FIRST_ELEMENT_CONTENT_TYPE = -22;
/**
- * The type, content type, key type are provided by the element computed by
- * its index. 0 for the first element, 1 for the second, etc. For instance,
- * TYPE_AT_INDEX + 2 will represent the third argument
+ * The type, content type, key type are provided by the element computed by its index. 0 for the first element, 1
+ * for the second, etc. For instance, TYPE_AT_INDEX + 2 will represent the third argument
*/
static final int INDEXED_TYPES = -100;
static final int TYPE_AT_INDEX = -200;

0 comments on commit 09cbca4

Please sign in to comment.