Commits

Anonymous committed abb8a6f

Loading projects create markers for compile errors. However at this point they are not yet displayed - there are some bugs.

  • Participants
  • Parent commits 30b86e8

Comments (0)

Files changed (3)

File src/org/lispdev/swank/LispImplementation.java

 
 import java.io.IOException;
 
+import org.eclipse.core.resources.IMarker;
 import org.eclipse.debug.core.DebugException;
 import org.lispdev.console.core.IPartitionData;
 import org.lispdev.log.Log;
       }
       catch(DebugException e)
       {
-        Log.logException("", e);
+        Log.logException(e);
       }
       for( int i = 2; i < c.getParamsCount(); ++i )
       {
   {
     LispNode res = n.getf(":return").getf(":ok").getf(":swank-compilation-unit");
     CompilationInfo info = new CompilationInfo();
-    for(LispNode ni : res.get(0).getParams())
+    for(LispNode ni : res.getParams())
     {
       LispNode loc = ni.getf(":location");
       CompileMessage m;
       {
         m = new CompileMessage(ni.getf(":message").value,
             ni.getf(":short-message").value,
-            severityToString(ni.getf(":severity")), loc.getf(":error").value);
+            severity2int(ni.getf(":severity")), loc.getf(":error").value);
       }
       else
       {
         m = new CompileMessage(ni.getf(":message").value,
             ni.getf(":short-message").value,
-            severityToString(ni.getf(":severity")),
-            loc.getf(":buffer").value, loc.getf(":position").value);
+            severity2int(ni.getf(":severity")),
+            loc.getf(":buffer").value,
+            Integer.parseInt(loc.getf(":position").value));
       }
       info.messages.add(m);
     }
     return info;
   }
 
-  private static String severityToString(LispNode severity)
+  private static int severity2int(LispNode severity)
   {
     String s = severity.value.toLowerCase();
     if( s == null || s.equals("") )
     {
-      return "";
+      return -1;
     }
     if( s.contains("error") )
     {
-      return CompileMessage.ERROR;
+      return IMarker.SEVERITY_ERROR;
     }
     if( s.contains("warning") )
     {
-      return CompileMessage.WARNING;
+      return IMarker.SEVERITY_WARNING;
     }
     if( s.contains("note") )
     {
-      return CompileMessage.INFO;
+      return IMarker.SEVERITY_INFO;
     }
-    return "";
+    return -1;
   }
 
   /*

File src/org/lispdev/swank/SwankInterfaceTest.java

 
   public SwankInterfaceTest()
   {
-    super(null,
+    super("tt",
         new LocalLispImplementation("tt", "tt", null, null, 1, true),null);
   }
 

File src/org/lispdev/swank/runnables/SwankCompilationRunnable.java

 package org.lispdev.swank.runnables;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
+import org.eclipse.core.resources.IMarker;
 import org.lispdev.swank.LispImplementation;
 
 public abstract class SwankCompilationRunnable extends SwankRunnable
   public static class CompilationInfo
   {
     public final List<CompileMessage> messages = new ArrayList<CompileMessage>();
+    @Override
+    public String toString()
+    {
+      return Arrays.deepToString(
+          messages.toArray(new CompileMessage[messages.size()]));
+    }
   }
 
   public static class CompileMessage
   {
-    public static final String WARNING = "warning";
-    public static final String ERROR = "error";
-    public static final String INFO = "info";
     public final String message;
-    public final String severity;
+    /**
+     * one of severity values from {@link IMarker}
+     */
+    public final int severity;
     public final String locationError;
     public final String file;
-    public final String position;
+    public final int position;
     public final String shortMessage;
 
-    public CompileMessage(String message, String shortMessage, String severity,
-        String file, String position)
+    public CompileMessage(String message, String shortMessage, int severity,
+        String file, int position)
     {
       this.message = message;
       this.severity = severity;
       this.shortMessage = shortMessage;
     }
 
-    public CompileMessage(String message, String shortMessage, String severity,
+    public CompileMessage(String message, String shortMessage, int severity,
         String locationError)
     {
       this.message = message;
       this.severity = severity;
       this.locationError = locationError;
       this.file = null;
-      this.position = null;
+      this.position = -1;
       this.shortMessage = shortMessage;
     }
+
+    @Override
+    public String toString()
+    {
+      StringBuilder sb = new StringBuilder();
+      sb.append('[');
+      sb.append(shortMessage);
+      sb.append(',');
+      switch(severity)
+      {
+        case IMarker.SEVERITY_ERROR:
+          sb.append(":error");
+          break;
+        case IMarker.SEVERITY_WARNING:
+          sb.append(":warning");
+          break;
+        case IMarker.SEVERITY_INFO:
+          sb.append(":info");
+          break;
+        default:
+          sb.append(":unknown");
+          break;
+      }
+      sb.append(',');
+      sb.append("pos:");
+      sb.append(String.valueOf(position));
+      sb.append(',');
+      sb.append(String.valueOf(file));
+      sb.append(']');
+      return sb.toString();
+    }
   }
 
 }