IDEA-CR-54438: PY-38760 Define a separate exception type for sending completion errors to IDE side

Also fixes EA-214990

GitOrigin-RevId: 8ff2ce9d6ffcf893447893d6c8d9e1ae780cc804
This commit is contained in:
Elizaveta Shashkova
2019-11-07 02:40:58 +00:00
committed by intellij-monorepo-bot
parent 769fa5365e
commit 25785c3200
17 changed files with 549 additions and 42 deletions
@@ -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<ArrayData, ArrayData._Fields>, java.io.Serializable, Cloneable, Comparable<ArrayData> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ArrayData");
@@ -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<ArrayHeaders, ArrayHeaders._Fields>, java.io.Serializable, Cloneable, Comparable<ArrayHeaders> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ArrayHeaders");
@@ -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<ColHeader, ColHeader._Fields>, java.io.Serializable, Cloneable, Comparable<ColHeader> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ColHeader");
@@ -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<CompletionOption, CompletionOption._Fields>, java.io.Serializable, Cloneable, Comparable<CompletionOption> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CompletionOption");
@@ -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<DebugValue, DebugValue._Fields>, java.io.Serializable, Cloneable, Comparable<DebugValue> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("DebugValue");
@@ -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<ExceedingArrayDimensionsException, ExceedingArrayDimensionsException._Fields>, java.io.Serializable, Cloneable, Comparable<ExceedingArrayDimensionsException> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExceedingArrayDimensionsException");
@@ -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<GetArrayResponse, GetArrayResponse._Fields>, java.io.Serializable, Cloneable, Comparable<GetArrayResponse> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("GetArrayResponse");
@@ -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<KeyboardInterruptException, KeyboardInterruptException._Fields>, java.io.Serializable, Cloneable, Comparable<KeyboardInterruptException> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("KeyboardInterruptException");
@@ -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<CompletionOption> getCompletions(java.lang.String text, java.lang.String actTok) throws org.apache.thrift.TException;
public java.util.List<CompletionOption> 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<CompletionOption> getCompletions(java.lang.String text, java.lang.String actTok) throws org.apache.thrift.TException
public java.util.List<CompletionOption> 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<CompletionOption> recv_getCompletions() throws org.apache.thrift.TException
public java.util.List<CompletionOption> 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<CompletionOption> getResult() throws org.apache.thrift.TException {
public java.util.List<CompletionOption> 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<CompletionOption> 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<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
@@ -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<CompletionOption> success)
java.util.List<CompletionOption> 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);
}
}
}
@@ -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 {
@@ -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<PythonUnhandledException, PythonUnhandledException._Fields>, java.io.Serializable, Cloneable, Comparable<PythonUnhandledException> {
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<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
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 <i>other</i>.
*/
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<PythonUnhandledException> {
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<PythonUnhandledException> {
@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 extends org.apache.thrift.scheme.IScheme> 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();
}
}
@@ -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<RowHeader, RowHeader._Fields>, java.io.Serializable, Cloneable, Comparable<RowHeader> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RowHeader");
@@ -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<UnsupportedArrayTypeException, UnsupportedArrayTypeException._Fields>, java.io.Serializable, Cloneable, Comparable<UnsupportedArrayTypeException> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UnsupportedArrayTypeException");
@@ -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):
"""
@@ -107,7 +107,7 @@ struct CompletionOption {
4: CompletionOptionType type,
}
typedef list<CompletionOption> GetCompletionsReponse
typedef list<CompletionOption> 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.
@@ -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
@@ -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<PydevCompletionVariant> 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<CompletionOption> 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<CompletionOption> 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