|
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;
|
@@ -704,6 +707,31 @@ public String codeComplete(SketchFile file, int line, int col) throws RunnerExce
|
704 | 707 | try {
|
705 | 708 | return builder.codeComplete(BaseNoGui.getTargetBoard(), pathToSketch, requestedFile, line, col);
|
706 | 709 | //return new Compiler(pathToSketch, sketch).codeComplete(editor.status.getCompilerProgressListeners(), requestedFile, line, col);
|
| 710 | + } catch (Exception x) { |
| 711 | + |
| 712 | + // Try getting some more useful information about the error; |
| 713 | + // Launch the same command in non-daemon mode, overriding verbosity to |
| 714 | + // print the actual call |
| 715 | + // TODO: override verbosity |
| 716 | + try { |
| 717 | + // Gather command line and preprocesor output |
| 718 | + String out = new Compiler(pathToSketch, sketch) |
| 719 | + .codeComplete(editor.status.getCompilerProgressListeners(), |
| 720 | + requestedFile, line, col); |
| 721 | + System.out.println("autocomplete failure output:\n" + out); |
| 722 | + |
| 723 | + SwingUtilities.invokeLater(() -> { |
| 724 | + NotificationPopup notificationPopup = new NotificationPopup(editor, |
| 725 | + null, tr("Code complete is not available. Try increasing ulimit."), |
| 726 | + true); |
| 727 | + notificationPopup.beginWhenFocused(); |
| 728 | + }); |
| 729 | + |
| 730 | + return ""; |
| 731 | + } catch (Exception e) { |
| 732 | + // Ignore |
| 733 | + return ""; |
| 734 | + } |
707 | 735 | } finally {
|
708 | 736 | // Make sure we clean up any temporary sketch copy
|
709 | 737 | if (deleteTemp)
|
|
0 commit comments