aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-04-17 01:53:14 (EDT)
committerzzhongwei2013-04-17 01:53:14 (EDT)
commite7d689e229b71d2b5952afacec232d18822c3beb (patch)
treee2e85e42c9a0d02130e8f13702b28f9492bd442e
parentbbead23d01321ece057aec4608b8500dd6f0f475 (diff)
downloadorg.eclipse.pdt-e7d689e229b71d2b5952afacec232d18822c3beb.zip
org.eclipse.pdt-e7d689e229b71d2b5952afacec232d18822c3beb.tar.gz
org.eclipse.pdt-e7d689e229b71d2b5952afacec232d18822c3beb.tar.bz2
405844: Code assist for arrays closes without assisting
https://bugs.eclipse.org/bugs/show_bug.cgi?id=405844
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/ArrayStringKeysStrategy.java11
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java46
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalLabelProvider.java10
3 files changed, 63 insertions, 4 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/ArrayStringKeysStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/ArrayStringKeysStrategy.java
index bcb63bd..2680dd0 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/ArrayStringKeysStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/ArrayStringKeysStrategy.java
@@ -23,6 +23,7 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.php.core.codeassist.ICompletionContext;
import org.eclipse.php.core.codeassist.IElementFilter;
import org.eclipse.php.internal.core.codeassist.ICompletionReporter;
+import org.eclipse.php.internal.core.codeassist.ProposalExtraInfo;
import org.eclipse.php.internal.core.codeassist.contexts.ArrayKeyContext;
import org.eclipse.php.internal.core.compiler.ast.nodes.*;
import org.eclipse.php.internal.core.compiler.ast.parser.ASTUtils;
@@ -66,15 +67,17 @@ public class ArrayStringKeysStrategy extends AbstractCompletionStrategy {
ArrayKeyFinder finder = new ArrayKeyFinder(prefix);
moduleDeclaration.traverse(finder);
Set<String> names = finder.getNames();
+ int extraObject = ProposalExtraInfo.DEFAULT;
+ if (!arrayContext.hasQuotes()) {
+ extraObject |= ProposalExtraInfo.ADD_QUOTES;
+ }
for (String name : names) {
if (!requestor.isContextInformationMode()) {
- if (!arrayContext.hasQuotes()) {
- name = "\'" + name + "\'";
- }
reporter.reportField(new FakeField(
(ModelElement) arrayContext.getSourceModule(),
- name, 0, 0), "", replaceRange, false); // NON-NLS-1
+ name, 0, 0), "", replaceRange, false, 0,
+ extraObject); // NON-NLS-1
}
}
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 0876e2d..0ac8ce6 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
@@ -319,6 +319,52 @@ public class PHPCompletionProposalCollector extends
}
+ protected IScriptCompletionProposal createFieldProposal(
+ final CompletionProposal proposal) {
+ String completion = String.valueOf(proposal.getCompletion());
+ int start = proposal.getReplaceStart();
+ int length = getLength(proposal);
+ String label = ((PHPCompletionProposalLabelProvider) getLabelProvider())
+ .createFieldProposalLabel(proposal);
+ Image image = getImage(((PHPCompletionProposalLabelProvider) getLabelProvider())
+ .createFieldImageDescriptor(proposal));
+ int relevance = computeRelevance(proposal);
+ // CompletionContext context = getContext();
+ // ScriptCompletionProposal scriptProposal =
+ // createScriptCompletionProposal(
+ // completion, start, length, image, label, relevance, /*
+ // * context
+ // * .isInDoc
+ // * ()
+ // */false);
+ ScriptCompletionProposal scriptProposal = new PHPCompletionProposal(
+ completion, start, length, image, label, relevance) {
+ private boolean fReplacementStringComputed = false;
+
+ public String getReplacementString() {
+ if (!fReplacementStringComputed) {
+ String replacementString = super.getReplacementString();
+ if (ProposalExtraInfo.isAddQuote(proposal.getExtraInfo())) {
+ replacementString = "'" + replacementString + "'";
+ }
+ setReplacementString(replacementString);
+ }
+ fReplacementStringComputed = true;
+ return super.getReplacementString();
+ }
+
+ @Override
+ public Object getExtraInfo() {
+ return proposal.getExtraInfo();
+ }
+ };
+ if (getSourceModule().getScriptProject() != null)
+ scriptProposal.setProposalInfo(new FieldProposalInfo(
+ getSourceModule().getScriptProject(), proposal));
+ scriptProposal.setTriggerCharacters(getVarTrigger());
+ return scriptProposal;
+ }
+
public int getOffset() {
return offset;
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalLabelProvider.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalLabelProvider.java
index 79cc6b4..93faa70 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalLabelProvider.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalLabelProvider.java
@@ -149,4 +149,14 @@ public class PHPCompletionProposalLabelProvider extends
return super.createTypeImageDescriptor(proposal);
}
}
+
+ public String createFieldProposalLabel(CompletionProposal proposal) {
+ return super.createFieldProposalLabel(proposal);
+ }
+
+ @Override
+ public ImageDescriptor createFieldImageDescriptor(
+ CompletionProposal proposal) {
+ return super.createFieldImageDescriptor(proposal);
+ }
}