--- /dev/null
+/*
+ * Copyright (c) 2002-2004 Widespace, OU 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:
+ * Igor Malinin - initial contribution
+ *
+ * $Id: PHPXMLPartitionScanner.java,v 1.1 2005-05-15 23:23:02 axelcl Exp $
+ */
+
+package net.sourceforge.phpeclipse.xml.ui.internal.text;
+
+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.IDocument;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+
+/**
+ *
+ *
+ * @author Igor Malinin
+ */
+public class PHPXMLPartitionScanner implements IPartitionTokenScanner {
+// public static final String XML_PI = "__xml_processing_instruction";
+ public static final String XML_COMMENT = "__xml_comment";
+ public static final String XML_DECL = "__xml_declaration";
+ public static final String XML_TAG = "__xml_tag";
+ public static final String XML_ATTRIBUTE = "__xml_attribute";
+ public static final String XML_CDATA = "__xml_cdata";
+
+ public static final String DTD_INTERNAL = "__dtd_internal";
+// public static final String DTD_INTERNAL_PI = "__dtd_internal_pi";
+ public static final String DTD_INTERNAL_COMMENT = "__dtd_internal_comment";
+ public static final String DTD_INTERNAL_DECL = "__dtd_internal_declaration";
+ public static final String DTD_CONDITIONAL = "__dtd_conditional";
+
+ public static final int STATE_DEFAULT = 0;
+ public static final int STATE_TAG = 1;
+ public static final int STATE_DECL = 2;
+ public static final int STATE_CDATA = 4;
+
+ public static final int STATE_INTERNAL = 8;
+
+ protected IDocument document;
+ protected int end;
+
+ protected int offset;
+ protected int length;
+
+ protected int position;
+ protected int state;
+
+ protected boolean parsedtd;
+
+ protected Map tokens = new HashMap();
+
+ public PHPXMLPartitionScanner(boolean parsedtd) {
+ this.parsedtd = parsedtd;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.ITokenScanner#nextToken()
+ */
+ public IToken nextToken() {
+ offset += length;
+
+ switch (state) {
+ case STATE_TAG:
+ return nextTagToken();
+
+ case STATE_DECL:
+ return nextDeclToken();
+
+ case STATE_CDATA:
+ return nextCDATAToken();
+ }
+
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ state = STATE_DEFAULT;
+ return getToken(null);
+
+ case '<':
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ if (parsedtd || isInternal()) {
+ break;
+ }
+
+ state = STATE_DEFAULT;
+ return getToken(XML_TAG);
+
+ case '?': // <? <?PI
+ unread();
+ break;
+// return nextPIToken();
+
+ case '!': // <! <!DEFINITION or <![CDATA[ or <!--COMMENT
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ state = STATE_DEFAULT;
+ return getToken(XML_TAG);
+
+ case '-': // <!- <!--COMMENT
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ return nextDeclToken();
+
+ case '-': // <!--
+ return nextCommentToken();
+ }
+
+ case '[': // <![ <![CDATA[ or <![%cond;[
+ if (parsedtd) {
+ return nextConditionalToken();
+ }
+
+ if (!isInternal()) {
+ return nextCDATAToken();
+ }
+ }
+
+ return nextDeclToken();
+ }
+
+ if (parsedtd || isInternal()) {
+ break;
+ }
+
+ unread();
+
+ return nextTagToken();
+
+ case ']':
+ if (isInternal()) {
+ unread();
+
+ state = STATE_DECL;
+ length = 0;
+ return nextToken();
+ }
+ break;
+ default:
+ unread();
+ }
+
+loop:
+ while (true) {
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ state = STATE_DEFAULT;
+ return getToken(null);
+
+ case '<':
+ if (parsedtd || isInternal()) {
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ state = STATE_DEFAULT;
+ return getToken(null);
+
+ case '!':
+ case '?':
+ unread();
+ break;
+
+ default:
+ continue loop;
+ }
+ }
+
+ unread();
+
+ state &= STATE_INTERNAL;
+ return getToken(isInternal() ? DTD_INTERNAL : null);
+
+ case ']':
+ if (isInternal()) {
+ unread();
+
+ state = STATE_DECL;
+ if (position == offset) {
+ // nothing between
+ length = 0;
+ return nextToken();
+ }
+
+ return getToken(DTD_INTERNAL);
+ }
+ }
+ }
+ }
+
+ private IToken nextTagToken() {
+ int quot = read();
+
+ switch (quot) {
+ case ICharacterScanner.EOF:
+ case '>':
+ state = STATE_DEFAULT;
+ return getToken(XML_TAG);
+
+ case '"': case '\'':
+ while (true) {
+ int ch = read();
+
+ if (ch == quot) {
+ state = STATE_TAG;
+ return getToken(XML_ATTRIBUTE);
+ }
+
+ switch (ch) {
+ case '<':
+ unread();
+
+ case ICharacterScanner.EOF:
+ state = STATE_DEFAULT;
+ return getToken(XML_ATTRIBUTE);
+ }
+ }
+ default:
+ unread();
+ }
+
+ while (true) {
+ switch (read()) {
+ case '<':
+ unread();
+
+ case ICharacterScanner.EOF:
+ case '>':
+ state = STATE_DEFAULT;
+ return getToken(XML_TAG);
+
+ case '"': case '\'':
+ unread();
+
+ state = STATE_TAG;
+ return getToken(XML_TAG);
+ }
+ }
+ }
+
+ private IToken nextDeclToken() {
+ loop: while (true) {
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ state = STATE_DEFAULT;
+ return getToken(isInternal() ? DTD_INTERNAL_DECL : XML_DECL);
+
+ case '<':
+ if (parsedtd || isInternal()) {
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ state = STATE_DEFAULT;
+ return getToken(isInternal() ? DTD_INTERNAL : null);
+
+ case '!':
+ case '?':
+ unread();
+ break;
+
+ default:
+ continue loop;
+ }
+ }
+
+ unread();
+
+ case '>':
+ state &= STATE_INTERNAL;
+ return getToken(isInternal() ? DTD_INTERNAL_DECL : XML_DECL);
+
+ case '[': // <!DOCTYPE xxx [dtd]>
+ if (!isInternal()) {
+ state = STATE_INTERNAL;
+ return getToken(XML_DECL);
+ }
+ }
+ }
+ }
+
+ private IToken nextCommentToken() {
+ state &= STATE_INTERNAL;
+
+ loop: while (true) {
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ break loop;
+
+ case '-': // - -->
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ break loop;
+
+ case '-': // -- -->
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ case '>':
+ break loop;
+ }
+
+ unread();
+ break loop;
+ }
+ }
+ }
+
+ return getToken(isInternal() ? DTD_INTERNAL_COMMENT : XML_COMMENT);
+ }
+
+ private IToken nextCDATAToken() {
+ state = STATE_DEFAULT;
+
+loop:
+ while (true) {
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ break loop;
+
+ case ']': // ] ]]>
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ break loop;
+
+ case ']': // ]] ]]>
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ case '>': // ]]>
+ break loop;
+ }
+
+ unread();
+ unread();
+ continue loop;
+ }
+ }
+ }
+
+ return getToken(XML_CDATA);
+ }
+
+ private IToken nextConditionalToken() {
+ state = STATE_DEFAULT;
+
+ int level = 1;
+
+loop:
+ while (true) {
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ break loop;
+
+ case '<': // - -->
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ break loop;
+
+ case '!': // -- -->
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ break loop;
+
+ case '[':
+ ++level;
+ continue loop;
+ }
+
+ unread();
+ continue loop;
+ }
+
+ unread();
+ continue loop;
+
+ case ']': // - -->
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ break loop;
+
+ case ']': // -- -->
+ switch (read()) {
+ case ICharacterScanner.EOF:
+ case '>':
+ if (--level == 0) {
+ break loop;
+ }
+
+ continue loop;
+ }
+
+ unread();
+ unread();
+ continue loop;
+ }
+ }
+ }
+
+ return getToken(DTD_CONDITIONAL);
+ }
+
+ private IToken getToken(String type) {
+ length = position - offset;
+
+ if (length == 0) {
+ return Token.EOF;
+ }
+
+ if (type == null) {
+ return Token.UNDEFINED;
+ }
+
+ IToken token = (IToken) tokens.get(type);
+ if (token == null) {
+ token = new Token(type);
+ tokens.put(type, token);
+ }
+
+ return token;
+ }
+
+ private boolean isInternal() {
+ return (state & STATE_INTERNAL) != 0;
+ }
+
+ private int read() {
+ if (position >= end) {
+ return ICharacterScanner.EOF;
+ }
+
+ try {
+ return document.getChar(position++);
+ } catch (BadLocationException e) {
+ --position;
+ return ICharacterScanner.EOF;
+ }
+ }
+
+ private void unread() {
+ --position;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.ITokenScanner#getTokenOffset()
+ */
+ public int getTokenOffset() {
+ Assert.isTrue(offset>=0, Integer.toString(offset));
+ return offset;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.ITokenScanner#getTokenLength()
+ */
+ public int getTokenLength() {
+ return length;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.ITokenScanner#setRange(IDocument, int, int)
+ */
+ public void setRange(IDocument document, int offset, int length) {
+ this.document = document;
+ this.end = offset + length;
+
+ this.offset = offset;
+ this.position = offset;
+ this.length = 0;
+
+ this.state = STATE_DEFAULT;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IPartitionTokenScanner
+ */
+// public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
+// state = STATE_DEFAULT;
+// if (partitionOffset > -1) {
+// int delta = offset - partitionOffset;
+// if (delta > 0) {
+// setRange(document, partitionOffset, length + delta);
+// return;
+// }
+// }
+// setRange(document, partitionOffset, length);
+// }
+ /*
+ * @see org.eclipse.jface.text.rules.IPartitionTokenScanner
+ */
+ public void setPartialRange(
+ IDocument document, int offset, int length,
+ String contentType, int partitionOffset
+ ) {
+// boolean flag = false;
+ this.document = document;
+ this.end = offset + length;
+
+ // NB! Undocumented value: -1
+ if (partitionOffset >= 0) {
+ offset = partitionOffset;
+// flag = true;
+ }
+
+ this.offset = offset;
+ this.position = offset;
+ this.length = 0;
+
+// if (flag) {
+// state = STATE_DEFAULT;
+// return;
+// }
+ if (contentType == XML_ATTRIBUTE) {
+ state = STATE_TAG;
+ return;
+ }
+
+ if (contentType == XML_TAG) {
+ state = isContinuationPartition() ? STATE_TAG : STATE_DEFAULT;
+ return;
+ }
+
+ if (contentType == XML_DECL) {
+ state = isContinuationPartition() ? STATE_DECL : STATE_DEFAULT;
+ return;
+ }
+
+ if (contentType == DTD_INTERNAL ||
+ contentType == DTD_INTERNAL_DECL ||
+ contentType == DTD_INTERNAL_COMMENT
+ ) {
+ state = STATE_INTERNAL;
+ return;
+ }
+
+ state = STATE_DEFAULT;
+ }
+
+ private boolean isContinuationPartition() {
+ try {
+ String type = document.getContentType(offset - 1);
+
+ if (type != IDocument.DEFAULT_CONTENT_TYPE) {
+ return true;
+ }
+ } catch (BadLocationException e) {}
+
+ return false;
+ }
+}
* Contributors:
* Igor Malinin - initial contribution
*
- * $Id: XMLPartitionScanner.java,v 1.2 2005-05-15 23:09:09 axelcl Exp $
+ * $Id: XMLPartitionScanner.java,v 1.3 2005-05-15 23:23:02 axelcl Exp $
*/
package net.sourceforge.phpeclipse.xml.ui.internal.text;
return getToken(XML_TAG);
case '?': // <? <?PI
- unread();
- break;
-// return nextPIToken();
+ return nextPIToken();
case '!': // <! <!DEFINITION or <![CDATA[ or <!--COMMENT
switch (read()) {
* Contributors:
* Igor Malinin - initial contribution
*
- * $Id: XMLTextTools.java,v 1.2 2005-05-06 00:55:41 stefanbjarni Exp $
+ * $Id: XMLTextTools.java,v 1.3 2005-05-15 23:23:02 axelcl Exp $
*/
package net.sourceforge.phpeclipse.xml.ui.text;
import net.sourceforge.phpeclipse.ui.text.AbstractTextTools;
import net.sourceforge.phpeclipse.xml.ui.internal.text.DeclScanner;
+import net.sourceforge.phpeclipse.xml.ui.internal.text.PHPXMLPartitionScanner;
import net.sourceforge.phpeclipse.xml.ui.internal.text.SingleTokenScanner;
import net.sourceforge.phpeclipse.xml.ui.internal.text.TextScanner;
import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLCDATAScanner;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.DefaultPartitioner;
-import org.eclipse.jface.text.rules.IPartitionTokenScanner;
import org.eclipse.jface.text.rules.ITokenScanner;
import org.eclipse.jface.text.rules.RuleBasedScanner;
/** The XML partitions scanner */
private XMLPartitionScanner xmlPartitionScanner;
-
+
+ private PHPXMLPartitionScanner phpXMLPartitionScanner;
/** The XML text scanner */
private TextScanner xmlTextScanner;
super( store, strTokens );
xmlPartitionScanner = new XMLPartitionScanner( false );
-
+ phpXMLPartitionScanner = new PHPXMLPartitionScanner( false );
Map tokens = getTokens();
xmlTextScanner = new TextScanner(
return new DefaultPartitioner( xmlPartitionScanner, TYPES );
}
+ public IDocumentPartitioner createPHPXMLPartitioner() {
+ return new DefaultPartitioner( phpXMLPartitionScanner, TYPES );
+ }
+
/**
*
*/
- public IPartitionTokenScanner getXMLPartitionScanner() {
- return xmlPartitionScanner;
- }
+// public IPartitionTokenScanner getXMLPartitionScanner() {
+// return xmlPartitionScanner;
+// }
/**
* Returns a scanner which is configured to scan XML text.
/** The Java singleline comment scanner */
private SingleTokenPHPScanner fSinglelineCommentScanner;
- /** The Java string scanner */
- private SingleTokenPHPScanner fStringScanner;
+ /** The PHP double quoted string scanner */
+// private SingleTokenPHPScanner fStringDQScanner;
+ /** The PHP single quoted string scanner */
+// private SingleTokenPHPScanner fStringSQScanner;
+
/** The PHPDoc scanner */
private PHPDocCodeScanner fPHPDocScanner;
IPreferenceConstants.PHP_MULTILINE_COMMENT);
fSinglelineCommentScanner = new SingleTokenPHPScanner((JavaColorManager) colorManager, store,
IPreferenceConstants.PHP_SINGLELINE_COMMENT);
- fStringScanner = new SingleTokenPHPScanner((JavaColorManager) colorManager, store, IPreferenceConstants.PHP_STRING);
+// fStringDQScanner = new SingleTokenPHPScanner((JavaColorManager) colorManager, store, IPreferenceConstants.PHP_STRING);
+// fStringSQScanner = new SingleTokenPHPScanner((JavaColorManager) colorManager, store, IPreferenceConstants.PHP_STRING);
+
fPHPDocScanner = new PHPDocCodeScanner((JavaColorManager) colorManager, store);
// fHTMLScanner = new HTMLCodeScanner((JavaColorManager)fColorManager, store);
fSmartyScanner = new SmartyCodeScanner((JavaColorManager) colorManager, store);
fCodeScanner = null;
fMultilineCommentScanner = null;
fSinglelineCommentScanner = null;
- fStringScanner = null;
+// fStringDQScanner = null;
+// fStringSQScanner = null;
fPHPDocScanner = null;
// fPartitionScanner = null;
*
* @since 2.0
*/
- public RuleBasedScanner getStringScanner() {
- return fStringScanner;
- }
+// public RuleBasedScanner getStringScanner() {
+// return fStringDQScanner;
+// }
/**
* Returns a scanner which is configured to scan JavaDoc compliant comments. Notes that the start sequence "/**" and the
// return fCodeScanner.affectsBehavior(event)
// || fMultilineCommentScanner.affectsBehavior(event)
// || fSinglelineCommentScanner.affectsBehavior(event)
- // || fStringScanner.affectsBehavior(event)
+ // || fStringDQScanner.affectsBehavior(event)
// || fPHPDocScanner.affectsBehavior(event);
// }
/**
fMultilineCommentScanner.adaptToPreferenceChange(event);
if (fSinglelineCommentScanner.affectsBehavior(event))
fSinglelineCommentScanner.adaptToPreferenceChange(event);
- // if (fStringScanner.affectsBehavior(event))
- // fStringScanner.adaptToPreferenceChange(event);
+ // if (fStringDQScanner.affectsBehavior(event))
+ // fStringDQScanner.adaptToPreferenceChange(event);
if (fPHPDocScanner.affectsBehavior(event))
fPHPDocScanner.adaptToPreferenceChange(event);
// if (fHTMLScanner.affectsBehavior(event))
/**
* Return a scanner for creating xml partitions.
*/
- private static XMLPartitionScanner getXMLPartitionScanner() {
- // if (XML_PARTITION_SCANNER == null)
- // XML_PARTITION_SCANNER = new HTMLPartitionScanner(IPHPPartitions.XML_FILE);
- // return XML_PARTITION_SCANNER;
- if (XML_PARTITION_SCANNER == null)
- XML_PARTITION_SCANNER = new XMLPartitionScanner(false);
- return XML_PARTITION_SCANNER;
- }
+// private static XMLPartitionScanner getXMLPartitionScanner() {
+// // if (XML_PARTITION_SCANNER == null)
+// // XML_PARTITION_SCANNER = new HTMLPartitionScanner(IPHPPartitions.XML_FILE);
+// // return XML_PARTITION_SCANNER;
+// if (XML_PARTITION_SCANNER == null)
+// XML_PARTITION_SCANNER = new XMLPartitionScanner(false);
+// return XML_PARTITION_SCANNER;
+// }
private PHPPartitionScanner getJSPPartitionScanner() {
if (jspPartitionScanner == null)
private AbstractJavaScanner fSinglelineCommentScanner;
/**
- * The Java string scanner
- *
- * @since 3.0
+ * The PHP double quoted string scanner
*/
- private AbstractJavaScanner fStringScanner;
-
+ private AbstractJavaScanner fStringDQScanner;
+ /**
+ * The PHP single quoted string scanner
+ */
+ private AbstractJavaScanner fStringSQScanner;
+
/**
* The Javadoc scanner
*
// fCodeScanner = (AbstractJavaScanner) fJavaTextTools.getCodeScanner();
// fMultilineCommentScanner = (AbstractJavaScanner) fJavaTextTools.getMultilineCommentScanner();
// fSinglelineCommentScanner = (AbstractJavaScanner) fJavaTextTools.getSinglelineCommentScanner();
- // fStringScanner = (AbstractJavaScanner) fJavaTextTools.getStringScanner();
+ // fStringDQScanner = (AbstractJavaScanner) fJavaTextTools.getStringScanner();
// fJavaDocScanner = (AbstractJavaScanner) fJavaTextTools.getJavaDocScanner();
// fTextEditor = editor;
// fXMLTextTools = XMLPlugin.getDefault().getXMLTextTools();
IPreferenceConstants.PHP_MULTILINE_COMMENT);
fSinglelineCommentScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore,
IPreferenceConstants.PHP_SINGLELINE_COMMENT);
- fStringScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore, IPreferenceConstants.PHP_STRING);
+ fStringDQScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore, IPreferenceConstants.PHP_STRING_DQ);
+ fStringSQScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore, IPreferenceConstants.PHP_STRING_SQ);
fJavaDocScanner = new PHPDocCodeScanner(getColorManager(), fPreferenceStore);
}
*/
public boolean affectsTextPresentation(PropertyChangeEvent event) {
return fCodeScanner.affectsBehavior(event) || fMultilineCommentScanner.affectsBehavior(event)
- || fSinglelineCommentScanner.affectsBehavior(event) || fStringScanner.affectsBehavior(event)
+ || fSinglelineCommentScanner.affectsBehavior(event) || fStringDQScanner.affectsBehavior(event)|| fStringSQScanner.affectsBehavior(event)
|| fJavaDocScanner.affectsBehavior(event);
}
fMultilineCommentScanner.adaptToPreferenceChange(event);
if (fSinglelineCommentScanner.affectsBehavior(event))
fSinglelineCommentScanner.adaptToPreferenceChange(event);
- if (fStringScanner.affectsBehavior(event))
- fStringScanner.adaptToPreferenceChange(event);
+ if (fStringDQScanner.affectsBehavior(event))
+ fStringDQScanner.adaptToPreferenceChange(event);
+ if (fStringSQScanner.affectsBehavior(event))
+ fStringSQScanner.adaptToPreferenceChange(event);
if (fJavaDocScanner.affectsBehavior(event))
fJavaDocScanner.adaptToPreferenceChange(event);
}
}
/**
- * Returns the Java string scanner for this configuration.
+ * Returns the PHP double quoted string scanner for this configuration.
*
- * @return the Java string scanner
- * @since 2.0
+ * @return the PHP double quoted string scanner
*/
- protected RuleBasedScanner getStringScanner() {
- return fStringScanner;
+ protected RuleBasedScanner getStringDQScanner() {
+ return fStringDQScanner;
}
/**
+ * Returns the PHP single quoted string scanner for this configuration.
+ *
+ * @return the PHP single quoted string scanner
+ */
+ protected RuleBasedScanner getStringSQScanner() {
+ return fStringSQScanner;
+ }
+ /**
* Returns the HTML source code scanner for this configuration.
*
* @return the HTML source code scanner
phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_PHPDOC_COMMENT);
phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_PHPDOC_COMMENT);
- phpDR = new DefaultDamagerRepairer(getStringScanner());
+ phpDR = new DefaultDamagerRepairer(getStringDQScanner());
phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_DQ);
phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_DQ);
- phpDR = new DefaultDamagerRepairer(getStringScanner());
+ phpDR = new DefaultDamagerRepairer(getStringSQScanner());
phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_SQ);
- phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_SQ);
+ phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_SQ);
phpDR = new DefaultDamagerRepairer(getSinglelineCommentScanner());
phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
IPreferenceConstants.PHP_KEYWORD,
IPreferenceConstants.PHP_FUNCTIONNAME,
IPreferenceConstants.PHP_VARIABLE,
- IPreferenceConstants.PHP_STRING,
+ IPreferenceConstants.PHP_STRING_DQ,
+ IPreferenceConstants.PHP_STRING_SQ,
IPreferenceConstants.PHP_TYPE,
IPreferenceConstants.PHP_CONSTANT,
IPreferenceConstants.PHP_DEFAULT,
// keyword = new Token(new TextAttribute(provider.getColor(PHPColorProvider.KEYWORD)));
// IToken type = new Token(new TextAttribute(provider.getColor(PHPColorProvider.FUNCTION_NAME)));
-// IToken string = new Token(new TextAttribute(provider.getColor(PHPColorProvider.STRING)));
+// IToken string = new Token(new TextAttribute(provider.getColor(PHPColorProvider.STRING_DQ)));
// IToken comment = new Token(new TextAttribute(provider.getColor(PHPColorProvider.SINGLE_LINE_COMMENT)));
// IToken multi_comment = new Token(new TextAttribute(provider.getColor(PHPColorProvider.MULTI_LINE_COMMENT)));
// IToken other = new Token(new TextAttribute(provider.getColor(PHPColorProvider.DEFAULT)));
//rules.add(new EndOfLineRule("#", comment));
// Add rule for strings and character constants.
- rules.add(new SingleLineRule("\"", "\"", getToken(IPreferenceConstants.PHP_STRING))); //$NON-NLS-2$ //$NON-NLS-1$
+ rules.add(new SingleLineRule("\"", "\"", getToken(IPreferenceConstants.PHP_STRING_DQ))); //$NON-NLS-2$ //$NON-NLS-1$
// rules.add(new SingleLineRule("'", "'", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
// rules.add(new SingleLineRule("//", "//", php_comment));
IPreferenceConstants.PHP_KEYWORD,
IPreferenceConstants.PHP_FUNCTIONNAME,
IPreferenceConstants.PHP_VARIABLE,
- IPreferenceConstants.PHP_STRING,
+ IPreferenceConstants.PHP_STRING_DQ,
+ IPreferenceConstants.PHP_STRING_SQ,
IPreferenceConstants.PHP_TYPE,
IPreferenceConstants.PHP_CONSTANT,
IPreferenceConstants.PHP_DEFAULT,
rules.add(new EndOfLineRule("//", token)); //$NON-NLS-1$
rules.add(new EndOfLineRule("#", token)); //$NON-NLS-1$
// Add rule for strings and character constants.
- token = getToken(IPreferenceConstants.PHP_STRING);
-// rules.add(new MultiLineRule("\"", "\"", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
-// rules.add(new MultiLineRule("`", "`", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
-// rules.add(new MultiLineRule("'", "'", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
- rules.add(new SingleQuoteStringRule(token));
- rules.add(new DoubleQuoteStringRule(token));
+// token = getToken(IPreferenceConstants.PHP_STRING_SQ);
+// rules.add(new SingleQuoteStringRule(token));
+// token = getToken(IPreferenceConstants.PHP_STRING_DQ);
+// rules.add(new DoubleQuoteStringRule(token));
rules.add(new AccentStringRule(token));
token = getToken(IPreferenceConstants.PHP_MULTILINE_COMMENT);
Contributors:
Igor Malinin - initial contribution
- $Id: PHPDocumentPartitioner.java,v 1.2 2004-11-12 20:17:10 axelcl Exp $
+ $Id: PHPDocumentPartitioner.java,v 1.3 2005-05-15 23:24:41 axelcl Exp $
**********************************************************************/
package net.sourceforge.phpeclipse.phpeditor.php;
protected IDocumentPartitioner createPartitioner(String contentType) {
if (contentType == null) {
// return JavaTextTools.createHTMLPartitioner();
- return PHPeclipsePlugin.getDefault().getJavaTextTools().getXMLTextTools().createXMLPartitioner();
+ return PHPeclipsePlugin.getDefault().getJavaTextTools().getXMLTextTools().createPHPXMLPartitioner();
}
if (contentType.equals(PHPPartitionScanner.PHP_SCRIPTING_AREA)) {
Contributors:
Igor Malinin - initial contribution
- $Id: PHPPartitionScanner.java,v 1.28 2005-05-13 20:19:42 axelcl Exp $
+ $Id: PHPPartitionScanner.java,v 1.29 2005-05-15 23:24:41 axelcl Exp $
**********************************************************************/
package net.sourceforge.phpeclipse.phpeditor.php;
* @author Igor Malinin
*/
public class PHPPartitionScanner implements IPartitionTokenScanner {
- // public static final String JSP_DIRECTIVE = "__jsp_directive";
- // public static final String JSP_COMMENT = "__jsp_comment";
- //// public static final String JSP_TAG = "__jsp_tag";
- // public static final String JSP_DECLARATION = "__jsp_declaration";
public static final String PHP_SCRIPTING_AREA = "__php_scripting_area ";
- // public static final String JSP_EXPRESSION = "__jsp_expression";
-
public static final int STATE_DEFAULT = 0;
// public static final int STATE_TAG = 1;
state = STATE_DEFAULT;
return getToken(null);
- case '?': // <%SCRIPLET <%@DIRECTIVE <%!DECLARATION <%=EXPRESSION <%--COMMENT
- int ch = read();
- // if (Character.isWhitespace((char)ch)) {
- // return nextJSPToken(PHP_SCRIPTING_AREA);
- // }
- switch (ch) {
- case ICharacterScanner.EOF:
- state = STATE_DEFAULT;
- return getToken(PHP_SCRIPTING_AREA);
-
- // case '-': // <%- <%--COMMENT
- // switch (read()) {
- // case ICharacterScanner.EOF:
- // case '-': // <%--
- // return nextCommentToken();
- // }
- //
- // break;
- }
-
+ case '?': // <?
+// int ch = read();
+//
+// switch (ch) {
+// case ICharacterScanner.EOF:
+// state = STATE_DEFAULT;
+// return getToken(PHP_SCRIPTING_AREA);
+// }
return scanUntilPHPEndToken(PHP_SCRIPTING_AREA);
}
}
}
- // private IToken nextCommentToken() {
- // int ch = read();
- // loop: while (true) {
- // switch (ch) {
- // case ICharacterScanner.EOF:
- // break loop;
- //
- // case '-': // - --%>
- // ch = read();
- // switch (ch) {
- // case ICharacterScanner.EOF:
- // break loop;
- //
- // case '-': // -- --%>
- // ch = read();
- // switch (ch) {
- // case ICharacterScanner.EOF:
- // break loop;
- //
- // case '%': // --% --%>
- // ch = read();
- // switch (ch) {
- // case ICharacterScanner.EOF:
- // case '>':
- // break loop;
- // }
- //
- // continue loop;
- //
- // case '-': // --- ---%>
- // unread();
- // continue loop;
- // }
- //
- // ch = read();
- // continue loop;
- // }
- // }
- //
- // ch = read();
- // }
- //
- // return getToken(JSP_COMMENT);
- // }
-
private IToken getToken(String type) {
length = position - offset;
*/
public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
state = STATE_DEFAULT;
- // if (partitionOffset > -1) {
- // int delta= offset - partitionOffset;
- // if (delta > 0) {
- // this.setRange(document, partitionOffset, length + delta);
- // return;
- // }
- // }
+ if (partitionOffset > -1) {
+ int delta = offset - partitionOffset;
+ if (delta > 0) {
+ setRange(document, partitionOffset, length + delta);
+ return;
+ }
+ }
setRange(document, partitionOffset, length);
}
+++ /dev/null
-/*
- * Created on 28.04.2003
- *
- */
-package net.sourceforge.phpeclipse.phpeditor.php;
-
-import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * @author slanger
- * @version $Revision: 1.2 $
- */
-public class PHPPartition_delete_it extends Partition
-{
- private boolean fShortTagsEnabled = true;
-
- /**
- * @param document
- * @param delim
- * @param contentType
- * @param parentPartition
- */
- public PHPPartition_delete_it(IDocument document, String parentPartition)
- {
- super(
- document,
- new char[] { '<', '>' },
- IPHPPartitions.PHP_PARTITIONING,
- parentPartition);
- }
-
-
-
- /* (non-Javadoc)
- * @see net.sourceforge.phpeclipse.phpeditor.php.Partition#allowedPartition(java.lang.String)
- */
- protected boolean allowedPartition(String type)
- {
- if(type.equals(IPHPPartitions.PHP_PHPDOC_COMMENT))
- return true;
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see net.sourceforge.phpeclipse.phpeditor.php.Partition#scan()
- */
- protected boolean scan()
- {
- int ch;
- if(fShortTagsEnabled && checkPattern("<?", true))
- {
- scanToEnd();
- }
- else if(checkPattern("<?php", false))
- {
- scanToEnd();
- }
- else
- return false;
-
- return true;
- }
-
- private void scanToEnd()
- {
- if(isEnd())
- return;
-
- while(!checkPattern("?>", true))
- {
- int offset = getOffset();
- if(checkPattern("/*", true))
- {
- unread(2);
- return;
- }
- }
- }
-}
IPreferenceConstants.PHP_KEYWORD,
IPreferenceConstants.PHP_FUNCTIONNAME,
IPreferenceConstants.PHP_VARIABLE,
- IPreferenceConstants.PHP_STRING,
+ IPreferenceConstants.PHP_STRING_DQ,
+ IPreferenceConstants.PHP_STRING_SQ,
IPreferenceConstants.PHP_TYPE,
IPreferenceConstants.PHP_CONSTANT,
IPreferenceConstants.PHP_DEFAULT };
protected List createRules() {
List rules = new ArrayList();
// Add rule for strings and character constants.
- Token token = getToken(IPreferenceConstants.PHP_STRING);
+ Token token = getToken(IPreferenceConstants.PHP_STRING_DQ);
rules.add(new MultiLineRule("\"", "\"", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
// Add generic whitespace rule.
public static final RGB KEYWORD = new RGB(127, 0, 85);
public static final RGB VARIABLE = new RGB(127, 159, 191);
public static final RGB FUNCTION_NAME = new RGB(127, 127, 159);
- public static final RGB STRING = new RGB(42, 0, 255);
+ public static final RGB STRING_DQ = new RGB(42, 0, 255);
+ public static final RGB STRING_SQ = new RGB(42, 0, 255);
public static final RGB DEFAULT = new RGB(0, 0, 0);
public static final RGB TYPE = new RGB(127, 0, 85);
public static final RGB CONSTANT = new RGB(127, 0, 85);