Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
import org.eclipse.jface.text.IInformationControlExtension2;
import org.eclipse.jface.text.IInformationControlExtension5;
import org.eclipse.jface.text.ITextHover;
import org.eclipse.lsp4e.operations.hover.FocusableBrowserInformationControl;

Check warning on line 33 in bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/CompositeInformationControl.java

View check run for this annotation

Jenkins - Eclipse Platform / Compiler

Import

ERROR: The import org.eclipse.lsp4e cannot be resolved
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -105,9 +108,21 @@
if (children.isEmpty()) {
continue;
}
for (Control control : children) {
control.setParent(parent);
}
if (abstractInformationControl instanceof FocusableBrowserInformationControl browserControl) {

Check warning on line 111 in bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/CompositeInformationControl.java

View check run for this annotation

Jenkins - Eclipse Platform / Compiler

Type

ERROR: FocusableBrowserInformationControl cannot be resolved to a type
for (Control control : ((Composite) browserControl.getShell().getChildren()[0]).getChildren()) {
if (control instanceof Browser browser) {
browser.addProgressListener(ProgressListener.completedAdapter(p -> {
if (!isHtmlEmpty(browser.getText())) {
reassignParent(parent, children);
getShell().layout(true, true);
getShell().setSize(computeSizeHint());
}
}));
}
}
} else {
reassignParent(parent, children);
}
controls.put(hoverControlCreator.getKey(), abstractInformationControl);
} else {
ILog.of(CompositeInformationControl.class).warn(
Expand All @@ -118,6 +133,35 @@
}
}

/**
* if the html is empty.
*
* @param html
* the html
* @return {@code true} if the html is empty, {@code false} otherwise
*/
@SuppressWarnings("nls")
public boolean isHtmlEmpty(final String html) {

Check warning on line 144 in bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/CompositeInformationControl.java

View check run for this annotation

Jenkins - Eclipse Platform / Compiler

Code Style

LOW: The method isHtmlEmpty(String) from the type CompositeInformationControl can potentially be declared as static
if (html == null || html.isEmpty()) {
return true;
}

// Remove all HTML tags
String plainText = html.replaceAll("<[^>]*>", "").trim();

Check warning on line 150 in bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/CompositeInformationControl.java

View check run for this annotation

Jenkins - Eclipse Platform / Compiler

NLS

ERROR: $ Non-externalized string literal; it should be followed by //$NON-NLS-

Check warning on line 150 in bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/CompositeInformationControl.java

View check run for this annotation

Jenkins - Eclipse Platform / Compiler

NLS

ERROR: $ Non-externalized string literal; it should be followed by //$NON-NLS-

// Check if what's left is actually content
// We also decode common entities like &nbsp; which can trick empty checks
plainText = plainText.replace("&nbsp;", " ").trim();

Check warning on line 154 in bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/CompositeInformationControl.java

View check run for this annotation

Jenkins - Eclipse Platform / Compiler

NLS

ERROR: $ Non-externalized string literal; it should be followed by //$NON-NLS-

Check warning on line 154 in bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/CompositeInformationControl.java

View check run for this annotation

Jenkins - Eclipse Platform / Compiler

NLS

ERROR: $ Non-externalized string literal; it should be followed by //$NON-NLS-

return plainText.isEmpty();
}

private void reassignParent(final Composite parent, final List<Control> children) {

Check warning on line 159 in bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/CompositeInformationControl.java

View check run for this annotation

Jenkins - Eclipse Platform / Compiler

Code Style

LOW: The method reassignParent(Composite, List ) from the type CompositeInformationControl can be declared as static
for (Control control : children) {
control.setParent(parent);
}
}

@Override
public void dispose() {
controls.values().forEach(IInformationControl::dispose);
Expand Down
Loading