Skip to content

On branch edburns/11556-duplicate-closing-punctuation-in-compiler-mes… #11557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static class ConcealedOptions {
}

public static class DeprecatedOptions {
@Option(help = "Ignore the maximum heap size while in VM-internal code. Serial GC only.", type = OptionType.Expert, deprecated = true, deprecationMessage = "Please use the option 'IgnoreMaxHeapSizeWhileInVMInternalCode' instead.")//
@Option(help = "Ignore the maximum heap size while in VM-internal code. Serial GC only.", type = OptionType.Expert, deprecated = true, deprecationMessage = "Please use the option 'IgnoreMaxHeapSizeWhileInVMInternalCode' instead")//
public static final HostedOptionKey<Boolean> IgnoreMaxHeapSizeWhileInVMOperation = new HostedOptionKey<>(false, SerialGCOptions::validateSerialHostedOption) {
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ public static boolean hasColorsEnabled(OptionValues values) {
@Option(help = "Deprecated, option no longer has any effect.", type = OptionType.User, deprecated = true, deprecationMessage = "It no longer has any effect, and no replacement is available")//
public static final HostedOptionKey<Boolean> BuildOutputPrefix = new HostedOptionKey<>(false);

@Option(help = "Color build output (enabled by default if colors are supported by terminal)", type = OptionType.User, deprecated = true, deprecationMessage = "Please use '--color' instead.")//
@Option(help = "Color build output (enabled by default if colors are supported by terminal)", type = OptionType.User, deprecated = true, deprecationMessage = "Please use '--color' instead")//
public static final HostedOptionKey<Boolean> BuildOutputColorful = new HostedOptionKey<>(false);

@Option(help = "Show links in build output (defaults to the value of BuildOutputColorful)", type = OptionType.User)//
Expand Down Expand Up @@ -1516,7 +1516,7 @@ public static class TruffleStableOptions {
public static final HostedOptionKey<Boolean> ReduceImplicitExceptionStackTraceInformation = new HostedOptionKey<>(false);

@Option(help = "Allow all instantiated types to be allocated via Unsafe.allocateInstance().", type = OptionType.Expert, //
deprecated = true, deprecationMessage = "ThrowMissingRegistrationErrors is the preferred way of configuring this on a per-type level.") //
deprecated = true, deprecationMessage = "ThrowMissingRegistrationErrors is the preferred way of configuring this on a per-type level") //
public static final HostedOptionKey<Boolean> AllowUnsafeAllocationOfAllInstantiatedTypes = new HostedOptionKey<>(null);

@Option(help = "Enable fallback to mremap for initializing the image heap.")//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static final class Options {
AccumulatingLocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing program elements to be made available for reflection (see ProxyConfigurationFiles).", type = OptionType.User, deprecated = true, //
deprecationMessage = "This can be caused by a proxy-config.json file in your META-INF directory. " +
"Consider including proxy configuration in the reflection section of reachability-metadata.md instead.")//
"Consider including proxy configuration in the reflection section of reachability-metadata.md instead")//
public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> DynamicProxyConfigurationResources = new HostedOptionKey<>(
AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void parseOptionAtRuntime(String arg, String optionPrefix, BooleanOptionF
// Checkstyle: Allow raw info or warning printing - end
String deprecationMessage = descriptor.getDeprecationMessage();
if (deprecationMessage != null && !deprecationMessage.isEmpty()) {
log.string(": ").string(deprecationMessage);
log.string(": ").string(deprecationMessage).string(".");
}
log.newline();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
};

@Option(help = "Uses the native architecture, i.e., the architecture of a machine that builds an image.", type = User, //
deprecated = true, deprecationMessage = "Please use '-march=native' instead. See '--help' for details.") //
deprecated = true, deprecationMessage = "Please use '-march=native' instead. See '--help' for details") //
public static final HostedOptionKey<Boolean> NativeArchitecture = new HostedOptionKey<>(false) {
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) {
Expand Down Expand Up @@ -231,7 +231,7 @@ public static void setCommonPoolParallelism(OptionValues optionValues) {
}
}

@Option(help = "Deprecated, option no longer has any effect", deprecated = true, deprecationMessage = "Please use '--parallelism' instead.")//
@Option(help = "Deprecated, option no longer has any effect", deprecated = true, deprecationMessage = "Please use '--parallelism' instead")//
public static final HostedOptionKey<Integer> NumberOfAnalysisThreads = new HostedOptionKey<>(-1);

@Option(help = "Return after analysis")//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static class Options {
public static final HostedOptionKey<Boolean> AddAllCharsets = new HostedOptionKey<>(false);

@Option(help = "Default locale of the image, by the default it is the same as the default locale of the image builder.", type = OptionType.User, //
deprecated = true, deprecationMessage = "Please switch to using system properties such as '-Duser.country=CH -Duser.language=de'.")//
deprecated = true, deprecationMessage = "Please switch to using system properties such as '-Duser.country=CH -Duser.language=de'")//
public static final HostedOptionKey<String> DefaultLocale = new HostedOptionKey<>(Locale.getDefault().toLanguageTag());

