summaryrefslogtreecommitdiff
path: root/src/main/java/com/fivetran/javac/message
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/fivetran/javac/message')
-rw-r--r--src/main/java/com/fivetran/javac/message/JavacArgs.java22
-rw-r--r--src/main/java/com/fivetran/javac/message/LintMessage.java19
-rw-r--r--src/main/java/com/fivetran/javac/message/Point.java10
-rw-r--r--src/main/java/com/fivetran/javac/message/Range.java10
-rw-r--r--src/main/java/com/fivetran/javac/message/Request.java51
-rw-r--r--src/main/java/com/fivetran/javac/message/RequestAutocomplete.java9
-rw-r--r--src/main/java/com/fivetran/javac/message/RequestLint.classbin0 -> 411 bytes
-rw-r--r--src/main/java/com/fivetran/javac/message/RequestLint.java4
-rw-r--r--src/main/java/com/fivetran/javac/message/Response.java50
-rw-r--r--src/main/java/com/fivetran/javac/message/ResponseAutocomplete.java13
-rw-r--r--src/main/java/com/fivetran/javac/message/ResponseChannel.java7
-rw-r--r--src/main/java/com/fivetran/javac/message/ResponseError.java9
-rw-r--r--src/main/java/com/fivetran/javac/message/ResponseLint.java8
-rw-r--r--src/main/java/com/fivetran/javac/message/package-info.java4
14 files changed, 216 insertions, 0 deletions
diff --git a/src/main/java/com/fivetran/javac/message/JavacArgs.java b/src/main/java/com/fivetran/javac/message/JavacArgs.java
new file mode 100644
index 0000000..5768278
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/JavacArgs.java
@@ -0,0 +1,22 @@
+package com.fivetran.javac.message;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
+public class JavacArgs {
+
+ /**
+ * Source of the file we want to compile
+ */
+ public String text;
+
+ /**
+ * Path to a file we want to compile. But we'll use content for the actual source code.
+ */
+ public String path;
+
+ public List<String> sourcePath = Collections.emptyList(), classPath = Collections.emptyList();
+
+ public Optional<String> outputDirectory = Optional.empty();
+}
diff --git a/src/main/java/com/fivetran/javac/message/LintMessage.java b/src/main/java/com/fivetran/javac/message/LintMessage.java
new file mode 100644
index 0000000..d6e21bb
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/LintMessage.java
@@ -0,0 +1,19 @@
+package com.fivetran.javac.message;
+
+public class LintMessage {
+ public final Type type;
+ public final String text, filePath;
+ public final Range range;
+
+ public LintMessage(Type type, String text, String filePath, Range range) {
+ this.type = type;
+ this.text = text;
+ this.filePath = filePath;
+ this.range = range;
+ }
+
+ public static enum Type {
+ Error,
+ Warning
+ }
+}
diff --git a/src/main/java/com/fivetran/javac/message/Point.java b/src/main/java/com/fivetran/javac/message/Point.java
new file mode 100644
index 0000000..8ab7da8
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/Point.java
@@ -0,0 +1,10 @@
+package com.fivetran.javac.message;
+
+public class Point {
+ public final long row, column;
+
+ public Point(long row, long column) {
+ this.row = row;
+ this.column = column;
+ }
+}
diff --git a/src/main/java/com/fivetran/javac/message/Range.java b/src/main/java/com/fivetran/javac/message/Range.java
new file mode 100644
index 0000000..550bd6a
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/Range.java
@@ -0,0 +1,10 @@
+package com.fivetran.javac.message;
+
+public class Range {
+ public final Point start, end;
+
+ public Range(Point start, Point end) {
+ this.start = start;
+ this.end = end;
+ }
+}
diff --git a/src/main/java/com/fivetran/javac/message/Request.java b/src/main/java/com/fivetran/javac/message/Request.java
new file mode 100644
index 0000000..78eb550
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/Request.java
@@ -0,0 +1,51 @@
+package com.fivetran.javac.message;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fivetran.javac.Main;
+
+import java.util.Optional;
+
+public class Request {
+ public int requestId;
+
+ /**
+ * Handy to test if the channel is working
+ */
+ public Optional<JsonNode> echo = Optional.empty();
+
+ public Optional<RequestLint> lint = Optional.empty();
+
+ public Optional<RequestAutocomplete> autocomplete = Optional.empty();
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Request response = (Request) o;
+
+ try {
+ return Main.JSON.writeValueAsString(this).equals(Main.JSON.writeValueAsString(response));
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ try {
+ return Main.JSON.writeValueAsString(this).hashCode();
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public String toString() {
+ try {
+ return Main.JSON.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/main/java/com/fivetran/javac/message/RequestAutocomplete.java b/src/main/java/com/fivetran/javac/message/RequestAutocomplete.java
new file mode 100644
index 0000000..a048c50
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/RequestAutocomplete.java
@@ -0,0 +1,9 @@
+package com.fivetran.javac.message;
+
+public class RequestAutocomplete extends JavacArgs {
+
+ /**
+ * Autocomplete symbols here
+ */
+ public int row, column;
+}
diff --git a/src/main/java/com/fivetran/javac/message/RequestLint.class b/src/main/java/com/fivetran/javac/message/RequestLint.class
new file mode 100644
index 0000000..dce766d
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/RequestLint.class
Binary files differ
diff --git a/src/main/java/com/fivetran/javac/message/RequestLint.java b/src/main/java/com/fivetran/javac/message/RequestLint.java
new file mode 100644
index 0000000..703f1f7
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/RequestLint.java
@@ -0,0 +1,4 @@
+package com.fivetran.javac.message;
+
+public class RequestLint extends JavacArgs {
+}
diff --git a/src/main/java/com/fivetran/javac/message/Response.java b/src/main/java/com/fivetran/javac/message/Response.java
new file mode 100644
index 0000000..48bee39
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/Response.java
@@ -0,0 +1,50 @@
+package com.fivetran.javac.message;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fivetran.javac.Main;
+
+import java.util.Optional;
+
+public class Response {
+ public final int requestId;
+ public Optional<ResponseLint> lint = Optional.empty();
+ public Optional<JsonNode> echo = Optional.empty();
+ public Optional<ResponseError> error = Optional.empty();
+ public Optional<ResponseAutocomplete> autocomplete = Optional.empty();
+
+ public Response(int requestId) {
+ this.requestId = requestId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Response response = (Response) o;
+
+ try {
+ return Main.JSON.writeValueAsString(this).equals(Main.JSON.writeValueAsString(response));
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ try {
+ return Main.JSON.writeValueAsString(this).hashCode();
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public String toString() {
+ try {
+ return Main.JSON.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/main/java/com/fivetran/javac/message/ResponseAutocomplete.java b/src/main/java/com/fivetran/javac/message/ResponseAutocomplete.java
new file mode 100644
index 0000000..2ab9be1
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/ResponseAutocomplete.java
@@ -0,0 +1,13 @@
+package com.fivetran.javac.message;
+
+import com.fivetran.javac.autocomplete.AutocompleteSuggestion;
+
+import java.util.Set;
+
+public class ResponseAutocomplete {
+ public final Set<AutocompleteSuggestion> suggestions;
+
+ public ResponseAutocomplete(Set<AutocompleteSuggestion> suggestions) {
+ this.suggestions = suggestions;
+ }
+}
diff --git a/src/main/java/com/fivetran/javac/message/ResponseChannel.java b/src/main/java/com/fivetran/javac/message/ResponseChannel.java
new file mode 100644
index 0000000..07037bb
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/ResponseChannel.java
@@ -0,0 +1,7 @@
+package com.fivetran.javac.message;
+
+import java.io.IOException;
+
+public interface ResponseChannel {
+ void next(Response response) throws IOException;
+}
diff --git a/src/main/java/com/fivetran/javac/message/ResponseError.java b/src/main/java/com/fivetran/javac/message/ResponseError.java
new file mode 100644
index 0000000..a435d39
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/ResponseError.java
@@ -0,0 +1,9 @@
+package com.fivetran.javac.message;
+
+public class ResponseError {
+ public final String message;
+
+ public ResponseError(String message) {
+ this.message = message;
+ }
+}
diff --git a/src/main/java/com/fivetran/javac/message/ResponseLint.java b/src/main/java/com/fivetran/javac/message/ResponseLint.java
new file mode 100644
index 0000000..f1e4e94
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/ResponseLint.java
@@ -0,0 +1,8 @@
+package com.fivetran.javac.message;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ResponseLint {
+ public List<LintMessage> messages = new ArrayList<>();
+}
diff --git a/src/main/java/com/fivetran/javac/message/package-info.java b/src/main/java/com/fivetran/javac/message/package-info.java
new file mode 100644
index 0000000..26d5aa2
--- /dev/null
+++ b/src/main/java/com/fivetran/javac/message/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Jackson JSON definitions for messages that go back and forth between atom and child process
+ */
+package com.fivetran.javac.message; \ No newline at end of file