diff --git a/python/gen/com/jetbrains/python/console/protocol/ArrayData.java b/python/gen/com/jetbrains/python/console/protocol/ArrayData.java index 46645f21e286..2da131e171b5 100644 --- a/python/gen/com/jetbrains/python/console/protocol/ArrayData.java +++ b/python/gen/com/jetbrains/python/console/protocol/ArrayData.java @@ -7,7 +7,7 @@ package com.jetbrains.python.console.protocol; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class ArrayData implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ArrayData"); diff --git a/python/gen/com/jetbrains/python/console/protocol/ArrayHeaders.java b/python/gen/com/jetbrains/python/console/protocol/ArrayHeaders.java index 2f698dc000c3..5488d2ea1b1b 100644 --- a/python/gen/com/jetbrains/python/console/protocol/ArrayHeaders.java +++ b/python/gen/com/jetbrains/python/console/protocol/ArrayHeaders.java @@ -7,7 +7,7 @@ package com.jetbrains.python.console.protocol; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class ArrayHeaders implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ArrayHeaders"); diff --git a/python/gen/com/jetbrains/python/console/protocol/ColHeader.java b/python/gen/com/jetbrains/python/console/protocol/ColHeader.java index f019f68ff4bc..34f34525954f 100644 --- a/python/gen/com/jetbrains/python/console/protocol/ColHeader.java +++ b/python/gen/com/jetbrains/python/console/protocol/ColHeader.java @@ -7,7 +7,7 @@ package com.jetbrains.python.console.protocol; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class ColHeader implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ColHeader"); diff --git a/python/gen/com/jetbrains/python/console/protocol/CompletionOption.java b/python/gen/com/jetbrains/python/console/protocol/CompletionOption.java index e8b07f9f4158..8720a183e84b 100644 --- a/python/gen/com/jetbrains/python/console/protocol/CompletionOption.java +++ b/python/gen/com/jetbrains/python/console/protocol/CompletionOption.java @@ -7,7 +7,7 @@ package com.jetbrains.python.console.protocol; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class CompletionOption implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CompletionOption"); diff --git a/python/gen/com/jetbrains/python/console/protocol/DebugValue.java b/python/gen/com/jetbrains/python/console/protocol/DebugValue.java index be55f755087b..71df4e7fe2ca 100644 --- a/python/gen/com/jetbrains/python/console/protocol/DebugValue.java +++ b/python/gen/com/jetbrains/python/console/protocol/DebugValue.java @@ -10,7 +10,7 @@ package com.jetbrains.python.console.protocol; /** * Corresponds to `PyDebugValue`. */ -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class DebugValue implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("DebugValue"); diff --git a/python/gen/com/jetbrains/python/console/protocol/ExceedingArrayDimensionsException.java b/python/gen/com/jetbrains/python/console/protocol/ExceedingArrayDimensionsException.java index 7529bfa7be15..f0c4e443524e 100644 --- a/python/gen/com/jetbrains/python/console/protocol/ExceedingArrayDimensionsException.java +++ b/python/gen/com/jetbrains/python/console/protocol/ExceedingArrayDimensionsException.java @@ -11,7 +11,7 @@ package com.jetbrains.python.console.protocol; * Indicates that the related array has more than two dimensions. * */ -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class ExceedingArrayDimensionsException extends org.apache.thrift.TException implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExceedingArrayDimensionsException"); diff --git a/python/gen/com/jetbrains/python/console/protocol/GetArrayResponse.java b/python/gen/com/jetbrains/python/console/protocol/GetArrayResponse.java index 35409a6a5a0a..8feb34ed16e1 100644 --- a/python/gen/com/jetbrains/python/console/protocol/GetArrayResponse.java +++ b/python/gen/com/jetbrains/python/console/protocol/GetArrayResponse.java @@ -11,7 +11,7 @@ package com.jetbrains.python.console.protocol; * Corresponds to `ArrayChunk`. * */ -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class GetArrayResponse implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("GetArrayResponse"); diff --git a/python/gen/com/jetbrains/python/console/protocol/KeyboardInterruptException.java b/python/gen/com/jetbrains/python/console/protocol/KeyboardInterruptException.java index 3de0381801d0..4b8aa6be5741 100644 --- a/python/gen/com/jetbrains/python/console/protocol/KeyboardInterruptException.java +++ b/python/gen/com/jetbrains/python/console/protocol/KeyboardInterruptException.java @@ -7,7 +7,7 @@ package com.jetbrains.python.console.protocol; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class KeyboardInterruptException extends org.apache.thrift.TException implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("KeyboardInterruptException"); diff --git a/python/gen/com/jetbrains/python/console/protocol/PythonConsoleBackendService.java b/python/gen/com/jetbrains/python/console/protocol/PythonConsoleBackendService.java index 8b89c98f2784..e6253bd78a48 100644 --- a/python/gen/com/jetbrains/python/console/protocol/PythonConsoleBackendService.java +++ b/python/gen/com/jetbrains/python/console/protocol/PythonConsoleBackendService.java @@ -7,7 +7,7 @@ package com.jetbrains.python.console.protocol; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class PythonConsoleBackendService { public interface Iface { @@ -28,7 +28,7 @@ public class PythonConsoleBackendService { */ public boolean execMultipleLines(java.lang.String lines) throws org.apache.thrift.TException; - public java.util.List getCompletions(java.lang.String text, java.lang.String actTok) throws org.apache.thrift.TException; + public java.util.List getCompletions(java.lang.String text, java.lang.String actTok) throws PythonUnhandledException, org.apache.thrift.TException; /** * The description of the given attribute in the shell. @@ -184,7 +184,7 @@ public class PythonConsoleBackendService { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "execMultipleLines failed: unknown result"); } - public java.util.List getCompletions(java.lang.String text, java.lang.String actTok) throws org.apache.thrift.TException + public java.util.List getCompletions(java.lang.String text, java.lang.String actTok) throws PythonUnhandledException, org.apache.thrift.TException { send_getCompletions(text, actTok); return recv_getCompletions(); @@ -198,13 +198,16 @@ public class PythonConsoleBackendService { sendBase("getCompletions", args); } - public java.util.List recv_getCompletions() throws org.apache.thrift.TException + public java.util.List recv_getCompletions() throws PythonUnhandledException, org.apache.thrift.TException { getCompletions_result result = new getCompletions_result(); receiveBase(result, "getCompletions"); if (result.isSetSuccess()) { return result.success; } + if (result.unhandledException != null) { + throw result.unhandledException; + } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getCompletions failed: unknown result"); } @@ -557,7 +560,7 @@ public class PythonConsoleBackendService { prot.writeMessageEnd(); } - public java.util.List getResult() throws org.apache.thrift.TException { + public java.util.List getResult() throws PythonUnhandledException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } @@ -1039,7 +1042,11 @@ public class PythonConsoleBackendService { public getCompletions_result getResult(I iface, getCompletions_args args) throws org.apache.thrift.TException { getCompletions_result result = new getCompletions_result(); - result.success = iface.getCompletions(args.text, args.actTok); + try { + result.success = iface.getCompletions(args.text, args.actTok); + } catch (PythonUnhandledException unhandledException) { + result.unhandledException = unhandledException; + } return result; } } @@ -1507,7 +1514,11 @@ public class PythonConsoleBackendService { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; getCompletions_result result = new getCompletions_result(); - if (e instanceof org.apache.thrift.transport.TTransportException) { + if (e instanceof PythonUnhandledException) { + result.unhandledException = (PythonUnhandledException) e; + result.setUnhandledExceptionIsSet(true); + msg = result; + } else if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; @@ -4103,15 +4114,18 @@ public class PythonConsoleBackendService { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getCompletions_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.LIST, (short)0); + private static final org.apache.thrift.protocol.TField UNHANDLED_EXCEPTION_FIELD_DESC = new org.apache.thrift.protocol.TField("unhandledException", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getCompletions_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getCompletions_resultTupleSchemeFactory(); public java.util.List success; // required + public PythonUnhandledException unhandledException; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { - SUCCESS((short)0, "success"); + SUCCESS((short)0, "success"), + UNHANDLED_EXCEPTION((short)1, "unhandledException"); private static final java.util.Map byName = new java.util.HashMap(); @@ -4128,6 +4142,8 @@ public class PythonConsoleBackendService { switch(fieldId) { case 0: // SUCCESS return SUCCESS; + case 1: // UNHANDLED_EXCEPTION + return UNHANDLED_EXCEPTION; default: return null; } @@ -4172,7 +4188,9 @@ public class PythonConsoleBackendService { static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.LIST , "GetCompletionsReponse"))); + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.LIST , "GetCompletionsResponse"))); + tmpMap.put(_Fields.UNHANDLED_EXCEPTION, new org.apache.thrift.meta_data.FieldMetaData("unhandledException", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PythonUnhandledException.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getCompletions_result.class, metaDataMap); } @@ -4181,10 +4199,12 @@ public class PythonConsoleBackendService { } public getCompletions_result( - java.util.List success) + java.util.List success, + PythonUnhandledException unhandledException) { this(); this.success = success; + this.unhandledException = unhandledException; } /** @@ -4198,6 +4218,9 @@ public class PythonConsoleBackendService { } this.success = __this__success; } + if (other.isSetUnhandledException()) { + this.unhandledException = new PythonUnhandledException(other.unhandledException); + } } public getCompletions_result deepCopy() { @@ -4207,6 +4230,7 @@ public class PythonConsoleBackendService { @Override public void clear() { this.success = null; + this.unhandledException = null; } public int getSuccessSize() { @@ -4248,6 +4272,30 @@ public class PythonConsoleBackendService { } } + public PythonUnhandledException getUnhandledException() { + return this.unhandledException; + } + + public getCompletions_result setUnhandledException(PythonUnhandledException unhandledException) { + this.unhandledException = unhandledException; + return this; + } + + public void unsetUnhandledException() { + this.unhandledException = null; + } + + /** Returns true if field unhandledException is set (has been assigned a value) and false otherwise */ + public boolean isSetUnhandledException() { + return this.unhandledException != null; + } + + public void setUnhandledExceptionIsSet(boolean value) { + if (!value) { + this.unhandledException = null; + } + } + public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: @@ -4258,6 +4306,14 @@ public class PythonConsoleBackendService { } break; + case UNHANDLED_EXCEPTION: + if (value == null) { + unsetUnhandledException(); + } else { + setUnhandledException((PythonUnhandledException)value); + } + break; + } } @@ -4266,6 +4322,9 @@ public class PythonConsoleBackendService { case SUCCESS: return getSuccess(); + case UNHANDLED_EXCEPTION: + return getUnhandledException(); + } throw new java.lang.IllegalStateException(); } @@ -4279,6 +4338,8 @@ public class PythonConsoleBackendService { switch (field) { case SUCCESS: return isSetSuccess(); + case UNHANDLED_EXCEPTION: + return isSetUnhandledException(); } throw new java.lang.IllegalStateException(); } @@ -4307,6 +4368,15 @@ public class PythonConsoleBackendService { return false; } + boolean this_present_unhandledException = true && this.isSetUnhandledException(); + boolean that_present_unhandledException = true && that.isSetUnhandledException(); + if (this_present_unhandledException || that_present_unhandledException) { + if (!(this_present_unhandledException && that_present_unhandledException)) + return false; + if (!this.unhandledException.equals(that.unhandledException)) + return false; + } + return true; } @@ -4318,6 +4388,10 @@ public class PythonConsoleBackendService { if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); + hashCode = hashCode * 8191 + ((isSetUnhandledException()) ? 131071 : 524287); + if (isSetUnhandledException()) + hashCode = hashCode * 8191 + unhandledException.hashCode(); + return hashCode; } @@ -4339,6 +4413,16 @@ public class PythonConsoleBackendService { return lastComparison; } } + lastComparison = java.lang.Boolean.valueOf(isSetUnhandledException()).compareTo(other.isSetUnhandledException()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUnhandledException()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.unhandledException, other.unhandledException); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -4366,6 +4450,14 @@ public class PythonConsoleBackendService { sb.append(this.success); } first = false; + if (!first) sb.append(", "); + sb.append("unhandledException:"); + if (this.unhandledException == null) { + sb.append("null"); + } else { + sb.append(this.unhandledException); + } + first = false; sb.append(")"); return sb.toString(); } @@ -4428,6 +4520,15 @@ public class PythonConsoleBackendService { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 1: // UNHANDLED_EXCEPTION + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.unhandledException = new PythonUnhandledException(); + struct.unhandledException.read(iprot); + struct.setUnhandledExceptionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -4455,6 +4556,11 @@ public class PythonConsoleBackendService { } oprot.writeFieldEnd(); } + if (struct.unhandledException != null) { + oprot.writeFieldBegin(UNHANDLED_EXCEPTION_FIELD_DESC); + struct.unhandledException.write(oprot); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -4476,7 +4582,10 @@ public class PythonConsoleBackendService { if (struct.isSetSuccess()) { optionals.set(0); } - oprot.writeBitSet(optionals, 1); + if (struct.isSetUnhandledException()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); @@ -4486,12 +4595,15 @@ public class PythonConsoleBackendService { } } } + if (struct.isSetUnhandledException()) { + struct.unhandledException.write(oprot); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getCompletions_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet incoming = iprot.readBitSet(1); + java.util.BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { org.apache.thrift.protocol.TList _list45 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); @@ -4506,6 +4618,11 @@ public class PythonConsoleBackendService { } struct.setSuccessIsSet(true); } + if (incoming.get(1)) { + struct.unhandledException = new PythonUnhandledException(); + struct.unhandledException.read(iprot); + struct.setUnhandledExceptionIsSet(true); + } } } diff --git a/python/gen/com/jetbrains/python/console/protocol/PythonConsoleFrontendService.java b/python/gen/com/jetbrains/python/console/protocol/PythonConsoleFrontendService.java index 98fc9f9b7d4d..318638bf0cf8 100644 --- a/python/gen/com/jetbrains/python/console/protocol/PythonConsoleFrontendService.java +++ b/python/gen/com/jetbrains/python/console/protocol/PythonConsoleFrontendService.java @@ -7,7 +7,7 @@ package com.jetbrains.python.console.protocol; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class PythonConsoleFrontendService { public interface Iface { diff --git a/python/gen/com/jetbrains/python/console/protocol/PythonUnhandledException.java b/python/gen/com/jetbrains/python/console/protocol/PythonUnhandledException.java new file mode 100644 index 000000000000..e5df52a03933 --- /dev/null +++ b/python/gen/com/jetbrains/python/console/protocol/PythonUnhandledException.java @@ -0,0 +1,372 @@ +/** + * Autogenerated by Thrift Compiler (0.11.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package com.jetbrains.python.console.protocol; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") +public class PythonUnhandledException extends org.apache.thrift.TException implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PythonUnhandledException"); + + private static final org.apache.thrift.protocol.TField TRACEBACK_FIELD_DESC = new org.apache.thrift.protocol.TField("traceback", org.apache.thrift.protocol.TType.STRING, (short)1); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new PythonUnhandledExceptionStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new PythonUnhandledExceptionTupleSchemeFactory(); + + public java.lang.String traceback; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + TRACEBACK((short)1, "traceback"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // TRACEBACK + return TRACEBACK; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.TRACEBACK, new org.apache.thrift.meta_data.FieldMetaData("traceback", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(PythonUnhandledException.class, metaDataMap); + } + + public PythonUnhandledException() { + } + + public PythonUnhandledException( + java.lang.String traceback) + { + this(); + this.traceback = traceback; + } + + /** + * Performs a deep copy on other. + */ + public PythonUnhandledException(PythonUnhandledException other) { + if (other.isSetTraceback()) { + this.traceback = other.traceback; + } + } + + public PythonUnhandledException deepCopy() { + return new PythonUnhandledException(this); + } + + @Override + public void clear() { + this.traceback = null; + } + + public java.lang.String getTraceback() { + return this.traceback; + } + + public PythonUnhandledException setTraceback(java.lang.String traceback) { + this.traceback = traceback; + return this; + } + + public void unsetTraceback() { + this.traceback = null; + } + + /** Returns true if field traceback is set (has been assigned a value) and false otherwise */ + public boolean isSetTraceback() { + return this.traceback != null; + } + + public void setTracebackIsSet(boolean value) { + if (!value) { + this.traceback = null; + } + } + + public void setFieldValue(_Fields field, java.lang.Object value) { + switch (field) { + case TRACEBACK: + if (value == null) { + unsetTraceback(); + } else { + setTraceback((java.lang.String)value); + } + break; + + } + } + + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case TRACEBACK: + return getTraceback(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case TRACEBACK: + return isSetTraceback(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that == null) + return false; + if (that instanceof PythonUnhandledException) + return this.equals((PythonUnhandledException)that); + return false; + } + + public boolean equals(PythonUnhandledException that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_traceback = true && this.isSetTraceback(); + boolean that_present_traceback = true && that.isSetTraceback(); + if (this_present_traceback || that_present_traceback) { + if (!(this_present_traceback && that_present_traceback)) + return false; + if (!this.traceback.equals(that.traceback)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetTraceback()) ? 131071 : 524287); + if (isSetTraceback()) + hashCode = hashCode * 8191 + traceback.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(PythonUnhandledException other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.valueOf(isSetTraceback()).compareTo(other.isSetTraceback()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTraceback()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.traceback, other.traceback); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("PythonUnhandledException("); + boolean first = true; + + sb.append("traceback:"); + if (this.traceback == null) { + sb.append("null"); + } else { + sb.append(this.traceback); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class PythonUnhandledExceptionStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public PythonUnhandledExceptionStandardScheme getScheme() { + return new PythonUnhandledExceptionStandardScheme(); + } + } + + private static class PythonUnhandledExceptionStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, PythonUnhandledException struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // TRACEBACK + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.traceback = iprot.readString(); + struct.setTracebackIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, PythonUnhandledException struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.traceback != null) { + oprot.writeFieldBegin(TRACEBACK_FIELD_DESC); + oprot.writeString(struct.traceback); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class PythonUnhandledExceptionTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public PythonUnhandledExceptionTupleScheme getScheme() { + return new PythonUnhandledExceptionTupleScheme(); + } + } + + private static class PythonUnhandledExceptionTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, PythonUnhandledException struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetTraceback()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetTraceback()) { + oprot.writeString(struct.traceback); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, PythonUnhandledException struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.traceback = iprot.readString(); + struct.setTracebackIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } +} + diff --git a/python/gen/com/jetbrains/python/console/protocol/RowHeader.java b/python/gen/com/jetbrains/python/console/protocol/RowHeader.java index 9e906c0b2335..4e0a42d1893c 100644 --- a/python/gen/com/jetbrains/python/console/protocol/RowHeader.java +++ b/python/gen/com/jetbrains/python/console/protocol/RowHeader.java @@ -7,7 +7,7 @@ package com.jetbrains.python.console.protocol; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class RowHeader implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RowHeader"); diff --git a/python/gen/com/jetbrains/python/console/protocol/UnsupportedArrayTypeException.java b/python/gen/com/jetbrains/python/console/protocol/UnsupportedArrayTypeException.java index 3e1c340bbdf7..c0aaa156c401 100644 --- a/python/gen/com/jetbrains/python/console/protocol/UnsupportedArrayTypeException.java +++ b/python/gen/com/jetbrains/python/console/protocol/UnsupportedArrayTypeException.java @@ -7,7 +7,7 @@ package com.jetbrains.python.console.protocol; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-01") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-10-28") public class UnsupportedArrayTypeException extends org.apache.thrift.TException implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UnsupportedArrayTypeException"); diff --git a/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py b/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py index 3e4ce030512a..a80784761c50 100644 --- a/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py +++ b/python/helpers/pydev/_pydev_bundle/pydev_console_utils.py @@ -1,4 +1,5 @@ import os +import signal import sys import traceback @@ -10,15 +11,14 @@ from _pydev_bundle.pydev_stdin import StdIn, DebugConsoleStdIn from _pydev_imps._pydev_saved_modules import thread from _pydevd_bundle import pydevd_thrift from _pydevd_bundle import pydevd_vars -from _pydevd_bundle.pydevd_constants import IS_JYTHON, dict_iter_items, NEXT_VALUE_SEPARATOR, Null -from pydev_console.protocol import CompletionOption, CompletionOptionType -import signal +from _pydevd_bundle.pydevd_constants import IS_JYTHON, dict_iter_items +from pydev_console.protocol import CompletionOption, CompletionOptionType, PythonUnhandledException try: - import cStringIO as StringIO #may not always be available @UnusedImport + import cStringIO as StringIO # may not always be available @UnusedImport except: try: - import StringIO #@Reimport + import StringIO # @Reimport except: import io as StringIO @@ -265,14 +265,15 @@ class BaseInterpreterInterface(BaseCodeExecutor): completer = Completer(self.get_namespace(), None) return completer.complete(act_tok) except: - import traceback - traceback.print_exc() return [] def getCompletions(self, text, act_tok): - words = self.do_get_completions(text, act_tok) - return [_to_completion_option(word) for word in words] + try: + words = self.do_get_completions(text, act_tok) + return [_to_completion_option(word) for word in words] + except: + raise PythonUnhandledException(traceback.format_exc()) def loadFullValue(self, seq, scope_attrs): """ diff --git a/python/helpers/pydev/pydev_console/console.thrift b/python/helpers/pydev/pydev_console/console.thrift index ebcdbc58a40d..5993b285a090 100644 --- a/python/helpers/pydev/pydev_console/console.thrift +++ b/python/helpers/pydev/pydev_console/console.thrift @@ -107,7 +107,7 @@ struct CompletionOption { 4: CompletionOptionType type, } -typedef list GetCompletionsReponse +typedef list GetCompletionsResponse typedef string AttributeDescription @@ -117,6 +117,10 @@ exception UnsupportedArrayTypeException { 1: string type, } +exception PythonUnhandledException { + 1: string traceback, +} + /** * Indicates that the related array has more than two dimensions. **/ @@ -136,7 +140,7 @@ service PythonConsoleBackendService { */ bool execMultipleLines(1: string lines), - GetCompletionsReponse getCompletions(1: string text, 2: string actTok), + GetCompletionsResponse getCompletions(1: string text, 2: string actTok) throws (1: PythonUnhandledException unhandledException), /** * The description of the given attribute in the shell. diff --git a/python/helpers/pydev/pydev_console/protocol.py b/python/helpers/pydev/pydev_console/protocol.py index 3b461ee71ede..51a9d50e48a1 100644 --- a/python/helpers/pydev/pydev_console/protocol.py +++ b/python/helpers/pydev/pydev_console/protocol.py @@ -18,6 +18,7 @@ RowHeader = _console_thrift.RowHeader UnsupportedArrayTypeException = _console_thrift.UnsupportedArrayTypeException ExceedingArrayDimensionsException = _console_thrift.ExceedingArrayDimensionsException KeyboardInterruptException = _console_thrift.KeyboardInterruptException +PythonUnhandledException = _console_thrift.PythonUnhandledException PythonConsoleFrontendService = _console_thrift.PythonConsoleFrontendService PythonConsoleBackendService = _console_thrift.PythonConsoleBackendService diff --git a/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java b/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java index 06674aaeca5f..739a4de21e52 100644 --- a/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java +++ b/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java @@ -2,6 +2,7 @@ package com.jetbrains.python.console; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ex.ApplicationUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.progress.ProcessCanceledException; @@ -290,16 +291,27 @@ public abstract class PydevConsoleCommunication extends AbstractConsoleCommunica @Override @NotNull public List getCompletions(String text, String actTok) throws Exception { - if (myDebugCommunication != null && myDebugCommunication.isSuspended()) { - return myDebugCommunication.getCompletions(text, actTok); - } - - if (waitingForInput) { + if (waitingForInput || isExecuting()) { return Collections.emptyList(); } - List fromServer = getPythonConsoleBackendClient().getCompletions(text, actTok); - - return fromServer.stream().map(option -> toPydevCompletionVariant(option)).collect(Collectors.toList()); + return ApplicationUtil.runWithCheckCanceled( + () -> + { + try { + if (myDebugCommunication != null && myDebugCommunication.isSuspended()) { + return myDebugCommunication.getCompletions(text, actTok); + } + else { + List fromServer = getPythonConsoleBackendClient().getCompletions(text, actTok); + return ContainerUtil.map(fromServer, option -> toPydevCompletionVariant(option)); + } + } + catch (PythonUnhandledException e) { + LOG.warn("Completion error in Python Console: " + e.traceback); + return Collections.emptyList(); + } + }, + ProgressManager.getInstance().getProgressIndicator()); } @NotNull