Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "PDT/Dev2Dev/Semantic"
(→API) |
(→API) |
||
Line 1: | Line 1: | ||
− | == Semantic Highlighting == | + | == Semantic Highlighting == |
− | === Overview === | + | === Overview === |
− | + | ||
− | + | Following the improvements done by the Web tools project ([https://bugs.eclipse.org/232752 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 [https://bugs.eclipse.org/271430 271430]. | + | [[Image:Pdt semantic editor.png]] |
+ | |||
+ | The latest version of the patch is available at [https://bugs.eclipse.org/271430 271430]. | ||
=== API === | === API === | ||
Line 72: | Line 73: | ||
<br> The following table describes the semantic rules that have been implemented so far and their default style. | <br> The following table describes the semantic rules that have been implemented so far and their default style. | ||
− | <br> | + | <br> |
{| cellspacing="1" cellpadding="1" border="1" style="width: 622px; height: 338px;" | {| cellspacing="1" cellpadding="1" border="1" style="width: 622px; height: 338px;" | ||
|- | |- | ||
− | | '''Rule<br>''' | + | | '''Rule<br>''' |
− | | '''Style<br>''' | + | | '''Style<br>''' |
| '''Enabled by default'''<br> | | '''Enabled by default'''<br> | ||
|- | |- | ||
− | | Constants<br> | + | | Constants<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Field<br> | + | | Field<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Function<br> | + | | Function<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Internal Function<br> | + | | Internal Function<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Global Variable<br> | + | | Global Variable<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Local variable<br> | + | | Local variable<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Method<br> | + | | Method<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Static Field<br> | + | | Static Field<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Static Method<br> | + | | Static Method<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Classes<br> | + | | Classes<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Internal Classes<br> | + | | Internal Classes<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Internal Interfaces<br> | + | | Internal Interfaces<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Interfaces<br> | + | | Interfaces<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Parameter Variables<br> | + | | Parameter Variables<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|- | |- | ||
− | | Super Globales<br> | + | | Super Globales<br> |
− | | <br> | + | | <br> |
| <br> | | <br> | ||
|} | |} | ||
− | <br> | + | <br> |
+ | |||
+ | === UI === | ||
− | + | The rules are automatically added to the Syntax Coloring preference page: | |
− | + | [[Image:Pdt semantic preferences.png]] | |
− | + | === Performances === | |
− | |||
Work in progress... | Work in progress... |
Revision as of 04:47, 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>
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 {
protected class InterfaceApply extends AbstractSemanticApply { @Override public boolean visit(ClassDeclaration classDecl) { for (Identifier type: classDecl.interfaces()) { highlight(type); } return true; } @Override public boolean visit(InterfaceDeclaration interfaceDecl) { highlight(interfaceDecl.getName()); for (Identifier type: classDecl.interfaces()) { highlight(type); } return true; } }
The following table describes the semantic rules that have been implemented so far and their default style.
Rule |
Style |
Enabled by default |
Constants |
|
|
Field |
|
|
Function |
|
|
Internal Function |
|
|
Global Variable |
|
|
Local variable |
|
|
Method |
|
|
Static Field |
|
|
Static Method |
|
|
Classes |
|
|
Internal Classes |
|
|
Internal Interfaces |
|
|
Interfaces |
|
|
Parameter Variables |
|
|
Super Globales |
|
|
UI
The rules are automatically added to the Syntax Coloring preference page:
Performances
Work in progress...