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 @@ -91,11 +91,9 @@ private boolean isCaptionLine(Position position, IDocument document, int line) {
private String getProjectionTextAtLine(ISourceViewer viewer, int line, int numberOfLines) {

IAnnotationModel model= null;
if (viewer instanceof ISourceViewerExtension2) {
ISourceViewerExtension2 viewerExtension= (ISourceViewerExtension2) viewer;
if (viewer instanceof ISourceViewerExtension2 viewerExtension) {
IAnnotationModel visual= viewerExtension.getVisualAnnotationModel();
if (visual instanceof IAnnotationModelExtension) {
IAnnotationModelExtension modelExtension= (IAnnotationModelExtension) visual;
if (visual instanceof IAnnotationModelExtension modelExtension) {
model= modelExtension.getAnnotationModel(ProjectionSupport.PROJECTION);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public ProjectionAnnotationModel() {
* @param annotation the annotation
*/
public void collapse(Annotation annotation) {
if (annotation instanceof ProjectionAnnotation) {
ProjectionAnnotation projection= (ProjectionAnnotation) annotation;
if (annotation instanceof ProjectionAnnotation projection) {
if (!projection.isCollapsed()) {
projection.markCollapsed();
modifyAnnotation(projection, true);
Expand All @@ -64,8 +63,7 @@ public void collapse(Annotation annotation) {
* @param annotation the annotation
*/
public void expand(Annotation annotation) {
if (annotation instanceof ProjectionAnnotation) {
ProjectionAnnotation projection= (ProjectionAnnotation) annotation;
if (annotation instanceof ProjectionAnnotation projection) {
if (projection.isCollapsed()) {
projection.markExpanded();
modifyAnnotation(projection, true);
Expand All @@ -80,9 +78,7 @@ public void expand(Annotation annotation) {
* @param annotation the annotation
*/
public void toggleExpansionState(Annotation annotation) {
if (annotation instanceof ProjectionAnnotation) {
ProjectionAnnotation projection= (ProjectionAnnotation) annotation;

if (annotation instanceof ProjectionAnnotation projection) {
if (projection.isCollapsed())
projection.markExpanded();
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ private ProjectionAnnotation findAnnotation(int line, boolean exact) {
Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
Object next= e.next();
if (next instanceof ProjectionAnnotation) {
ProjectionAnnotation annotation= (ProjectionAnnotation) next;
if (next instanceof ProjectionAnnotation annotation) {
Position p= model.getPosition(annotation);
if (p == null)
continue;
Expand Down Expand Up @@ -235,8 +234,7 @@ public void mouseExit(MouseEvent e) {

@Override
public void setModel(IAnnotationModel model) {
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension extension= (IAnnotationModelExtension) model;
if (model instanceof IAnnotationModelExtension extension) {
model= extension.getAnnotationModel(ProjectionSupport.PROJECTION);
}
super.setModel(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ private void createSummaries(IProgressMonitor monitor, IAnnotationModel visualAn
}

if (!additions.isEmpty()) {
if (visualAnnotationModel instanceof IAnnotationModelExtension) {
IAnnotationModelExtension extension= (IAnnotationModelExtension)visualAnnotationModel;
if (visualAnnotationModel instanceof IAnnotationModelExtension extension) {
if (!isCanceled(monitor))
extension.replaceAnnotations(null, additions);
} else {
Expand Down Expand Up @@ -279,8 +278,7 @@ private void createSummary(Map<Annotation, Position> additions, IRegion[] summar

private AnnotationBag findBagForType(Map<String, AnnotationBag> bagMap, String annotationType) {
AnnotationBag bag= bagMap.get(annotationType);
if (bag == null && fAnnotationAccess instanceof IAnnotationAccessExtension) {
IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
if (bag == null && fAnnotationAccess instanceof IAnnotationAccessExtension extension) {
Object[] superTypes= extension.getSupertypes(annotationType);
for (int i= 0; i < superTypes.length && bag == null; i++) {
bag= bagMap.get(superTypes[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public ProjectionAnnotationsPainter(ISourceViewer sourceViewer, IAnnotationAcces

@Override
protected IAnnotationModel findAnnotationModel(ISourceViewer sourceViewer) {
if (sourceViewer instanceof ProjectionViewer) {
ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer;
if (sourceViewer instanceof ProjectionViewer projectionViewer) {
return projectionViewer.getProjectionAnnotationModel();
}
return null;
Expand All @@ -84,8 +83,7 @@ protected boolean skip(Annotation annotation) {
private static class ProjectionDrawingStrategy implements AnnotationPainter.IDrawingStrategy {
@Override
public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) {
if (annotation instanceof ProjectionAnnotation) {
ProjectionAnnotation projectionAnnotation= (ProjectionAnnotation) annotation;
if (annotation instanceof ProjectionAnnotation projectionAnnotation) {
if (projectionAnnotation.isCollapsed()) {

if (gc != null) {
Expand Down Expand Up @@ -351,8 +349,7 @@ private IAnnotationHover createProjectionAnnotationHover() {
@SuppressWarnings("unchecked")
public <T> T getAdapter(ISourceViewer viewer, Class<T> required) {
if (ProjectionAnnotationModel.class.equals(required)) {
if (viewer instanceof ProjectionViewer) {
ProjectionViewer projectionViewer= (ProjectionViewer) viewer;
if (viewer instanceof ProjectionViewer projectionViewer) {
return (T) projectionViewer.getProjectionAnnotationModel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,7 @@ public void setProjectionSummary(ProjectionSummary projectionSummary) {
* @param model the model to which the projection annotation model is added
*/
private void addProjectionAnnotationModel(IAnnotationModel model) {
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension extension= (IAnnotationModelExtension) model;
if (model instanceof IAnnotationModelExtension extension) {
extension.addAnnotationModel(ProjectionSupport.PROJECTION, fProjectionAnnotationModel);
model.addAnnotationModelListener(fAnnotationModelListener);
}
Expand All @@ -344,9 +343,8 @@ private void addProjectionAnnotationModel(IAnnotationModel model) {
* @return the removed projection annotation model or <code>null</code> if there was none
*/
private IAnnotationModel removeProjectionAnnotationModel(IAnnotationModel model) {
if (model instanceof IAnnotationModelExtension) {
if (model instanceof IAnnotationModelExtension extension) {
model.removeAnnotationModelListener(fAnnotationModelListener);
IAnnotationModelExtension extension= (IAnnotationModelExtension) model;
return extension.removeAnnotationModel(ProjectionSupport.PROJECTION);
}
return null;
Expand Down Expand Up @@ -387,8 +385,7 @@ protected IAnnotationModel createVisualAnnotationModel(IAnnotationModel annotati
*/
public ProjectionAnnotationModel getProjectionAnnotationModel() {
IAnnotationModel model= getVisualAnnotationModel();
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension extension= (IAnnotationModelExtension) model;
if (model instanceof IAnnotationModelExtension extension) {
return (ProjectionAnnotationModel) extension.getAnnotationModel(ProjectionSupport.PROJECTION);
}
return null;
Expand All @@ -401,9 +398,7 @@ protected ISlaveDocumentManager createSlaveDocumentManager() {

@Override
protected boolean updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) throws BadLocationException {
if (slaveDocument instanceof ProjectionDocument) {
ProjectionDocument projection= (ProjectionDocument) slaveDocument;

if (slaveDocument instanceof ProjectionDocument projection) {
int offset= modelRangeOffset;
int length= modelRangeLength;

Expand Down Expand Up @@ -814,9 +809,7 @@ private void collapse(int offset, int length, boolean fireRedraw) throws BadLoca
*/
private void expand(int offset, int length, boolean fireRedraw) throws BadLocationException {
IDocument slave= getVisibleDocument();
if (slave instanceof ProjectionDocument) {
ProjectionDocument projection= (ProjectionDocument) slave;

if (slave instanceof ProjectionDocument projection) {
// expand
addMasterDocumentRange(projection, offset, length);

Expand Down Expand Up @@ -1100,8 +1093,7 @@ IRegion[] computeCollapsedRegions(Position position) {
if (document == null)
return null;

if (position instanceof IProjectionPosition) {
IProjectionPosition projPosition= (IProjectionPosition) position;
if (position instanceof IProjectionPosition projPosition) {
return projPosition.computeProjectionRegions(document);
}

Expand Down Expand Up @@ -1308,9 +1300,7 @@ protected void handleDispose() {
*/
@Override
protected void handleVisibleDocumentChanged(DocumentEvent event) {
if (fHandleProjectionChanges && event instanceof ProjectionDocumentEvent && isProjectionMode()) {
ProjectionDocumentEvent e= (ProjectionDocumentEvent) event;

if (fHandleProjectionChanges && event instanceof ProjectionDocumentEvent e && isProjectionMode()) {
DocumentEvent master= e.getMasterEvent();
if (master != null)
fReplaceVisibleDocumentExecutionTrigger= master.getDocument();
Expand Down Expand Up @@ -1355,8 +1345,7 @@ public IRegion[] getCoveredModelRanges(IRegion modelRange) {
if (fInformationMapping == null)
return new IRegion[] { new Region(modelRange.getOffset(), modelRange.getLength()) };

if (fInformationMapping instanceof IDocumentInformationMappingExtension) {
IDocumentInformationMappingExtension extension= (IDocumentInformationMappingExtension) fInformationMapping;
if (fInformationMapping instanceof IDocumentInformationMappingExtension extension) {
try {
return extension.getExactCoverage(modelRange);
} catch (BadLocationException x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ public void showInformationControl(Rectangle subjectArea, Object information) {
private Rectangle computeBoundsFromContent(IInformationControl informationControl, Rectangle controlBounds) {
Rectangle result= Geometry.copy(controlBounds);

if (informationControl instanceof IInformationControlExtension3) {
IInformationControlExtension3 iControl3= (IInformationControlExtension3) informationControl;
if (informationControl instanceof IInformationControlExtension3 iControl3) {
Rectangle trim= iControl3.computeTrim();
result= Geometry.add(result, trim);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,7 @@ private int visualSizeIncrement(char character, int visual) {
*/
public SelectionProcessor(ITextViewer viewer) {
this(viewer.getDocument(), viewer.getTextWidget().getTabs());
if (viewer instanceof ITextViewerExtension) {
ITextViewerExtension ext= (ITextViewerExtension)viewer;
if (viewer instanceof ITextViewerExtension ext) {
fRewriteTarget= ext.getRewriteTarget();
}
fSelectionProvider= viewer.getSelectionProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,8 @@ public void handleEvent(Event event) {
return;

IInformationControl infoControl= getCurrentInformationControl2();
if (infoControl != null && !infoControl.isFocusControl() && infoControl instanceof IInformationControlExtension3) {
if (infoControl != null && !infoControl.isFocusControl() && infoControl instanceof IInformationControlExtension3 iControl3) {
// if (DEBUG) System.out.println("StickyHoverManager.Closer.handleEvent(): activeShell= " + fDisplay.getActiveShell()); //$NON-NLS-1$
IInformationControlExtension3 iControl3= (IInformationControlExtension3) infoControl;
Rectangle controlBounds= iControl3.getBounds();
if (controlBounds != null) {
Point mouseLoc= event.display.map((Control) event.widget, null, event.x, event.y);
Expand Down Expand Up @@ -319,8 +318,7 @@ public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) {
@Override
public boolean setFocus(IWidgetTokenOwner owner) {
IInformationControl iControl= getCurrentInformationControl2();
if (iControl instanceof IInformationControlExtension5) {
IInformationControlExtension5 iControl5= (IInformationControlExtension5) iControl;
if (iControl instanceof IInformationControlExtension5 iControl5) {
if (iControl5.isVisible()) {
iControl.setFocus();
return iControl.isFocusControl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,7 @@ public void markDeleted(boolean deleted) {
@Override
public void draw(GC gc, StyledText textWidget, int offset, int length, Color color, int x, int y) {
int singleLineHeight= super.getHeight();
CodeMiningLineHeaderAnnotation.draw(fMinings, fBounds, singleLineHeight, fResolvedMinings, gc, textWidget, color, x, y, new Runnable() {

@Override
public void run() {
redraw();
}
});
CodeMiningLineHeaderAnnotation.draw(fMinings, fBounds, singleLineHeight, fResolvedMinings, gc, textWidget, color, x, y, this::redraw);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,7 @@ static void disposeMinings(List<ICodeMining> minings) {
@Override
public void draw(GC gc, StyledText textWidget, int offset, int length, Color color, int x, int y) {
int singleLineHeight= super.getHeight();
draw(fMinings, fBounds, singleLineHeight, fResolvedMinings, gc, textWidget, color, x, y, new Runnable() {

@Override
public void run() {
redraw();
}
});
draw(fMinings, fBounds, singleLineHeight, fResolvedMinings, gc, textWidget, color, x, y, this::redraw);
}

static void draw(List<ICodeMining> pMinings, List<Rectangle> fBounds, int singleLineHeight, ICodeMining[] fResolvedMinings, GC gc, StyledText textWidget, Color color,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ protected void computeInformation() {
String information= null;
Object d= item.getData();

if (d instanceof ICompletionProposal) {
ICompletionProposal p= (ICompletionProposal) d;
if (d instanceof ICompletionProposal p) {
information= p.getAdditionalProposalInfo();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ private void insertProposal(ICompletionProposal p, char trigger, int stateMask,

IDocument document= fViewer.getDocument();

if (fViewer instanceof ITextViewerExtension) {
ITextViewerExtension extension= (ITextViewerExtension) fViewer;
if (fViewer instanceof ITextViewerExtension extension) {
target= extension.getRewriteTarget();
}

Expand All @@ -406,11 +405,9 @@ private void insertProposal(ICompletionProposal p, char trigger, int stateMask,
registry.register(fModificationEditingSupport);
}

if (p instanceof ICompletionProposalExtension2) {
ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p;
if (p instanceof ICompletionProposalExtension2 e) {
e.apply(fViewer, trigger, stateMask, offset);
} else if (p instanceof ICompletionProposalExtension) {
ICompletionProposalExtension e= (ICompletionProposalExtension) p;
} else if (p instanceof ICompletionProposalExtension e) {
e.apply(document, trigger, offset);
} else {
p.apply(document);
Expand All @@ -426,8 +423,7 @@ private void insertProposal(ICompletionProposal p, char trigger, int stateMask,
if (info != null) {

int position;
if (p instanceof ICompletionProposalExtension) {
ICompletionProposalExtension e= (ICompletionProposalExtension) p;
if (p instanceof ICompletionProposalExtension e) {
position= e.getContextInformationPosition();
} else {
if (selection == null)
Expand Down Expand Up @@ -470,8 +466,7 @@ public void hide() {

unregister();

if (fViewer instanceof IEditingSupportRegistry) {
IEditingSupportRegistry registry= (IEditingSupportRegistry) fViewer;
if (fViewer instanceof IEditingSupportRegistry registry) {
registry.unregister(fFocusEditingSupport);
}

Expand Down Expand Up @@ -504,8 +499,7 @@ private void unregister() {
styledText.removeKeyListener(fKeyListener);

if (fLastProposal != null) {
if (fLastProposal instanceof ICompletionProposalExtension2) {
ICompletionProposalExtension2 extension= (ICompletionProposalExtension2) fLastProposal;
if (fLastProposal instanceof ICompletionProposalExtension2 extension) {
extension.unselected(fViewer);
}

Expand Down Expand Up @@ -629,12 +623,10 @@ private int getTableHeightHint(Table table, int rows) {

private boolean validateProposal(IDocument document, ICompletionProposal p, int offset, DocumentEvent event) {
// detect selected
if (p instanceof ICompletionProposalExtension2) {
ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p;
if (p instanceof ICompletionProposalExtension2 e) {
if (e.validate(document, offset, event))
return true;
} else if (p instanceof ICompletionProposalExtension) {
ICompletionProposalExtension e= (ICompletionProposalExtension) p;
} else if (p instanceof ICompletionProposalExtension e) {
if (e.isValidFor(document, offset))
return true;
}
Expand Down Expand Up @@ -684,8 +676,7 @@ public void documentChanged(DocumentEvent event) {
document.addDocumentListener(fDocumentListener);


if (fViewer instanceof IEditingSupportRegistry) {
IEditingSupportRegistry registry= (IEditingSupportRegistry) fViewer;
if (fViewer instanceof IEditingSupportRegistry registry) {
registry.register(fFocusEditingSupport);
}

Expand Down Expand Up @@ -787,8 +778,7 @@ public boolean verifyKey(VerifyEvent e) {

default:
ICompletionProposal p= getSelectedProposal();
if (p instanceof ICompletionProposalExtension) {
ICompletionProposalExtension t= (ICompletionProposalExtension) p;
if (p instanceof ICompletionProposalExtension t) {
char[] triggers= t.getTriggerCharacters();
if (contains(triggers, key)) {
hide();
Expand Down Expand Up @@ -931,15 +921,13 @@ private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent
List<Object> filtered= new ArrayList<>(length);
for (int i= 0; i < length; i++) {

if (proposals[i] instanceof ICompletionProposalExtension2) {
if (proposals[i] instanceof ICompletionProposalExtension2 p) {

ICompletionProposalExtension2 p= (ICompletionProposalExtension2) proposals[i];
if (p.validate(document, offset, event))
filtered.add(p);

} else if (proposals[i] instanceof ICompletionProposalExtension) {
} else if (proposals[i] instanceof ICompletionProposalExtension p) {

ICompletionProposalExtension p= (ICompletionProposalExtension) proposals[i];
if (p.isValidFor(document, offset))
filtered.add(p);

Expand Down
Loading
Loading