aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2012-08-01 23:00:12 (EDT)
committerzzhongwei2012-08-01 23:00:12 (EDT)
commit24cf0482090dff67508aa043b7bf3b920acbd92f (patch)
treef1a1d168942233e4192183b2add76b2e11d40c5f
parent68b32c7edc356ca79783fd006d96a6bd2343cc3a (diff)
downloadorg.eclipse.pdt-24cf0482090dff67508aa043b7bf3b920acbd92f.zip
org.eclipse.pdt-24cf0482090dff67508aa043b7bf3b920acbd92f.tar.gz
org.eclipse.pdt-24cf0482090dff67508aa043b7bf3b920acbd92f.tar.bz2
Bug 379780 - Syntax Coloring for php5.4
-rw-r--r--plugins/org.eclipse.php.ui/plugin.xml22
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/ClassHighlighting.java3
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/FieldHighlighting.java43
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/MethodHighlighting.java30
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitFieldHighlighting.java22
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitHighlighting.java94
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitMemberHighlighting.java338
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitMethodHighlighting.java22
8 files changed, 571 insertions, 3 deletions
diff --git a/plugins/org.eclipse.php.ui/plugin.xml b/plugins/org.eclipse.php.ui/plugin.xml
index 4048cc8..2d77039 100644
--- a/plugins/org.eclipse.php.ui/plugin.xml
+++ b/plugins/org.eclipse.php.ui/plugin.xml
@@ -1932,6 +1932,28 @@
target="org.eclipse.php.core.phpsource">
</highlighting>
</extension>
+
+
+ <extension point="org.eclipse.wst.sse.ui.semanticHighlighting">
+ <highlighting
+ class="org.eclipse.php.internal.ui.editor.highlighters.TraitHighlighting"
+ target="org.eclipse.php.core.phpsource">
+ </highlighting>
+ </extension>
+
+ <extension point="org.eclipse.wst.sse.ui.semanticHighlighting">
+ <highlighting
+ class="org.eclipse.php.internal.ui.editor.highlighters.TraitMethodHighlighting"
+ target="org.eclipse.php.core.phpsource">
+ </highlighting>
+ </extension>
+
+ <extension point="org.eclipse.wst.sse.ui.semanticHighlighting">
+ <highlighting
+ class="org.eclipse.php.internal.ui.editor.highlighters.TraitFieldHighlighting"
+ target="org.eclipse.php.core.phpsource">
+ </highlighting>
+ </extension>
<extension
id="commentTemplateProposalCategory"
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/ClassHighlighting.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/ClassHighlighting.java
index 5157b2b..6d1c686 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/ClassHighlighting.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/ClassHighlighting.java
@@ -22,6 +22,9 @@ public class ClassHighlighting extends AbstractSemanticHighlighting {
@Override
public boolean visit(ClassDeclaration clazz) {
+ if (clazz instanceof TraitDeclaration) {
+ return true;
+ }
highlight(clazz.getName());
Expression superClass = clazz.getSuperClass();
if (superClass instanceof NamespaceName) {
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/FieldHighlighting.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/FieldHighlighting.java
index d889b5e..0f0c39a 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/FieldHighlighting.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/FieldHighlighting.java
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.php.internal.ui.editor.highlighters;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.internal.core.SourceField;
+import org.eclipse.php.core.compiler.PHPFlags;
import org.eclipse.php.internal.core.ast.nodes.*;
import org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticApply;
import org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticHighlighting;
@@ -22,7 +26,18 @@ public class FieldHighlighting extends AbstractSemanticHighlighting {
@Override
public boolean visit(SingleFieldDeclaration fieldDecl) {
- highlight(fieldDecl.getName());
+ ClassDeclaration cd = null;
+ ASTNode parent = fieldDecl.getParent();
+ while (parent != null) {
+ if (parent instanceof ClassDeclaration) {
+ cd = (ClassDeclaration) parent;
+ break;
+ }
+ parent = parent.getParent();
+ }
+ if (!(cd instanceof TraitDeclaration)) {
+ highlight(fieldDecl.getName());
+ }
return true;
}
@@ -45,7 +60,31 @@ public class FieldHighlighting extends AbstractSemanticHighlighting {
public boolean visit(Variable var) {
if (visitField > 0 && !var.isDollared()) {
- highlight(var);
+
+ IModelElement[] elements = null;
+ boolean processed = false;
+ try {
+ elements = (getSourceModule()).codeSelect(var.getStart(),
+ var.getLength());
+ if (elements != null && elements.length > 0) {
+ processed = true;
+ for (IModelElement iModelElement : elements) {
+ if ((iModelElement instanceof SourceField)) {
+ SourceField sourceMethod = (SourceField) iModelElement;
+ if (sourceMethod.getDeclaringType() != null
+ && PHPFlags.isClass(sourceMethod
+ .getDeclaringType().getFlags())) {
+ highlight(var);
+ break;
+ }
+ }
+ }
+ }
+ } catch (ModelException e) {
+ }
+ if (!processed) {
+ highlight(var);
+ }
}
return true;
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/MethodHighlighting.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/MethodHighlighting.java
index efcc38d..f101467 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/MethodHighlighting.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/MethodHighlighting.java
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.php.internal.ui.editor.highlighters;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.internal.core.SourceMethod;
+import org.eclipse.php.core.compiler.PHPFlags;
import org.eclipse.php.internal.core.ast.nodes.*;
import org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticApply;
import org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticHighlighting;
@@ -40,7 +44,31 @@ public class MethodHighlighting extends AbstractSemanticHighlighting {
*/
private void checkDispatch(ASTNode node) {
if (node.getType() == ASTNode.IDENTIFIER) {
- highlight(node);
+ // ((Identifier)node).resolveBinding()
+ IModelElement[] elements = null;
+ boolean processed = false;
+ try {
+ elements = (getSourceModule()).codeSelect(node.getStart(),
+ node.getLength());
+ if (elements != null && elements.length > 0) {
+ processed = true;
+ for (IModelElement iModelElement : elements) {
+ if (iModelElement instanceof SourceMethod) {
+ SourceMethod sourceMethod = (SourceMethod) iModelElement;
+ if (sourceMethod.getDeclaringType() != null
+ && PHPFlags.isClass(sourceMethod
+ .getDeclaringType().getFlags())) {
+ highlight(node);
+ }
+ }
+ }
+ }
+ } catch (ModelException e) {
+ }
+ if (!processed) {
+ highlight(node);
+ }
+
}
if (node.getType() == ASTNode.VARIABLE) {
Variable id = (Variable) node;
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitFieldHighlighting.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitFieldHighlighting.java
new file mode 100644
index 0000000..7b5a75e
--- /dev/null
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitFieldHighlighting.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Zend Corporation and IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William Candillon {wcandillon@gmail.com} - Initial implementation
+ *******************************************************************************/
+package org.eclipse.php.internal.ui.editor.highlighters;
+
+public class TraitFieldHighlighting extends TraitMemberHighlighting {
+
+ public String getDisplayName() {
+ return "Trait fields";
+ }
+
+ protected boolean isMethod() {
+ return false;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitHighlighting.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitHighlighting.java
new file mode 100644
index 0000000..dfce2ab
--- /dev/null
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitHighlighting.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Zend Corporation and IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William Candillon {wcandillon@gmail.com} - Initial implementation
+ *******************************************************************************/
+package org.eclipse.php.internal.ui.editor.highlighters;
+
+import java.util.List;
+
+import org.eclipse.php.internal.core.ast.nodes.*;
+import org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticApply;
+import org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticHighlighting;
+
+public class TraitHighlighting extends AbstractSemanticHighlighting {
+
+ protected class TraitApply extends AbstractSemanticApply {
+
+ @Override
+ public boolean visit(ClassDeclaration clazz) {
+ if (clazz instanceof TraitDeclaration) {
+ highlight(clazz.getName());
+ Expression superClass = clazz.getSuperClass();
+ if (superClass instanceof NamespaceName) {
+ highlightNamespaceType((NamespaceName) superClass);
+ } else if (superClass != null) {
+ highlight(superClass);
+ }
+ }
+ return true;
+ }
+
+ // public boolean visit(TraitAlias node) {
+ // return apply(node);
+ // }
+ //
+ // public boolean visit(TraitPrecedence node) {
+ // return apply(node);
+ // }
+
+ public boolean visit(TraitUseStatement node) {
+ List<NamespaceName> traitList = node.getTraitList();
+ for (NamespaceName namespaceName : traitList) {
+ highlightNamespaceType(namespaceName);
+ }
+ List<TraitStatement> tsList = node.getTsList();
+ for (TraitStatement traitStatement : tsList) {
+ if (traitStatement instanceof TraitAliasStatement) {
+ TraitAliasStatement statement = (TraitAliasStatement) traitStatement;
+ if (statement.getAlias().getTraitMethod() instanceof FullyQualifiedTraitMethodReference) {
+ FullyQualifiedTraitMethodReference reference = (FullyQualifiedTraitMethodReference) statement
+ .getAlias().getTraitMethod();
+ highlightNamespaceType(reference.getClassName());
+ }
+
+ } else if (traitStatement instanceof TraitPrecedenceStatement) {
+ TraitPrecedenceStatement statement = (TraitPrecedenceStatement) traitStatement;
+ FullyQualifiedTraitMethodReference reference = statement
+ .getPrecedence().getMethodReference();
+ highlightNamespaceType(reference.getClassName());
+ traitList = statement.getPrecedence().getTrList();
+ for (NamespaceName namespaceName : traitList) {
+ highlightNamespaceType(namespaceName);
+ }
+ }
+ }
+ return false;
+ }
+
+ private void highlightNamespaceType(NamespaceName name) {
+ List<Identifier> segments = name.segments();
+ Identifier segment = segments.get(segments.size() - 1);
+ highlight(segment);
+ }
+ }
+
+ @Override
+ public AbstractSemanticApply getSemanticApply() {
+ return new TraitApply();
+ }
+
+ @Override
+ public void initDefaultPreferences() {
+ getStyle().setEnabledByDefault(false).setDefaultTextColor(0, 80, 50);
+ }
+
+ public String getDisplayName() {
+ return "Traits";
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitMemberHighlighting.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitMemberHighlighting.java
new file mode 100644
index 0000000..02fe229
--- /dev/null
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitMemberHighlighting.java
@@ -0,0 +1,338 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Zend Corporation and IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William Candillon {wcandillon@gmail.com} - Initial implementation
+ *******************************************************************************/
+package org.eclipse.php.internal.ui.editor.highlighters;
+
+import java.util.List;
+
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.core.*;
+import org.eclipse.dltk.internal.core.SourceField;
+import org.eclipse.dltk.internal.core.SourceMethod;
+import org.eclipse.dltk.ti.types.IEvaluatedType;
+import org.eclipse.php.core.compiler.PHPFlags;
+import org.eclipse.php.internal.core.ast.nodes.*;
+import org.eclipse.php.internal.core.typeinference.PHPClassType;
+import org.eclipse.php.internal.core.typeinference.PHPModelUtils;
+import org.eclipse.php.internal.core.typeinference.PHPTypeInferenceUtils;
+import org.eclipse.php.internal.core.typeinference.context.FileContext;
+import org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticApply;
+import org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticHighlighting;
+
+public abstract class TraitMemberHighlighting extends
+ AbstractSemanticHighlighting {
+
+ protected class TraitMemberApply extends AbstractSemanticApply {
+
+ private int visitField = 0;
+
+ @Override
+ public boolean visit(FieldAccess fieldAccess) {
+ if (!isMethod()) {
+ visitField++;
+ }
+ return true;
+ }
+
+ public boolean visit(Variable var) {
+ if (!isMethod()) {
+ if (visitField > 0 && !var.isDollared()) {
+
+ IModelElement[] elements = null;
+ boolean processed = false;
+ try {
+ elements = (getSourceModule()).codeSelect(
+ var.getStart(), var.getLength());
+ if (elements != null && elements.length > 0) {
+ processed = true;
+ for (IModelElement iModelElement : elements) {
+ if ((iModelElement instanceof SourceField)) {
+ SourceField sourceMethod = (SourceField) iModelElement;
+ if (sourceMethod.getDeclaringType() != null
+ && PHPFlags.isTrait(sourceMethod
+ .getDeclaringType()
+ .getFlags())) {
+ highlight(var);
+ break;
+ }
+ }
+ }
+ }
+ } catch (ModelException e) {
+ }
+ if (!processed) {
+ // highlight(var);
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void endVisit(FieldAccess fieldAccess) {
+ if (!isMethod()) {
+ visitField--;
+ }
+ }
+
+ @Override
+ public void endVisit(Program program) {
+ if (!isMethod()) {
+ if (visitField < 0) {
+ throw new IllegalStateException("visitField is negative: "
+ + visitField);
+ }
+ }
+ }
+
+ @Override
+ public boolean visit(MethodDeclaration classMethodDeclaration) {
+ if (isMethod()) {
+ if (classMethodDeclaration.getParent().getParent() instanceof TraitDeclaration) {
+ Identifier functionName = classMethodDeclaration
+ .getFunction().getFunctionName();
+ highlight(functionName);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean visit(SingleFieldDeclaration fieldDecl) {
+ if (!isMethod()) {
+ ClassDeclaration cd = null;
+ ASTNode parent = fieldDecl.getParent();
+ while (parent != null) {
+ if (parent instanceof ClassDeclaration) {
+ cd = (ClassDeclaration) parent;
+ break;
+ }
+ parent = parent.getParent();
+ }
+ if ((cd instanceof TraitDeclaration)) {
+ highlight(fieldDecl.getName());
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Mark foo() on: $a->foo();
+ */
+ public boolean visit(MethodInvocation methodInvocation) {
+ if (isMethod()) {
+ checkDispatch(methodInvocation.getMethod().getFunctionName()
+ .getName());
+ }
+ return true;
+ }
+
+ /**
+ * @param dispatch
+ * @throws RuntimeException
+ */
+ private void checkDispatch(ASTNode node) {
+ if (node.getType() == ASTNode.IDENTIFIER) {
+ // ((Identifier)node).resolveBinding()
+ IModelElement[] elements = null;
+ boolean processed = false;
+ try {
+ elements = (getSourceModule()).codeSelect(node.getStart(),
+ node.getLength());
+ if (elements != null && elements.length > 0) {
+ processed = true;
+ for (IModelElement iModelElement : elements) {
+ if (iModelElement instanceof SourceMethod) {
+ SourceMethod sourceMethod = (SourceMethod) iModelElement;
+ if (sourceMethod.getDeclaringType() != null
+ && PHPFlags.isTrait(sourceMethod
+ .getDeclaringType().getFlags())) {
+ highlight(node);
+ break;
+ }
+ }
+ }
+ }
+ } catch (ModelException e) {
+ }
+ if (!processed) {
+ // highlight(node);
+ }
+
+ }
+ if (node.getType() == ASTNode.VARIABLE) {
+ Variable id = (Variable) node;
+ checkDispatch(id.getName());
+ }
+ }
+
+ public boolean visit(TraitUseStatement node) {
+ ISourceModule sourceModule = getSourceModule();
+ ModuleDeclaration moduleDeclaration = SourceParserUtil
+ .getModuleDeclaration(sourceModule, null);
+ FileContext context = new FileContext(sourceModule,
+ moduleDeclaration, node.getStart());
+ List<TraitStatement> tsList = node.getTsList();
+ for (TraitStatement traitStatement : tsList) {
+ if (traitStatement instanceof TraitAliasStatement) {
+ TraitAliasStatement statement = (TraitAliasStatement) traitStatement;
+ if (statement.getAlias().getTraitMethod() instanceof FullyQualifiedTraitMethodReference) {
+ FullyQualifiedTraitMethodReference reference = (FullyQualifiedTraitMethodReference) statement
+ .getAlias().getTraitMethod();
+
+ IEvaluatedType type = PHPClassType.fromTraitName(
+ PHPModelUtils.getFullName(reference
+ .getClassName()), sourceModule,
+ traitStatement.getStart());
+ IType[] modelElements = PHPTypeInferenceUtils
+ .getModelElements(type, context,
+ traitStatement.getStart());
+ if (modelElements != null && modelElements.length > 0) {
+ for (IType iType : modelElements) {
+ boolean shouldBreak = false;
+ try {
+ IModelElement[] children = iType
+ .getChildren();
+ for (IModelElement iModelElement : children) {
+ if (iModelElement.getElementName()
+ .equals(reference
+ .getFunctionName()
+ .getName())) {
+ if ((iModelElement instanceof IMethod)
+ && isMethod()) {
+ highlight(reference
+ .getFunctionName());
+ } else if (!(iModelElement instanceof IMethod)
+ && !isMethod()) {
+ highlight(reference
+ .getFunctionName());
+ }
+ shouldBreak = true;
+ break;
+ }
+ }
+ } catch (ModelException e) {
+ e.printStackTrace();
+ }
+ if (shouldBreak) {
+ break;
+ }
+ }
+ }
+ } else {
+ Identifier method = (Identifier) statement.getAlias()
+ .getTraitMethod();
+ List<NamespaceName> traitList = node.getTraitList();
+ for (NamespaceName namespaceName : traitList) {
+ boolean shouldBreak = false;
+ IEvaluatedType type = PHPClassType.fromTraitName(
+ PHPModelUtils.getFullName(namespaceName),
+ sourceModule, traitStatement.getStart());
+ IType[] modelElements = PHPTypeInferenceUtils
+ .getModelElements(type, context,
+ traitStatement.getStart());
+ if (modelElements != null
+ && modelElements.length > 0) {
+ for (IType iType : modelElements) {
+ try {
+ IModelElement[] children = iType
+ .getChildren();
+ for (IModelElement iModelElement : children) {
+ if (iModelElement.getElementName()
+ .equals(method.getName())) {
+ if ((iModelElement instanceof IMethod)
+ && isMethod()) {
+ highlight(method);
+ } else if (!(iModelElement instanceof IMethod)
+ && !isMethod()) {
+ highlight(method);
+ }
+ shouldBreak = true;
+ break;
+ }
+ }
+ } catch (ModelException e) {
+ e.printStackTrace();
+ }
+ if (shouldBreak) {
+ break;
+ }
+ }
+ }
+ if (shouldBreak) {
+ break;
+ }
+ }
+ }
+
+ } else if (traitStatement instanceof TraitPrecedenceStatement) {
+ TraitPrecedenceStatement statement = (TraitPrecedenceStatement) traitStatement;
+ FullyQualifiedTraitMethodReference reference = statement
+ .getPrecedence().getMethodReference();
+
+ IEvaluatedType type = PHPClassType
+ .fromTraitName(PHPModelUtils.getFullName(reference
+ .getClassName()), sourceModule,
+ traitStatement.getStart());
+ IType[] modelElements = PHPTypeInferenceUtils
+ .getModelElements(type, context,
+ traitStatement.getStart());
+ if (modelElements != null && modelElements.length > 0) {
+ for (IType iType : modelElements) {
+ boolean shouldBreak = false;
+ try {
+ IModelElement[] children = iType.getChildren();
+ for (IModelElement iModelElement : children) {
+ if (iModelElement.getElementName().equals(
+ reference.getFunctionName()
+ .getName())) {
+ if ((iModelElement instanceof IMethod)
+ && isMethod()) {
+ highlight(reference
+ .getFunctionName());
+ } else if (!(iModelElement instanceof IMethod)
+ && !isMethod()) {
+ highlight(reference
+ .getFunctionName());
+ }
+ shouldBreak = true;
+ break;
+ }
+ }
+ } catch (ModelException e) {
+ e.printStackTrace();
+ }
+ if (shouldBreak) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+ }
+
+ @Override
+ public AbstractSemanticApply getSemanticApply() {
+ return new TraitMemberApply();
+ }
+
+ @Override
+ public void initDefaultPreferences() {
+ getStyle().setEnabledByDefault(false).setDefaultTextColor(0, 80, 50);
+ }
+
+ // public String getDisplayName() {
+ // return "Traits";
+ // }
+
+ protected abstract boolean isMethod();
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitMethodHighlighting.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitMethodHighlighting.java
new file mode 100644
index 0000000..78f9413
--- /dev/null
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitMethodHighlighting.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Zend Corporation and IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * William Candillon {wcandillon@gmail.com} - Initial implementation
+ *******************************************************************************/
+package org.eclipse.php.internal.ui.editor.highlighters;
+
+public class TraitMethodHighlighting extends TraitMemberHighlighting {
+
+ public String getDisplayName() {
+ return "Trait methods";
+ }
+
+ protected boolean isMethod() {
+ return true;
+ }
+} \ No newline at end of file