Skip to content

Commit

Permalink
Rename useSkylarkSemantics to useStarlarkSemantics
Browse files Browse the repository at this point in the history
RELNOTES: None.
PiperOrigin-RevId: 253027175
  • Loading branch information
laurentlb authored and siberex committed Jul 4, 2019
1 parent 0740e70 commit 7df45eb
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ ConfigurationTransitionApi transition(
+ "an analysis test requires to be set in order to pass."),
},
useLocation = true,
useSkylarkSemantics = true)
useStarlarkSemantics = true)
public ConfigurationTransitionApi analysisTestTransition(
SkylarkDict<String, String> changedSettings, Location location, StarlarkSemantics semantics)
throws EvalException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public JavaInfoT createJavaCompileAction(
allowedTypes = {@ParamType(type = JavaToolchainSkylarkApiProviderApi.class)},
doc = "A JavaToolchainInfo to used to find the ijar tool."),
},
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true)
public FileApi runIjar(
SkylarkActionFactoryT actions,
Expand Down Expand Up @@ -424,7 +424,7 @@ public FileApi runIjar(
allowedTypes = {@ParamType(type = JavaToolchainSkylarkApiProviderApi.class)},
doc = "A JavaToolchainInfo to used to find the stamp_jar tool."),
},
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true)
public FileApi stampJar(
SkylarkActionFactoryT actions,
Expand Down Expand Up @@ -486,7 +486,7 @@ public FileApi stampJar(
doc = "A JavaRuntimeInfo to be used for packing sources."),
},
allowReturnNones = true,
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true)
public FileApi packSources(
SkylarkActionFactoryT actions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface JavaSkylarkApiProviderApi<FileT extends FileApi> {
@SkylarkCallable(
name = "source_jars",
doc = "Returns the Jars containing Java source files for the target.",
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true,
structField = true)
public NestedSet<FileT> getSourceJars(Location location, StarlarkSemantics semantics)
Expand All @@ -51,7 +51,7 @@ public NestedSet<FileT> getSourceJars(Location location, StarlarkSemantics seman
@SkylarkCallable(
name = "transitive_deps",
doc = "Returns the transitive set of Jars required to build the target.",
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true,
structField = true)
public NestedSet<FileT> getTransitiveDeps(Location location, StarlarkSemantics semantics)
Expand All @@ -60,7 +60,7 @@ public NestedSet<FileT> getTransitiveDeps(Location location, StarlarkSemantics s
@SkylarkCallable(
name = "transitive_runtime_deps",
doc = "Returns the transitive set of Jars required on the target's runtime classpath.",
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true,
structField = true)
public NestedSet<FileT> getTransitiveRuntimeDeps(Location location, StarlarkSemantics semantics)
Expand All @@ -71,7 +71,7 @@ public NestedSet<FileT> getTransitiveRuntimeDeps(Location location, StarlarkSema
doc =
"Returns the Jars containing Java source files for the target and all of its transitive "
+ "dependencies.",
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true,
structField = true)
public NestedSet<FileT> getTransitiveSourceJars(Location location, StarlarkSemantics semantics)
Expand All @@ -80,7 +80,7 @@ public NestedSet<FileT> getTransitiveSourceJars(Location location, StarlarkSeman
@SkylarkCallable(
name = "outputs",
doc = "Returns information about outputs of this Java target.",
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true,
structField = true)
public JavaRuleOutputJarsProviderApi<?> getOutputJars(
Expand All @@ -89,7 +89,7 @@ public JavaRuleOutputJarsProviderApi<?> getOutputJars(
@SkylarkCallable(
name = "transitive_exports",
structField = true,
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true,
doc = "Returns transitive set of labels that are being exported from this rule.")
public NestedSet<Label> getTransitiveExports(Location location, StarlarkSemantics semantics)
Expand All @@ -99,7 +99,7 @@ public NestedSet<Label> getTransitiveExports(Location location, StarlarkSemantic
name = "annotation_processing",
structField = true,
allowReturnNones = true,
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true,
doc = "Returns information about annotation processing for this Java target.")
public JavaAnnotationProcessingApi<?> getGenJarsProvider(
Expand All @@ -109,7 +109,7 @@ public JavaAnnotationProcessingApi<?> getGenJarsProvider(
name = "compilation_info",
structField = true,
allowReturnNones = true,
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useLocation = true,
doc = "Returns compilation information for this Java target.")
public JavaCompilationInfoProviderApi<?> getCompilationInfoProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import java.lang.annotation.Target;

/**
* Annotates a Java method that can be called from Skylark.
* Annotates a Java method that can be called from Starlark.
*
* <p>This annotation is only allowed to appear on methods of classes that are directly annotated
* with {@link SkylarkModule} or {@link SkylarkGlobalLibrary}. Since subtypes can't add new
* Skylark-accessible methods unless they have their own {@code @SkylarkModule} annotation, this
* implies that you can always determine the complete set of Skylark entry points for a given {@link
* SkylarkValue} type by looking at the ancestor class or interface from which it inherits its
* {@code @SkylarkModule}.
* Starlark-accessible methods unless they have their own {@code @SkylarkModule} annotation, this
* implies that you can always determine the complete set of Starlark entry points for a given
* {@link StarlarkValue} type by looking at the ancestor class or interface from which it inherits
* its {@code @SkylarkModule}.
*
* <p>If a method is annotated with {@code @SkylarkCallable}, it is not allowed to have any
* overloads or hide any static or default methods. Overriding is allowed, but the
Expand All @@ -50,7 +50,7 @@
* where (extra positionals list) is a SkylarkList if extraPositionals is defined, (extra
* kwargs) is a SkylarkDict if extraKeywords is defined, and Location, FuncallExpression,
* Environment, and StarlarkSemantics are supplied by the interpreter if and only if
* useLocation, useAst, useEnvironment, and useSkylarkSemantics are specified, respectively.
* useLocation, useAst, useEnvironment, and useStarlarkSemantics are specified, respectively.
* <li>The number of method parameters much match the number of annotation-declared parameters
* plus the number of interpreter-supplied parameters.
* </ul>
Expand All @@ -59,20 +59,18 @@
@Retention(RetentionPolicy.RUNTIME)
public @interface SkylarkCallable {

/**
* Name of the method, as exposed to Skylark.
*/
/** Name of the method, as exposed to Starlark. */
String name();

/**
* The documentation text in Skylark. It can contain HTML tags for special formatting.
* The documentation text in Starlark. It can contain HTML tags for special formatting.
*
* <p>It is allowed to be empty only if {@link #documented()} is false.
*/
String doc() default "";

/**
* If true, the function will appear in the Skylark documentation. Set this to false if the
* If true, the function will appear in the Starlark documentation. Set this to false if the
* function is experimental or an overloading and doesn't need to be documented.
*/
boolean documented() default true;
Expand Down Expand Up @@ -120,13 +118,13 @@

/**
* If true, indicates that the class containing the annotated method has the ability to be called
* from skylark (as if it were a function) and that the annotated method should be invoked when
* from Starlark (as if it were a function) and that the annotated method should be invoked when
* this occurs.
*
* <p>A class may only have one method with selfCall set to true.</p>
* <p>A class may only have one method with selfCall set to true.
*
* <p>A method with selfCall=true must not be a structField, and must have name specified
* (used for descriptive errors if, for example, there are missing arguments).</p>
* <p>A method with selfCall=true must not be a structField, and must have name specified (used
* for descriptive errors if, for example, there are missing arguments).
*/
boolean selfCall() default false;

Expand Down Expand Up @@ -155,7 +153,7 @@
boolean useAst() default false;

/**
* If true, the Skylark Environment will be passed as an argument of the annotated function.
* If true, the Starlark Environment will be passed as an argument of the annotated function.
* (Thus, the annotated method signature must contain Environment as a parameter. See the
* interface-level javadoc for details.)
*
Expand All @@ -164,11 +162,11 @@
boolean useEnvironment() default false;

/**
* If true, the Skylark semantics will be passed as an argument of the annotated function. (Thus,
* If true, the Starlark semantics will be passed as an argument of the annotated function. (Thus,
* the annotated method signature must contain StarlarkSemantics as a parameter. See the
* interface-level javadoc for details.)
*/
boolean useSkylarkSemantics() default false;
boolean useStarlarkSemantics() default false;

/**
* If true, StarlarkContext will be passed as an argument of the annotated function. (Thus, the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,16 +439,16 @@ private void verifyExtraInterpreterParams(ExecutableElement methodElement,
}
currentIndex++;
}
if (annotation.useSkylarkSemantics()) {
if (annotation.useStarlarkSemantics()) {
if (!STARLARK_SEMANTICS.equals(methodSignatureParams.get(currentIndex).asType().toString())) {
throw new SkylarkCallableProcessorException(
methodElement,
String.format(
"Expected parameter index %d to be the %s type, matching useSkylarkSemantics, "
"Expected parameter index %d to be the %s type, matching useStarlarkSemantics, "
+ "but was %s",
currentIndex,
STARLARK_SEMANTICS,
methodSignatureParams.get(currentIndex).asType().toString()));
methodSignatureParams.get(currentIndex).asType()));
}
currentIndex++;
}
Expand All @@ -471,7 +471,7 @@ private int numExpectedExtraInterpreterParams(SkylarkCallable annotation) {
numExtraInterpreterParams += annotation.useLocation() ? 1 : 0;
numExtraInterpreterParams += annotation.useAst() ? 1 : 0;
numExtraInterpreterParams += annotation.useEnvironment() ? 1 : 0;
numExtraInterpreterParams += annotation.useSkylarkSemantics() ? 1 : 0;
numExtraInterpreterParams += annotation.useStarlarkSemantics() ? 1 : 0;
numExtraInterpreterParams += annotation.useContext() ? 1 : 0;
return numExtraInterpreterParams;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final class MethodDescriptor {
private final boolean useLocation;
private final boolean useAst;
private final boolean useEnvironment;
private final boolean useSkylarkSemantics;
private final boolean useStarlarkSemantics;
private final boolean useContext;

private MethodDescriptor(
Expand All @@ -64,7 +64,7 @@ private MethodDescriptor(
boolean useLocation,
boolean useAst,
boolean useEnvironment,
boolean useSkylarkSemantics,
boolean useStarlarkSemantics,
boolean useContext) {
this.method = method;
this.annotation = annotation;
Expand All @@ -80,7 +80,7 @@ private MethodDescriptor(
this.useLocation = useLocation;
this.useAst = useAst;
this.useEnvironment = useEnvironment;
this.useSkylarkSemantics = useSkylarkSemantics;
this.useStarlarkSemantics = useStarlarkSemantics;
this.useContext = useContext;
}

Expand Down Expand Up @@ -112,7 +112,7 @@ public static MethodDescriptor of(
annotation.useLocation(),
annotation.useAst(),
annotation.useEnvironment(),
annotation.useSkylarkSemantics(),
annotation.useStarlarkSemantics(),
annotation.useContext());
}

Expand Down Expand Up @@ -195,9 +195,9 @@ public boolean isUseEnvironment() {
return useEnvironment;
}

/** @see SkylarkCallable#useSkylarkSemantics() */
/** @see SkylarkCallable#useStarlarkSemantics() */
boolean isUseSkylarkSemantics() {
return useSkylarkSemantics;
return useStarlarkSemantics;
}

/** See {@link SkylarkCallable#useContext()}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public String structFieldMethod() {
name = "struct_field_method_with_info",
documented = false,
structField = true,
useSkylarkSemantics = true)
useStarlarkSemantics = true)
public String structFieldMethodWithInfo(StarlarkSemantics semantics) {
return "foo";
}
Expand All @@ -66,7 +66,7 @@ public Integer zeroArgMethod(Environment environment) {
useAst = true,
useLocation = true,
useEnvironment = true,
useSkylarkSemantics = true)
useStarlarkSemantics = true)
public Integer zeroArgMethod(
Location location,
FuncallExpression ast,
Expand Down Expand Up @@ -116,7 +116,7 @@ public String threeArgMethod(String one, Integer two, Object three) {
useAst = true,
useLocation = true,
useEnvironment = true,
useSkylarkSemantics = true)
useStarlarkSemantics = true)
public String threeArgMethodWithParams(
String one,
Integer two,
Expand Down Expand Up @@ -165,7 +165,7 @@ public String manyArgMethodMixingPositoinalAndNamed(
useAst = true,
useLocation = true,
useEnvironment = true,
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useContext = true)
public String twoArgMethodWithParamsAndInfoAndKwargs(
String one,
Expand Down Expand Up @@ -218,7 +218,7 @@ public Integer selfCallMethod(String one, Integer two) {
structField = true,
useLocation = true,
useEnvironment = true,
useSkylarkSemantics = true)
useStarlarkSemantics = true)
public String structFieldMethodWithInfo(
Location location, Environment environment, StarlarkSemantics starlarkSemantics) {
return "dragon";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public String structField() {
name = "struct_field_with_extra",
documented = false,
structField = true,
useSkylarkSemantics = true)
useStarlarkSemantics = true)
public String structFieldWithExtra(StarlarkSemantics sem) {
return "struct_field_with_extra("
+ (sem != null)
Expand Down Expand Up @@ -316,7 +316,7 @@ public String withParams(
useLocation = true,
useAst = true,
useEnvironment = true,
useSkylarkSemantics = true,
useStarlarkSemantics = true,
useContext = true)
public String withExtraInterpreterParams(
Location location,
Expand Down Expand Up @@ -384,7 +384,7 @@ public String withExtraInterpreterParams(
useAst = true,
useLocation = true,
useEnvironment = true,
useSkylarkSemantics = true)
useStarlarkSemantics = true)
public String withParamsAndExtraInterpreterParams(
Integer pos1,
boolean pos2,
Expand Down

0 comments on commit 7df45eb

Please sign in to comment.