From 96a52fe2d035f640679c2b144b0b5951cfb76733 Mon Sep 17 00:00:00 2001 From: develar Date: Sun, 30 Sep 2012 15:21:44 +0400 Subject: [PATCH] cleanup --- .idea/artifacts/dart_ast_jar.xml | 2 +- .idea/codeStyleSettings.xml | 9 + .idea/inspectionProfiles/Project_Default.xml | 4 + src/com/google/dart/compiler/util/Lists.java | 267 ------------------ .../dart/compiler/util/TextOutputImpl.java | 2 +- 5 files changed, 15 insertions(+), 269 deletions(-) create mode 100644 .idea/codeStyleSettings.xml delete mode 100644 src/com/google/dart/compiler/util/Lists.java diff --git a/.idea/artifacts/dart_ast_jar.xml b/.idea/artifacts/dart_ast_jar.xml index 501533125dd..22aab8d51c0 100644 --- a/.idea/artifacts/dart_ast_jar.xml +++ b/.idea/artifacts/dart_ast_jar.xml @@ -1,5 +1,5 @@ - + $PROJECT_DIR$/out/artifacts diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 00000000000..1129f00105d --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 9ff76d8c843..3674c63d88d 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -54,5 +54,9 @@ + + \ No newline at end of file diff --git a/src/com/google/dart/compiler/util/Lists.java b/src/com/google/dart/compiler/util/Lists.java deleted file mode 100644 index 69507ed3197..00000000000 --- a/src/com/google/dart/compiler/util/Lists.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -package com.google.dart.compiler.util; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -/** - * Utility methods for operating on memory-efficient lists. All lists of size 0 - * or 1 are assumed to be immutable. All lists of size greater than 1 are - * assumed to be mutable. - */ -public class Lists { - private Lists() { - } - - public static List add(List list, int index, T toAdd) { - switch (list.size()) { - case 0: - // Empty -> Singleton - if (index != 0) { - throw newIndexOutOfBounds(list, index); - } - return Collections.singletonList(toAdd); - case 1: { - // Singleton -> ArrayList - List result = new ArrayList(2); - switch (index) { - case 0: - result.add(toAdd); - result.add(list.get(0)); - return result; - case 1: - result.add(list.get(0)); - result.add(toAdd); - return result; - default: - throw newIndexOutOfBounds(list, index); - } - } - default: - // ArrayList - list.add(index, toAdd); - return list; - } - } - - public static List add(List list, T toAdd) { - switch (list.size()) { - case 0: - // Empty -> Singleton - return Collections.singletonList(toAdd); - case 1: { - // Singleton -> ArrayList - List result = new ArrayList(2); - result.add(list.get(0)); - result.add(toAdd); - return result; - } - default: - // ArrayList - list.add(toAdd); - return list; - } - } - - public static List addAll(List list, int index, List toAdd) { - switch (toAdd.size()) { - case 0: - // No-op. - return list; - case 1: - // Add one element. - return add(list, index, toAdd.get(0)); - default: - // True list merge, result >= 2. - switch (list.size()) { - case 0: - if (index != 0) { - throw newIndexOutOfBounds(list, index); - } - return new ArrayList(toAdd); - case 1: { - List result = new ArrayList(1 + toAdd.size()); - switch (index) { - case 0: - result.addAll(toAdd); - result.add(list.get(0)); - return result; - case 1: - result.add(list.get(0)); - result.addAll(toAdd); - return result; - default: - throw newIndexOutOfBounds(list, index); - } - } - default: - list.addAll(index, toAdd); - return list; - } - } - } - - public static List addAll(List list, List toAdd) { - switch (toAdd.size()) { - case 0: - // No-op. - return list; - case 1: - // Add one element. - return add(list, toAdd.get(0)); - default: - // True list merge, result >= 2. - switch (list.size()) { - case 0: - return new ArrayList(toAdd); - case 1: { - List result = new ArrayList(1 + toAdd.size()); - result.add(list.get(0)); - result.addAll(toAdd); - return result; - } - default: - list.addAll(toAdd); - return list; - } - } - } - - public static List addAll(List list, T... toAdd) { - switch (toAdd.length) { - case 0: - // No-op. - return list; - case 1: - // Add one element. - return add(list, toAdd[0]); - default: - // True list merge, result >= 2. - switch (list.size()) { - case 0: - return new ArrayList(Arrays.asList(toAdd)); - case 1: { - List result = new ArrayList(1 + toAdd.length); - result.add(list.get(0)); - result.addAll(Arrays.asList(toAdd)); - return result; - } - default: - list.addAll(Arrays.asList(toAdd)); - return list; - } - } - } - - public static List create() { - return Collections.emptyList(); - } - - public static List create(Collection collection) { - switch (collection.size()) { - case 0: - return create(); - default: - return new ArrayList(collection); - } - } - - public static List create(List list) { - switch (list.size()) { - case 0: - return create(); - case 1: - return create(list.get(0)); - default: - return new ArrayList(list); - } - } - - public static List create(T item) { - return Collections.singletonList(item); - } - - public static List create(T... items) { - switch (items.length) { - case 0: - return create(); - case 1: - return create(items[0]); - default: - return new ArrayList(Arrays.asList(items)); - } - } - - public static List remove(List list, int toRemove) { - switch (list.size()) { - case 0: - // Empty - throw newIndexOutOfBounds(list, toRemove); - case 1: - // Singleton -> Empty - if (toRemove == 0) { - return Collections.emptyList(); - } else { - throw newIndexOutOfBounds(list, toRemove); - } - case 2: - // ArrayList -> Singleton - switch (toRemove) { - case 0: - return Collections.singletonList(list.get(1)); - case 1: - return Collections.singletonList(list.get(0)); - default: - throw newIndexOutOfBounds(list, toRemove); - } - default: - // ArrayList - list.remove(toRemove); - return list; - } - } - - public static List set(List list, int index, T e) { - switch (list.size()) { - case 0: - // Empty - throw newIndexOutOfBounds(list, index); - case 1: - // Singleton - if (index == 0) { - return Collections.singletonList(e); - } else { - throw newIndexOutOfBounds(list, index); - } - default: - // ArrayList - list.set(index, e); - return list; - } - } - - public static > List sort(List list) { - if (list.size() > 1) { - Collections.sort(list); - } - return list; - } - - public static List sort(List list, Comparator sort) { - if (list.size() > 1) { - Collections.sort(list, sort); - } - return list; - } - - private static IndexOutOfBoundsException newIndexOutOfBounds(List list, int index) { - return new IndexOutOfBoundsException("Index: " + index + ", Size: " + list.size()); - } -} diff --git a/src/com/google/dart/compiler/util/TextOutputImpl.java b/src/com/google/dart/compiler/util/TextOutputImpl.java index 84c126da023..174fc429ed3 100644 --- a/src/com/google/dart/compiler/util/TextOutputImpl.java +++ b/src/com/google/dart/compiler/util/TextOutputImpl.java @@ -26,7 +26,7 @@ public class TextOutputImpl implements TextOutput { public TextOutputImpl(boolean compact) { this.compact = compact; - this.out = new StringBuilder(); + out = new StringBuilder(); } @Override