1 /**********************************************************************
2 Copyright (c) 2002 Widespace, OU and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://solareclipse.sourceforge.net/legal/cpl-v10.html
9 Igor Malinin - initial contribution
11 $Id: PHPDocumentPartitioner.java,v 1.6 2006-10-21 23:18:33 pombredanne Exp $
12 **********************************************************************/
13 package net.sourceforge.phpeclipse.phpeditor.php;
15 //import net.sourceforge.phpeclipse.PHPeclipsePlugin;
16 import net.sourceforge.phpeclipse.ui.WebUI;
17 import net.sourceforge.phpeclipse.ui.text.rules.FlatNode;
18 import net.sourceforge.phpeclipse.ui.text.rules.MultiViewPartitioner;
19 import net.sourceforge.phpeclipse.ui.text.rules.ViewNode;
22 //import org.eclipse.jface.text.Assert;
23 import org.eclipse.core.runtime.Assert;
24 import org.eclipse.jface.text.IDocument;
25 import org.eclipse.jface.text.IDocumentPartitioner;
26 import org.eclipse.jface.text.rules.IPartitionTokenScanner;
31 * @author Igor Malinin
33 public class PHPDocumentPartitioner extends MultiViewPartitioner {
34 public static final String PHP_TEMPLATE_DATA = "__php_template_data";
36 public static final String PHP_SCRIPT_CODE = "__php_script_code";
38 public static final String[] LEGAL_TYPES = { PHP_TEMPLATE_DATA,
41 public PHPDocumentPartitioner(IPartitionTokenScanner scanner) {
45 protected FlatNode createNode(String type, int offset, int length) {
46 if (type.equals(PHPPartitionScanner.PHP_SCRIPTING_AREA)) {
48 Assert.isTrue(offset >= 0);
50 ViewNode node = new ViewNode(type);
56 return super.createNode(type, offset, length);
60 * @see net.sf.solareclipse.text.rules.DocumentViewPartitioner#createPartitioner(String)
62 protected IDocumentPartitioner createPartitioner(String contentType) {
63 if (contentType == null) {
64 // return JavaTextTools.createHTMLPartitioner();
65 return WebUI.getDefault().getJavaTextTools()
66 .getXMLTextTools().createPHPXMLPartitioner();
69 if (contentType.equals(PHPPartitionScanner.PHP_SCRIPTING_AREA)) {
70 return WebUI.getDefault().getJavaTextTools()
71 .createPHPPartitioner();
77 * @see net.sf.solareclipse.text.rules.DocumentViewPartitioner#getContentType(String,
80 protected String getContentType(String parent, String view) {
82 if (view == IDocument.DEFAULT_CONTENT_TYPE) {
83 return PHP_TEMPLATE_DATA;
86 if (view == IDocument.DEFAULT_CONTENT_TYPE) {
87 return PHP_SCRIPT_CODE;
91 return super.getContentType(parent, view);
94 public String[] getLegalContentTypes() {