rewrite e.g. `List<Object> xs = new LinkedList<>()` -> `... = new ArrayList<>()`
359131
private static Optional<Fix> linkedListFix(Tree tree, VisitorState state) {
    Type type = getTargetType(state);
    if (type == null) {
      return Optional.empty();
    }
    Types types = state.getTypes();
    for (String replacement : ImmutableList.of("java.util.ArrayList", "java.util.ArrayDeque")) {
      Symbol sym = state.getSymbolFromString(replacement);
      if (sym == null) {
        continue;
      }
      if (types.isAssignable(types.erasure(sym.asType()), types.erasure(type))) {
        SuggestedFix.Builder fix = SuggestedFix.builder();
        while (tree instanceof ParameterizedTypeTree) {
          tree = ((ParameterizedTypeTree) tree).getType();
        }
        fix.replace(tree, SuggestedFixes.qualifyType(state, fix, sym));
        return Optional.of(fix.build());
      }
    }
    return Optional.empty();
  }
757395
def from_list(cls, vals: List[Value] = [], reverse: bool = False) -> "LinkedList":
        
        res = EmptyList()
        for v in (vals if reverse else vals[::-1]):
            res = cls(v, res)
        return res
556506
public void writeOverSet(int which, List<Point2D_I32> points) {
		BlockIndexLength set = sets.get(which);
		if( set.length != points.size() )
			throw new IllegalArgumentException("points and set don't have the same length");

		for (int i = 0; i < set.length; i++) {
			int index = set.start + i*2;
			int blockIndex = set.block + index/blockLength;
			index %= blockLength;

			Point2D_I32 p = points.get(i);
			int block[] = blocks.get( blockIndex );
			block[index] = p.x;
			block[index+1] = p.y;
		}
	}
1163166
public static <T> List<T> list(boolean isLinked, Collection<T> collection) {
		if (null == collection) {
			return list(isLinked);
		}
		return isLinked ? new LinkedList<T>(collection) : new ArrayList<T>(collection);
	}
195132
function LinkedList( ... elements ) {
	this.head = null ;
	this.tail = null ;
	this.length = 0 ;

	if ( elements.length ) {
		this.push( ... elements ) ;
	}
}
409260
function (value) {
        var node;

        if (value instanceof LinkedListNode) {
            node = value;
            validateNode(node, this);

            if (node._next === node) {
                this.head = null;
            }
            else {
                node._next._prev = node._prev;
                node._prev._next = node._next;

                if (this.head === node) {
                    this.head = node._next;
                }
            }
            node._list = null;
            node._next = null;
            node._prev = null;
            this.size--;

            return true;
        }
        else {
            if ((node = this.find(value)) !== null) {
                this.remove(node);
                return true;
            }
            return false;
        }
    }
1223375
private void rewriteCall(Node getprop, String newMethodName) {
    checkArgument(getprop.isGetProp(), getprop);
    Node call = getprop.getParent();
    checkArgument(call.isCall(), call);
    Node receiver = getprop.getFirstChild();

    // This rewriting does not exactly preserve order of operations; the newly inserted static
    // method name will be resolved before `receiver` is evaluated. This is known to be safe due
    // to the eligibility checks earlier in the pass.
    //
    // We choose not to do a full-fidelity rewriting (e.g. using `ExpressionDecomposer`) because
    // doing so means extracting `receiver` into a new variable at each call-site. This  has a
    // significant code-size impact (circa 2018-11-19).

    getprop.removeChild(receiver);
    call.replaceChild(getprop, receiver);
    call.addChildToFront(IR.name(newMethodName).srcref(getprop));

    if (receiver.isSuper()) {
      // Case: `super.foo(a, b)` => `foo(this, a, b)`
      receiver.setToken(Token.THIS);
    }

    call.putBooleanProp(Node.FREE_CALL, true);
    compiler.reportChangeToEnclosingScope(call);
  }
