aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2012-08-14 00:24:34 (EDT)
committerzzhongwei2012-08-14 00:24:34 (EDT)
commit060b5e81d8cc5aab75d744d187eedf66c91a7b3d (patch)
tree8b223214f84840b73477b9c6d984af1b51c4fcf3
parentb8645c8a50cb31f065bf18662de526f631452db0 (diff)
downloadorg.eclipse.pdt-060b5e81d8cc5aab75d744d187eedf66c91a7b3d.zip
org.eclipse.pdt-060b5e81d8cc5aab75d744d187eedf66c91a7b3d.tar.gz
org.eclipse.pdt-060b5e81d8cc5aab75d744d187eedf66c91a7b3d.tar.bz2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=379780 - no syntax
coloring for php 5.4 seems a big hole.. How is user going to see Traits without colors. Now merge the trait highlighting and class highlighting
-rw-r--r--plugins/org.eclipse.php.ui/plugin.xml23
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/ClassHighlighting.java32
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/FieldHighlighting.java153
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/MethodHighlighting.java147
-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
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/PHPSyntaxColoringPage.java51
9 files changed, 307 insertions, 575 deletions
diff --git a/plugins/org.eclipse.php.ui/plugin.xml b/plugins/org.eclipse.php.ui/plugin.xml
index 8cfd560..9c68964 100644
--- a/plugins/org.eclipse.php.ui/plugin.xml
+++ b/plugins/org.eclipse.php.ui/plugin.xml
@@ -1947,29 +1947,6 @@
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"
name="%extension.name.0"
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 6d1c686..cae4fdf 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,9 +22,6 @@ 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) {
@@ -57,6 +54,35 @@ public class ClassHighlighting extends AbstractSemanticHighlighting {
return true;
}
+ 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);
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 0f0c39a..891e588 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,11 +10,17 @@
*******************************************************************************/
package org.eclipse.php.internal.ui.editor.highlighters;
-import org.eclipse.dltk.core.IModelElement;
-import org.eclipse.dltk.core.ModelException;
+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.php.core.compiler.PHPFlags;
+import org.eclipse.dltk.ti.types.IEvaluatedType;
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;
@@ -35,9 +41,7 @@ public class FieldHighlighting extends AbstractSemanticHighlighting {
}
parent = parent.getParent();
}
- if (!(cd instanceof TraitDeclaration)) {
- highlight(fieldDecl.getName());
- }
+ highlight(fieldDecl.getName());
return true;
}
@@ -70,13 +74,8 @@ public class FieldHighlighting extends AbstractSemanticHighlighting {
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;
- }
+ highlight(var);
+ break;
}
}
}
@@ -101,6 +100,134 @@ public class FieldHighlighting extends AbstractSemanticHighlighting {
+ visitField);
}
}
+
+ 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())
+ && (iModelElement instanceof IField)) {
+ 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())
+ && (iModelElement instanceof IField)) {
+ 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())
+ && ((iModelElement instanceof IField))) {
+ highlight(reference.getFunctionName());
+ shouldBreak = true;
+ break;
+ }
+ }
+ } catch (ModelException e) {
+ e.printStackTrace();
+ }
+ if (shouldBreak) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
}
@Override
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 f101467..e26ba49 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,11 +10,17 @@
*******************************************************************************/
package org.eclipse.php.internal.ui.editor.highlighters;
-import org.eclipse.dltk.core.IModelElement;
-import org.eclipse.dltk.core.ModelException;
+import java.util.List;
+
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.core.*;
import org.eclipse.dltk.internal.core.SourceMethod;
-import org.eclipse.php.core.compiler.PHPFlags;
+import org.eclipse.dltk.ti.types.IEvaluatedType;
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;
@@ -54,12 +60,8 @@ public class MethodHighlighting extends AbstractSemanticHighlighting {
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);
- }
+ highlight(node);
+ break;
}
}
}
@@ -76,6 +78,133 @@ public class MethodHighlighting extends AbstractSemanticHighlighting {
}
}
+ 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())
+ && (iModelElement instanceof IMethod)) {
+ 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())
+ && (iModelElement instanceof IMethod)) {
+ 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())
+ && (iModelElement instanceof IMethod)) {
+ highlight(reference.getFunctionName());
+ shouldBreak = true;
+ break;
+ }
+ }
+ } catch (ModelException e) {
+ e.printStackTrace();
+ }
+ if (shouldBreak) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
}
@Override
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
deleted file mode 100644
index 7b5a75e..0000000
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitFieldHighlighting.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * 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
deleted file mode 100644
index dfce2ab..0000000
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitHighlighting.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * 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
deleted file mode 100644
index 02fe229..0000000
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitMemberHighlighting.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*******************************************************************************
- * 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
deleted file mode 100644
index 78f9413..0000000
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/highlighters/TraitMethodHighlighting.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * 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
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/PHPSyntaxColoringPage.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/PHPSyntaxColoringPage.java
index 16dfd3f..2fe59e9 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/PHPSyntaxColoringPage.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/preferences/PHPSyntaxColoringPage.java
@@ -1344,57 +1344,6 @@ public final class PHPSyntaxColoringPage extends PreferencePage implements
return DeprecatedHighlighting.class.getName();
}
});
- highlightings.add(new TraitHighlighting() {
- @Override
- protected Program getProgram(
- IStructuredDocumentRegion region) {
- return program;
- }
-
- @Override
- public ISourceModule getSourceModule() {
- return sourceModule;
- }
-
- @Override
- public String getPreferenceKey() {
- return TraitHighlighting.class.getName();
- }
- });
- highlightings.add(new TraitMethodHighlighting() {
- @Override
- protected Program getProgram(
- IStructuredDocumentRegion region) {
- return program;
- }
-
- @Override
- public ISourceModule getSourceModule() {
- return sourceModule;
- }
-
- @Override
- public String getPreferenceKey() {
- return TraitMethodHighlighting.class.getName();
- }
- });
- highlightings.add(new TraitFieldHighlighting() {
- @Override
- protected Program getProgram(
- IStructuredDocumentRegion region) {
- return program;
- }
-
- @Override
- public ISourceModule getSourceModule() {
- return sourceModule;
- }
-
- @Override
- public String getPreferenceKey() {
- return TraitFieldHighlighting.class.getName();
- }
- });
Collections.sort(highlightings);