diff --git a/java/src/main/java/com/kcl/api/Spec.java b/java/src/main/java/com/kcl/api/Spec.java
index d49f441a..10cacedb 100644
--- a/java/src/main/java/com/kcl/api/Spec.java
+++ b/java/src/main/java/com/kcl/api/Spec.java
@@ -37826,6 +37826,31 @@ com.kcl.api.Spec.Variable getVariablesOrDefault(java.lang.String key,
* @return The bytes of the unsupportedCodes at the given index.
*/
com.google.protobuf.ByteString getUnsupportedCodesBytes(int index);
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ java.util.List getParseErrsList();
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ com.kcl.api.Spec.Error getParseErrs(int index);
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ int getParseErrsCount();
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ java.util.List extends com.kcl.api.Spec.ErrorOrBuilder> getParseErrsOrBuilderList();
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ com.kcl.api.Spec.ErrorOrBuilder getParseErrsOrBuilder(int index);
}
/**
@@ -37843,6 +37868,7 @@ private ListVariables_Result(com.google.protobuf.GeneratedMessageV3.Builder> b
private ListVariables_Result() {
unsupportedCodes_ = com.google.protobuf.LazyStringArrayList.emptyList();
+ parseErrs_ = java.util.Collections.emptyList();
}
@java.lang.Override
@@ -38001,6 +38027,50 @@ public com.google.protobuf.ByteString getUnsupportedCodesBytes(int index) {
return unsupportedCodes_.getByteString(index);
}
+ public static final int PARSE_ERRS_FIELD_NUMBER = 3;
+ @SuppressWarnings("serial")
+ private java.util.List parseErrs_;
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ @java.lang.Override
+ public java.util.List getParseErrsList() {
+ return parseErrs_;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ @java.lang.Override
+ public java.util.List extends com.kcl.api.Spec.ErrorOrBuilder> getParseErrsOrBuilderList() {
+ return parseErrs_;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ @java.lang.Override
+ public int getParseErrsCount() {
+ return parseErrs_.size();
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ @java.lang.Override
+ public com.kcl.api.Spec.Error getParseErrs(int index) {
+ return parseErrs_.get(index);
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ @java.lang.Override
+ public com.kcl.api.Spec.ErrorOrBuilder getParseErrsOrBuilder(int index) {
+ return parseErrs_.get(index);
+ }
+
private byte memoizedIsInitialized = -1;
@java.lang.Override
@@ -38022,6 +38092,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io
for (int i = 0; i < unsupportedCodes_.size(); i++) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, unsupportedCodes_.getRaw(i));
}
+ for (int i = 0; i < parseErrs_.size(); i++) {
+ output.writeMessage(3, parseErrs_.get(i));
+ }
getUnknownFields().writeTo(output);
}
@@ -38046,6 +38119,9 @@ public int getSerializedSize() {
size += dataSize;
size += 1 * getUnsupportedCodesList().size();
}
+ for (int i = 0; i < parseErrs_.size(); i++) {
+ size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, parseErrs_.get(i));
+ }
size += getUnknownFields().getSerializedSize();
memoizedSize = size;
return size;
@@ -38065,6 +38141,8 @@ public boolean equals(final java.lang.Object obj) {
return false;
if (!getUnsupportedCodesList().equals(other.getUnsupportedCodesList()))
return false;
+ if (!getParseErrsList().equals(other.getParseErrsList()))
+ return false;
if (!getUnknownFields().equals(other.getUnknownFields()))
return false;
return true;
@@ -38085,6 +38163,10 @@ public int hashCode() {
hash = (37 * hash) + UNSUPPORTED_CODES_FIELD_NUMBER;
hash = (53 * hash) + getUnsupportedCodesList().hashCode();
}
+ if (getParseErrsCount() > 0) {
+ hash = (37 * hash) + PARSE_ERRS_FIELD_NUMBER;
+ hash = (53 * hash) + getParseErrsList().hashCode();
+ }
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
@@ -38231,6 +38313,13 @@ public Builder clear() {
bitField0_ = 0;
internalGetMutableVariables().clear();
unsupportedCodes_ = com.google.protobuf.LazyStringArrayList.emptyList();
+ if (parseErrsBuilder_ == null) {
+ parseErrs_ = java.util.Collections.emptyList();
+ } else {
+ parseErrs_ = null;
+ parseErrsBuilder_.clear();
+ }
+ bitField0_ = (bitField0_ & ~0x00000004);
return this;
}
@@ -38256,6 +38345,7 @@ public com.kcl.api.Spec.ListVariables_Result build() {
@java.lang.Override
public com.kcl.api.Spec.ListVariables_Result buildPartial() {
com.kcl.api.Spec.ListVariables_Result result = new com.kcl.api.Spec.ListVariables_Result(this);
+ buildPartialRepeatedFields(result);
if (bitField0_ != 0) {
buildPartial0(result);
}
@@ -38263,6 +38353,18 @@ public com.kcl.api.Spec.ListVariables_Result buildPartial() {
return result;
}
+ private void buildPartialRepeatedFields(com.kcl.api.Spec.ListVariables_Result result) {
+ if (parseErrsBuilder_ == null) {
+ if (((bitField0_ & 0x00000004) != 0)) {
+ parseErrs_ = java.util.Collections.unmodifiableList(parseErrs_);
+ bitField0_ = (bitField0_ & ~0x00000004);
+ }
+ result.parseErrs_ = parseErrs_;
+ } else {
+ result.parseErrs_ = parseErrsBuilder_.build();
+ }
+ }
+
private void buildPartial0(com.kcl.api.Spec.ListVariables_Result result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
@@ -38331,6 +38433,31 @@ public Builder mergeFrom(com.kcl.api.Spec.ListVariables_Result other) {
}
onChanged();
}
+ if (parseErrsBuilder_ == null) {
+ if (!other.parseErrs_.isEmpty()) {
+ if (parseErrs_.isEmpty()) {
+ parseErrs_ = other.parseErrs_;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ } else {
+ ensureParseErrsIsMutable();
+ parseErrs_.addAll(other.parseErrs_);
+ }
+ onChanged();
+ }
+ } else {
+ if (!other.parseErrs_.isEmpty()) {
+ if (parseErrsBuilder_.isEmpty()) {
+ parseErrsBuilder_.dispose();
+ parseErrsBuilder_ = null;
+ parseErrs_ = other.parseErrs_;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ parseErrsBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
+ ? getParseErrsFieldBuilder() : null;
+ } else {
+ parseErrsBuilder_.addAllMessages(other.parseErrs_);
+ }
+ }
+ }
this.mergeUnknownFields(other.getUnknownFields());
onChanged();
return this;
@@ -38370,6 +38497,17 @@ public Builder mergeFrom(com.google.protobuf.CodedInputStream input,
unsupportedCodes_.add(s);
break;
} // case 18
+ case 26: {
+ com.kcl.api.Spec.Error m = input.readMessage(com.kcl.api.Spec.Error.parser(),
+ extensionRegistry);
+ if (parseErrsBuilder_ == null) {
+ ensureParseErrsIsMutable();
+ parseErrs_.add(m);
+ } else {
+ parseErrsBuilder_.addMessage(m);
+ }
+ break;
+ } // case 26
default: {
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
done = true; // was an endgroup tag
@@ -38703,6 +38841,244 @@ public Builder addUnsupportedCodesBytes(com.google.protobuf.ByteString value) {
return this;
}
+ private java.util.List parseErrs_ = java.util.Collections.emptyList();
+
+ private void ensureParseErrsIsMutable() {
+ if (!((bitField0_ & 0x00000004) != 0)) {
+ parseErrs_ = new java.util.ArrayList(parseErrs_);
+ bitField0_ |= 0x00000004;
+ }
+ }
+
+ private com.google.protobuf.RepeatedFieldBuilderV3 parseErrsBuilder_;
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public java.util.List getParseErrsList() {
+ if (parseErrsBuilder_ == null) {
+ return java.util.Collections.unmodifiableList(parseErrs_);
+ } else {
+ return parseErrsBuilder_.getMessageList();
+ }
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public int getParseErrsCount() {
+ if (parseErrsBuilder_ == null) {
+ return parseErrs_.size();
+ } else {
+ return parseErrsBuilder_.getCount();
+ }
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public com.kcl.api.Spec.Error getParseErrs(int index) {
+ if (parseErrsBuilder_ == null) {
+ return parseErrs_.get(index);
+ } else {
+ return parseErrsBuilder_.getMessage(index);
+ }
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public Builder setParseErrs(int index, com.kcl.api.Spec.Error value) {
+ if (parseErrsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureParseErrsIsMutable();
+ parseErrs_.set(index, value);
+ onChanged();
+ } else {
+ parseErrsBuilder_.setMessage(index, value);
+ }
+ return this;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public Builder setParseErrs(int index, com.kcl.api.Spec.Error.Builder builderForValue) {
+ if (parseErrsBuilder_ == null) {
+ ensureParseErrsIsMutable();
+ parseErrs_.set(index, builderForValue.build());
+ onChanged();
+ } else {
+ parseErrsBuilder_.setMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public Builder addParseErrs(com.kcl.api.Spec.Error value) {
+ if (parseErrsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureParseErrsIsMutable();
+ parseErrs_.add(value);
+ onChanged();
+ } else {
+ parseErrsBuilder_.addMessage(value);
+ }
+ return this;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public Builder addParseErrs(int index, com.kcl.api.Spec.Error value) {
+ if (parseErrsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureParseErrsIsMutable();
+ parseErrs_.add(index, value);
+ onChanged();
+ } else {
+ parseErrsBuilder_.addMessage(index, value);
+ }
+ return this;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public Builder addParseErrs(com.kcl.api.Spec.Error.Builder builderForValue) {
+ if (parseErrsBuilder_ == null) {
+ ensureParseErrsIsMutable();
+ parseErrs_.add(builderForValue.build());
+ onChanged();
+ } else {
+ parseErrsBuilder_.addMessage(builderForValue.build());
+ }
+ return this;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public Builder addParseErrs(int index, com.kcl.api.Spec.Error.Builder builderForValue) {
+ if (parseErrsBuilder_ == null) {
+ ensureParseErrsIsMutable();
+ parseErrs_.add(index, builderForValue.build());
+ onChanged();
+ } else {
+ parseErrsBuilder_.addMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public Builder addAllParseErrs(java.lang.Iterable extends com.kcl.api.Spec.Error> values) {
+ if (parseErrsBuilder_ == null) {
+ ensureParseErrsIsMutable();
+ com.google.protobuf.AbstractMessageLite.Builder.addAll(values, parseErrs_);
+ onChanged();
+ } else {
+ parseErrsBuilder_.addAllMessages(values);
+ }
+ return this;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public Builder clearParseErrs() {
+ if (parseErrsBuilder_ == null) {
+ parseErrs_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000004);
+ onChanged();
+ } else {
+ parseErrsBuilder_.clear();
+ }
+ return this;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public Builder removeParseErrs(int index) {
+ if (parseErrsBuilder_ == null) {
+ ensureParseErrsIsMutable();
+ parseErrs_.remove(index);
+ onChanged();
+ } else {
+ parseErrsBuilder_.remove(index);
+ }
+ return this;
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public com.kcl.api.Spec.Error.Builder getParseErrsBuilder(int index) {
+ return getParseErrsFieldBuilder().getBuilder(index);
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public com.kcl.api.Spec.ErrorOrBuilder getParseErrsOrBuilder(int index) {
+ if (parseErrsBuilder_ == null) {
+ return parseErrs_.get(index);
+ } else {
+ return parseErrsBuilder_.getMessageOrBuilder(index);
+ }
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public java.util.List extends com.kcl.api.Spec.ErrorOrBuilder> getParseErrsOrBuilderList() {
+ if (parseErrsBuilder_ != null) {
+ return parseErrsBuilder_.getMessageOrBuilderList();
+ } else {
+ return java.util.Collections.unmodifiableList(parseErrs_);
+ }
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public com.kcl.api.Spec.Error.Builder addParseErrsBuilder() {
+ return getParseErrsFieldBuilder().addBuilder(com.kcl.api.Spec.Error.getDefaultInstance());
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public com.kcl.api.Spec.Error.Builder addParseErrsBuilder(int index) {
+ return getParseErrsFieldBuilder().addBuilder(index, com.kcl.api.Spec.Error.getDefaultInstance());
+ }
+
+ /**
+ * repeated .com.kcl.api.Error parse_errs = 3;
+ */
+ public java.util.List getParseErrsBuilderList() {
+ return getParseErrsFieldBuilder().getBuilderList();
+ }
+
+ private com.google.protobuf.RepeatedFieldBuilderV3 getParseErrsFieldBuilder() {
+ if (parseErrsBuilder_ == null) {
+ parseErrsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3(
+ parseErrs_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean());
+ parseErrs_ = null;
+ }
+ return parseErrsBuilder_;
+ }
+
@java.lang.Override
public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
@@ -67333,10 +67709,11 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
+ "le_Args\022\014\n\004file\030\001 \001(\t\022\r\n\005specs\030\002 \003(\t\022\024\n\014"
+ "import_paths\030\003 \003(\t\"%\n\023OverrideFile_Resul"
+ "t\022\016\n\006result\030\001 \001(\010\"1\n\022ListVariables_Args\022"
- + "\014\n\004file\030\001 \001(\t\022\r\n\005specs\030\002 \003(\t\"\277\001\n\024ListVar"
+ + "\014\n\004file\030\001 \001(\t\022\r\n\005specs\030\002 \003(\t\"\347\001\n\024ListVar"
+ "iables_Result\022C\n\tvariables\030\001 \003(\01320.com.k"
+ "cl.api.ListVariables_Result.VariablesEnt"
- + "ry\022\031\n\021unsupported_codes\030\002 \003(\t\032G\n\016Variabl"
+ + "ry\022\031\n\021unsupported_codes\030\002 \003(\t\022&\n\nparse_e"
+ + "rrs\030\003 \003(\0132\022.com.kcl.api.Error\032G\n\016Variabl"
+ "esEntry\022\013\n\003key\030\001 \001(\t\022$\n\005value\030\002 \001(\0132\025.co"
+ "m.kcl.api.Variable:\0028\001\"<\n\010Variable\022\r\n\005va"
+ "lue\030\001 \001(\t\022\021\n\ttype_name\030\002 \001(\t\022\016\n\006op_sym\030\003"
@@ -67621,7 +67998,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
internal_static_com_kcl_api_ListVariables_Result_descriptor = getDescriptor().getMessageTypes().get(37);
internal_static_com_kcl_api_ListVariables_Result_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_com_kcl_api_ListVariables_Result_descriptor,
- new java.lang.String[] { "Variables", "UnsupportedCodes", });
+ new java.lang.String[] { "Variables", "UnsupportedCodes", "ParseErrs", });
internal_static_com_kcl_api_ListVariables_Result_VariablesEntry_descriptor = internal_static_com_kcl_api_ListVariables_Result_descriptor
.getNestedTypes().get(0);
internal_static_com_kcl_api_ListVariables_Result_VariablesEntry_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
diff --git a/java/src/test/java/com/kcl/ListVariablesTest.java b/java/src/test/java/com/kcl/ListVariablesTest.java
index e4f14d21..113fdb62 100644
--- a/java/src/test/java/com/kcl/ListVariablesTest.java
+++ b/java/src/test/java/com/kcl/ListVariablesTest.java
@@ -3,6 +3,9 @@
import com.kcl.api.API;
import com.kcl.api.Spec.ListVariables_Args;
import com.kcl.api.Spec.ListVariables_Result;
+
+import java.nio.file.Paths;
+
import org.junit.Assert;
import org.junit.Test;
@@ -39,4 +42,24 @@ public void testListVariables() throws Exception {
Assert.assertEquals(result.getVariablesMap().get(spec).getOpSym(), expectOpSym);
}
}
+
+ @Test
+ public void testListVariablesWithInvalidKcl() throws Exception {
+ // API instance
+ API api = new API();
+
+ String filePath = Paths.get("./src/test_data/list_variables/invalid.k").toAbsolutePath().toString();
+
+ ListVariables_Result result = api.listVariables(ListVariables_Args.newBuilder()
+ .setFile(filePath).addSpecs("a").build());
+
+ Assert.assertEquals(result.getParseErrsCount(), 1);
+ Assert.assertEquals(result.getParseErrs(0).getLevel(), "error");
+ Assert.assertEquals(result.getParseErrs(0).getCode(), "Error(InvalidSyntax)");
+ Assert.assertTrue(result.getParseErrs(0).getMessages(0).getPos().getFilename()
+ .contains(Paths.get("src/test_data/list_variables/invalid.k").getFileName().toString()));
+ Assert.assertEquals(result.getParseErrs(0).getMessages(0).getPos().getLine(), 1);
+ Assert.assertEquals(result.getParseErrs(0).getMessages(0).getPos().getColumn(), 3);
+ Assert.assertEquals(result.getParseErrs(0).getMessages(0).getMsg(), "unexpected token ':'");
+ }
}
diff --git a/java/src/test_data/list_variables/invalid.k b/java/src/test_data/list_variables/invalid.k
new file mode 100644
index 00000000..9495fd5e
--- /dev/null
+++ b/java/src/test_data/list_variables/invalid.k
@@ -0,0 +1 @@
+"a": "b"
\ No newline at end of file
diff --git a/spec/gpyrpc/spec.proto b/spec/gpyrpc/spec.proto
index 056377b6..70284ffb 100644
--- a/spec/gpyrpc/spec.proto
+++ b/spec/gpyrpc/spec.proto
@@ -299,6 +299,7 @@ message ListVariables_Args {
message ListVariables_Result {
map variables = 1;
repeated string unsupported_codes = 2;
+ repeated Error parse_errs = 3;
}
message Variable {