Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring: clean deprecated elements from version 5.4.0 #1135

Merged
merged 13 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/main/java/spoon/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import spoon.SpoonModelBuilder.InputType;
import spoon.compiler.Environment;
import spoon.compiler.SpoonCompiler;
import spoon.compiler.SpoonResource;
import spoon.compiler.SpoonResourceHelper;
import spoon.processing.Processor;
Expand Down Expand Up @@ -541,8 +540,8 @@ protected JSAPResult parseArgs() {
* @param factory
* the factory this compiler works on
*/
public SpoonCompiler createCompiler(Factory factory) {
SpoonCompiler comp = new JDTBasedSpoonCompiler(factory);
public SpoonModelBuilder createCompiler(Factory factory) {
SpoonModelBuilder comp = new JDTBasedSpoonCompiler(factory);
Environment env = getEnvironment();
// building
comp.setEncoding(getArguments().getString("encoding"));
Expand All @@ -565,8 +564,8 @@ public SpoonCompiler createCompiler(Factory factory) {
return comp;
}

public SpoonCompiler createCompiler(Factory factory, List<SpoonResource> inputSources) {
SpoonCompiler c = createCompiler(factory);
public SpoonModelBuilder createCompiler(Factory factory, List<SpoonResource> inputSources) {
SpoonModelBuilder c = createCompiler(factory);
c.addInputSources(inputSources);
return c;
}
Expand All @@ -583,16 +582,16 @@ public SpoonModelBuilder createCompiler(Factory factory, List<SpoonResource> inp
}

@Override
public SpoonCompiler createCompiler() {
public SpoonModelBuilder createCompiler() {
return createCompiler(factory);
}

/**
* Creates a new Spoon Java compiler with a default factory and a list of
* input sources.
*/
public SpoonCompiler createCompiler(List<SpoonResource> inputSources) {
SpoonCompiler c = createCompiler(factory);
public SpoonModelBuilder createCompiler(List<SpoonResource> inputSources) {
SpoonModelBuilder c = createCompiler(factory);
c.addInputSources(inputSources);
return c;
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/spoon/SpoonModelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ interface InputType {
*/
boolean compile(InputType... types);

/** replaced by {@link #compile(InputType...)} */
@Deprecated
boolean compileInputSources();

/**
* Takes a list of fully qualified name processors and instantiates them to process
* the Java model.
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/spoon/compiler/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,6 @@ void report(Processor<?> processor, Level level,
*/
void setSourceClasspath(String[] sourceClasspath);

/**
* Use {@link #getInputClassLoader()}
*/
@Deprecated
ClassLoader getClassLoader();

/**
* Sets the option "noclasspath", use with caution (see explanation below).
*
Expand Down
26 changes: 0 additions & 26 deletions src/main/java/spoon/compiler/SpoonCompiler.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/spoon/compiler/SpoonResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/**
* This interface defines generic resources that are used by
* {@link SpoonCompiler} in the Java compilation process.
* {@link spoon.SpoonModelBuilder} in the Java compilation process.
*/
public interface SpoonResource {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/spoon/processing/ProcessingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
/**
* The processing manager defines the API to process a program model of a given
* {@link spoon.reflect.factory.Factory} with a set of processors. The program model has
* been previously built using a {@link spoon.compiler.SpoonCompiler} - see
* {@link spoon.compiler.SpoonCompiler#build()}. To use, add processors to
* been previously built using a {@link spoon.SpoonModelBuilder} - see
* {@link spoon.SpoonModelBuilder#build()}. To use, add processors to
* the manager, and then call the {@code process} method. Also, the method
* {@link spoon.processing.Processor#processingDone()} is up called.
*
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/spoon/reflect/declaration/CtElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import spoon.processing.FactoryAccessor;
import spoon.reflect.code.CtComment;
import spoon.reflect.cu.SourcePosition;
import spoon.reflect.reference.CtReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.CtVisitable;
import spoon.reflect.visitor.Filter;
Expand Down Expand Up @@ -170,15 +169,6 @@ <E extends CtElement> List<E> getAnnotatedChildren(
*/
<E extends CtElement> List<E> getElements(Filter<E> filter);

/**
* @param filter
* @return
*
* @deprecated use {@link #getElements(Filter)} instead.
*/
@Deprecated
<T extends CtReference> List<T> getReferences(Filter<T> filter);

/**
* Sets the position of this element and all its children element. Note that
* this information is used to feed the line numbers in the generated
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/spoon/reflect/declaration/CtTypeInformation.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@ public interface CtTypeInformation {
*/
boolean isSubtypeOf(CtTypeReference<?> type);

/**
* Returns <code>true</code> if this referenced type is assignable from an
* instance of the given type.
*
* Deprecated on Nov 19, 2016
* Reasons for deprecation:
* 1) it has the opposite behavior of java.lang.Class.isAssignableFrom, this is very confusing
* 2) we already have {@link #isSubtypeOf(CtTypeReference)}
*/
@Deprecated
boolean isAssignableFrom(CtTypeReference<?> type);

/**
* Returns the class type directly extended by this class.
*
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/spoon/reflect/factory/CoreFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,6 @@ public interface CoreFactory {
*/
<R> CtReturn<R> createReturn();

/**
* Creates a source position.
*/
@Deprecated
SourcePosition createSourcePosition(
CompilationUnit compilationUnit,
int startDeclaration, int startSource, int end, int[] lineSeparatorPositions);

/**
* Creates a source position.
*/
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/spoon/reflect/factory/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,6 @@ public interface Factory {
*/
CompilationUnit createCompilationUnit();

/**
* @see CoreFactory#createSourcePosition(CompilationUnit,int,int,int,int[])
*/
@Deprecated
SourcePosition createSourcePosition(CompilationUnit compilationUnit, int startDeclaration, int startSource, int end, int[] lineSeparatorPositions);

/**
* @see CoreFactory#createSourcePosition(CompilationUnit,int,int,int[])
*/
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/spoon/reflect/factory/FactoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -932,12 +932,6 @@ public CompilationUnit createCompilationUnit() {
return Core().createCompilationUnit();
}

@Deprecated
@Override
public SourcePosition createSourcePosition(CompilationUnit compilationUnit, int startDeclaration, int startSource, int end, int[] lineSeparatorPositions) {
return Core().createSourcePosition(compilationUnit, startDeclaration, startSource, end, lineSeparatorPositions);
}

@Override
public SourcePosition createSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int[] lineSeparatorPositions) {
return Core().createSourcePosition(compilationUnit, startSource, end, lineSeparatorPositions);
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/spoon/support/DefaultCoreFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,6 @@ public void setMainFactory(Factory mainFactory) {
this.factory = mainFactory;
}

@Override
@Deprecated
public SourcePosition createSourcePosition(CompilationUnit compilationUnit, int startDeclaration, int startSource, int end, int[] lineSeparatorPositions) {
return new SourcePositionImpl(compilationUnit, startSource, end, lineSeparatorPositions);
}

@Override
public SourcePosition createSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int[] lineSeparatorPositions) {
return new SourcePositionImpl(compilationUnit, startSource, end, lineSeparatorPositions);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/support/QueueProcessingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public boolean addProcessor(Processor<?> p) {
@SuppressWarnings("unchecked")
public void addProcessor(String qualifiedName) {
try {
addProcessor((Class<? extends Processor<?>>) getFactory().getEnvironment().getClassLoader().loadClass(qualifiedName));
addProcessor((Class<? extends Processor<?>>) getFactory().getEnvironment().getInputClassLoader().loadClass(qualifiedName));
} catch (ClassNotFoundException e) {
throw new SpoonException("Unable to load processor \"" + qualifiedName + "\" - Check your classpath.", e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/spoon/support/RuntimeProcessingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public boolean addProcessor(Processor<?> p) {
@SuppressWarnings("unchecked")
public void addProcessor(String qualifiedName) {
try {
addProcessor((Class<? extends Processor<?>>) getFactory().getEnvironment().getClassLoader().loadClass(qualifiedName));
addProcessor((Class<? extends Processor<?>>) getFactory().getEnvironment().getInputClassLoader().loadClass(qualifiedName));
} catch (ClassNotFoundException e) {
factory.getEnvironment().report(null, Level.ERROR, "Unable to load processor \"" + qualifiedName + "\" - Check your classpath.");
}
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/spoon/support/StandardEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,6 @@ public ClassLoader getInputClassLoader() {
return inputClassloader;
}

@Override
public ClassLoader getClassLoader() {
return getInputClassLoader();
}

/**
* Creates a URL class path from {@link Environment#getSourceClasspath()}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package spoon.support.compiler;

import spoon.SpoonModelBuilder;
import spoon.compiler.ModelBuildingException;
import spoon.compiler.SpoonCompiler;
import spoon.reflect.code.CtBlock;
import spoon.reflect.code.CtCodeSnippetExpression;
import spoon.reflect.code.CtCodeSnippetStatement;
Expand Down Expand Up @@ -109,7 +109,7 @@ public static <T> CtExpression<T> compileExpression(

private static void build(Factory f, String contents) {
// Build contents
SpoonCompiler builder = new JDTSnippetCompiler(f, contents);
SpoonModelBuilder builder = new JDTSnippetCompiler(f, contents);
try {
builder.build();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import spoon.SpoonException;
import spoon.compiler.Environment;
import spoon.compiler.ModelBuildingException;
import spoon.compiler.SpoonCompiler;
import spoon.compiler.SpoonFile;
import spoon.compiler.SpoonFolder;
import spoon.compiler.SpoonResource;
Expand Down Expand Up @@ -71,7 +70,7 @@
* Main class of Spoon to build the model.
* Highly depends on {@link JDTBatchCompiler} for performing the job.
*/
public class JDTBasedSpoonCompiler implements SpoonCompiler {
public class JDTBasedSpoonCompiler implements spoon.SpoonModelBuilder {
protected INameEnvironment environment = null;
protected final List<CategorizedProblem> probs = new ArrayList<>();
protected final TreeBuilderRequestor requestor = new TreeBuilderRequestor(this);
Expand Down Expand Up @@ -620,11 +619,6 @@ protected Environment getEnvironment() {
return getFactory().getEnvironment();
}

@Override
public boolean compileInputSources() {
return compile(InputType.FILES);
}

@Override
public void addCompilationUnitFilter(final CompilationUnitFilter filter) {
compilationUnitFilters.add(filter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,6 @@ public <P extends CtElement> CtQuery filterChildren(Filter<P> predicate) {
return factory.Query().createQuery(this).filterChildren(predicate);
}

public <T extends CtReference> List<T> getReferences(Filter<T> filter) {
return getElements(filter);
}

@Override
public CtElement getParent() throws ParentNotInitializedException {
if (parent == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,6 @@ public List<CtFieldReference<?>> getDeclaredFields() {
return fields;
}

@Override
public boolean isAssignableFrom(CtTypeReference<?> type) {
return isSubtypeOf(type);
}

@Override
public <M, C extends CtType<T>> C addMethod(CtMethod<M> method) {
if (method != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,6 @@ public boolean isSubtypeOf(CtTypeReference<?> type) {
return false;
}

@Override
public boolean isAssignableFrom(CtTypeReference<?> type) {
return false;
}

@Override
@UnsettableProperty
public <M, C extends CtType<Object>> C addMethod(CtMethod<M> method) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ public <T extends CtTypeParameterReference> T setUpper(boolean upper) {
return (T) this;
}

@Override
public boolean isAssignableFrom(CtTypeReference<?> type) {
return false;
}

@Override
public boolean isGenerics() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected Class<T> findClass() {
// creating a classloader on the fly is not the most efficient
// but it decreases the amount of state to maintain
// since getActualClass is only used in rare cases, that's OK.
return (Class<T>) getFactory().getEnvironment().getClassLoader().loadClass(getQualifiedName());
return (Class<T>) getFactory().getEnvironment().getInputClassLoader().loadClass(getQualifiedName());
} catch (Throwable e) {
throw new SpoonClassNotFoundException("cannot load class: " + getQualifiedName(), e);
}
Expand Down Expand Up @@ -194,11 +194,6 @@ public String getQualifiedName() {
}
}

@Override
public boolean isAssignableFrom(CtTypeReference<?> type) {
return type != null && type.isSubtypeOf(this);
}

@Override
public boolean isPrimitive() {
return ("boolean".equals(getSimpleName()) || "byte".equals(getSimpleName()) || "double".equals(getSimpleName()) || "int".equals(getSimpleName()) || "short".equals(getSimpleName())
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/spoon/testing/AbstractAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ public T withProcessor(String qualifiedName) {
return myself;
}

/**
* @deprecated
*/
@Deprecated
public boolean equals(Object obj) {
throw new UnsupportedOperationException("\'equals\' is not supported...maybe you intended to call \'isEqualTo\'");
}

public int hashCode() {
return 1;
}
Expand Down
Loading