private static void checkObjectLiteralOrClass ( NodeTraversal t , Node n ) { Set < String > getters = new HashSet <> ( ) ; Set < String > setters = new HashSet <> ( ) ; Set < String > staticGetters = new HashSet <> ( ) ; Set < String > staticSetters = new HashSet <> ( ) ; for ( Node key = n . getFirstChild ( ) ; key != null ; key = key . getNext ( ) ) { if ( key . isEmpty ( ) || key . isComputedProp ( ) ) { continue ; } if ( key . isSpread ( ) ) { continue ; } String keyName = key . getString ( ) ; if ( ! key . isSetterDef ( ) ) { // normal property and getter cases Set < String > set = key . isStaticMember ( ) ? staticGetters : getters ; if ( ! set . add ( keyName ) ) { if ( n . isClassMembers ( ) ) { t . report ( key , DUPLICATE_CLASS_METHODS , keyName ) ; } else { t . report ( key , DUPLICATE_OBJECT_KEY , keyName ) ; } } } if ( ! key . isGetterDef ( ) ) { // normal property and setter cases Set < String > set = key . isStaticMember ( ) ? staticSetters : setters ; if ( ! set . add ( keyName ) ) { if ( n . isClassMembers ( ) ) { t . report ( key , DUPLICATE_CLASS_METHODS , keyName ) ; } else { t . report ( key , DUPLICATE_OBJECT_KEY , keyName ) ; } } } } }
Checks that object literal keys or class method names are valid .