@Option(help = "Default charset of the image, by the default it is the same as the default charset of the image builder.", type = OptionType.User)//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,49 @@ public void testOptionValueEqualsAndHashCode() {

}

@Test
public void testNoClosingPunctuationInDeprecationMessage() {
TruffleTestAssumptions.assumeWeakEncapsulation();
Engine engine = createEngineBuilder().build();

// Test languages
for (String languageId : engine.getLanguages().keySet()) {
OptionDescriptors descriptors = engine.getLanguages().get(languageId).getOptions();
checkDescriptorsForClosingPunctuation(descriptors);
}

// Test instruments
for (String instrumentId : engine.getInstruments().keySet()) {
OptionDescriptors descriptors = engine.getInstruments().get(instrumentId).getOptions();
checkDescriptorsForClosingPunctuation(descriptors);
}

// Test explicit test cases for bad deprecation messages
OptionDescriptors descriptors = engine.getLanguages().get("optiontestlang2").getOptions();
OptionDescriptor deprecatedWithPeriod = descriptors.get("optiontestlang2.DeprecatedWithPeriod");
if (deprecatedWithPeriod != null) {
String message = deprecatedWithPeriod.getDeprecationMessage();
assertFalse("Deprecation message should not end with period: " + message,
message != null && message.endsWith("."));
}
}

private void checkDescriptorsForClosingPunctuation(OptionDescriptors descriptors) {
for (OptionDescriptor descriptor : descriptors) {
if (descriptor.isDeprecated()) {
String message = descriptor.getDeprecationMessage();
if (message != null && !message.isEmpty()) {
assertFalse("Deprecation message should not end with period: " + message,
message.endsWith("."));
assertFalse("Deprecation message should not end with exclamation mark: " + message,
message.endsWith("!"));
assertFalse("Deprecation message should not end with question mark: " + message,
message.endsWith("?"));
}
}
}
}

