diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java index e13ec43bffe..c9cfa2774c1 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java @@ -99,8 +99,9 @@ public AbstractControlContentAssistSubjectAdapter() { public void addKeyListener(KeyListener keyListener) { fKeyListeners.add(keyListener); - if (DEBUG) + if (DEBUG) { System.out.println("AbstractControlContentAssistSubjectAdapter#addKeyListener()"); //$NON-NLS-1$ + } installControlListener(); } @@ -110,8 +111,9 @@ public void removeKeyListener(KeyListener keyListener) { boolean deleted= fKeyListeners.remove(keyListener); if (DEBUG) { - if (!deleted) + if (!deleted) { System.out.println("removeKeyListener -> wasn't here"); //$NON-NLS-1$ + } System.out.println("AbstractControlContentAssistSubjectAdapter#removeKeyListener() -> " + fKeyListeners.size()); //$NON-NLS-1$ } @@ -127,8 +129,9 @@ public boolean supportsVerifyKeyListener() { public boolean appendVerifyKeyListener(final VerifyKeyListener verifyKeyListener) { fVerifyKeyListeners.add(verifyKeyListener); - if (DEBUG) + if (DEBUG) { System.out.println("AbstractControlContentAssistSubjectAdapter#appendVerifyKeyListener() -> " + fVerifyKeyListeners.size()); //$NON-NLS-1$ + } installControlListener(); return true; @@ -138,8 +141,9 @@ public boolean appendVerifyKeyListener(final VerifyKeyListener verifyKeyListener public boolean prependVerifyKeyListener(final VerifyKeyListener verifyKeyListener) { fVerifyKeyListeners.add(0, verifyKeyListener); - if (DEBUG) + if (DEBUG) { System.out.println("AbstractControlContentAssistSubjectAdapter#prependVerifyKeyListener() -> " + fVerifyKeyListeners.size()); //$NON-NLS-1$ + } installControlListener(); return true; @@ -149,8 +153,9 @@ public boolean prependVerifyKeyListener(final VerifyKeyListener verifyKeyListene public void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener) { fVerifyKeyListeners.remove(verifyKeyListener); - if (DEBUG) + if (DEBUG) { System.out.println("AbstractControlContentAssistSubjectAdapter#removeVerifyKeyListener() -> " + fVerifyKeyListeners.size()); //$NON-NLS-1$ + } uninstallControlListener(); } @@ -158,8 +163,9 @@ public void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener) { @Override public void setEventConsumer(IEventConsumer eventConsumer) { // this is not supported - if (DEBUG) + if (DEBUG) { System.out.println("AbstractControlContentAssistSubjectAdapter#setEventConsumer()"); //$NON-NLS-1$ + } } @Override @@ -172,24 +178,28 @@ public String getLineDelimiter() { * passing them to {@link #fVerifyKeyListeners} and {@link #fKeyListeners}. */ private void installControlListener() { - if (DEBUG) + if (DEBUG) { System.out.println("AbstractControlContentAssistSubjectAdapter#installControlListener() -> k: " + fKeyListeners.size() + ", v: " + fVerifyKeyListeners.size()); //$NON-NLS-1$ //$NON-NLS-2$ + } - if (fControlListener != null) + if (fControlListener != null) { return; + } fControlListener= new Listener() { @Override public void handleEvent(Event e) { - if (! getControl().isFocusControl()) + if (! getControl().isFocusControl()) { return; //SWT.TRAVERSE_MNEMONIC events can also come in to inactive widgets + } VerifyEvent verifyEvent= new VerifyEvent(e); KeyEvent keyEvent= new KeyEvent(e); switch (e.type) { case SWT.Traverse : - if (DEBUG) + if (DEBUG) { dump("before traverse", e, verifyEvent); //$NON-NLS-1$ + } verifyEvent.doit= true; for (VerifyKeyListener verifyKeyListener : fVerifyKeyListeners) { @@ -197,13 +207,15 @@ public void handleEvent(Event e) { if (! verifyEvent.doit) { e.detail= SWT.TRAVERSE_NONE; e.doit= true; - if (DEBUG) + if (DEBUG) { dump("traverse eaten by verify", e, verifyEvent); //$NON-NLS-1$ + } return; } - if (DEBUG) + if (DEBUG) { dump("traverse OK", e, verifyEvent); //$NON-NLS-1$ + } } break; @@ -212,14 +224,16 @@ public void handleEvent(Event e) { verifyKeyListener.verifyKey(verifyEvent); if (! verifyEvent.doit) { e.doit= verifyEvent.doit; - if (DEBUG) + if (DEBUG) { dump("keyDown eaten by verify", e, verifyEvent); //$NON-NLS-1$ + } return; } } - if (DEBUG) + if (DEBUG) { dump("keyDown OK", e, verifyEvent); //$NON-NLS-1$ + } for (KeyListener keyListener : fKeyListeners) { keyListener.keyPressed(keyEvent); @@ -263,8 +277,9 @@ private String hex(int i) { getControl().addListener(SWT.Traverse, fControlListener); getControl().addListener(SWT.KeyDown, fControlListener); - if (DEBUG) + if (DEBUG) { System.out.println("AbstractControlContentAssistSubjectAdapter#installControlListener() - installed"); //$NON-NLS-1$ + } } /** @@ -275,8 +290,9 @@ private String hex(int i) { private void uninstallControlListener() { if (fControlListener == null || fKeyListeners.size() + fVerifyKeyListeners.size() != 0) { - if (DEBUG) + if (DEBUG) { System.out.println("AbstractControlContentAssistSubjectAdapter#uninstallControlListener() -> k: " + fKeyListeners.size() + ", v: " + fVerifyKeyListeners.size()); //$NON-NLS-1$ //$NON-NLS-2$ + } return; } @@ -284,8 +300,9 @@ private void uninstallControlListener() { getControl().removeListener(SWT.KeyDown, fControlListener); fControlListener= null; - if (DEBUG) + if (DEBUG) { System.out.println("AbstractControlContentAssistSubjectAdapter#uninstallControlListener() - done"); //$NON-NLS-1$ + } } /** @@ -349,8 +366,9 @@ public void setContentAssistCueProvider(final ILabelProvider labelProvider) { ILabelProviderListener listener= event -> { fControlDecoration.setDescriptionText(labelProvider.getText(getControl())); Image image= labelProvider.getImage(getControl()); - if (image == null) + if (image == null) { image= getDefaultCueImage(); + } fControlDecoration.setImage(image); }; labelProvider.addListener(listener); diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java index 65c7a2476fe..48b44e1b137 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java @@ -168,7 +168,8 @@ public boolean addSelectionListener(final SelectionListener selectionListener) { public void removeSelectionListener(SelectionListener selectionListener) { fCombo.removeSelectionListener(selectionListener); Listener listener= fModifyListeners.get(selectionListener); - if (listener != null) + if (listener != null) { fCombo.removeListener(SWT.Modify, listener); + } } } diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java index 07e04429ff8..c8ec349b344 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java @@ -65,8 +65,9 @@ public boolean isContextInformationValid(int offset) { IContextInformation[] infos= ((ISubjectControlContentAssistProcessor)fProcessor).computeContextInformation(fContentAssistSubjectControl, offset); if (infos != null && infos.length > 0) { for (IContextInformation info : infos) { - if (fContextInformation.equals(info)) + if (fContextInformation.equals(info)) { return true; + } } } } diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java index 87e5405a4b5..862f31e98aa 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java @@ -151,7 +151,8 @@ public boolean addSelectionListener(final SelectionListener selectionListener) { public void removeSelectionListener(SelectionListener selectionListener) { fText.removeSelectionListener(selectionListener); Listener listener= fModifyListeners.get(selectionListener); - if (listener != null) + if (listener != null) { fText.removeListener(SWT.Modify, listener); + } } } diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/InformationControlReplacer.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/InformationControlReplacer.java index f34fb4ea1e8..e191e05cbd3 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/InformationControlReplacer.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/InformationControlReplacer.java @@ -89,10 +89,11 @@ public void replaceInformationControl(IInformationControlCreator informationPres try { fIsReplacing= true; - if (! fDelayedInformationSet) + if (! fDelayedInformationSet) { fReplacableInformation= information; - else + } else { takeFocus= true; // delayed input has been set, so the original info control must have been focused + } fContentBounds= contentBounds; fReplaceableArea= subjectArea; @@ -117,8 +118,9 @@ protected void computeInformation() { return; } - if (DEBUG) + if (DEBUG) { System.out.println("InformationControlReplacer: no active replaceable"); //$NON-NLS-1$ + } } /** @@ -136,10 +138,11 @@ public void showInformationControl(Rectangle subjectArea, Object information) { // Caveat: some IInformationControls fail unless setSizeConstraints(..) is called with concrete values informationControl.setSizeConstraints(controlBounds.width, controlBounds.height); - if (informationControl instanceof IInformationControlExtension2) + if (informationControl instanceof IInformationControlExtension2) { ((IInformationControlExtension2) informationControl).setInput(information); - else + } else { informationControl.setInformation(information.toString()); + } // need to recompute the bounds because trim might have changed based on input controlBounds= computeBoundsFromContent(informationControl, fContentBounds); diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/NonDeletingPositionUpdater.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/NonDeletingPositionUpdater.java index 6c71d76941d..99dbf5060e0 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/NonDeletingPositionUpdater.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/NonDeletingPositionUpdater.java @@ -57,8 +57,9 @@ public void update(DocumentEvent event) { Position position= positions[i]; - if (position.isDeleted()) + if (position.isDeleted()) { continue; + } int offset= position.getOffset(); int length= position.getLength(); diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java index 0129ec83a52..835adc4498c 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java @@ -106,8 +106,9 @@ boolean isEmpty(T selection) throws BadLocationException { * @throws BadLocationException if selection is not a valid selection on the target document */ boolean isMultiline(T selection) throws BadLocationException { - if (selection == null) + if (selection == null) { throw new NullPointerException(); + } return false; } @@ -544,8 +545,9 @@ String getText(IBlockTextSelection selection) throws BadLocationException { for (int line= startLine; line <= endLine; line++) { appendColumnRange(buf, line, visualStartColumn, visualEndColumn); - if (line != endLine) + if (line != endLine) { buf.append(fDocument.getLineDelimiter(line)); + } } return buf.toString(); @@ -656,16 +658,18 @@ private TextEdit createReplaceEdit(int line, int visualStartColumn, int visualEn int visual= 0; for (int offset= 0; offset < lineLength; offset++) { if (startColumn == -1) { - if (visual == visualStartColumn) - if (!delete && isWider(content.charAt(offset), visual) && replacement.isEmpty()) + if (visual == visualStartColumn) { + if (!delete && isWider(content.charAt(offset), visual) && replacement.isEmpty()) { startColumn= offset - 1; - else + } else { startColumn= offset; - else if (visual > visualStartColumn) { - if (isWider(content.charAt(offset - 1), visual)) + } + } else if (visual > visualStartColumn) { + if (isWider(content.charAt(offset - 1), visual)) { startColumn= offset - 1; - else + } else { startColumn= offset; + } } } if (startColumn != -1) { @@ -673,10 +677,11 @@ else if (visual > visualStartColumn) { endColumn= offset; break; } else if (visual > visualEndColumn) { - if (!delete && isWider(content.charAt(offset - 1), visual)) + if (!delete && isWider(content.charAt(offset - 1), visual)) { endColumn= offset - 1; - else + } else { endColumn= offset; + } break; } } @@ -692,10 +697,12 @@ else if (visual > visualStartColumn) { } return new MultiTextEdit(); } - if (endColumn == -1) + if (endColumn == -1) { endColumn= lineLength; - if (replacement.isEmpty()) + } + if (replacement.isEmpty()) { return new DeleteEdit(info.getOffset() + startColumn, endColumn - startColumn); + } return new ReplaceEdit(info.getOffset() + startColumn, endColumn - startColumn, replacement); } @@ -707,20 +714,23 @@ private void appendColumnRange(StringBuilder buf, int line, int visualStartColum int endColumn= -1; int visual= 0; for (int offset= 0; offset < lineLength; offset++) { - if (startColumn == -1 && visual >= visualStartColumn) + if (startColumn == -1 && visual >= visualStartColumn) { startColumn= offset; + } if (visual >= visualEndColumn) { endColumn= offset; break; } visual+= visualSizeIncrement(content.charAt(offset), visual); } - if (startColumn != -1) + if (startColumn != -1) { buf.append(content.substring(startColumn, endColumn == -1 ? lineLength : endColumn)); + } if (endColumn == -1) { int spaces= Math.max(0, visualEndColumn - Math.max(visual, visualStartColumn)); - for (int i= 0; i < spaces; i++) + for (int i= 0; i < spaces; i++) { buf.append(' '); + } } } @@ -730,10 +740,12 @@ private int computeVisualColumn(final int line, final int column) throws BadLoca int to= Math.min(lineLength, column); String content= fDocument.get(info.getOffset(), lineLength); int visual= 0; - for (int offset= 0; offset < to; offset++) + for (int offset= 0; offset < to; offset++) { visual+= visualSizeIncrement(content.charAt(offset), visual); - if (column > lineLength) + } + if (column > lineLength) { visual+= column - lineLength; // virtual spaces + } return visual; } @@ -743,8 +755,9 @@ private int computeCharacterColumn(int line, int visualColumn) throws BadLocatio String content= fDocument.get(info.getOffset(), lineLength); int visual= 0; for (int offset= 0; offset < lineLength; offset++) { - if (visual >= visualColumn) + if (visual >= visualColumn) { return offset; + } visual+= visualSizeIncrement(content.charAt(offset), visual); } return lineLength + Math.max(0, visualColumn - visual); @@ -773,14 +786,17 @@ private int visualSizeIncrement(char character, int visual) { int singleCharWidth= gc.stringExtent(" ").x; //$NON-NLS-1$ return (int) Math.ceil((double) charWidth / singleCharWidth); } finally { - if (gc != null) + if (gc != null) { gc.dispose(); + } } } - if (character != '\t') + if (character != '\t') { return 1; - if (fTabWidth <= 0) + } + if (fTabWidth <= 0) { return 0; + } return fTabWidth - visual % fTabWidth; } }; @@ -935,8 +951,9 @@ private ISelection makeDeleteSelection(ISelection selection) throws BadLocationE public void doDelete(ISelection selection) throws BadLocationException { TextEdit edit= delete(selection); boolean complex= edit.hasChildren(); - if (complex && fRewriteTarget != null) + if (complex && fRewriteTarget != null) { fRewriteTarget.beginCompoundChange(); + } try { edit.apply(fDocument, TextEdit.UPDATE_REGIONS); if (fSelectionProvider != null) { @@ -944,9 +961,10 @@ public void doDelete(ISelection selection) throws BadLocationException { fSelectionProvider.setSelection(empty); } } finally { - if (complex && fRewriteTarget != null) + if (complex && fRewriteTarget != null) { fRewriteTarget.endCompoundChange(); } + } } /** @@ -959,8 +977,9 @@ public void doDelete(ISelection selection) throws BadLocationException { public void doBackspace(ISelection selection) throws BadLocationException { TextEdit edit= backspace(selection); boolean complex= edit.hasChildren(); - if (complex && fRewriteTarget != null) + if (complex && fRewriteTarget != null) { fRewriteTarget.beginCompoundChange(); + } try { ISelection newSelection= makeBackspaceSelection(selection); edit.apply(fDocument, TextEdit.UPDATE_REGIONS); @@ -968,8 +987,9 @@ public void doBackspace(ISelection selection) throws BadLocationException { fSelectionProvider.setSelection(newSelection); } } finally { - if (complex && fRewriteTarget != null) + if (complex && fRewriteTarget != null) { fRewriteTarget.endCompoundChange(); + } } } @@ -984,8 +1004,9 @@ public void doBackspace(ISelection selection) throws BadLocationException { public void doReplace(ISelection selection, String replacement) throws BadLocationException { TextEdit edit= replace(selection, replacement); boolean complex= edit.hasChildren(); - if (complex && fRewriteTarget != null) + if (complex && fRewriteTarget != null) { fRewriteTarget.beginCompoundChange(); + } try { edit.apply(fDocument, TextEdit.UPDATE_REGIONS); @@ -994,8 +1015,9 @@ public void doReplace(ISelection selection, String replacement) throws BadLocati fSelectionProvider.setSelection(empty); } } finally { - if (complex && fRewriteTarget != null) + if (complex && fRewriteTarget != null) { fRewriteTarget.endCompoundChange(); + } } } diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/StickyHoverManager.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/StickyHoverManager.java index 35456f83cf3..a4801442c8c 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/StickyHoverManager.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/StickyHoverManager.java @@ -100,8 +100,9 @@ public void setInformationControl(IInformationControl control) { @Override public void start(Rectangle informationArea) { - if (fIsActive) + if (fIsActive) { return; + } fIsActive= true; if (fSubjectControl != null && !fSubjectControl.isDisposed()) { @@ -113,8 +114,9 @@ public void start(Rectangle informationArea) { fTextViewer.addViewportListener(this); IInformationControl fInformationControlToClose= getCurrentInformationControl2(); - if (fInformationControlToClose != null) + if (fInformationControlToClose != null) { fInformationControlToClose.addFocusListener(this); + } fDisplay= fSubjectControl.getDisplay(); if (!fDisplay.isDisposed()) { @@ -126,8 +128,9 @@ public void start(Rectangle informationArea) { @Override public void stop() { - if (!fIsActive) + if (!fIsActive) { return; + } fIsActive= false; fTextViewer.removeViewportListener(this); @@ -139,8 +142,9 @@ public void stop() { } IInformationControl fInformationControlToClose= getCurrentInformationControl2(); - if (fInformationControlToClose != null) + if (fInformationControlToClose != null) { fInformationControlToClose.removeFocusListener(this); + } if (fDisplay != null && !fDisplay.isDisposed()) { fDisplay.removeFilter(SWT.MouseMove, this); @@ -194,7 +198,9 @@ public void focusGained(FocusEvent e) { @Override public void focusLost(FocusEvent e) { - if (DEBUG) System.out.println("StickyHoverManager.Closer.focusLost(): " + e); //$NON-NLS-1$ + if (DEBUG) { + System.out.println("StickyHoverManager.Closer.focusLost(): " + e); //$NON-NLS-1$ + } Display d= fSubjectControl.getDisplay(); // Without the asyncExec, mouse clicks to the workbench window are swallowed. d.asyncExec(() -> hideInformationControl()); @@ -203,8 +209,9 @@ public void focusLost(FocusEvent e) { @Override public void handleEvent(Event event) { if (event.type == SWT.MouseMove) { - if (!(event.widget instanceof Control) || event.widget.isDisposed()) + if (!(event.widget instanceof Control) || event.widget.isDisposed()) { return; + } IInformationControl infoControl= getCurrentInformationControl2(); if (infoControl != null && !infoControl.isFocusControl() && infoControl instanceof IInformationControlExtension3 iControl3) { @@ -224,15 +231,19 @@ public void handleEvent(Event event) { * TODO: need better understanding of why/if this is needed. * Looks like the same panic code we have in org.eclipse.jface.text.AbstractHoverInformationControlManager.Closer.handleMouseMove(Event) */ - if (fDisplay != null && !fDisplay.isDisposed()) + if (fDisplay != null && !fDisplay.isDisposed()) { fDisplay.removeFilter(SWT.MouseMove, this); + } } } else if (event.type == SWT.FocusOut) { - if (DEBUG) System.out.println("StickyHoverManager.Closer.handleEvent(): focusOut: " + event); //$NON-NLS-1$ + if (DEBUG) { + System.out.println("StickyHoverManager.Closer.handleEvent(): focusOut: " + event); //$NON-NLS-1$ + } IInformationControl iControl= getCurrentInformationControl2(); - if (iControl != null && ! iControl.isFocusControl()) + if (iControl != null && ! iControl.isFocusControl()) { hideInformationControl(); + } } } } @@ -257,11 +268,12 @@ public StickyHoverManager(TextViewer textViewer) { @Override protected void showInformationControl(Rectangle subjectArea) { - if (fTextViewer != null && fTextViewer.requestWidgetToken(this, WIDGET_PRIORITY)) + if (fTextViewer != null && fTextViewer.requestWidgetToken(this, WIDGET_PRIORITY)) { super.showInformationControl(subjectArea); - else - if (DEBUG) + } else + if (DEBUG) { System.out.println("cancelled StickyHoverManager.showInformationControl(..): did not get widget token (with prio)"); //$NON-NLS-1$ + } } @Override @@ -269,8 +281,9 @@ public void hideInformationControl() { try { super.hideInformationControl(); } finally { - if (fTextViewer != null) + if (fTextViewer != null) { fTextViewer.releaseWidgetToken(this); + } } } @@ -279,16 +292,18 @@ protected void handleInformationControlDisposed() { try { super.handleInformationControlDisposed(); } finally { - if (fTextViewer != null) + if (fTextViewer != null) { fTextViewer.releaseWidgetToken(this); + } } } @Override public boolean requestWidgetToken(IWidgetTokenOwner owner) { hideInformationControl(); - if (DEBUG) + if (DEBUG) { System.out.println("StickyHoverManager gave up widget token (no prio)"); //$NON-NLS-1$ + } return true; } @@ -296,22 +311,26 @@ public boolean requestWidgetToken(IWidgetTokenOwner owner) { public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) { if (getCurrentInformationControl2() != null) { if (getCurrentInformationControl2().isFocusControl()) { - if (DEBUG) + if (DEBUG) { System.out.println("StickyHoverManager kept widget token (focused)"); //$NON-NLS-1$ + } return false; } else if (priority > WIDGET_PRIORITY) { hideInformationControl(); - if (DEBUG) + if (DEBUG) { System.out.println("StickyHoverManager gave up widget token (prio)"); //$NON-NLS-1$ + } return true; } else { - if (DEBUG) + if (DEBUG) { System.out.println("StickyHoverManager kept widget token (prio)"); //$NON-NLS-1$ + } return false; } } - if (DEBUG) + if (DEBUG) { System.out.println("StickyHoverManager gave up widget token (no iControl)"); //$NON-NLS-1$ + } return true; } diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java index 6042241b376..1e79dc782f4 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java @@ -281,13 +281,15 @@ public void setInput(Object input) { fInput= (BrowserInformationControlInput)input; String content= null; - if (fInput != null) + if (fInput != null) { content= fInput.getHtml(); + } fBrowserHasContent= content != null && !content.isEmpty(); - if (!fBrowserHasContent) + if (!fBrowserHasContent) { content= "
"; //$NON-NLS-1$ + } boolean RTL= (getShell().getStyle() & SWT.RIGHT_TO_LEFT) != 0; boolean resizable= isResizable(); @@ -300,16 +302,17 @@ public void setInput(Object input) { // The default "overflow:auto" would not result in a predictable width for the client area // and the re-wrapping would cause visual noise String[] styles= null; - if (RTL && resizable) + if (RTL && resizable) { styles= new String[] { "direction:rtl;", scrollbarStyle, "word-wrap:break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ - else if (RTL && !resizable) + } else if (RTL && !resizable) { styles= new String[] { "direction:rtl;", "overflow:hidden;", "word-wrap:break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - else if (!resizable) + } else if (!resizable) { //XXX: In IE, "word-wrap: break-word;" causes bogus wrapping even in non-broken words :-(see e.g. Javadoc of String). // Re-check whether we really still need this now that the Javadoc Hover header already sets this style. styles= new String[] { "overflow:hidden;"/*, "word-wrap: break-word;"*/}; //$NON-NLS-1$ - else + } else { styles= new String[] { scrollbarStyle }; + } StringBuilder buffer= new StringBuilder(content); HTMLPrinter.insertStyles(buffer, styles); @@ -340,8 +343,9 @@ public void setVisible(boolean visible) { return; } - if (shell.isVisible() == visible) + if (shell.isVisible() == visible) { return; + } /* * The Browser widget flickers when made visible while it is not completely loaded. * The fix is to delay the call to setVisible until either loading is completed @@ -360,15 +364,17 @@ public void setVisible(boolean visible) { } shell= getShell(); - if (shell == null || shell.isDisposed()) + if (shell == null || shell.isDisposed()) { return; + } /* * Avoids flickering when replacing hovers, especially on Vista in ON_CLICK mode. * Causes flickering on GTK. Carbon does not care. */ - if (Util.isWin32()) + if (Util.isWin32()) { shell.moveAbove(null); + } super.setVisible(true); } @@ -440,8 +446,9 @@ public Point computeSizeHint() { Iteratortrue
if the popup has the focus
*/
public boolean hasFocus() {
- if (isValid(fProposalShell))
+ if (isValid(fProposalShell)) {
return (fProposalShell.isFocusControl() || fProposalTable.isFocusControl());
+ }
return false;
}
@@ -488,15 +504,17 @@ public void hide() {
private void unregister() {
if (fDocumentListener != null) {
IDocument document= fViewer.getDocument();
- if (document != null)
+ if (document != null) {
document.removeDocumentListener(fDocumentListener);
+ }
fDocumentListener= null;
}
fDocumentEvents.clear();
StyledText styledText= fViewer.getTextWidget();
- if (fKeyListener != null && styledText != null && !styledText.isDisposed())
+ if (fKeyListener != null && styledText != null && !styledText.isDisposed()) {
styledText.removeKeyListener(fKeyListener);
+ }
if (fLastProposal != null) {
if (fLastProposal instanceof ICompletionProposalExtension2 extension) {
@@ -529,8 +547,9 @@ private void setProposals(ICompletionProposal[] proposals) {
if (isValid(fProposalTable)) {
ICompletionProposal oldProposal= getSelectedProposal();
- if (oldProposal instanceof ICompletionProposalExtension2)
+ if (oldProposal instanceof ICompletionProposalExtension2) {
((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
+ }
fFilteredProposals= proposals;
@@ -544,16 +563,18 @@ private void setProposals(ICompletionProposal[] proposals) {
endOffset= selection.x + selection.y;
IDocument document= fViewer.getDocument();
boolean validate= false;
- if (selection.y != 0 && document != null)
+ if (selection.y != 0 && document != null) {
validate= true;
+ }
TableItem item;
ICompletionProposal p;
for (int i= 0; i < proposals.length; i++) {
p= proposals[i];
item= new TableItem(fProposalTable, SWT.NULL);
- if (p.getImage() != null)
+ if (p.getImage() != null) {
item.setImage(p.getImage());
+ }
String displayString;
StyleRange[] styleRanges= null;
@@ -561,12 +582,14 @@ private void setProposals(ICompletionProposal[] proposals) {
StyledString styledString= ((ICompletionProposalExtension6)p).getStyledDisplayString();
displayString= styledString.getString();
styleRanges= styledString.getStyleRanges();
- } else
+ } else {
displayString= p.getDisplayString();
+ }
item.setText(displayString);
- if (fIsColoredLabelsSupportEnabled)
+ if (fIsColoredLabelsSupportEnabled) {
TableOwnerDrawSupport.storeStyleRanges(item, 0, styleRanges);
+ }
item.setData(p);
@@ -610,11 +633,13 @@ private void resizeProposalSelector(boolean adjustWidth) {
* @return the height hint for table
*/
private int getTableHeightHint(Table table, int rows) {
- if (table.getFont().equals(JFaceResources.getDefaultFont()))
+ if (table.getFont().equals(JFaceResources.getDefaultFont())) {
table.setFont(JFaceResources.getDialogFont());
+ }
int result= table.getItemHeight() * rows;
- if (table.getLinesVisible())
+ if (table.getLinesVisible()) {
result+= table.getGridLineWidth() * (rows - 1);
+ }
// TODO adjust to correct size. +4 works on windows, but not others
// return result + 4;
@@ -624,11 +649,13 @@ private int getTableHeightHint(Table table, int rows) {
private boolean validateProposal(IDocument document, ICompletionProposal p, int offset, DocumentEvent event) {
// detect selected
if (p instanceof ICompletionProposalExtension2 e) {
- if (e.validate(document, offset, event))
+ if (e.validate(document, offset, event)) {
return true;
+ }
} else if (p instanceof ICompletionProposalExtension e) {
- if (e.isValidFor(document, offset))
+ if (e.isValidFor(document, offset)) {
return true;
+ }
}
return false;
}
@@ -643,8 +670,12 @@ private Point getLocation() {
Point selection= text.getSelection();
Point p= text.getLocationAtOffset(selection.x);
p.x -= fProposalShell.getBorderWidth();
- if (p.x < 0) p.x= 0;
- if (p.y < 0) p.y= 0;
+ if (p.x < 0) {
+ p.x= 0;
+ }
+ if (p.y < 0) {
+ p.y= 0;
+ }
p= new Point(p.x, p.y + text.getLineHeight(selection.x));
p= text.toDisplay(p);
return p;
@@ -657,23 +688,27 @@ private Point getLocation() {
private void displayProposals() {
if (fContentAssistant.addContentAssistListener(this, ContentAssistant2.PROPOSAL_SELECTOR)) {
- if (fDocumentListener == null)
+ if (fDocumentListener == null) {
fDocumentListener= new IDocumentListener() {
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
- if (!fInserting)
+ if (!fInserting) {
fDocumentEvents.add(event);
+ }
}
@Override
public void documentChanged(DocumentEvent event) {
- if (!fInserting)
+ if (!fInserting) {
filterProposals();
+ }
}
};
+ }
IDocument document= fViewer.getDocument();
- if (document != null)
+ if (document != null) {
document.addDocumentListener(fDocumentListener);
+ }
if (fViewer instanceof IEditingSupportRegistry registry) {
@@ -684,8 +719,9 @@ public void documentChanged(DocumentEvent event) {
// see bug 47511: setVisible may run the event loop on GTK
// and trigger a rentrant call - have to check whether we are still
// visible
- if (!isValid(fProposalShell))
+ if (!isValid(fProposalShell)) {
return;
+ }
if (fAdditionalInfoController != null) {
@@ -697,8 +733,9 @@ public void documentChanged(DocumentEvent event) {
@Override
public boolean verifyKey(VerifyEvent e) {
- if (!isValid(fProposalShell))
+ if (!isValid(fProposalShell)) {
return true;
+ }
char key= e.character;
if (key == 0) {
@@ -713,26 +750,30 @@ public boolean verifyKey(VerifyEvent e) {
case SWT.ARROW_UP :
newSelection -= 1;
- if (newSelection < 0)
+ if (newSelection < 0) {
newSelection= fProposalTable.getItemCount() - 1;
+ }
break;
case SWT.ARROW_DOWN :
newSelection += 1;
- if (newSelection > fProposalTable.getItemCount() - 1)
+ if (newSelection > fProposalTable.getItemCount() - 1) {
newSelection= 0;
+ }
break;
case SWT.PAGE_DOWN :
newSelection += visibleRows;
- if (newSelection >= fProposalTable.getItemCount())
+ if (newSelection >= fProposalTable.getItemCount()) {
newSelection= fProposalTable.getItemCount() - 1;
+ }
break;
case SWT.PAGE_UP :
newSelection -= visibleRows;
- if (newSelection < 0)
+ if (newSelection < 0) {
newSelection= 0;
+ }
break;
case SWT.HOME :
@@ -744,8 +785,9 @@ public boolean verifyKey(VerifyEvent e) {
break;
default :
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
+ if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4) {
hide();
+ }
return true;
}
@@ -802,19 +844,22 @@ public boolean verifyKey(VerifyEvent e) {
private void selectProposal(int index, boolean smartToggle) {
ICompletionProposal oldProposal= getSelectedProposal();
- if (oldProposal instanceof ICompletionProposalExtension2)
+ if (oldProposal instanceof ICompletionProposalExtension2) {
((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
+ }
ICompletionProposal proposal= fFilteredProposals[index];
- if (proposal instanceof ICompletionProposalExtension2)
+ if (proposal instanceof ICompletionProposalExtension2) {
((ICompletionProposalExtension2) proposal).selected(fViewer, smartToggle);
+ }
fLastProposal= proposal;
fProposalTable.setSelection(index);
fProposalTable.showSelection();
- if (fAdditionalInfoController != null)
+ if (fAdditionalInfoController != null) {
fAdditionalInfoController.handleTableSelectionChanged();
+ }
}
/**
@@ -828,12 +873,14 @@ private void selectProposal(int index, boolean smartToggle) {
*/
private boolean contains(char[] characters, char c) {
- if (characters == null)
+ if (characters == null) {
return false;
+ }
for (char character : characters) {
- if (c == character)
+ if (c == character) {
return true;
+ }
}
return false;
@@ -851,10 +898,12 @@ private void filterProposals() {
Control control= fViewer.getTextWidget();
long fCounter= fInvocationCounter;
control.getDisplay().asyncExec(() -> {
- if (fCounter != fInvocationCounter)
+ if (fCounter != fInvocationCounter) {
return;
- if (fInvocationProcessedCounter == fInvocationCounter)
+ }
+ if (fInvocationProcessedCounter == fInvocationCounter) {
return;
+ }
doFilterProposals();
});
@@ -902,19 +951,22 @@ public boolean doFilterProposals() {
*/
private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent event) {
- if (offset == fInvocationOffset && event == null)
+ if (offset == fInvocationOffset && event == null) {
return fComputedProposals;
+ }
if (offset < fInvocationOffset) {
return null;
}
ICompletionProposal[] proposals= fComputedProposals;
- if (offset > fFilterOffset)
+ if (offset > fFilterOffset) {
proposals= fFilteredProposals;
+ }
- if (proposals == null)
+ if (proposals == null) {
return null;
+ }
IDocument document= fViewer.getDocument();
int length= proposals.length;
@@ -923,13 +975,15 @@ private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent
if (proposals[i] instanceof ICompletionProposalExtension2 p) {
- if (p.validate(document, offset, event))
+ if (p.validate(document, offset, event)) {
filtered.add(p);
+ }
} else if (proposals[i] instanceof ICompletionProposalExtension p) {
- if (p.isValidFor(document, offset))
+ if (p.isValidFor(document, offset)) {
filtered.add(p);
+ }
} else {
// restore original behavior
@@ -950,7 +1004,8 @@ private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent
* @since 3.0
*/
public void setFocus() {
- if (isValid(fProposalShell))
+ if (isValid(fProposalShell)) {
fProposalShell.setFocus();
+ }
}
}
diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.java
index 5b89cba3c73..0b3a8846cbe 100644
--- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.java
+++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistMessages.java
@@ -78,8 +78,9 @@ public static String getFormattedString(String key, Object arg) {
} catch (MissingResourceException e) {
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
}
- if (arg == null)
+ if (arg == null) {
arg= ""; //$NON-NLS-1$
+ }
return MessageFormat.format(format, arg);
}
}
diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
index 8fbda719750..81a8dfbcb46 100644
--- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
+++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
@@ -121,8 +121,9 @@ protected void install() {
protected void uninstall() {
Shell shell= fShell;
fShell= null;
- if (isValid(shell))
+ if (isValid(shell)) {
shell.removeControlListener(this);
+ }
Control w= fViewer.getTextWidget();
if (isValid(w)) {
@@ -175,8 +176,9 @@ public void focusLost(FocusEvent e) {
Display d= control.getDisplay();
if (d != null) {
d.asyncExec(() -> {
- if (!hasFocus())
+ if (!hasFocus()) {
hide();
+ }
});
}
}
@@ -196,8 +198,9 @@ public void widgetDisposed(DisposeEvent e) {
@Override
public void viewportChanged(int topIndex) {
- if (System.currentTimeMillis() > fViewportListenerStartTime)
+ if (System.currentTimeMillis() > fViewportListenerStartTime) {
hide();
+ }
}
}
@@ -234,8 +237,9 @@ public void run() {
try {
while (true) {
synchronized (fMutex) {
- if (fAutoActivationDelay != 0)
+ if (fAutoActivationDelay != 0) {
fMutex.wait(fAutoActivationDelay);
+ }
if (fIsReset) {
fIsReset= false;
continue;
@@ -259,18 +263,21 @@ protected void reset(int showStyle) {
protected void stop() {
Thread threadToStop= fThread;
- if (threadToStop != null)
+ if (threadToStop != null) {
threadToStop.interrupt();
+ }
}
@Override
public void verifyKey(VerifyEvent e) {
// Only act on typed characters and ignore modifier-only events
- if (e.character == 0 && (e.keyCode & SWT.KEYCODE_BIT) == 0)
+ if (e.character == 0 && (e.keyCode & SWT.KEYCODE_BIT) == 0) {
return;
+ }
- if (e.character != 0 && (e.stateMask == SWT.ALT))
+ if (e.character != 0 && (e.stateMask == SWT.ALT)) {
return;
+ }
@@ -285,22 +292,24 @@ public void verifyKey(VerifyEvent e) {
- if (p.isCompletionProposalAutoActivation(e.character, fViewer, pos) && !fProposalPopup.isActive())
+ if (p.isCompletionProposalAutoActivation(e.character, fViewer, pos) && !fProposalPopup.isActive()) {
showStyle= SHOW_PROPOSALS;
- else {
- if (p.isContextInformationAutoActivation(e.character, fViewer, pos) && !fContextInfoPopup.isActive())
+ } else {
+ if (p.isContextInformationAutoActivation(e.character, fViewer, pos) && !fContextInfoPopup.isActive()) {
showStyle= SHOW_CONTEXT_INFO;
- else {
- if (fThread != null && fThread.isAlive())
+ } else {
+ if (fThread != null && fThread.isAlive()) {
stop();
+ }
return;
}
}
- if (fThread != null && fThread.isAlive())
+ if (fThread != null && fThread.isAlive()) {
reset(showStyle);
- else
+ } else {
start(showStyle);
+ }
}
protected void showAssist(final int showStyle) {
@@ -309,10 +318,11 @@ protected void showAssist(final int showStyle) {
if (d != null) {
try {
d.syncExec(() -> {
- if (showStyle == SHOW_PROPOSALS)
+ if (showStyle == SHOW_PROPOSALS) {
fProposalPopup.showProposals(true);
- else if (showStyle == SHOW_CONTEXT_INFO)
+ } else if (showStyle == SHOW_CONTEXT_INFO) {
fContextInfoPopup.showContextProposals(true);
+ }
});
} catch (SWTError e) {
}
@@ -345,15 +355,17 @@ protected void add(Object popup, Shell shell, int type, int offset) {
checkType(type);
if (fShells[type] != shell) {
- if (fShells[type] != null)
+ if (fShells[type] != null) {
fShells[type].removeListener(SWT.Dispose, this);
+ }
shell.addListener(SWT.Dispose, this);
fShells[type]= shell;
}
fPopups[type]= popup;
- if (type == LAYOUT_CONTEXT_SELECTOR || type == LAYOUT_CONTEXT_INFO_POPUP)
+ if (type == LAYOUT_CONTEXT_SELECTOR || type == LAYOUT_CONTEXT_INFO_POPUP) {
fContextType= type;
+ }
layout(type, offset);
adjustListeners(type);
@@ -384,8 +396,9 @@ public void handleEvent(Event event) {
case LAYOUT_CONTEXT_SELECTOR:
if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- if (fProposalPopupOrientation == PROPOSAL_STACKED)
+ if (fProposalPopupOrientation == PROPOSAL_STACKED) {
layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
+ }
// Restore event notification to the proposal popup.
addContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR);
}
@@ -394,8 +407,9 @@ public void handleEvent(Event event) {
case LAYOUT_CONTEXT_INFO_POPUP:
if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
- if (fContextInfoPopupOrientation == CONTEXT_INFO_BELOW)
+ if (fContextInfoPopupOrientation == CONTEXT_INFO_BELOW) {
layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
+ }
}
fContextType= LAYOUT_CONTEXT_SELECTOR;
break;
@@ -404,8 +418,9 @@ public void handleEvent(Event event) {
protected int getShellType(Widget shell) {
for (int i=0; itrue
if teh context selector has the focus
*/
public boolean hasFocus() {
- if (isValid(fContextSelectorShell))
+ if (isValid(fContextSelectorShell)) {
return (fContextSelectorShell.isFocusControl() || fContextSelectorTable.isFocusControl());
+ }
return false;
}
@@ -460,10 +476,12 @@ public boolean isActive() {
@Override
public boolean verifyKey(VerifyEvent e) {
- if (isValid(fContextSelectorShell))
+ if (isValid(fContextSelectorShell)) {
return contextSelectorKeyPressed(e);
- if (isValid(fContextInfoPopup))
+ }
+ if (isValid(fContextInfoPopup)) {
return contextInfoPopupKeyPressed(e);
+ }
return true;
}
@@ -494,14 +512,16 @@ private boolean contextSelectorKeyPressed(VerifyEvent e) {
case SWT.PAGE_DOWN :
change= visibleRows;
- if (selection + change >= fContextSelectorTable.getItemCount())
+ if (selection + change >= fContextSelectorTable.getItemCount()) {
change= fContextSelectorTable.getItemCount() - selection;
+ }
break;
case SWT.PAGE_UP :
change= -visibleRows;
- if (selection + change < 0)
+ if (selection + change < 0) {
change= -selection;
+ }
break;
case SWT.HOME :
@@ -513,8 +533,9 @@ private boolean contextSelectorKeyPressed(VerifyEvent e) {
break;
default:
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
+ if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4) {
hideContextSelector();
+ }
return true;
}
@@ -555,8 +576,9 @@ private boolean contextInfoPopupKeyPressed(KeyEvent e) {
validateContextInformation();
break;
default:
- if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
+ if (e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4) {
hideContextInfoPopup();
+ }
break;
}
@@ -571,10 +593,12 @@ private boolean contextInfoPopupKeyPressed(KeyEvent e) {
@Override
public void processEvent(VerifyEvent event) {
- if (isValid(fContextSelectorShell))
+ if (isValid(fContextSelectorShell)) {
contextSelectorProcessEvent(event);
- if (isValid(fContextInfoPopup))
+ }
+ if (isValid(fContextInfoPopup)) {
contextInfoPopupProcessEvent(event);
+ }
}
/**
@@ -598,8 +622,9 @@ private void contextSelectorProcessEvent(VerifyEvent e) {
* @param e the verify event describing the key stroke
*/
private void contextInfoPopupProcessEvent(VerifyEvent e) {
- if (e.start != e.end && (e.text == null || e.text.isEmpty()))
+ if (e.start != e.end && (e.text == null || e.text.isEmpty())) {
validateContextInformation();
+ }
}
/**
diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
index f3e9794cbbc..af381b1c33e 100644
--- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
+++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
@@ -65,8 +65,9 @@ public void install(ContentAssistant2 contentAssistant, Table table) {
}
fTable.addFocusListener(this);
fScrollbar= fTable.getVerticalBar();
- if (fScrollbar != null)
+ if (fScrollbar != null) {
fScrollbar.addSelectionListener(this);
+ }
}
}
@@ -75,13 +76,16 @@ public void install(ContentAssistant2 contentAssistant, Table table) {
*/
public void uninstall() {
fContentAssistant= null;
- if (isValid(fShell))
+ if (isValid(fShell)) {
fShell.removeShellListener(this);
+ }
fShell= null;
- if (isValid(fScrollbar))
+ if (isValid(fScrollbar)) {
fScrollbar.removeSelectionListener(this);
- if (isValid(fTable))
+ }
+ if (isValid(fTable)) {
fTable.removeFocusListener(this);
+ }
}
@Override
@@ -103,21 +107,24 @@ public void focusLost(final FocusEvent e) {
fScrollbarClicked= false;
Display d= fTable.getDisplay();
d.asyncExec(() -> {
- if (isValid(fTable) && !fTable.isFocusControl() && !fScrollbarClicked && fContentAssistant != null)
+ if (isValid(fTable) && !fTable.isFocusControl() && !fScrollbarClicked && fContentAssistant != null) {
fContentAssistant.popupFocusLost(e);
+ }
});
}
@Override
public void shellDeactivated(ShellEvent e) {
- if (fContentAssistant != null)
+ if (fContentAssistant != null) {
fContentAssistant.hide();
+ }
}
@Override
public void shellClosed(ShellEvent e) {
- if (fContentAssistant != null)
+ if (fContentAssistant != null) {
fContentAssistant.hide();
+ }
}
}
diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java
index e4138f04b2b..6542155766d 100644
--- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java
+++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java
@@ -84,8 +84,9 @@ public Liststart
< 0
*/
public void moveTo(int start) throws LineIndexOutOfBoundsException {
- if ((start < 0))
+ if ((start < 0)) {
throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$
+ }
fStart= start;
}
@@ -168,8 +169,9 @@ public void moveBy(int delta) throws LineIndexOutOfBoundsException {
*/
public void setStart(int start) throws LineIndexOutOfBoundsException {
int end= end();
- if (((start < 0) || (start >= end)))
+ if (((start < 0) || (start >= end))) {
throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$
+ }
moveTo(start);
setEnd(end);
}
@@ -191,8 +193,9 @@ public void setEnd(int end) throws LineIndexOutOfBoundsException {
* @throws LineIndexOutOfBoundsException if length
<= 0
*/
public void setLength(int length) throws LineIndexOutOfBoundsException {
- if ((length <= 0))
+ if ((length <= 0)) {
throw new LineIndexOutOfBoundsException("Cannot set length <= 0: " + length); //$NON-NLS-1$
+ }
fLength= length;
}
@@ -235,8 +238,9 @@ public void resizeAndMoveBy(int delta) throws LineIndexOutOfBoundsException {
* @throws LineIndexOutOfBoundsException if remaining
>= {@link #length()} or remaining
<= 0
*/
public Range split(int remaining) throws LineIndexOutOfBoundsException {
- if ((remaining >= length())) // assert before modification
+ if ((remaining >= length())) { // assert before modification
throw new LineIndexOutOfBoundsException("Remaining must be less than length: " + length()); //$NON-NLS-1$
+ }
int splitLength= length() - remaining;
setLength(remaining);
@@ -250,10 +254,12 @@ public Range split(int remaining) throws LineIndexOutOfBoundsException {
* @return true
if range
has the same offset and length as the receiver
*/
public boolean equalRange(ILineRange range) {
- if (range == this)
+ if (range == this) {
return true;
- if (range == null)
+ }
+ if (range == null) {
return false;
+ }
return range.getStartLine() == start() && range.getNumberOfLines() == length();
}
diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
index 99870496d46..a001961a37c 100644
--- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
+++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
@@ -167,8 +167,9 @@ public void setInfo(RevisionInformation info) {
fFocusColors.clear();
fGradientStart= null;
fGradientStop= null;
- if (info == null)
+ if (info == null) {
return;
+ }
Listnull
for no focus
*/
private void updateFocusRange(RevisionRange range) {
- if (range != fFocusRange)
+ if (range != fFocusRange) {
onFocusRangeChanged(fFocusRange, range);
+ }
}
/**
@@ -1252,16 +1287,18 @@ private void updateFocusRange(RevisionRange range) {
* @param nextRange the new focus range (null
for no focus)
*/
private void onFocusRangeChanged(RevisionRange previousRange, RevisionRange nextRange) {
- if (DEBUG)
+ if (DEBUG) {
System.out.println("range: " + previousRange + " > " + nextRange); //$NON-NLS-1$ //$NON-NLS-2$
+ }
fFocusRange= nextRange;
Revision revision= nextRange == null ? null : nextRange.getRevision();
updateFocusRevision(revision);
}
private void updateFocusRevision(Revision revision) {
- if (fFocusRevision != revision)
+ if (fFocusRevision != revision) {
onFocusRevisionChanged(fFocusRevision, revision);
+ }
}
/**
@@ -1271,8 +1308,9 @@ private void updateFocusRevision(Revision revision) {
* @param nextRevision the new focus revision (null
for no focus)
*/
private void onFocusRevisionChanged(Revision previousRevision, Revision nextRevision) {
- if (DEBUG)
+ if (DEBUG) {
System.out.println("revision: " + previousRevision + " > " + nextRevision); //$NON-NLS-1$ //$NON-NLS-2$
+ }
fFocusRevision= nextRevision;
uninstallWheelHandler();
installWheelHandler();
@@ -1329,8 +1367,9 @@ private void handleMouseWheel(Event event) {
nextWidgetRange= last;
break;
}
- if (widgetRange != null)
+ if (widgetRange != null) {
last= widgetRange;
+ }
}
} else {
for (ListIteratorILineDiffInfo
for line
, or null
.
*/
private ILineDiffInfo getDiffInfo(int line) {
- if (fLineDiffer != null)
+ if (fLineDiffer != null) {
return fLineDiffer.getLineInfo(line);
+ }
return null;
}
@@ -303,21 +312,24 @@ private Color getColor(ILineDiffInfo info) {
* @return the shaded color
*/
private Color getShadedColor(Color color) {
- if (color == null)
+ if (color == null) {
return null;
+ }
- if (fSharedColors == null)
+ if (fSharedColors == null) {
return color;
+ }
RGB baseRGB= color.getRGB();
RGB background= getBackground().getRGB();
boolean darkBase= isDark(baseRGB);
boolean darkBackground= isDark(background);
- if (darkBase && darkBackground)
+ if (darkBase && darkBackground) {
background= new RGB(255, 255, 255);
- else if (!darkBase && !darkBackground)
+ } else if (!darkBase && !darkBackground) {
background= new RGB(0, 0, 0);
+ }
return fSharedColors.getColor(interpolate(baseRGB, background, 0.6));
}
@@ -330,10 +342,11 @@ else if (!darkBase && !darkBackground)
*/
public void setModel(IAnnotationModel model) {
IAnnotationModel newModel;
- if (model instanceof IAnnotationModelExtension)
+ if (model instanceof IAnnotationModelExtension) {
newModel= ((IAnnotationModelExtension) model).getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
- else
+ } else {
newModel= model;
+ }
setDiffer(newModel);
}
@@ -346,8 +359,9 @@ public void setModel(IAnnotationModel model) {
private void setDiffer(IAnnotationModel differ) {
if (differ instanceof ILineDiffer) {
if (fLineDiffer != differ) {
- if (fLineDiffer != null)
+ if (fLineDiffer != null) {
((IAnnotationModel) fLineDiffer).removeAnnotationModelListener(fAnnotationListener);
+ }
fLineDiffer= (ILineDiffer) differ;
((IAnnotationModel) fLineDiffer).addAnnotationModelListener(fAnnotationListener);
}
@@ -400,8 +414,9 @@ private static int end(ILineRange range) {
* @return the System background color for list widgets
*/
private Color getBackground() {
- if (fBackground == null)
+ if (fBackground == null) {
return fWidget.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+ }
return fBackground;
}
@@ -463,8 +478,9 @@ public String getDisplayCharacter(int line) {
* @return the character indication for info
*/
private String getDisplayCharacter(ILineDiffInfo info) {
- if (info == null)
+ if (info == null) {
return " "; //$NON-NLS-1$
+ }
switch (info.getChangeType()) {
case ILineDiffInfo.CHANGED:
return "~"; //$NON-NLS-1$
@@ -494,8 +510,9 @@ private static RGB interpolate(RGB fg, RGB bg, double scale) {
* @return the grey-scale value
*/
private static double greyLevel(RGB rgb) {
- if (rgb.red == rgb.green && rgb.green == rgb.blue)
+ if (rgb.red == rgb.green && rgb.green == rgb.blue) {
return rgb.red;
+ }
return (0.299 * rgb.red + 0.587 * rgb.green + 0.114 * rgb.blue + 0.5);
}
@@ -516,8 +533,9 @@ private static boolean isDark(RGB rgb) {
* @since 3.3
*/
public boolean hasInformation() {
- if (fLineDiffer instanceof ILineDifferExtension2)
+ if (fLineDiffer instanceof ILineDifferExtension2) {
return !((ILineDifferExtension2) fLineDiffer).isSuspended();
+ }
return fLineDiffer != null;
}