aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2012-10-11 02:57:22 (EDT)
committerzzhongwei2012-10-14 22:54:51 (EDT)
commit1158884edcf2352c6353ce3e68f22e80956b7026 (patch)
tree26aaeb74022eeae02b7c62e7ed6280a05021acdd
parent3a471601cbcc1448de8c6cfb87d9c6ab514101f2 (diff)
downloadorg.eclipse.pdt-1158884edcf2352c6353ce3e68f22e80956b7026.zip
org.eclipse.pdt-1158884edcf2352c6353ce3e68f22e80956b7026.tar.gz
org.eclipse.pdt-1158884edcf2352c6353ce3e68f22e80956b7026.tar.bz2
391631: Add 'as' and 'insteadof' options for CA for traits
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391631
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts/AbstractCompletionContext.java9
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java24
2 files changed, 28 insertions, 5 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts/AbstractCompletionContext.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts/AbstractCompletionContext.java
index 7d59297..743846a 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts/AbstractCompletionContext.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/contexts/AbstractCompletionContext.java
@@ -794,6 +794,15 @@ public abstract class AbstractCompletionContext implements ICompletionContext {
&& type2 == PHPRegionTypes.PHP_SEMICOLON) {
return TRAIT_KEYWORD;
}
+ } else if (types.size() == 4) {
+ String type = types.get(0);
+ String type1 = types.get(1);
+ String type2 = types.get(2);
+ if (type == PHPRegionTypes.PHP_STRING
+ && type1 == PHPRegionTypes.PHP_PAAMAYIM_NEKUDOTAYIM
+ && type2 == PHPRegionTypes.PHP_STRING) {
+ return TRAIT_KEYWORD;
+ }
}
return NONE;
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java
index c8518e0..625bca1 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java
@@ -151,8 +151,8 @@ public class CompletionStrategyFactory implements ICompletionStrategyFactory {
return new ICompletionStrategy[] { new MethodNameStrategy(context) };
}
if (contextClass == ClassStatementContext.class) {
- if (((ClassStatementContext) context).isInUseTraitStatement()) {
- int type = ((ClassStatementContext) context)
+ if (((AbstractCompletionContext) context).isInUseTraitStatement()) {
+ int type = ((AbstractCompletionContext) context)
.getUseTraitStatementContext();
if (type == AbstractCompletionContext.TRAIT_NAME) {
return new ICompletionStrategy[] { new InUseTraitStrategy(
@@ -203,9 +203,23 @@ public class CompletionStrategyFactory implements ICompletionStrategyFactory {
// }
if (contextClass == ClassStaticMemberContext.class
|| contextClass == ClassObjMemberContext.class) {
- return new ICompletionStrategy[] {
- new ClassFieldsStrategy(context),
- new ClassMethodsStrategy(context) };
+ if (((AbstractCompletionContext) context).isInUseTraitStatement()) {
+ int type = ((AbstractCompletionContext) context)
+ .getUseTraitStatementContext();
+ if (type == AbstractCompletionContext.TRAIT_NAME) {
+ return new ICompletionStrategy[] { new InUseTraitStrategy(
+ context) };
+ } else if (type == AbstractCompletionContext.TRAIT_KEYWORD) {
+ return new ICompletionStrategy[] { new InUseTraitKeywordStrategy(
+ context) };
+ } else {
+ return new ICompletionStrategy[] {};
+ }
+ } else {
+ return new ICompletionStrategy[] {
+ new ClassFieldsStrategy(context),
+ new ClassMethodsStrategy(context) };
+ }
}
if (contextClass == ClassDeclarationKeywordContext.class) {
return new ICompletionStrategy[] { new ClassDeclarationKeywordsStrategy(