@@ -188,6 +188,7 @@ non-sealed class C extends A {}
188188 assertEquals ("'non-sealed' modifier is not set in binding" , Modifier .isNonSealed (aBinding .getModifiers ()), true );
189189 }
190190
191+ //public sealed
191192 public void test003_c () throws CoreException {
192193 ASTParser astParser = ASTParser .newParser (getAST23 ());
193194 Map <String , String > options = new HashMap <>();
@@ -212,10 +213,222 @@ non-sealed class C extends A {}
212213 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
213214
214215 assertEquals ("Modifier is not present in AST" , Modifier .isSealed (a .getModifiers ()), true );
216+ assertEquals ("Modifier is not present in AST" , Modifier .isPublic (a .getModifiers ()), true );
215217
216218 assertEquals ("permitted types are not present in AST" , a .permittedTypes ().size (), 2 );
217219
218220 ITypeBinding aBinding = a .resolveBinding ();
219221 assertEquals ("'sealed' modifier is not set in binding" , Modifier .isSealed (aBinding .getModifiers ()), true );
222+ assertEquals ("'public' modifier is not set in binding" , Modifier .isPublic (aBinding .getModifiers ()), true );
223+ }
224+
225+ //abstract final
226+ public void test003_d () throws CoreException {
227+ ASTParser astParser = ASTParser .newParser (getAST23 ());
228+ Map <String , String > options = new HashMap <>();
229+ options .put (JavaCore .COMPILER_COMPLIANCE , "23" );
230+ options .put (JavaCore .COMPILER_SOURCE , "23" );
231+
232+ astParser .setCompilerOptions (options );
233+ astParser .setEnvironment (new String [] {}, new String [] {}, new String [] {}, true );
234+ astParser .setUnitName ("Example.java" );
235+ astParser .setResolveBindings (true );
236+ astParser .setBindingsRecovery (true );
237+
238+ String source = """
239+ abstract final class A {}
240+ """ ;
241+ astParser .setSource (source .toCharArray ());
242+
243+ CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
244+ TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
245+
246+ assertEquals ("Modifier is not present in AST" , Modifier .isAbstract (a .getModifiers ()), true );
247+ assertEquals ("Modifier is not present in AST" , Modifier .isFinal (a .getModifiers ()), true );
248+
249+ ITypeBinding aBinding = a .resolveBinding ();
250+
251+ assertEquals ("'abstract' modifier is not set in binding" , Modifier .isAbstract (aBinding .getModifiers ()), true );
252+ assertEquals ("'final' modifier is not set in binding" , Modifier .isFinal (aBinding .getModifiers ()), true );
253+ }
254+
255+ //abstract non-sealed
256+ public void test003_e () throws CoreException {
257+ ASTParser astParser = ASTParser .newParser (getAST23 ());
258+ Map <String , String > options = new HashMap <>();
259+ options .put (JavaCore .COMPILER_COMPLIANCE , "23" );
260+ options .put (JavaCore .COMPILER_SOURCE , "23" );
261+
262+ astParser .setCompilerOptions (options );
263+ astParser .setEnvironment (new String [] {}, new String [] {}, new String [] {}, true );
264+ astParser .setUnitName ("Example.java" );
265+ astParser .setResolveBindings (true );
266+ astParser .setBindingsRecovery (true );
267+
268+ String source = """
269+ abstract non-sealed class A {}
270+ """ ;
271+ astParser .setSource (source .toCharArray ());
272+
273+ CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
274+ TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
275+
276+ assertEquals ("Modifier is not present in AST" , Modifier .isAbstract (a .getModifiers ()), true );
277+ assertEquals ("Modifier is not present in AST" , Modifier .isNonSealed (a .getModifiers ()), true );
278+
279+ ITypeBinding aBinding = a .resolveBinding ();
280+
281+ assertEquals ("'abstract' modifier is not set in binding" , Modifier .isAbstract (aBinding .getModifiers ()), true );
282+ assertEquals ("'non-sealed' modifier is not set in binding" , Modifier .isNonSealed (aBinding .getModifiers ()), true );
283+ }
284+
285+ //public final
286+ public void test003_f () throws CoreException {
287+ ASTParser astParser = ASTParser .newParser (getAST23 ());
288+ Map <String , String > options = new HashMap <>();
289+ options .put (JavaCore .COMPILER_COMPLIANCE , "23" );
290+ options .put (JavaCore .COMPILER_SOURCE , "23" );
291+
292+ astParser .setCompilerOptions (options );
293+ astParser .setEnvironment (new String [] {}, new String [] {}, new String [] {}, true );
294+ astParser .setUnitName ("Example.java" );
295+ astParser .setResolveBindings (true );
296+ astParser .setBindingsRecovery (true );
297+
298+ String source = """
299+ public final class A {}
300+ """ ;
301+ astParser .setSource (source .toCharArray ());
302+
303+ CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
304+ TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
305+
306+ assertEquals ("Modifier is not present in AST" , Modifier .isPublic (a .getModifiers ()), true );
307+ assertEquals ("Modifier is not present in AST" , Modifier .isFinal (a .getModifiers ()), true );
308+
309+ ITypeBinding aBinding = a .resolveBinding ();
310+
311+ assertEquals ("'public' modifier is not set in binding" , Modifier .isPublic (aBinding .getModifiers ()), true );
312+ assertEquals ("'final' modifier is not set in binding" , Modifier .isFinal (aBinding .getModifiers ()), true );
313+ }
314+
315+ //public non-sealed
316+ public void test003_g () throws CoreException {
317+ ASTParser astParser = ASTParser .newParser (getAST23 ());
318+ Map <String , String > options = new HashMap <>();
319+ options .put (JavaCore .COMPILER_COMPLIANCE , "23" );
320+ options .put (JavaCore .COMPILER_SOURCE , "23" );
321+
322+ astParser .setCompilerOptions (options );
323+ astParser .setEnvironment (new String [] {}, new String [] {}, new String [] {}, true );
324+ astParser .setUnitName ("Example.java" );
325+ astParser .setResolveBindings (true );
326+ astParser .setBindingsRecovery (true );
327+
328+ String source = """
329+ public non-sealed class A {}
330+ """ ;
331+ astParser .setSource (source .toCharArray ());
332+
333+ CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
334+ TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
335+
336+ assertEquals ("Modifier is not present in AST" , Modifier .isPublic (a .getModifiers ()), true );
337+ assertEquals ("Modifier is not present in AST" , Modifier .isNonSealed (a .getModifiers ()), true );
338+
339+ ITypeBinding aBinding = a .resolveBinding ();
340+
341+ assertEquals ("'public' modifier is not set in binding" , Modifier .isPublic (aBinding .getModifiers ()), true );
342+ assertEquals ("'final' modifier is not set in binding" , Modifier .isNonSealed (aBinding .getModifiers ()), true );
343+ }
344+
345+ //protected non-sealed
346+ public void test003_h () throws CoreException {
347+ ASTParser astParser = ASTParser .newParser (getAST23 ());
348+ Map <String , String > options = new HashMap <>();
349+ options .put (JavaCore .COMPILER_COMPLIANCE , "23" );
350+ options .put (JavaCore .COMPILER_SOURCE , "23" );
351+
352+ astParser .setCompilerOptions (options );
353+ astParser .setEnvironment (new String [] {}, new String [] {}, new String [] {}, true );
354+ astParser .setUnitName ("Example.java" );
355+ astParser .setResolveBindings (true );
356+ astParser .setBindingsRecovery (true );
357+
358+ String source = """
359+ protected non-sealed class A {}
360+ """ ;
361+ astParser .setSource (source .toCharArray ());
362+
363+ CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
364+ TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
365+
366+ assertEquals ("Modifier is not present in AST" , Modifier .isProtected (a .getModifiers ()), true );
367+ assertEquals ("Modifier is not present in AST" , Modifier .isNonSealed (a .getModifiers ()), true );
368+
369+ ITypeBinding aBinding = a .resolveBinding ();
370+
371+ assertEquals ("'public' modifier is not set in binding" , Modifier .isProtected (aBinding .getModifiers ()), true );
372+ assertEquals ("'final' modifier is not set in binding" , Modifier .isNonSealed (aBinding .getModifiers ()), true );
373+ }
374+
375+ //private non-sealed
376+ public void test003_i () throws CoreException {
377+ ASTParser astParser = ASTParser .newParser (getAST23 ());
378+ Map <String , String > options = new HashMap <>();
379+ options .put (JavaCore .COMPILER_COMPLIANCE , "23" );
380+ options .put (JavaCore .COMPILER_SOURCE , "23" );
381+
382+ astParser .setCompilerOptions (options );
383+ astParser .setEnvironment (new String [] {}, new String [] {}, new String [] {}, true );
384+ astParser .setUnitName ("Example.java" );
385+ astParser .setResolveBindings (true );
386+ astParser .setBindingsRecovery (true );
387+
388+ String source = """
389+ private non-sealed class A {}
390+ """ ;
391+ astParser .setSource (source .toCharArray ());
392+
393+ CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
394+ TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
395+
396+ assertEquals ("Modifier is not present in AST" , Modifier .isPrivate (a .getModifiers ()), true );
397+ assertEquals ("Modifier is not present in AST" , Modifier .isNonSealed (a .getModifiers ()), true );
398+
399+ ITypeBinding aBinding = a .resolveBinding ();
400+
401+ assertEquals ("'public' modifier is not set in binding" , Modifier .isPrivate (aBinding .getModifiers ()), true );
402+ assertEquals ("'final' modifier is not set in binding" , Modifier .isNonSealed (aBinding .getModifiers ()), true );
403+ }
404+
405+ //protected abstract
406+ public void test003_j () throws CoreException {
407+ ASTParser astParser = ASTParser .newParser (getAST23 ());
408+ Map <String , String > options = new HashMap <>();
409+ options .put (JavaCore .COMPILER_COMPLIANCE , "23" );
410+ options .put (JavaCore .COMPILER_SOURCE , "23" );
411+
412+ astParser .setCompilerOptions (options );
413+ astParser .setEnvironment (new String [] {}, new String [] {}, new String [] {}, true );
414+ astParser .setUnitName ("Example.java" );
415+ astParser .setResolveBindings (true );
416+ astParser .setBindingsRecovery (true );
417+
418+ String source = """
419+ protected abstract class A {}
420+ """ ;
421+ astParser .setSource (source .toCharArray ());
422+
423+ CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
424+ TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
425+
426+ assertEquals ("Modifier is not present in AST" , Modifier .isProtected (a .getModifiers ()), true );
427+ assertEquals ("Modifier is not present in AST" , Modifier .isAbstract (a .getModifiers ()), true );
428+
429+ ITypeBinding aBinding = a .resolveBinding ();
430+
431+ assertEquals ("'public' modifier is not set in binding" , Modifier .isProtected (aBinding .getModifiers ()), true );
432+ assertEquals ("'final' modifier is not set in binding" , Modifier .isAbstract (aBinding .getModifiers ()), true );
220433 }
221434}
0 commit comments