X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java index 7ba9d51..fb386ab 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java @@ -50,16 +50,16 @@ import org.eclipse.jface.util.PropertyChangeEvent; *
*/ public class JavaTextTools implements IPHPPartitions { -// private static final String[] TOKENS = { -// JSPScriptScanner.JSP_DEFAULT, -// JSPScriptScanner.JSP_BRACKET }; - private final static String[] LEGAL_CONTENT_TYPES = new String[] { - PHP_PHPDOC_COMMENT, - PHP_MULTILINE_COMMENT, - PHP_SINGLELINE_COMMENT, - PHP_STRING_DQ, + // private static final String[] TOKENS = { + // JSPScriptScanner.JSP_DEFAULT, + // JSPScriptScanner.JSP_BRACKET }; + private final static String[] LEGAL_CONTENT_TYPES = new String[] { + PHP_PHPDOC_COMMENT, + PHP_MULTILINE_COMMENT, + PHP_SINGLELINE_COMMENT, + PHP_STRING_DQ, PHP_STRING_SQ }; - + private static XMLPartitionScanner HTML_PARTITION_SCANNER = null; private static FastJavaPartitionScanner PHP_PARTITION_SCANNER = null; @@ -70,15 +70,15 @@ public class JavaTextTools implements IPHPPartitions { // private final static String[] TYPES= new String[] { PHPPartitionScanner.PHP, PHPPartitionScanner.JAVA_DOC, // PHPPartitionScanner.JAVA_MULTILINE_COMMENT }; -// private final static String[] TYPES = new String[] { -// IPHPPartitions.PHP_PARTITIONING, -// IPHPPartitions.PHP_PHPDOC_COMMENT, -// // IPHPPartitions.HTML, -// // IPHPPartitions.HTML_MULTILINE_COMMENT, -// IPHPPartitions.JAVASCRIPT, -// IPHPPartitions.CSS, -// IPHPPartitions.SMARTY, -// IPHPPartitions.SMARTY_MULTILINE_COMMENT }; + // private final static String[] TYPES = new String[] { + // IPHPPartitions.PHP_PARTITIONING, + // IPHPPartitions.PHP_PHPDOC_COMMENT, + // // IPHPPartitions.HTML, + // // IPHPPartitions.HTML_MULTILINE_COMMENT, + // IPHPPartitions.JAVASCRIPT, + // IPHPPartitions.CSS, + // IPHPPartitions.SMARTY, + // IPHPPartitions.SMARTY_MULTILINE_COMMENT }; /** * This tools' preference listener. @@ -119,15 +119,16 @@ public class JavaTextTools implements IPHPPartitions { /** The SmartyDoc scanner */ private SmartyDocCodeScanner fSmartyDocScanner; - + /** The Java partitions scanner. */ - private FastJavaPartitionScanner fPartitionScanner; - + private FastJavaPartitionScanner fPartitionScanner; + /** The preference store */ private IPreferenceStore fPreferenceStore; - + /** The XML Language text tools */ private XMLTextTools xmlTextTools; + /** * The core preference store. * @@ -142,14 +143,11 @@ public class JavaTextTools implements IPHPPartitions { private PHPPartitionScanner jspPartitionScanner = null; /** The JSP script subpartitions scanner */ -// private JSPScriptScanner jspScriptScanner; - + // private JSPScriptScanner jspScriptScanner; /** The PHP plain text scanner */ -// private RuleBasedScanner jspTextScanner; - + // private RuleBasedScanner jspTextScanner; /** The PHP brackets scanner */ -// private RuleBasedScanner jspBracketScanner; - + // private RuleBasedScanner jspBracketScanner; /** * Creates a new Java text tools collection. * @@ -187,10 +185,9 @@ public class JavaTextTools implements IPHPPartitions { */ public JavaTextTools(IPreferenceStore store, Preferences coreStore, boolean autoDisposeOnDisplayDispose) { // super(store, TOKENS, ); -// REVISIT: preference store - xmlTextTools = new XMLTextTools( - XMLPlugin.getDefault().getPreferenceStore()); - + // REVISIT: preference store + xmlTextTools = new XMLTextTools(XMLPlugin.getDefault().getPreferenceStore()); + colorManager = new JavaColorManager(autoDisposeOnDisplayDispose); fPreferenceStore = store; fPreferenceStore.addPropertyChangeListener(fPreferenceListener); @@ -210,24 +207,25 @@ public class JavaTextTools implements IPHPPartitions { fSmartyScanner = new SmartyCodeScanner((JavaColorManager) colorManager, store); fSmartyDocScanner = new SmartyDocCodeScanner((JavaColorManager) colorManager, store); - fPartitionScanner= new FastJavaPartitionScanner(); + fPartitionScanner = new FastJavaPartitionScanner(); -// jspScriptScanner = new JSPScriptScanner(); + // jspScriptScanner = new JSPScriptScanner(); // fPartitionScanner = new FastJavaPartitionScanner(); // fPartitionScanner = new PHPPartitionScanner(); -// jspBracketScanner = new RuleBasedScanner(); -// jspBracketScanner.setDefaultReturnToken(new Token(JSPScriptScanner.JSP_BRACKET)); -// jspTextScanner = new RuleBasedScanner(); -// jspTextScanner.setDefaultReturnToken(new Token(JSPScriptScanner.JSP_DEFAULT)); + // jspBracketScanner = new RuleBasedScanner(); + // jspBracketScanner.setDefaultReturnToken(new Token(JSPScriptScanner.JSP_BRACKET)); + // jspTextScanner = new RuleBasedScanner(); + // jspTextScanner.setDefaultReturnToken(new Token(JSPScriptScanner.JSP_DEFAULT)); } /** - * - */ - public XMLTextTools getXMLTextTools() { - return xmlTextTools; - } + * + */ + public XMLTextTools getXMLTextTools() { + return xmlTextTools; + } + /** * Disposes all the individual tools of this tools collection. */ @@ -395,20 +393,20 @@ public class JavaTextTools implements IPHPPartitions { } else if (extension.equalsIgnoreCase(".xml")) { // xml partitioner = createXMLPartitioner(); -// } else if (extension.equalsIgnoreCase(".js")) { -// // javascript -// partitioner = createJavaScriptPartitioner(); -// } else if (extension.equalsIgnoreCase(".css")) { -// // cascading style sheets -// partitioner = createCSSPartitioner(); + // } else if (extension.equalsIgnoreCase(".js")) { + // // javascript + // partitioner = createJavaScriptPartitioner(); + // } else if (extension.equalsIgnoreCase(".css")) { + // // cascading style sheets + // partitioner = createCSSPartitioner(); } else if (extension.equalsIgnoreCase(".tpl")) { // smarty ? partitioner = createSmartyPartitioner(); -// } else if (extension.equalsIgnoreCase(".inc")) { -// // php include files ? -// partitioner = createIncludePartitioner(); + // } else if (extension.equalsIgnoreCase(".inc")) { + // // php include files ? + // partitioner = createIncludePartitioner(); } - + if (partitioner == null) { partitioner = createJSPPartitioner(); } @@ -416,7 +414,6 @@ public class JavaTextTools implements IPHPPartitions { return partitioner; } - /** * Sets up the Java document partitioner for the given document for the given partitioning. * @@ -429,18 +426,17 @@ public class JavaTextTools implements IPHPPartitions { * * @since 3.0 */ -// public void setupJavaDocumentPartitioner(IDocument document, String partitioning, Object element) { -// IDocumentPartitioner partitioner = createDocumentPartitioner(".php"); -// -// // if (document instanceof IDocumentExtension3) { -// // IDocumentExtension3 extension3= (IDocumentExtension3) document; -// // extension3.setDocumentPartitioner(partitioning, partitioner); -// // } else { -// document.setDocumentPartitioner(partitioner); -// // } -// partitioner.connect(document); -// } - + // public void setupJavaDocumentPartitioner(IDocument document, String partitioning, Object element) { + // IDocumentPartitioner partitioner = createDocumentPartitioner(".php"); + // + // // if (document instanceof IDocumentExtension3) { + // // IDocumentExtension3 extension3= (IDocumentExtension3) document; + // // extension3.setDocumentPartitioner(partitioning, partitioner); + // // } else { + // document.setDocumentPartitioner(partitioner); + // // } + // partitioner.connect(document); + // } public void setupHTMLDocumentPartitioner(IDocument document, String partitioning, Object element) { IDocumentPartitioner partitioner = createDocumentPartitioner(".html"); @@ -476,22 +472,22 @@ public class JavaTextTools implements IPHPPartitions { } /** - * Determines whether the preference change encoded by the given event - * changes the behavior of one its contained components. - * - * @param event the event to be investigated - * @returntrue
if event causes a behavioral change
- * @since 2.0
- * @deprecated As of 3.0, replaced by {@link org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration#affectsTextPresentation(PropertyChangeEvent)}
- */
-// public boolean affectsBehavior(PropertyChangeEvent event) {
-// return fCodeScanner.affectsBehavior(event)
-// || fMultilineCommentScanner.affectsBehavior(event)
-// || fSinglelineCommentScanner.affectsBehavior(event)
-// || fStringScanner.affectsBehavior(event)
-// || fPHPDocScanner.affectsBehavior(event);
-// }
-
+ * Determines whether the preference change encoded by the given event changes the behavior of one its contained components.
+ *
+ * @param event
+ * the event to be investigated
+ * @return true
if event causes a behavioral change
+ * @since 2.0
+ * @deprecated As of 3.0, replaced by
+ * {@link org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration#affectsTextPresentation(PropertyChangeEvent)}
+ */
+ // public boolean affectsBehavior(PropertyChangeEvent event) {
+ // return fCodeScanner.affectsBehavior(event)
+ // || fMultilineCommentScanner.affectsBehavior(event)
+ // || fSinglelineCommentScanner.affectsBehavior(event)
+ // || fStringScanner.affectsBehavior(event)
+ // || fPHPDocScanner.affectsBehavior(event);
+ // }
/**
* Adapts the behavior of the contained components to the change encoded in the given event.
*
@@ -506,8 +502,8 @@ public class JavaTextTools implements IPHPPartitions {
fMultilineCommentScanner.adaptToPreferenceChange(event);
if (fSinglelineCommentScanner.affectsBehavior(event))
fSinglelineCommentScanner.adaptToPreferenceChange(event);
-// if (fStringScanner.affectsBehavior(event))
-// fStringScanner.adaptToPreferenceChange(event);
+ // if (fStringScanner.affectsBehavior(event))
+ // fStringScanner.adaptToPreferenceChange(event);
if (fPHPDocScanner.affectsBehavior(event))
fPHPDocScanner.adaptToPreferenceChange(event);
// if (fHTMLScanner.affectsBehavior(event))
@@ -516,82 +512,79 @@ public class JavaTextTools implements IPHPPartitions {
fSmartyScanner.adaptToPreferenceChange(event);
if (fSmartyDocScanner.affectsBehavior(event))
fSmartyDocScanner.adaptToPreferenceChange(event);
-// if (XMLPlugin.getDefault().getXMLTextTools().affectsBehavior(event)) {
-// XMLPlugin.getDefault().getXMLTextTools().adaptToPreferenceChange(event);
-// }
+ // if (XMLPlugin.getDefault().getXMLTextTools().affectsBehavior(event)) {
+ // XMLPlugin.getDefault().getXMLTextTools().adaptToPreferenceChange(event);
+ // }
}
/**
* Return a partitioner for .html files.
*/
public IDocumentPartitioner createHTMLPartitioner() {
-// return new DefaultPartitioner(getHTMLPartitionScanner(), TYPES);
+ // return new DefaultPartitioner(getHTMLPartitionScanner(), TYPES);
return xmlTextTools.createXMLPartitioner();
}
-// private static IDocumentPartitioner createIncludePartitioner() {
-// // return new DefaultPartitioner(getPHPPartitionScanner(), TYPES);
-// return new DefaultPartitioner(getPHPPartitionScanner(), FastJavaPartitionScanner.PHP_PARTITION_TYPES);
-//
-// }
+ // private static IDocumentPartitioner createIncludePartitioner() {
+ // // return new DefaultPartitioner(getPHPPartitionScanner(), TYPES);
+ // return new DefaultPartitioner(getPHPPartitionScanner(), FastJavaPartitionScanner.PHP_PARTITION_TYPES);
+ //
+ // }
-// private static IDocumentPartitioner createJavaScriptPartitioner() {
-// return new DefaultPartitioner(getHTMLPartitionScanner(), TYPES);
-// }
+ // private static IDocumentPartitioner createJavaScriptPartitioner() {
+ // return new DefaultPartitioner(getHTMLPartitionScanner(), TYPES);
+ // }
/**
- * Return a partitioner for .php files.
+ * Return a partitioner for .php files.
*/
public IDocumentPartitioner createPHPPartitioner() {
// return new DefaultPartitioner(getPHPPartitionScanner(), TYPES);
return new DefaultPartitioner(getPHPPartitionScanner(), LEGAL_CONTENT_TYPES);
- }
+ }
private IDocumentPartitioner createJSPPartitioner() {
- return new PHPDocumentPartitioner(
- getJSPPartitionScanner(), getPHPPartitionScanner());
-// return new JSPDocumentPartitioner(getJSPPartitionScanner(), jspScriptScanner);
+ return new PHPDocumentPartitioner(getJSPPartitionScanner(), getPHPPartitionScanner());
+ // return new JSPDocumentPartitioner(getJSPPartitionScanner(), jspScriptScanner);
}
-
+
/**
*
*/
-// public IPartitionTokenScanner getJSPScriptScanner() {
-// return jspScriptScanner;
-// }
-
+ // public IPartitionTokenScanner getJSPScriptScanner() {
+ // return jspScriptScanner;
+ // }
private IDocumentPartitioner createSmartyPartitioner() {
return new DefaultPartitioner(getSmartyPartitionScanner(), XMLTextTools.TYPES);
}
private IDocumentPartitioner createXMLPartitioner() {
-// return new DefaultPartitioner(getXMLPartitionScanner(), XMLTextTools.TYPES);
+ // return new DefaultPartitioner(getXMLPartitionScanner(), XMLTextTools.TYPES);
return xmlTextTools.createXMLPartitioner();
}
-// private IDocumentPartitioner createCSSPartitioner() {
-// return new DefaultPartitioner(getHTMLPartitionScanner(), XMLTextTools.TYPES);
-// }
+ // private IDocumentPartitioner createCSSPartitioner() {
+ // return new DefaultPartitioner(getHTMLPartitionScanner(), XMLTextTools.TYPES);
+ // }
/**
* Return a scanner for creating html partitions.
*/
-// private static XMLPartitionScanner getHTMLPartitionScanner() {
-// // if (HTML_PARTITION_SCANNER == null)
-// // HTML_PARTITION_SCANNER = new HTMLPartitionScanner(IPHPPartitions.HTML_FILE);
-// // return HTML_PARTITION_SCANNER;^
-// if (HTML_PARTITION_SCANNER == null)
-// HTML_PARTITION_SCANNER = new XMLPartitionScanner(false);
-// return HTML_PARTITION_SCANNER;
-// }
-
+ // private static XMLPartitionScanner getHTMLPartitionScanner() {
+ // // if (HTML_PARTITION_SCANNER == null)
+ // // HTML_PARTITION_SCANNER = new HTMLPartitionScanner(IPHPPartitions.HTML_FILE);
+ // // return HTML_PARTITION_SCANNER;^
+ // if (HTML_PARTITION_SCANNER == null)
+ // HTML_PARTITION_SCANNER = new XMLPartitionScanner(false);
+ // return HTML_PARTITION_SCANNER;
+ // }
/**
* Return a scanner for creating php partitions.
- */
+ */
private FastJavaPartitionScanner getPHPPartitionScanner() {
-// if (PHP_PARTITION_SCANNER == null)
-// PHP_PARTITION_SCANNER = new FastJavaPartitionScanner(); //new PHPPartitionScanner(IPHPPartitions.PHP_FILE);
-// return PHP_PARTITION_SCANNER;
+ // if (PHP_PARTITION_SCANNER == null)
+ // PHP_PARTITION_SCANNER = new FastJavaPartitionScanner(); //new PHPPartitionScanner(IPHPPartitions.PHP_FILE);
+ // return PHP_PARTITION_SCANNER;
return fPartitionScanner;
}
@@ -600,19 +593,17 @@ public class JavaTextTools implements IPHPPartitions {
*
* @return a JSP text scanner
*/
-// public RuleBasedScanner getJSPTextScanner() {
-// return jspTextScanner;
-// }
-
+ // public RuleBasedScanner getJSPTextScanner() {
+ // return jspTextScanner;
+ // }
/**
* Returns a scanner which is configured to scan plain text in JSP.
*
* @return a JSP text scanner
*/
-// public RuleBasedScanner getJSPBracketScanner() {
-// return jspBracketScanner;
-// }
-
+ // public RuleBasedScanner getJSPBracketScanner() {
+ // return jspBracketScanner;
+ // }
/**
* Return a scanner for creating smarty partitions.
*/
@@ -633,7 +624,7 @@ public class JavaTextTools implements IPHPPartitions {
XML_PARTITION_SCANNER = new XMLPartitionScanner(false);
return XML_PARTITION_SCANNER;
}
-
+
private PHPPartitionScanner getJSPPartitionScanner() {
if (jspPartitionScanner == null)
jspPartitionScanner = new PHPPartitionScanner();
@@ -641,50 +632,53 @@ public class JavaTextTools implements IPHPPartitions {
}
/**
- * Sets up the Java document partitioner for the given document for the default partitioning.
- *
- * @param document the document to be set up
- * @since 3.0
- */
- public void setupJavaDocumentPartitioner(IDocument document) {
- setupJavaDocumentPartitioner(document, IDocumentExtension3.DEFAULT_PARTITIONING);
- }
-
- /**
- * Sets up the Java document partitioner for the given document for the given partitioning.
- *
- * @param document the document to be set up
- * @param partitioning the document partitioning
- * @since 3.0
- */
- public void setupJavaDocumentPartitioner(IDocument document, String partitioning) {
- IDocumentPartitioner partitioner= createDocumentPartitioner();
- if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension3= (IDocumentExtension3) document;
- extension3.setDocumentPartitioner(partitioning, partitioner);
- } else {
- document.setDocumentPartitioner(partitioner);
- }
- partitioner.connect(document);
- }
-
- /**
- * Returns this text tool's preference store.
- *
- * @return the preference store
- * @since 3.0
- */
- protected IPreferenceStore getPreferenceStore() {
- return fPreferenceStore;
- }
-
- /**
- * Returns this text tool's core preference store.
- *
- * @return the core preference store
- * @since 3.0
- */
- protected Preferences getCorePreferenceStore() {
- return fCorePreferenceStore;
- }
+ * Sets up the Java document partitioner for the given document for the default partitioning.
+ *
+ * @param document
+ * the document to be set up
+ * @since 3.0
+ */
+ public void setupJavaDocumentPartitioner(IDocument document) {
+ setupJavaDocumentPartitioner(document, IDocumentExtension3.DEFAULT_PARTITIONING);
+ }
+
+ /**
+ * Sets up the Java document partitioner for the given document for the given partitioning.
+ *
+ * @param document
+ * the document to be set up
+ * @param partitioning
+ * the document partitioning
+ * @since 3.0
+ */
+ public void setupJavaDocumentPartitioner(IDocument document, String partitioning) {
+ IDocumentPartitioner partitioner = createDocumentPartitioner();
+ if (document instanceof IDocumentExtension3) {
+ IDocumentExtension3 extension3 = (IDocumentExtension3) document;
+ extension3.setDocumentPartitioner(partitioning, partitioner);
+ } else {
+ document.setDocumentPartitioner(partitioner);
+ }
+ partitioner.connect(document);
+ }
+
+ /**
+ * Returns this text tool's preference store.
+ *
+ * @return the preference store
+ * @since 3.0
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ return fPreferenceStore;
+ }
+
+ /**
+ * Returns this text tool's core preference store.
+ *
+ * @return the core preference store
+ * @since 3.0
+ */
+ protected Preferences getCorePreferenceStore() {
+ return fCorePreferenceStore;
+ }
}
\ No newline at end of file