Skip to content

Commit 06cd163

Browse files
committed
Removed some old utility classes
1 parent a675b8f commit 06cd163

19 files changed

Lines changed: 45 additions & 268 deletions

File tree

ide/org.codehaus.groovy.eclipse.core/src/org/codehaus/groovy/eclipse/core/util/ArrayUtils.java renamed to base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/core/util/ArrayUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2016 the original author or authors.
2+
* Copyright 2009-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.codehaus.groovy.eclipse.core.util;
16+
package org.eclipse.jdt.groovy.core.util;
1717

1818
import java.lang.reflect.Array;
1919
import java.util.ArrayList;
@@ -23,13 +23,13 @@
2323

2424
/**
2525
* Use this class so we don't have a dependency on apache commons-lang.
26-
* No code was copied from that jar
27-
*
28-
* @author Andrew Eisenberg
29-
* @created Sep 20, 2012
26+
* <p>
27+
* NODE: No code was copied from that library.
3028
*/
3129
public class ArrayUtils {
3230

31+
private ArrayUtils() {}
32+
3333
public static Object[] add(Object[] arr, Object val) {
3434
return add(arr, arr.length, val);
3535
}

base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/core/util/GroovyUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
/**
4646
* Helper methods - can be made more eclipse friendly or replaced if the groovy infrastructure provides the information.
4747
*/
48-
public abstract class GroovyUtils {
48+
public class GroovyUtils {
49+
50+
private GroovyUtils() {}
4951

5052
public static char[] readSourceRange(SourceUnit unit, int offset, int length) {
5153
Reader reader = null;

base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/core/util/ReflectionUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727

2828
/**
2929
* Common functionality for accessing private fields and methods.
30-
*
31-
* @author Andrew Eisenberg
32-
* @created May 8, 2009
3330
*/
3431
public class ReflectionUtils {
3532

33+
private ReflectionUtils() {}
34+
3635
public static <T> Constructor<T> getConstructor(Class<T> instanceType, Class<?>... parameterTypes) {
3736
try {
3837
Constructor<T> ctor = instanceType.getDeclaredConstructor(parameterTypes);

ide-test/org.codehaus.groovy.eclipse.tests/src/org/codehaus/groovy/eclipse/test/TestProject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import org.codehaus.groovy.eclipse.core.builder.GroovyClasspathContainer;
2626
import org.codehaus.groovy.eclipse.core.model.GroovyProjectFacade;
27-
import org.codehaus.groovy.eclipse.core.util.ArrayUtils;
2827
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
2928
import org.codehaus.jdt.groovy.model.GroovyNature;
3029
import org.eclipse.core.internal.events.BuildCommand;
@@ -52,6 +51,7 @@
5251
import org.eclipse.jdt.core.JavaCore;
5352
import org.eclipse.jdt.core.groovy.tests.SimpleProgressMonitor;
5453
import org.eclipse.jdt.core.tests.util.Util;
54+
import org.eclipse.jdt.groovy.core.util.ArrayUtils;
5555
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
5656
import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner;
5757
import org.eclipse.jdt.internal.core.JavaModelManager;

ide-test/org.codehaus.groovy.eclipse.tests/src/org/codehaus/groovy/eclipse/test/core/util/ArrayUtilsTests.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.codehaus.groovy.eclipse.test.core.util
1717

18-
import org.codehaus.groovy.eclipse.core.util.ArrayUtils
18+
import org.eclipse.jdt.groovy.core.util.ArrayUtils
1919
import org.junit.Test
2020

2121
final class ArrayUtilsTests {

ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/ProposalUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
*/
1616
package org.codehaus.groovy.eclipse.codeassist;
1717

18-
import static org.codehaus.groovy.eclipse.core.util.ListUtil.newEmptyList;
19-
18+
import java.util.ArrayList;
2019
import java.util.Collections;
2120
import java.util.List;
2221

@@ -259,7 +258,7 @@ public static boolean looselyMatches(String prefix, String target) {
259258
* e.g. mA = ['m','A']
260259
*/
261260
private static String[] toCamelCaseParts(String str) {
262-
List<String> parts = newEmptyList();
261+
List<String> parts = new ArrayList<String>();
263262
for (int i = str.length() - 1; i >= 0; --i) {
264263
if (Character.isUpperCase(str.charAt(i))) {
265264
parts.add(str.substring(i));

ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/requestor/ASTNodeFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
import org.codehaus.groovy.ast.stmt.ExpressionStatement;
4949
import org.codehaus.groovy.ast.stmt.Statement;
5050
import org.codehaus.groovy.eclipse.core.GroovyCore;
51-
import org.codehaus.groovy.eclipse.core.util.ArrayUtils;
5251
import org.codehaus.groovy.eclipse.core.util.VisitCompleteException;
5352
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
5453
import org.codehaus.groovy.runtime.GeneratedClosure;
54+
import org.eclipse.jdt.groovy.core.util.ArrayUtils;
5555
import org.eclipse.jdt.groovy.core.util.DepthFirstVisitor;
5656
import org.eclipse.jdt.groovy.core.util.GroovyUtils;
5757

ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/requestor/CodeSelectRequestor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.codehaus.groovy.eclipse.codebrowsing.elements.GroovyResolvedSourceType;
4545
import org.codehaus.groovy.eclipse.core.GroovyCore;
4646
import org.codehaus.groovy.eclipse.core.model.GroovyProjectFacade;
47-
import org.codehaus.groovy.eclipse.core.util.ArrayUtils;
4847
import org.codehaus.jdt.groovy.model.GroovyCompilationUnit;
4948
import org.eclipse.jdt.core.IField;
5049
import org.eclipse.jdt.core.IJavaElement;
@@ -58,6 +57,7 @@
5857
import org.eclipse.jdt.core.JavaModelException;
5958
import org.eclipse.jdt.core.Signature;
6059
import org.eclipse.jdt.core.compiler.CharOperation;
60+
import org.eclipse.jdt.groovy.core.util.ArrayUtils;
6161
import org.eclipse.jdt.groovy.core.util.GroovyUtils;
6262
import org.eclipse.jdt.groovy.search.AccessorSupport;
6363
import org.eclipse.jdt.groovy.search.GenericsMapper;

ide/org.codehaus.groovy.eclipse.core/src/org/codehaus/groovy/eclipse/core/impl/StringSourceBuffer.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2016 the original author or authors.
2+
* Copyright 2009-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
1515
*/
1616
package org.codehaus.groovy.eclipse.core.impl;
1717

18-
import static org.codehaus.groovy.eclipse.core.util.ListUtil.newList;
19-
2018
import java.util.ArrayList;
2119
import java.util.List;
2220

@@ -40,11 +38,10 @@ public StringSourceBuffer(String sourceCode) {
4038
}
4139

4240
private List<Integer> createLineLookup(char[] sourceCode) {
41+
List<Integer> offsets = new ArrayList<Integer>();
4342
if (sourceCode.length == 0) {
44-
return new ArrayList<Integer>();
43+
return offsets;
4544
}
46-
47-
List< Integer > offsets = newList();
4845
offsets.add(new Integer(0));
4946

5047
int ch;
Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2016 the original author or authors.
2+
* Copyright 2009-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,13 +19,13 @@
1919

2020
import java.io.IOException;
2121
import java.net.URL;
22+
import java.util.Arrays;
2223
import java.util.Collections;
2324
import java.util.Enumeration;
2425
import java.util.List;
2526

2627
import org.codehaus.groovy.eclipse.core.GroovyCore;
2728
import org.codehaus.groovy.eclipse.core.GroovyCoreActivator;
28-
import org.codehaus.groovy.eclipse.core.util.ListUtil;
2929
import org.eclipse.core.runtime.CoreException;
3030
import org.eclipse.core.runtime.IStatus;
3131
import org.eclipse.core.runtime.Platform;
@@ -34,30 +34,26 @@
3434
import org.eclipse.jdt.launching.JavaLaunchDelegate;
3535
import org.osgi.framework.Bundle;
3636

37-
/**
38-
* @author Andrew Eisenberg
39-
* @created Jul 31, 2009
40-
*
41-
*/
4237
public class GroovyShellLaunchDelegate extends JavaLaunchDelegate {
4338

4439
public static final String JLINE_JAR = "jline-*.jar";
4540

46-
4741
@Override
4842
public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
49-
5043
String[] classpath = super.getClasspath(configuration);
51-
List<String> newClasspath = ListUtil.array(classpath);
44+
List<String> newClasspath = Arrays.asList(classpath);
5245
try {
53-
newClasspath.add(getPathTo("jline-*.jar"));
46+
newClasspath.addAll(getExtraClasspathElements());
5447
} catch (IOException e) {
5548
GroovyCore.logException("Could not fine path to jline jars", e);
5649
}
57-
5850
return newClasspath.toArray(new String[0]);
5951
}
6052

53+
public static List<String> getExtraClasspathElements() throws CoreException, IOException {
54+
return Collections.singletonList(getPathTo(JLINE_JAR));
55+
}
56+
6157
private static String getPathTo(String jarName) throws CoreException, IOException {
6258
Bundle groovyBundle = Platform.getBundle("org.codehaus.groovy");
6359
Enumeration<URL> enu = groovyBundle.findEntries("lib", jarName, false);
@@ -68,8 +64,4 @@ private static String getPathTo(String jarName) throws CoreException, IOExceptio
6864
throw new CoreException(new Status(IStatus.ERROR, GroovyCoreActivator.PLUGIN_ID, "Could not find " + jarName + " on the class path. Please add it manually"));
6965
}
7066
}
71-
72-
public static List<String> getExtraClasspathElements() throws CoreException, IOException {
73-
return Collections.singletonList(GroovyShellLaunchDelegate.getPathTo(GroovyShellLaunchDelegate.JLINE_JAR));
74-
}
7567
}

0 commit comments

Comments
 (0)