From: khartlage Date: Thu, 7 Nov 2002 19:19:24 +0000 (+0000) Subject: misc changes X-Git-Url: http://secure.phpeclipse.com?hp=c12e0fa4be1b82b8e9287c8addcfa50bb5f5625d misc changes --- diff --git a/net.sourceforge.phpeclipse/.classpath b/net.sourceforge.phpeclipse/.classpath index 1ac08d6..bb58950 100644 --- a/net.sourceforge.phpeclipse/.classpath +++ b/net.sourceforge.phpeclipse/.classpath @@ -10,7 +10,8 @@ - - + + diff --git a/net.sourceforge.phpeclipse/build.xml b/net.sourceforge.phpeclipse/build.xml new file mode 100644 index 0000000..75914da --- /dev/null +++ b/net.sourceforge.phpeclipse/build.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/net.sourceforge.phpeclipse/install.txt b/net.sourceforge.phpeclipse/install.txt new file mode 100644 index 0000000..5a4aa23 --- /dev/null +++ b/net.sourceforge.phpeclipse/install.txt @@ -0,0 +1,16 @@ +Installing the PHPEclipse plugin is quite straightforward : + +- Make sure you have Eclipse 2.0 properly setup or download it from www.eclipse.org + +- Simply unzip the files in your eclipse plugins + directory (\eclipse\plugins). + +- (re)Start Eclipse. + +- Open the "Resource Perspective" in the Eclipse IDE and add a file with a + *.php, *.php3 or *.php4 extension to your source tree. + With a right mouse click on the PHP file you should see the new menu entry + "Open With->PHP Editor". + +- For more Information go to the menu "Help->Help Contents" and + open the "PHPEclipse Help" \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/phphelp.xml b/net.sourceforge.phpeclipse/phphelp.xml index 2b9a211..8e19278 100644 --- a/net.sourceforge.phpeclipse/phphelp.xml +++ b/net.sourceforge.phpeclipse/phphelp.xml @@ -1,4 +1,5 @@ - + + diff --git a/net.sourceforge.phpeclipse/plugin.properties b/net.sourceforge.phpeclipse/plugin.properties index 7a8b7b1..5169f87 100644 --- a/net.sourceforge.phpeclipse/plugin.properties +++ b/net.sourceforge.phpeclipse/plugin.properties @@ -9,3 +9,5 @@ providerName = EclipseProject.de # phpEditorName=PHP Editor phpFileExtension=php +php3FileExtension=php3 +php4FileExtension=php4 diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index 98a1e91..b8fec77 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -2,14 +2,14 @@ - + - s + @@ -78,7 +78,23 @@ + + + + @@ -91,7 +107,29 @@ nameFilter="*.php" id="net.sourceforge.phpeclipse.actions.popupShowAction"> + + + + + + + + @@ -124,6 +162,22 @@ id="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"> + + + + + + + + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index 911cceb..20ede98 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -14,10 +14,21 @@ package net.sourceforge.phpeclipse; import java.util.MissingResourceException; import java.util.ResourceBundle; +import net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPluginDescriptor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +//import org.eclipse.jdt.internal.ui.JavaStatusConstants; +//import org.eclipse.jdt.internal.ui.JavaUIMessages; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; /** @@ -32,10 +43,18 @@ public class PHPeclipsePlugin extends AbstractUIPlugin { public static final String APACHE_START_PREF = "_apache_start"; public static final String APACHE_STOP_PREF = "_apache_stop"; public static final String APACHE_RESTART_PREF = "_apache_restart"; + + /** + * The id of the PHP plugin (value "net.sourceforge.phpeclipse"). + */ + public static final String ID_PLUGIN= "net.sourceforge.phpeclipse"; //$NON-NLS-1$ + //The shared instance. private static PHPeclipsePlugin plugin; //Resource bundle. private ResourceBundle resourceBundle; + + private PHPDocumentProvider fCompilationUnitDocumentProvider; /** * The Java virtual machine that we are running on. */ @@ -75,6 +94,13 @@ public class PHPeclipsePlugin extends AbstractUIPlugin { } } + // @TODO: refactor this into a better method name ! + public PHPDocumentProvider getCompilationUnitDocumentProvider() { + if (fCompilationUnitDocumentProvider == null) + fCompilationUnitDocumentProvider= new PHPDocumentProvider(); + return fCompilationUnitDocumentProvider; + } + public static void setJVM() { String osName = System.getProperty("os.name"); @@ -124,6 +150,52 @@ public class PHPeclipsePlugin extends AbstractUIPlugin { public static IWorkspace getWorkspace() { return ResourcesPlugin.getWorkspace(); } + + public static IWorkbenchPage getActivePage() { + return getDefault().getActivePage(); + } + + public static IWorkbenchWindow getActiveWorkbenchWindow() { + return getDefault().getWorkbench().getActiveWorkbenchWindow(); + } + + public static Shell getActiveWorkbenchShell() { + return getActiveWorkbenchWindow().getShell(); + } + + public static String getPluginId() { + return getDefault().getDescriptor().getUniqueIdentifier(); + } + + public static void log(IStatus status) { + getDefault().getLog().log(status); + } + +// public static void logErrorMessage(String message) { +// log(new Status(IStatus.ERROR, getPluginId(), JavaStatusConstants.INTERNAL_ERROR, message, null)); +// } +// +// public static void logErrorStatus(String message, IStatus status) { +// if (status == null) { +// logErrorMessage(message); +// return; +// } +// MultiStatus multi= new MultiStatus(getPluginId(), JavaStatusConstants.INTERNAL_ERROR, message, null); +// multi.add(status); +// log(multi); +// } +// +// public static void log(Throwable e) { +// log(new Status(IStatus.ERROR, getPluginId(), JavaStatusConstants.INTERNAL_ERROR, JavaUIMessages.getString("JavaPlugin.internal_error"), e)); //$NON-NLS-1$ +// } + + public static boolean isDebug() { + return getDefault().isDebugging(); + } + + static IPath getInstallLocation() { + return new Path(getDefault().getDescriptor().getInstallURL().getFile()); + } /** * Returns the string from the plugin's resource bundle, diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPRestartApacheAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPRestartApacheAction.java new file mode 100644 index 0000000..a5c461e --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPRestartApacheAction.java @@ -0,0 +1,31 @@ +/********************************************************************** +Copyright (c) 2000, 2002 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 + +Contributors: + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de +**********************************************************************/ +package net.sourceforge.phpeclipse.actions; + +import java.io.IOException; +import java.text.MessageFormat; + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +public class PHPRestartApacheAction extends PHPStartApacheAction { + public void run(IAction action) { + final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + execute(store.getString(PHPeclipsePlugin.APACHE_RESTART_PREF)); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java new file mode 100644 index 0000000..7f69883 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java @@ -0,0 +1,62 @@ +/********************************************************************** +Copyright (c) 2000, 2002 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 + +Contributors: + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de +**********************************************************************/ +package net.sourceforge.phpeclipse.actions; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.text.MessageFormat; + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +public class PHPStartApacheAction implements IWorkbenchWindowActionDelegate { + protected IWorkbenchWindow activeWindow = null; + + public void run(IAction action) { + final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); + // replace backslash with slash in the DocumentRoot under Windows + documentRoot = documentRoot.replace('\\', '/'); + String[] arguments = { documentRoot }; + MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.APACHE_START_PREF)); + execute(form.format(arguments)); + } + + public void execute(String command) { +// MessageDialog.openInformation(activeWindow.getShell(), "Exec command: ", command); + try { + Runtime runtime = Runtime.getRuntime(); + // Process process = runtime.exec(new String[] { "c:\\apache\\apache.exe" }); + Process process = runtime.exec(command); + } catch (IOException e) { + MessageDialog.openInformation(activeWindow.getShell(), "IOException: ", e.getMessage()); + } + } + + public void selectionChanged(IAction action, ISelection selection) { + + } + + public void init(IWorkbenchWindow window) { + this.activeWindow = window; + } + + public void dispose() { + + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartMySQLAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartMySQLAction.java new file mode 100644 index 0000000..31c5586 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartMySQLAction.java @@ -0,0 +1,31 @@ +/********************************************************************** +Copyright (c) 2000, 2002 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 + +Contributors: + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de +**********************************************************************/ +package net.sourceforge.phpeclipse.actions; + +import java.io.IOException; +import java.text.MessageFormat; + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +public class PHPStartMySQLAction extends PHPStartApacheAction { + public void run(IAction action) { + final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + execute(store.getString(PHPeclipsePlugin.MYSQL_PREF)); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStopApacheAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStopApacheAction.java new file mode 100644 index 0000000..3711fcd --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStopApacheAction.java @@ -0,0 +1,31 @@ +/********************************************************************** +Copyright (c) 2000, 2002 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 + +Contributors: + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de +**********************************************************************/ +package net.sourceforge.phpeclipse.actions; + +import java.io.IOException; +import java.text.MessageFormat; + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +public class PHPStopApacheAction extends PHPStartApacheAction { + public void run(IAction action) { + final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + execute(store.getString(PHPeclipsePlugin.APACHE_STOP_PREF)); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java index dfc01fb..1bf4dbe 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java @@ -12,13 +12,11 @@ Contributors: Klaus Hartlage - www.eclipseproject.de **********************************************************************/ -import java.text.MessageFormat; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadPositionCategoryException; import org.eclipse.jface.text.DefaultPositionUpdater; @@ -32,14 +30,15 @@ import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; - +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.views.contentoutline.ContentOutlinePage; /** - * A content outline page which always represents the content of the - * connected editor in 10 segments. + * A content outline page which always represents the functions of the + * connected PHPEditor. */ public class PHPContentOutlinePage extends ContentOutlinePage { @@ -59,6 +58,12 @@ public class PHPContentOutlinePage extends ContentOutlinePage { return name; } }; + + protected static class SegmentComparator implements Comparator { + public int compare(Object o1, Object o2) { + return ((Segment)o1).name.compareToIgnoreCase(((Segment)o2).name); + } + } /** * Divides the editor's document into ten segments and provides elements for them. @@ -68,6 +73,7 @@ public class PHPContentOutlinePage extends ContentOutlinePage { protected final static String SEGMENTS = "__php_segments"; //$NON-NLS-1$ protected IPositionUpdater fPositionUpdater = new DefaultPositionUpdater(SEGMENTS); protected List fContent = new ArrayList(10); + protected List fVariables = new ArrayList(100); private String getIdentifier(String text, int firstIndex) { int i = firstIndex; @@ -76,7 +82,9 @@ public class PHPContentOutlinePage extends ContentOutlinePage { StringBuffer identifier = new StringBuffer(); while (i < textLength) { c = text.charAt(i++); - if (Character.isJavaIdentifierPart(c)) { + if (Character.isJavaIdentifierPart(c) || (c=='$')) { + identifier.append(c); + } else if ( (i==firstIndex+1) && (c=='$')) { identifier.append(c); } else { return identifier.toString(); @@ -189,9 +197,15 @@ public class PHPContentOutlinePage extends ContentOutlinePage { functionMode = true; i+=8; } + } else if (c == '$') { + // get the variable name + identifier = getIdentifier(text, i - 1); + fVariables.add( identifier ); } } + Collections.sort(fContent, new SegmentComparator()); + Collections.sort(fVariables); // for (int line = 0; line < lines; line += increment) { // @@ -230,6 +244,7 @@ public class PHPContentOutlinePage extends ContentOutlinePage { } fContent.clear(); + fVariables.clear(); if (newInput != null) { IDocument document = fDocumentProvider.getDocument(newInput); @@ -250,6 +265,10 @@ public class PHPContentOutlinePage extends ContentOutlinePage { fContent.clear(); fContent = null; } + if (fVariables != null) { + fVariables.clear(); + fVariables = null; + } } /* @@ -266,6 +285,12 @@ public class PHPContentOutlinePage extends ContentOutlinePage { return fContent.toArray(); } + /** + * returns all PHP variables + */ + public Object[] getVariables() { + return fVariables.toArray(); + } /* * @see ITreeContentProvider#hasChildren(Object) */ diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java index 919bdd9..1c603b6 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java @@ -26,41 +26,44 @@ import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner; public class PHPDocumentProvider extends FileDocumentProvider { - // private final static String[] TYPES= new String[] { PHPPartitionScanner.PHP, PHPPartitionScanner.JAVA_DOC, PHPPartitionScanner.JAVA_MULTILINE_COMMENT }; -private final static String[] TYPES= new String[] { PHPPartitionScanner.PHP, PHPPartitionScanner.JAVA_MULTILINE_COMMENT }; + // private final static String[] TYPES= new String[] { PHPPartitionScanner.PHP, PHPPartitionScanner.JAVA_DOC, PHPPartitionScanner.JAVA_MULTILINE_COMMENT }; + private final static String[] TYPES = new String[] { + PHPPartitionScanner.PHP, +// PHPPartitionScanner.HTML, + PHPPartitionScanner.HTML_MULTILINE_COMMENT }; - private static PHPPartitionScanner fgScanner= null; + private static PHPPartitionScanner fgScanner = null; - public PHPDocumentProvider() { - super(); - } - - /* (non-Javadoc) - * Method declared on AbstractDocumentProvider - */ - protected IDocument createDocument(Object element) throws CoreException { - IDocument document= super.createDocument(element); - if (document != null) { - IDocumentPartitioner partitioner= createJavaPartitioner(); - document.setDocumentPartitioner(partitioner); - partitioner.connect(document); - } - return document; - } - - /** - * Return a partitioner for .java files. - */ - private IDocumentPartitioner createJavaPartitioner() { - return new DefaultPartitioner(getPHPPartitionScanner(), TYPES); - } - - /** - * Return a scanner for creating java partitions. - */ - private PHPPartitionScanner getPHPPartitionScanner() { - if (fgScanner == null) - fgScanner= new PHPPartitionScanner(); - return fgScanner; - } + public PHPDocumentProvider() { + super(); + } + + /* (non-Javadoc) + * Method declared on AbstractDocumentProvider + */ + protected IDocument createDocument(Object element) throws CoreException { + IDocument document = super.createDocument(element); + if (document != null) { + IDocumentPartitioner partitioner = createPHPPartitioner(); + document.setDocumentPartitioner(partitioner); + partitioner.connect(document); + } + return document; + } + + /** + * Return a partitioner for .php files. + */ + private IDocumentPartitioner createPHPPartitioner() { + return new DefaultPartitioner(getPHPPartitionScanner(), TYPES); + } + + /** + * Return a scanner for creating java partitions. + */ + private PHPPartitionScanner getPHPPartitionScanner() { + if (fgScanner == null) + fgScanner = new PHPPartitionScanner(); + return fgScanner; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java index df0c4cc..2608187 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java @@ -11,7 +11,7 @@ Contributors: IBM Corporation - Initial implementation Klaus Hartlage - www.eclipseproject.de **********************************************************************/ -import net.sourceforge.phpeclipse.phpeditor.php.PHPWordDetector; +import net.sourceforge.phpeclipse.phpeditor.php.PHPWordExtractor; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.help.IHelp; @@ -168,7 +168,7 @@ public class PHPEditor extends TextEditor { } private String getFunctionName(IDocument doc, int pos) { - Point word = PHPWordDetector.findWord(doc, pos); + Point word = PHPWordExtractor.findWord(doc, pos); if (word != null) { try { return doc.get(word.x, word.y).replace('_', '-'); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorEnvironment.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorEnvironment.java index 47760a9..f50c26d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorEnvironment.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorEnvironment.java @@ -12,63 +12,70 @@ Contributors: Klaus Hartlage - www.eclipseproject.de **********************************************************************/ -import org.eclipse.jface.text.rules.RuleBasedScanner; +import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner; import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner; -//import net.sourceforge.phpeclipse.phpeditor.html.JavaDocScanner; +import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner; import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider; +import org.eclipse.jface.text.rules.RuleBasedScanner; -/** The JavaEditorEnvironment maintains singletons used by the java editor - * examples. +/** The PHPEditorEnvironment maintains singletons used by the php editor */ public class PHPEditorEnvironment { - private static PHPColorProvider fgColorProvider; - private static PHPCodeScanner fgCodeScanner; - //private static JavaDocScanner fgDocScanner; + private static PHPColorProvider fgColorProvider; + private static PHPCodeScanner fgCodeScanner; + private static HTMLCodeScanner fgHTMLCodeScanner; + //private static JavaDocScanner fgDocScanner; + + private static int fgRefCount = 0; + + /** + * A connection has occured - initialize the receiver if it is the first activation. + */ + public static void connect(Object client) { + if (++fgRefCount == 1) { + fgColorProvider = new PHPColorProvider(); + fgCodeScanner = new PHPCodeScanner(fgColorProvider); + fgHTMLCodeScanner = new HTMLCodeScanner(fgColorProvider); + // fgDocScanner= new JavaDocScanner(fgColorProvider); + } + } + + /** + * A disconnection has occured - clear the receiver if it is the last deactivation. + */ + public static void disconnect(Object client) { + if (--fgRefCount == 0) { + fgCodeScanner = null; + fgHTMLCodeScanner = null; + // fgDocScanner= null; + fgColorProvider.dispose(); + fgColorProvider = null; + } + } + + /** + * Returns the singleton scanner. + */ + public static RuleBasedScanner getPHPCodeScanner() { + return fgCodeScanner; + } + + public static RuleBasedScanner getHTMLCodeScanner() { + return fgHTMLCodeScanner; + } - private static int fgRefCount= 0; + /** + * Returns the singleton color provider. + */ + public static PHPColorProvider getJavaColorProvider() { + return fgColorProvider; + } - /** - * A connection has occured - initialize the receiver if it is the first activation. - */ - public static void connect(Object client) { - if (++fgRefCount == 1) { - fgColorProvider= new PHPColorProvider(); - fgCodeScanner= new PHPCodeScanner(fgColorProvider); - // fgDocScanner= new JavaDocScanner(fgColorProvider); - } - } - - /** - * A disconnection has occured - clear the receiver if it is the last deactivation. - */ - public static void disconnect(Object client) { - if (--fgRefCount == 0) { - fgCodeScanner= null; -// fgDocScanner= null; - fgColorProvider.dispose(); - fgColorProvider= null; - } - } - - /** - * Returns the singleton scanner. - */ - public static RuleBasedScanner getPHPCodeScanner() { - return fgCodeScanner; - } - - /** - * Returns the singleton color provider. - */ - public static PHPColorProvider getJavaColorProvider() { - return fgColorProvider; - } - - /** - * Returns the singleton document scanner. - */ -// public static RuleBasedScanner getJavaDocScanner() { -// return fgDocScanner; -// } + /** + * Returns the singleton document scanner. + */ + // public static RuleBasedScanner getJavaDocScanner() { + // return fgDocScanner; + // } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties index e69de29..0ad7081 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties @@ -0,0 +1,33 @@ +############################################################# +# +# (c) Copyright IBM Corp. 2000, 2001. +# All Rights Reserved. +# +############################################################# + +## Actions ## + +ContentAssistProposal.label=Content Assist@Ctrl+SPACE +ContentAssistProposal.tooltip=Content Assist +ContentAssistProposal.image= +ContentAssistProposal.description=Content Assist + +ContentAssistTip.label=Content Tip@Ctrl+SHIFT+SPACE +ContentAssistTip.tooltip=Content Tip +ContentAssistTip.image= +ContentAssistTip.description=Content Tip + +TogglePresentation.label=Change Presentation +TogglePresentation.tooltip=Enable/Disable Segmented Source Viewer +TogglePresentation.image=togglepresentation.gif +TogglePresentation.description=Enable/Disable Segmented Source Viewer + +OutlinePage.segment.title_pattern=position {0} + +AutoIndent.error.bad_location_1=JavaAutoIndentStrategy.getAutoIndentString: BadLocationException +AutoIndent.error.bad_location_2=JavaAutoIndentStrategy.calcShiftBackReplace: BadLocationException + +CompletionProcessor.ContextInfo.display.pattern=proposal {0} at position {1} +CompletionProcessor.ContextInfo.value.pattern=proposal {0} valid from {1} to {2} +CompletionProcessor.Proposal.ContextInfo.pattern={0} valid 5 characters around insertion point +CompletionProcessor.Proposal.hoverinfo.pattern=Java keyword: {0} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPFunctionHelpResource.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPFunctionHelpResource.java new file mode 100644 index 0000000..e14fcdf --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPFunctionHelpResource.java @@ -0,0 +1,36 @@ +/********************************************************************** +Copyright (c) 2000, 2002 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 + +Contributors: + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de +**********************************************************************/ +package net.sourceforge.phpeclipse.phpeditor; + +import org.eclipse.help.IHelpResource; + +/** + * Example implementation for an ITextHover + * which hovers over PHP code. + */ +public class PHPFunctionHelpResource implements IHelpResource { + + private String word; + + public PHPFunctionHelpResource(String word) { + this.word = word; + } + + public String getHref() { + return "/net.sourceforge.phpeclipse/doc/function." + word + ".html"; + } + + public String getLabel() { + return "PHP Context Help"; + } + +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java index c6aaad9..abea8df 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java @@ -11,7 +11,6 @@ Contributors: **********************************************************************/ package net.sourceforge.phpeclipse.phpeditor; - import java.util.List; import org.eclipse.swt.graphics.RGB; @@ -45,123 +44,125 @@ import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider; */ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration { - /** - * Single token scanner. - */ - static class SingleTokenScanner extends BufferedRuleBasedScanner { - public SingleTokenScanner(TextAttribute attribute) { - setDefaultReturnToken(new Token(attribute)); - } - }; - - /** - * Default constructor. - */ - public PHPSourceViewerConfiguration() { - } - - /* (non-Javadoc) - * Method declared on SourceViewerConfiguration - */ - public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { - return new PHPAnnotationHover(); - } - - /* (non-Javadoc) - * Method declared on SourceViewerConfiguration - */ - public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) { - return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? new PHPAutoIndentStrategy() : new DefaultAutoIndentStrategy()); - } - - /* (non-Javadoc) - * Method declared on SourceViewerConfiguration - */ - public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { - return new String[] { - IDocument.DEFAULT_CONTENT_TYPE, - PHPPartitionScanner.PHP, - // PHPPartitionScanner.JAVA_DOC, - PHPPartitionScanner.JAVA_MULTILINE_COMMENT }; - } - - /* (non-Javadoc) - * Method declared on SourceViewerConfiguration - */ - public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { - - ContentAssistant assistant = new ContentAssistant(); - assistant.setContentAssistProcessor(new PHPCompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE); - // assistant.setContentAssistProcessor(new JavaDocCompletionProcessor(), PHPPartitionScanner.JAVA_DOC); - - assistant.enableAutoActivation(true); - assistant.setAutoActivationDelay(500); - assistant.setProposalPopupOrientation(assistant.PROPOSAL_OVERLAY); - assistant.setContextInformationPopupOrientation(assistant.CONTEXT_INFO_ABOVE); - assistant.setContextInformationPopupBackground(PHPEditorEnvironment.getJavaColorProvider().getColor(new RGB(150, 150, 0))); - - return assistant; - } - - /* (non-Javadoc) - * Method declared on SourceViewerConfiguration - */ - public String getDefaultPrefix(ISourceViewer sourceViewer, String contentType) { - return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" : null); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * Method declared on SourceViewerConfiguration - */ - public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { - return new PHPDoubleClickSelector(); - } - - /* (non-Javadoc) - * Method declared on SourceViewerConfiguration - */ - public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) { - return new String[] { "\t", " " }; //$NON-NLS-1$ //$NON-NLS-2$ - } - - /* (non-Javadoc) - * Method declared on SourceViewerConfiguration - */ - public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { - - PHPColorProvider provider = PHPEditorEnvironment.getJavaColorProvider(); - PresentationReconciler reconciler = new PresentationReconciler(); - - DefaultDamagerRepairer dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(provider.HTML_DEFAULT)))); - reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); - reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); + /** + * Single token scanner. + */ + static class SingleTokenScanner extends BufferedRuleBasedScanner { + public SingleTokenScanner(TextAttribute attribute) { + setDefaultReturnToken(new Token(attribute)); + } + }; + + /** + * Default constructor. + */ + public PHPSourceViewerConfiguration() { + } + + /* (non-Javadoc) + * Method declared on SourceViewerConfiguration + */ + public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { + return new PHPAnnotationHover(); + } + + /* (non-Javadoc) + * Method declared on SourceViewerConfiguration + */ + public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) { + return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? new PHPAutoIndentStrategy() : new DefaultAutoIndentStrategy()); + } + + /* (non-Javadoc) + * Method declared on SourceViewerConfiguration + */ + public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { + return new String[] { IDocument.DEFAULT_CONTENT_TYPE, PHPPartitionScanner.PHP, + // PHPPartitionScanner.JAVA_DOC, + PHPPartitionScanner.HTML_MULTILINE_COMMENT }; + } + + /* (non-Javadoc) + * Method declared on SourceViewerConfiguration + */ + public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { + + ContentAssistant assistant = new ContentAssistant(); + // assistant.setContentAssistProcessor(new PHPCompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE); + assistant.setContentAssistProcessor(new PHPCompletionProcessor(), PHPPartitionScanner.PHP); + + assistant.enableAutoActivation(true); + assistant.setAutoActivationDelay(500); + assistant.setProposalPopupOrientation(assistant.PROPOSAL_OVERLAY); + assistant.setContextInformationPopupOrientation(assistant.CONTEXT_INFO_ABOVE); + assistant.setContextInformationPopupBackground(PHPEditorEnvironment.getJavaColorProvider().getColor(new RGB(150, 150, 0))); + + return assistant; + } + + /* (non-Javadoc) + * Method declared on SourceViewerConfiguration + */ + public String getDefaultPrefix(ISourceViewer sourceViewer, String contentType) { + return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" : null); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * Method declared on SourceViewerConfiguration + */ + public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { + return new PHPDoubleClickSelector(); + } + + /* (non-Javadoc) + * Method declared on SourceViewerConfiguration + */ + public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) { + return new String[] { "\t", " " }; //$NON-NLS-1$ //$NON-NLS-2$ + } + + /* (non-Javadoc) + * Method declared on SourceViewerConfiguration + */ + public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { + + PHPColorProvider provider = PHPEditorEnvironment.getJavaColorProvider(); + PresentationReconciler reconciler = new PresentationReconciler(); + + DefaultDamagerRepairer dr= new DefaultDamagerRepairer(PHPEditorEnvironment.getHTMLCodeScanner()); + reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); + reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); +// dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(provider.HTML_DEFAULT)))); +// reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); +// reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); + dr = new DefaultDamagerRepairer(PHPEditorEnvironment.getPHPCodeScanner()); reconciler.setDamager(dr, PHPPartitionScanner.PHP); reconciler.setRepairer(dr, PHPPartitionScanner.PHP); - -// dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(provider.JAVADOC_DEFAULT)))); -// reconciler.setDamager(dr, PHPPartitionScanner.JAVA_DOC); -// reconciler.setRepairer(dr, PHPPartitionScanner.JAVA_DOC); - - dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(provider.MULTI_LINE_COMMENT)))); - reconciler.setDamager(dr, PHPPartitionScanner.JAVA_MULTILINE_COMMENT); - reconciler.setRepairer(dr, PHPPartitionScanner.JAVA_MULTILINE_COMMENT); - - return reconciler; - } - - /* (non-Javadoc) - * Method declared on SourceViewerConfiguration - */ - public int getTabWidth(ISourceViewer sourceViewer) { - return 4; - } - - /* (non-Javadoc) - * Method declared on SourceViewerConfiguration - */ - public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { - return new PHPTextHover(); - } + +// dr = new DefaultDamagerRepairer(PHPEditorEnvironment.getHTMLCodeScanner()); +// reconciler.setDamager(dr, PHPPartitionScanner.HTML); +// reconciler.setRepairer(dr, PHPPartitionScanner.HTML); + + dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(provider.MULTI_LINE_COMMENT)))); + reconciler.setDamager(dr, PHPPartitionScanner.HTML_MULTILINE_COMMENT); + reconciler.setRepairer(dr, PHPPartitionScanner.HTML_MULTILINE_COMMENT); + + return reconciler; + } + + /* (non-Javadoc) + * Method declared on SourceViewerConfiguration + */ + public int getTabWidth(ISourceViewer sourceViewer) { + return 4; + } + + /* (non-Javadoc) + * Method declared on SourceViewerConfiguration + */ + public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { + return new PHPTextHover(); + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java index 3f8e79a..071cb9f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java @@ -11,41 +11,43 @@ Contributors: **********************************************************************/ package net.sourceforge.phpeclipse.phpeditor; - -import org.eclipse.swt.graphics.Point; +import net.sourceforge.phpeclipse.phpeditor.php.PHPWordExtractor; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextHover; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Region; +import org.eclipse.swt.graphics.Point; /** * Example implementation for an ITextHover * which hovers over PHP code. */ public class PHPTextHover implements ITextHover { + private static PHPWordExtractor phpWordDetector = new PHPWordExtractor(); + /* (non-Javadoc) + * Method declared on ITextHover + */ + public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { + if (hoverRegion != null) { + try { + if (hoverRegion.getLength() > -1) { + return textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength()); + } + } catch (BadLocationException x) { + } + } + return "empty selection"; + } - /* (non-Javadoc) - * Method declared on ITextHover - */ - public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { - if (hoverRegion != null) { - try { - if (hoverRegion.getLength() > -1) - return textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength()); - } catch (BadLocationException x) { - } - } - return "empty selection"; - } - - /* (non-Javadoc) - * Method declared on ITextHover - */ - public IRegion getHoverRegion(ITextViewer textViewer, int offset) { - Point selection= textViewer.getSelectedRange(); - if (selection.x <= offset && offset < selection.x + selection.y) - return new Region(selection.x, selection.y); - return new Region(offset, 0); - } + /* (non-Javadoc) + * Method declared on ITextHover + */ + public IRegion getHoverRegion(ITextViewer textViewer, int offset) { + Point selection = PHPWordExtractor.findWord(textViewer.getDocument(), offset); +// show the extracted word as a tooltip + if (selection!=null && selection.x <= offset && offset < selection.x + selection.y) + return new Region(selection.x, selection.y); + return new Region(offset, 0); + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLCodeScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLCodeScanner.java new file mode 100644 index 0000000..ccc6b92 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLCodeScanner.java @@ -0,0 +1,152 @@ +/********************************************************************** +Copyright (c) 2000, 2002 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 + +Contributors: + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de +**********************************************************************/ +package net.sourceforge.phpeclipse.phpeditor.php; + +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.phpeclipse.phpeditor.util.HTMLWordDetector; +import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider; +import net.sourceforge.phpeclipse.phpeditor.util.PHPWhitespaceDetector; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.TextAttribute; +import org.eclipse.jface.text.rules.ICharacterScanner; +import org.eclipse.jface.text.rules.IRule; +import org.eclipse.jface.text.rules.IToken; +import org.eclipse.jface.text.rules.IWordDetector; +import org.eclipse.jface.text.rules.RuleBasedScanner; +import org.eclipse.jface.text.rules.SingleLineRule; +import org.eclipse.jface.text.rules.Token; +import org.eclipse.jface.text.rules.WhitespaceRule; +import org.eclipse.jface.text.rules.WordRule; + +/** + * A Java code scanner. + */ +public class HTMLCodeScanner extends RuleBasedScanner { + + private static String[] fgKeywords = { + }; + + private static String[] fgTypes = { + }; + + private IToken keyword; + + private class HTMLWordRule extends WordRule { + private StringBuffer fBuffer = new StringBuffer(); + + public HTMLWordRule(IWordDetector detector) { + super(detector, Token.UNDEFINED); + } + + public HTMLWordRule(IWordDetector detector, IToken defaultToken) { + super(detector, defaultToken); + } + + public IToken evaluate(ICharacterScanner scanner) { + int c = scanner.read(); + boolean tagBegin = false; + if (fDetector.isWordStart((char) c)) { + if (c == '<') { + tagBegin = true; + } + if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) { + + fBuffer.setLength(0); + do { + fBuffer.append((char) c); + c = scanner.read(); + if (c == '>') { + fBuffer.append((char) c); + c = scanner.read(); + break; + } + if (c == '/' && (fBuffer.length() > 2) ) { + break; + } + } while (c != scanner.EOF && fDetector.isWordPart((char) c)); + scanner.unread(); + + if (tagBegin) { + return keyword; + } + IToken token = (IToken) fWords.get(fBuffer.toString()); + if (token != null) + return token; + + if (fDefaultToken.isUndefined()) + unreadBuffer(scanner); + + return fDefaultToken; + } + } + + scanner.unread(); + return Token.UNDEFINED; + } + + } + + //private static String[] fgConstants = { "__LINE__", "__FILE__", "true", "false" }; + private TextAttribute fComment; + private TextAttribute fKeyword; + private TextAttribute fType; + private TextAttribute fString; + private PHPColorProvider fColorProvider; + + /** + * Creates a Java code scanner + */ + public HTMLCodeScanner(PHPColorProvider provider) { + + keyword = new Token(new TextAttribute(provider.getColor(PHPColorProvider.KEYWORD))); + IToken type = new Token(new TextAttribute(provider.getColor(PHPColorProvider.TYPE))); + IToken string = new Token(new TextAttribute(provider.getColor(PHPColorProvider.STRING))); + 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))); + + //variable = new Token(new TextAttribute(provider.getColor(PHPColorProvider.VARIABLE))); + + List rules = new ArrayList(); + + // Add rule for single line comments. + //rules.add(new EndOfLineRule("//", comment)); //$NON-NLS-1$ + //rules.add(new EndOfLineRule("#", comment)); + + // Add rule for strings and character constants. + rules.add(new SingleLineRule("\"", "\"", string)); //$NON-NLS-2$ //$NON-NLS-1$ + // rules.add(new SingleLineRule("'", "'", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$ + + // rules.add(new SingleLineRule("//", "//", php_comment)); + // rules.add(new MultiLineRule("/*", "*/", multi_comment)); + + // Add generic whitespace rule. + rules.add(new WhitespaceRule(new PHPWhitespaceDetector())); + + // Add word rule for keywords, types, and constants. + HTMLWordRule wordRule = new HTMLWordRule(new HTMLWordDetector(), other); + for (int i = 0; i < fgKeywords.length; i++) + wordRule.addWord(fgKeywords[i], keyword); + for (int i = 0; i < fgTypes.length; i++) + wordRule.addWord(fgTypes[i], type); + // for (int i = 0; i < fgConstants.length; i++) + // wordRule.addWord(fgConstants[i], type); + rules.add(wordRule); + + IRule[] result = new IRule[rules.size()]; + rules.toArray(result); + setRules(result); + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java new file mode 100644 index 0000000..a79d914 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java @@ -0,0 +1,86 @@ +/********************************************************************** +Copyright (c) 2000, 2002 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 + +Contributors: + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de +**********************************************************************/ +package net.sourceforge.phpeclipse.phpeditor.php; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; + +/** + * Detects HTML words in documents. + */ +public class HTMLWordExtractor { + + /** + * Find the location of the word at offset in document. + * @returns Point - x is the start position, y is the end position. + * Return null if it is not found. + * @param document the document being searched. + * @param offset - the position to start searching from. + */ + public static Point findWord(IDocument document, int offset) { + + int start = -1; + int end = -1; + + try { + + int position = offset; + char character = ' '; + + while (position >= 0) { + character = document.getChar(position); + if (!Character.isJavaIdentifierPart(character)) + break; + --position; + } + if ((position > 0) && (character == '<')) { + --position; + } + if ((position > 1) && (character == '/')) { + character = document.getChar(position - 1); + if (character == '<') { + --position; + --position; + } + } + if (position==offset) { + return null; + } + + start = position; + + position = offset; + int length = document.getLength(); + character = ' '; + + while (position < length) { + character = document.getChar(position); + if (!Character.isJavaIdentifierPart(character)) + break; + ++position; + } + if ((position < length) && (character == '>')) { + ++position; + } + start++; + end = position; + + if (end > start) + return new Point(start, end - start); + + } catch (BadLocationException x) { + } + + return null; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java index 9e75272..c763b3f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java @@ -73,7 +73,7 @@ public class PHPCodeScanner extends RuleBasedScanner { "echo", "var" }; - private static String[] fgTypes = + public static String[] fgFunctionNames = { "COM_invoke", "COM_load", @@ -2506,8 +2506,8 @@ public class PHPCodeScanner extends RuleBasedScanner { PHPWordRule wordRule = new PHPWordRule(new PHPWordDetector(), other); for (int i = 0; i < fgKeywords.length; i++) wordRule.addWord(fgKeywords[i], keyword); - for (int i = 0; i < fgTypes.length; i++) - wordRule.addWord(fgTypes[i], type); + for (int i = 0; i < fgFunctionNames.length; i++) + wordRule.addWord(fgFunctionNames[i], type); for (int i = 0; i < fgConstants.length; i++) wordRule.addWord(fgConstants[i], type); rules.add(wordRule); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java index a9b88fc..57e4372 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java @@ -12,7 +12,10 @@ Contributors: package net.sourceforge.phpeclipse.phpeditor.php; import java.text.MessageFormat; +import java.util.ArrayList; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.TextPresentation; import org.eclipse.jface.text.contentassist.CompletionProposal; @@ -22,130 +25,176 @@ import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationPresenter; import org.eclipse.jface.text.contentassist.IContextInformationValidator; +import org.eclipse.swt.graphics.Point; /** * Example PHP completion processor. */ public class PHPCompletionProcessor implements IContentAssistProcessor { - /** - * Simple content assist tip closer. The tip is valid in a range - * of 5 characters around its popup location. - */ - protected static class Validator implements IContextInformationValidator, IContextInformationPresenter { - - protected int fInstallOffset; - - /* - * @see IContextInformationValidator#isContextInformationValid(int) - */ - public boolean isContextInformationValid(int offset) { - return Math.abs(fInstallOffset - offset) < 5; - } - - /* - * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int) - */ - public void install(IContextInformation info, ITextViewer viewer, int offset) { - fInstallOffset = offset; - } - - /* - * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int, TextPresentation) - */ - public boolean updatePresentation(int documentPosition, TextPresentation presentation) { - return false; - } - }; - - protected final static String[] fgProposals = - { - "array", - "break", - "class", - "continue", - "do", - "echo", - "else", - "elseif", - "endfor", - "endif", - "for", - "if", - "while", - "endwhile", - "switch", - "case", - "endswitch", - "return", - "define", - "include", - "include_once", - "require", - "require_once", - "function", - "new", - "old_function", - "default", - "global", - "static", - "foreach", - "endforeach", - "extends", - "empty", - "isset", - "var" }; - - protected IContextInformationValidator fValidator = new Validator(); - - /* (non-Javadoc) - * Method declared on IContentAssistProcessor - */ - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { - ICompletionProposal[] result = new ICompletionProposal[fgProposals.length]; - for (int i = 0; i < fgProposals.length; i++) { - IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ - result[i] = new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length(), null, fgProposals[i], info, MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ - } - return result; - } - - /* (non-Javadoc) - * Method declared on IContentAssistProcessor - */ - public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { - IContextInformation[] result = new IContextInformation[5]; - for (int i = 0; i < result.length; i++) - result[i] = new ContextInformation(MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.ContextInfo.display.pattern"), new Object[] { new Integer(i), new Integer(documentOffset)}), //$NON-NLS-1$ - MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.ContextInfo.value.pattern"), new Object[] { new Integer(i), new Integer(documentOffset - 5), new Integer(documentOffset + 5)})); //$NON-NLS-1$ - return result; - } - - /* (non-Javadoc) - * Method declared on IContentAssistProcessor - */ - public char[] getCompletionProposalAutoActivationCharacters() { - return new char[] { '.', '(' }; - } - - /* (non-Javadoc) - * Method declared on IContentAssistProcessor - */ - public char[] getContextInformationAutoActivationCharacters() { - return new char[] { '#' }; - } - - /* (non-Javadoc) - * Method declared on IContentAssistProcessor - */ - public IContextInformationValidator getContextInformationValidator() { - return fValidator; - } - - /* (non-Javadoc) - * Method declared on IContentAssistProcessor - */ - public String getErrorMessage() { - return null; - } + /** + * Simple content assist tip closer. The tip is valid in a range + * of 5 characters around its popup location. + */ + protected static class Validator implements IContextInformationValidator, IContextInformationPresenter { + + protected int fInstallOffset; + + /* + * @see IContextInformationValidator#isContextInformationValid(int) + */ + public boolean isContextInformationValid(int offset) { + return Math.abs(fInstallOffset - offset) < 5; + } + + /* + * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int) + */ + public void install(IContextInformation info, ITextViewer viewer, int offset) { + fInstallOffset = offset; + } + + /* + * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int, TextPresentation) + */ + public boolean updatePresentation(int documentPosition, TextPresentation presentation) { + return false; + } + }; + + protected final static String[] fgProposals = PHPCodeScanner.fgFunctionNames; + // { + // "array", + // "break", + // "class", + // "continue", + // "do", + // "echo", + // "else", + // "elseif", + // "endfor", + // "endif", + // "for", + // "if", + // "while", + // "endwhile", + // "switch", + // "case", + // "endswitch", + // "return", + // "define", + // "include", + // "include_once", + // "require", + // "require_once", + // "function", + // "new", + // "old_function", + // "default", + // "global", + // "static", + // "foreach", + // "endforeach", + // "extends", + // "empty", + // "isset", + // "var" }; + + protected IContextInformationValidator fValidator = new Validator(); + + /* (non-Javadoc) + * Method declared on IContentAssistProcessor + */ + public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { + + // ArrayList arrList = new ArrayList(5); + // IDocument document = viewer.getDocument(); + // if (documentOffset > 0) { + // try { + // char character = document.getChar(documentOffset - 1); + // Point point = PHPWordExtractor.findWord(document, documentOffset); + // if (point != null) { + // String word = document.get(point.x, point.y); + // for (int i = 0; i < fgProposals.length; i++) { + // if ((fgProposals[i].length() >= point.y) && fgProposals[i].substring(0, point.y).equals(word)) { + // IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ + // arrList.add(new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length(), null, fgProposals[i], info, MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i] }))); //$NON-NLS-1$ + // } + // } + // if (arrList.size() > 0) { + // ICompletionProposal[] result = new ICompletionProposal[arrList.size()]; + // for (int i=0;i 0) { + // try { + // char character = document.getChar(documentOffset - 1); + // if (character=='$') { + // + // } + // result = new ICompletionProposal[fgProposals.length]; + // for (int i = 0; i < fgProposals.length; i++) { + // IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ + // result[i] = new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length(), null, fgProposals[i], info, MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ + // } + // } catch (BadLocationException e) { + // } + // + // } else { + ICompletionProposal[] result = new ICompletionProposal[fgProposals.length]; + for (int i = 0; i < fgProposals.length; i++) { + IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ + result[i] = new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length(), null, fgProposals[i], info, MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ + } + + return result; + } + + /* (non-Javadoc) + * Method declared on IContentAssistProcessor + */ + public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { + IContextInformation[] result = new IContextInformation[5]; + for (int i = 0; i < result.length; i++) + result[i] = new ContextInformation(MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.ContextInfo.display.pattern"), new Object[] { new Integer(i), new Integer(documentOffset)}), //$NON-NLS-1$ + MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.ContextInfo.value.pattern"), new Object[] { new Integer(i), new Integer(documentOffset - 5), new Integer(documentOffset + 5)})); //$NON-NLS-1$ + return result; + } + + /* (non-Javadoc) + * Method declared on IContentAssistProcessor + */ + public char[] getCompletionProposalAutoActivationCharacters() { + return new char[] { '$' }; + } + + /* (non-Javadoc) + * Method declared on IContentAssistProcessor + */ + public char[] getContextInformationAutoActivationCharacters() { + return new char[] { + }; + } + + /* (non-Javadoc) + * Method declared on IContentAssistProcessor + */ + public IContextInformationValidator getContextInformationValidator() { + return fValidator; + } + + /* (non-Javadoc) + * Method declared on IContentAssistProcessor + */ + public String getErrorMessage() { + return null; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPEditorMessages.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPEditorMessages.java index f8970bf..d45fffc 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPEditorMessages.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPEditorMessages.java @@ -16,19 +16,21 @@ import java.util.ResourceBundle; public class PHPEditorMessages { - private static final String RESOURCE_BUNDLE = "org.eclipse.ui.examples.javaeditor.JavaEditorMessages"; //$NON-NLS-1$ + private static final String RESOURCE_BUNDLE = "net.sourceforge.phpeclipse.phpeditor.PHPEditorMessages"; //$NON-NLS-1$ + +// private static ResourceBundle fgResourceBundle = null; + private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - private static ResourceBundle fgResourceBundle = null; // ResourceBundle.getBundle(RESOURCE_BUNDLE); private PHPEditorMessages() { - if (fgResourceBundle == null) { - try { - fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE); - } catch (MissingResourceException x) { - fgResourceBundle = null; - } - } +// if (fgResourceBundle == null) { +// try { +// fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE); +// } catch (MissingResourceException x) { +// fgResourceBundle = null; +// } +// } } public static String getString(String key) { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java index 43970cd..bebcc1f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java @@ -30,10 +30,20 @@ import org.eclipse.jface.text.rules.WordRule; public class PHPPartitionScanner extends RuleBasedPartitionScanner { private final static String SKIP = "__skip"; //$NON-NLS-1$ - public final static String JAVA_MULTILINE_COMMENT = "__html_multiline_comment"; //$NON-NLS-1$ + public final static String HTML_MULTILINE_COMMENT = "__html_multiline_comment"; //$NON-NLS-1$ // public final static String JAVA_DOC= "__java_javadoc"; //$NON-NLS-1$ public final static String PHP = "__php"; +// public final static String HTML = "__html"; + + public final static IToken php = new Token(PHP); +// public final static IToken html = new Token(HTML); + public final static IToken comment = new Token(HTML_MULTILINE_COMMENT); + + protected final static char[] php0EndSequence = { '<', '?' }; + protected final static char[] php1EndSequence = { '<', '?', 'p', 'h', 'p' }; + protected final static char[] php2EndSequence = { '<', '?', 'P', 'H', 'P' }; private StringBuffer test; + public class PHPMultiLineRule extends MultiLineRule { public PHPMultiLineRule(String startSequence, String endSequence, IToken token) { @@ -115,8 +125,287 @@ public class PHPPartitionScanner extends RuleBasedPartitionScanner { } } scanner.unread(); + return false; + } + } + +// public class HTMLMultiLineRule extends MultiLineRule { +// +// public HTMLMultiLineRule(String startSequence, String endSequence, IToken token) { +// super(startSequence, endSequence, token); +// } +// +// public HTMLMultiLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter) { +// super(startSequence, endSequence, token, escapeCharacter); +// } +// +// protected boolean endSequenceDetected(ICharacterScanner scanner) { +// int c; +// +// char[][] delimiters = scanner.getLegalLineDelimiters(); +// while ((c = scanner.read()) != ICharacterScanner.EOF) { +// if (c == '<') { +// // scanner.unread(); +// if (sequenceDetected(scanner, php2EndSequence, true)) { +// // null is a legal value + * @param token the token which will be returned on success + * @param escapeCharacter any character following this one will be ignored + * @param indicates whether the end of the line also termines the pattern + */ + public HTMLPatternRule(IToken token) { + fToken = token; + fEscapeCharacter = (char)0; + fBreaksOnEOL = false; + } + + /** + * Sets a column constraint for this rule. If set, the rule's token + * will only be returned if the pattern is detected starting at the + * specified column. If the column is smaller then 0, the column + * constraint is considered removed. + * + * @param column the column in which the pattern starts + */ + public void setColumnConstraint(int column) { + if (column < 0) + column = UNDEFINED; + fColumn = column; + } + + /** + * Evaluates this rules without considering any column constraints. + * + * @param scanner the character scanner to be used + * @return the token resulting from this evaluation + */ + protected IToken doEvaluate(ICharacterScanner scanner) { + return doEvaluate(scanner, false); + } + + /** + * Evaluates this rules without considering any column constraints. Resumes + * detection, i.e. look sonly for the end sequence required by this rule if the + * resume flag is set. + * + * @param scanner the character scanner to be used + * @param resume true if detection should be resumed, false otherwise + * @return the token resulting from this evaluation + * @since 2.0 + */ + protected IToken doEvaluate(ICharacterScanner scanner, boolean resume) { + + if (resume) { + + if (endSequenceDetected(scanner)) + return fToken; + + } else { + + int c = scanner.read(); + // if (c == fStartSequence[0]) { + // if (sequenceDetected(scanner, fStartSequence, false)) { + if (endSequenceDetected(scanner)) + return fToken; + // } + // } + } + + scanner.unread(); + return Token.UNDEFINED; + } + + /* + * @see IRule#evaluate + */ + public IToken evaluate(ICharacterScanner scanner) { + return evaluate(scanner, false); + } + + /** + * Returns whether the end sequence was detected. As the pattern can be considered + * ended by a line delimiter, the result of this method is true if the + * rule breaks on the end of the line, or if the EOF character is read. + * + * @param scanner the character scanner to be used + * @return true if the end sequence has been detected + */ + protected boolean endSequenceDetected(ICharacterScanner scanner) { + int c; + + char[][] delimiters = scanner.getLegalLineDelimiters(); + while ((c = scanner.read()) != ICharacterScanner.EOF) { + if (c == '<') { + // scanner.unread(); + if (sequenceDetected(scanner, php2EndSequence, true)) { + // true if the given sequence has been detected + */ + protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) { + for (int i = 1; i < sequence.length; i++) { + int c = scanner.read(); + if (c == ICharacterScanner.EOF && eofAllowed) { + return true; + } else if (c != sequence[i]) { + // Non-matching character detected, rewind the scanner back to the start. + scanner.unread(); + for (int j = i - 1; j > 0; j--) + scanner.unread(); + return false; + } + } + return true; } + + /* + * @see IPredicateRule#evaluate(ICharacterScanner, boolean) + * @since 2.0 + */ + public IToken evaluate(ICharacterScanner scanner, boolean resume) { + if (fColumn == UNDEFINED) + return doEvaluate(scanner, resume); + + int c = scanner.read(); + scanner.unread(); + // if (c == fStartSequence[0]) + return (fColumn == scanner.getColumn() ? doEvaluate(scanner, resume) : Token.UNDEFINED); + // else + // return Token.UNDEFINED; + } + + /* + * @see IPredicateRule#getSuccessToken() + * @since 2.0 + */ + public IToken getSuccessToken() { + return fToken; + } } /** * Detector for empty comments. @@ -172,9 +461,9 @@ public class PHPPartitionScanner extends RuleBasedPartitionScanner { public PHPPartitionScanner() { super(); - // IToken javaDoc= new Token(JAVA_DOC); - IToken comment = new Token(JAVA_MULTILINE_COMMENT); - IToken php = new Token(PHP); + // IToken php = new Token(PHP); + // IToken html = new Token(HTML); + // IToken comment = new Token(HTML_MULTILINE_COMMENT); List rules = new ArrayList(); @@ -186,10 +475,12 @@ public class PHPPartitionScanner extends RuleBasedPartitionScanner { // rules.add(new SingleLineRule("'", "'", Token.UNDEFINED, '\\')); // Add special case word rule. - rules.add(new WordPredicateRule(comment)); +// rules.add(new WordPredicateRule(comment)); // Add rules for multi-line comments and javadoc. //rules.add(new MultiLineRule("/**", "*/", javaDoc)); + // rules.add(new HTMLMultiLineRule("<", "", comment)); rules.add(new PHPMultiLineRule("", php)); rules.add(new PHPMultiLineRule("", php)); @@ -197,10 +488,67 @@ public class PHPPartitionScanner extends RuleBasedPartitionScanner { rules.add(new PHPMultiLineRule("", php)); rules.add(new PHPMultiLineRule("", php)); rules.add(new PHPMultiLineRule("", php)); + +// rules.add(new HTMLPatternRule(html)); // "<", "'); + } + + /* (non-Javadoc) + * Method declared on IWordDetector. + */ + public boolean isWordStart(char character) { + return character=='<'; + } +}