boolean (MessageLite message) { try { final JavacRemoteProto.Message msg = (JavacRemoteProto.Message)message; final JavacRemoteProto.Message.Type messageType = msg.getMessageType(); if (messageType == JavacRemoteProto.Message.Type.RESPONSE) { final JavacRemoteProto.Message.Response response = msg.getResponse(); final JavacRemoteProto.Message.Response.Type responseType = response.getResponseType(); if (responseType == JavacRemoteProto.Message.Response.Type.BUILD_MESSAGE) { final JavacRemoteProto.Message.Response.CompileMessage compileMessage = response.getCompileMessage(); final JavacRemoteProto.Message.Response.CompileMessage.Kind messageKind = compileMessage.getKind(); if (messageKind == JavacRemoteProto.Message.Response.CompileMessage.Kind.STD_OUT) { if (compileMessage.hasText()) { myDiagnosticSink.outputLineAvailable(compileMessage.getText()); } } else { final String sourceUri = compileMessage.hasSourceUri()? compileMessage.getSourceUri() : null; final JavaFileObject srcFileObject = sourceUri != null? new DummyJavaFileObject(URI.create(sourceUri)) : null; myDiagnosticSink.report(new DummyDiagnostic(convertKind(messageKind), srcFileObject, compileMessage)); } return false; } if (responseType == JavacRemoteProto.Message.Response.Type.OUTPUT_OBJECT) { final JavacRemoteProto.Message.Response.OutputObject outputObject = response.getOutputObject(); final JavacRemoteProto.Message.Response.OutputObject.Kind kind = outputObject.getKind(); final String outputRoot = outputObject.hasOutputRoot()? outputObject.getOutputRoot() : null; final File outputRootFile = outputRoot != null? new File(myWslSupport.convertPath(outputRoot)) : null; final BinaryContent fileObjectContent; final ByteString content = outputObject.hasContent()? outputObject.getContent() : null; if (content != null) { final byte[] bytes = content.toByteArray(); fileObjectContent = new BinaryContent(bytes, 0, bytes.length); } else { fileObjectContent = null; } final JavaFileManager.Location location = outputObject.hasLocation()? StandardLocation.locationFor(outputObject.getLocation()) : null; Collection<URI> sources = new ArrayList<>(); for (String uri : outputObject.getSourceUriList()) { sources.add(URI.create(uri)); } final OutputFileObject fileObject = new OutputFileObject( null, outputRootFile, outputObject.hasRelativePath()? outputObject.getRelativePath() : null, new File(myWslSupport.convertPath(outputObject.getFilePath())), convertKind(kind), outputObject.hasClassName()? outputObject.getClassName() : null, sources, myEncodingName, fileObjectContent, location, outputObject.getIsGenerated() ); myOutputSink.save(fileObject); return false; } if (responseType == JavacRemoteProto.Message.Response.Type.SRC_FILE_LOADED) { final JavacRemoteProto.Message.Response.OutputObject outputObject = response.getOutputObject(); final File file = new File(myWslSupport.convertPath(outputObject.getFilePath())); myDiagnosticSink.javaFileLoaded(file); return false; } if (responseType == JavacRemoteProto.Message.Response.Type.CUSTOM_OUTPUT_OBJECT) { final JavacRemoteProto.Message.Response.OutputObject outputObject = response.getOutputObject(); final String pluginId = outputObject.getFilePath(); final String name = outputObject.getClassName(); final byte[] content = outputObject.hasContent()? outputObject.getContent().toByteArray() : new byte[0]; myDiagnosticSink.customOutputData(pluginId, name, content); return false; } if (responseType == JavacRemoteProto.Message.Response.Type.BUILD_COMPLETED) { if (response.hasCompletionStatus()) { myTerminatedSuccessfully = response.getCompletionStatus(); } return true; } throw new Exception("Unsupported response type: " + responseType.name()); } if (messageType == JavacRemoteProto.Message.Type.FAILURE) { final JavacRemoteProto.Message.Failure failure = msg.getFailure(); final StringBuilder buf = new StringBuilder(); if (failure.hasDescription()) { buf.append(failure.getDescription()); } if (failure.hasStacktrace()) { if (buf.length() > 0) { buf.append("\n"); } buf.append(failure.getStacktrace()); } //noinspection HardCodedStringLiteral myDiagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, buf.toString())); return true; } throw new Exception("Unsupported message type: " + messageType.name()); } catch (Throwable e) { myDiagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, e.getMessage())); return true; } }