blob: 017afa24c7211ac05072da7fd3c40b25952f869d [file] [log] [blame]
package fuchsia.developer.plugin.fidl;
import com.intellij.lang.Language;
import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable;
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
import org.jetbrains.annotations.NotNull;
public class FidlLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
@NotNull
@Override
public Language getLanguage() {
return fuchsia.developer.plugin.fidl.Language.INSTANCE;
}
@Override
public void customizeSettings(
@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
if (settingsType == SettingsType.INDENT_SETTINGS) {
consumer.showAllStandardOptions();
} else if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) {
consumer.showStandardOptions(
"RIGHT_MARGIN", "WRAP_ON_TYPING", "KEEP_FIRST_COLUMN_COMMENT", "WRAP_COMMENTS");
} else if (settingsType == SettingsType.BLANK_LINES_SETTINGS) {
consumer.showStandardOptions("KEEP_BLANK_LINES_IN_CODE");
}
}
@Override
public String getCodeSample(@NotNull SettingsType settingsType) {
return "library qux;\n\n"
+ "const hi string = \"hi\";\n\n"
+ "alias OptionalChannel = zx.handle:<CHANNEL, zx.rights.DUPLICATE, optional>;\n\n"
+ "type Foo = struct {};\n\n"
+ "@foobar\n"
+ "type Foo = struct {\n"
+ " f1 Bar;\n"
+ "};\n\n"
+ "/// Foo is a protocol\n"
+ "@foobar(\"hi\")\n"
+ "protocol Foo {\n"
+ " compose foo.bar.baz;\n"
+ " Foo() -> ();\n"
+ " Foo(struct {\n"
+ " f1 uint8;\n"
+ " }) -> (struct {\n"
+ " f2 uint8;\n"
+ " });\n"
+ "};\n\n"
+ "service Qux {\n"
+ " foo Foo:client_end;\n"
+ " bar Foo:<client_end>;\n"
+ "};";
}
}