/** * This is called right at the start of query execution and its the first step in the instrumentation chain. * * @param parameters the parameters to this step * * @return a non null {@link InstrumentationContext} object that will be called back when the step ends */
InstrumentationContext<ExecutionResult> beginExecution(InstrumentationExecutionParameters parameters);
/** * This is called just before a field is resolved into a value. * * @param parameters the parameters to this step * * @return a non null {@link InstrumentationContext} object that will be called back when the step ends */
InstrumentationContext<ExecutionResult> beginField(InstrumentationFieldParameters parameters);
INFO a.u.m.p.i.LogDeprecatedQueryInstrumentation - description
INFO a.u.m.p.i.LogDeprecatedQueryInstrumentation - description
INFO a.u.m.p.i.LogDeprecatedQueryInstrumentation - description
INFO a.u.m.p.i.LogDeprecatedQueryInstrumentation - description
INFO a.u.m.p.i.LogDeprecatedQueryInstrumentation - description
INFO a.u.m.p.i.LogDeprecatedQueryInstrumentation - description
InstrumentationやSimpleInstrumentationクラスは全て begin しか提供されていません。終わった時の処理はwhenCompletedメソッドを利用します。
/** * Allows for the more fluent away to return an instrumentation context that runs the specified * code on instrumentation step completion. * * @param codeToRun the code to run on completion * @param <U> the generic type * * @return an instrumentation context */publicstatic <U> SimpleInstrumentationContext<U> whenCompleted(BiConsumer<U, Throwable> codeToRun) {
returnnew SimpleInstrumentationContext<>(null, codeToRun);
}
/** * Adds a provider for drawing custom text annotations in the editor gutter, with the * possibility to execute an action when the annotation is clicked. * * @param provider the provider instance. * @param action the action to execute when the annotation is clicked. */void registerTextAnnotation(@NotNull TextAnnotationGutterProvider provider, @NotNull EditorGutterAction action);
/** * Returns the text which should be drawn for the line with the specified number in the specified editor. * * @param line the line for which the text is requested. * @param editor the editor in which the text will be drawn. * @return the text to draw, or null if no text should be drawn. */@Nullable
String getLineText(int line, Editor editor);
これを踏まえて、 getLineText の実装をします。最初に問題になるのが、 line の意味です。the line for which the text is requested. と記述されていますが、説明が圧倒的に足りていません。というか、説明通りに受け取ってはいけません。この line は Annotate が表示された時の行番号に当たります。今まさにEditorで表示されている行番号ではありません。受け取った line をそのまま利用するのは危険です。 line が今表示されているエディターの行番号としてどこに当たるのかを確認し、その確認した行番号に対して情報を返さないといけません。(ここを読むような訓練されたプラグイン開発者なら「あーよくあるやつね」となるいつものやつです。)
val upToDateLineNumberProvider = UpToDateLineNumberProviderImpl(editor?.document, editor?.project)
val currentLine = upToDateLineNumberProvider.getLineNumber(line)
/** * Processes the click on the specified line. * * @param lineNum the number of line in the document the annotation for which was clicked. */void doAction(int lineNum);
/** * Notify that annotations should be closed*/publicsynchronizedfinalvoid close() {
myIsClosed = true;
if (myCloser != null) {
myCloser.run();
myCloser = null;
myReloader = null;
}
}
/** * Notify that annotation information has changed, and should be updated. * If `this` is visible, hide it and show new one instead. * If `this` is not visible, do nothing. * * @param newFileAnnotation annotations to be shown or `null` to load annotations again */@CalledInAwtpublicsynchronizedfinalvoid reload(@Nullable FileAnnotation newFileAnnotation) {
if (myReloader != null) myReloader.consume(newFileAnnotation);
}
/** * @see #close() */publicsynchronizedfinalvoid setCloser(@NotNull Runnable closer) {
if (myIsClosed) return;
myCloser = closer;
}
/** * @see #reload(FileAnnotation) */publicsynchronizedfinalvoid setReloader(@Nullable Consumer<? super FileAnnotation> reloader) {
if (myIsClosed) return;
myReloader = reloader;
}
java.lang.Throwable: Synchronous execution on EDT: /usr/bin/git -c ...
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:145)
at com.intellij.execution.process.OSProcessHandler.checkEdtAndReadAction(OSProcessHandler.java:117)
at com.intellij.execution.process.OSProcessHandler.waitFor(OSProcessHandler.java:62)
at git4idea.commands.GitTextHandler.waitForProcess(GitTextHandler.java:145)
at git4idea.commands.GitHandler.runInCurrentThread(GitHandler.java:383)
at git4idea.commands.GitImplBase.doRun(GitImplBase.java:172)
at git4idea.commands.GitImplBase.run(GitImplBase.java:148)
at git4idea.commands.GitImplBase.runCommand(GitImplBase.java:46)
at git4idea.commands.GitImpl.runCommand(GitImpl.java:41)
java.lang.Throwable: Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:162)
at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1027)
at com.intellij.openapi.editor.impl.EditorImpl.assertReadAccess(EditorImpl.java:3254)
at com.intellij.openapi.editor.impl.EditorImpl.getSettings(EditorImpl.java:920)
dataclass GraphQLRequest(
val query: String = "",
val operationName: String? = "",
val variables: Map<String, Any>? = mapOf()
)
Ktorでデフォルトで使える、 ObjectMapper を使ってパース処理を書くと。
fun Application.module(testing: Boolean = false) {
routing {
get("/graphql") {
val stringRequest = call.receive<String>()
val mapper = ObjectMapper()
val request = mapper.readValue(stringRequest, GraphQLRequest::class.java)
}
post("/graphql") {
val stringRequest = call.receive<String>()
val mapper = ObjectMapper()
val request = mapper.readValue(stringRequest, GraphQLRequest::class.java)
}
}
}
何度も同じ処理を二箇所に書くのは辛いので、 GraphQLController を作成します。
class GraphQLController {
suspend fun handleGraphQL(call: ApplicationCall) {
val stringRequest = call.receive<String>()
val mapper = ObjectMapper()
val request = mapper.readValue(stringRequest, GraphQLRequest::class.java)
TODO()
}
}
最初、インターン先探しているということに対して、声かけるのはなしだよなーって思ったんですが、子供の朝ごはんを少しこぼしたので片付けをしていて、人ってミスするし、そこでダメって決めつけるのおかしい。優秀な子がこれでチャンス無くすのおかしい。弊社のバリューの一つが「launch x launch」(ロンロン)*1なのにグジグジ考えて行動起こさないのおかしい。と思い、声かけることにしました。