Skip to content

Commit 57324f0

Browse files
cmagliefacchinm
authored andcommitted
Added more debugging output for codecompletion errors
1 parent b5717d9 commit 57324f0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

app/src/processing/app/SketchController.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import cc.arduino.UploaderUtils;
2929
import cc.arduino.builder.ArduinoBuilder;
3030
import cc.arduino.packages.Uploader;
31+
import cc.arduino.view.NotificationPopup;
3132
import processing.app.debug.RunnerException;
3233
import processing.app.forms.PasswordAuthorizationDialog;
3334
import processing.app.helpers.FileUtils;
@@ -38,6 +39,8 @@
3839

3940
import javax.swing.*;
4041
import java.awt.*;
42+
import java.awt.event.WindowEvent;
43+
import java.awt.event.WindowFocusListener;
4144
import java.io.File;
4245
import java.io.IOException;
4346
import java.nio.file.Files;
@@ -704,6 +707,31 @@ public String codeComplete(SketchFile file, int line, int col) throws RunnerExce
704707
try {
705708
return builder.codeComplete(BaseNoGui.getTargetBoard(), pathToSketch, requestedFile, line, col);
706709
//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+
}
707735
} finally {
708736
// Make sure we clean up any temporary sketch copy
709737
if (deleteTemp)

0 commit comments

Comments
 (0)