001    // Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file
002    // for details. All rights reserved. Use of this source code is governed by a
003    // BSD-style license that can be found in the LICENSE file.
004    
005    package com.google.dart.compiler.backend.js.ast;
006    
007    import com.intellij.util.SmartList;
008    import org.jetbrains.annotations.NotNull;
009    
010    import java.util.Arrays;
011    import java.util.Collections;
012    import java.util.List;
013    
014    public final class JsInvocation extends JsExpressionImpl.JsExpressionHasArguments {
015        private JsExpression qualifier;
016    
017        public JsInvocation() {
018            super(new SmartList<JsExpression>());
019        }
020    
021        public JsInvocation(JsExpression qualifier, @NotNull List<JsExpression> arguments) {
022            super(arguments);
023            this.qualifier = qualifier;
024        }
025    
026        public JsInvocation(JsExpression qualifier, JsExpression arg) {
027            this(qualifier, Collections.singletonList(arg));
028        }
029    
030        public JsInvocation(JsExpression qualifier, JsExpression... arguments) {
031            this(qualifier, Arrays.asList(arguments));
032        }
033    
034        public JsInvocation(JsExpression qualifier) {
035            this();
036            this.qualifier = qualifier;
037        }
038    
039        @NotNull
040        @Override
041        public List<JsExpression> getArguments() {
042            return arguments;
043        }
044    
045        public JsExpression getQualifier() {
046            return qualifier;
047        }
048    
049        public void setQualifier(JsExpression qualifier) {
050            this.qualifier = qualifier;
051        }
052    
053        @Override
054        public void accept(JsVisitor v) {
055            v.visitInvocation(this);
056        }
057    
058        @Override
059        public void acceptChildren(JsVisitor visitor) {
060            visitor.accept(qualifier);
061            visitor.acceptList(arguments);
062        }
063    }