Skip to content
Merged
Show file tree
Hide file tree
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 @@ -183,12 +183,10 @@ private void initializeSearchScope() {
resetIncrementalBaseLocation();
}

if (target == null || !(target instanceof IFindReplaceTargetExtension)) {
if (target == null || !(target instanceof IFindReplaceTargetExtension extensionTarget)) {
return;
}

IFindReplaceTargetExtension extensionTarget = (IFindReplaceTargetExtension) target;

IRegion scope;
Point lineSelection = extensionTarget.getLineSelection();
scope = new Region(lineSelection.x, lineSelection.y);
Expand All @@ -204,12 +202,10 @@ private void initializeSearchScope() {
* Unsets the search scope for a "Scoped"-Search.
*/
private void unsetSearchScope() {
if (target == null || !(target instanceof IFindReplaceTargetExtension)) {
if (target == null || !(target instanceof IFindReplaceTargetExtension extensionTarget)) {
return;
}

IFindReplaceTargetExtension extensionTarget = (IFindReplaceTargetExtension) target;

extensionTarget.setScope(null);
}

Expand Down Expand Up @@ -309,8 +305,7 @@ public void performSelectAll() {
* otherwise
*/
private boolean prepareTargetForEditing() {
if (target instanceof IFindReplaceTargetExtension2) {
IFindReplaceTargetExtension2 extension = (IFindReplaceTargetExtension2) target;
if (target instanceof IFindReplaceTargetExtension2 extension) {
if (!extension.validateTargetState()) {
status = new FindStatus(FindStatus.StatusCode.READONLY);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ public boolean openFocusedAnnotationHover(IAnnotationHover annotationHover, int
try {
// compute the hover information
Object hoverInfo;
if (annotationHover instanceof IAnnotationHoverExtension) {
IAnnotationHoverExtension extension= (IAnnotationHoverExtension) annotationHover;
if (annotationHover instanceof IAnnotationHoverExtension extension) {
ILineRange hoverLineRange= extension.getHoverLineRange(fSourceViewer, line);
if (hoverLineRange == null)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ public static List<IDocument> computeDocuments(ITextEditor currentTextEditor) {

for (IEditorReference editor : editorsArray) {
IEditorPart realEditor = editor.getEditor(false);
if (realEditor instanceof ITextEditor && !realEditor.equals(currentTextEditor)) {
ITextEditor textEditor= (ITextEditor)realEditor;
if (realEditor instanceof ITextEditor textEditor && !realEditor.equals(currentTextEditor)) {
provider= textEditor.getDocumentProvider();
if (provider == null) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,18 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
return null;
}
ISelection selection = textEditor.getSelectionProvider().getSelection();
if (!(selection instanceof IBlockTextSelection)) {
if (!(selection instanceof IBlockTextSelection blockSelection)) {
return null;
}
IBlockTextSelection blockSelection = (IBlockTextSelection) selection;
IRegion[] initialRegions = ((IMultiTextSelection) blockSelection).getRegions();
IDocument document = textEditor.getDocumentProvider().getDocument(editor.getEditorInput());
if (document == null) {
return null;
}
IMultiTextSelection newSelection = new MultiTextSelection(document, initialRegions);
if (!(editor instanceof ITextEditorExtension5)) {
if (!(editor instanceof ITextEditorExtension5 ext)) {
return null;
}
ITextEditorExtension5 ext = (ITextEditorExtension5) editor;
ext.setBlockSelectionMode(false);
textEditor.getSelectionProvider().setSelection(newSelection);
return newSelection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,9 @@ private StyledText getWidget() {
}

private void setBlockSelectionMode(boolean blockSelectionMode) {
if (!(textEditor instanceof ITextEditorExtension5)) {
if (!(textEditor instanceof ITextEditorExtension5 ext)) {
return;
}
ITextEditorExtension5 ext = (ITextEditorExtension5) textEditor;
ext.setBlockSelectionMode(blockSelectionMode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1411,8 +1411,7 @@ public void connect(IDocument document) {
if (fOpenConnections == 1) {
fRightDocument= document;
fRightDocument.addDocumentListener(this);
if (document instanceof IDocumentExtension4) {
IDocumentExtension4 ext= (IDocumentExtension4) document;
if (document instanceof IDocumentExtension4 ext) {
ext.addDocumentRewriteSessionListener(fSessionListener);
}
initialize();
Expand Down Expand Up @@ -1449,8 +1448,7 @@ private void uninstall() {

if (fRightDocument != null) {
fRightDocument.removeDocumentListener(this);
if (fRightDocument instanceof IDocumentExtension4) {
IDocumentExtension4 ext= (IDocumentExtension4) fRightDocument;
if (fRightDocument instanceof IDocumentExtension4 ext) {
ext.removeDocumentRewriteSessionListener(fSessionListener);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public void run() {
if (differ == null)
return;

if (fEditor instanceof ITextEditorExtension3) {
ITextEditorExtension3 extension= (ITextEditorExtension3) fEditor;
if (fEditor instanceof ITextEditorExtension3 extension) {
IQuickDiffReferenceProvider provider= getProvider();
if (provider != null) {
provider.setActiveEditor(fEditor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public int getRangeCount() {
*/
@Override
public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) {
if (other instanceof DocEquivalenceComparator) {
DocEquivalenceComparator dec= (DocEquivalenceComparator) other;
if (other instanceof DocEquivalenceComparator dec) {
try {
Hash ourHash= getHash(thisIndex);
Hash otherHash= dec.getHash(otherIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ private StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) {
}

private IRegion modelRange2WidgetRange(IRegion region) {
if (fEditorViewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension = (ITextViewerExtension5) fEditorViewer;
if (fEditorViewer instanceof ITextViewerExtension5 extension) {
return extension.modelRange2WidgetRange(region);
}
if (fEditorViewer instanceof TextViewer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ public MultiPageMinimapPage(MultiPageEditorPart multiPageEditor) {
return;
}

if (selectedPage instanceof ITextEditor) {
if (selectedPage instanceof ITextEditor textEditor) {
// Create and show a minimap page for the given text editor page
ITextEditor textEditor = (ITextEditor) selectedPage;
minimapPage = MinimapPage.createMinimapPage(textEditor);
}
if (minimapPage != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ public ElementInfo(IDocument document, IAnnotationModel model) {
*/
@Override
public boolean equals(Object o) {
if (o instanceof ElementInfo) {
ElementInfo e= (ElementInfo) o;
if (o instanceof ElementInfo e) {
return fDocument.equals(e.fDocument);
}
return false;
Expand Down Expand Up @@ -873,8 +872,7 @@ protected void fireElementStateValidationChanged(Object element, boolean isState
Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
Object o= e.next();
if (o instanceof IElementStateListenerExtension) {
IElementStateListenerExtension l= (IElementStateListenerExtension) o;
if (o instanceof IElementStateListenerExtension l) {
l.elementStateValidationChanged(element, isStateValidated);
}
}
Expand All @@ -892,8 +890,7 @@ protected void fireElementStateChanging(Object element) {
Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
Object o= e.next();
if (o instanceof IElementStateListenerExtension) {
IElementStateListenerExtension l= (IElementStateListenerExtension) o;
if (o instanceof IElementStateListenerExtension l) {
l.elementStateChanging(element);
}
}
Expand All @@ -911,8 +908,7 @@ protected void fireElementStateChangeFailed(Object element) {
Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
Object o= e.next();
if (o instanceof IElementStateListenerExtension) {
IElementStateListenerExtension l= (IElementStateListenerExtension) o;
if (o instanceof IElementStateListenerExtension l) {
l.elementStateChangeFailed(element);
}
}
Expand Down
Loading
Loading