@@ -310,14 +310,12 @@ protected IStatus run(IProgressMonitor monitor) {
310310
311311 static IStatus doToggleLambdaEntryMethodBreakpoints (IWorkbenchPart part , ISelection selection , String lambdaMethodName , String lambdaMethodSignature , LambdaProperties lambdaProperties , IProgressMonitor monitor ) throws CoreException {
312312 ITextEditor textEditor = getTextEditor (part );
313- if (textEditor == null || !(selection instanceof ITextSelection )) {
313+ if (textEditor == null || !(selection instanceof ITextSelection textSelection )) {
314314 return Status .OK_STATUS ;
315315 }
316- ITextSelection textSelection = (ITextSelection ) selection ;
317316 IEditorInput editorInput = textEditor .getEditorInput ();
318317 ITypeRoot root = getTypeRoot (editorInput );
319- if (root instanceof ICompilationUnit ) {
320- ICompilationUnit unit = (ICompilationUnit ) root ;
318+ if (root instanceof ICompilationUnit unit ) {
321319 synchronized (unit ) {
322320 unit .reconcile (ICompilationUnit .NO_AST , false , null , null );
323321 }
@@ -345,14 +343,12 @@ static IStatus doToggleLambdaEntryMethodBreakpoints(IWorkbenchPart part, ISelect
345343
346344 static IStatus doToggleLambdaMethodBreakpoints (IWorkbenchPart part , ISelection selection , ValidBreakpointLocationLocator loc , IProgressMonitor monitor ) throws CoreException {
347345 ITextEditor textEditor = getTextEditor (part );
348- if (textEditor == null || !(selection instanceof ITextSelection )) {
346+ if (textEditor == null || !(selection instanceof ITextSelection textSelection )) {
349347 return Status .OK_STATUS ;
350348 }
351- ITextSelection textSelection = (ITextSelection ) selection ;
352349 IEditorInput editorInput = textEditor .getEditorInput ();
353350 ITypeRoot root = getTypeRoot (editorInput );
354- if (root instanceof ICompilationUnit ) {
355- ICompilationUnit unit = (ICompilationUnit ) root ;
351+ if (root instanceof ICompilationUnit unit ) {
356352 synchronized (unit ) {
357353 unit .reconcile (ICompilationUnit .NO_AST , false , null , null );
358354 }
@@ -859,8 +855,7 @@ public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection select
859855 if (isRemote (part , selection )) {
860856 return false ;
861857 }
862- if (selection instanceof IStructuredSelection ) {
863- IStructuredSelection ss = (IStructuredSelection ) selection ;
858+ if (selection instanceof IStructuredSelection ss ) {
864859 return getMethods (ss , isInterface (selection , part )).length > 0 ;
865860 }
866861 return (selection instanceof ITextSelection ) && isMethod ((ITextSelection ) selection , part );
@@ -870,11 +865,9 @@ public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection select
870865 * Returns whether the given part/selection is remote (viewing a repository)
871866 */
872867 protected static boolean isRemote (IWorkbenchPart part , ISelection selection ) {
873- if (selection instanceof IStructuredSelection ) {
874- IStructuredSelection ss = (IStructuredSelection ) selection ;
868+ if (selection instanceof IStructuredSelection ss ) {
875869 Object element = ss .getFirstElement ();
876- if (element instanceof IMember ) {
877- IMember member = (IMember ) element ;
870+ if (element instanceof IMember member ) {
878871 return !member .getJavaProject ().getProject ().exists ();
879872 }
880873 }
@@ -916,8 +909,7 @@ protected static IMethod[] getMethods(IStructuredSelection selection, boolean is
916909 while (iterator .hasNext ()) {
917910 Object thing = iterator .next ();
918911 try {
919- if (thing instanceof IMethod ) {
920- IMethod method = (IMethod ) thing ;
912+ if (thing instanceof IMethod method ) {
921913 if (isInterace ){
922914 if (Flags .isDefaultMethod (method .getFlags ()) || Flags .isStatic (method .getFlags ())) {
923915 methods .add (method );
@@ -947,8 +939,7 @@ protected static IMethod[] getInterfaceMethods(IStructuredSelection selection) {
947939 while (iterator .hasNext ()) {
948940 Object thing = iterator .next ();
949941 try {
950- if (thing instanceof IMethod ) {
951- IMethod method = (IMethod ) thing ;
942+ if (thing instanceof IMethod method ) {
952943 if (Flags .isDefaultMethod (method .getFlags ())) {
953944 methods .add (method );
954945 }
@@ -1044,8 +1035,7 @@ private static boolean isInterface(ISelection selection, IWorkbenchPart part) {
10441035 IType type = member .getDeclaringType ();
10451036 return type != null && type .isInterface ();
10461037 }
1047- else if (obj instanceof IJavaFieldVariable ) {
1048- IJavaFieldVariable var = (IJavaFieldVariable ) obj ;
1038+ else if (obj instanceof IJavaFieldVariable var ) {
10491039 IType type = JavaDebugUtils .resolveType (var .getDeclaringType ());
10501040 return type != null && type .isInterface ();
10511041 }
@@ -1099,8 +1089,7 @@ private static boolean isFields(IStructuredSelection selection) {
10991089 if (thing instanceof IField ) {
11001090 int flags = ((IField ) thing ).getFlags ();
11011091 return !Flags .isFinal (flags );
1102- } else if (thing instanceof IJavaFieldVariable ) {
1103- IJavaFieldVariable fv = (IJavaFieldVariable ) thing ;
1092+ } else if (thing instanceof IJavaFieldVariable fv ) {
11041093 return !fv .isFinal ();
11051094 }
11061095 }
@@ -1167,8 +1156,7 @@ static IStatus doToggleWatchpoints(IWorkbenchPart part, ISelection finalSelectio
11671156 fin = javaField .getConstant () != null ; // watch point is allowed if no constant value
11681157 }
11691158 allowed = !fin ;
1170- } else if (element instanceof IJavaFieldVariable ) {
1171- IJavaFieldVariable var = (IJavaFieldVariable ) element ;
1159+ } else if (element instanceof IJavaFieldVariable var ) {
11721160 typeName = var .getDeclaringType ().getName ();
11731161 fieldName = var .getName ();
11741162 boolean fin = var .isFinal ();
@@ -1233,8 +1221,7 @@ private static IJavaWatchpoint getWatchpoint(String typeName, String fieldName)
12331221 IBreakpoint [] breakpoints = breakpointManager .getBreakpoints (JDIDebugModel .getPluginIdentifier ());
12341222 for (int i = 0 ; i < breakpoints .length ; i ++) {
12351223 IBreakpoint breakpoint = breakpoints [i ];
1236- if (breakpoint instanceof IJavaWatchpoint ) {
1237- IJavaWatchpoint watchpoint = (IJavaWatchpoint ) breakpoint ;
1224+ if (breakpoint instanceof IJavaWatchpoint watchpoint ) {
12381225 if (typeName .equals (watchpoint .getTypeName ()) && fieldName .equals (watchpoint .getFieldName ())) {
12391226 return watchpoint ;
12401227 }
@@ -1448,8 +1435,7 @@ public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) {
14481435 if (isRemote (part , selection )) {
14491436 return false ;
14501437 }
1451- if (selection instanceof IStructuredSelection ) {
1452- IStructuredSelection ss = (IStructuredSelection ) selection ;
1438+ if (selection instanceof IStructuredSelection ss ) {
14531439 return isFields (ss );
14541440 }
14551441 return (selection instanceof ITextSelection ) && isField ((ITextSelection ) selection , part );
@@ -1466,10 +1452,9 @@ public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) {
14661452 */
14671453 protected static ISelection translateToMembers (IWorkbenchPart part , ISelection selection ) throws CoreException {
14681454 ITextEditor textEditor = getTextEditor (part );
1469- if (textEditor == null || !(selection instanceof ITextSelection )) {
1455+ if (textEditor == null || !(selection instanceof ITextSelection textSelection )) {
14701456 return selection ;
14711457 }
1472- ITextSelection textSelection = (ITextSelection ) selection ;
14731458 IEditorInput editorInput = textEditor .getEditorInput ();
14741459 IDocumentProvider documentProvider = textEditor .getDocumentProvider ();
14751460 if (documentProvider == null ) {
@@ -1489,8 +1474,7 @@ protected static ISelection translateToMembers(IWorkbenchPart part, ISelection s
14891474 }
14901475 IMember m = null ;
14911476 ITypeRoot root = getTypeRoot (editorInput );
1492- if (root instanceof ICompilationUnit ) {
1493- ICompilationUnit unit = (ICompilationUnit ) root ;
1477+ if (root instanceof ICompilationUnit unit ) {
14941478 synchronized (unit ) {
14951479 unit .reconcile (ICompilationUnit .NO_AST , false , null , null );
14961480 }
@@ -1502,8 +1486,7 @@ protected static ISelection translateToMembers(IWorkbenchPart part, ISelection s
15021486 }
15031487 // Class breakpoint should be created if the offset was at the record component in the record definition
15041488 if (m != null && m .getParent () instanceof IType && ((IType ) m .getParent ()).isRecord ()) {
1505- if (m instanceof IField ) {
1506- IField field = (IField )m ;
1489+ if (m instanceof IField field ) {
15071490 if (field .isRecordComponent ()) {
15081491 m = (IMember ) field .getParent ();
15091492 }
@@ -1597,10 +1580,9 @@ public static IJavaLineBreakpoint findExistingBreakpoint(ITextEditor editor, ITe
15971580 Iterator <Annotation > iterator = annotationModel .getAnnotationIterator ();
15981581 while (iterator .hasNext ()) {
15991582 Object object = iterator .next ();
1600- if (!(object instanceof SimpleMarkerAnnotation )) {
1583+ if (!(object instanceof SimpleMarkerAnnotation markerAnnotation )) {
16011584 continue ;
16021585 }
1603- SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation ) object ;
16041586 IMarker marker = markerAnnotation .getMarker ();
16051587 try {
16061588 if (marker .isSubtypeOf (IBreakpoint .BREAKPOINT_MARKER )) {
@@ -1623,10 +1605,9 @@ public static IJavaLineBreakpoint findExistingBreakpoint(ITextEditor editor, ITe
16231605 }
16241606
16251607 private void toggleFieldOrMethodBreakpoints (IWorkbenchPart part , ISelection selection ) throws CoreException {
1626- if (!(selection instanceof ITextSelection )) {
1608+ if (!(selection instanceof ITextSelection ts )) {
16271609 return ;
16281610 }
1629- ITextSelection ts = (ITextSelection ) selection ;
16301611 ITextEditor editor = getTextEditor (part );
16311612 if (editor == null ) {
16321613 return ;
0 commit comments