Skip to content

Commit

Permalink
chore: adjusted ds.toml completion insert text
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsDeltin committed May 29, 2024
1 parent 4af69b8 commit 6ee5f4e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Deltinteger/Deltinteger/Parse/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,18 @@ static CompletionList GetCompletionList()
return null;

// Determine default value.
var defaultValue = prop.GetValue(Default) switch
{
true => "true",
false => "false",
null => "null",
ReferenceValidationType.Inline => "inline",
ReferenceValidationType.Subroutine => "subroutine",
_ => string.Empty,
};
string defaultValue;
if (prop.PropertyType == typeof(string))
defaultValue = "\"\"";
else
defaultValue = prop.GetValue(Default) switch
{
true => "true",
false => "false",
ReferenceValidationType.Inline => "\"inline\"",
ReferenceValidationType.Subroutine => "\"subroutine\"",
_ => string.Empty,
};
string insertText = $"{jsonPropertyName} = {defaultValue}";

return new CompletionItem()
Expand Down Expand Up @@ -112,8 +115,8 @@ static CompletionList GetCompletionList()
"new_class_register_optimization" => new MarkupBuilder("Code like ").Code("a = new MyClass()").Add(" will be optimized so that the 'a' value which is already being overridden is used to assign to the heap, rather than creating a new register."),
"abort_on_error" => new MarkupBuilder("If an invalid class reference is found when ").Code("global_reference_validation").Add(" is enabled, this determines if the rule should be aborted."),
"c_style_workshop_output" => new MarkupBuilder("Controls the workshop output format.")
.NewLine().Add("Classic style (false):").NewLine().StartCodeLine().Add("Set Global Variable(A, Value In Array(Global Variable(B), 2));").EndCodeLine()
.NewLine().Add("C style (true):").NewLine().StartCodeLine().Add("Global.A = Global.B[2];").EndCodeLine(),
.NewLine().Add("Default:").NewLine().StartCodeLine("ow").Add("Set Global Variable(A, Value In Array(Global Variable(B), 2));").EndCodeLine()
.NewLine().Add("C style:").NewLine().StartCodeLine("ow").Add("Global.A = Global.B[2];").EndCodeLine(),
"compile_miscellaneous_comments" => "Toggles the extra comments generated by the OSTW compiler in the workshop output, like rule action count and extended collection names.",
"out_file" => "The file to write the generated workshop code to.",
"optimize_output" => "Controls if OSTW will optimize the generated workshop code.",
Expand Down

0 comments on commit 6ee5f4e

Please sign in to comment.