Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2019-11-03 06:28:51 -0500
committerDawid Pakuła2019-11-03 06:28:51 -0500
commit423e813980b3dcbfbda130b910e4a6966f5fa1a8 (patch)
tree03240869ad128bd4d508f3ef359094bea42fa310
parent8739136334b7166ad4edda22fc0a262d8c20c482 (diff)
downloadorg.eclipse.pdt-423e813980b3dcbfbda130b910e4a6966f5fa1a8.tar.gz
org.eclipse.pdt-423e813980b3dcbfbda130b910e4a6966f5fa1a8.tar.xz
org.eclipse.pdt-423e813980b3dcbfbda130b910e4a6966f5fa1a8.zip
Bug 530721 - Reduce code assist complexity
Switch to DLTK CompletionHoverControlCreator Change-Id: Ic3a205b6f335f40a0ae939b11fa528a97bb9fc9b Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposal.java30
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPOverrideCompletionProposal.java29
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/hover/BrowserInformationControl2.java63
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/hover/CompletionHoverControlCreator.java102
4 files changed, 2 insertions, 222 deletions
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 d8528f15a..b860a27be 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
@@ -20,14 +20,9 @@ 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.ui.PreferenceConstants;
import org.eclipse.dltk.ui.text.ScriptTextTools;
import org.eclipse.dltk.ui.text.completion.ScriptCompletionProposal;
-import org.eclipse.jface.internal.text.html.BrowserInformationControl;
-import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.php.core.compiler.ast.nodes.NamespaceReference;
@@ -37,17 +32,10 @@ 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.php.internal.ui.text.hover.CompletionHoverControlCreator;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
public class PHPCompletionProposal extends ScriptCompletionProposal implements IPHPCompletionProposalExtension {
- /**
- * The control creator.
- */
- private IInformationControlCreator fCreator;
-
public PHPCompletionProposal(String replacementString, int replacementOffset, int replacementLength,
Supplier<Image> image, StyledString displayString, int relevance) {
super(replacementString, replacementOffset, replacementLength, image, displayString, relevance, false);
@@ -192,24 +180,6 @@ public class PHPCompletionProposal extends ScriptCompletionProposal implements I
}
@Override
- public IInformationControlCreator getInformationControlCreator() {
- if (fCreator == null) {
- fCreator = new CompletionHoverControlCreator(new IInformationControlCreator() {
- @Override
- public IInformationControl createInformationControl(Shell parent) {
- if (BrowserInformationControl.isAvailable(parent)) {
- return new BrowserInformationControl(parent, PreferenceConstants.APPEARANCE_DOCUMENTATION_FONT,
- true);
- } else {
- return new DefaultInformationControl(parent, true);
- }
- }
- }, true);
- }
- return fCreator;
- }
-
- @Override
public Object getExtraInfo() {
return ProposalExtraInfo.DEFAULT;
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPOverrideCompletionProposal.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPOverrideCompletionProposal.java
index dbbedd2ed..557cbea62 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPOverrideCompletionProposal.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPOverrideCompletionProposal.java
@@ -15,11 +15,10 @@ package org.eclipse.php.internal.ui.editor.contentassist;
import org.eclipse.core.runtime.Platform;
import org.eclipse.dltk.core.*;
-import org.eclipse.dltk.ui.PreferenceConstants;
import org.eclipse.dltk.ui.text.ScriptTextTools;
import org.eclipse.dltk.ui.text.completion.ScriptOverrideCompletionProposal;
-import org.eclipse.jface.internal.text.html.BrowserInformationControl;
-import org.eclipse.jface.text.*;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.contentassist.ContextInformation;
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension4;
@@ -30,15 +29,9 @@ import org.eclipse.php.core.compiler.ast.nodes.NamespaceReference;
import org.eclipse.php.internal.core.PHPCoreConstants;
import org.eclipse.php.internal.core.PHPCorePlugin;
import org.eclipse.php.internal.ui.PHPUiPlugin;
-import org.eclipse.php.internal.ui.text.hover.CompletionHoverControlCreator;
-import org.eclipse.swt.widgets.Shell;
public class PHPOverrideCompletionProposal extends ScriptOverrideCompletionProposal
implements ICompletionProposalExtension4 {
- /**
- * The control creator.
- */
- private IInformationControlCreator fCreator;
public PHPOverrideCompletionProposal(IScriptProject jproject, ISourceModule cu, String methodName,
String[] paramTypes, int start, int length, StyledString displayName, String completionProposal) {
@@ -183,22 +176,4 @@ public class PHPOverrideCompletionProposal extends ScriptOverrideCompletionPropo
return PHPUiPlugin.getDefault().getTextTools();
}
- @Override
- public IInformationControlCreator getInformationControlCreator() {
- if (fCreator == null) {
- fCreator = new CompletionHoverControlCreator(new IInformationControlCreator() {
- @Override
- public IInformationControl createInformationControl(Shell parent) {
- if (BrowserInformationControl.isAvailable(parent)) {
- return new BrowserInformationControl(parent, PreferenceConstants.APPEARANCE_DOCUMENTATION_FONT,
- true);
- } else {
- return new DefaultInformationControl(parent, true);
- }
- }
- }, true);
- }
- return fCreator;
- }
-
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/hover/BrowserInformationControl2.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/hover/BrowserInformationControl2.java
deleted file mode 100644
index 4fd132d82..000000000
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/hover/BrowserInformationControl2.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 IBM Corporation and others.
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Zend Technologies
- *******************************************************************************/
-package org.eclipse.php.internal.ui.text.hover;
-
-import org.eclipse.dltk.internal.ui.BrowserInformationControl;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IInformationControlExtension4;
-import org.eclipse.jface.text.IInformationControlExtension5;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @deprecated
- */
-@Deprecated
-public class BrowserInformationControl2 extends BrowserInformationControl
- implements IInformationControlExtension4, IInformationControlExtension5 {
- public BrowserInformationControl2(Shell parent, int shellStyle, int style, String statusFieldText) {
- super(parent, JFaceResources.DIALOG_FONT, statusFieldText);
- }
-
- @Override
- public Point computeSizeConstraints(int widthInChars, int heightInChars) {
- return null;
- }
-
- @Override
- public boolean containsControl(Control control) {
- do {
- if (control == getShell()) {
- return true;
- }
- if (control instanceof Shell) {
- return false;
- }
- control = control.getParent();
- } while (control != null);
- return false;
- }
-
- @Override
- public IInformationControlCreator getInformationPresenterControlCreator() {
- return null;
- }
-
- @Override
- public boolean isVisible() {
- return getShell() != null && !getShell().isDisposed() && getShell().isVisible();
- }
-}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/hover/CompletionHoverControlCreator.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/hover/CompletionHoverControlCreator.java
deleted file mode 100644
index 035f75bbe..000000000
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/hover/CompletionHoverControlCreator.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 IBM Corporation and others.
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Zend Technologies
- *******************************************************************************/
-package org.eclipse.php.internal.ui.text.hover;
-
-import org.eclipse.dltk.internal.ui.BrowserInformationControl;
-import org.eclipse.dltk.ui.DLTKUIPlugin;
-import org.eclipse.jface.text.*;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.editors.text.EditorsUI;
-
-/**
- * @deprecated
- */
-@Deprecated
-public final class CompletionHoverControlCreator extends AbstractReusableInformationControlCreator {
- /**
- * The information presenter control creator.
- */
- private final IInformationControlCreator fInformationPresenterControlCreator;
- /**
- * <code>true</code> to use the additional info affordance, <code>false</code>
- * to use the hover affordance.
- */
- private final boolean fAdditionalInfoAffordance;
-
- /**
- * @param informationPresenterControlCreator
- * control creator for enriched hover
- */
- public CompletionHoverControlCreator(IInformationControlCreator informationPresenterControlCreator) {
- this(informationPresenterControlCreator, false);
- }
-
- /**
- * @param informationPresenterControlCreator
- * control creator for enriched hover
- * @param additionalInfoAffordance
- * <code>true</code> to use the additional info affordance,
- * <code>false</code> to use the hover affordance
- */
- public CompletionHoverControlCreator(IInformationControlCreator informationPresenterControlCreator,
- boolean additionalInfoAffordance) {
- fInformationPresenterControlCreator = informationPresenterControlCreator;
- fAdditionalInfoAffordance = additionalInfoAffordance;
- }
-
- /*
- * @seeorg.eclipse.jdt.internal.ui.text.java.hover.
- * AbstractReusableInformationControlCreator
- * #doCreateInformationControl(org.eclipse.swt.widgets.Shell)
- */
- @Override
- public IInformationControl doCreateInformationControl(Shell parent) {
- String tooltipAffordanceString = fAdditionalInfoAffordance ? DLTKUIPlugin.getAdditionalInfoAffordanceString()
- : EditorsUI.getTooltipAffordanceString();
- if (BrowserInformationControl.isAvailable(parent)) {
- BrowserInformationControl2 iControl = new BrowserInformationControl2(parent, SWT.TOOL | SWT.NO_TRIM,
- SWT.NONE, tooltipAffordanceString) {
- @Override
- public IInformationControlCreator getInformationPresenterControlCreator() {
- return fInformationPresenterControlCreator;
- }
- };
- return iControl;
- } else {
- return new DefaultInformationControl(parent, tooltipAffordanceString);
- }
- }
-
- /*
- * @seeorg.eclipse.jdt.internal.ui.text.java.hover.
- * AbstractReusableInformationControlCreator
- * #canReuse(org.eclipse.jface.text.IInformationControl)
- */
- @Override
- public boolean canReuse(IInformationControl control) {
- if (!super.canReuse(control)) {
- return false;
- }
-
- if (control instanceof IInformationControlExtension4) {
- String tooltipAffordanceString = fAdditionalInfoAffordance
- ? DLTKUIPlugin.getAdditionalInfoAffordanceString()
- : EditorsUI.getTooltipAffordanceString();
- ((IInformationControlExtension4) control).setStatusText(tooltipAffordanceString);
- }
-
- return true;
- }
-}

Back to the top