@Override public String getOutgoing() { if (file != null) { return makeCommand( AbstractDebuggerCommand.CMD_IGNORE_THROWN_EXCEPTION_AT, sequence, StringUtils.join("|", FileUtils.getFileAbsolutePath(file), this.lineNumber)); } else { // Bulk-creation Collection<String> ignoreThrownExceptions = PyExceptionBreakPointManager.getInstance() .ignoreCaughtExceptionsWhenThrownFrom .getIgnoreThrownExceptions(); return makeCommand( AbstractDebuggerCommand.CMD_IGNORE_THROWN_EXCEPTION_AT, sequence, "REPLACE:" + StringUtils.join("||", ignoreThrownExceptions)); } }
/** Creates options related to dealing with exceptions. */ private void createDealingWithExceptionsOptions(Composite composite) { PyExceptionBreakPointManager instance = PyExceptionBreakPointManager.getInstance(); uncaughtExceptionCheck = new Button(composite, SWT.CHECK); uncaughtExceptionCheck.setText("Suspend on uncaught exceptions"); uncaughtExceptionCheck.setSelection(instance.getBreakOnUncaughtExceptions()); caughtExceptionCheck = new Button(composite, SWT.CHECK); caughtExceptionCheck.setText("Suspend on caught exceptions *"); caughtExceptionCheck.setSelection(instance.getBreakOnCaughtExceptions()); stopOnExceptionsHandledInSameContextCheck = new Button(composite, SWT.CHECK); stopOnExceptionsHandledInSameContextCheck.setText( " Skip exceptions caught in same function"); stopOnExceptionsHandledInSameContextCheck.setSelection( instance.getSkipCaughtExceptionsInSameFunction()); ignoreExceptionsThrownInLinesWithIgnoreExceptionCheck = new Button(composite, SWT.CHECK); ignoreExceptionsThrownInLinesWithIgnoreExceptionCheck.setText( " Ignore exceptions thrown in lines with # @IgnoreException"); ignoreExceptionsThrownInLinesWithIgnoreExceptionCheck.setSelection( instance.getIgnoreExceptionsThrownInLinesWithIgnoreException()); caughtExceptionCheck.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { updateStates(); } @Override public void widgetDefaultSelected(SelectionEvent e) {} }); updateStates(); Label label = new Label(composite, SWT.NONE); label.setText("* Will make debugging ~ 2x slower"); breakOnDjangoTemplateExceptionsCheck = new Button(composite, SWT.CHECK); breakOnDjangoTemplateExceptionsCheck.setText("Suspend on django template render exceptions"); breakOnDjangoTemplateExceptionsCheck.setSelection( PydevPlugin.getDefault() .getPreferenceStore() .getBoolean(AbstractPydevPrefs.TRACE_DJANGO_TEMPLATE_RENDER_EXCEPTIONS)); }
@Override public void run() { IPath ignoreThrownExceptionsPath = PyExceptionBreakPointManager.getInstance() .ignoreCaughtExceptionsWhenThrownFrom .getIgnoreThrownExceptionsPath(); File file = ignoreThrownExceptionsPath.toFile(); IEditorPart openFile = EditorUtils.openFile(file); if (openFile instanceof ITextEditor) { final ITextEditor textEditor = (ITextEditor) openFile; IDocumentProvider documentProvider = textEditor.getDocumentProvider(); final IEditorInput input = openFile.getEditorInput(); if (documentProvider instanceof IStorageDocumentProvider) { IStorageDocumentProvider storageDocumentProvider = (IStorageDocumentProvider) documentProvider; // Make sure the file is seen as UTF-8. storageDocumentProvider.setEncoding(input, "utf-8"); textEditor.doRevertToSaved(); } if (textEditor instanceof ISaveablePart) { IPropertyListener listener = new IPropertyListener() { @Override public void propertyChanged(Object source, int propId) { if (propId == IWorkbenchPartConstants.PROP_DIRTY) { if (source == textEditor) { if (textEditor.getEditorInput() == input) { if (!textEditor.isDirty()) { PyExceptionBreakPointManager.getInstance() .ignoreCaughtExceptionsWhenThrownFrom .updateIgnoreThrownExceptions(); } } } } } }; textEditor.addPropertyListener(listener); } } // Code to provide a dialog to edit it (decided on opening the file instead). // Collection<IgnoredExceptionInfo> ignoreThrownExceptionsForEdition = // PyExceptionBreakPointManager.getInstance() // .getIgnoreThrownExceptionsForEdition(); // HashMap<String, String> map = new HashMap<>(); // for (IgnoredExceptionInfo ignoredExceptionInfo : ignoreThrownExceptionsForEdition) { // map.put(ignoredExceptionInfo.filename + ": " + ignoredExceptionInfo.line, // ignoredExceptionInfo.contents); // } // // EditIgnoredCaughtExceptionsDialog dialog = new // EditIgnoredCaughtExceptionsDialog(EditorUtils.getShell(), map); // int open = dialog.open(); // if (open == dialog.OK) { // Map<String, String> result = dialog.getResult(); // // } else { // System.out.println("Cancel"); // } }