Commits

Anonymous committed 59494a5

Compile markers now switch, when config changes.

Comments (0)

Files changed (3)

org.lispdev.editor/src/org/lispdev/editor/LispMarkers.java

   static final String PARSING_ERROR = MARKER + ".parsingError";
   public static final String COMPILE = MARKER + ".compile";
 
+  public static final String ATTR_LAUNCH_NAME = "org.lispdev.marker.launchName";
+
   private static void deleteMarkers(IFile file, String marketType)
   {
     if( file != null )
     }
   }
 
-  private static HashMap<String, Object> getMarketAttributes(
+  private static HashMap<String, Object> getMarkerAttributes(
       String msg, int severity)
   {
     HashMap<String,Object> attr = new HashMap<String, Object>(2);
     return attr;
   }
 
-  private static HashMap<String, Object> getMarketAttributes(int offset,
+  private static HashMap<String, Object> getMarkerAttributes(int offset,
       int length, String msg, int severity)
   {
     HashMap<String,Object> attr = new HashMap<String, Object>(5);
     return attr;
   }
 
-  private static HashMap<String, Object> getMarketAttributes(int offset,
+  private static HashMap<String, Object> getMarkerAttributes(int offset,
       int length, int lineNum, String msg, int severity)
   {
     HashMap<String,Object> attr = new HashMap<String, Object>(6);
     attr.put(IMarker.CHAR_START, new Integer(offset));
     attr.put(IMarker.CHAR_END, new Integer(offset + length));
+    attr.put(IMarker.LINE_NUMBER, lineNum);
 
     attr.put(IMarker.MESSAGE, msg);
     attr.put(IMarker.SEVERITY, severity);
     return attr;
   }
 
+  private static HashMap<String, Object> getMarkerAttributes(int offset,
+      int length, Integer lineNum, String msg, int severity, String launchName)
+  {
+    HashMap<String,Object> attr = new HashMap<String, Object>(6);
+    attr.put(IMarker.CHAR_START, new Integer(offset));
+    attr.put(IMarker.CHAR_END, new Integer(offset + length));
+    if( lineNum != null )
+    {
+      attr.put(IMarker.LINE_NUMBER, lineNum);
+    }
+    attr.put(ATTR_LAUNCH_NAME, launchName);
+    attr.put(IMarker.MESSAGE, msg);
+    attr.put(IMarker.SEVERITY, severity);
+
+    return attr;
+  }
+
+  /**
+   * If marker m has type ending at ".quiet" then replace by the
+   * one that does not have this at the end. And vice versa.
+   * @param m
+   */
+  public static void replaceMarker(IMarker m)
+  {
+    if( m == null || m.getResource() == null ) return;
+    IResource res = m.getResource();
+    Integer def = new Integer(-1);
+    int offset = m.getAttribute(IMarker.CHAR_START, def);
+    int endoffset = m.getAttribute(IMarker.CHAR_END, def);
+    int length = ( offset < 0 || endoffset < 0 ? 0 : endoffset - offset );
+    int line = m.getAttribute(IMarker.LINE_NUMBER, def);
+    String msg = m.getAttribute(IMarker.MESSAGE, "");
+    int severity = m.getAttribute(IMarker.SEVERITY, def);
+    String type = "";
+    try
+    {
+      type = m.getType();
+    }
+    catch(CoreException e)
+    {
+      Log.logException(e);
+      return;
+    }
+    String launchName = m.getAttribute(ATTR_LAUNCH_NAME,(String)null);
+    String newtype = (type.endsWith(".quiet")
+        ? type.substring(0, type.length() - ".quiet".length())
+        : type + ".quiet");
+    try
+    {
+      m.delete();
+      addMarker(res, offset, length, line, msg, severity, newtype, launchName);
+    }
+    catch(CoreException e)
+    {
+      Log.logException(e);
+    }
+  }
+
+  public static void toggleMarkers(IResource resource,
+      String type, String launchName)
+  {
+    if( resource == null ) return;
+    try
+    {
+      IMarker[] markers =
+        resource.findMarkers(type, false, IResource.DEPTH_ZERO);
+      if( markers == null ) return;
+      for( IMarker m : markers )
+      {
+        if( m.getAttribute(ATTR_LAUNCH_NAME, "").equals(launchName) )
+        {
+          replaceMarker(m);
+        }
+      }
+    }
+    catch(CoreException e)
+    {
+      Log.logException(e);
+    }
+  }
+
   public static void addMarker(IFile file, int offset, int length,
       int lineNum, String msg, int severity, String markerType)
   {
     try
     {
       MarkerUtilities.createMarker(file,
-          getMarketAttributes(offset, length, lineNum, msg, severity),
+          getMarkerAttributes(offset, length, lineNum, msg, severity),
+          markerType);
+    }
+    catch(CoreException e)
+    {
+      Log.logException(e);
+    }
+  }
+
+  public static void addMarker(IResource file, int offset, int length,
+      int lineNum, String msg, int severity,
+      String markerType, String launchName)
+  {
+    Integer lineNumber = (lineNum < 0 ? null : new Integer(lineNum));
+    try
+    {
+      MarkerUtilities.createMarker(file,
+          getMarkerAttributes(offset, length, lineNumber,
+              msg, severity, launchName),
           markerType);
     }
     catch(CoreException e)
     try
     {
       MarkerUtilities.createMarker(file,
-          getMarketAttributes(offset, length, msg, severity), markerType);
+          getMarkerAttributes(offset, length, msg, severity), markerType);
     }
     catch(CoreException e)
     {
   {
     try
     {
-      MarkerUtilities.createMarker(project, getMarketAttributes(msg, severity),
+      MarkerUtilities.createMarker(project, getMarkerAttributes(msg, severity),
           markerType);
     }
     catch(CoreException e)

org.lispdev.main/plugin.xml

       <persistent
             value="true">
       </persistent>
+      <attribute
+            name="org.lispdev.marker.launchName">
+      </attribute>
+   </extension>
+   <extension
+         id="org.lispdev.marker.compile.quiet"
+         point="org.eclipse.core.resources.markers">
+      <super
+            type="org.lispdev.marker">
+      </super>
+      <persistent
+            value="true">
+      </persistent>
+      <attribute
+            name="org.lispdev.marker.launchName">
+      </attribute>
    </extension>
 
 </plugin>

org.lispdev.main/todo.txt

 Active lisp connects with each other:
 repl, process (with its swank), config
 given config should be able to get repl or process. process can get through
-SwankPlugin, repl should be able to get through repl plugin
+SwankPlugin, repl should be able to get through repl plugin
+
+--------------------------
+
+How to switch markers:
+Two types of compile markers: one is subtype of regular ones, that are
+displayed, second type is not a subtype of regular ones, so hopefully
+they are not displayed. Each marker has attribute, which identifies
+config it is related to.
+When a marker is created its resource is noted in markers map.
+When switch from config1 to config2:
+- check resources for config1 and replace all markers with same markers but
+not visible ones.
+- if a resource doesn't have markers, remove it from resources for config1
+- check resources for config2 and replace all markers with same markers but
+visible ones. If 
+
+ All this info is stored in a marker when it is
+created. Have map, which tracks resources, where compile markers were created
+for which config. When change active config:
+- Save all info on markers associated with current config (for each associated
+resource), also remove associated resources, if they don't have markers.
+- Delete all saved markers from resources.
+- Get resources associated with new config and add markers from new config.
+
+