From c808ac4a00fdf1842c8ed5ce0312e74202b5863a Mon Sep 17 00:00:00 2001 From: kitakkun <48154936+kitakkun@users.noreply.github.com> Date: Sat, 6 Jul 2024 19:52:30 +0900 Subject: [PATCH] fix the flipper plugin implementation --- backintime-flipper-plugin/.gitignore | 3 ++- .../src/__tests__/test.incomingEvents.tsx | 8 ++++++-- .../src/data/MethodCallInfo.tsx | 4 +++- backintime-flipper-plugin/src/reducer/appReducer.tsx | 4 +++- .../src/view/page/backintime/BackInTimeModalPage.tsx | 12 +++++------- .../src/view/page/backintime/BackInTimeSelector.tsx | 2 +- .../EditAndEmitValueModalPage.tsx | 4 ++-- .../edited_value_emitter/EditAndEmitValueReducer.tsx | 3 ++- .../edited_value_emitter/EditAndEmitValueView.tsx | 3 ++- .../src/view/page/instance_list/InstanceListPage.tsx | 3 +-- .../view/page/instance_list/InstanceListSelector.tsx | 2 +- .../view/page/value_emit/ChangedPropertiesView.tsx | 2 +- .../src/view/page/value_emit/ValueEmitModalPage.tsx | 6 +++--- .../PropertyInspectorStateSelector.tsx | 4 ++-- 14 files changed, 34 insertions(+), 26 deletions(-) diff --git a/backintime-flipper-plugin/.gitignore b/backintime-flipper-plugin/.gitignore index bbe09586..277ec51a 100644 --- a/backintime-flipper-plugin/.gitignore +++ b/backintime-flipper-plugin/.gitignore @@ -2,4 +2,5 @@ node_modules dist/ .idea/* !.idea/codeStyles -*.tgz \ No newline at end of file +*.tgz +*.map diff --git a/backintime-flipper-plugin/src/__tests__/test.incomingEvents.tsx b/backintime-flipper-plugin/src/__tests__/test.incomingEvents.tsx index 8e3fbecd..8049f2a4 100644 --- a/backintime-flipper-plugin/src/__tests__/test.incomingEvents.tsx +++ b/backintime-flipper-plugin/src/__tests__/test.incomingEvents.tsx @@ -71,6 +71,7 @@ test(`notifyMethodCall event`, () => { sendEvent("notifyMethodCall", { methodName: "hoge", + ownerClassFqName: "com.example.MyClass", instanceUUID: "7fd43b42-f951-4307-a997-85f6074c17c9", methodCallUUID: "jf245181-8d9f-4d9e-9a7b-1a7f4b6f0b3e", calledAt: 1619813420, @@ -80,6 +81,7 @@ test(`notifyMethodCall event`, () => { expect(state.methodCallInfoList[0]).toEqual({ instanceUUID: "7fd43b42-f951-4307-a997-85f6074c17c9", + ownerClassFqName: "com.example.MyClass", methodName: "hoge", callUUID: "jf245181-8d9f-4d9e-9a7b-1a7f4b6f0b3e", calledAt: 1619813420, @@ -97,6 +99,7 @@ test(`notifyValueChange event`, () => { sendEvent("notifyMethodCall", { methodName: "hoge", + ownerClassFqName: "com.example.MyClass", instanceUUID: instanceUUID, methodCallUUID: methodCallUUID, calledAt: calledAt, @@ -104,7 +107,8 @@ test(`notifyValueChange event`, () => { sendEvent("notifyValueChange", { instanceUUID: instanceUUID, - propertyFqName: "hoge", + ownerClassFqName: "com.example.MyClass", + propertyName: "hoge", value: "fuga", methodCallUUID: methodCallUUID, } as NotifyValueChange); @@ -116,7 +120,7 @@ test(`notifyValueChange event`, () => { calledAt: calledAt, valueChanges: [ { - propertyFqName: "hoge", + propertyName: "hoge", value: "fuga", } ], diff --git a/backintime-flipper-plugin/src/data/MethodCallInfo.tsx b/backintime-flipper-plugin/src/data/MethodCallInfo.tsx index ff4b44d6..e21e4768 100644 --- a/backintime-flipper-plugin/src/data/MethodCallInfo.tsx +++ b/backintime-flipper-plugin/src/data/MethodCallInfo.tsx @@ -1,4 +1,5 @@ export interface MethodCallInfo { + ownerClassFqName: string; callUUID: string; instanceUUID: string; methodName: string; @@ -7,6 +8,7 @@ export interface MethodCallInfo { } export interface ValueChangeInfo { - propertyFqName: string; + ownerClassFqName: string; + propertyName: string; value: string; } diff --git a/backintime-flipper-plugin/src/reducer/appReducer.tsx b/backintime-flipper-plugin/src/reducer/appReducer.tsx index 1c1732df..03f89a26 100644 --- a/backintime-flipper-plugin/src/reducer/appReducer.tsx +++ b/backintime-flipper-plugin/src/reducer/appReducer.tsx @@ -85,6 +85,7 @@ const appSlice = createSlice({ registerMethodCall: (state, action: PayloadAction) => { const event = action.payload; state.methodCallInfoList.push({ + ownerClassFqName: event.ownerClassFqName, callUUID: event.methodCallUUID, instanceUUID: event.instanceUUID, methodName: event.methodName, @@ -97,7 +98,8 @@ const appSlice = createSlice({ const methodCallInfo = state.methodCallInfoList.find((info) => info.callUUID == event.methodCallUUID); if (!methodCallInfo) return; methodCallInfo.valueChanges.push({ - propertyFqName: event.propertyFqName, + ownerClassFqName: event.ownerClassFqName, + propertyName: event.propertyName, value: event.value, }); }, diff --git a/backintime-flipper-plugin/src/view/page/backintime/BackInTimeModalPage.tsx b/backintime-flipper-plugin/src/view/page/backintime/BackInTimeModalPage.tsx index d3b5a1be..61ab180e 100644 --- a/backintime-flipper-plugin/src/view/page/backintime/BackInTimeModalPage.tsx +++ b/backintime-flipper-plugin/src/view/page/backintime/BackInTimeModalPage.tsx @@ -34,15 +34,13 @@ export function BackInTimeModalPage() { .filter((history) => history.title == "methodCall") .map((history) => history as MethodCallHistoryInfo); const allValueChanges = methodCallHistories.flatMap((history) => history.valueChanges); - const properties = distinctBy(allValueChanges.map((valueChange) => valueChange.propertyFqName), (name) => name); - properties.forEach((name) => { - const value = allValueChanges.reverse().find((valueChange) => valueChange.propertyFqName == name)?.value; - if (!value) return; + const propertyValueChanges = distinctBy(allValueChanges.reverse(), (valueChange) => valueChange.ownerClassFqName + valueChange.propertyName); + propertyValueChanges.forEach((info) => { const event = new BackInTimeDebuggerEvent.ForceSetPropertyValue( state.instanceUUID, - name, - value, - "", // 使われてないから大丈夫 + info.ownerClassFqName, + info.propertyName, + info.value, ); dispatch(appActions.forceSetPropertyValue(event)); }); diff --git a/backintime-flipper-plugin/src/view/page/backintime/BackInTimeSelector.tsx b/backintime-flipper-plugin/src/view/page/backintime/BackInTimeSelector.tsx index 83c03de6..084dd3d2 100644 --- a/backintime-flipper-plugin/src/view/page/backintime/BackInTimeSelector.tsx +++ b/backintime-flipper-plugin/src/view/page/backintime/BackInTimeSelector.tsx @@ -31,7 +31,7 @@ export const backInTimeStateSelector = createSelector( title: "methodCall", timestamp: info.calledAt, subtitle: info.methodName, - description: info.valueChanges.map((change) => `${change.propertyFqName} = ${change.value}`).join(", "), + description: info.valueChanges.map((change) => `${change.propertyName} = ${change.value}`).join(", "), valueChanges: info.valueChanges, } as HistoryInfo; }); diff --git a/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueModalPage.tsx b/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueModalPage.tsx index 9c305175..f47c5286 100644 --- a/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueModalPage.tsx +++ b/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueModalPage.tsx @@ -18,12 +18,12 @@ export function EditAndEmitValueModalPage() { cancelText={"Cancel"} okText={"Emit Edited Value"} onOk={() => { - if (!state.instanceUUID || !state.propertyName || !state.valueType) return; + if (!state.instanceUUID || !state.propertyName || !state.valueType || !state.ownerClassFqName) return; const event = new BackInTimeDebuggerEvent.ForceSetPropertyValue( state.instanceUUID, + state.ownerClassFqName, state.propertyName, JSON.stringify(state.editingValue), - state.valueType, ); dispatch(appActions.forceSetPropertyValue(event)); dispatch(editAndEmitValueActions.close()); diff --git a/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueReducer.tsx b/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueReducer.tsx index 93807674..ae3c9fe2 100644 --- a/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueReducer.tsx +++ b/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueReducer.tsx @@ -58,6 +58,7 @@ export const editAndEmitValueStateSelector = createSelector( return { ...state, valueType: valueType, + ownerClassFqName: classInfo?.name, } as EditAndEmitState; } -); \ No newline at end of file +); diff --git a/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueView.tsx b/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueView.tsx index 1105d3b1..5ad25a33 100644 --- a/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueView.tsx +++ b/backintime-flipper-plugin/src/view/page/edited_value_emitter/EditAndEmitValueView.tsx @@ -8,6 +8,7 @@ export interface EditAndEmitState { editingValue: any; open: boolean; instanceUUID: string; + ownerClassFqName: string; propertyName: string; valueType: string | undefined; } @@ -34,4 +35,4 @@ export function EditAndEmitValueView({state, onEdit}: EditAndEmitValueViewProps) ); -} \ No newline at end of file +} diff --git a/backintime-flipper-plugin/src/view/page/instance_list/InstanceListPage.tsx b/backintime-flipper-plugin/src/view/page/instance_list/InstanceListPage.tsx index ab2a42ea..b5cedd7e 100644 --- a/backintime-flipper-plugin/src/view/page/instance_list/InstanceListPage.tsx +++ b/backintime-flipper-plugin/src/view/page/instance_list/InstanceListPage.tsx @@ -27,8 +27,7 @@ export function InstanceListPage() { onClickRefresh={() => { const uuids = state.instances.map((info) => info.uuid); if (uuids.length == 0) return; - const event = createCheckInstanceAliveEvent(uuids); - dispatch(appActions.refreshInstanceAliveStatuses(event)); + dispatch(appActions.refreshInstanceAliveStatuses(createCheckInstanceAliveEvent(uuids))); }} onChangeNonDebuggablePropertyVisible={(visible) => { dispatch(persistentStateActions().updateNonDebuggablePropertyVisibility(visible)); diff --git a/backintime-flipper-plugin/src/view/page/instance_list/InstanceListSelector.tsx b/backintime-flipper-plugin/src/view/page/instance_list/InstanceListSelector.tsx index 24f9bbb0..ad9feaf5 100644 --- a/backintime-flipper-plugin/src/view/page/instance_list/InstanceListSelector.tsx +++ b/backintime-flipper-plugin/src/view/page/instance_list/InstanceListSelector.tsx @@ -54,7 +54,7 @@ function resolveInstanceInfo( name: property.name, type: property.type, debuggable: property.debuggable, - eventCount: allValueChangeEvents.filter((event) => event.propertyFqName == `${classInfo.name}.${property.name}`).length, + eventCount: allValueChangeEvents.filter((event) => event.propertyName == property.name && classInfo.name == event.ownerClassFqName).length, stateHolderInstance: propertyInstanceInfo && resolveInstanceInfo( classInfoList, instanceInfoList, diff --git a/backintime-flipper-plugin/src/view/page/value_emit/ChangedPropertiesView.tsx b/backintime-flipper-plugin/src/view/page/value_emit/ChangedPropertiesView.tsx index 3c1060c5..17c78456 100644 --- a/backintime-flipper-plugin/src/view/page/value_emit/ChangedPropertiesView.tsx +++ b/backintime-flipper-plugin/src/view/page/value_emit/ChangedPropertiesView.tsx @@ -22,7 +22,7 @@ type ValueChangeItem = { export function ChangedPropertiesView({classInfo, methodCallInfo, onClickEmitValue, onClickEditAndEmitValue}: ChangedPropertiesViewProps) { const dataSource: ValueChangeItem[] = methodCallInfo.valueChanges.map((valueChange) => { // FIXME: will not work correctly for the class which has a back-in-time debuggable class as a super class. - const property = classInfo.properties.find((property) => property.name === valueChange.propertyFqName.split(".").pop())!; + const property = classInfo.properties.find((property) => property.name === valueChange.propertyName)!; const jsonValue = JSON.parse(valueChange.value); return { action: { const instanceUUID = state.instanceInfo?.uuid; const valueType = state.classInfo?.properties.find((property) => property.name == propertyName)?.valueType; - if (!instanceUUID || !valueType) { + const className = state.classInfo?.name + if (!instanceUUID || !valueType || !className) { return; } - const propertyFqName = `${state.classInfo?.name}.${propertyName}`; - const event = new BackInTimeDebuggerEvent.ForceSetPropertyValue(instanceUUID, propertyFqName, value, valueType); + const event = new BackInTimeDebuggerEvent.ForceSetPropertyValue(instanceUUID, className, propertyName, value); dispatch(appActions.forceSetPropertyValue(event)); }} onEditAndEmitValue={(propertyName: string, value: string) => { diff --git a/backintime-flipper-plugin/src/view/sidebar/property_inspector/PropertyInspectorStateSelector.tsx b/backintime-flipper-plugin/src/view/sidebar/property_inspector/PropertyInspectorStateSelector.tsx index 566da788..64d65ff5 100644 --- a/backintime-flipper-plugin/src/view/sidebar/property_inspector/PropertyInspectorStateSelector.tsx +++ b/backintime-flipper-plugin/src/view/sidebar/property_inspector/PropertyInspectorStateSelector.tsx @@ -13,13 +13,13 @@ export const propertyInspectorStateSelector = createSelector( const valueChanges = methodCallInfoList.filter((info) => // FIXME: will not work correctly for the class which has a back-in-time debuggable class as a super class. - info.instanceUUID == state.instanceUUID && info.valueChanges.some((change) => change.propertyFqName.split(".").pop() == state.propertyName) + info.instanceUUID == state.instanceUUID && info.valueChanges.some((change) => change.propertyName.split(".").pop() == state.propertyName) ).map((info) => { return { methodCallUUID: info.callUUID, time: info.calledAt, // FIXME: will not work correctly for the class which has a back-in-time debuggable class as a super class. - value: [...info.valueChanges].reverse().find((change) => change.propertyFqName.split(".").pop() == state.propertyName)?.value ?? "", + value: [...info.valueChanges].reverse().find((change) => change.propertyName.split(".").pop() == state.propertyName)?.value ?? "", } });