Skip to content

Commit

Permalink
Merge in master (Closes #573 #597 #600)
Browse files Browse the repository at this point in the history
  • Loading branch information
monperrus authored Aug 25, 2016
2 parents 25f9202 + a1c266b commit 1b758e1
Show file tree
Hide file tree
Showing 30 changed files with 131 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public interface CtTypeInformation {
*/
boolean isAnnotationType();

/**
* Returns true if this element is a generics (eg "T") and false if it is an actual type (eg 'Book" or "String")
*/
boolean isGenerics();

/**
* Returns true if the referenced type is a sub-type of the given type.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/spoon/reflect/factory/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,4 @@ public interface Factory {
EvalFactory Eval(); // used 4 times

ConstructorFactory Constructor(); // used 3 times

InternalFactory Internal();
}
11 changes: 0 additions & 11 deletions src/main/java/spoon/reflect/factory/FactoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.CtType;
import spoon.support.DefaultCoreFactory;
import spoon.support.DefaultInternalFactory;
import spoon.support.StandardEnvironment;

import java.io.Serializable;
Expand Down Expand Up @@ -256,16 +255,6 @@ public TypeFactory Type() {
return type;
}

private transient InternalFactory internal;

@Override
public InternalFactory Internal() {
if (internal == null) {
internal = new DefaultInternalFactory(this);
}
return internal;
}

/**
* A constructor that takes the parent factory
*/
Expand Down
31 changes: 0 additions & 31 deletions src/main/java/spoon/reflect/factory/InternalFactory.java

This file was deleted.

34 changes: 0 additions & 34 deletions src/main/java/spoon/reflect/internal/CtCircularTypeReference.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package spoon.reflect.reference;

import spoon.reflect.declaration.CtTypeParameter;

import java.util.List;

/**
Expand Down Expand Up @@ -68,6 +70,11 @@ public interface CtTypeParameterReference extends CtTypeReference<Object> {
*/
<T extends CtTypeParameterReference> T setBoundingType(CtTypeReference<?> superType);

// override the return
@Override
CtTypeParameter getDeclaration();

// override the return
@Override
CtTypeParameterReference clone();
}
6 changes: 0 additions & 6 deletions src/main/java/spoon/reflect/visitor/CtAbstractVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.internal.CtCircularTypeReference;
import spoon.reflect.reference.CtArrayTypeReference;
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.reflect.reference.CtExecutableReference;
Expand Down Expand Up @@ -393,11 +392,6 @@ public <T> void visitCtTypeReference(CtTypeReference<T> reference) {

}

@Override
public void visitCtCircularTypeReference(CtCircularTypeReference reference) {

}

@Override
public <T> void visitCtTypeAccess(CtTypeAccess<T> typeAccess) {

Expand Down
8 changes: 0 additions & 8 deletions src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ public void visitCtTypeParameterReference(final spoon.reflect.reference.CtTypePa
enter(ref);
biScan(ref.getPackage(), other.getPackage());
biScan(ref.getDeclaringType(), other.getDeclaringType());
biScan(ref.getActualTypeArguments(), other.getActualTypeArguments());
biScan(ref.getAnnotations(), other.getAnnotations());
biScan(ref.getBoundingType(), other.getBoundingType());
exit(ref);
Expand Down Expand Up @@ -660,13 +659,6 @@ public <T> void visitCtTypeReference(final spoon.reflect.reference.CtTypeReferen
exit(reference);
}

@java.lang.Override
public void visitCtCircularTypeReference(final spoon.reflect.internal.CtCircularTypeReference reference) {
spoon.reflect.internal.CtCircularTypeReference other = ((spoon.reflect.internal.CtCircularTypeReference) (stack.peek()));
enter(reference);
exit(reference);
}

@java.lang.Override
public <T> void visitCtTypeAccess(final spoon.reflect.code.CtTypeAccess<T> typeAccess) {
spoon.reflect.code.CtTypeAccess other = ((spoon.reflect.code.CtTypeAccess) (stack.peek()));
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/spoon/reflect/visitor/CtInheritanceScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.declaration.CtTypedElement;
import spoon.reflect.declaration.CtVariable;
import spoon.reflect.internal.CtCircularTypeReference;
import spoon.reflect.reference.CtActualTypeContainer;
import spoon.reflect.reference.CtArrayTypeReference;
import spoon.reflect.reference.CtCatchVariableReference;
Expand Down Expand Up @@ -805,11 +804,6 @@ public <T> void visitCtTypeReference(CtTypeReference<T> e) {
scanCtVisitable(e);
}

@Override
public void visitCtCircularTypeReference(CtCircularTypeReference e) {
visitCtTypeParameterReference(e);
}

@Override
public <T> void visitCtTypeAccess(CtTypeAccess<T> e) {
scanCtExpression(e);
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/spoon/reflect/visitor/CtScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.internal.CtCircularTypeReference;
import spoon.reflect.reference.CtArrayTypeReference;
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.reflect.reference.CtExecutableReference;
Expand Down Expand Up @@ -720,7 +719,6 @@ public void visitCtTypeParameterReference(final CtTypeParameterReference ref) {
enter(ref);
scan(ref.getPackage());
scan(ref.getDeclaringType());
scan(ref.getActualTypeArguments());
scan(ref.getAnnotations());
scan(ref.getBoundingType());
exit(ref);
Expand Down Expand Up @@ -751,12 +749,6 @@ public <T> void visitCtTypeReference(final CtTypeReference<T> reference) {
exit(reference);
}

@Override
public void visitCtCircularTypeReference(final CtCircularTypeReference reference) {
enter(reference);
exit(reference);
}

@Override
public <T> void visitCtTypeAccess(final CtTypeAccess<T> typeAccess) {
enter(typeAccess);
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/spoon/reflect/visitor/CtVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.internal.CtCircularTypeReference;
import spoon.reflect.reference.CtArrayTypeReference;
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.reflect.reference.CtExecutableReference;
Expand Down Expand Up @@ -406,11 +405,6 @@ <T, A extends T> void visitCtOperatorAssignment(
*/
<T> void visitCtTypeReference(CtTypeReference<T> reference);

/**
* Visits a circular reference.
*/
void visitCtCircularTypeReference(CtCircularTypeReference reference);

/**
* Visits a type access.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.declaration.ModifierKind;
import spoon.reflect.declaration.ParentNotInitializedException;
import spoon.reflect.internal.CtCircularTypeReference;
import spoon.reflect.reference.CtArrayTypeReference;
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.reflect.reference.CtExecutableReference;
Expand Down Expand Up @@ -1644,11 +1643,6 @@ public <T> void visitCtTypeReference(CtTypeReference<T> ref) {
visitCtTypeReference(ref, true);
}

@Override
public void visitCtCircularTypeReference(CtCircularTypeReference reference) {
visitCtTypeReference(reference);
}

@Override
public <T> void visitCtTypeAccess(CtTypeAccess<T> typeAccess) {
if (typeAccess.isImplicit()) {
Expand Down
37 changes: 0 additions & 37 deletions src/main/java/spoon/support/DefaultInternalFactory.java

This file was deleted.

24 changes: 8 additions & 16 deletions src/main/java/spoon/support/compiler/jdt/ReferenceBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
import spoon.reflect.code.CtLocalVariable;
import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.ModifierKind;
import spoon.reflect.internal.CtCircularTypeReference;
import spoon.reflect.reference.CtArrayTypeReference;
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.reflect.reference.CtExecutableReference;
Expand Down Expand Up @@ -464,7 +463,6 @@ CtTypeReference<Object> getTypeParameterReference(TypeBinding binding, TypeRefer
typeParameterRef.setSimpleName(ctRef.getSimpleName());
typeParameterRef.setDeclaringType(ctRef.getDeclaringType());
typeParameterRef.setPackage(ctRef.getPackage());
typeParameterRef.setActualTypeArguments(ctRef.getActualTypeArguments());
ctRef = typeParameterRef;
}
insertGenericTypesInNoClasspathFromJDTInSpoon(ref, ctRef);
Expand Down Expand Up @@ -580,16 +578,17 @@ private <T> CtTypeReference<T> getTypeReference(String name) {
* Try to build a CtTypeParameterReference from a single name with specified generic types but
* keep in mind that if you give wrong data in the strong, reference will be wrong.
*/
private CtTypeParameterReference getTypeParameterReference(String name) {
CtTypeParameterReference param = this.jdtTreeBuilder.getFactory().Core().createTypeParameterReference();
private CtTypeReference<Object> getTypeParameterReference(String name) {
CtTypeReference<Object> param = null;
if (name.contains("extends") || name.contains("super")) {
String[] split = name.contains("extends") ? name.split("extends") : name.split("super");
param = getTypeParameterReference(split[0].trim());
param.setBoundingType(getTypeReference(split[split.length - 1].trim()));
((CtTypeParameterReference) param).setBoundingType(getTypeReference(split[split.length - 1].trim()));
} else if (name.matches(".*(<.+>)")) {
Pattern pattern = Pattern.compile("([^<]+)<(.+)>");
Matcher m = pattern.matcher(name);
if (m.find()) {
param = this.jdtTreeBuilder.getFactory().Core().createTypeReference();
param.setSimpleName(m.group(1));
final String[] split = m.group(2).split(",");
for (String parameter : split) {
Expand All @@ -599,6 +598,7 @@ private CtTypeParameterReference getTypeParameterReference(String name) {
} else if (name.contains("?")) {
param = this.jdtTreeBuilder.getFactory().Core().createWildcardReference();
} else {
param = this.jdtTreeBuilder.getFactory().Core().createTypeParameterReference();
param.setSimpleName(name);
}
return param;
Expand Down Expand Up @@ -717,8 +717,7 @@ <T> CtTypeReference<T> getTypeReference(TypeBinding binding) {

if (((WildcardBinding) binding).bound != null && ref instanceof CtTypeParameterReference) {
if (bindingCache.containsKey(((WildcardBinding) binding).bound)) {
final CtCircularTypeReference circularRef = getCtCircularTypeReference(((WildcardBinding) binding).bound);
((CtTypeParameterReference) ref).setBoundingType(circularRef);
((CtTypeParameterReference) ref).setBoundingType(getCtCircularTypeReference(((WildcardBinding) binding).bound));
} else {
((CtTypeParameterReference) ref).setBoundingType(getTypeReference(((WildcardBinding) binding).bound));
}
Expand Down Expand Up @@ -790,15 +789,8 @@ <T> CtTypeReference<T> getTypeReference(TypeBinding binding) {
return (CtTypeReference<T>) ref;
}

private CtCircularTypeReference getCtCircularTypeReference(TypeBinding b) {
final CtCircularTypeReference circularRef = this.jdtTreeBuilder.getFactory().Internal().createCircularTypeReference();
final CtTypeReference originalRef = bindingCache.get(b).clone();
circularRef.setPackage(originalRef.getPackage());
circularRef.setSimpleName(originalRef.getSimpleName());
circularRef.setDeclaringType(originalRef.getDeclaringType());
circularRef.setActualTypeArguments(originalRef.getActualTypeArguments());
circularRef.setAnnotations(originalRef.getAnnotations());
return circularRef;
private CtTypeReference<?> getCtCircularTypeReference(TypeBinding b) {
return bindingCache.get(b).clone();
}

@SuppressWarnings("unchecked")
Expand Down
Loading

0 comments on commit 1b758e1

Please sign in to comment.