Skip to content

Commit

Permalink
Adding debug information in Mounting Manager
Browse files Browse the repository at this point in the history
Summary: This diff adds extra debug information in the mounting manager

Reviewed By: shergin

Differential Revision: D14817456

fbshipit-source-id: 5619c94eb76cdc20f5d7767f1aa4263e63f8d021
  • Loading branch information
mdvacca authored and facebook-github-bot committed Apr 10, 2019
1 parent 8fcb229 commit ebbc4f6
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,18 @@ public void addViewAt(int parentTag, int tag, int index) {
UiThreadUtil.assertOnUiThread();
ViewState parentViewState = getViewState(parentTag);
final ViewGroup parentView = (ViewGroup) parentViewState.mView;
final View view = getViewState(tag).mView;
ViewState viewState = getViewState(tag);
final View view = viewState.mView;
if (view == null) {
throw new IllegalStateException("Unable to find view for tag " + tag);
throw new IllegalStateException("Unable to find view for view " + viewState);
}
getViewGroupManager(parentViewState).addView(parentView, view, index);
}

private ViewState getViewState(int tag) {
ViewState viewState = mTagToViewState.get(tag);
if (viewState == null) {
throw new IllegalStateException("Unable to find viewState for tag " + tag);
throw new IllegalStateException("Unable to find viewState view " + viewState);
}
return viewState;
}
Expand All @@ -152,7 +153,7 @@ public void receiveCommand(int reactTag, int commandId, @Nullable ReadableArray
@SuppressWarnings("unchecked") // prevents unchecked conversion warn of the <ViewGroup> type
private static ViewGroupManager<ViewGroup> getViewGroupManager(ViewState viewState) {
if (viewState.mViewManager == null) {
throw new IllegalStateException("Unable to find ViewManager");
throw new IllegalStateException("Unable to find ViewManager for view: " + viewState);
}
return (ViewGroupManager<ViewGroup>) viewState.mViewManager;
}
Expand All @@ -175,6 +176,10 @@ public void createView(
String componentName,
int reactTag,
boolean isLayoutable) {
if (mTagToViewState.get(reactTag) != null) {
return;
}

View view = null;
ViewManager viewManager = null;

Expand Down Expand Up @@ -264,7 +269,7 @@ public void updateLocalData(int reactTag, ReadableMap newLocalData) {
ViewManager viewManager = viewState.mViewManager;

if (viewManager == null) {
throw new IllegalStateException("Unable to find ViewManager for tag: " + reactTag);
throw new IllegalStateException("Unable to find ViewManager for view: " + viewState);
}
Object extraData =
viewManager.updateLocalData(
Expand Down Expand Up @@ -304,7 +309,9 @@ public void preallocateView(
ReadableMap props,
boolean isLayoutable) {

if (mTagToViewState.get(reactTag) != null) return;
if (mTagToViewState.get(reactTag) != null) {
throw new IllegalStateException("View for component " + componentName + " with tag " + reactTag + " already exists.");
}

createView(reactContext, componentName, reactTag, isLayoutable);
if (isLayoutable) {
Expand Down Expand Up @@ -365,5 +372,10 @@ private ViewState(int reactTag, @Nullable View view, ViewManager viewManager, bo
mIsRoot = isRoot;
mViewManager = viewManager;
}

@Override
public String toString() {
return "ViewState [" + mReactTag + "] - isRoot: " + mIsRoot + " - props: " + mCurrentProps + " - localData: " + mCurrentLocalData + " - viewManager: " + mViewManager;
}
}
}

0 comments on commit ebbc4f6

Please sign in to comment.