aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-03-13 06:23:15 (EDT)
committerzzhongwei2013-03-13 06:23:15 (EDT)
commit3aaaeabbe626c856827a99b941aadce61458dabf (patch)
treec18ce9d105066d8067252c5665b98ed796fcf924
parenta319c42a668002443a965898ae8a64891c00b032 (diff)
downloadorg.eclipse.pdt-3aaaeabbe626c856827a99b941aadce61458dabf.zip
org.eclipse.pdt-3aaaeabbe626c856827a99b941aadce61458dabf.tar.gz
org.eclipse.pdt-3aaaeabbe626c856827a99b941aadce61458dabf.tar.bz2
403139: [CA] show namespace classes in string
https://bugs.eclipse.org/bugs/show_bug.cgi?id=403139
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ICompletionReporter.java4
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPCompletionEngine.java9
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ProposalExtraInfo.java13
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java10
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposal.java9
-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.java14
7 files changed, 52 insertions, 12 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ICompletionReporter.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ICompletionReporter.java
index 754415f..ed7101f 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ICompletionReporter.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ICompletionReporter.java
@@ -156,4 +156,8 @@ public interface ICompletionReporter {
* @return
*/
public IModuleSource getModule();
+
+ public void reportField(IField field, String suffix,
+ SourceRange replaceRange, boolean removeDollar, int subRelevance,
+ Object extraInfo);
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPCompletionEngine.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPCompletionEngine.java
index bb154f2..22dc0cd 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPCompletionEngine.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPCompletionEngine.java
@@ -167,6 +167,13 @@ public class PHPCompletionEngine extends ScriptCompletionEngine implements
public void reportField(IField field, String suffix,
SourceRange replaceRange, boolean removeDollar, int subRelevance) {
+ reportField(field, suffix, replaceRange, removeDollar, subRelevance,
+ null);
+ }
+
+ public void reportField(IField field, String suffix,
+ SourceRange replaceRange, boolean removeDollar, int subRelevance,
+ Object extraInfo) {
if (processedFields.contains(field)) {
return;
}
@@ -195,7 +202,7 @@ public class PHPCompletionEngine extends ScriptCompletionEngine implements
completion = completion.substring(1);
}
proposal.setCompletion(completion);
-
+ proposal.setExtraInfo(extraInfo);
proposal.setModelElement(field);
proposal.setFlags(flags);
proposal.setRelevance(relevance);
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 9865beb..405494a 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
@@ -10,6 +10,7 @@ public final class ProposalExtraInfo {
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 final int CLASS_IN_NAMESPACE = 1 << 7;
public static boolean isTypeOnly(int flags) {
return (flags & TYPE_ONLY) != 0;
@@ -71,4 +72,16 @@ public final class ProposalExtraInfo {
}
}
+ public static boolean isClassInNamespace(int flags) {
+ return (flags & CLASS_IN_NAMESPACE) != 0;
+ }
+
+ public static boolean isClassInNamespace(Object flags) {
+ if (flags instanceof Integer) {
+ return isClassInNamespace(((Integer) flags).intValue());
+ } else {
+ return false;
+ }
+ }
+
}
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 8947a9e..ac474fe 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
@@ -120,9 +120,13 @@ public class GlobalTypesStrategy extends GlobalElementStrategy {
IType[] subTypes = type.getTypes();
for (IType subType : subTypes) {
int subFlags = type.getFlags();
- reporter.reportType(subType, PHPFlags
- .isNamespace(subFlags) ? nsSuffix : suffix,
- replacementRange, extraInfo);
+ reporter.reportType(
+ subType,
+ PHPFlags.isNamespace(subFlags) ? nsSuffix
+ : suffix,
+ replacementRange,
+ extraInfo
+ | ProposalExtraInfo.CLASS_IN_NAMESPACE);
}
}
}
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 da4e518..2e8d14d 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
@@ -15,6 +15,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.IType;
import org.eclipse.dltk.internal.ui.text.hover.CompletionHoverControlCreator;
import org.eclipse.dltk.ui.PreferenceConstants;
import org.eclipse.dltk.ui.text.ScriptTextTools;
@@ -29,6 +30,7 @@ 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.core.typeinference.PHPModelUtils;
import org.eclipse.php.internal.ui.PHPUiPlugin;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
@@ -61,8 +63,13 @@ public class PHPCompletionProposal extends ScriptCompletionProposal {
word = word.substring(1);
}
boolean result = isPrefix(prefix, word);
+ if (!result && ProposalExtraInfo.isClassInNamespace(getExtraInfo())
+ && (getModelElement() instanceof IType)) {
+ IType type = (IType) getModelElement();
+ result = isPrefix(prefix, PHPModelUtils.getFullName(type));
+ }
// int index = word.indexOf(" - ");
- // if (!result && index >= 0 && prefix.indexOf('\\') >= 0) {
+ // if (!result && index >= 0) {
// StringBuffer sb = new StringBuffer();
// sb.append(word.substring(index + " - ".length()));
// sb.append('\\');
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 8ed7788..9109d2a 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
@@ -235,6 +235,11 @@ public class PHPCompletionProposalCollector extends
fReplacementStringComputed = true;
IType type = (IType) typeProposal.getModelElement();
+ if (ProposalExtraInfo.isClassInNamespace(typeProposal
+ .getExtraInfo())) {
+ return PHPModelUtils.getFullName(type);
+ }
+
String prefix = "";
try {
int flags = type.getFlags();
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 7171842..6ebf672 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
@@ -209,6 +209,13 @@ public class UseStatementInjector {
}
if (modelElement == null)
return offset;
+ if (proposal instanceof PHPCompletionProposal) {
+ PHPCompletionProposal phpCompletionProposal = (PHPCompletionProposal) proposal;
+ if (ProposalExtraInfo.isNoInsert(phpCompletionProposal
+ .getExtraInfo())) {
+ return offset;
+ }
+ }
try {
// quanlified namespace should return offset directly
if (offset - proposal.getReplacementLength() > 0
@@ -219,13 +226,6 @@ 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(),