255063
function List(parameters) {
    abstractions.Collection.call(this, utilities.types.LIST, parameters);

    // the array is a private attribute so methods that use it are defined in the constructor
    const array = [];

    this.acceptVisitor = function(visitor) {
        visitor.visitList(this);
    };
    
    this.toArray = function() {
        return array.slice();  // copy the array
    };

    this.getSize = function() {
        return array.length;
    };
    
    this.getItem = function(index) {
        index = this.normalizeIndex(index) - 1;  // JS uses zero based indexing
        return array[index];
    };
    
    this.setItem = function(index, item) {
        index = this.normalizeIndex(index) - 1;  // JS uses zero based indexing
        item = this.convert(item);
        const oldItem = array[index];
        array[index] = item;
        return oldItem;
    };
    
    this.addItem = function(item) {
        item = this.convert(item);
        array.push(item);
        return true;
    };
    
    this.insertItem = function(index, item) {
        item = this.convert(item);
        index = this.normalizeIndex(index) - 1;  // JS uses zero based indexing
        array.splice(index, 0, item);
    };
    
    this.insertItems = function(index, items) {
        const iterator = items.getIterator();
        while (iterator.hasNext()) {
            const item = iterator.getNext();
            this.insertItem(index++, item);
        }
    };
    
    this.removeItem = function(index) {
        index = this.normalizeIndex(index) - 1;  // JS uses zero based indexing
        const oldItem = array[index];
        if (oldItem) array.splice(index, 1);
        return oldItem;
    };
    
    this.removeItems = function(range) {
        const items = new List(this.getParameters());
        const iterator = range.getIterator();
        while (iterator.hasNext()) {
            const index = iterator.getNext();
            const item = this.removeItem(index);
            items.addItem(item);
        }
        return items;
    };
    
    this.sortItems = function(sorter) {
        sorter = sorter || new utilities.Sorter();
        sorter.sortCollection(this);
    };
    
    this.reverseItems = function() {
        array.reverse();
    };

    this.shuffleItems = function() {
        const size = this.getSize();
        for (var index = size; index > 1; index--) {
            const randomIndex = utilities.random.index(index);  // in range [1..index] ordinal indexing
            const item = this.getItem(index);
            this.setItem(index, this.getItem(randomIndex));
            this.setItem(randomIndex, item);
        }
    };
    
    this.deleteAll = function() {
        array.splice(0);
    };

    return this;
}
1333801
static JSBoxedListImpl create(JSVaryingList subList, int subAccessor) {
    if (subList.getIndirection() > 0)
      return new JSIndirectBoxedListImpl(subList, subAccessor);
    else
      return new JSBoxedListImpl(subList, subAccessor);
  }
1048592
public ListBuffer<A> appendList(List<A> xs) {
        while (xs.nonEmpty()) {
            append(xs.head);
            xs = xs.tail;
        }
        return this;
    }
1120898
def writeList(self, n, is_proxy=False):
        
        if self.use_proxies and not is_proxy:
            self.writeProxy(n)

            return

        self.stream.write(TYPE_ARRAY)

        ref = self.context.getObjectReference(n)

        if ref != -1:
            self._writeInteger(ref << 1)

            return

        self.context.addObject(n)

        self._writeInteger((len(n) << 1) | REFERENCE_BIT)
        self.stream.write('\x01')

        [self.writeElement(x) for x in n]
437820
private Element rewriteLinks(final Element src) {
        final Element dst = (Element) src.cloneNode(true);
        for (final Element desc: getChildElements(dst, TOPIC_DESC, true)) {
            for (final Element elem: getChildElements(desc, true)) {
                final Attr href = elem.getAttributeNode(ATTRIBUTE_NAME_HREF);
                final String scope = elem.getAttribute(ATTRIBUTE_NAME_SCOPE);
                if (href != null && !scope.equals(ATTR_SCOPE_VALUE_EXTERNAL)) {
                    final URI abs = baseURI.resolve(href.getValue());
                    final URI rel = getRelativePath(currentFile, abs);
                    href.setValue(rel.toString());
                }
            }
        }
        return dst;
    }
844280
public static <E> LinkedBlockingDeque<E> newLinkedBlockingDeque(Iterable<? extends E> elements) {
    if (elements instanceof Collection) {
      return new LinkedBlockingDeque<E>(Collections2.cast(elements));
    }
    LinkedBlockingDeque<E> deque = new LinkedBlockingDeque<E>();
    Iterables.addAll(deque, elements);
    return deque;
  }
551786
@SuppressWarnings({ "unused", "unchecked" })
  private static void rewriteMergeData(String key, String subKey,
      NamedList<Object> snl, NamedList<Object> tnl) {
    if (snl != null) {
      Object o = tnl.get(key);
      NamedList<Object> tnnnl;
      if (o != null && o instanceof NamedList) {
        tnnnl = (NamedList<Object>) o;
      } else {
        tnnnl = new SimpleOrderedMap<>();
        tnl.add(key, tnnnl);
      }
      tnnnl.add(subKey, snl);
    }
  }
