summaryrefslogtreecommitdiff
path: root/platform/script-debugger/protocol/protocol-model-generator/src/org/jetbrains/protocolReader/TypeDescriptor.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/script-debugger/protocol/protocol-model-generator/src/org/jetbrains/protocolReader/TypeDescriptor.java')
-rw-r--r--platform/script-debugger/protocol/protocol-model-generator/src/org/jetbrains/protocolReader/TypeDescriptor.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/platform/script-debugger/protocol/protocol-model-generator/src/org/jetbrains/protocolReader/TypeDescriptor.java b/platform/script-debugger/protocol/protocol-model-generator/src/org/jetbrains/protocolReader/TypeDescriptor.java
new file mode 100644
index 000000000000..d142e8bdf6d5
--- /dev/null
+++ b/platform/script-debugger/protocol/protocol-model-generator/src/org/jetbrains/protocolReader/TypeDescriptor.java
@@ -0,0 +1,50 @@
+package org.jetbrains.protocolReader;
+
+import org.jetbrains.annotations.NotNull;
+
+class TypeDescriptor {
+ private final BoxableType type;
+ private final boolean optional;
+ private final boolean nullable;
+ private final boolean asRawString;
+
+ TypeDescriptor(@NotNull BoxableType type, boolean optional) {
+ this(type, optional, false, false);
+ }
+
+ TypeDescriptor(@NotNull BoxableType type, boolean optional, boolean nullable, boolean asRawString) {
+ this.type = type;
+ this.optional = optional;
+ this.nullable = nullable;
+ this.asRawString = asRawString;
+ }
+
+ boolean isNullable() {
+ return nullable;
+ }
+
+ @NotNull
+ BoxableType getType() {
+ return type;
+ }
+
+ void writeAnnotations(@NotNull TextOutput out) {
+ if (optional || asRawString) {
+ out.append("@org.jetbrains.jsonProtocol.JsonField(");
+ if (optional) {
+ out.append("optional=true");
+ }
+ if (asRawString) {
+ if (optional) {
+ out.append(", ");
+ }
+ out.append("allowAnyPrimitiveValue=true");
+ }
+ out.append(")").newLine();
+ }
+
+ if (isNullable()) {
+ out.append("@org.jetbrains.jsonProtocol.JsonNullable").newLine();
+ }
+ }
+}