summaryrefslogtreecommitdiff
path: root/platform/script-debugger/protocol/protocol-model-generator/src/org/jetbrains/protocolReader/ParserRootInterfaceItem.java
blob: e84c641ff9c375673c73c6089e0c99fcf46a8334 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package org.jetbrains.protocolReader;

import org.jetbrains.annotations.NotNull;

import java.io.IOException;

class ParserRootInterfaceItem implements Comparable<ParserRootInterfaceItem> {
  final String domain;
  final String name;
  private final ClassNameScheme.Input nameScheme;
  final String fullName;

  public ParserRootInterfaceItem(String domain, String name, ClassNameScheme.Input nameScheme) {
    this.domain = domain;
    this.name = name;
    this.nameScheme = nameScheme;
    fullName = nameScheme.getFullName(domain, name).getFullText();
  }

  void writeCode(TextOutput out) throws IOException {
    out.append("@org.jetbrains.jsonProtocol.JsonParseMethod").newLine();
    out.append("public abstract ").append(fullName).space();
    appendReadMethodName(out);
    out.append("(").append(Util.JSON_READER_PARAMETER_DEF).append(")").semi().newLine();
  }

  void appendReadMethodName(TextOutput out) {
    out.append(nameScheme.getParseMethodName(domain, name));
  }

  @Override
  public int compareTo(@NotNull ParserRootInterfaceItem o) {
    return fullName.compareTo(o.fullName);
  }
}