aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-03-03 08:45:10 (EST)
committerzzhongwei2013-03-06 00:14:52 (EST)
commit295191980da557682d3bcb9b2890214694526168 (patch)
tree28c3d30817295b7c7797ba816dc35082302438da
parenta6c228141b3b64392b7c8ac9b8d213d66f98c954 (diff)
downloadorg.eclipse.pdt-295191980da557682d3bcb9b2890214694526168.zip
org.eclipse.pdt-295191980da557682d3bcb9b2890214694526168.tar.gz
org.eclipse.pdt-295191980da557682d3bcb9b2890214694526168.tar.bz2
401766: array key replace is missing last char + hint issue
https://bugs.eclipse.org/bugs/show_bug.cgi?id=401766
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ProposalExtraInfo.java15
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CatchTypeStrategy.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CompletionStrategyFactory.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/FunctionParameterTypeStrategy.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java23
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/InstanceOfStrategy.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/NamespaceDocTypesCompositeStrategy.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/NonFinalClassesStrategy.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/PHPDocReturnTypeStrategy.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/UseNameStrategy.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/UseTraitNameStrategy.java2
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposal.java5
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java5
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/UseStatementInjector.java13
14 files changed, 64 insertions, 15 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ProposalExtraInfo.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ProposalExtraInfo.java
index ab99711..9865beb 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ProposalExtraInfo.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ProposalExtraInfo.java
@@ -1,6 +1,7 @@
package org.eclipse.php.internal.core.codeassist;
public final class ProposalExtraInfo {
+ public static final int DEFAULT = 1;
public static final int TYPE_ONLY = 1 << 1;
public static final int MAGIC_METHOD = 1 << 2;
// this is for namespace
@@ -8,6 +9,7 @@ public final class ProposalExtraInfo {
// the stub is a type of class/method/field,which does not exist yet
public static final int STUB = 1 << 4;
public static final int METHOD_ONLY = 1 << 5;
+ public static final int NO_INSERT_NAMESPACE = 1 << 6;
public static boolean isTypeOnly(int flags) {
return (flags & TYPE_ONLY) != 0;
@@ -56,4 +58,17 @@ public final class ProposalExtraInfo {
return false;
}
}
+
+ public static boolean isNoInsert(int flags) {
+ return (flags & NO_INSERT_NAMESPACE) != 0;
+ }
+
+ public static boolean isNoInsert(Object flags) {
+ if (flags instanceof Integer) {
+ return isNoInsert(((Integer) flags).intValue());
+ } else {
+ return false;
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CatchTypeStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CatchTypeStrategy.java
index 098035e..7fc589f 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CatchTypeStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/CatchTypeStrategy.java
@@ -34,7 +34,7 @@ public class CatchTypeStrategy extends GlobalTypesStrategy {
public String getSuffix(AbstractCompletionContext abstractContext) {
return " "; //$NON-NLS-1$
}
- protected Object getExtraInfo() {
+ protected int getExtraInfo() {
return ProposalExtraInfo.TYPE_ONLY;
}
}
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 1571fdf..bd32922 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
@@ -103,7 +103,7 @@ public class CompletionStrategyFactory implements ICompletionStrategyFactory {
return new ICompletionStrategy[] { new GlobalClassesStrategy(
context) {
@Override
- protected Object getExtraInfo() {
+ protected int getExtraInfo() {
return ProposalExtraInfo.TYPE_ONLY;
}
} };
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/FunctionParameterTypeStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/FunctionParameterTypeStrategy.java
index bc5fef5..af3682e 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/FunctionParameterTypeStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/FunctionParameterTypeStrategy.java
@@ -29,7 +29,7 @@ public class FunctionParameterTypeStrategy extends GlobalTypesStrategy {
public String getSuffix(AbstractCompletionContext abstractContext) {
return " "; //$NON-NLS-1$
}
- protected Object getExtraInfo() {
+ protected int getExtraInfo() {
return ProposalExtraInfo.TYPE_ONLY;
}
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java
index 4541a57..48f8703 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java
@@ -27,6 +27,7 @@ import org.eclipse.php.internal.core.PHPCorePlugin;
import org.eclipse.php.internal.core.codeassist.AliasType;
import org.eclipse.php.internal.core.codeassist.CodeAssistUtils;
import org.eclipse.php.internal.core.codeassist.ICompletionReporter;
+import org.eclipse.php.internal.core.codeassist.ProposalExtraInfo;
import org.eclipse.php.internal.core.codeassist.contexts.AbstractCompletionContext;
import org.eclipse.php.internal.core.codeassist.contexts.NamespaceMemberContext;
import org.eclipse.php.internal.core.compiler.ast.nodes.NamespaceReference;
@@ -83,13 +84,28 @@ public class GlobalTypesStrategy extends GlobalElementStrategy {
// now we compute type suffix in PHPCompletionProposalCollector
String suffix = "";//$NON-NLS-1$
String nsSuffix = getNSSuffix(abstractContext);
+ int extraInfo = getExtraInfo();
+ if ((abstractContext.getOffset() - abstractContext.getPrefix().length()
+ - 1 >= 0)
+ && (abstractContext.getDocument().getChar(
+ abstractContext.getOffset()
+ - abstractContext.getPrefix().length() - 1) == '\'' || abstractContext
+ .getDocument().getChar(
+ abstractContext.getOffset()
+ - abstractContext.getPrefix().length()
+ - 1) == '\"')) {
+ extraInfo = extraInfo | ProposalExtraInfo.NO_INSERT_NAMESPACE;
+ }
+ if ("namespace".equals(abstractContext.getPreviousWord(1))) {
+ extraInfo = extraInfo | ProposalExtraInfo.NO_INSERT_NAMESPACE;
+ }
for (IType type : types) {
try {
int flags = type.getFlags();
reporter.reportType(type,
PHPFlags.isNamespace(flags) ? nsSuffix : suffix,
- replacementRange, getExtraInfo());
+ replacementRange, extraInfo);
} catch (ModelException e) {
PHPCorePlugin.log(e);
}
@@ -394,8 +410,7 @@ public class GlobalTypesStrategy extends GlobalElementStrategy {
*
* @return
*/
- protected Object getExtraInfo() {
- // TODO Auto-generated method stub
- return null;
+ protected int getExtraInfo() {
+ return ProposalExtraInfo.DEFAULT;
}
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/InstanceOfStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/InstanceOfStrategy.java
index c304436..987e586 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/InstanceOfStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/InstanceOfStrategy.java
@@ -50,7 +50,7 @@ public class InstanceOfStrategy extends GlobalTypesStrategy {
return ""; //$NON-NLS-1$
}
- protected Object getExtraInfo() {
+ protected int getExtraInfo() {
return ProposalExtraInfo.TYPE_ONLY;
}
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/NamespaceDocTypesCompositeStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/NamespaceDocTypesCompositeStrategy.java
index ff402b6..dcb77dc 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/NamespaceDocTypesCompositeStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/NamespaceDocTypesCompositeStrategy.java
@@ -28,7 +28,7 @@ public class NamespaceDocTypesCompositeStrategy extends
if (concreteContext.isGlobal()) {
GlobalTypesStrategy strategy = new GlobalTypesStrategy(context) {
- protected Object getExtraInfo() {
+ protected int getExtraInfo() {
return ProposalExtraInfo.TYPE_ONLY;
}
};
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/NonFinalClassesStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/NonFinalClassesStrategy.java
index 583bb77..a06b458 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/NonFinalClassesStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/NonFinalClassesStrategy.java
@@ -46,7 +46,7 @@ public class NonFinalClassesStrategy extends GlobalClassesStrategy {
}
@Override
- protected Object getExtraInfo() {
+ protected int getExtraInfo() {
return ProposalExtraInfo.TYPE_ONLY;
}
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/PHPDocReturnTypeStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/PHPDocReturnTypeStrategy.java
index 60f287f..a29571a 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/PHPDocReturnTypeStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/PHPDocReturnTypeStrategy.java
@@ -56,7 +56,7 @@ public class PHPDocReturnTypeStrategy extends GlobalClassesStrategy {
}
@Override
- protected Object getExtraInfo() {
+ protected int getExtraInfo() {
return ProposalExtraInfo.TYPE_ONLY;
}
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/UseNameStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/UseNameStrategy.java
index d812ae1..e1b20d8 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/UseNameStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/UseNameStrategy.java
@@ -45,7 +45,7 @@ public class UseNameStrategy extends GlobalTypesStrategy {
}
@Override
- protected Object getExtraInfo() {
+ protected int getExtraInfo() {
return ProposalExtraInfo.TYPE_ONLY;
}
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/UseTraitNameStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/UseTraitNameStrategy.java
index 0bd5f76..1e45575 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/UseTraitNameStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/UseTraitNameStrategy.java
@@ -81,7 +81,7 @@ public class UseTraitNameStrategy extends GlobalTypesStrategy {
}
@Override
- protected Object getExtraInfo() {
+ protected int getExtraInfo() {
return ProposalExtraInfo.TYPE_ONLY;
}
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposal.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposal.java
index d81611d..da4e518 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposal.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposal.java
@@ -27,6 +27,7 @@ import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.php.internal.core.PHPCoreConstants;
import org.eclipse.php.internal.core.PHPCorePlugin;
+import org.eclipse.php.internal.core.codeassist.ProposalExtraInfo;
import org.eclipse.php.internal.core.codeassist.strategies.IncludeStatementStrategy;
import org.eclipse.php.internal.ui.PHPUiPlugin;
import org.eclipse.swt.graphics.Image;
@@ -181,4 +182,8 @@ public class PHPCompletionProposal extends ScriptCompletionProposal {
}
return fCreator;
}
+
+ public Object getExtraInfo() {
+ return ProposalExtraInfo.DEFAULT;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java
index b301136..8ed7788 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java
@@ -286,6 +286,11 @@ public class PHPCompletionProposalCollector extends
return DOUBLE_COLON.equals(nextWord) ? defaultResult
: DOUBLE_COLON;
}
+
+ @Override
+ public Object getExtraInfo() {
+ return typeProposal.getExtraInfo();
+ }
};
scriptProposal.setRelevance(computeRelevance(typeProposal));
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/UseStatementInjector.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/UseStatementInjector.java
index d24fb34..7171842 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/UseStatementInjector.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/UseStatementInjector.java
@@ -33,6 +33,7 @@ import org.eclipse.php.internal.core.PHPCorePlugin;
import org.eclipse.php.internal.core.PHPVersion;
import org.eclipse.php.internal.core.ast.nodes.*;
import org.eclipse.php.internal.core.codeassist.AliasType;
+import org.eclipse.php.internal.core.codeassist.ProposalExtraInfo;
import org.eclipse.php.internal.core.compiler.ast.nodes.NamespaceReference;
import org.eclipse.php.internal.core.compiler.ast.nodes.UsePart;
import org.eclipse.php.internal.core.compiler.ast.parser.ASTUtils;
@@ -218,12 +219,20 @@ public class UseStatementInjector {
if (modelElement.getElementType() == IModelElement.TYPE
&& PHPFlags.isNamespace(((IType) modelElement).getFlags())) {
+ if (proposal instanceof PHPCompletionProposal) {
+ PHPCompletionProposal phpCompletionProposal = (PHPCompletionProposal) proposal;
+ if (ProposalExtraInfo.isNoInsert(phpCompletionProposal
+ .getExtraInfo())) {
+ return offset;
+ }
+ }
if (offset - proposal.getReplacementLength() > 0) {
String prefix = document.get(
offset - proposal.getReplacementLength(),
proposal.getReplacementLength());
- String fullName = PHPModelUtils
- .getFullName((IType) modelElement);
+ String fullName = ((IType) modelElement).getElementName();
+ // String fullName = PHPModelUtils
+ // .getFullName((IType) modelElement);
if (fullName.startsWith(prefix)
&& prefix
.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) < 0) {