|
28 | 28 | import cc.arduino.UploaderUtils; |
29 | 29 | import cc.arduino.builder.ArduinoBuilder; |
30 | 30 | import cc.arduino.packages.Uploader; |
| 31 | +import cc.arduino.view.NotificationPopup; |
31 | 32 | import processing.app.debug.RunnerException; |
32 | 33 | import processing.app.forms.PasswordAuthorizationDialog; |
33 | 34 | import processing.app.helpers.FileUtils; |
|
38 | 39 |
|
39 | 40 | import javax.swing.*; |
40 | 41 | import java.awt.*; |
| 42 | +import java.awt.event.WindowEvent; |
| 43 | +import java.awt.event.WindowFocusListener; |
41 | 44 | import java.io.File; |
42 | 45 | import java.io.IOException; |
43 | 46 | import java.nio.file.Files; |
@@ -717,6 +720,31 @@ public String codeComplete(SketchFile file, int line, int col) throws RunnerExce |
717 | 720 | try { |
718 | 721 | return builder.codeComplete(BaseNoGui.getTargetBoard(), pathToSketch, requestedFile, line, col); |
719 | 722 | //return new Compiler(pathToSketch, sketch).codeComplete(editor.status.getCompilerProgressListeners(), requestedFile, line, col); |
| 723 | + } catch (Exception x) { |
| 724 | + |
| 725 | + // Try getting some more useful information about the error; |
| 726 | + // Launch the same command in non-daemon mode, overriding verbosity to |
| 727 | + // print the actual call |
| 728 | + // TODO: override verbosity |
| 729 | + try { |
| 730 | + // Gather command line and preprocesor output |
| 731 | + String out = new Compiler(pathToSketch, sketch) |
| 732 | + .codeComplete(editor.status.getCompilerProgressListeners(), |
| 733 | + requestedFile, line, col); |
| 734 | + System.out.println("autocomplete failure output:\n" + out); |
| 735 | + |
| 736 | + SwingUtilities.invokeLater(() -> { |
| 737 | + NotificationPopup notificationPopup = new NotificationPopup(editor, |
| 738 | + null, tr("Code complete is not available. Try increasing ulimit."), |
| 739 | + true); |
| 740 | + notificationPopup.beginWhenFocused(); |
| 741 | + }); |
| 742 | + |
| 743 | + return ""; |
| 744 | + } catch (Exception e) { |
| 745 | + // Ignore |
| 746 | + return ""; |
| 747 | + } |
720 | 748 | } finally { |
721 | 749 | // Make sure we clean up any temporary sketch copy |
722 | 750 | if (deleteTemp) |
|
0 commit comments