private static OptionValues getOptionValues(Context c) {
c.enter();
try {
Expand Down Expand Up @@ -444,17 +487,17 @@ public static class OptionError {
static final OptionKey<OptionMap<String>> Error9 = OptionKey.mapOf(String.class);

@ExpectError("Deprecation message can be specified only for deprecated options.") //
@Option(help = "A", category = OptionCategory.USER, deprecationMessage = "Deprecated with no replacement.") //
@Option(help = "A", category = OptionCategory.USER, deprecationMessage = "Deprecated with no replacement") //
static final OptionKey<String> Error10 = new OptionKey<>("defaultValue");

@ExpectError("Option deprecation message must start with upper case letter.") //
@Option(help = "A", category = OptionCategory.USER, deprecated = true, deprecationMessage = "deprecated with no replacement.") //
@Option(help = "A", category = OptionCategory.USER, deprecated = true, deprecationMessage = "deprecated with no replacement") //
static final OptionKey<String> Error11 = new OptionKey<>("defaultValue");

@Option(help = "A", name = "", deprecated = true, category = OptionCategory.USER) //
static final OptionKey<String> EmptyNameAllowed = new OptionKey<>("defaultValue");

@Option(help = "A", category = OptionCategory.USER, deprecated = true, deprecationMessage = "Deprecated with no replacement.") //
@Option(help = "A", category = OptionCategory.USER, deprecated = true, deprecationMessage = "Deprecated with no replacement") //
static final OptionKey<String> ValidDeprecationMessage = new OptionKey<>("defaultValue");

}
Expand Down Expand Up @@ -545,6 +588,38 @@ public static Env getCurrentContext() {

}

@Registration(id = OptionTestLang2.ID, version = "1.0", name = OptionTestLang2.ID)
public static class OptionTestLang2 extends TruffleLanguage<Env> {

public static final String ID = "optiontestlang2";

@Option(help = "Option with bad deprecation message", category = OptionCategory.USER, deprecated = true, deprecationMessage = "This message incorrectly ends with a period.")
static final OptionKey<String> DeprecatedWithPeriod = new OptionKey<>("test");

@Option(help = "Option with bad deprecation message", category = OptionCategory.USER, deprecated = true, deprecationMessage = "This message incorrectly ends with an exclamation mark!")
static final OptionKey<String> DeprecatedWithExclamation = new OptionKey<>("test");

@Option(help = "Option with good deprecation message", category = OptionCategory.USER, deprecated = true, deprecationMessage = "This message correctly omits closing punctuation")
static final OptionKey<String> DeprecatedWithGoodMessage = new OptionKey<>("test");

@Override
protected OptionDescriptors getOptionDescriptors() {
return new OptionTestLang2OptionDescriptors();
}

@Override
protected Env createContext(Env env) {
return env;
}

private static final ContextReference<Env> REFERENCE = ContextReference.create(OptionTestLang2.class);

public static Env getCurrentContext() {
return REFERENCE.get(null);
}

}

@TruffleInstrument.Registration(id = "optiontestinstr1", services = OptionValues.class)
public static class OptionTestInstrument1 extends TruffleInstrument {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
boolean deprecated() default false;

/**
* Returns the deprecation reason and the recommended fix. The generated option descriptor
* Returns the deprecation reason and the recommended fix. Do not include closing punctuation. The generated option descriptor
* returns this value as result of {@link OptionDescriptor#getDeprecationMessage()}.
*
* @since 20.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ final class PolyglotEngineOptions {

@Option(category = OptionCategory.INTERNAL, stability = OptionStability.EXPERIMENTAL, help = "Enables conservative context references. " +
"This allows invalid sharing between contexts. " +
"For testing purposes only.", deprecated = true, deprecationMessage = "Has no longer any effect. Scheduled for removal in in 22.1.")//
"For testing purposes only.", deprecated = true, deprecationMessage = "Has no longer any effect. Scheduled for removal in in 22.1")//
static final OptionKey<Boolean> UseConservativeContextReferences = new OptionKey<>(false);

@Option(category = OptionCategory.INTERNAL, stability = OptionStability.EXPERIMENTAL, help = "Enables specialization statistics for nodes generated with Truffle DSL and prints the result on exit. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public class WasmOptions {
public static final OptionKey<String> Builtins = new OptionKey<>("");

@Option(help = "The minimal binary size for which to use async parsing. If threads are not supported, async parsing will not be used.", category = OptionCategory.USER, stability = OptionStability.STABLE, usageSyntax = "[0, inf)", //
deprecated = true, deprecationMessage = "Option no longer has any effect and can be safely omitted.")//
deprecated = true, deprecationMessage = "Option no longer has any effect and can be safely omitted")//
public static final OptionKey<Integer> AsyncParsingBinarySize = new OptionKey<>(100_000);

@Option(help = "The stack size in kilobytes to use during async parsing, or zero to use defaults.", category = OptionCategory.USER, stability = OptionStability.STABLE, usageSyntax = "[0, inf)", //
deprecated = true, deprecationMessage = "Option no longer has any effect and can be safely omitted.")//
deprecated = true, deprecationMessage = "Option no longer has any effect and can be safely omitted")//
public static final OptionKey<Integer> AsyncParsingStackSize = new OptionKey<>(0);

@Option(help = "A comma-separated list of pre-opened Wasi directories.", category = OptionCategory.USER, stability = OptionStability.STABLE, usageSyntax = "[<virtualDir>::]<hostDir>,[<virtualDir>::]<hostDir>,...")//
Expand Down