4343import java .util .logging .Level ;
4444import javax .swing .text .BadLocationException ;
4545import javax .swing .text .Document ;
46- import java .util .HashSet ;
4746import java .util .List ;
4847import java .util .Map ;
4948import java .util .Set ;
@@ -514,14 +513,13 @@ private static int findBodyStartImpl(CompilationInfo info, Tree cltree, Compilat
514513
515514 public static int findBodyStart (final CompilationInfo info , final Tree cltree , final CompilationUnitTree cu , final SourcePositions positions , final Document doc ) {
516515 Kind kind = cltree .getKind ();
517- if (!TreeUtilities .CLASS_TREE_KINDS .contains (kind ) && kind != Kind .METHOD && ! cltree . getKind (). toString (). equals ( "RECORD" ))
516+ if (!TreeUtilities .CLASS_TREE_KINDS .contains (kind ) && kind != Kind .METHOD ) {
518517 throw new IllegalArgumentException ("Unsupported kind: " + kind );
518+ }
519519 final int [] result = new int [1 ];
520520
521- doc .render (new Runnable () {
522- public void run () {
523- result [0 ] = findBodyStartImpl (info , cltree , cu , positions , doc );
524- }
521+ doc .render (() -> {
522+ result [0 ] = findBodyStartImpl (info , cltree , cu , positions , doc );
525523 });
526524
527525 return result [0 ];
@@ -562,10 +560,8 @@ private static int findLastBracketImpl(Tree tree, CompilationUnitTree cu, Source
562560 public static int findLastBracket (final Tree tree , final CompilationUnitTree cu , final SourcePositions positions , final Document doc ) {
563561 final int [] result = new int [1 ];
564562
565- doc .render (new Runnable () {
566- public void run () {
567- result [0 ] = findLastBracketImpl (tree , cu , positions , doc );
568- }
563+ doc .render (() -> {
564+ result [0 ] = findLastBracketImpl (tree , cu , positions , doc );
569565 });
570566
571567 return result [0 ];
@@ -579,7 +575,7 @@ private static Token<JavaTokenId> createHighlightImpl(CompilationInfo info, Docu
579575 //XXX: do not use instanceof:
580576 if (leaf instanceof MethodTree || leaf instanceof VariableTree || leaf instanceof ClassTree
581577 || leaf instanceof MemberSelectTree || leaf instanceof AnnotatedTypeTree || leaf instanceof MemberReferenceTree
582- || "BINDING_PATTERN" . equals ( leaf .getKind (). name ()) ) {
578+ || leaf .getKind () == Kind . BINDING_PATTERN ) {
583579 return findIdentifierSpan (info , doc , tree );
584580 }
585581
@@ -617,34 +613,16 @@ public static Token<JavaTokenId> getToken(final CompilationInfo info, final Docu
617613 @ SuppressWarnings ("unchecked" )
618614 final Token <JavaTokenId >[] result = new Token [1 ];
619615
620- doc .render (new Runnable () {
621- public void run () {
622- result [0 ] = createHighlightImpl (info , doc , tree );
623- }
616+ doc .render (() -> {
617+ result [0 ] = createHighlightImpl (info , doc , tree );
624618 });
625619
626620 return result [0 ];
627621 }
628622
629- private static final Set <String > keywords ;
630- private static final Set <String > nonCtorKeywords ;
631-
632- static {
633- keywords = new HashSet <String >();
634-
635- keywords .add ("true" );
636- keywords .add ("false" );
637- keywords .add ("null" );
638- keywords .add ("this" );
639- keywords .add ("super" );
640- keywords .add ("class" );
623+ private static final Set <String > keywords = Set .of ("true" , "false" , "null" , "this" , "super" , "class" );
624+ private static final Set <String > nonCtorKeywords = Set .of ("true" , "false" , "null" , "class" );
641625
642- nonCtorKeywords = new HashSet <String >(keywords );
643- nonCtorKeywords .remove ("this" );
644- nonCtorKeywords .remove ("super" );
645-
646- }
647-
648626 public static boolean isKeyword (Tree tree ) {
649627 if (tree .getKind () == Kind .IDENTIFIER ) {
650628 return keywords .contains (((IdentifierTree ) tree ).getName ().toString ());
0 commit comments