From 4f592efca0b99375a74e955131038e6080516ba3 Mon Sep 17 00:00:00 2001 From: khartlage <khartlage> Date: Wed, 26 Mar 2003 21:01:26 +0000 Subject: [PATCH 1/1] Added PHPDoc Scanner and Code Completion Processor --- .../internal/corext/template/default-templates.xml | 20 ++ .../internal/ui/text/phpdoc/PHPDocCodeScanner.java | 200 ++++++++++++++++++++ .../ui/text/phpdoc/PHPDocCompletionProcessor.java | 185 ++++++++++++++++++ .../phpeclipse/IPreferenceConstants.java | 9 + .../sourceforge/phpeclipse/PHPeclipsePlugin.java | 24 ++- .../phpeclipse/phpeditor/PHPEditorEnvironment.java | 23 ++- .../phpeditor/PHPSourceViewerConfiguration.java | 9 +- .../phpeditor/php/HTMLCompletionProcessor.java | 2 +- .../phpeditor/php/PHPPartitionScanner.java | 15 +- .../phpeditor/util/PHPColorProvider.java | 6 + 10 files changed, 471 insertions(+), 22 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/PHPDocCodeScanner.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/PHPDocCompletionProcessor.java diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml index 4b23f16..c684ed0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml @@ -63,6 +63,26 @@ <template name="echo" description="echo a string" context="php" enabled="true">echo "${string}"; ${cursor}</template> + <!-- phpdoc --> + + <template description="<code></code>" name="<code>" context="phpdoc" + ><code>${cursor}</code></template> + + <template description="<code>null</code>" name="<code>" context="phpdoc" + ><code>null</code></template> + + <template description="<pre></pre>" name="<pre>" context="phpdoc" + ><pre>${cursor}</pre></template> + + <template description="<b></b>" name="<b>" context="phpdoc" + ><b>${cursor}</b></template> + + <template description="<i></i>" name="<i>" context="phpdoc" + ><i>${cursor}</i></template> + + <template description="author name" name="@author" context="phpdoc" + >@author ${user}</template> + <template name="<html" description="html page with head,title,body" context="html" enabled="true"> <html> <head> diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/PHPDocCodeScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/PHPDocCodeScanner.java new file mode 100644 index 0000000..ab422d1 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/PHPDocCodeScanner.java @@ -0,0 +1,200 @@ +/********************************************************************** +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 +**********************************************************************/ +package net.sourceforge.phpdt.internal.ui.text.phpdoc; + + +import java.util.ArrayList; +import java.util.List; + +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.IDocument; +import org.eclipse.jface.text.TextAttribute; +import org.eclipse.jface.text.rules.ICharacterScanner; +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 rule based PHPDoc scanner. + */ +public final class PHPDocCodeScanner extends RuleBasedScanner { + + + /** + * A key word detector. + */ + static class PHPDocKeywordDetector implements IWordDetector { + + /** + * @see IWordDetector#isWordStart + */ + public boolean isWordStart(char c) { + return (c == '@'); + } + + /** + * @see IWordDetector#isWordPart + */ + public boolean isWordPart(char c) { + return Character.isLetter(c); + } + }; + + + /** + * Detector for HTML comment delimiters. + */ + static class HTMLCommentDetector implements IWordDetector { + + /** + * @see IWordDetector#isWordStart + */ + public boolean isWordStart(char c) { + return (c == '<' || c == '-'); + } + + /** + * @see IWordDetector#isWordPart + */ + public boolean isWordPart(char c) { + return (c == '-' || c == '!' || c == '>'); + } + }; + + class TagRule extends SingleLineRule { + + /* + * @see SingleLineRule + */ + public TagRule(IToken token) { + super("<", ">", token, (char) 0); //$NON-NLS-2$ //$NON-NLS-1$ + } + + /* + * @see SingleLineRule + */ + public TagRule(IToken token, char escapeCharacter) { + super("<", ">", token, escapeCharacter); //$NON-NLS-2$ //$NON-NLS-1$ + } + + private IToken checkForWhitespace(ICharacterScanner scanner) { + + try { + + char c= getDocument().getChar(getTokenOffset() + 1); + if (!Character.isWhitespace(c)) + return fToken; + + } catch (BadLocationException x) { + } + + return Token.UNDEFINED; + } + + /* + * @see PatternRule#evaluate(ICharacterScanner) + */ + public IToken evaluate(ICharacterScanner scanner) { + IToken result= super.evaluate(scanner); + if (result == fToken) + return checkForWhitespace(scanner); + return result; + } + }; + + + private static String[] fgKeywords= {"@author", "@deprecated", "@exception", "@param", "@return", "@see", "@serial", "@serialData", "@serialField", "@since", "@throws", "@version"}; //$NON-NLS-12$ //$NON-NLS-11$ //$NON-NLS-10$ //$NON-NLS-7$ //$NON-NLS-9$ //$NON-NLS-8$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ + +// private static String[] fgTokenProperties= { +// IJavaColorConstants.JAVADOC_KEYWORD, +// IJavaColorConstants.JAVADOC_TAG, +// IJavaColorConstants.JAVADOC_LINK, +// IJavaColorConstants.JAVADOC_DEFAULT +// }; + + + public PHPDocCodeScanner(PHPColorProvider provider) { // , IPreferenceStore store) { + // super(manager, store); + // initialize(); + createRules(provider); + } + + public IDocument getDocument() { + return fDocument; + } + + /* + * @see AbstractJavaScanner#getTokenProperties() + */ +// protected String[] getTokenProperties() { +// return fgTokenProperties; +// } + + /* create the rules for PHPDoc + */ + protected List createRules(PHPColorProvider provider) { + + List list= new ArrayList(); + + +// IToken type = new Token(new TextAttribute(provider.getColor(PHPColorProvider.FUNCTION_NAME))); +// 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))); + + // Add rule for tags. + // Token token= getToken(IJavaColorConstants.JAVADOC_TAG); + Token token = new Token(new TextAttribute(provider.getColor(PHPColorProvider.PHPDOC_TAG))); + list.add(new TagRule(token)); + + + // Add rule for HTML comments + WordRule wordRule= new WordRule(new HTMLCommentDetector(), token); + wordRule.addWord("<!--", token); //$NON-NLS-1$ + wordRule.addWord("--!>", token); //$NON-NLS-1$ + list.add(wordRule); + + + // Add rule for links. + token= new Token(new TextAttribute(provider.getColor(PHPColorProvider.PHPDOC_LINK))); + list.add(new SingleLineRule("{@link", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ + + + // Add generic whitespace rule. + list.add(new WhitespaceRule(new PHPWhitespaceDetector())); + + + // Add word rule for keywords. + token= new Token(new TextAttribute(provider.getColor(PHPColorProvider.PHPDOC_DEFAULT))); + wordRule= new WordRule(new PHPDocKeywordDetector(), token); + + token= new Token(new TextAttribute(provider.getColor(PHPColorProvider.PHPDOC_KEYWORD))); + for (int i= 0; i < fgKeywords.length; i++) + wordRule.addWord(fgKeywords[i], token); + list.add(wordRule); + + setDefaultReturnToken( new Token(new TextAttribute(provider.getColor(PHPColorProvider.PHPDOC_DEFAULT))) ); + return list; + } +} + + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/PHPDocCompletionProcessor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/PHPDocCompletionProcessor.java new file mode 100644 index 0000000..bca81e5 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/PHPDocCompletionProcessor.java @@ -0,0 +1,185 @@ +package net.sourceforge.phpdt.internal.ui.text.phpdoc; + +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ + +import java.util.Arrays; +import java.util.Comparator; + +import net.sourceforge.phpdt.internal.corext.template.ContextType; +import net.sourceforge.phpdt.internal.corext.template.ContextTypeRegistry; +import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal; +import net.sourceforge.phpdt.internal.ui.text.java.PHPCompletionProposalComparator; +import net.sourceforge.phpdt.internal.ui.text.template.TemplateEngine; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.jface.text.contentassist.IContextInformationValidator; +import org.eclipse.ui.IEditorPart; + +/** + * Simple PHPDoc completion processor. + */ +public class PHPDocCompletionProcessor implements IContentAssistProcessor { + + private static class JavaDocCompletionProposalComparator implements Comparator { + public int compare(Object o1, Object o2) { + ICompletionProposal c1= (ICompletionProposal) o1; + ICompletionProposal c2= (ICompletionProposal) o2; + return c1.getDisplayString().compareTo(c2.getDisplayString()); + } + }; + +// private IEditorPart fEditor; +// private IWorkingCopyManager fManager; + private char[] fProposalAutoActivationSet; + private PHPCompletionProposalComparator fComparator; + private TemplateEngine fTemplateEngine; + + private boolean fRestrictToMatchingCase; + + + public PHPDocCompletionProcessor() {// (IEditorPart editor) { + +// fEditor= editor; +// fManager= JavaPlugin.getDefault().getWorkingCopyManager(); + ContextType contextType= ContextTypeRegistry.getInstance().getContextType("phpdoc"); //$NON-NLS-1$ + if (contextType != null) + fTemplateEngine= new TemplateEngine(contextType); + fRestrictToMatchingCase= false; + + fComparator= new PHPCompletionProposalComparator(); + } + + /** + * Tells this processor to order the proposals alphabetically. + * + * @param order <code>true</code> if proposals should be ordered. + */ + public void orderProposalsAlphabetically(boolean order) { + fComparator.setOrderAlphabetically(order); + } + + /** + * Tells this processor to restrict is proposals to those + * starting with matching cases. + * + * @param restrict <code>true</code> if proposals should be restricted + */ + public void restrictProposalsToMatchingCases(boolean restrict) { + fRestrictToMatchingCase= restrict; + } + + /** + * @see IContentAssistProcessor#getErrorMessage() + */ + public String getErrorMessage() { + return null; + } + + /** + * @see IContentAssistProcessor#getContextInformationValidator() + */ + public IContextInformationValidator getContextInformationValidator() { + return null; + } + + /** + * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters() + */ + public char[] getContextInformationAutoActivationCharacters() { + return null; + } + + /** + * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() + */ + public char[] getCompletionProposalAutoActivationCharacters() { + return fProposalAutoActivationSet; + } + + /** + * Sets this processor's set of characters triggering the activation of the + * completion proposal computation. + * + * @param activationSet the activation set + */ + public void setCompletionProposalAutoActivationCharacters(char[] activationSet) { + fProposalAutoActivationSet= activationSet; + } + + /** + * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) + */ + public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { + return null; + } + + /** + * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int) + */ + public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { + // ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput()); + IDocument document= viewer.getDocument(); + + IPHPCompletionProposal[] results= new IPHPCompletionProposal[0]; + +// try { +// if (unit != null) { +// +// int offset= documentOffset; +// int length= 0; +// +// Point selection= viewer.getSelectedRange(); +// if (selection.y > 0) { +// offset= selection.x; +// length= selection.y; +// } +// +// JavaDocCompletionEvaluator evaluator= new JavaDocCompletionEvaluator(unit, document, offset, length); +// evaluator.restrictProposalsToMatchingCases(fRestrictToMatchingCase); +// results= evaluator.computeProposals(); +// } +// } catch (JavaModelException e) { +// JavaPlugin.log(e); +// } + + if (fTemplateEngine != null) { + // try { + fTemplateEngine.reset(); + fTemplateEngine.complete(viewer, documentOffset); //, unit); +// } catch (JavaModelException x) { +// } + + IPHPCompletionProposal[] templateResults= fTemplateEngine.getResults(); + if (results.length == 0) { + results= templateResults; + } else { + // concatenate arrays + IPHPCompletionProposal[] total= new IPHPCompletionProposal[results.length + templateResults.length]; + System.arraycopy(templateResults, 0, total, 0, templateResults.length); + System.arraycopy(results, 0, total, templateResults.length, results.length); + results= total; + } + } + + /* + * Order here and not in result collector to make sure that the order + * applies to all proposals and not just those of the compilation unit. + */ + return order(results); + } + + /** + * Order the given proposals. + */ + private IPHPCompletionProposal[] order(IPHPCompletionProposal[] proposals) { + Arrays.sort(proposals, fComparator); + return proposals; + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java index d40577c..06d2c17 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java @@ -69,6 +69,15 @@ public interface IPreferenceConstants { public static final String PHP_EDITOR_BACKGROUND = "_php_editor_background"; public static final String PHP_USERDEF_XMLFILE = "_userdef_xmlfile"; + /** The color key for PHPDoc keywords (<code>@foo</code>) in PHPDoc comments. */ + public static final String PHPDOC_KEYWORD= "_php_doc_keyword"; //$NON-NLS-1$ + /** The color key for HTML tags (<code><foo></code>) in PHPDoc comments. */ + public static final String PHPDOC_TAG= "_php_doc_tag"; //$NON-NLS-1$ + /** The color key for PHPDoc links (<code>{foo}</code>) in PHPDoc comments. */ + public static final String PHPDOC_LINK= "_php_doc_link"; //$NON-NLS-1$ + /** The color key for everthing in PHPDoc comments for which no other color is specified. */ + public static final String PHPDOC_DEFAULT= "_php_doc_default"; //$NON-NLS-1$ + /*Language stuff - under dev*/ public static final String RESOURCE_BUNDLE = "_php_editor_res_bundle"; //$NON-NLS-1$ public static final String LANGUAGE_DEFAULT = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_en_GB"; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index 48b2835..1f6f8f3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -103,7 +103,7 @@ public class PHPeclipsePlugin /** JVM constant for any other platform */ private static final int OTHER = -1; - + /** General debug flag*/ public static final boolean DEBUG = false; /** @@ -231,7 +231,7 @@ public class PHPeclipsePlugin public static void log(Throwable e) { log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$ } - + public static boolean isDebug() { return getDefault().isDebugging(); } @@ -339,7 +339,7 @@ public class PHPeclipsePlugin PreferenceConverter.setDefault( store, PHP_FUNCTIONNAME, - PHPColorProvider.FUNCTION_NAME); + PHPColorProvider.FUNCTION_NAME); PreferenceConverter.setDefault( store, PHP_CONSTANT, @@ -363,6 +363,24 @@ public class PHPeclipsePlugin LINE_NUMBER_COLOR, PHPColorProvider.LINE_NUMBER_COLOR); + // set default PHPDoc colors: + PreferenceConverter.setDefault( + store, + PHPDOC_KEYWORD, + PHPColorProvider.PHPDOC_KEYWORD); + PreferenceConverter.setDefault( + store, + PHPDOC_LINK, + PHPColorProvider.PHPDOC_LINK); + PreferenceConverter.setDefault( + store, + PHPDOC_DEFAULT, + PHPColorProvider.PHPDOC_DEFAULT); + PreferenceConverter.setDefault( + store, + PHPDOC_TAG, + PHPColorProvider.PHPDOC_TAG); + store.setDefault(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, "true"); PreferenceConverter.setDefault( store, 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 1b698a0..4c2ea9d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorEnvironment.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorEnvironment.java @@ -12,6 +12,7 @@ Contributors: Klaus Hartlage - www.eclipseproject.de **********************************************************************/ +import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner; import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner; import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner; import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider; @@ -23,7 +24,7 @@ public class PHPEditorEnvironment { private static PHPColorProvider fgColorProvider; private static PHPCodeScanner fgPHPCodeScanner; private static HTMLCodeScanner fgHTMLCodeScanner; - //private static JavaDocScanner fgDocScanner; + private static PHPDocCodeScanner fgDocScanner; private static int fgRefCount = 0; @@ -35,7 +36,7 @@ public class PHPEditorEnvironment { fgColorProvider = new PHPColorProvider(); fgPHPCodeScanner = new PHPCodeScanner(fgColorProvider); fgHTMLCodeScanner = new HTMLCodeScanner(fgColorProvider); - // fgDocScanner= new JavaDocScanner(fgColorProvider); + fgDocScanner = new PHPDocCodeScanner(fgColorProvider); } } @@ -46,7 +47,7 @@ public class PHPEditorEnvironment { if (--fgRefCount == 0) { fgPHPCodeScanner = null; fgHTMLCodeScanner = null; - // fgDocScanner= null; + fgDocScanner = null; fgColorProvider.dispose(); fgColorProvider = null; } @@ -59,21 +60,25 @@ public class PHPEditorEnvironment { return fgPHPCodeScanner; } + /** + * Returns the singleton scanner. + */ public static HTMLCodeScanner getHTMLCodeScanner() { return fgHTMLCodeScanner; } /** + * Returns the singleton PHPDoc scanner. + */ + public static PHPDocCodeScanner getPHPDocCodeScanner() { + return fgDocScanner; + } + + /** * Returns the singleton color provider. */ public static PHPColorProvider getPHPColorProvider() { return fgColorProvider; } - /** - * Returns the singleton document scanner. - */ - // public static RuleBasedScanner getJavaDocScanner() { - // return fgDocScanner; - // } } 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 09662be..b519646 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java @@ -14,6 +14,7 @@ package net.sourceforge.phpeclipse.phpeditor; import java.util.Vector; import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy; +import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy; import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor; @@ -157,8 +158,8 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration { ContentAssistant assistant = new ContentAssistant(); assistant.setContentAssistProcessor(new HTMLCompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE); assistant.setContentAssistProcessor(new PHPCompletionProcessor(), PHPPartitionScanner.PHP); - //assistant.setContentAssistProcessor(new PHPCompletionProcessor(), PHPPartitionScanner.HTML); - + assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(), PHPPartitionScanner.PHP_MULTILINE_COMMENT); + assistant.enableAutoActivation(true); assistant.setAutoActivationDelay(500); assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY); @@ -256,6 +257,10 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration { reconciler.setDamager(dr, PHPPartitionScanner.PHP); reconciler.setRepairer(dr, PHPPartitionScanner.PHP); + dr = new DefaultDamagerRepairer(PHPEditorEnvironment.getPHPDocCodeScanner()); + reconciler.setDamager(dr, PHPPartitionScanner.PHP_MULTILINE_COMMENT); + reconciler.setRepairer(dr, PHPPartitionScanner.PHP_MULTILINE_COMMENT); + // dr = new DefaultDamagerRepairer(PHPEditorEnvironment.getHTMLCodeScanner()); // reconciler.setDamager(dr, PHPPartitionScanner.HTML); // reconciler.setRepairer(dr, PHPPartitionScanner.HTML); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLCompletionProcessor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLCompletionProcessor.java index 493021f..9323dae 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLCompletionProcessor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLCompletionProcessor.java @@ -33,7 +33,7 @@ import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.swt.graphics.Image; /** - * Example PHP completion processor. + * HTML completion processor. */ public class HTMLCompletionProcessor implements IContentAssistProcessor { 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 df3d421..213ff71 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 @@ -24,13 +24,14 @@ import org.eclipse.jface.text.rules.Token; /** * This scanner recognizes the JavaDoc comments and Java multi line comments. */ -public class PHPPartitionScanner extends RuleBasedPartitionScanner { - - private final static String SKIP = "__skip"; //$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"; //$NON-NLS-1$ - //public final static String HTML = "__html"; //$NON-NLS-1$ +public class PHPPartitionScanner extends RuleBasedPartitionScanner implements IPHPPartitionScannerConstants { + + // private final static String SKIP = "__skip"; //$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"; //$NON-NLS-1$ +// //public final static String HTML = "__html"; //$NON-NLS-1$ public final static IToken php = new Token(PHP); //public final static IToken html = new Token(HTML); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPColorProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPColorProvider.java index 38d0238..b4cc40c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPColorProvider.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPColorProvider.java @@ -38,6 +38,12 @@ public class PHPColorProvider { public static final RGB LINE_NUMBER_COLOR = new RGB(0, 0, 0); public static final RGB BACKGROUND_COLOR = new RGB(255, 255, 255); + + public static final RGB PHPDOC_TAG = new RGB(63, 127, 95); + public static final RGB PHPDOC_LINK = new RGB(63, 63, 191); + public static final RGB PHPDOC_DEFAULT = new RGB(63, 95, 191); + public static final RGB PHPDOC_KEYWORD = new RGB(127, 159, 191); + protected Map fColorTable = new HashMap(10); /** -- 1.7.1