1120746
private void rewriteDuplicates(final Element root) {
        // collect href and copy-to
        final Map<URI, Map<Set<URI>, List<Attr>>> refs = new HashMap<>();
        for (final Element e: getTopicrefs(root)) {
            Attr attr = e.getAttributeNode(BRANCH_COPY_TO);
            if (attr == null) {
                attr = e.getAttributeNode(ATTRIBUTE_NAME_COPY_TO);
                if (attr == null) {
                    attr = e.getAttributeNode(ATTRIBUTE_NAME_HREF);
                }
            }
            if (attr != null) {
                final URI h = stripFragment(map.resolve(attr.getValue()));
                Map<Set<URI>, List<Attr>> attrsMap = refs.computeIfAbsent(h, k -> new HashMap<>());
                final Set<URI> currentFilter = getBranchFilters(e);
                List<Attr> attrs = attrsMap.computeIfAbsent(currentFilter, k -> new ArrayList<>());
                attrs.add(attr);
            }
        }
        // check and rewrite
        for (final Map.Entry<URI, Map<Set<URI>, List<Attr>>> ref: refs.entrySet()) {
            final Map<Set<URI>, List<Attr>> attrsMaps = ref.getValue();
            if (attrsMaps.size() > 1) {
                if (attrsMaps.containsKey(Collections.EMPTY_LIST)) {
                    attrsMaps.remove(Collections.EMPTY_LIST);
                } else {
                    Set<URI> first = attrsMaps.keySet().iterator().next();
                    attrsMaps.remove(first);
                }
                int i = 1;
                for (final Map.Entry<Set<URI>, List<Attr>> attrsMap: attrsMaps.entrySet()) {
                    final String suffix = "-" + i;
                    final List<Attr> attrs = attrsMap.getValue();
                    for (final Attr attr: attrs) {
                        final String gen = addSuffix(attr.getValue(), suffix);
                        logger.info(MessageUtils.getMessage("DOTJ065I", attr.getValue(), gen)
                                .setLocation(attr.getOwnerElement()).toString());
                        if (attr.getName().equals(BRANCH_COPY_TO)) {
                            attr.setValue(gen);
                        } else {
                            attr.getOwnerElement().setAttribute(BRANCH_COPY_TO, gen);
                        }

                        final URI dstUri = map.resolve(gen);
                        if (dstUri != null) {
                            final FileInfo hrefFileInfo = job.getFileInfo(currentFile.resolve(attr.getValue()));
                            if (hrefFileInfo != null) {
                                final URI newResult = addSuffix(hrefFileInfo.result, suffix);
                                final FileInfo.Builder dstBuilder = new FileInfo.Builder(hrefFileInfo)
                                        .uri(dstUri)
                                        .result(newResult);
                                if (hrefFileInfo.format == null) {
                                    dstBuilder.format(ATTR_FORMAT_VALUE_DITA);
                                }
                                final FileInfo dstFileInfo = dstBuilder.build();
                                job.add(dstFileInfo);
                            }
                        }
                    }
                    i++;
                }
            }
        }
    }
451652
private static Optional<Fix> rewriteCompoundAssignment(
      CompoundAssignmentTree tree, VisitorState state) {
    CharSequence var = state.getSourceForNode(tree.getVariable());
    CharSequence expr = state.getSourceForNode(tree.getExpression());
    if (var == null || expr == null) {
      return Optional.absent();
    }
    switch (tree.getKind()) {
      case RIGHT_SHIFT_ASSIGNMENT:
        // narrowing the result of a signed right shift does not lose information
        return Optional.absent();
      default:
        break;
    }
    Kind regularAssignmentKind = regularAssignmentFromCompound(tree.getKind());
    String op = assignmentToString(regularAssignmentKind);

    // Add parens to the rhs if necessary to preserve the current precedence
    // e.g. 's -= 1 - 2' -> 's = s - (1 - 2)'
    OperatorPrecedence rhsPrecedence =
        tree.getExpression() instanceof JCBinary
            ? OperatorPrecedence.from(tree.getExpression().getKind())
            : tree.getExpression() instanceof ConditionalExpressionTree
                ? OperatorPrecedence.TERNARY
                : null;

    if (rhsPrecedence != null) {
      if (!rhsPrecedence.isHigher(OperatorPrecedence.from(regularAssignmentKind))) {
        expr = String.format("(%s)", expr);
      }
    }

    // e.g. 's *= 42' -> 's = (short) (s * 42)'
    String castType = getType(tree.getVariable()).toString();
    String replacement = String.format("%s = (%s) (%s %s %s)", var, castType, var, op, expr);
    return Optional.of(SuggestedFix.replace(tree, replacement));
  }
661248
private <R> Collection<R> copy(Iterable<R> src) {
        return Lists.newArrayList(src);
    }