Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "PDT/Dev2Dev/Semantic"
(→Overview) |
(→Overview) |
||
Line 8: | Line 8: | ||
[[Image:pdt_semantic_editor.png]] | [[Image:pdt_semantic_editor.png]] | ||
− | The latest version of the patch is available at [https://bugs.eclipse.org/271430]. | + | The latest version of the patch is available at [https://bugs.eclipse.org/271430 271430]. |
=== API === | === API === |
Revision as of 03:27, 26 August 2009
Semantic Highlighting
Overview
Following the improvements done by the Web tools project (232752) on semantic highlighting, the PHP Source Editor can now set semantic rules for better coloring techniques that will improve its performance and functionality. For example, currently, all variables are highlighted in the same color. Although members / static / constants variables should be colored in separate colors just like the Java editor does.
The following screenshot demonstrate the power of the semantic coloring:
The latest version of the patch is available at 271430.
API
The PHP semantic highlighting API is used to define semantic rules for PHP coloring. It's also useful for plugin developpers who would like to extends PHP highlighting with specific semantic rules.
The first step is to use the org.eclipse.wst.sse.ui.semanticHighlighting extension point with the org.eclipse.php.core.phpsource target. By using the PHP source target, PHP UI plugin is automatically registering this contributor as a semantic highlighter.<extension point="org.eclipse.wst.sse.ui.semanticHighlighting"> <highlighting class="org.eclipse.php.internal.ui.editor.highlighting.ParameterVariableHighlighting" target="org.eclipse.php.core.phpsource"> </highlighting> </extension>
The given class must extend org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticHighlighting.
public class ParameterVariableHighlighting extends AbstractSemanticHighlighting { @Override public AbstractSemanticApply getSemanticApply() { return new ParameterVariableApply(); } @Override public void initDefaultPreferences() { getStyle().setUnderlineByDefault(true) .setDefaultTextColor(new RGB(102, 0, 0)); } public String getDisplayName() { return "Local variables"; } }
@HighlightingPriority(Priority.HIGH) public class InternalClassHighlighting extends AbstractSemanticHighlighting {
UI
The rules are automatically added to the Syntax Coloring preference page:
Performances
Work in progress...