@@ -1199,6 +1199,46 @@ private static String getRequestMethod(JsonObject request) {
1199
1199
return null ;
1200
1200
}
1201
1201
1202
+ //
1203
+ // LSP over Legacy DAS (Dart Analysis Server) protocol below
1204
+ //
1205
+ public static final String LSP_DART_TEXT_DOCUMENT_CONTENT = "dart/textDocumentContent" ;
1206
+
1207
+ private static final String LSP_HANDLE = "lsp.handle" ;
1208
+
1209
+ public static final String LSP_JSONRPC = "jsonrpc" ;
1210
+
1211
+ public static final String LSP_JSONROC_VERSION = "2.0" ;
1212
+
1213
+ public static final String LSP_MESSAGE = "lspMessage" ;
1214
+
1215
+ /**
1216
+ * Generate and return a LSP over Legacy DAS request.
1217
+ *
1218
+ * Example:
1219
+ * {"id":"2","method":"lsp.handle","params":
1220
+ * {"lspMessage":
1221
+ * {"id":0,"jsonrpc":"2.0","method":"dart/textDocumentContent","params":
1222
+ * {"position":{"character":7,"line":1},
1223
+ * "textDocument":{"uri":"some-uri"}}}}}
1224
+ */
1225
+ private static JsonObject generateLSPMessage (String idValue , String lspMethod , JsonObject lspParams ) {
1226
+ JsonObject lspMessageParams = new JsonObject ();
1227
+ lspMessageParams .addProperty (ID , idValue );
1228
+ lspMessageParams .addProperty (LSP_JSONRPC , LSP_JSONROC_VERSION );
1229
+ lspMessageParams .addProperty (METHOD , lspMethod );
1230
+ lspMessageParams .add (PARAMS , lspParams );
1231
+ JsonObject lspMessage = new JsonObject ();
1232
+ lspMessage .add (LSP_MESSAGE , lspMessageParams );
1233
+ return buildJsonObjectRequest (idValue , LSP_HANDLE , lspMessage );
1234
+ }
1235
+
1236
+ public static JsonObject generateLSPMessage_dart_textDocumentContent (String idValue , String uri ) {
1237
+ JsonObject lspParams = new JsonObject ();
1238
+ lspParams .addProperty ("uri" , uri );
1239
+ return generateLSPMessage (idValue , LSP_DART_TEXT_DOCUMENT_CONTENT , lspParams );
1240
+ }
1241
+
1202
1242
private RequestUtilities () {
1203
1243
}
1204
1244
}
0 commit comments