Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Maetzel2004-04-19 08:43:14 -0400
committerKai Maetzel2004-04-19 08:43:14 -0400
commit8ec0c2f9f03b29aff0dedc6a8e5fc92eb63be80d (patch)
tree2541ba8d41b6a263ba59c77363b1ecdda24b7a5c /org.eclipse.jface.text/src/org/eclipse/jface/text/formatter
parenta2ac643d5c76a67ca4bb381d1a046e17f2e156bc (diff)
downloadeclipse.platform.text-8ec0c2f9f03b29aff0dedc6a8e5fc92eb63be80d.tar.gz
eclipse.platform.text-8ec0c2f9f03b29aff0dedc6a8e5fc92eb63be80d.tar.xz
eclipse.platform.text-8ec0c2f9f03b29aff0dedc6a8e5fc92eb63be80d.zip
API cleanup
Diffstat (limited to 'org.eclipse.jface.text/src/org/eclipse/jface/text/formatter')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java11
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java76
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java75
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java21
4 files changed, 72 insertions, 111 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
index a13de6cec..4d2c21018 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
@@ -61,8 +61,9 @@ import org.eclipse.jface.text.TypedPosition;
* @see IDocument
* @see ITypedRegion
* @see Position
+ * @deprecated since 3.0, use <code>MultiPassContentFormatter</code> instead
*/
-public class ContentFormatter implements IContentFormatter, IContentFormatterExtension {
+public class ContentFormatter implements IContentFormatter {
/**
* Defines a reference to either the offset or the end offset of
@@ -344,14 +345,6 @@ public class ContentFormatter implements IContentFormatter, IContentFormatterExt
fPartitioning= partitioning;
}
- /*
- * @see org.eclipse.jface.text.formatter.IContentFormatterExtension#getDocumentPartitioning()
- * @since 3.0
- */
- public String getDocumentPartitioning() {
- return fPartitioning;
- }
-
/**
* Sets the formatter's operation mode.
*
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java
index 0ab4f5e5d..c932438c5 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension.java
@@ -1,27 +1,75 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
+/*****************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *****************************************************************************/
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
package org.eclipse.jface.text.formatter;
+import org.eclipse.jface.text.IDocument;
+
/**
* Extension interface for <code>IContentFormatter</code>.
- * Updates the content formatter to be aware of documents with multiple partitions.
+ * <p>
+ * Updates the content formatter to be able to pass <code>IFormattingContext</code>
+ * context objects to <code>IFormattingStrategyExtension<code> objects
+ * operating in context based mode.
+ * <p>
+ * Clients using context based formatting call the method
+ * <code>format(IDocument, IFormattingContext)</code> with a properly
+ * initialized formatting context.<br>
+ * The formatting context must be set up according to the desired formatting mode:
+ * <ul>
+ * <li>For whole document formatting set the property <code>CONTEXT_DOCUMENT</code>. This is
+ * equivalent to setting <code>CONTEXT_REGION</code> with a region spanning the whole document.</li>
+ * <li>For multiple region formatting set the property <code>CONTEXT_REGION</code>. Note that
+ * the content formatter automatically aligns the region to a block selected region, and if the region spans
+ * multiple partitions, it also completes eventual partitions covered only partially by the region.</li>
+ * </ul>
+ * Depending on the registered formatting strategies, more context information must
+ * be passed in the formatting context, like e.g. <code>CONTEXT_PREFERENCES</code>.
+ * <p>
+ * Note that in context based mode the content formatter is fully reentrant, but not
+ * thread-safe.
+ * <p>
*
+ * @see IFormattingContext
+ * @see FormattingContextProperties
* @since 3.0
*/
public interface IContentFormatterExtension {
-
+
/**
- * Returns the partitioning this content formatter is using.
+ * Formats the given region of the specified document.
+ * <p>
+ * The formatter may safely assume that it is the only subject that
+ * modifies the document at this point in time. This method is fully
+ * reentrant, but not thread-safe.
+ * <p>
+ * The formatting process performed by <code>format(IDocument, IFormattingContext)</code>
+ * happens as follows:
+ * <ul>
+ * <li>In a first pass the content formatter formats the range of the
+ * document to be formatted by using the master formatting strategy. This
+ * happens regardless of the content type of the underlying partition.
+ * </li>
+ * <li>In the second pass, the range is formatted again, this time using
+ * the registered slave formatting strategies. For each partition contained
+ * in the range to be formatted, the content formatter determines its
+ * content type and formats the partition with the correct formatting
+ * strategy.
+ * </li>
*
- * @return the partitioning this content formatter is using
+ * @param document
+ * The document to be formatted
+ * @param context
+ * The formatting context to pass to the formatting strategies.
+ * This argument must not be <code>null</code>.
*/
- String getDocumentPartitioning();
+ void format(IDocument document, IFormattingContext context);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java
deleted file mode 100644
index 5ea47ab8a..000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IContentFormatterExtension2.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.jface.text.formatter;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Extension interface for <code>IContentFormatter</code>.
- * <p>
- * Updates the content formatter to be able to pass <code>IFormattingContext</code>
- * context objects to <code>IFormattingStrategyExtension<code> objects
- * operating in context based mode.
- * <p>
- * Clients using context based formatting call the method
- * <code>format(IDocument, IFormattingContext)</code> with a properly
- * initialized formatting context.<br>
- * The formatting context must be set up according to the desired formatting mode:
- * <ul>
- * <li>For whole document formatting set the property <code>CONTEXT_DOCUMENT</code>. This is
- * equivalent to setting <code>CONTEXT_REGION</code> with a region spanning the whole document.</li>
- * <li>For multiple region formatting set the property <code>CONTEXT_REGION</code>. Note that
- * the content formatter automatically aligns the region to a block selected region, and if the region spans
- * multiple partitions, it also completes eventual partitions covered only partially by the region.</li>
- * </ul>
- * Depending on the registered formatting strategies, more context information must
- * be passed in the formatting context, like e.g. <code>CONTEXT_PREFERENCES</code>.
- * <p>
- * Note that in context based mode the content formatter is fully reentrant, but not
- * thread-safe.
- * <p>
- *
- * @see IFormattingContext
- * @see FormattingContextProperties
- * @since 3.0
- */
-public interface IContentFormatterExtension2 {
-
- /**
- * Formats the given region of the specified document.
- * <p>
- * The formatter may safely assume that it is the only subject that
- * modifies the document at this point in time. This method is fully
- * reentrant, but not thread-safe.
- * <p>
- * The formatting process performed by <code>format(IDocument, IFormattingContext)</code>
- * happens as follows:
- * <ul>
- * <li>In a first pass the content formatter formats the range of the
- * document to be formatted by using the master formatting strategy. This
- * happens regardless of the content type of the underlying partition.
- * </li>
- * <li>In the second pass, the range is formatted again, this time using
- * the registered slave formatting strategies. For each partition contained
- * in the range to be formatted, the content formatter determines its
- * content type and formats the partition with the correct formatting
- * strategy.
- * </li>
- *
- * @param document
- * The document to be formatted
- * @param context
- * The formatting context to pass to the formatting strategies.
- * This argument must not be <code>null</code>.
- */
- void format(IDocument document, IFormattingContext context);
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
index 816360796..a74e137d0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
@@ -14,6 +14,7 @@ package org.eclipse.jface.text.formatter;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultPositionUpdater;
import org.eclipse.jface.text.IDocument;
@@ -41,7 +42,7 @@ import org.eclipse.jface.text.TypedPosition;
*
* @since 3.0
*/
-public class MultiPassContentFormatter implements IContentFormatter, IContentFormatterExtension, IContentFormatterExtension2 {
+public class MultiPassContentFormatter implements IContentFormatter, IContentFormatterExtension {
/**
* Position updater that shifts otherwise deleted positions to the next
@@ -116,7 +117,7 @@ public class MultiPassContentFormatter implements IContentFormatter, IContentFor
}
/*
- * @see org.eclipse.jface.text.formatter.IContentFormatterExtension2#format(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.formatter.IFormattingContext)
+ * @see org.eclipse.jface.text.formatter.IContentFormatterExtension#format(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.formatter.IFormattingContext)
*/
public final void format(final IDocument medium, final IFormattingContext context) {
@@ -272,13 +273,6 @@ public class MultiPassContentFormatter implements IContentFormatter, IContentFor
}
/*
- * @see org.eclipse.jface.text.formatter.IContentFormatterExtension#getDocumentPartitioning()
- */
- public final String getDocumentPartitioning() {
- return fPartitioning;
- }
-
- /*
* @see org.eclipse.jface.text.formatter.IContentFormatter#getFormattingStrategy(java.lang.String)
*/
public final IFormattingStrategy getFormattingStrategy(final String type) {
@@ -295,8 +289,9 @@ public class MultiPassContentFormatter implements IContentFormatter, IContentFor
*
* @param strategy The master formatting strategy
*/
- public final void setMasterStrategy(final IFormattingStrategyExtension strategy) {
- fMaster= strategy;
+ public final void setMasterStrategy(final IFormattingStrategy strategy) {
+ Assert.isTrue(strategy instanceof IFormattingStrategyExtension);
+ fMaster= (IFormattingStrategyExtension) strategy;
}
/**
@@ -311,8 +306,8 @@ public class MultiPassContentFormatter implements IContentFormatter, IContentFor
* @param strategy The slave formatting strategy
* @param type The content type to register this strategy with
*/
- public final void setSlaveStrategy(final IFormattingStrategyExtension strategy, final String type) {
-
+ public final void setSlaveStrategy(final IFormattingStrategy strategy, final String type) {
+ Assert.isTrue(strategy instanceof IFormattingStrategyExtension);
if (!fType.equals(type))
fSlaves.put(type, strategy);
}

Back to the top