@Nullable @Override public CloudLineBreakpointProperties createProperties() { return new CloudLineBreakpointProperties(); }
@Override public void loadState(CloudLineBreakpointProperties state) { watchExpressions = state.getWatchExpressions(); }
/** * Sets the watch expressions and returns if the passed in expression differ from the currently * set ones. */ public final boolean setWatchExpressions(@Nullable String[] watchExpressions) { boolean changed = !arrayEqual(this.watchExpressions, watchExpressions); if (changed) { this.watchExpressions = watchExpressions == null ? null : Arrays.copyOf(watchExpressions, watchExpressions.length); } return changed; }
removedBp.set(null); CloudLineBreakpointProperties properties = new CloudLineBreakpointProperties(); properties.setWatchExpressions(watches); properties.setCreatedByServer(createdByServer);
if (ideBreakpoint.getProperties().isCreatedByServer()) { if (ideBreakpoint.getProperties().isAddedOnServer() && !ideBreakpoint.getProperties().isDisabledByServer()) {
newXIdeBreakpoint .getProperties() .setWatchExpressions( serverBreakpoint .getExpressions() newXIdeBreakpoint.getProperties().setCreatedByServer(false); com.intellij.debugger.ui.breakpoints.Breakpoint cloudIdeBreakpoint = BreakpointManager.getJavaBreakpoint(newXIdeBreakpoint);
assertThat(cloudLineBreakpointProperties.getWatchExpressions()).hasLength(1); assertThat(cloudLineBreakpointProperties.getWatchExpressions()[0]) .isEqualTo(MOCK_BREAKPOINT_EXPRESSION); assertFalse(cloudLineBreakpointProperties.isCreatedByServer());
final CloudLineBreakpointProperties properties = new CloudLineBreakpointProperties(); properties.setCreatedByServer(true); addedBreakpoint = true; ApplicationManager.getApplication()
@SuppressWarnings("unchecked") public void testUnregisterBreakpoint_shouldSetAddedOnServerToFalseAfterClientDisablesBp() throws Exception { XLineBreakpointImpl breakpoint = registerMockBreakpoint( psiJavaFile, NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc"); assertNotNull(breakpoint.getProperties()); assertTrue(((CloudLineBreakpointProperties) breakpoint.getProperties()).isAddedOnServer()); handler.unregisterBreakpoint(breakpoint, false); assertFalse(((CloudLineBreakpointProperties) breakpoint.getProperties()).isAddedOnServer()); verify(stateController).deleteBreakpointAsync("12abc"); }
@SuppressWarnings("ConstantConditions") @Override public void saveTo(@NotNull final XLineBreakpoint<CloudLineBreakpointProperties> ideBreakpoint) { CloudLineBreakpointProperties properties = ideBreakpoint.getProperties(); if (properties == null) { LOG.error( "Could not save changes to the breakpoint because for some reason it does not have cloud " + "properties."); return; } XBreakpointBase lineBreakpointImpl = ideBreakpoint instanceof XBreakpointBase ? (XBreakpointBase) ideBreakpoint : null; if (rootNode != null && lineBreakpointImpl != null) { List<String> expressionsToSave = new ArrayList<String>(); List<? extends WatchNode> children = rootNode.getAllChildren(); if (children != null) { for (WatchNode node : rootNode.getAllChildren()) { expressionsToSave.add(node.getExpression().getExpression()); } if (properties.setWatchExpressions( expressionsToSave.toArray(new String[expressionsToSave.size()]))) { lineBreakpointImpl.fireBreakpointChanged(); } } } }
@Override public void unregisterBreakpoint( @NotNull XLineBreakpoint<CloudLineBreakpointProperties> ideBreakpoint, boolean temporary) { // If the state was set to disabled as a result of a server update, // then we do not need to update the server side. if (!ideBreakpoint.getProperties().isDisabledByServer()) { String breakpointId = ideBreakpoint.getUserData(CLOUD_ID); if (!Strings.isNullOrEmpty(breakpointId)) { process.getStateController().deleteBreakpointAsync(breakpointId); } else { LOG.warn("could not delete breakpoint because it was not added through the cloud handler."); } } // reset this flag: either it has been disabled by the server or the client has deleted it, in // both cases we need to add it again, if it is re-enabled ideBreakpoint.getProperties().setAddedOnServer(false); } }
/** * Called when the server records a new snapshot, we find the IDE representation and disable it. */ public void setStateToDisabled(@NotNull Breakpoint serverBreakpoint) { final XBreakpoint ideBreakpoint = ideBreakpoints.get(serverBreakpoint.getId()); if (ideBreakpoint != null && ideBreakpoint.getProperties() instanceof CloudLineBreakpointProperties) { CloudLineBreakpointProperties properties = (CloudLineBreakpointProperties) ideBreakpoint.getProperties(); properties.setDisabledByServer(true); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { ideBreakpoint.setEnabled(false); } }); } }
@SuppressWarnings("unchecked") public void testUnregisterBreakpoint_shouldSetAddedOnServerToFalseAfterHitOnBackend() throws Exception { XLineBreakpointImpl breakpoint = registerMockBreakpoint( psiJavaFile, NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc"); handler.setStateToDisabled(new Breakpoint().setId("12abc")); assertNotNull(breakpoint.getProperties()); assertTrue(((CloudLineBreakpointProperties) breakpoint.getProperties()).isAddedOnServer()); handler.unregisterBreakpoint(breakpoint, false); assertFalse(((CloudLineBreakpointProperties) breakpoint.getProperties()).isAddedOnServer()); verify(stateController, never()).deleteBreakpointAsync("12abc"); }
@Override public void run() { if (finalserverBreakpoint.getExpressions() != null && finalserverBreakpoint.getExpressions().size() > 0) { properties.setWatchExpressions( finalserverBreakpoint .getExpressions() .toArray(new String[finalserverBreakpoint.getExpressions().size()])); } XLineBreakpoint<CloudLineBreakpointProperties> newxIdeBreakpoint = manager.addLineBreakpoint( CloudLineBreakpointType.getInstance(), file.getUrl(), line, properties); // Condition, watches. if (!Strings.isNullOrEmpty(finalserverBreakpoint.getCondition())) { newxIdeBreakpoint.setCondition(finalserverBreakpoint.getCondition()); } } });
@Nullable @Override public CloudLineBreakpointProperties createBreakpointProperties( @NotNull VirtualFile file, int line) { return new CloudLineBreakpointProperties(); }
/** Get the watch expressions from the breakpoint. */ @Nullable public List<String> getWatchExpressions() { CloudLineBreakpointProperties properties = (CloudLineBreakpointProperties) getXBreakpoint().getProperties(); if (properties.getWatchExpressions() != null && properties.getWatchExpressions().length > 0) { return Arrays.asList(properties.getWatchExpressions()); } return null; }
isA(CloudLineBreakpointProperties.class))) .thenReturn(mockLineBreakpoint); when(mockLineBreakpoint.getProperties()).thenReturn(new CloudLineBreakpointProperties()); VirtualFile projectDir = mock(VirtualFile.class); when(projectDir.getPath()).thenReturn("/project/dir");
null); List<XExpression> watches = new ArrayList<XExpression>(); for (String watchExpression : breakpoint.getProperties().getWatchExpressions()) { watches.add( debuggerEditorsProvider.createExpression(
final CloudLineBreakpointProperties properties = new CloudLineBreakpointProperties(); final Breakpoint finalserverBreakpoint = serverBreakpoint; ApplicationManager.getApplication()