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 org.jetbrains.annotations.Nullable; 008 009 import java.util.List; 010 011 /** 012 * The context in which a JsNode visitation occurs. This represents the set of 013 * possible operations a JsVisitor subclass can perform on the currently visited 014 * node. 015 */ 016 public abstract class JsContext<T extends JsNode> { 017 018 public <R extends T> void addPrevious(R node) { 019 throw new UnsupportedOperationException(); 020 } 021 022 public <R extends T> void addPrevious(List<R> nodes) { 023 for (R node : nodes) { 024 addPrevious(node); 025 } 026 } 027 028 public <R extends T> void addNext(R node) { 029 throw new UnsupportedOperationException(); 030 } 031 032 public abstract void removeMe(); 033 034 public abstract <R extends T> void replaceMe(R node); 035 036 @Nullable 037 public abstract T getCurrentNode(); 038 }