diff dwtx/jface/text/formatter/MultiPassContentFormatter.d @ 162:1a5b8f8129df

...
author Frank Benoit <benoit@tionex.de>
date Mon, 08 Sep 2008 00:51:37 +0200
parents 25f1f92fa3df
children
line wrap: on
line diff
--- a/dwtx/jface/text/formatter/MultiPassContentFormatter.d	Wed Aug 27 14:49:30 2008 +0200
+++ b/dwtx/jface/text/formatter/MultiPassContentFormatter.d	Mon Sep 08 00:51:37 2008 +0200
@@ -116,7 +116,7 @@
     /** The partitioning of this content formatter */
     private const String fPartitioning;
     /** The slave formatting strategies */
-    private const Map fSlaves= new HashMap();
+    private const Map fSlaves;
     /** The default content type */
     private const String fType;
 
@@ -127,6 +127,8 @@
      * @param type the default content type
      */
     public this(String partitioning, String type) {
+        fSlaves= new HashMap();
+
         fPartitioning= partitioning;
         fType= type;
     }
@@ -136,12 +138,12 @@
      */
     public final void format(IDocument medium, IFormattingContext context) {
 
-        context.setProperty(FormattingContextProperties.CONTEXT_MEDIUM, medium);
+        context.setProperty(stringcast(FormattingContextProperties.CONTEXT_MEDIUM), cast(Object)medium);
 
-        final Boolean document= cast(Boolean)context.getProperty(FormattingContextProperties.CONTEXT_DOCUMENT);
+        final Boolean document= cast(Boolean)context.getProperty(stringcast(FormattingContextProperties.CONTEXT_DOCUMENT));
         if (document is null || !document.booleanValue()) {
 
-            final IRegion region= cast(IRegion)context.getProperty(FormattingContextProperties.CONTEXT_REGION);
+            final IRegion region= cast(IRegion)context.getProperty(stringcast(FormattingContextProperties.CONTEXT_REGION));
             if (region !is null) {
                 try {
                     formatMaster(context, medium, region.getOffset(), region.getLength());
@@ -165,8 +167,8 @@
 
         final FormattingContext context= new FormattingContext();
 
-        context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.FALSE);
-        context.setProperty(FormattingContextProperties.CONTEXT_REGION, region);
+        context.setProperty(stringcast(FormattingContextProperties.CONTEXT_DOCUMENT), Boolean.FALSE);
+        context.setProperty(stringcast(FormattingContextProperties.CONTEXT_REGION), cast(Object)region);
 
         format(medium, context);
     }
@@ -199,7 +201,7 @@
 
         if (fMaster !is null) {
 
-            context.setProperty(FormattingContextProperties.CONTEXT_PARTITION, new TypedPosition(offset, length, fType));
+            context.setProperty(stringcast(FormattingContextProperties.CONTEXT_PARTITION), new TypedPosition(offset, length, fType));
 
             fMaster.formatterStarts(context);
             fMaster.format();
@@ -227,7 +229,7 @@
         final IFormattingStrategyExtension strategy= cast(IFormattingStrategyExtension)fSlaves.get(type);
         if (strategy !is null) {
 
-            context.setProperty(FormattingContextProperties.CONTEXT_PARTITION, new TypedPosition(offset, length, type));
+            context.setProperty(stringcast(FormattingContextProperties.CONTEXT_PARTITION), new TypedPosition(offset, length, type));
 
             strategy.formatterStarts(context);
             strategy.format();
@@ -306,7 +308,7 @@
      *  {@link IFormattingStrategyExtension}
      */
     public final void setMasterStrategy(IFormattingStrategy strategy) {
-        Assert.isTrue( cast(IFormattingStrategyExtension)strategy );
+        Assert.isTrue( null !is cast(IFormattingStrategyExtension)strategy );
         fMaster= cast(IFormattingStrategyExtension) strategy;
     }
 
@@ -324,8 +326,8 @@
      *  must implement {@link IFormattingStrategyExtension}
      */
     public final void setSlaveStrategy(IFormattingStrategy strategy, String type) {
-        Assert.isTrue( cast(IFormattingStrategyExtension)strategy );
+        Assert.isTrue( null !is cast(IFormattingStrategyExtension)strategy );
         if (!fType.equals(type))
-            fSlaves.put(type, strategy);
+            fSlaves.put(type, cast(Object)strategy);
     }
 }