[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[imp-commit] r22943 - trunk/org.eclipse.imp.runtime/src/org/eclipse/imp/services/base

Author: jvinju
Date: 2011-12-08 05:39:47 -0500 (Thu, 08 Dec 2011)
New Revision: 22943

Modified:
   trunk/org.eclipse.imp.runtime/src/org/eclipse/imp/services/base/FolderBase.java
Log:
added feature to set default status of fold to folded

Modified: trunk/org.eclipse.imp.runtime/src/org/eclipse/imp/services/base/FolderBase.java
===================================================================
--- trunk/org.eclipse.imp.runtime/src/org/eclipse/imp/services/base/FolderBase.java	2011-10-31 07:48:09 UTC (rev 22942)
+++ trunk/org.eclipse.imp.runtime/src/org/eclipse/imp/services/base/FolderBase.java	2011-12-08 10:39:47 UTC (rev 22943)
@@ -66,6 +66,18 @@
      * @param n an Object representing a program entity
      */
     public void makeAnnotation(Object n) {
+    	makeAnnotation(n, false);
+    }
+    
+    /**
+     * Make a folding annotation that corresponds to the extent of text
+     * represented by a given program entity. Usually, this will be an
+     * AST node, but it can be anything for which the language's
+     * ISourcePositionLocator can produce an offset/end offset.
+     * 
+     * @param n an Object representing a program entity
+     */
+    public void makeAnnotation(Object n, boolean collapsed) {
 		ISourcePositionLocator nodeLocator = parseController.getSourcePositionLocator();
 		int startOffset = 0;
 		int endOffset = 0;
@@ -77,7 +89,7 @@
 		    RuntimePlugin.getInstance().logException("Error while attempting to determine position of a foldable source entity", e);
 			return;
 		}
-		makeAnnotation(startOffset, endOffset-startOffset+1);
+		makeAnnotation(startOffset, endOffset-startOffset+1, collapsed);
     }
 
     /**
@@ -95,6 +107,22 @@
 		newAnnotations.put(annotation, new Position(start, len));
 		annotations.add(annotation);
     }
+    
+    /**
+     * Make a folding annotation that corresponds to the given range of text.
+     * 
+     * @param start		The starting offset of the text range
+     * @param len		The length of the text range
+     */
+    public void makeAnnotation(int start, int len, boolean collapsed) {
+        if (fDebugMode) {
+            PrintStream cons= RuntimePlugin.getInstance().getConsoleStream();
+            cons.println("Adding folding annotation for extent [" + start + ":" + len + "]");
+        }
+		ProjectionAnnotation annotation= new ProjectionAnnotation(collapsed);
+		newAnnotations.put(annotation, new Position(start, len));
+		annotations.add(annotation);
+    }
 
 	/**
 	 * Update the folding structure for a source text, where the text and its